diff --git a/base/applications/applications.rbuild b/base/applications/applications.rbuild index f4adbe4bd5a..d3c202051fb 100644 --- a/base/applications/applications.rbuild +++ b/base/applications/applications.rbuild @@ -22,6 +22,9 @@ + + + diff --git a/base/applications/charmap/precomp.h b/base/applications/charmap/precomp.h index a87f118d866..4e0324c3de5 100644 --- a/base/applications/charmap/precomp.h +++ b/base/applications/charmap/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __CHARMAP_PRECOMP_H +#define __CHARMAP_PRECOMP_H #include #include @@ -52,3 +53,5 @@ VOID ShowAboutDlg(HWND hWndParent); BOOL RegisterMapClasses(HINSTANCE hInstance); VOID UnregisterMapClasses(HINSTANCE hInstance); + +#endif /* __CHARMAP_PRECOMP_H */ diff --git a/base/applications/cmdutils/reg/De.rc b/base/applications/cmdutils/reg/De.rc index 504359d67a6..0940640306c 100644 --- a/base/applications/cmdutils/reg/De.rc +++ b/base/applications/cmdutils/reg/De.rc @@ -35,6 +35,6 @@ STRINGTABLE STRING_SUCCESS, "Der Vorgang wurde erfolgreich abgeschlossen\n" STRING_INVALID_KEY, "Fehler: Ungültiger Schlüssel\n" STRING_INVALID_CMDLINE, "Fehler: Ungültige Befehlszeilenargumente\n" - STRING_NO_REMOTE, "Fehler: Konnte Schlüssel nicht zum entfernten Rechner hinzufügen\n" + STRING_NO_REMOTE, "Fehler: Konnte Schlüssel nicht zum remote Rechner hinzufügen\n" STRING_CANNOT_FIND, "Fehler: Der angegebene Schlüssel oder Wert konnte nicht gefunden werden\n" } diff --git a/base/applications/cmdutils/reg/It.rc b/base/applications/cmdutils/reg/It.rc new file mode 100644 index 00000000000..09d38fd4025 --- /dev/null +++ b/base/applications/cmdutils/reg/It.rc @@ -0,0 +1,40 @@ +/* + * REG.EXE - Wine-compatible reg program. + * Italian language support + * + * Copyright 2010 Luca Bennati + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "reg.h" + +/*UTF-8*/ +#pragma code_page(65001) + +LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL + +STRINGTABLE +{ + STRING_USAGE, "La sintassi di questo comando è:\n\nREG [ ADD | DELETE | QUERY ]\nREG comando /?\n" + STRING_ADD_USAGE, "REG ADD nome_della_chiave [/v nome_del_valore | /ve] [/t tipo] [/s separatore] [/d dati] [/f]\n" + STRING_DELETE_USAGE, "REG DELETE nome_della_chiave [/v nome_del_valore | /ve | /va] [/f]\n" + STRING_QUERY_USAGE, "REG QUERY nome_della_chiave [/v nome_del_valore | /ve] [/s]\n" + STRING_SUCCESS, "Operazione completata con successo\n" + STRING_INVALID_KEY, "Errore: nome della chiave non valido\n" + STRING_INVALID_CMDLINE, "Errore: parametri della linea di comando non validi\n" + STRING_NO_REMOTE, "Errore: Impossibile aggiungere chiavi alla macchina remota\n" + STRING_CANNOT_FIND, "Errore: Il sistema non è riuscito a trovare la chiave di registro o il valore specificati\n" +} diff --git a/base/applications/cmdutils/reg/Uk.rc b/base/applications/cmdutils/reg/Uk.rc new file mode 100644 index 00000000000..70c86f70cb9 --- /dev/null +++ b/base/applications/cmdutils/reg/Uk.rc @@ -0,0 +1,43 @@ +/* + * REG.EXE - Wine-compatible reg program. + * + * Copyright 2008 Andrew Riedi + * + * Ukrainian language support + * + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "reg.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE +{ + STRING_USAGE, "Синтаксис цієї команди наступний:\n\nREG [ ADD | DELETE | QUERY ]\nREG command /?\n" + STRING_ADD_USAGE, "REG ADD key_name [/v value_name | /ve] [/t type] [/s separator] [/d data] [/f]\n" + STRING_DELETE_USAGE, "REG DELETE key_name [/v value_name | /ve | /va] [/f]\n" + STRING_QUERY_USAGE, "REG QUERY key_name [/v value_name | /ve] [/s]\n" + STRING_SUCCESS, "Операція успішно завершена\n" + STRING_INVALID_KEY, "Помилка: неправильне ім'я ключа\n" + STRING_INVALID_CMDLINE, "Помилка: неправильні параметри командного рядка\n" + STRING_NO_REMOTE, "Помилка: неможливо додати ключі на віддаленій машині\n" + STRING_CANNOT_FIND, "Помилка: не вдалось знайти вказаний ключ реєстру чи значення\n" +} diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c index 07dbdbff367..f65a3c8bc93 100644 --- a/base/applications/cmdutils/reg/reg.c +++ b/base/applications/cmdutils/reg/reg.c @@ -124,6 +124,21 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r lstrcpyW((LPWSTR)out_data,data); break; } + case REG_DWORD: + { + LPWSTR rest; + DWORD val; + val = strtolW(data, &rest, 0); + if (rest == data) { + static const WCHAR nonnumber[] = {'E','r','r','o','r',':',' ','/','d',' ','r','e','q','u','i','r','e','s',' ','n','u','m','b','e','r','.','\n',0}; + reg_printfW(nonnumber); + break; + } + *reg_count = sizeof(DWORD); + out_data = HeapAlloc(GetProcessHeap(),0,*reg_count); + ((LPDWORD)out_data)[0] = val; + break; + } default: { static const WCHAR unhandled[] = {'U','n','h','a','n','d','l','e','d',' ','T','y','p','e',' ','0','x','%','x',' ',' ','d','a','t','a',' ','%','s','\n',0}; diff --git a/base/applications/cmdutils/reg/rsrc.rc b/base/applications/cmdutils/reg/rsrc.rc index 1ab7f7f3b97..c145fe91a21 100644 --- a/base/applications/cmdutils/reg/rsrc.rc +++ b/base/applications/cmdutils/reg/rsrc.rc @@ -1,13 +1,17 @@ #include "Da.rc" -#include "De.rc" #include "En.rc" -#include "Fr.rc" -#include "Ja.rc" -//#include "Ko.rc" -#include "Lt.rc" +#include "Ko.rc" #include "Nl.rc" +#include "Pl.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "It.rc" +#include "Ja.rc" +#include "Lt.rc" #include "No.rc" -//#include "Pl.rc" #include "Pt.rc" #include "Ru.rc" #include "Si.rc" +#include "Uk.rc" diff --git a/base/applications/cmdutils/xcopy/De.rc b/base/applications/cmdutils/xcopy/De.rc index 3d15e780f6e..cd6e1b91384 100644 --- a/base/applications/cmdutils/xcopy/De.rc +++ b/base/applications/cmdutils/xcopy/De.rc @@ -80,4 +80,3 @@ Mit:\n\ \t\tQuelldateien kopiert, die neuer sind als die Zieldatei\n\n" } -#pragma code_page(default) diff --git a/base/applications/cmdutils/xcopy/Fr.rc b/base/applications/cmdutils/xcopy/Fr.rc index b4e387eb17c..047b4b3f739 100644 --- a/base/applications/cmdutils/xcopy/Fr.rc +++ b/base/applications/cmdutils/xcopy/Fr.rc @@ -81,4 +81,3 @@ où :\n\ \t\tque le fichier source\n\n" } -#pragma code_page(default) diff --git a/base/applications/cmdutils/xcopy/It.rc b/base/applications/cmdutils/xcopy/It.rc index 84ca52ca911..258cb3f4a7b 100644 --- a/base/applications/cmdutils/xcopy/It.rc +++ b/base/applications/cmdutils/xcopy/It.rc @@ -81,4 +81,3 @@ Dove:\n\ \t\tdella sorgente\n\n" } -#pragma code_page(default) diff --git a/base/applications/cmdutils/xcopy/Ja.rc b/base/applications/cmdutils/xcopy/Ja.rc index 1c4fe12b406..38487af8256 100644 --- a/base/applications/cmdutils/xcopy/Ja.rc +++ b/base/applications/cmdutils/xcopy/Ja.rc @@ -81,4 +81,3 @@ XCOPY 送り元 [送り先] [/I] [/S] [/Q] [/F] [/L] [/W] [/T] [/N] [/U]\n\ \t\tコピー先がコピー元より古いファイルだけコピーします。\n\n" } -#pragma code_page(default) diff --git a/base/applications/cmdutils/xcopy/Lt.rc b/base/applications/cmdutils/xcopy/Lt.rc index f1254b61921..9d431de08fa 100644 --- a/base/applications/cmdutils/xcopy/Lt.rc +++ b/base/applications/cmdutils/xcopy/Lt.rc @@ -81,4 +81,3 @@ Kur:\n\ \t\tsenesnis už šaltinio failą\n\n" } -#pragma code_page(default) diff --git a/base/applications/cmdutils/xcopy/Nl.rc b/base/applications/cmdutils/xcopy/Nl.rc index 868475e958b..4f5dee58b59 100644 --- a/base/applications/cmdutils/xcopy/Nl.rc +++ b/base/applications/cmdutils/xcopy/Nl.rc @@ -79,4 +79,3 @@ Parameters:\n\ \t\tdatum. Als geen detum wordt gegeven, copiëer alleen als bron nieuwer is.\n\n" } -#pragma code_page(default) diff --git a/base/applications/cmdutils/xcopy/Ru.rc b/base/applications/cmdutils/xcopy/Ru.rc index 4339e80dc72..154c999d357 100644 --- a/base/applications/cmdutils/xcopy/Ru.rc +++ b/base/applications/cmdutils/xcopy/Ru.rc @@ -84,4 +84,3 @@ XCOPY source [dest] [/I] [/S] [/Q] [/F] [/L] [/W] [/T] [/N] [/U]\n\ после указанной даты. Если дата не указана, копирует только\n\ те файлы, которые новее в исходной папке.\n" } -#pragma code_page(default) diff --git a/base/applications/cmdutils/xcopy/Si.rc b/base/applications/cmdutils/xcopy/Si.rc index 8e45d498b99..1013837f402 100644 --- a/base/applications/cmdutils/xcopy/Si.rc +++ b/base/applications/cmdutils/xcopy/Si.rc @@ -80,4 +80,3 @@ Where:\n\ \t\tod izvora\n\n" } -#pragma code_page(default) diff --git a/base/applications/cmdutils/xcopy/Uk.rc b/base/applications/cmdutils/xcopy/Uk.rc index d25e6483dcf..6d59e1bfac6 100644 --- a/base/applications/cmdutils/xcopy/Uk.rc +++ b/base/applications/cmdutils/xcopy/Uk.rc @@ -82,4 +82,3 @@ Where:\n\ \t\tthan source\n\n" } -#pragma code_page(default) diff --git a/base/applications/cmdutils/xcopy/rsrc.rc b/base/applications/cmdutils/xcopy/rsrc.rc index 6d7817cf4cd..b82341cda08 100644 --- a/base/applications/cmdutils/xcopy/rsrc.rc +++ b/base/applications/cmdutils/xcopy/rsrc.rc @@ -27,17 +27,19 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include #include "Da.rc" -#include "De.rc" #include "En.rc" -#include "Fr.rc" -#include "It.rc" -#include "Ja.rc" #include "Ko.rc" -#include "Lt.rc" -#include "Nl.rc" #include "No.rc" #include "Pl.rc" #include "Pt.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "It.rc" +#include "Ja.rc" +#include "Lt.rc" +#include "Nl.rc" #include "Ru.rc" #include "Si.rc" #include "Uk.rc" diff --git a/base/applications/extrac32/extrac32.c b/base/applications/extrac32/extrac32.c new file mode 100644 index 00000000000..fc1ae1c94ae --- /dev/null +++ b/base/applications/extrac32/extrac32.c @@ -0,0 +1,179 @@ +/* + * Extract - Wine-compatible program for extract *.cab files. + * + * Copyright 2007 Etersoft (Lyutin Anatoly) + * Copyright 2009 Ilya Shpigor + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include + +#include "wine/unicode.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(extrac32); + +static BOOL force_mode; + +static UINT WINAPI ExtCabCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2) +{ + FILE_IN_CABINET_INFO_W *pInfo; + FILEPATHS_W *pFilePaths; + + switch(Notification) + { + case SPFILENOTIFY_FILEINCABINET: + pInfo = (FILE_IN_CABINET_INFO_W*)Param1; + lstrcpyW(pInfo->FullTargetName, (LPCWSTR)Context); + lstrcatW(pInfo->FullTargetName, pInfo->NameInCabinet); + return FILEOP_DOIT; + case SPFILENOTIFY_FILEEXTRACTED: + pFilePaths = (FILEPATHS_W*)Param1; + WINE_TRACE("Extracted %s\n", wine_dbgstr_w(pFilePaths->Target)); + return NO_ERROR; + } + return NO_ERROR; +} + +static void extract(LPCWSTR cabfile, LPWSTR destdir) +{ + if (!SetupIterateCabinetW(cabfile, 0, ExtCabCallback, destdir)) + WINE_ERR("Could not extract cab file %s\n", wine_dbgstr_w(cabfile)); +} + +static void copy_file(LPCWSTR source, LPCWSTR destination) +{ + WCHAR destfile[MAX_PATH]; + + /* append source filename if destination is a directory */ + if (PathIsDirectoryW(destination)) + { + PathCombineW(destfile, destination, PathFindFileNameW(source)); + destination = destfile; + } + + if (PathFileExistsW(destination) && !force_mode) + { + static const WCHAR overwriteMsg[] = {'O','v','e','r','w','r','i','t','e',' ','"','%','s','"','?',0}; + static const WCHAR titleMsg[] = {'E','x','t','r','a','c','t',0}; + WCHAR msg[MAX_PATH+100]; + snprintfW(msg, sizeof(msg)/sizeof(msg[0]), overwriteMsg, destination); + if (MessageBoxW(NULL, msg, titleMsg, MB_YESNO | MB_ICONWARNING) != IDYES) + return; + } + + WINE_TRACE("copying %s to %s\n", wine_dbgstr_w(source), wine_dbgstr_w(destination)); + CopyFileW(source, destination, FALSE); +} + +int PASCAL wWinMain(HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmdline, int show) +{ + LPWSTR *argv; + int argc; + int i; + WCHAR check, cmd = 0; + WCHAR path[MAX_PATH]; + WCHAR backslash[] = {'\\',0}; + LPCWSTR cabfile = NULL; + + path[0] = 0; + argv = CommandLineToArgvW(cmdline, &argc); + + if(!argv) + { + WINE_ERR("Bad command line arguments\n"); + return 0; + } + + /* Parse arguments */ + for(i = 0; i < argc; i++) + { + /* Get cabfile */ + if (argv[i][0] != '/') + { + if (!cabfile) + { + cabfile = argv[i]; + continue; + } else + break; + } + /* Get parameters for commands */ + check = toupperW( argv[i][1] ); + switch(check) + { + case 'A': + WINE_FIXME("/A not implemented\n"); + break; + case 'Y': + force_mode = TRUE; + break; + case 'L': + if ((i + 1) >= argc) return 0; + if (!GetFullPathNameW(argv[++i], MAX_PATH, path, NULL)) + return 0; + break; + case 'C': + if (cmd) return 0; + cmd = check; + break; + case 'E': + case 'D': + if (cmd) return 0; + cmd = check; + break; + default: + return 0; + } + } + + if (!cabfile) + return 0; + + if (cmd == 'C') + { + if ((i + 1) != argc) return 0; + if (!GetFullPathNameW(argv[i], MAX_PATH, path, NULL)) + return 0; + } + + if (!path[0]) + GetCurrentDirectoryW(MAX_PATH, path); + + lstrcatW(path, backslash); + + /* Execute the specified command */ + switch(cmd) + { + case 'C': + /* Copy file */ + copy_file(cabfile, path); + break; + case 'E': + /* Extract CAB archive */ + extract(cabfile, path); + break; + case 0: + case 'D': + /* Display CAB archive */ + WINE_FIXME("/D not implemented\n"); + break; + } + return 0; +} diff --git a/base/applications/extrac32/extrac32.rbuild b/base/applications/extrac32/extrac32.rbuild new file mode 100644 index 00000000000..24532ddfd3d --- /dev/null +++ b/base/applications/extrac32/extrac32.rbuild @@ -0,0 +1,9 @@ + + . + wine + shell32 + setupapi + shlwapi + user32 + extrac32.c + diff --git a/base/applications/mscutils/devmgmt/precomp.h b/base/applications/mscutils/devmgmt/precomp.h index 8723d8d1d55..d9bdd425f85 100644 --- a/base/applications/mscutils/devmgmt/precomp.h +++ b/base/applications/mscutils/devmgmt/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __DEVMGMT_PRECOMP_H +#define __DEVMGMT_PRECOMP_H #define WIN32_LEAN_AND_MEAN #include @@ -92,3 +93,5 @@ HIMAGELIST InitImageList(UINT NumButtons, VOID GetError(VOID); VOID DisplayString(LPTSTR); + +#endif /* __DEVMGMT_PRECOMP_H */ diff --git a/base/applications/mscutils/servman/precomp.h b/base/applications/mscutils/servman/precomp.h index a81b984c7d3..9b829ad78df 100644 --- a/base/applications/mscutils/servman/precomp.h +++ b/base/applications/mscutils/servman/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __SERVMAN_PRECOMP_H +#define __SERVMAN_PRECOMP_H //#define WIN32_LEAN_AND_MEAN #include @@ -184,3 +185,5 @@ HIMAGELIST InitImageList(UINT StartResource, UINT Width, UINT Height, ULONG type); + +#endif /* __SERVMAN_PRECOMP_H */ diff --git a/base/applications/paint/lang/pl-PL.rc b/base/applications/paint/lang/pl-PL.rc index 3449a3add71..b37039a4def 100644 --- a/base/applications/paint/lang/pl-PL.rc +++ b/base/applications/paint/lang/pl-PL.rc @@ -49,7 +49,7 @@ BEGIN MENUITEM SEPARATOR POPUP "Powikszenie" BEGIN - POPUP "User defined" + POPUP "Zdefiniowane przez uytkownika" BEGIN MENUITEM "12,5%", IDM_VIEWZOOM125 MENUITEM "25%", IDM_VIEWZOOM25 @@ -60,8 +60,8 @@ BEGIN MENUITEM "800%", IDM_VIEWZOOM800 END MENUITEM SEPARATOR - MENUITEM "Show grid", IDM_VIEWSHOWGRID - MENUITEM "Show miniature", IDM_VIEWSHOWMINIATURE + MENUITEM "Poka siatk", IDM_VIEWSHOWGRID + MENUITEM "Poka miniatur", IDM_VIEWSHOWMINIATURE END MENUITEM "Peny ekran\tCtrl+F", IDM_VIEWFULLSCREEN END @@ -181,7 +181,7 @@ BEGIN IDS_INFOTEXT, "Paint dla ReactOS jest dostpny na licencji GNU Lesser General Public License (LGPL) wersja 3 (www.gnu.org)" IDS_SAVEPROMPTTEXT, "Czy chcesz zapisa zmiany do %s?" IDS_DEFAULTFILENAME, "Nienazwany.bmp" - IDS_MINIATURETITLE, "Miniature" + IDS_MINIATURETITLE, "Miniatura" IDS_TOOLTIP1, "Zaznaczenie dowolne" IDS_TOOLTIP2, "Zaznaczenie" IDS_TOOLTIP3, "Gumka" @@ -190,16 +190,16 @@ BEGIN IDS_TOOLTIP6, "Przyblienie" IDS_TOOLTIP7, "Owek" IDS_TOOLTIP8, "Pdzel" - IDS_TOOLTIP9, "Spray" + IDS_TOOLTIP9, "Aerograf" IDS_TOOLTIP10, "Tekst" IDS_TOOLTIP11, "Linia" IDS_TOOLTIP12, "Krzywa Beziera" IDS_TOOLTIP13, "Prostokt" - IDS_TOOLTIP14, "Polygon" + IDS_TOOLTIP14, "Wielokt" IDS_TOOLTIP15, "Elipsa" IDS_TOOLTIP16, "Zaokrglony Prostokt" IDS_OPENFILTER, "Pliki Bitmapy (*.bmp;*.dib)\1*.bmp;*.dib\1Wszystkie pliki (*.*)\1*.*\1" IDS_SAVEFILTER, "Bitmapa 24 bit (*.bmp;*.dib)\1*.bmp;*.dib\1" - IDS_FILESIZE, "%d bytes" - IDS_PRINTRES, "%d x %d pixels per meter" + IDS_FILESIZE, "%d bajtw" + IDS_PRINTRES, "%d x %d pikseli na metr" END diff --git a/base/applications/rapps/lang/pl-PL.rc b/base/applications/rapps/lang/pl-PL.rc index fc79e8a205b..60fd20b7530 100644 --- a/base/applications/rapps/lang/pl-PL.rc +++ b/base/applications/rapps/lang/pl-PL.rc @@ -16,7 +16,7 @@ BEGIN MENUITEM "&Odinstaluj",ID_UNINSTALL MENUITEM "&Modyfikuj", ID_MODIFY MENUITEM SEPARATOR - MENUITEM "&Remove from Registry", ID_REGREMOVE + MENUITEM "&Usu z rejestru", ID_REGREMOVE MENUITEM SEPARATOR MENUITEM "O&dwie", ID_REFRESH END @@ -44,7 +44,7 @@ BEGIN MENUITEM "&odinstaluj", ID_UNINSTALL MENUITEM "&Modyfikuj", ID_MODIFY MENUITEM SEPARATOR - MENUITEM "&Remove from Registry", ID_REGREMOVE + MENUITEM "&Usu z rejestru", ID_REGREMOVE MENUITEM SEPARATOR MENUITEM "&Odwie", ID_REFRESH END @@ -52,37 +52,37 @@ END IDD_SETTINGS_DIALOG DIALOGEX DISCARDABLE 0, 0, 250, 144 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Settings" +CAPTION "Ustawienia" FONT 8, "MS Shell Dlg" BEGIN - GROUPBOX "General", -1, 4, 2, 240, 61 - AUTOCHECKBOX "&Save window position", IDC_SAVE_WINDOW_POS, 15, 12, 219, 12 - AUTOCHECKBOX "&Update the list of accessible programs at start", IDC_UPDATE_AVLIST, 15, 29, 219, 12 - AUTOCHECKBOX "&Log of installation and removal of programs", IDC_LOG_ENABLED, 15, 46, 219, 12 + GROUPBOX "Oglne", -1, 4, 2, 240, 61 + AUTOCHECKBOX "&Zapisz pozycj okna", IDC_SAVE_WINDOW_POS, 15, 12, 219, 12 + AUTOCHECKBOX "&Aktualizuj list dostpnych programw przy kadym uruchomieniu", IDC_UPDATE_AVLIST, 15, 29, 219, 12 + AUTOCHECKBOX "Zap&isuj dziennik instalacji i usuwania programw", IDC_LOG_ENABLED, 15, 46, 219, 12 - GROUPBOX "Downloading", -1, 4, 65, 240, 51 - LTEXT "Folder for downloadings:", -1, 16, 75, 100, 9 + GROUPBOX "Pobieranie", -1, 4, 65, 240, 51 + LTEXT "Katalog dla pobranych plikw:", -1, 16, 75, 100, 9 EDITTEXT IDC_DOWNLOAD_DIR_EDIT, 15, 86, 166, 12, WS_CHILD | WS_VISIBLE | WS_GROUP - PUSHBUTTON "&Choose", IDC_CHOOSE, 187, 85, 50, 14 - AUTOCHECKBOX "&Delete installers of programs after installation", IDC_DEL_AFTER_INSTALL, 16, 100, 218, 12 + PUSHBUTTON "&Wybierz", IDC_CHOOSE, 187, 85, 50, 14 + AUTOCHECKBOX "&Usu instalatory programw po ich zainstalowaniu", IDC_DEL_AFTER_INSTALL, 16, 100, 218, 12 - PUSHBUTTON "Default", IDC_DEFAULT_SETTINGS, 8, 124, 60, 14 + PUSHBUTTON "Domylne", IDC_DEFAULT_SETTINGS, 8, 124, 60, 14 PUSHBUTTON "OK", IDOK, 116, 124, 60, 14 - PUSHBUTTON "Cancel", IDCANCEL, 181, 124, 60, 14 + PUSHBUTTON "Anuluj", IDCANCEL, 181, 124, 60, 14 END IDD_INSTALL_DIALOG DIALOGEX DISCARDABLE 0, 0, 216, 97 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Program installation" +CAPTION "Instalacja programu" FONT 8, "MS Shell Dlg" BEGIN LTEXT "...", IDC_INSTALL_TEXT, 4, 5, 209, 35 - AUTORADIOBUTTON "&Install from a disk (CD or DVD)", IDC_CD_INSTALL, 10, 46, 197, 11, WS_GROUP - AUTORADIOBUTTON "&Download and install", IDC_DOWNLOAD_INSTALL, 10, 59, 197, 11, NOT WS_TABSTOP + AUTORADIOBUTTON "&Zainstaluj z dysku (CD or DVD)", IDC_CD_INSTALL, 10, 46, 197, 11, WS_GROUP + AUTORADIOBUTTON "&Pobierz i zainstaluj", IDC_DOWNLOAD_INSTALL, 10, 59, 197, 11, NOT WS_TABSTOP PUSHBUTTON "OK", IDOK, 86, 78, 60, 14 - PUSHBUTTON "Cancel", IDCANCEL, 150, 78, 60, 14 + PUSHBUTTON "Anuluj", IDCANCEL, 150, 78, 60, 14 END IDD_DOWNLOAD_DIALOG DIALOGEX LOADONCALL MOVEABLE DISCARDABLE 0, 0, 220, 76 @@ -101,7 +101,7 @@ CAPTION "O programie" FONT 8, "MS Shell Dlg" BEGIN LTEXT "ReactOS Applications Manager\nCopyright (C) 2009\nby Dmitry Chapyshev (dmitry@reactos.org)", IDC_STATIC, 48, 7, 130, 39 - PUSHBUTTON "Close", IDOK, 133, 46, 50, 14 + PUSHBUTTON "Zamknij", IDOK, 133, 46, 50, 14 ICON IDI_MAIN, IDC_STATIC, 10, 10, 7, 30 END @@ -139,7 +139,7 @@ BEGIN IDS_INFO_INSTLOCATION "\nScieka instalacji: " IDS_INFO_INSTALLSRC "\nrdo instalacji: " IDS_INFO_UNINSTALLSTR "\nKomenda deinstalacji: " - IDS_INFO_MODIFYPATH "\nModify Path: " + IDS_INFO_MODIFYPATH "\nModyfikacja cieki instalacji: " IDS_INFO_INSTALLDATE "\nData instalacji: " END @@ -186,10 +186,10 @@ BEGIN IDS_AVAILABLEFORINST "Dostpne" IDS_UPDATES "Uaktualnienia" IDS_APPLICATIONS "Aplikacje" - IDS_CHOOSE_FOLDER_TEXT "Choose a folder which will be used for downloading of programs:" - IDS_CHOOSE_FOLDER_ERROR "You have specified a nonexistent folder!" - IDS_USER_NOT_ADMIN "You should be administrator for start ""ReactOS Applications Manager""!" - IDS_APP_REG_REMOVE "Are you sure you want to delete the data on the installed program from the registry?" - IDS_INFORMATION "Information" - IDS_UNABLE_TO_REMOVE "Unable to remove data on the program from the registry!" + IDS_CHOOSE_FOLDER_TEXT "Wybierz katalog w ktrym bda zapisywane pobrane programy:" + IDS_CHOOSE_FOLDER_ERROR "Wybrae nieistniejcy katalog!" + IDS_USER_NOT_ADMIN "Musisz mie uprawnienia administratora aby uruchomi ""ReactOS Applications Manager""!" + IDS_APP_REG_REMOVE "Czy na pewno chcesz usun wpis tego programu z rejestru?" + IDS_INFORMATION "Informacja" + IDS_UNABLE_TO_REMOVE "Nie mona byo usun wpisu z rejestru!" END diff --git a/base/applications/rapps/rapps.h b/base/applications/rapps/rapps.h index 5401b37a317..cba76db823a 100644 --- a/base/applications/rapps/rapps.h +++ b/base/applications/rapps/rapps.h @@ -11,7 +11,7 @@ #include "resource.h" -#define APPLICATION_DATEBASE_URL L"http://opendn.org/rappmgr.cab" +#define APPLICATION_DATEBASE_URL L"http://svn.reactos.org/packages/rappmgr.cab" #define SPLIT_WIDTH 4 #define MAX_STR_LEN 256 diff --git a/base/applications/taskmgr/precomp.h b/base/applications/taskmgr/precomp.h index 67272472a48..c30856b3065 100644 --- a/base/applications/taskmgr/precomp.h +++ b/base/applications/taskmgr/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __PRECOMP_H +#define __PRECOMP_H #ifndef UNICODE #error Task-Manager uses NDK functions, so it can only be compiled with Unicode support enabled! @@ -35,3 +36,5 @@ #include "priority.h" #include "run.h" #include "trayicon.h" + +#endif /* __PRECOMP_H */ diff --git a/base/applications/winhlp32/De.rc b/base/applications/winhlp32/De.rc index 0ec40add40f..2e14f70ad84 100644 --- a/base/applications/winhlp32/De.rc +++ b/base/applications/winhlp32/De.rc @@ -128,4 +128,3 @@ END MENUITEM "Systemfarben verwenden", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/base/applications/winhlp32/Fr.rc b/base/applications/winhlp32/Fr.rc index 2199e37ab9e..cedb0f694b7 100644 --- a/base/applications/winhlp32/Fr.rc +++ b/base/applications/winhlp32/Fr.rc @@ -131,4 +131,3 @@ BEGIN MENUITEM "Utiliser les couleurs système", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/base/applications/winhlp32/It.rc b/base/applications/winhlp32/It.rc index cd16e4058bf..b5c53929bf4 100644 --- a/base/applications/winhlp32/It.rc +++ b/base/applications/winhlp32/It.rc @@ -89,4 +89,3 @@ STID_FILE_NOT_FOUND_s "Non è stato possibile trovare '%s'. Vuoi cercare questo STID_NO_RICHEDIT "Non è stato possibile trovare un'implementazione richedit... Annullando" STID_PSH_INDEX, "Argomenti di aiuto: " } -#pragma code_page(default) diff --git a/base/applications/winhlp32/Ja.rc b/base/applications/winhlp32/Ja.rc index a06b5f1df65..b73d18dd192 100644 --- a/base/applications/winhlp32/Ja.rc +++ b/base/applications/winhlp32/Ja.rc @@ -128,4 +128,3 @@ BEGIN MENUITEM "システム カラーを使う", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/base/applications/winhlp32/Lt.rc b/base/applications/winhlp32/Lt.rc index 5ee53f8aa16..f8e78681aae 100644 --- a/base/applications/winhlp32/Lt.rc +++ b/base/applications/winhlp32/Lt.rc @@ -129,4 +129,3 @@ BEGIN MENUITEM "Naudoti sistemos spalvas", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/base/applications/winhlp32/Nl.rc b/base/applications/winhlp32/Nl.rc index a7938406b65..029d58265b9 100644 --- a/base/applications/winhlp32/Nl.rc +++ b/base/applications/winhlp32/Nl.rc @@ -127,4 +127,3 @@ BEGIN MENUITEM "Gebruik systeem kleuren", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/base/applications/winhlp32/Pt.rc b/base/applications/winhlp32/Pt.rc index 5598bd77cd6..28933a22a6f 100644 --- a/base/applications/winhlp32/Pt.rc +++ b/base/applications/winhlp32/Pt.rc @@ -204,4 +204,3 @@ BEGIN MENUITEM "Usar cores do sistema", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/base/applications/winhlp32/Rm.rc b/base/applications/winhlp32/Rm.rc index 17293875f99..3b2a1fa9403 100644 --- a/base/applications/winhlp32/Rm.rc +++ b/base/applications/winhlp32/Rm.rc @@ -92,4 +92,3 @@ STID_FILE_NOT_FOUND_s "Cannot find '%s'. Do you want to find this file yoursel STID_NO_RICHEDIT "Cannot find a richedit implementation... Aborting" STID_PSH_INDEX, "Help topics: " } -#pragma code_page(default) diff --git a/base/applications/winhlp32/Ro.rc b/base/applications/winhlp32/Ro.rc index eaa530bc5bb..1f916ac21d5 100644 --- a/base/applications/winhlp32/Ro.rc +++ b/base/applications/winhlp32/Ro.rc @@ -130,4 +130,3 @@ BEGIN MENUITEM "Utilizează culorile sistemului", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/base/applications/winhlp32/Ru.rc b/base/applications/winhlp32/Ru.rc index a476b344c6c..165094f4720 100644 --- a/base/applications/winhlp32/Ru.rc +++ b/base/applications/winhlp32/Ru.rc @@ -121,4 +121,3 @@ BEGIN MENUITEM "Использовать системные цвета", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/base/applications/winhlp32/Si.rc b/base/applications/winhlp32/Si.rc index 310ef45a8f7..527b45431ee 100644 --- a/base/applications/winhlp32/Si.rc +++ b/base/applications/winhlp32/Si.rc @@ -126,4 +126,3 @@ BEGIN MENUITEM "Uporabi sistemske barve", MNID_CTXT_SYSTEM_COLORS END END -#pragma code_page(default) diff --git a/base/applications/winhlp32/Zh.rc b/base/applications/winhlp32/Zh.rc index a68b699c44f..ed20356cf47 100644 --- a/base/applications/winhlp32/Zh.rc +++ b/base/applications/winhlp32/Zh.rc @@ -160,4 +160,3 @@ STID_FILE_NOT_FOUND_s "不能開啟檔案 '%s'. 你想要自己找這個檔案 STID_NO_RICHEDIT "找不到 richedit... 終止" STID_PSH_INDEX, "幫助內容: " } -#pragma code_page(default) diff --git a/base/applications/winhlp32/rsrc.rc b/base/applications/winhlp32/rsrc.rc index e45fc8a7ce5..28d8de35fe3 100644 --- a/base/applications/winhlp32/rsrc.rc +++ b/base/applications/winhlp32/rsrc.rc @@ -27,25 +27,27 @@ IDI_WINHELP ICON DISCARDABLE winhelp.ico #include "Bg.rc" #include "Cs.rc" #include "Da.rc" -#include "De.rc" #include "En.rc" #include "Es.rc" #include "Fi.rc" -#include "Fr.rc" #include "Hu.rc" -#include "It.rc" -#include "Ja.rc" #include "Ko.rc" -#include "Lt.rc" -#include "Nl.rc" #include "No.rc" #include "Pl.rc" +#include "Sk.rc" +#include "Sv.rc" +#include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "It.rc" +#include "Ja.rc" +#include "Lt.rc" +#include "Nl.rc" #include "Pt.rc" #include "Rm.rc" #include "Ro.rc" #include "Ru.rc" #include "Si.rc" -#include "Sk.rc" -#include "Sv.rc" -#include "Tr.rc" #include "Zh.rc" diff --git a/base/applications/wordpad/Da.rc b/base/applications/wordpad/Da.rc index 8d035955bd2..882cca7e8d8 100644 --- a/base/applications/wordpad/Da.rc +++ b/base/applications/wordpad/Da.rc @@ -106,6 +106,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Sort", ID_COLOR_BLACK + MENUITEM "Mrkerd", ID_COLOR_MAROON + MENUITEM "Grn", ID_COLOR_GREEN + MENUITEM "Oliven" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Lilla" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Gr" ID_COLOR_GRAY + MENUITEM "Slv" ID_COLOR_SILVER + MENUITEM "Rd" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Gul" ID_COLOR_YELLOW + MENUITEM "Bl" ID_COLOR_BLUE + MENUITEM "Violet" ID_COLOR_FUCHSIA + MENUITEM "Cyan" ID_COLOR_AQUA + MENUITEM "Hvid" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Dato og tid" @@ -221,6 +245,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Luk" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/base/applications/wordpad/De.rc b/base/applications/wordpad/De.rc index d552d9c21a5..ca11edd8bea 100644 --- a/base/applications/wordpad/De.rc +++ b/base/applications/wordpad/De.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Schwarz" ID_COLOR_BLACK + MENUITEM "Kastanienbraun" ID_COLOR_MAROON + MENUITEM "Grün" ID_COLOR_GREEN + MENUITEM "Olivgrün" ID_COLOR_OLIVE + MENUITEM "Dunkelblau" ID_COLOR_NAVY + MENUITEM "Lila" ID_COLOR_PURPLE + MENUITEM "Blaugrün" ID_COLOR_TEAL + MENUITEM "Grau" ID_COLOR_GRAY + MENUITEM "Silber" ID_COLOR_SILVER + MENUITEM "Rot" ID_COLOR_RED + MENUITEM "Hellgrün" ID_COLOR_LIME + MENUITEM "Gelb" ID_COLOR_YELLOW + MENUITEM "Blau" ID_COLOR_BLUE + MENUITEM "Pink" ID_COLOR_FUCHSIA + MENUITEM "Aquamarin" ID_COLOR_AQUA + MENUITEM "Weiß" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Datum und Uhrzeit" @@ -218,9 +242,13 @@ BEGIN STRING_PREVIEW_PRINT, "&Drucken" STRING_PREVIEW_NEXTPAGE, "&Nächste" STRING_PREVIEW_PREVPAGE, "&Vorherige" - STRING_PREVIEW_TWOPAGES, "Zwei Seiten" - STRING_PREVIEW_ONEPAGE, "Eine Seite" + STRING_PREVIEW_TWOPAGES, "&Zwei Seiten" + STRING_PREVIEW_ONEPAGE, "&Eine Seite" + STRING_PREVIEW_ZOOMIN, "Ver&größern" + STRING_PREVIEW_ZOOMOUT, "Ver&kleinern" STRING_PREVIEW_CLOSE, "&Schließen" + STRING_PREVIEW_PAGE, "Seite" + STRING_PREVIEW_PAGES, "Seiten" END STRINGTABLE DISCARDABLE @@ -246,4 +274,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Drucken ist nicht implementiert" STRING_MAX_TAB_STOPS, "Es können nur maximal 32 Tabstopps definiert werden." END -#pragma code_page(default) diff --git a/base/applications/wordpad/En.rc b/base/applications/wordpad/En.rc index 7af40bda4b8..0dec19bc650 100644 --- a/base/applications/wordpad/En.rc +++ b/base/applications/wordpad/En.rc @@ -106,6 +106,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Black", ID_COLOR_BLACK + MENUITEM "Maroon", ID_COLOR_MAROON + MENUITEM "Green", ID_COLOR_GREEN + MENUITEM "Olive" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Purple" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Gray" ID_COLOR_GRAY + MENUITEM "Silver" ID_COLOR_SILVER + MENUITEM "Red" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Yellow" ID_COLOR_YELLOW + MENUITEM "Blue" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "White" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Date and time" @@ -213,6 +237,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Close" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" STRING_UNITS_CM, "cm" END diff --git a/base/applications/wordpad/Fr.rc b/base/applications/wordpad/Fr.rc index b38daad137e..54ae0b992b8 100644 --- a/base/applications/wordpad/Fr.rc +++ b/base/applications/wordpad/Fr.rc @@ -109,6 +109,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Noir" ID_COLOR_BLACK + MENUITEM "Marron" ID_COLOR_MAROON + MENUITEM "Vert" ID_COLOR_GREEN + MENUITEM "Olive" ID_COLOR_OLIVE + MENUITEM "Bleu marine" ID_COLOR_NAVY + MENUITEM "Pourpre" ID_COLOR_PURPLE + MENUITEM "Sarcelle" ID_COLOR_TEAL + MENUITEM "Gris" ID_COLOR_GRAY + MENUITEM "Argent" ID_COLOR_SILVER + MENUITEM "Rouge" ID_COLOR_RED + MENUITEM "Citron vert" ID_COLOR_LIME + MENUITEM "Jaune" ID_COLOR_YELLOW + MENUITEM "Bleu" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Eau" ID_COLOR_AQUA + MENUITEM "Blanc" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Date et heure" @@ -224,6 +248,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom avant" STRING_PREVIEW_ZOOMOUT, "Zoom arrière" STRING_PREVIEW_CLOSE, "Fermer" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "L'impression n'est pas implémentée" STRING_MAX_TAB_STOPS, "Impossible d'ajouter plus de 32 taquets de tabulation." END -#pragma code_page(default) diff --git a/base/applications/wordpad/Hu.rc b/base/applications/wordpad/Hu.rc index 1eeede3c8aa..3694062e355 100644 --- a/base/applications/wordpad/Hu.rc +++ b/base/applications/wordpad/Hu.rc @@ -106,6 +106,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Black", ID_COLOR_BLACK + MENUITEM "Maroon", ID_COLOR_MAROON + MENUITEM "Green", ID_COLOR_GREEN + MENUITEM "Olive" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Purple" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Gray" ID_COLOR_GRAY + MENUITEM "Silver" ID_COLOR_SILVER + MENUITEM "Red" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Yellow" ID_COLOR_YELLOW + MENUITEM "Blue" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "White" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Date and time" @@ -221,6 +245,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Close" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/base/applications/wordpad/It.rc b/base/applications/wordpad/It.rc index e0d3b890bc4..99968411776 100644 --- a/base/applications/wordpad/It.rc +++ b/base/applications/wordpad/It.rc @@ -110,6 +110,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Nero" ID_COLOR_BLACK + MENUITEM "Marrone rossiccio" ID_COLOR_MAROON + MENUITEM "Verde" ID_COLOR_GREEN + MENUITEM "Verde oliva" ID_COLOR_OLIVE + MENUITEM "Blu oltremare" ID_COLOR_NAVY + MENUITEM "Propora" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Grigio" ID_COLOR_GRAY + MENUITEM "Argento" ID_COLOR_SILVER + MENUITEM "Rosso" ID_COLOR_RED + MENUITEM "Verde cedro" ID_COLOR_LIME + MENUITEM "Giallo" ID_COLOR_YELLOW + MENUITEM "Blu" ID_COLOR_BLUE + MENUITEM "Fucsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "Bianco" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Data e ora" @@ -217,6 +241,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Ingrandisci" STRING_PREVIEW_ZOOMOUT, "Rimpicciolisci" STRING_PREVIEW_CLOSE, "Chiudi" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" STRING_UNITS_CM, "cm" END @@ -238,4 +264,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Stampa non implementata" STRING_MAX_TAB_STOPS, "Non si possono aggiungere più di 32 punti di fermata delle tabulazioni." END -#pragma code_page(default) diff --git a/base/applications/wordpad/Ja.rc b/base/applications/wordpad/Ja.rc index 89b4b0041e2..bd5e4c9ea94 100644 --- a/base/applications/wordpad/Ja.rc +++ b/base/applications/wordpad/Ja.rc @@ -109,6 +109,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "黒" ID_COLOR_BLACK + MENUITEM "茶色" ID_COLOR_MAROON + MENUITEM "緑" ID_COLOR_GREEN + MENUITEM "オリーブ" ID_COLOR_OLIVE + MENUITEM "紺" ID_COLOR_NAVY + MENUITEM "紫" ID_COLOR_PURPLE + MENUITEM "青緑" ID_COLOR_TEAL + MENUITEM "灰色" ID_COLOR_GRAY + MENUITEM "銀色" ID_COLOR_SILVER + MENUITEM "赤" ID_COLOR_RED + MENUITEM "黄緑" ID_COLOR_LIME + MENUITEM "黄" ID_COLOR_YELLOW + MENUITEM "青" ID_COLOR_BLUE + MENUITEM "赤紫" ID_COLOR_FUCHSIA + MENUITEM "水色" ID_COLOR_AQUA + MENUITEM "白" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "日付と時刻" @@ -224,6 +248,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "閉じる" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "プリントが実装されていません。" STRING_MAX_TAB_STOPS, "32以上なタブを追加できません。" END -#pragma code_page(default) diff --git a/base/applications/wordpad/Ko.rc b/base/applications/wordpad/Ko.rc index 20928221c02..81110831b75 100644 --- a/base/applications/wordpad/Ko.rc +++ b/base/applications/wordpad/Ko.rc @@ -107,6 +107,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "" ID_COLOR_BLACK + MENUITEM "" ID_COLOR_MAROON + MENUITEM "" ID_COLOR_GREEN + MENUITEM "ø" ID_COLOR_OLIVE + MENUITEM "£ " ID_COLOR_NAVY + MENUITEM "ȫ" ID_COLOR_PURPLE + MENUITEM " " ID_COLOR_TEAL + MENUITEM "ȸ" ID_COLOR_GRAY + MENUITEM "" ID_COLOR_SILVER + MENUITEM "" ID_COLOR_RED + MENUITEM "ӻ" ID_COLOR_LIME + MENUITEM "" ID_COLOR_YELLOW + MENUITEM "Ķ" ID_COLOR_BLUE + MENUITEM "ȫ" ID_COLOR_FUCHSIA + MENUITEM "" ID_COLOR_AQUA + MENUITEM "Ͼ" ID_COLOR_WHITE + MENUITEM "ڵ" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "¥ ð" @@ -212,10 +236,12 @@ BEGIN STRING_PREVIEW_PREVPAGE, " " STRING_PREVIEW_TWOPAGES, " " STRING_PREVIEW_ONEPAGE, " " - STRING_PREVIEW_ZOOMIN, "Zoom in" - STRING_PREVIEW_ZOOMOUT, "Zoom out" + STRING_PREVIEW_ZOOMIN, "Ȯ" + STRING_PREVIEW_ZOOMOUT, "" STRING_PREVIEW_CLOSE, "ݱ" - STRING_UNITS_CM, "cm" + STRING_PREVIEW_PAGE, "" + STRING_PREVIEW_PAGES, "" + STRING_UNITS_CM, "cm" END STRINGTABLE DISCARDABLE diff --git a/base/applications/wordpad/Lt.rc b/base/applications/wordpad/Lt.rc index a1c73126b74..c9f2571ccc1 100644 --- a/base/applications/wordpad/Lt.rc +++ b/base/applications/wordpad/Lt.rc @@ -109,6 +109,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Juoda" ID_COLOR_BLACK + MENUITEM "Kaštoninė" ID_COLOR_MAROON + MENUITEM "Žalia" ID_COLOR_GREEN + MENUITEM "Alyvinė" ID_COLOR_OLIVE + MENUITEM "Ultramarinas" ID_COLOR_NAVY + MENUITEM "Purpurinė" ID_COLOR_PURPLE + MENUITEM "Neutrali ciano" ID_COLOR_TEAL + MENUITEM "Pilka" ID_COLOR_GRAY + MENUITEM "Sidabrinė" ID_COLOR_SILVER + MENUITEM "Raudona" ID_COLOR_RED + MENUITEM "Gelsvai žalsva" ID_COLOR_LIME + MENUITEM "Geltona" ID_COLOR_YELLOW + MENUITEM "Mėlyna" ID_COLOR_BLUE + MENUITEM "Fuksija" ID_COLOR_FUCHSIA + MENUITEM "Žydra" ID_COLOR_AQUA + MENUITEM "Balta" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Data ir laikas" @@ -224,6 +248,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Didinti" STRING_PREVIEW_ZOOMOUT, "Mažinti" STRING_PREVIEW_CLOSE, "Užverti" + STRING_PREVIEW_PAGE, "Puslapis" + STRING_PREVIEW_PAGES, "Puslapiai" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Spausdinimas nerealizuotas" STRING_MAX_TAB_STOPS, "Negalima pridėti daugiau negu 32-jų tabuliavimo pozicijų." END -#pragma code_page(default) diff --git a/base/applications/wordpad/Nl.rc b/base/applications/wordpad/Nl.rc index 581855eec98..5741dbea9b7 100644 --- a/base/applications/wordpad/Nl.rc +++ b/base/applications/wordpad/Nl.rc @@ -107,6 +107,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Zwart" ID_COLOR_BLACK + MENUITEM "Kastanjebruin" ID_COLOR_MAROON + MENUITEM "Groen" ID_COLOR_GREEN + MENUITEM "Olijfgroen" ID_COLOR_OLIVE + MENUITEM "Marineblauw" ID_COLOR_NAVY + MENUITEM "Paars" ID_COLOR_PURPLE + MENUITEM "Groenblauw" ID_COLOR_TEAL + MENUITEM "Grijs" ID_COLOR_GRAY + MENUITEM "Zilver" ID_COLOR_SILVER + MENUITEM "Rood" ID_COLOR_RED + MENUITEM "Lichtgroen" ID_COLOR_LIME + MENUITEM "Geel" ID_COLOR_YELLOW + MENUITEM "Blauw" ID_COLOR_BLUE + MENUITEM "Fuchsiapaars" ID_COLOR_FUCHSIA + MENUITEM "Zeeblauw" ID_COLOR_AQUA + MENUITEM "Wit" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Datum en tijd" @@ -214,6 +238,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Sluiten" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/base/applications/wordpad/No.rc b/base/applications/wordpad/No.rc index c8086582afe..fbca2a09bee 100644 --- a/base/applications/wordpad/No.rc +++ b/base/applications/wordpad/No.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Svart" ID_COLOR_BLACK + MENUITEM "Rødbrun" ID_COLOR_MAROON + MENUITEM "Grønn" ID_COLOR_GREEN + MENUITEM "Oliven" ID_COLOR_OLIVE + MENUITEM "Marineblå" ID_COLOR_NAVY + MENUITEM "Purpur" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Grå" ID_COLOR_GRAY + MENUITEM "Sølv" ID_COLOR_SILVER + MENUITEM "Rød" ID_COLOR_RED + MENUITEM "Lime-grønn" ID_COLOR_LIME + MENUITEM "Gul" ID_COLOR_YELLOW + MENUITEM "Blå" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "Hvit" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Dato og klokkeslett" @@ -223,6 +247,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Lukk" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -248,4 +274,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Utskriftfunksjonen er ikke laget ennå." STRING_MAX_TAB_STOPS, "Kan ikke legge til mer enn 32 tabulatorstopp." END -#pragma code_page(default) diff --git a/base/applications/wordpad/Pl.rc b/base/applications/wordpad/Pl.rc index 97d7288bc4c..4d403041858 100644 --- a/base/applications/wordpad/Pl.rc +++ b/base/applications/wordpad/Pl.rc @@ -107,6 +107,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Czarny" ID_COLOR_BLACK + MENUITEM "Kasztanowy" ID_COLOR_MAROON + MENUITEM "Zielony" ID_COLOR_GREEN + MENUITEM "Oliwkowy" ID_COLOR_OLIVE + MENUITEM "Granatowy" ID_COLOR_NAVY + MENUITEM "Purpurowy" ID_COLOR_PURPLE + MENUITEM "Zielonomodry" ID_COLOR_TEAL + MENUITEM "Szary" ID_COLOR_GRAY + MENUITEM "Srebrny" ID_COLOR_SILVER + MENUITEM "Czerwony" ID_COLOR_RED + MENUITEM "Limonowy" ID_COLOR_LIME + MENUITEM "ty" ID_COLOR_YELLOW + MENUITEM "Niebieski" ID_COLOR_BLUE + MENUITEM "Fuksja" ID_COLOR_FUCHSIA + MENUITEM "Akwamaryna" ID_COLOR_AQUA + MENUITEM "Biay" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Data i godzina" @@ -222,6 +246,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Zamknij" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/base/applications/wordpad/Pt.rc b/base/applications/wordpad/Pt.rc index 8b0114af22c..2a2ae4b749b 100644 --- a/base/applications/wordpad/Pt.rc +++ b/base/applications/wordpad/Pt.rc @@ -110,6 +110,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Preto" ID_COLOR_BLACK + MENUITEM "Castanho" ID_COLOR_MAROON + MENUITEM "Verde" ID_COLOR_GREEN + MENUITEM "Verde-oliva" ID_COLOR_OLIVE + MENUITEM "Azul-marinho" ID_COLOR_NAVY + MENUITEM "Roxo" ID_COLOR_PURPLE + MENUITEM "Azul-petróleo" ID_COLOR_TEAL + MENUITEM "Cinza" ID_COLOR_GRAY + MENUITEM "Prateado" ID_COLOR_SILVER + MENUITEM "Vermelho" ID_COLOR_RED + MENUITEM "Verde-limão" ID_COLOR_LIME + MENUITEM "Amarelo" ID_COLOR_YELLOW + MENUITEM "Azul" ID_COLOR_BLUE + MENUITEM "Fúcsia" ID_COLOR_FUCHSIA + MENUITEM "Azul-piscina" ID_COLOR_AQUA + MENUITEM "Branco" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Data e hora" @@ -225,6 +249,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Fechar" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -250,4 +276,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Impressão não implementada" STRING_MAX_TAB_STOPS, "Não pode adicionar mais de 32 tabs." END -#pragma code_page(default) diff --git a/base/applications/wordpad/Ru.rc b/base/applications/wordpad/Ru.rc index 70d9b96e743..230003b3c61 100644 --- a/base/applications/wordpad/Ru.rc +++ b/base/applications/wordpad/Ru.rc @@ -109,6 +109,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Чёрный" ID_COLOR_BLACK + MENUITEM "Тёмно-бордовый" ID_COLOR_MAROON + MENUITEM "Зелёный" ID_COLOR_GREEN + MENUITEM "Оливковый" ID_COLOR_OLIVE + MENUITEM "Тёмно-синий" ID_COLOR_NAVY + MENUITEM "Пурпурный" ID_COLOR_PURPLE + MENUITEM "Морской волны" ID_COLOR_TEAL + MENUITEM "Серый" ID_COLOR_GRAY + MENUITEM "Серебряный" ID_COLOR_SILVER + MENUITEM "Красный" ID_COLOR_RED + MENUITEM "Лимонный" ID_COLOR_LIME + MENUITEM "Жёлтый" ID_COLOR_YELLOW + MENUITEM "Синий" ID_COLOR_BLUE + MENUITEM "Ярко-розовый" ID_COLOR_FUCHSIA + MENUITEM "Голубой" ID_COLOR_AQUA + MENUITEM "Белый" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Дата и время" @@ -221,9 +245,11 @@ BEGIN STRING_PREVIEW_PREVPAGE, "Предыдущая страница" STRING_PREVIEW_TWOPAGES, "Две страницы" STRING_PREVIEW_ONEPAGE, "Одна страница" - STRING_PREVIEW_ZOOMIN, "Zoom in" - STRING_PREVIEW_ZOOMOUT, "Zoom out" + STRING_PREVIEW_ZOOMIN, "Приблизить" + STRING_PREVIEW_ZOOMOUT, "Отдалить" STRING_PREVIEW_CLOSE, "Закрыть" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Печать не поддерживается" STRING_MAX_TAB_STOPS, "Нельзя добавить более 32 позиций табуляции." END -#pragma code_page(default) diff --git a/base/applications/wordpad/Si.rc b/base/applications/wordpad/Si.rc index dc0c8d08c0d..f7e0c722b46 100644 --- a/base/applications/wordpad/Si.rc +++ b/base/applications/wordpad/Si.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Črna" ID_COLOR_BLACK + MENUITEM "Kostanjeva" ID_COLOR_MAROON + MENUITEM "Zelena" ID_COLOR_GREEN + MENUITEM "Olivna" ID_COLOR_OLIVE + MENUITEM "Mornariška" ID_COLOR_NAVY + MENUITEM "Vijolična" ID_COLOR_PURPLE + MENUITEM "Zelenomodra" ID_COLOR_TEAL + MENUITEM "Siva" ID_COLOR_GRAY + MENUITEM "Srebrna" ID_COLOR_SILVER + MENUITEM "Rdeča" ID_COLOR_RED + MENUITEM "Citronska" ID_COLOR_LIME + MENUITEM "Rumena" ID_COLOR_YELLOW + MENUITEM "Modra" ID_COLOR_BLUE + MENUITEM "Roza" ID_COLOR_FUCHSIA + MENUITEM "Akvamarin" ID_COLOR_AQUA + MENUITEM "Bela" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Datum in čas" @@ -223,6 +247,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Zapri" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -249,4 +275,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Tiskanje (še) ni na voljo" STRING_MAX_TAB_STOPS, "Ne morem vstaviti več kot 32 položajev tabulatorja." END -#pragma code_page(default) diff --git a/base/applications/wordpad/Sv.rc b/base/applications/wordpad/Sv.rc index c954dc1a7a7..edc35a9b24a 100644 --- a/base/applications/wordpad/Sv.rc +++ b/base/applications/wordpad/Sv.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Svart" ID_COLOR_BLACK + MENUITEM "Rödbrun" ID_COLOR_MAROON + MENUITEM "Grön" ID_COLOR_GREEN + MENUITEM "Oliv" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Lila" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Grå" ID_COLOR_GRAY + MENUITEM "Silver" ID_COLOR_SILVER + MENUITEM "Röd" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Gul" ID_COLOR_YELLOW + MENUITEM "Blå" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "Vit" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Datum och tid" @@ -223,6 +247,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zooma in" STRING_PREVIEW_ZOOMOUT, "Zooma ut" STRING_PREVIEW_CLOSE, "Stäng" + STRING_PREVIEW_PAGE, "Sida" + STRING_PREVIEW_PAGES, "Sidor" END STRINGTABLE DISCARDABLE @@ -248,4 +274,3 @@ BEGIN STRING_PRINTING_NOT_IMPLEMENTED, "Utskrift ej implementerat." STRING_MAX_TAB_STOPS, "Kan ej lägga till mer än 32 tabbstopp." END -#pragma code_page(default) diff --git a/base/applications/wordpad/Tr.rc b/base/applications/wordpad/Tr.rc index e8d9f982ffb..ef66aa40ad8 100644 --- a/base/applications/wordpad/Tr.rc +++ b/base/applications/wordpad/Tr.rc @@ -108,6 +108,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Siyah" ID_COLOR_BLACK + MENUITEM "Koyu Krmz" ID_COLOR_MAROON + MENUITEM "Yeil" ID_COLOR_GREEN + MENUITEM "Koyu Sar" ID_COLOR_OLIVE + MENUITEM "Koyu Mavi" ID_COLOR_NAVY + MENUITEM "Mor" ID_COLOR_PURPLE + MENUITEM "Deniz Mavisi" ID_COLOR_TEAL + MENUITEM "Gri" ID_COLOR_GRAY + MENUITEM "Gm" ID_COLOR_SILVER + MENUITEM "Krmz" ID_COLOR_RED + MENUITEM "Parlak Yeil" ID_COLOR_LIME + MENUITEM "Sar" ID_COLOR_YELLOW + MENUITEM "Mavi" ID_COLOR_BLUE + MENUITEM "Pembe" ID_COLOR_FUCHSIA + MENUITEM "Turkuaz" ID_COLOR_AQUA + MENUITEM "Beyaz" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Date and time" @@ -223,6 +247,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "Close" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE diff --git a/base/applications/wordpad/Uk.rc b/base/applications/wordpad/Uk.rc index c71cbe1575c..35e35977e59 100644 --- a/base/applications/wordpad/Uk.rc +++ b/base/applications/wordpad/Uk.rc @@ -113,6 +113,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "×îðíèé" ID_COLOR_BLACK + MENUITEM "Áðóíàòíèé" ID_COLOR_MAROON + MENUITEM "Çåëåíèé" ID_COLOR_GREEN + MENUITEM "Îëèâêîâèé" ID_COLOR_OLIVE + MENUITEM "Ñèí³é" ID_COLOR_NAVY + MENUITEM "Ïóðïóðíèé" ID_COLOR_PURPLE + MENUITEM "Çåëåíî-ñèí³é" ID_COLOR_TEAL + MENUITEM "ѳðèé" ID_COLOR_GRAY + MENUITEM "Ñð³áíèé" ID_COLOR_SILVER + MENUITEM "×åðâîíèé" ID_COLOR_RED + MENUITEM "Ñàëàòîâèé" ID_COLOR_LIME + MENUITEM "Æîâòèé" ID_COLOR_YELLOW + MENUITEM "Ãîëóáèé" ID_COLOR_BLUE + MENUITEM "Ô³îëåòîâèé" ID_COLOR_FUCHSIA + MENUITEM "Àêâàìàðèí" ID_COLOR_AQUA + MENUITEM "Á³ëèé" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Дата та час" @@ -220,6 +244,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Збільшити" STRING_PREVIEW_ZOOMOUT, "Зменшити" STRING_PREVIEW_CLOSE, "Закрити" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" STRING_UNITS_CM, "cm" END @@ -250,4 +276,3 @@ BEGIN STRING_ALIGN_RIGHT, "По правому Краю" STRING_ALIGN_CENTER, "По Центру" END -#pragma code_page(default) diff --git a/base/applications/wordpad/Zh.rc b/base/applications/wordpad/Zh.rc index 7fd7e120f3e..6adb30af43b 100644 --- a/base/applications/wordpad/Zh.rc +++ b/base/applications/wordpad/Zh.rc @@ -111,6 +111,30 @@ BEGIN END END +IDM_COLOR_POPUP MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "Black", ID_COLOR_BLACK + MENUITEM "Maroon", ID_COLOR_MAROON + MENUITEM "Green", ID_COLOR_GREEN + MENUITEM "Olive" ID_COLOR_OLIVE + MENUITEM "Navy" ID_COLOR_NAVY + MENUITEM "Purple" ID_COLOR_PURPLE + MENUITEM "Teal" ID_COLOR_TEAL + MENUITEM "Gray" ID_COLOR_GRAY + MENUITEM "Silver" ID_COLOR_SILVER + MENUITEM "Red" ID_COLOR_RED + MENUITEM "Lime" ID_COLOR_LIME + MENUITEM "Yellow" ID_COLOR_YELLOW + MENUITEM "Blue" ID_COLOR_BLUE + MENUITEM "Fuchsia" ID_COLOR_FUCHSIA + MENUITEM "Aqua" ID_COLOR_AQUA + MENUITEM "White" ID_COLOR_WHITE + MENUITEM "Automatic" ID_COLOR_AUTOMATIC + END +END + IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "日期和时间" @@ -226,6 +250,8 @@ BEGIN STRING_PREVIEW_ZOOMIN, "Zoom in" STRING_PREVIEW_ZOOMOUT, "Zoom out" STRING_PREVIEW_CLOSE, "关闭" + STRING_PREVIEW_PAGE, "Page" + STRING_PREVIEW_PAGES, "Pages" END STRINGTABLE DISCARDABLE @@ -473,4 +499,3 @@ BEGIN STRING_OPEN_FAILED, "不能開啟檔案." STRING_OPEN_ACCESS_DENIED, "你沒有開啟檔案的權力." END -#pragma code_page(default) diff --git a/base/applications/wordpad/formatbar.bmp b/base/applications/wordpad/formatbar.bmp index 9c643b11b97..310b596d92a 100644 Binary files a/base/applications/wordpad/formatbar.bmp and b/base/applications/wordpad/formatbar.bmp differ diff --git a/base/applications/wordpad/print.c b/base/applications/wordpad/print.c index 79b43a6f494..71c06273fdb 100644 --- a/base/applications/wordpad/print.c +++ b/base/applications/wordpad/print.c @@ -27,7 +27,10 @@ typedef struct _previewinfo { int page; - int pages; + int pages_shown; + int saved_pages_shown; + int *pageEnds, pageCapacity; + int textlength; HDC hdc; HDC hdc2; HDC hdcSized; @@ -51,6 +54,7 @@ static previewinfo preview; extern const WCHAR wszPreviewWndClass[]; static const WCHAR var_pagemargin[] = {'P','a','g','e','M','a','r','g','i','n',0}; +static const WCHAR var_previewpages[] = {'P','r','e','v','i','e','w','P','a','g','e','s',0}; static LPWSTR get_print_file_filter(HWND hMainWnd) { @@ -93,6 +97,28 @@ void registry_read_pagemargins(HKEY hKey) } } +void registry_set_previewpages(HKEY hKey) +{ + RegSetValueExW(hKey, var_previewpages, 0, REG_DWORD, + (LPBYTE)&preview.pages_shown, sizeof(DWORD)); +} + +void registry_read_previewpages(HKEY hKey) +{ + DWORD size = sizeof(DWORD); + if(!hKey || + RegQueryValueExW(hKey, var_previewpages, 0, NULL, + (LPBYTE)&preview.pages_shown, &size) != ERROR_SUCCESS || + size != sizeof(DWORD)) + { + preview.pages_shown = 1; + } else { + if (preview.pages_shown < 1) preview.pages_shown = 1; + else if (preview.pages_shown > 2) preview.pages_shown = 2; + } +} + + static void AddTextButton(HWND hRebarWnd, UINT string, UINT command, UINT id) { REBARBANDINFOW rb; @@ -244,24 +270,6 @@ static LPWSTR dialog_print_to_file(HWND hMainWnd) return FALSE; } -static int get_num_pages(HWND hEditorWnd, FORMATRANGE fr) -{ - int page = 0; - fr.chrg.cpMin = 0; - - do - { - int bottom = fr.rc.bottom; - page++; - fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, - (LPARAM)&fr); - fr.rc.bottom = bottom; - } - while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); - - return page; -} - static void char_from_pagenum(HWND hEditorWnd, FORMATRANGE *fr, int page) { int i; @@ -295,413 +303,6 @@ static void update_ruler(HWND hRulerWnd) redraw_ruler(hRulerWnd); } -static void print(LPPRINTDLGW pd, LPWSTR wszFileName) -{ - FORMATRANGE fr; - DOCINFOW di; - HWND hEditorWnd = GetDlgItem(pd->hwndOwner, IDC_EDITOR); - int printedPages = 0; - - fr.hdc = pd->hDC; - fr.hdcTarget = pd->hDC; - - fr.rc = get_print_rect(fr.hdc); - fr.rcPage.left = 0; - fr.rcPage.right = fr.rc.right + margins.right; - fr.rcPage.top = 0; - fr.rcPage.bottom = fr.rc.bottom + margins.bottom; - - ZeroMemory(&di, sizeof(di)); - di.cbSize = sizeof(di); - di.lpszDocName = wszFileName; - - if(pd->Flags & PD_PRINTTOFILE) - { - di.lpszOutput = dialog_print_to_file(pd->hwndOwner); - if(!di.lpszOutput) - return; - } - - if(pd->Flags & PD_SELECTION) - { - SendMessageW(hEditorWnd, EM_EXGETSEL, 0, (LPARAM)&fr.chrg); - } else - { - GETTEXTLENGTHEX gt; - gt.flags = GTL_DEFAULT; - gt.codepage = 1200; - fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); - - if(pd->Flags & PD_PAGENUMS) - char_from_pagenum(hEditorWnd, &fr, pd->nToPage); - } - - StartDocW(fr.hdc, &di); - do - { - int bottom = fr.rc.bottom; - if(StartPage(fr.hdc) <= 0) - break; - - fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr); - - if(EndPage(fr.hdc) <= 0) - break; - bottom = fr.rc.bottom; - - printedPages++; - if((pd->Flags & PD_PAGENUMS) && (printedPages > (pd->nToPage - pd->nFromPage))) - break; - } - while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); - - EndDoc(fr.hdc); - SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0); -} - -void dialog_printsetup(HWND hMainWnd) -{ - PAGESETUPDLGW ps; - - ZeroMemory(&ps, sizeof(ps)); - ps.lStructSize = sizeof(ps); - ps.hwndOwner = hMainWnd; - ps.Flags = PSD_INHUNDREDTHSOFMILLIMETERS | PSD_MARGINS; - ps.rtMargin.left = twips_to_centmm(margins.left); - ps.rtMargin.right = twips_to_centmm(margins.right); - ps.rtMargin.top = twips_to_centmm(margins.top); - ps.rtMargin.bottom = twips_to_centmm(margins.bottom); - ps.hDevMode = devMode; - ps.hDevNames = devNames; - - if(PageSetupDlgW(&ps)) - { - margins.left = centmm_to_twips(ps.rtMargin.left); - margins.right = centmm_to_twips(ps.rtMargin.right); - margins.top = centmm_to_twips(ps.rtMargin.top); - margins.bottom = centmm_to_twips(ps.rtMargin.bottom); - devMode = ps.hDevMode; - devNames = ps.hDevNames; - update_ruler(get_ruler_wnd(hMainWnd)); - } -} - -void get_default_printer_opts(void) -{ - PRINTDLGW pd; - ZeroMemory(&pd, sizeof(pd)); - - ZeroMemory(&pd, sizeof(pd)); - pd.lStructSize = sizeof(pd); - pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT; - pd.hDevMode = devMode; - - PrintDlgW(&pd); - - devMode = pd.hDevMode; - devNames = pd.hDevNames; -} - -void print_quick(LPWSTR wszFileName) -{ - PRINTDLGW pd; - - ZeroMemory(&pd, sizeof(pd)); - pd.hDC = make_dc(); - - print(&pd, wszFileName); -} - -void dialog_print(HWND hMainWnd, LPWSTR wszFileName) -{ - PRINTDLGW pd; - HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); - int from = 0; - int to = 0; - - ZeroMemory(&pd, sizeof(pd)); - pd.lStructSize = sizeof(pd); - pd.hwndOwner = hMainWnd; - pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; - pd.nMinPage = 1; - pd.nMaxPage = -1; - pd.hDevMode = devMode; - pd.hDevNames = devNames; - - SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to); - if(from == to) - pd.Flags |= PD_NOSELECTION; - - if(PrintDlgW(&pd)) - { - devMode = pd.hDevMode; - devNames = pd.hDevNames; - print(&pd, wszFileName); - update_ruler(get_ruler_wnd(hMainWnd)); - } -} - -static void preview_bar_show(HWND hMainWnd, BOOL show) -{ - HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); - int i; - - if(show) - { - REBARBANDINFOW rb; - HWND hStatic; - - AddTextButton(hReBar, STRING_PREVIEW_PRINT, ID_PRINT, BANDID_PREVIEW_BTN1); - AddTextButton(hReBar, STRING_PREVIEW_NEXTPAGE, ID_PREVIEW_NEXTPAGE, BANDID_PREVIEW_BTN2); - AddTextButton(hReBar, STRING_PREVIEW_PREVPAGE, ID_PREVIEW_PREVPAGE, BANDID_PREVIEW_BTN3); - AddTextButton(hReBar, STRING_PREVIEW_TWOPAGES, ID_PREVIEW_NUMPAGES, BANDID_PREVIEW_BTN4); - AddTextButton(hReBar, STRING_PREVIEW_ZOOMIN, ID_PREVIEW_ZOOMIN, BANDID_PREVIEW_BTN5); - AddTextButton(hReBar, STRING_PREVIEW_ZOOMOUT, ID_PREVIEW_ZOOMOUT, BANDID_PREVIEW_BTN6); - AddTextButton(hReBar, STRING_PREVIEW_CLOSE, ID_FILE_EXIT, BANDID_PREVIEW_BTN7); - - hStatic = CreateWindowW(WC_STATICW, NULL, - WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, - hReBar, NULL, NULL, NULL); - - rb.cbSize = REBARBANDINFOW_V6_SIZE; - rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID; - rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT; - rb.hwndChild = hStatic; - rb.cyChild = rb.cyMinChild = 22; - rb.cx = rb.cxMinChild = 90; - rb.cxIdeal = 100; - rb.wID = BANDID_PREVIEW_BUFFER; - - SendMessageW(hReBar, RB_INSERTBAND, -1, (LPARAM)&rb); - } else - { - for(i = 0; i <= PREVIEW_BUTTONS; i++) - SendMessageW(hReBar, RB_DELETEBAND, SendMessageW(hReBar, RB_IDTOINDEX, BANDID_PREVIEW_BTN1+i, 0), 0); - } -} - -static const int min_spacing = 10; - -static void update_preview_scrollbars(HWND hwndPreview, RECT *window) -{ - SCROLLINFO sbi; - sbi.cbSize = sizeof(sbi); - sbi.fMask = SIF_PAGE|SIF_RANGE; - sbi.nMin = 0; - if (preview.zoomlevel == 0) - { - /* Hide scrollbars when zoomed out. */ - sbi.nMax = 0; - sbi.nPage = window->right; - SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE); - sbi.nPage = window->bottom; - SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE); - } else { - if (!preview.hdc2) - sbi.nMax = preview.bmScaledSize.cx + min_spacing * 2; - else - sbi.nMax = preview.bmScaledSize.cx * 2 + min_spacing * 3; - sbi.nPage = window->right; - SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE); - /* Change in the horizontal scrollbar visibility affects the - * client rect, so update the client rect. */ - GetClientRect(hwndPreview, window); - sbi.nMax = preview.bmScaledSize.cy + min_spacing * 2; - sbi.nPage = window->bottom; - SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE); - } -} - -static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated) -{ - RECT window; - - GetClientRect(hwndPreview, &window); - - /* The zoom ratio isn't updated for partial zoom because of resizing the window. */ - if (zoomLevelUpdated || preview.zoomlevel != 1) - { - float ratio, ratioHeight, ratioWidth; - if (preview.zoomlevel == 2) - { - ratio = 1.0; - } else { - ratioHeight = (window.bottom - min_spacing * 2) / (float)preview.bmSize.cy; - - if(preview.hdc2) - ratioWidth = ((window.right - min_spacing * 3) / 2.0) / (float)preview.bmSize.cx; - else - ratioWidth = (window.right - min_spacing * 2) / (float)preview.bmSize.cx; - - if(ratioWidth > ratioHeight) - ratio = ratioHeight; - else - ratio = ratioWidth; - - if (preview.zoomlevel == 1) - ratio += (1.0 - ratio) / 2; - } - preview.zoomratio = ratio; - } - - preview.bmScaledSize.cx = preview.bmSize.cx * preview.zoomratio; - preview.bmScaledSize.cy = preview.bmSize.cy * preview.zoomratio; - - preview.spacing.cy = max(min_spacing, (window.bottom - preview.bmScaledSize.cy) / 2); - - if(!preview.hdc2) - preview.spacing.cx = (window.right - preview.bmScaledSize.cx) / 2; - else - preview.spacing.cx = (window.right - preview.bmScaledSize.cx * 2) / 3; - if (preview.spacing.cx < min_spacing) - preview.spacing.cx = min_spacing; - - update_preview_scrollbars(hwndPreview, &window); -} - -/* Update for zoom ratio changes with same page. */ -static void update_scaled_preview(HWND hMainWnd) -{ - HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); - preview.window.right = 0; - InvalidateRect(hwndPreview, NULL, TRUE); -} - -LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_CREATE: - { - HWND hEditorWnd = GetDlgItem(GetParent(hWnd), IDC_EDITOR); - FORMATRANGE fr; - GETTEXTLENGTHEX gt = {GTL_DEFAULT, 1200}; - HDC hdc = GetDC(hWnd); - HDC hdcTarget = make_dc(); - - fr.rc = preview.rcPage = get_print_rect(hdcTarget); - preview.rcPage.bottom += margins.bottom; - preview.rcPage.right += margins.right; - preview.rcPage.top = preview.rcPage.left = 0; - fr.rcPage = preview.rcPage; - - preview.bmSize.cx = twips_to_pixels(preview.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX)); - preview.bmSize.cy = twips_to_pixels(preview.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY)); - - fr.hdc = CreateCompatibleDC(hdc); - fr.hdcTarget = hdcTarget; - fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); - preview.pages = get_num_pages(hEditorWnd, fr); - DeleteDC(fr.hdc); - - update_preview_sizes(hWnd, TRUE); - break; - } - - case WM_PAINT: - return print_preview(hWnd); - - case WM_SIZE: - { - update_preview_sizes(hWnd, FALSE); - update_scaled_preview(hWnd); - break; - } - - case WM_VSCROLL: - case WM_HSCROLL: - { - SCROLLINFO si; - RECT rc; - int nBar = (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ; - int origPos; - - GetClientRect(hWnd, &rc); - si.cbSize = sizeof(si); - si.fMask = SIF_ALL; - GetScrollInfo(hWnd, nBar, &si); - origPos = si.nPos; - switch(LOWORD(wParam)) - { - case SB_TOP: /* == SB_LEFT */ - si.nPos = si.nMin; - break; - case SB_BOTTOM: /* == SB_RIGHT */ - si.nPos = si.nMax; - break; - case SB_LINEUP: /* == SB_LINELEFT */ - si.nPos -= si.nPage / 10; - break; - case SB_LINEDOWN: /* == SB_LINERIGHT */ - si.nPos += si.nPage / 10; - break; - case SB_PAGEUP: /* == SB_PAGELEFT */ - si.nPos -= si.nPage; - break; - case SB_PAGEDOWN: /* SB_PAGERIGHT */ - si.nPos += si.nPage; - break; - case SB_THUMBTRACK: - si.nPos = si.nTrackPos; - break; - } - si.fMask = SIF_POS; - SetScrollInfo(hWnd, nBar, &si, TRUE); - GetScrollInfo(hWnd, nBar, &si); - if (si.nPos != origPos) - { - int amount = origPos - si.nPos; - if (msg == WM_VSCROLL) - ScrollWindow(hWnd, 0, amount, NULL, NULL); - else - ScrollWindow(hWnd, amount, 0, NULL, NULL); - } - return 0; - } - - default: - return DefWindowProcW(hWnd, msg, wParam, lParam); - } - - return 0; -} - -void init_preview(HWND hMainWnd, LPWSTR wszFileName) -{ - HWND hwndPreview; - HINSTANCE hInstance = GetModuleHandleW(0); - preview.page = 1; - preview.hdc = 0; - preview.hdc2 = 0; - preview.wszFileName = wszFileName; - preview.zoomratio = 0; - preview.zoomlevel = 0; - preview_bar_show(hMainWnd, TRUE); - - hwndPreview = CreateWindowExW(0, wszPreviewWndClass, NULL, - WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, - 0, 0, 200, 10, hMainWnd, (HMENU)IDC_PREVIEW, hInstance, NULL); -} - -void close_preview(HWND hMainWnd) -{ - HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); - preview.window.right = 0; - preview.window.bottom = 0; - preview.page = 0; - preview.pages = 0; - - preview_bar_show(hMainWnd, FALSE); - DestroyWindow(hwndPreview); -} - -BOOL preview_isactive(void) -{ - return preview.page != 0; -} - static void add_ruler_units(HDC hdcRuler, RECT* drawRect, BOOL NewMetrics, LONG EditLeftmost) { static HDC hdc; @@ -841,25 +442,296 @@ LRESULT CALLBACK ruler_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } -static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float ratio, int bmNewWidth, int bmNewHeight, int bmWidth, int bmHeight) +static void print(LPPRINTDLGW pd, LPWSTR wszFileName) +{ + FORMATRANGE fr; + DOCINFOW di; + HWND hEditorWnd = GetDlgItem(pd->hwndOwner, IDC_EDITOR); + int printedPages = 0; + + fr.hdc = pd->hDC; + fr.hdcTarget = pd->hDC; + + fr.rc = get_print_rect(fr.hdc); + fr.rcPage.left = 0; + fr.rcPage.right = fr.rc.right + margins.right; + fr.rcPage.top = 0; + fr.rcPage.bottom = fr.rc.bottom + margins.bottom; + + ZeroMemory(&di, sizeof(di)); + di.cbSize = sizeof(di); + di.lpszDocName = wszFileName; + + if(pd->Flags & PD_PRINTTOFILE) + { + di.lpszOutput = dialog_print_to_file(pd->hwndOwner); + if(!di.lpszOutput) + return; + } + + if(pd->Flags & PD_SELECTION) + { + SendMessageW(hEditorWnd, EM_EXGETSEL, 0, (LPARAM)&fr.chrg); + } else + { + GETTEXTLENGTHEX gt; + gt.flags = GTL_DEFAULT; + gt.codepage = 1200; + fr.chrg.cpMin = 0; + fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + + if(pd->Flags & PD_PAGENUMS) + char_from_pagenum(hEditorWnd, &fr, pd->nToPage); + } + + StartDocW(fr.hdc, &di); + do + { + int bottom = fr.rc.bottom; + if(StartPage(fr.hdc) <= 0) + break; + + fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr); + + if(EndPage(fr.hdc) <= 0) + break; + bottom = fr.rc.bottom; + + printedPages++; + if((pd->Flags & PD_PAGENUMS) && (printedPages > (pd->nToPage - pd->nFromPage))) + break; + } + while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); + + EndDoc(fr.hdc); + SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0); +} + +void dialog_printsetup(HWND hMainWnd) +{ + PAGESETUPDLGW ps; + + ZeroMemory(&ps, sizeof(ps)); + ps.lStructSize = sizeof(ps); + ps.hwndOwner = hMainWnd; + ps.Flags = PSD_INHUNDREDTHSOFMILLIMETERS | PSD_MARGINS; + ps.rtMargin.left = twips_to_centmm(margins.left); + ps.rtMargin.right = twips_to_centmm(margins.right); + ps.rtMargin.top = twips_to_centmm(margins.top); + ps.rtMargin.bottom = twips_to_centmm(margins.bottom); + ps.hDevMode = devMode; + ps.hDevNames = devNames; + + if(PageSetupDlgW(&ps)) + { + margins.left = centmm_to_twips(ps.rtMargin.left); + margins.right = centmm_to_twips(ps.rtMargin.right); + margins.top = centmm_to_twips(ps.rtMargin.top); + margins.bottom = centmm_to_twips(ps.rtMargin.bottom); + devMode = ps.hDevMode; + devNames = ps.hDevNames; + update_ruler(get_ruler_wnd(hMainWnd)); + } +} + +void get_default_printer_opts(void) +{ + PRINTDLGW pd; + ZeroMemory(&pd, sizeof(pd)); + + ZeroMemory(&pd, sizeof(pd)); + pd.lStructSize = sizeof(pd); + pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT; + pd.hDevMode = devMode; + + PrintDlgW(&pd); + + devMode = pd.hDevMode; + devNames = pd.hDevNames; +} + +void print_quick(HWND hMainWnd, LPWSTR wszFileName) +{ + PRINTDLGW pd; + + ZeroMemory(&pd, sizeof(pd)); + pd.hwndOwner = hMainWnd; + pd.hDC = make_dc(); + + print(&pd, wszFileName); + DeleteDC(pd.hDC); +} + +void dialog_print(HWND hMainWnd, LPWSTR wszFileName) +{ + PRINTDLGW pd; + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + int from = 0; + int to = 0; + + ZeroMemory(&pd, sizeof(pd)); + pd.lStructSize = sizeof(pd); + pd.hwndOwner = hMainWnd; + pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; + pd.nMinPage = 1; + pd.nMaxPage = -1; + pd.hDevMode = devMode; + pd.hDevNames = devNames; + + SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to); + if(from == to) + pd.Flags |= PD_NOSELECTION; + + if(PrintDlgW(&pd)) + { + devMode = pd.hDevMode; + devNames = pd.hDevNames; + print(&pd, wszFileName); + update_ruler(get_ruler_wnd(hMainWnd)); + } +} + +static void preview_bar_show(HWND hMainWnd, BOOL show) +{ + HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); + int i; + + if(show) + { + REBARBANDINFOW rb; + HWND hStatic; + UINT num_pages_string = preview.pages_shown > 1 ? STRING_PREVIEW_ONEPAGE : + STRING_PREVIEW_TWOPAGES; + + AddTextButton(hReBar, STRING_PREVIEW_PRINT, ID_PRINT, BANDID_PREVIEW_BTN1); + AddTextButton(hReBar, STRING_PREVIEW_NEXTPAGE, ID_PREVIEW_NEXTPAGE, BANDID_PREVIEW_BTN2); + AddTextButton(hReBar, STRING_PREVIEW_PREVPAGE, ID_PREVIEW_PREVPAGE, BANDID_PREVIEW_BTN3); + AddTextButton(hReBar, num_pages_string, ID_PREVIEW_NUMPAGES, BANDID_PREVIEW_BTN4); + AddTextButton(hReBar, STRING_PREVIEW_ZOOMIN, ID_PREVIEW_ZOOMIN, BANDID_PREVIEW_BTN5); + AddTextButton(hReBar, STRING_PREVIEW_ZOOMOUT, ID_PREVIEW_ZOOMOUT, BANDID_PREVIEW_BTN6); + AddTextButton(hReBar, STRING_PREVIEW_CLOSE, ID_FILE_EXIT, BANDID_PREVIEW_BTN7); + + hStatic = CreateWindowW(WC_STATICW, NULL, + WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, + hReBar, NULL, NULL, NULL); + + rb.cbSize = REBARBANDINFOW_V6_SIZE; + rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID; + rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT; + rb.hwndChild = hStatic; + rb.cyChild = rb.cyMinChild = 22; + rb.cx = rb.cxMinChild = 90; + rb.cxIdeal = 100; + rb.wID = BANDID_PREVIEW_BUFFER; + + SendMessageW(hReBar, RB_INSERTBAND, -1, (LPARAM)&rb); + } else + { + for(i = 0; i <= PREVIEW_BUTTONS; i++) + SendMessageW(hReBar, RB_DELETEBAND, SendMessageW(hReBar, RB_IDTOINDEX, BANDID_PREVIEW_BTN1+i, 0), 0); + } +} + +static const int min_spacing = 10; + +static void update_preview_scrollbars(HWND hwndPreview, RECT *window) +{ + SCROLLINFO sbi; + sbi.cbSize = sizeof(sbi); + sbi.fMask = SIF_PAGE|SIF_RANGE; + sbi.nMin = 0; + if (preview.zoomlevel == 0) + { + /* Hide scrollbars when zoomed out. */ + sbi.nMax = 0; + sbi.nPage = window->right; + SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE); + sbi.nPage = window->bottom; + SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE); + } else { + sbi.nMax = preview.bmScaledSize.cx * preview.pages_shown + + min_spacing * (preview.pages_shown + 1); + sbi.nPage = window->right; + SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE); + /* Change in the horizontal scrollbar visibility affects the + * client rect, so update the client rect. */ + GetClientRect(hwndPreview, window); + sbi.nMax = preview.bmScaledSize.cy + min_spacing * 2; + sbi.nPage = window->bottom; + SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE); + } +} + +static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated) +{ + RECT window; + + GetClientRect(hwndPreview, &window); + + /* The zoom ratio isn't updated for partial zoom because of resizing the window. */ + if (zoomLevelUpdated || preview.zoomlevel != 1) + { + float ratio, ratioHeight, ratioWidth; + if (preview.zoomlevel == 2) + { + ratio = 1.0; + } else { + ratioHeight = (window.bottom - min_spacing * 2) / (float)preview.bmSize.cy; + + ratioWidth = (float)(window.right - + min_spacing * (preview.pages_shown + 1)) / + (preview.pages_shown * preview.bmSize.cx); + + if(ratioWidth > ratioHeight) + ratio = ratioHeight; + else + ratio = ratioWidth; + + if (preview.zoomlevel == 1) + ratio += (1.0 - ratio) / 2; + } + preview.zoomratio = ratio; + } + + preview.bmScaledSize.cx = preview.bmSize.cx * preview.zoomratio; + preview.bmScaledSize.cy = preview.bmSize.cy * preview.zoomratio; + + preview.spacing.cy = max(min_spacing, (window.bottom - preview.bmScaledSize.cy) / 2); + + preview.spacing.cx = (window.right - + preview.bmScaledSize.cx * preview.pages_shown) / + (preview.pages_shown + 1); + if (preview.spacing.cx < min_spacing) + preview.spacing.cx = min_spacing; + + update_preview_scrollbars(hwndPreview, &window); +} + +static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float ratio, int bmNewWidth, int bmNewHeight, int bmWidth, int bmHeight, BOOL draw_margins) { HBITMAP hBitmapScaled = CreateCompatibleBitmap(hdc, bmNewWidth, bmNewHeight); - HPEN hPen; + HBITMAP oldbm; + HPEN hPen, oldPen; int TopMargin = (int)((float)twips_to_pixels(lpFr->rc.top, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio); int BottomMargin = (int)((float)twips_to_pixels(lpFr->rc.bottom, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio); int LeftMargin = (int)((float)twips_to_pixels(lpFr->rc.left, GetDeviceCaps(hdc, LOGPIXELSY)) * ratio); int RightMargin = (int)((float)twips_to_pixels(lpFr->rc.right, GetDeviceCaps(hdc, LOGPIXELSY)) * ratio); - if(*hdcSized) - DeleteDC(*hdcSized); - *hdcSized = CreateCompatibleDC(hdc); - SelectObject(*hdcSized, hBitmapScaled); + if(*hdcSized) { + oldbm = SelectObject(*hdcSized, hBitmapScaled); + DeleteObject(oldbm); + } else { + *hdcSized = CreateCompatibleDC(hdc); + SelectObject(*hdcSized, hBitmapScaled); + } StretchBlt(*hdcSized, 0, 0, bmNewWidth, bmNewHeight, hdc, 0, 0, bmWidth, bmHeight, SRCCOPY); + if (!draw_margins) return; + /* Draw margin lines */ hPen = CreatePen(PS_DOT, 1, RGB(0,0,0)); - SelectObject(*hdcSized, hPen); + oldPen = SelectObject(*hdcSized, hPen); MoveToEx(*hdcSized, 0, TopMargin, NULL); LineTo(*hdcSized, bmNewWidth, TopMargin); @@ -871,18 +743,137 @@ static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float r MoveToEx(*hdcSized, RightMargin, 0, NULL); LineTo(*hdcSized, RightMargin, bmNewHeight); + SelectObject(*hdcSized, oldPen); + DeleteObject(hPen); } -static void draw_preview(HWND hEditorWnd, FORMATRANGE* lpFr, int bmWidth, int bmHeight, RECT* paper, int page) +static BOOL is_last_preview_page(int page) +{ + return preview.pageEnds[page - 1] >= preview.textlength; +} + +/* Update for zoom ratio changes with same page. */ +static void update_scaled_preview(HWND hMainWnd) +{ + FORMATRANGE fr; + HWND hwndPreview; + + /* This may occur on WM_CREATE before update_preview is called + * because a WM_SIZE message is generated from updating the + * scrollbars. */ + if (!preview.hdc) return; + + hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); + fr.hdcTarget = make_dc(); + fr.rc = fr.rcPage = preview.rcPage; + fr.rc.left += margins.left; + fr.rc.top += margins.top; + fr.rc.bottom -= margins.bottom; + fr.rc.right -= margins.right; + + draw_preview_page(preview.hdc, &preview.hdcSized, &fr, preview.zoomratio, + preview.bmScaledSize.cx, preview.bmScaledSize.cy, + preview.bmSize.cx, preview.bmSize.cy, TRUE); + + if(preview.pages_shown > 1) + { + draw_preview_page(preview.hdc2, &preview.hdcSized2, &fr, preview.zoomratio, + preview.bmScaledSize.cx, preview.bmScaledSize.cy, + preview.bmSize.cx, preview.bmSize.cy, + !is_last_preview_page(preview.page)); + } + + InvalidateRect(hwndPreview, NULL, TRUE); + DeleteDC(fr.hdcTarget); +} + +void init_preview(HWND hMainWnd, LPWSTR wszFileName) +{ + HWND hwndPreview; + HINSTANCE hInstance = GetModuleHandleW(0); + preview.page = 1; + preview.hdc = 0; + preview.hdc2 = 0; + preview.wszFileName = wszFileName; + preview.zoomratio = 0; + preview.zoomlevel = 0; + preview_bar_show(hMainWnd, TRUE); + + hwndPreview = CreateWindowExW(0, wszPreviewWndClass, NULL, + WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, + 0, 0, 200, 10, hMainWnd, (HMENU)IDC_PREVIEW, hInstance, NULL); +} + +void close_preview(HWND hMainWnd) +{ + HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); + preview.window.right = 0; + preview.window.bottom = 0; + preview.page = 0; + HeapFree(GetProcessHeap(), 0, preview.pageEnds); + preview.pageEnds = NULL; + preview.pageCapacity = 0; + if (preview.zoomlevel > 0) + preview.pages_shown = preview.saved_pages_shown; + if(preview.hdc) { + HBITMAP oldbm = GetCurrentObject(preview.hdc, OBJ_BITMAP); + DeleteDC(preview.hdc); + DeleteObject(oldbm); + preview.hdc = NULL; + } + if(preview.hdc2) { + HBITMAP oldbm = GetCurrentObject(preview.hdc2, OBJ_BITMAP); + DeleteDC(preview.hdc2); + DeleteObject(oldbm); + preview.hdc2 = NULL; + } + if(preview.hdcSized) { + HBITMAP oldbm = GetCurrentObject(preview.hdcSized, OBJ_BITMAP); + DeleteDC(preview.hdcSized); + DeleteObject(oldbm); + preview.hdcSized = NULL; + } + if(preview.hdcSized2) { + HBITMAP oldbm = GetCurrentObject(preview.hdcSized2, OBJ_BITMAP); + DeleteDC(preview.hdcSized2); + DeleteObject(oldbm); + preview.hdcSized2 = NULL; + } + + preview_bar_show(hMainWnd, FALSE); + DestroyWindow(hwndPreview); +} + +BOOL preview_isactive(void) +{ + return preview.page != 0; +} + +static void draw_preview(HWND hEditorWnd, FORMATRANGE* lpFr, RECT* paper, int page) { - HBITMAP hBitmapCapture = CreateCompatibleBitmap(lpFr->hdc, bmWidth, bmHeight); int bottom; - char_from_pagenum(hEditorWnd, lpFr, page); - SelectObject(lpFr->hdc, hBitmapCapture); + if (!preview.pageEnds) + { + preview.pageCapacity = 32; + preview.pageEnds = HeapAlloc(GetProcessHeap(), 0, + sizeof(int) * preview.pageCapacity); + if (!preview.pageEnds) return; + } else if (page >= preview.pageCapacity) { + int *new_buffer; + new_buffer = HeapReAlloc(GetProcessHeap(), 0, preview.pageEnds, + sizeof(int) * preview.pageCapacity * 2); + if (!new_buffer) return; + preview.pageCapacity *= 2; + preview.pageEnds = new_buffer; + } + FillRect(lpFr->hdc, paper, GetStockObject(WHITE_BRUSH)); + if (page > 1 && is_last_preview_page(page - 1)) return; + lpFr->chrg.cpMin = page <= 1 ? 0 : preview.pageEnds[page-2]; bottom = lpFr->rc.bottom; - SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)lpFr); + preview.pageEnds[page-1] = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)lpFr); + /* EM_FORMATRANGE sets fr.rc.bottom to indicate the area printed in, * but we want to keep the original for drawing margins */ lpFr->rc.bottom = bottom; @@ -893,70 +884,26 @@ static void update_preview_buttons(HWND hMainWnd) { HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_PREVPAGE), preview.page > 1); - EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), preview.hdc2 ? - (preview.page + 1) < preview.pages : - preview.page < preview.pages); - EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NUMPAGES), preview.pages > 1 && preview.zoomlevel == 0); + EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), + !is_last_preview_page(preview.page) && + !is_last_preview_page(preview.page + preview.pages_shown - 1)); + EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NUMPAGES), + preview.pages_shown > 1 || + (!is_last_preview_page(1) && preview.zoomlevel == 0)); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_ZOOMIN), preview.zoomlevel < 2); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_ZOOMOUT), preview.zoomlevel > 0); } LRESULT print_preview(HWND hwndPreview) { - FORMATRANGE fr; HDC hdc; RECT window, background; PAINTSTRUCT ps; - HWND hMainWnd = GetParent(hwndPreview); POINT scrollpos; hdc = BeginPaint(hwndPreview, &ps); GetClientRect(hwndPreview, &window); - fr.hdcTarget = make_dc(); - fr.rc = fr.rcPage = preview.rcPage; - fr.rc.left += margins.left; - fr.rc.top += margins.top; - fr.rc.bottom -= margins.bottom; - fr.rc.right -= margins.right; - - if(!preview.hdc) - { - GETTEXTLENGTHEX gt; - RECT paper; - HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); - - preview.hdc = CreateCompatibleDC(hdc); - - if(preview.hdc2) - { - if(preview.hdc2 != (HDC)-1) - DeleteDC(preview.hdc2); - preview.hdc2 = CreateCompatibleDC(hdc); - } - - gt.flags = GTL_DEFAULT; - gt.codepage = 1200; - fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); - - paper.left = 0; - paper.right = preview.bmSize.cx; - paper.top = 0; - paper.bottom = preview.bmSize.cy; - - fr.hdc = preview.hdc; - draw_preview(hEditorWnd, &fr, preview.bmSize.cx, preview.bmSize.cy, &paper, preview.page); - - if(preview.hdc2) - { - fr.hdc = preview.hdc2; - draw_preview(hEditorWnd, &fr, preview.bmSize.cx, preview.bmSize.cy, &fr.rcPage, preview.page + 1); - } - - update_preview_buttons(hMainWnd); - } - FillRect(hdc, &window, GetStockObject(GRAY_BRUSH)); scrollpos.x = GetScrollPos(hwndPreview, SB_HORZ); @@ -969,7 +916,7 @@ LRESULT print_preview(HWND hwndPreview) FillRect(hdc, &background, GetStockObject(BLACK_BRUSH)); - if(preview.hdc2) + if(preview.pages_shown > 1) { background.left += preview.bmScaledSize.cx + preview.spacing.cx; background.right += preview.bmScaledSize.cx + preview.spacing.cx; @@ -977,32 +924,17 @@ LRESULT print_preview(HWND hwndPreview) FillRect(hdc, &background, GetStockObject(BLACK_BRUSH)); } - if(window.right != preview.window.right || window.bottom != preview.window.bottom) - { - draw_preview_page(preview.hdc, &preview.hdcSized, &fr, preview.zoomratio, - preview.bmScaledSize.cx, preview.bmScaledSize.cy, - preview.bmSize.cx, preview.bmSize.cy); - - if(preview.hdc2) - { - draw_preview_page(preview.hdc2, &preview.hdcSized2, &fr, preview.zoomratio, - preview.bmScaledSize.cx, preview.bmScaledSize.cy, - preview.bmSize.cx, preview.bmSize.cy); - } - } - BitBlt(hdc, preview.spacing.cx - scrollpos.x, preview.spacing.cy - scrollpos.y, preview.bmScaledSize.cx, preview.bmScaledSize.cy, preview.hdcSized, 0, 0, SRCCOPY); - if(preview.hdc2) + if(preview.pages_shown > 1) { BitBlt(hdc, preview.spacing.cx * 2 + preview.bmScaledSize.cx - scrollpos.x, preview.spacing.cy - scrollpos.y, preview.bmScaledSize.cx, preview.bmScaledSize.cy, preview.hdcSized2, 0, 0, SRCCOPY); } - DeleteDC(fr.hdcTarget); preview.window = window; EndPaint(hwndPreview, &ps); @@ -1010,13 +942,81 @@ LRESULT print_preview(HWND hwndPreview) return 0; } +static void update_preview_statusbar(HWND hMainWnd) +{ + HWND hStatusbar = GetDlgItem(hMainWnd, IDC_STATUSBAR); + HINSTANCE hInst = GetModuleHandleW(0); + WCHAR *p; + WCHAR wstr[MAX_STRING_LEN]; + + p = wstr; + if (preview.pages_shown < 2 || is_last_preview_page(preview.page)) + { + static const WCHAR fmt[] = {' ','%','d','\0'}; + p += LoadStringW(hInst, STRING_PREVIEW_PAGE, wstr, MAX_STRING_LEN); + wsprintfW(p, fmt, preview.page); + } else { + static const WCHAR fmt[] = {' ','%','d','-','%','d','\0'}; + p += LoadStringW(hInst, STRING_PREVIEW_PAGES, wstr, MAX_STRING_LEN); + wsprintfW(p, fmt, preview.page, preview.page + 1); + } + SetWindowTextW(hStatusbar, wstr); +} + /* Update for page changes. */ static void update_preview(HWND hMainWnd) { - DeleteDC(preview.hdc); - preview.hdc = 0; + RECT paper; + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); + HBITMAP hBitmapCapture; + FORMATRANGE fr; + HDC hdc = GetDC(hwndPreview); + + fr.hdcTarget = make_dc(); + fr.rc = fr.rcPage = preview.rcPage; + fr.rc.left += margins.left; + fr.rc.top += margins.top; + fr.rc.bottom -= margins.bottom; + fr.rc.right -= margins.right; + + fr.chrg.cpMin = 0; + fr.chrg.cpMax = preview.textlength; + + paper.left = 0; + paper.right = preview.bmSize.cx; + paper.top = 0; + paper.bottom = preview.bmSize.cy; + + if (!preview.hdc) { + preview.hdc = CreateCompatibleDC(hdc); + hBitmapCapture = CreateCompatibleBitmap(hdc, preview.bmSize.cx, preview.bmSize.cy); + SelectObject(preview.hdc, hBitmapCapture); + } + + fr.hdc = preview.hdc; + draw_preview(hEditorWnd, &fr, &paper, preview.page); + + if(preview.pages_shown > 1) + { + if (!preview.hdc2) + { + preview.hdc2 = CreateCompatibleDC(hdc); + hBitmapCapture = CreateCompatibleBitmap(hdc, + preview.bmSize.cx, + preview.bmSize.cy); + SelectObject(preview.hdc2, hBitmapCapture); + } + + fr.hdc = preview.hdc2; + draw_preview(hEditorWnd, &fr, &fr.rcPage, preview.page + 1); + } + DeleteDC(fr.hdcTarget); + ReleaseDC(hwndPreview, hdc); update_scaled_preview(hMainWnd); + update_preview_buttons(hMainWnd); + update_preview_statusbar(hMainWnd); } static void toggle_num_pages(HWND hMainWnd) @@ -1024,19 +1024,15 @@ static void toggle_num_pages(HWND hMainWnd) HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); WCHAR name[MAX_STRING_LEN]; HINSTANCE hInst = GetModuleHandleW(0); + int nPreviewPages; - if(preview.hdc2) - { - DeleteDC(preview.hdc2); - preview.hdc2 = 0; - } else - { - if(preview.page == preview.pages) - preview.page--; - preview.hdc2 = (HDC)-1; - } + preview.pages_shown = preview.pages_shown > 1 ? 1 : 2; - LoadStringW(hInst, preview.hdc2 ? STRING_PREVIEW_ONEPAGE : STRING_PREVIEW_TWOPAGES, + nPreviewPages = preview.zoomlevel > 0 ? preview.saved_pages_shown : + preview.pages_shown; + + LoadStringW(hInst, nPreviewPages > 1 ? STRING_PREVIEW_ONEPAGE : + STRING_PREVIEW_TWOPAGES, name, MAX_STRING_LEN); SetWindowTextW(GetDlgItem(hReBar, ID_PREVIEW_NUMPAGES), name); @@ -1044,6 +1040,216 @@ static void toggle_num_pages(HWND hMainWnd) update_preview(hMainWnd); } +/* Returns the page shown that the point is in (1 or 2) or 0 if the point + * isn't inside either page */ +int preview_page_hittest(POINT pt) +{ + RECT rc; + rc.left = preview.spacing.cx; + rc.right = rc.left + preview.bmScaledSize.cx; + rc.top = preview.spacing.cy; + rc.bottom = rc.top + preview.bmScaledSize.cy; + if (PtInRect(&rc, pt)) + return 1; + + if (preview.pages_shown <= 1) + return 0; + + rc.left += preview.bmScaledSize.cx + preview.spacing.cx; + rc.right += preview.bmScaledSize.cx + preview.spacing.cx; + if (PtInRect(&rc, pt)) + return is_last_preview_page(preview.page) ? 1 : 2; + + return 0; +} + +LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_CREATE: + { + HWND hMainWnd = GetParent(hWnd); + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + FORMATRANGE fr; + GETTEXTLENGTHEX gt = {GTL_DEFAULT, 1200}; + HDC hdc = GetDC(hWnd); + HDC hdcTarget = make_dc(); + + fr.rc = preview.rcPage = get_print_rect(hdcTarget); + preview.rcPage.bottom += margins.bottom; + preview.rcPage.right += margins.right; + preview.rcPage.top = preview.rcPage.left = 0; + fr.rcPage = preview.rcPage; + + preview.bmSize.cx = twips_to_pixels(preview.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX)); + preview.bmSize.cy = twips_to_pixels(preview.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY)); + + preview.textlength = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + + fr.hdc = CreateCompatibleDC(hdc); + fr.hdcTarget = hdcTarget; + fr.chrg.cpMin = 0; + fr.chrg.cpMax = preview.textlength; + DeleteDC(fr.hdc); + DeleteDC(hdcTarget); + ReleaseDC(hWnd, hdc); + + update_preview_sizes(hWnd, TRUE); + update_preview(hMainWnd); + break; + } + + case WM_PAINT: + return print_preview(hWnd); + + case WM_SIZE: + { + update_preview_sizes(hWnd, FALSE); + update_scaled_preview(hWnd); + break; + } + + case WM_VSCROLL: + case WM_HSCROLL: + { + SCROLLINFO si; + RECT rc; + int nBar = (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ; + int origPos; + + GetClientRect(hWnd, &rc); + si.cbSize = sizeof(si); + si.fMask = SIF_ALL; + GetScrollInfo(hWnd, nBar, &si); + origPos = si.nPos; + switch(LOWORD(wParam)) + { + case SB_TOP: /* == SB_LEFT */ + si.nPos = si.nMin; + break; + case SB_BOTTOM: /* == SB_RIGHT */ + si.nPos = si.nMax; + break; + case SB_LINEUP: /* == SB_LINELEFT */ + si.nPos -= si.nPage / 10; + break; + case SB_LINEDOWN: /* == SB_LINERIGHT */ + si.nPos += si.nPage / 10; + break; + case SB_PAGEUP: /* == SB_PAGELEFT */ + si.nPos -= si.nPage; + break; + case SB_PAGEDOWN: /* SB_PAGERIGHT */ + si.nPos += si.nPage; + break; + case SB_THUMBTRACK: + si.nPos = si.nTrackPos; + break; + } + si.fMask = SIF_POS; + SetScrollInfo(hWnd, nBar, &si, TRUE); + GetScrollInfo(hWnd, nBar, &si); + if (si.nPos != origPos) + { + int amount = origPos - si.nPos; + if (msg == WM_VSCROLL) + ScrollWindow(hWnd, 0, amount, NULL, NULL); + else + ScrollWindow(hWnd, amount, 0, NULL, NULL); + } + return 0; + } + + case WM_SETCURSOR: + { + POINT pt; + RECT rc; + int bHittest = FALSE; + DWORD messagePos = GetMessagePos(); + pt.x = (short)LOWORD(messagePos); + pt.y = (short)HIWORD(messagePos); + ScreenToClient(hWnd, &pt); + + GetClientRect(hWnd, &rc); + if (PtInRect(&rc, pt)) + { + pt.x += GetScrollPos(hWnd, SB_HORZ); + pt.y += GetScrollPos(hWnd, SB_VERT); + bHittest = preview_page_hittest(pt); + } + + if (bHittest) + SetCursor(LoadCursorW(GetModuleHandleW(0), + MAKEINTRESOURCEW(IDC_ZOOM))); + else + SetCursor(LoadCursorW(NULL, (WCHAR*)IDC_ARROW)); + + return TRUE; + } + + case WM_LBUTTONDOWN: + { + int page; + POINT pt; + pt.x = (short)LOWORD(lParam) + GetScrollPos(hWnd, SB_HORZ); + pt.y = (short)HIWORD(lParam) + GetScrollPos(hWnd, SB_VERT); + if ((page = preview_page_hittest(pt)) > 0) + { + HWND hMainWnd = GetParent(hWnd); + + /* Convert point from client coordinate to unzoomed page + * coordinate. */ + pt.x -= preview.spacing.cx; + if (page > 1) + pt.x -= preview.bmScaledSize.cx + preview.spacing.cx; + pt.y -= preview.spacing.cy; + pt.x /= preview.zoomratio; + pt.y /= preview.zoomratio; + + if (preview.zoomlevel == 0) + preview.saved_pages_shown = preview.pages_shown; + preview.zoomlevel = (preview.zoomlevel + 1) % 3; + preview.zoomratio = 0; + if (preview.zoomlevel == 0 && preview.saved_pages_shown > 1) + { + toggle_num_pages(hMainWnd); + } else if (preview.pages_shown > 1) { + if (page >= 2) preview.page++; + toggle_num_pages(hMainWnd); + } else { + update_preview_sizes(hWnd, TRUE); + update_scaled_preview(hMainWnd); + update_preview_buttons(hMainWnd); + } + + if (preview.zoomlevel > 0) { + SCROLLINFO si; + /* Convert the coordinate back to client coordinate. */ + pt.x *= preview.zoomratio; + pt.y *= preview.zoomratio; + pt.x += preview.spacing.cx; + pt.y += preview.spacing.cy; + /* Scroll to center view at that point on the page */ + si.cbSize = sizeof(si); + si.fMask = SIF_PAGE; + GetScrollInfo(hWnd, SB_HORZ, &si); + pt.x -= si.nPage / 2; + SetScrollPos(hWnd, SB_HORZ, pt.x, TRUE); + GetScrollInfo(hWnd, SB_VERT, &si); + pt.y -= si.nPage / 2; + SetScrollPos(hWnd, SB_VERT, pt.y, TRUE); + } + } + } + + default: + return DefWindowProcW(hWnd, msg, wParam, lParam); + } + + return 0; +} + LRESULT preview_command(HWND hWnd, WPARAM wParam) { switch(LOWORD(wParam)) @@ -1071,9 +1277,11 @@ LRESULT preview_command(HWND hWnd, WPARAM wParam) case ID_PREVIEW_ZOOMIN: if (preview.zoomlevel < 2) { + if (preview.zoomlevel == 0) + preview.saved_pages_shown = preview.pages_shown; preview.zoomlevel++; preview.zoomratio = 0; - if (preview.hdc2) + if (preview.pages_shown > 1) { /* Forced switch to one page when zooming in. */ toggle_num_pages(hWnd); @@ -1092,9 +1300,13 @@ LRESULT preview_command(HWND hWnd, WPARAM wParam) HWND hwndPreview = GetDlgItem(hWnd, IDC_PREVIEW); preview.zoomlevel--; preview.zoomratio = 0; - update_preview_sizes(hwndPreview, TRUE); - update_scaled_preview(hWnd); - update_preview_buttons(hWnd); + if (preview.zoomlevel == 0 && preview.saved_pages_shown > 1) { + toggle_num_pages(hWnd); + } else { + update_preview_sizes(hwndPreview, TRUE); + update_scaled_preview(hWnd); + update_preview_buttons(hWnd); + } } break; diff --git a/base/applications/wordpad/registry.c b/base/applications/wordpad/registry.c index c7edc5b1e50..7311fb68232 100644 --- a/base/applications/wordpad/registry.c +++ b/base/applications/wordpad/registry.c @@ -27,6 +27,7 @@ static const WCHAR key_recentfiles[] = {'R','e','c','e','n','t',' ','f','i','l','e', ' ','l','i','s','t',0}; static const WCHAR key_options[] = {'O','p','t','i','o','n','s',0}; +static const WCHAR key_settings[] = {'S','e','t','t','i','n','g','s',0}; static const WCHAR key_rtf[] = {'R','T','F',0}; static const WCHAR key_text[] = {'T','e','x','t',0}; @@ -94,9 +95,14 @@ void registry_set_options(HWND hMainWnd) RegSetValueExW(hKey, var_maximized, 0, REG_DWORD, (LPBYTE)&isMaximized, sizeof(DWORD)); registry_set_pagemargins(hKey); + RegCloseKey(hKey); } - RegCloseKey(hKey); + if(registry_get_handle(&hKey, &action, key_settings) == ERROR_SUCCESS) + { + registry_set_previewpages(hKey); + RegCloseKey(hKey); + } } void registry_read_winrect(RECT* rc) @@ -339,6 +345,13 @@ void registry_read_options(void) registry_read_pagemargins(hKey); RegCloseKey(hKey); } + + if(registry_get_handle(&hKey, 0, key_settings) != ERROR_SUCCESS) { + registry_read_previewpages(NULL); + } else { + registry_read_previewpages(hKey); + RegCloseKey(hKey); + } } static void registry_read_formatopts(int index, LPCWSTR key, DWORD barState[], DWORD wordWrap[]) diff --git a/base/applications/wordpad/rsrc.rc b/base/applications/wordpad/rsrc.rc index 4a699aa9c15..a3f66c55e5c 100644 --- a/base/applications/wordpad/rsrc.rc +++ b/base/applications/wordpad/rsrc.rc @@ -1,4 +1,4 @@ -/* +/* * Copyright 2004 by Krzysztof Foltman * Copyright 2007 by Alexander N. Sørnes * @@ -61,22 +61,28 @@ IDI_WRI ICON "wri.ico" /* @makedep: txt.ico */ IDI_TXT ICON "txt.ico" +/* @makedep: zoom.cur */ +IDC_ZOOM CURSOR "zoom.cur" + + #include "Da.rc" -#include "De.rc" #include "En.rc" -#include "Fr.rc" #include "Hu.rc" +#include "Ko.rc" +#include "Nl.rc" +#include "Pl.rc" +#include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" #include "It.rc" #include "Ja.rc" -#include "Ko.rc" #include "Lt.rc" -#include "Nl.rc" #include "No.rc" -#include "Pl.rc" #include "Pt.rc" #include "Ru.rc" #include "Si.rc" #include "Sv.rc" -#include "Tr.rc" #include "Uk.rc" #include "Zh.rc" diff --git a/base/applications/wordpad/wordpad.c b/base/applications/wordpad/wordpad.c index 0bbe3604438..b9e6f3716a2 100644 --- a/base/applications/wordpad/wordpad.c +++ b/base/applications/wordpad/wordpad.c @@ -63,6 +63,7 @@ static HWND hMainWnd; static HWND hEditorWnd; static HWND hFindWnd; static HMENU hPopupMenu; +static HMENU hColorPopupMenu; static UINT ID_FINDMSGSTRING; @@ -1836,17 +1837,18 @@ static LRESULT OnCreate( HWND hWnd ) hFormatBarWnd = CreateToolbarEx(hReBarWnd, CCS_NOPARENTALIGN | CCS_NOMOVEY | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_BUTTON, - IDC_FORMATBAR, 7, hInstance, IDB_FORMATBAR, NULL, 0, 16, 16, 16, 16, sizeof(TBBUTTON)); + IDC_FORMATBAR, 8, hInstance, IDB_FORMATBAR, NULL, 0, 16, 16, 16, 16, sizeof(TBBUTTON)); AddButton(hFormatBarWnd, 0, ID_FORMAT_BOLD); AddButton(hFormatBarWnd, 1, ID_FORMAT_ITALIC); AddButton(hFormatBarWnd, 2, ID_FORMAT_UNDERLINE); + AddButton(hFormatBarWnd, 3, ID_FORMAT_COLOR); AddSeparator(hFormatBarWnd); - AddButton(hFormatBarWnd, 3, ID_ALIGN_LEFT); - AddButton(hFormatBarWnd, 4, ID_ALIGN_CENTER); - AddButton(hFormatBarWnd, 5, ID_ALIGN_RIGHT); + AddButton(hFormatBarWnd, 4, ID_ALIGN_LEFT); + AddButton(hFormatBarWnd, 5, ID_ALIGN_CENTER); + AddButton(hFormatBarWnd, 6, ID_ALIGN_RIGHT); AddSeparator(hFormatBarWnd); - AddButton(hFormatBarWnd, 6, ID_BULLET); + AddButton(hFormatBarWnd, 7, ID_BULLET); SendMessageW(hFormatBarWnd, TB_AUTOSIZE, 0, 0); @@ -2001,6 +2003,15 @@ static LRESULT OnNotify( HWND hWnd, LPARAM lParam) return 0; } +/* Copied from dlls/comdlg32/fontdlg.c */ +static const COLORREF textcolors[]= +{ + 0x00000000L,0x00000080L,0x00008000L,0x00008080L, + 0x00800000L,0x00800080L,0x00808000L,0x00808080L, + 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL, + 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL +}; + static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) { HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); @@ -2098,7 +2109,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) break; case ID_PRINT_QUICK: - print_quick(wszFileName); + print_quick(hMainWnd, wszFileName); target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); break; @@ -2106,7 +2117,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) { int index = reg_formatindex(fileFormat); DWORD tmp = barState[index]; - barState[index] = 0; + barState[index] = 1 << BANDID_STATUSBAR; set_bar_states(); barState[index] = tmp; ShowWindow(hEditorWnd, FALSE); @@ -2152,6 +2163,46 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) break; } + case ID_FORMAT_COLOR: + { + HWND hReBarWnd = GetDlgItem(hWnd, IDC_REBAR); + HWND hFormatBarWnd = GetDlgItem(hReBarWnd, IDC_FORMATBAR); + HMENU hPop; + RECT itemrc; + POINT pt; + int mid; + int itemidx = SendMessage(hFormatBarWnd, TB_COMMANDTOINDEX, ID_FORMAT_COLOR, 0); + + SendMessage(hFormatBarWnd, TB_GETITEMRECT, itemidx, (LPARAM)&itemrc); + pt.x = itemrc.left; + pt.y = itemrc.bottom; + ClientToScreen(hFormatBarWnd, &pt); + hPop = GetSubMenu(hColorPopupMenu, 0); + mid = TrackPopupMenu(hPop, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON | + TPM_RETURNCMD | TPM_NONOTIFY, + pt.x, pt.y, 0, hWnd, 0); + if (mid >= ID_COLOR_FIRST && mid <= ID_COLOR_AUTOMATIC) + { + CHARFORMAT2W fmt; + + ZeroMemory(&fmt, sizeof(fmt)); + fmt.cbSize = sizeof(fmt); + SendMessageW(hwndEditor, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); + + fmt.dwMask = CFM_COLOR; + + if (mid < ID_COLOR_AUTOMATIC) { + fmt.crTextColor = textcolors[mid - ID_COLOR_FIRST]; + fmt.dwEffects &= ~CFE_AUTOCOLOR; + } else { + fmt.dwEffects |= CFE_AUTOCOLOR; + } + + SendMessageW(hwndEditor, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); + } + break; + } + case ID_EDIT_CUT: PostMessageW(hwndEditor, WM_CUT, 0, 0); break; @@ -2618,6 +2669,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar set_bar_states(); set_fileformat(SF_RTF); hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP)); + hColorPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_COLOR_POPUP)); get_default_printer_opts(); target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); diff --git a/base/applications/wordpad/wordpad.h b/base/applications/wordpad/wordpad.h index 26aa41a1828..2f774c3aff0 100644 --- a/base/applications/wordpad/wordpad.h +++ b/base/applications/wordpad/wordpad.h @@ -80,6 +80,7 @@ #define ID_FORMAT_BOLD 1400 #define ID_FORMAT_ITALIC 1401 #define ID_FORMAT_UNDERLINE 1402 +#define ID_FORMAT_COLOR 1403 #define ID_TOGGLE_TOOLBAR 1500 #define ID_TOGGLE_FORMATBAR 1501 @@ -133,6 +134,25 @@ #define ID_ABOUT 1603 #define ID_VIEWPROPERTIES 1604 +#define ID_COLOR_FIRST 1800 +#define ID_COLOR_BLACK 1800 +#define ID_COLOR_MAROON 1801 +#define ID_COLOR_GREEN 1802 +#define ID_COLOR_OLIVE 1803 +#define ID_COLOR_NAVY 1804 +#define ID_COLOR_PURPLE 1805 +#define ID_COLOR_TEAL 1806 +#define ID_COLOR_GRAY 1807 +#define ID_COLOR_SILVER 1808 +#define ID_COLOR_RED 1809 +#define ID_COLOR_LIME 1810 +#define ID_COLOR_YELLOW 1811 +#define ID_COLOR_BLUE 1812 +#define ID_COLOR_FUCHSIA 1813 +#define ID_COLOR_AQUA 1814 +#define ID_COLOR_WHITE 1815 +#define ID_COLOR_AUTOMATIC 1816 + #define IDC_STATUSBAR 2000 #define IDC_EDITOR 2001 #define IDC_TOOLBAR 2002 @@ -159,6 +179,7 @@ #define IDM_MAINMENU 2200 #define IDM_POPUP 2201 +#define IDM_COLOR_POPUP 2202 #define IDB_TOOLBAR 100 #define IDB_FORMATBAR 101 @@ -168,6 +189,8 @@ #define IDI_WRI 104 #define IDI_TXT 105 +#define IDC_ZOOM 106 + #define STRING_ALL_FILES 1400 #define STRING_TEXT_FILES_TXT 1401 #define STRING_TEXT_FILES_UNICODE_TXT 1402 @@ -195,8 +218,10 @@ #define STRING_PREVIEW_ZOOMIN 1453 #define STRING_PREVIEW_ZOOMOUT 1454 #define STRING_PREVIEW_CLOSE 1455 +#define STRING_PREVIEW_PAGE 1456 +#define STRING_PREVIEW_PAGES 1457 -#define STRING_UNITS_CM 1456 +#define STRING_UNITS_CM 1458 #define STRING_DEFAULT_FILENAME 1700 #define STRING_PROMPT_SAVE_CHANGES 1701 @@ -217,7 +242,7 @@ LPWSTR file_basename(LPWSTR); void dialog_printsetup(HWND); void dialog_print(HWND, LPWSTR); void target_device(HWND, DWORD); -void print_quick(LPWSTR); +void print_quick(HWND, LPWSTR); LRESULT preview_command(HWND, WPARAM); void init_preview(HWND, LPWSTR); void close_preview(HWND); @@ -226,6 +251,8 @@ LRESULT print_preview(HWND); void get_default_printer_opts(void); void registry_set_pagemargins(HKEY); void registry_read_pagemargins(HKEY); +void registry_set_previewpages(HKEY hKey); +void registry_read_previewpages(HKEY hKey); LRESULT CALLBACK ruler_proc(HWND, UINT, WPARAM, LPARAM); void redraw_ruler(HWND); diff --git a/base/applications/wordpad/zoom.cur b/base/applications/wordpad/zoom.cur new file mode 100644 index 00000000000..26d1a8fa157 Binary files /dev/null and b/base/applications/wordpad/zoom.cur differ diff --git a/base/applications/write/De.rc b/base/applications/write/De.rc index 83cb909c318..db175a02d56 100644 --- a/base/applications/write/De.rc +++ b/base/applications/write/De.rc @@ -27,4 +27,3 @@ STRINGTABLE { IDS_FAILED, "Der Start von Wordpad ist fehlgeschlagen" } -#pragma code_page(default) diff --git a/base/applications/write/Fr.rc b/base/applications/write/Fr.rc index 69105d9a788..a81dffda827 100644 --- a/base/applications/write/Fr.rc +++ b/base/applications/write/Fr.rc @@ -28,4 +28,3 @@ STRINGTABLE { IDS_FAILED, "Wordpad n'a pas pu être démarré" } -#pragma code_page(default) diff --git a/base/applications/write/It.rc b/base/applications/write/It.rc index 9c8ce25a7c9..b906a7906b8 100644 --- a/base/applications/write/It.rc +++ b/base/applications/write/It.rc @@ -29,4 +29,3 @@ STRINGTABLE { IDS_FAILED, "Impossibile avviare WordPad" } -#pragma code_page(default) diff --git a/base/applications/write/Ja.rc b/base/applications/write/Ja.rc index 6b942ce02e0..5c9a8259a97 100644 --- a/base/applications/write/Ja.rc +++ b/base/applications/write/Ja.rc @@ -29,4 +29,3 @@ STRINGTABLE { IDS_FAILED, "Wordpad の起動に失敗しました" } -#pragma code_page(default) diff --git a/base/applications/write/Lt.rc b/base/applications/write/Lt.rc index 8e3eae38569..5cef934fbc7 100644 --- a/base/applications/write/Lt.rc +++ b/base/applications/write/Lt.rc @@ -29,4 +29,3 @@ STRINGTABLE { IDS_FAILED, "Nepavyko paleisti Wordpad" } -#pragma code_page(default) diff --git a/base/applications/write/Ro.rc b/base/applications/write/Ro.rc index a871350bfda..f6a7b65665f 100644 --- a/base/applications/write/Ro.rc +++ b/base/applications/write/Ro.rc @@ -27,4 +27,3 @@ STRINGTABLE { IDS_FAILED, "Execuția Wordpad a eșuat" } -#pragma code_page(default) diff --git a/base/applications/write/Ru.rc b/base/applications/write/Ru.rc index e64003fe566..008011f2720 100644 --- a/base/applications/write/Ru.rc +++ b/base/applications/write/Ru.rc @@ -29,4 +29,3 @@ STRINGTABLE { IDS_FAILED, "Не удалось запустить Wordpad" } -#pragma code_page(default) diff --git a/base/applications/write/Si.rc b/base/applications/write/Si.rc index 3eaae9ed5ee..9d3e5fe1520 100644 --- a/base/applications/write/Si.rc +++ b/base/applications/write/Si.rc @@ -28,4 +28,3 @@ STRINGTABLE { IDS_FAILED, "Zagon programa Wordpad ni uspel" } -#pragma code_page(default) diff --git a/base/applications/write/Uk.rc b/base/applications/write/Uk.rc index ac970be8bd7..f922210e0e3 100644 --- a/base/applications/write/Uk.rc +++ b/base/applications/write/Uk.rc @@ -31,4 +31,3 @@ STRINGTABLE { IDS_FAILED, "Не вдалось запустити Wordpad" } -#pragma code_page(default) diff --git a/base/applications/write/rsrc.rc b/base/applications/write/rsrc.rc index d3ddc33bdc7..45c5d308136 100644 --- a/base/applications/write/rsrc.rc +++ b/base/applications/write/rsrc.rc @@ -20,17 +20,21 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#include "De.rc" #include "En.rc" +#include "Ko.rc" +#include "Nl.rc" +#include "No.rc" +#include "Pl.rc" +#include "Pt.rc" +#include "Sv.rc" + +/* UTF-8 */ +#include "De.rc" #include "Fr.rc" #include "It.rc" #include "Ja.rc" -#include "Ko.rc" #include "Lt.rc" -#include "Nl.rc" -#include "Pt.rc" #include "Ro.rc" #include "Ru.rc" #include "Si.rc" -#include "Sv.rc" #include "Uk.rc" diff --git a/base/services/dhcp/dhclient.c b/base/services/dhcp/dhclient.c index 8b18010735c..db263bc4ab5 100644 --- a/base/services/dhcp/dhclient.c +++ b/base/services/dhcp/dhclient.c @@ -57,6 +57,7 @@ #include #include "dhcpd.h" #include "privsep.h" +#include "debug.h" #define PERIOD 0x2e #define hyphenchar(c) ((c) == 0x2d) @@ -109,22 +110,106 @@ int check_arp( struct interface_info *ip, struct client_lease *lp ) time_t scripttime; + +static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv); +static WCHAR ServiceName[] = L"DHCP"; +static SERVICE_TABLE_ENTRYW ServiceTable[] = +{ + {ServiceName, ServiceMain}, + {NULL, NULL} +}; + +SERVICE_STATUS_HANDLE ServiceStatusHandle; +SERVICE_STATUS ServiceStatus; + + /* XXX Implement me */ int check_arp( struct interface_info *ip, struct client_lease *lp ) { return 1; } -static VOID CALLBACK -DispatchMain(DWORD argc, LPTSTR *argv) + +static VOID +UpdateServiceStatus(DWORD dwState) { - dispatch(); + ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + ServiceStatus.dwCurrentState = dwState; + + ServiceStatus.dwControlsAccepted = 0; + + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwServiceSpecificExitCode = 0; + ServiceStatus.dwCheckPoint = 0; + + if (dwState == SERVICE_START_PENDING || + dwState == SERVICE_STOP_PENDING || + dwState == SERVICE_PAUSE_PENDING || + dwState == SERVICE_CONTINUE_PENDING) + ServiceStatus.dwWaitHint = 10000; + else + ServiceStatus.dwWaitHint = 0; + + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); } -static SERVICE_TABLE_ENTRY ServiceTable[2] = + +static DWORD WINAPI +ServiceControlHandler(DWORD dwControl, + DWORD dwEventType, + LPVOID lpEventData, + LPVOID lpContext) { - {TEXT("DHCP"), DispatchMain}, - {NULL, NULL} -}; + switch (dwControl) + { + case SERVICE_CONTROL_STOP: + UpdateServiceStatus(SERVICE_STOP_PENDING); + UpdateServiceStatus(SERVICE_STOPPED); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_PAUSE: + UpdateServiceStatus(SERVICE_PAUSED); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_CONTINUE: + UpdateServiceStatus(SERVICE_START_PENDING); + UpdateServiceStatus(SERVICE_RUNNING); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_INTERROGATE: + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_SHUTDOWN: + UpdateServiceStatus(SERVICE_STOP_PENDING); + UpdateServiceStatus(SERVICE_STOPPED); + return ERROR_SUCCESS; + + default : + return ERROR_CALL_NOT_IMPLEMENTED; + } +} + + +static VOID CALLBACK +ServiceMain(DWORD argc, LPWSTR *argv) +{ + ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName, + ServiceControlHandler, + NULL); + if (!ServiceStatusHandle) + { + return; + } + + UpdateServiceStatus(SERVICE_START_PENDING); + + UpdateServiceStatus(SERVICE_RUNNING); + + dispatch(); +} + int main(int argc, char *argv[]) @@ -147,7 +232,7 @@ main(int argc, char *argv[]) DH_DbgPrint(MID_TRACE,("Going into dispatch()\n")); - StartServiceCtrlDispatcher(ServiceTable); + StartServiceCtrlDispatcherW(ServiceTable); /* not reached */ return (0); diff --git a/base/services/umpnpmgr/umpnpmgr.c b/base/services/umpnpmgr/umpnpmgr.c index 8dc8a16e031..2352efe703f 100644 --- a/base/services/umpnpmgr/umpnpmgr.c +++ b/base/services/umpnpmgr/umpnpmgr.c @@ -51,15 +51,17 @@ /* GLOBALS ******************************************************************/ -static VOID CALLBACK -ServiceMain(DWORD argc, LPTSTR *argv); - -static SERVICE_TABLE_ENTRY ServiceTable[2] = +static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv); +static WCHAR ServiceName[] = L"PlugPlay"; +static SERVICE_TABLE_ENTRYW ServiceTable[] = { - {TEXT("PlugPlay"), ServiceMain}, + {ServiceName, ServiceMain}, {NULL, NULL} }; +static SERVICE_STATUS_HANDLE ServiceStatusHandle; +static SERVICE_STATUS ServiceStatus; + static WCHAR szRootDeviceId[] = L"HTREE\\ROOT\\0"; static HKEY hEnumKey = NULL; @@ -2446,6 +2448,72 @@ PnpEventThread(LPVOID lpParameter) } +static VOID +UpdateServiceStatus(DWORD dwState) +{ + ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + ServiceStatus.dwCurrentState = dwState; + ServiceStatus.dwControlsAccepted = 0; + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwServiceSpecificExitCode = 0; + ServiceStatus.dwCheckPoint = 0; + + if (dwState == SERVICE_START_PENDING || + dwState == SERVICE_STOP_PENDING || + dwState == SERVICE_PAUSE_PENDING || + dwState == SERVICE_CONTINUE_PENDING) + ServiceStatus.dwWaitHint = 10000; + else + ServiceStatus.dwWaitHint = 0; + + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); +} + + +static DWORD WINAPI +ServiceControlHandler(DWORD dwControl, + DWORD dwEventType, + LPVOID lpEventData, + LPVOID lpContext) +{ + DPRINT1("ServiceControlHandler() called\n"); + + switch (dwControl) + { + case SERVICE_CONTROL_STOP: + DPRINT1(" SERVICE_CONTROL_STOP received\n"); + UpdateServiceStatus(SERVICE_STOPPED); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_PAUSE: + DPRINT1(" SERVICE_CONTROL_PAUSE received\n"); + UpdateServiceStatus(SERVICE_PAUSED); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_CONTINUE: + DPRINT1(" SERVICE_CONTROL_CONTINUE received\n"); + UpdateServiceStatus(SERVICE_RUNNING); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_INTERROGATE: + DPRINT1(" SERVICE_CONTROL_INTERROGATE received\n"); + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_SHUTDOWN: + DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n"); + UpdateServiceStatus(SERVICE_STOPPED); + return ERROR_SUCCESS; + + default : + DPRINT1(" Control %lu received\n"); + return ERROR_CALL_NOT_IMPLEMENTED; + } +} + + static VOID CALLBACK ServiceMain(DWORD argc, LPTSTR *argv) { @@ -2457,6 +2525,17 @@ ServiceMain(DWORD argc, LPTSTR *argv) DPRINT("ServiceMain() called\n"); + ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName, + ServiceControlHandler, + NULL); + if (!ServiceStatusHandle) + { + DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError()); + return; + } + + UpdateServiceStatus(SERVICE_START_PENDING); + hThread = CreateThread(NULL, 0, PnpEventThread, @@ -2484,6 +2563,8 @@ ServiceMain(DWORD argc, LPTSTR *argv) if (hThread != NULL) CloseHandle(hThread); + UpdateServiceStatus(SERVICE_RUNNING); + DPRINT("ServiceMain() done\n"); } diff --git a/base/setup/reactos/lang/pl-PL.rc b/base/setup/reactos/lang/pl-PL.rc index 97cff875b7d..31c951397cf 100644 --- a/base/setup/reactos/lang/pl-PL.rc +++ b/base/setup/reactos/lang/pl-PL.rc @@ -66,25 +66,25 @@ BEGIN LISTBOX IDC_PARTITION, 20,12,278,142,LBS_HASSTRINGS | WS_VSCROLL PUSHBUTTON "&Stwrz", IDC_PARTCREATE, 20,155,50,15 PUSHBUTTON "&Usu", IDC_PARTDELETE, 76,155,50,15 - PUSHBUTTON "D&river", IDC_DEVICEDRIVER, 162,155,50,15, WS_DISABLED + PUSHBUTTON "s&terownik", IDC_DEVICEDRIVER, 162,155,50,15, WS_DISABLED PUSHBUTTON "&Opcje zaawansowane...", IDC_PARTMOREOPTS, 218,155,80,15 LTEXT "Nacinij Dalej aby rozpocz proces instalacji.", IDC_STATIC, 10, 180 ,277, 20 END IDD_PARTITION DIALOGEX DISCARDABLE 0, 0, 145, 90 STYLE WS_VISIBLE|WS_CAPTION|WS_THICKFRAME -CAPTION "Create Partition" +CAPTION "Stwrz partycj" FONT 8, "MS Shell Dlg" BEGIN CONTROL "",IDC_UPDOWN1,"msctls_updown32", WS_VISIBLE,104,22,9,13 - CONTROL "Create and format partition",IDC_STATIC,"Button",BS_GROUPBOX,7,5,129,57 - LTEXT "Size:",IDC_STATIC, 13,24,27,9 + CONTROL "Stwrz i sformatuj partycj",IDC_STATIC,"Button",BS_GROUPBOX,7,5,129,57 + LTEXT "Rozmiar:",IDC_STATIC, 13,24,27,9 EDITTEXT IDC_PARTSIZE,52,23,53,13, WS_VISIBLE|WS_TABSTOP LTEXT "GB",IDC_UNIT, 117,24,14,9 - LTEXT "Filesystem:",IDC_STATIC,13,46,35,9 + LTEXT "System plikw:",IDC_STATIC,13,46,35,9 CONTROL "",IDC_FSTYPE,"ComboBox",WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,52,42,79,50 PUSHBUTTON "&OK",IDOK,35,68,47,15, WS_VISIBLE|WS_TABSTOP - PUSHBUTTON "&Cancel",IDCANCEL,87,68,47,15, WS_VISIBLE|WS_TABSTOP + PUSHBUTTON "&Anuluj",IDCANCEL,87,68,47,15, WS_VISIBLE|WS_TABSTOP END IDD_BOOTOPTIONS DIALOGEX DISCARDABLE 0, 0, 305, 105 @@ -105,11 +105,11 @@ END IDD_SUMMARYPAGE DIALOGEX 0, 0, 317, 193 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "ReactOS Setup" +CAPTION "Instalator ReactOS" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "Installation summary", IDC_ACTION, "Button", BS_GROUPBOX, 10,0,297,172 - LTEXT "Click Next to start the installation process.", IDC_STATIC, 10, 180 ,277, 20 + CONTROL "Podsumowanie instalacji", IDC_ACTION, "Button", BS_GROUPBOX, 10,0,297,172 + LTEXT "Kliknij Dalej aby rozpocz proces instalacji.", IDC_STATIC, 10, 180 ,277, 20 END IDD_PROCESSPAGE DIALOGEX 0, 0, 317, 193 @@ -151,8 +151,8 @@ BEGIN IDS_PROCESSSUBTITLE "Przygotuj i sformatuj partycj, skopiuj pliki, skopiuj i zainstaluj bootloader" IDS_RESTARTTITLE "Pierwszy etap instalacji zakoczony sukcesem" IDS_RESTARTSUBTITLE "Pierwszy etap instalacji zosta zakoczony, uruchom ponownie komputer aby przej do drugiego etapu" - IDS_SUMMARYTITLE "Installation Summary" - IDS_SUMMARYSUBTITLE "List installation properties to check before apply to the installation device" + IDS_SUMMARYTITLE "Podsumowanie instalacji" + IDS_SUMMARYSUBTITLE "Sprawd ustawienia instalacji przed dokonaniem zmian na dysku" IDS_ABORTSETUP "Instalacja ReactOS nie zostaa ukoczona na tym komputerze. Jeli teraz zakoczysz instalacj, bdziesz musia uruchomi Instalator ponownie, aby zainstalowa Reactos. Na pewno zakoczy?" IDS_ABORTSETUP2 "Przerwa instalacj?" END diff --git a/base/shell/cmd/lang/pl-PL.rc b/base/shell/cmd/lang/pl-PL.rc index 58bdadfc262..f8d2cb79a02 100644 --- a/base/shell/cmd/lang/pl-PL.rc +++ b/base/shell/cmd/lang/pl-PL.rc @@ -8,13 +8,13 @@ LANGUAGE LANG_POLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE BEGIN -STRING_ASSOC_HELP, "Modify file extension associations.\n\n\ -assoc [.ext[=[FileType]]]\n\ +STRING_ASSOC_HELP, "Modyfikuje skojarzenia rozszerze plikw.\n\n\ +assoc [.ext[=[typPliku]]]\n\ \n\ -assoc (print all associations)\n\ -assoc .ext (print specific association)\n\ -assoc .ext= (remove specific association)\n\ -assoc .ext=FileType (add new association)\n" +assoc (wywietla wszystkie skojarzenia)\n\ +assoc .ext (wywietla okrelone skojarzenie)\n\ +assoc .ext= (usuwa okrelone skojarzenie)\n\ +assoc .ext=typPliku (dodaje nowe skojarzenie)\n" STRING_ATTRIB_HELP, "Wywietla lub zmienia atrybuty plikw.\n\n\ ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] nazwa_pliku ...\n\ @@ -298,12 +298,12 @@ STRING_LOCALE_HELP1, "Czas bie STRING_MKDIR_HELP, "Tworzy katalog.\n\n\ MKDIR [napd:]cieka\nMD [napd:]cieka" -STRING_MKLINK_HELP, "Creates a filesystem link object.\n\n\ -MKLINK [/D | /H | /J] linkname target\n\n\ - /D Indicates that the symbolic link target is a directory.\n\ - /H Create a hard link.\n\ - /J Create a directory junction.\n\n\ -If neither /H or /J is specified, a symbolic link is created." +STRING_MKLINK_HELP, "Tworzy dowizanie obiektu w systemie plikw.\n\n\ +MKLINK [/D | /H | /J] nazwa_linku element_docelowy\n\n\ + /D Oznacza, e dowizanie symboliczne elementu docelowego jest katalogiem.\n\ + /H Tworzy dowizanie twarde.\n\ + /J Tworzy punkt poczenia katalogw.\n\n\ +Jeli nie zostay uyte zarwno /H jak i /J, zostanie utworzone dowizanie symboliczne." STRING_MEMMORY_HELP1, "Wywietla ilo pamici systemowej.\n\nMEMORY" @@ -546,7 +546,7 @@ IF Przetwarzanie warunkowe w programach wsadowych.\n\ LABEL Tworzy, zmienia lub kasuje etykiet woluminu w danym napdzie.\n\ MD Tworzy katalog.\n\ MKDIR Tworzy katalog.\n\ -MKLINK Creates a filesystem link object.\n\ +MKLINK Tworzy dowizanie obiektu w systemie plikw.\n\ MOVE Przenosi jeden lub wicej plikw z jednego katalogu do drugiego.\n\ PATH Wywietla lub ustawia cieki dostpu dla programw.\n\ PAUSE Zawiesza przetwarzanie programu wsadowego i wywietla komunikat.\n\ @@ -656,11 +656,11 @@ STRING_FOR_ERROR, "z STRING_SCREEN_COL, "nieprawidowy numer kolumny" STRING_SCREEN_ROW, "nieprawidowy numer rzdu" STRING_TIMER_TIME "Stoper %d czas - %s: " -STRING_MKLINK_CREATED_SYMBOLIC, "Symbolic link created for %s <<===>> %s\n" -STRING_MKLINK_CREATED_HARD, "Hard link created for %s <<===>> %s\n" -STRING_MKLINK_CREATED_JUNCTION, "Junction created for %s <<===>> %s\n" -STRING_MORE, "More? " -STRING_CANCEL_BATCH_FILE, "\r\nCtrl-Break pressed. Cancel batch file? (Tak/Nie/Zawsze) " +STRING_MKLINK_CREATED_SYMBOLIC, "Dowizanie symboliczne utworzone dla %s <<===>> %s\n" +STRING_MKLINK_CREATED_HARD, "Dowizanie twarde utworzone dla %s <<===>> %s\n" +STRING_MKLINK_CREATED_JUNCTION, "Punkt dowizania katalogw utworzony dla %s <<===>> %s\n" +STRING_MORE, "Wicej? " +STRING_CANCEL_BATCH_FILE, "\r\nWcinito Ctrl-Break. Anulowa wykonanie pliku wsadowego? (Tak/Nie/Zawsze) " STRING_INVALID_OPERAND, "Nieprawidowy argument operatora." STRING_EXPECTED_CLOSE_PAREN, "Oczekiwano ')'." diff --git a/base/shell/cmd/precomp.h b/base/shell/cmd/precomp.h index f36368e1d59..915246cceb8 100644 --- a/base/shell/cmd/precomp.h +++ b/base/shell/cmd/precomp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __CMD_PRECOMP_H +#define __CMD_PRECOMP_H #ifdef _MSC_VER #pragma warning ( disable : 4103 ) /* use #pragma pack to change alignment */ @@ -42,3 +43,5 @@ WINE_DEFAULT_DEBUG_CHANNEL(cmd); #else #define debugstr_aw debugstr_a #endif + +#endif /* __CMD_PRECOMP_H */ diff --git a/base/system/msiexec/msiexec.c b/base/system/msiexec/msiexec.c index 9221fa2a9ce..fe19d98e434 100644 --- a/base/system/msiexec/msiexec.c +++ b/base/system/msiexec/msiexec.c @@ -47,6 +47,7 @@ static const char UsageStr[] = " Install a product:\n" " msiexec {package|productcode} [property]\n" " msiexec /i {package|productcode} [property]\n" +" msiexec /package {package|productcode} [property]\n" " msiexec /a package [property]\n" " Repair an installation:\n" " msiexec /f[p|o|e|d|c|a|u|m|s|v] {package|productcode}\n" @@ -562,12 +563,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine { FunctionUnregServer = TRUE; } - else if(msi_option_prefix(argvW[i], "i")) + else if(msi_option_prefix(argvW[i], "i") || msi_option_prefix(argvW[i], "package")) { LPWSTR argvWi = argvW[i]; + int argLen = (msi_option_prefix(argvW[i], "i") ? 2 : 8); FunctionInstall = TRUE; - if(lstrlenW(argvWi) > 2) - argvWi += 2; + if(lstrlenW(argvW[i]) > argLen) + argvWi += argLen; else { i++; diff --git a/base/system/msiexec/msiexec.rbuild b/base/system/msiexec/msiexec.rbuild index a3a24950930..228875d72c7 100644 --- a/base/system/msiexec/msiexec.rbuild +++ b/base/system/msiexec/msiexec.rbuild @@ -12,7 +12,6 @@ ole32 msi msiexec.c - rsrc.rc service.c - version.rc + rsrc.rc diff --git a/base/system/msiexec/rsrc.rc b/base/system/msiexec/rsrc.rc index 01e43befe19..cfc89370039 100644 --- a/base/system/msiexec/rsrc.rc +++ b/base/system/msiexec/rsrc.rc @@ -18,7 +18,16 @@ #include -#include "version.rc" +#define WINE_FILEDESCRIPTION_STR "Wine Installer" +#define WINE_FILENAME_STR "msiexec.exe" +#define WINE_FILETYPE VFT_APP +#define WINE_FILEVERSION 3,1,4000,1823 +#define WINE_FILEVERSION_STR "3.1.4000.1823" +#define WINE_PRODUCTVERSION 3,1,4000,1823 +#define WINE_PRODUCTVERSION_STR "3.1.4000.1823" +#define WINE_PRODUCTNAME_STR "Wine Installer" + +#include "wine/wine_common_ver.rc" LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL diff --git a/base/system/services/database.c b/base/system/services/database.c index 2a0ae9859f9..7a9819e4c8b 100644 --- a/base/system/services/database.c +++ b/base/system/services/database.c @@ -121,37 +121,6 @@ ScmGetServiceEntryByResumeCount(DWORD dwResumeCount) } -PSERVICE -ScmGetServiceEntryByClientHandle(HANDLE Handle) -{ - PLIST_ENTRY ServiceEntry; - PSERVICE CurrentService; - - DPRINT("ScmGetServiceEntryByClientHandle() called\n"); - DPRINT("looking for %p\n", Handle); - - ServiceEntry = ServiceListHead.Flink; - while (ServiceEntry != &ServiceListHead) - { - CurrentService = CONTAINING_RECORD(ServiceEntry, - SERVICE, - ServiceListEntry); - - if (CurrentService->hClient == Handle) - { - DPRINT("Found service: '%S'\n", CurrentService->lpDisplayName); - return CurrentService; - } - - ServiceEntry = ServiceEntry->Flink; - } - - DPRINT("Couldn't find a matching service\n"); - - return NULL; -} - - DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName, PSERVICE *lpServiceRecord) @@ -710,12 +679,15 @@ ScmGetBootAndSystemDriverState(VOID) DWORD ScmControlService(PSERVICE Service, - DWORD dwControl, - LPSERVICE_STATUS lpServiceStatus) + DWORD dwControl) { PSCM_CONTROL_PACKET ControlPacket; - DWORD Count; + SCM_REPLY_PACKET ReplyPacket; + + DWORD dwWriteCount = 0; + DWORD dwReadCount = 0; DWORD TotalLength; + DWORD dwError = ERROR_SUCCESS; DPRINT("ScmControlService() called\n"); @@ -728,31 +700,37 @@ ScmControlService(PSERVICE Service, return ERROR_NOT_ENOUGH_MEMORY; ControlPacket->dwControl = dwControl; - ControlPacket->hClient = Service->hClient; ControlPacket->dwSize = TotalLength; + ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service; wcscpy(&ControlPacket->szArguments[0], Service->lpServiceName); /* Send the control packet */ WriteFile(Service->ControlPipeHandle, ControlPacket, sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)), - &Count, + &dwWriteCount, NULL); - /* FIXME: Read the reply */ + /* Read the reply */ + ReadFile(Service->ControlPipeHandle, + &ReplyPacket, + sizeof(SCM_REPLY_PACKET), + &dwReadCount, + NULL); /* Release the contol packet */ HeapFree(GetProcessHeap(), 0, ControlPacket); - RtlCopyMemory(lpServiceStatus, - &Service->Status, - sizeof(SERVICE_STATUS)); + if (dwReadCount == sizeof(SCM_REPLY_PACKET)) + { + dwError = ReplyPacket.dwError; + } - DPRINT("ScmControlService) done\n"); + DPRINT("ScmControlService() done\n"); - return ERROR_SUCCESS; + return dwError; } @@ -762,11 +740,15 @@ ScmSendStartCommand(PSERVICE Service, LPWSTR *argv) { PSCM_CONTROL_PACKET ControlPacket; + SCM_REPLY_PACKET ReplyPacket; DWORD TotalLength; DWORD ArgsLength = 0; DWORD Length; PWSTR Ptr; - DWORD Count; + DWORD dwWriteCount = 0; + DWORD dwReadCount = 0; + DWORD dwError = ERROR_SUCCESS; + DWORD i; DPRINT("ScmSendStartCommand() called\n"); @@ -774,10 +756,10 @@ ScmSendStartCommand(PSERVICE Service, TotalLength = wcslen(Service->lpServiceName) + 1; if (argc > 0) { - for (Count = 0; Count < argc; Count++) + for (i = 0; i < argc; i++) { - DPRINT("Arg: %S\n", argv[Count]); - Length = wcslen(argv[Count]) + 1; + DPRINT("Arg: %S\n", argv[i]); + Length = wcslen(argv[i]) + 1; TotalLength += Length; ArgsLength += Length; } @@ -793,7 +775,7 @@ ScmSendStartCommand(PSERVICE Service, return ERROR_NOT_ENOUGH_MEMORY; ControlPacket->dwControl = SERVICE_CONTROL_START; - ControlPacket->hClient = Service->hClient; + ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service; ControlPacket->dwSize = TotalLength; Ptr = &ControlPacket->szArguments[0]; wcscpy(Ptr, Service->lpServiceName); @@ -817,19 +799,29 @@ ScmSendStartCommand(PSERVICE Service, WriteFile(Service->ControlPipeHandle, ControlPacket, sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR), - &Count, + &dwWriteCount, NULL); - /* FIXME: Read the reply */ + /* Read the reply */ + ReadFile(Service->ControlPipeHandle, + &ReplyPacket, + sizeof(SCM_REPLY_PACKET), + &dwReadCount, + NULL); /* Release the contol packet */ HeapFree(GetProcessHeap(), 0, ControlPacket); + if (dwReadCount == sizeof(SCM_REPLY_PACKET)) + { + dwError = ReplyPacket.dwError; + } + DPRINT("ScmSendStartCommand() done\n"); - return ERROR_SUCCESS; + return dwError; } @@ -850,6 +842,7 @@ ScmStartUserModeService(PSERVICE Service, WCHAR NtControlPipeName[MAX_PATH + 1]; HKEY hServiceCurrentKey = INVALID_HANDLE_VALUE; DWORD KeyDisposition; + DWORD dwProcessId; RtlInitUnicodeString(&ImagePath, NULL); @@ -991,7 +984,7 @@ ScmStartUserModeService(PSERVICE Service, /* Read SERVICE_STATUS_HANDLE from pipe */ if (!ReadFile(Service->ControlPipeHandle, - (LPVOID)&Service->hClient, + (LPVOID)&dwProcessId, sizeof(DWORD), &dwRead, NULL)) @@ -1002,7 +995,7 @@ ScmStartUserModeService(PSERVICE Service, } else { - DPRINT("Received service status %lu\n", Service->hClient); + DPRINT("Received service process ID %lu\n", dwProcessId); /* Send start command */ dwError = ScmSendStartCommand(Service, argc, argv); @@ -1222,7 +1215,6 @@ ScmAutoShutdownServices(VOID) { PLIST_ENTRY ServiceEntry; PSERVICE CurrentService; - SERVICE_STATUS ServiceStatus; DPRINT("ScmAutoShutdownServices() called\n"); @@ -1235,7 +1227,7 @@ ScmAutoShutdownServices(VOID) CurrentService->Status.dwCurrentState == SERVICE_START_PENDING) { /* shutdown service */ - ScmControlService(CurrentService, SERVICE_CONTROL_STOP, &ServiceStatus); + ScmControlService(CurrentService, SERVICE_CONTROL_STOP); } ServiceEntry = ServiceEntry->Flink; @@ -1244,4 +1236,25 @@ ScmAutoShutdownServices(VOID) DPRINT("ScmGetBootAndSystemDriverState() done\n"); } + +BOOL +ScmLockDatabaseExclusive(VOID) +{ + return RtlAcquireResourceExclusive(&DatabaseLock, TRUE); +} + + +BOOL +ScmLockDatabaseShared(VOID) +{ + return RtlAcquireResourceShared(&DatabaseLock, TRUE); +} + + +VOID +ScmUnlockDatabase(VOID) +{ + RtlReleaseResource(&DatabaseLock); +} + /* EOF */ diff --git a/base/system/services/rpcserver.c b/base/system/services/rpcserver.c index 2262aa55e71..914e013327b 100644 --- a/base/system/services/rpcserver.c +++ b/base/system/services/rpcserver.c @@ -637,8 +637,12 @@ DWORD RControlService( { /* Send control code to the service */ dwError = ScmControlService(lpService, - dwControl, - lpServiceStatus); + dwControl); + + /* Return service status information */ + RtlCopyMemory(lpServiceStatus, + &lpService->Status, + sizeof(SERVICE_STATUS)); } if ((dwError == ERROR_SUCCESS) && (pcbBytesNeeded)) @@ -652,10 +656,6 @@ DWORD RControlService( lpService->ThreadId = 0; } - /* Return service status information */ - RtlCopyMemory(lpServiceStatus, - &lpService->Status, - sizeof(SERVICE_STATUS)); return dwError; } @@ -978,11 +978,15 @@ DWORD RQueryServiceStatus( return ERROR_INVALID_HANDLE; } + ScmLockDatabaseShared(); + /* Return service status information */ RtlCopyMemory(lpServiceStatus, &lpService->Status, sizeof(SERVICE_STATUS)); + ScmUnlockDatabase(); + return ERROR_SUCCESS; } @@ -1030,7 +1034,7 @@ DWORD RSetServiceStatus( return ERROR_INVALID_HANDLE; } - lpService = ScmGetServiceEntryByClientHandle((HANDLE)hServiceStatus); + lpService = (PSERVICE)hServiceStatus; if (lpService == NULL) { DPRINT("lpService == NULL!\n"); @@ -1059,11 +1063,14 @@ DWORD RSetServiceStatus( return ERROR_INVALID_DATA; } + ScmLockDatabaseExclusive(); RtlCopyMemory(&lpService->Status, lpServiceStatus, sizeof(SERVICE_STATUS)); + ScmUnlockDatabase(); + DPRINT("Set %S to %lu\n", lpService->lpDisplayName, lpService->Status.dwCurrentState); DPRINT("RSetServiceStatus() done\n"); diff --git a/base/system/services/services.h b/base/system/services/services.h index 23022dc2c92..8371ad18b71 100644 --- a/base/system/services/services.h +++ b/base/system/services/services.h @@ -42,7 +42,6 @@ typedef struct _SERVICE DWORD dwResumeCount; DWORD dwRefCount; - CLIENT_HANDLE hClient; SERVICE_STATUS Status; DWORD dwStartType; DWORD dwErrorControl; @@ -112,15 +111,18 @@ DWORD ScmStartService(PSERVICE Service, PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName); PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName); PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount); -PSERVICE ScmGetServiceEntryByClientHandle(HANDLE Handle); DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName, PSERVICE *lpServiceRecord); VOID ScmDeleteServiceRecord(PSERVICE lpService); DWORD ScmMarkServiceForDelete(PSERVICE pService); DWORD ScmControlService(PSERVICE Service, - DWORD dwControl, - LPSERVICE_STATUS lpServiceStatus); + DWORD dwControl); + +BOOL ScmLockDatabaseExclusive(VOID); +BOOL ScmLockDatabaseShared(VOID); +VOID ScmUnlockDatabase(VOID); + /* driver.c */ diff --git a/base/system/smss/smss.h b/base/system/smss/smss.h index 8c467e566dc..61f3b4bead4 100644 --- a/base/system/smss/smss.h +++ b/base/system/smss/smss.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _SMSS_H_INCLUDED_ +#define _SMSS_H_INCLUDED_ #include #include @@ -112,4 +113,7 @@ NTSTATUS SmInitializeDbgSs(VOID); VOID NTAPI DisplayString(LPCWSTR lpwString); VOID NTAPI PrintString (char* fmt, ...); +#endif /* _SMSS_H_INCLUDED_ */ + /* EOF */ + diff --git a/boot/bootdata/packages/reactos.dff b/boot/bootdata/packages/reactos.dff index 248f5f7c347..c8be7bd6a18 100644 --- a/boot/bootdata/packages/reactos.dff +++ b/boot/bootdata/packages/reactos.dff @@ -482,6 +482,9 @@ drivers\base\beep\beep.sys 2 drivers\base\null\null.sys 2 drivers\base\nmidebug\nmidebug.sys 2 +drivers\battery\cmbatt\cmbatt.sys 2 +drivers\battery\battc\battc.sys 2 + drivers\bus\isapnp\isapnp.sys 2 drivers\directx\dxapi\dxapi.sys 2 @@ -628,7 +631,9 @@ media\nls\c_28606.nls 1 media\drivers\etc\services 5 media\inf\audio.inf 6 media\inf\acpi.inf 6 +media\inf\battery.inf 6 media\inf\cdrom.inf 6 +media\inf\cpu.inf 6 media\inf\display.inf 6 media\inf\font.inf 6 media\inf\fdc.inf 6 @@ -754,6 +759,7 @@ modules\rostests\winetests\comctl32\comctl32_winetest.exe 7 o modules\rostests\winetests\comdlg32\comdlg32_winetest.exe 7 optional modules\rostests\winetests\crypt32\crypt32_winetest.exe 7 optional modules\rostests\winetests\cryptnet\cryptnet_winetest.exe 7 optional +modules\rostests\winetests\dsound\dsound_winetest.exe 7 optional modules\rostests\winetests\gdi32\gdi32_winetest.exe 7 optional modules\rostests\winetests\gdiplus\gdiplus_winetest.exe 7 optional modules\rostests\winetests\hlink\hlink_winetest.exe 7 optional @@ -797,6 +803,7 @@ modules\rostests\winetests\winmm\winmm_winetest.exe 7 o modules\rostests\winetests\wintrust\wintrust_winetest.exe 7 optional modules\rostests\winetests\wlanapi\wlanapi_winetest.exe 7 optional modules\rostests\winetests\ws2_32\ws2_32_winetest.exe 7 optional +modules\rostests\winetests\xmllite\xmllite_winetest.exe 7 optional modules\wallpaper\Angelus_02_ROSWP.bmp 4 optional diff --git a/boot/freeldr/freeldr/arch/i386/halstub.c b/boot/freeldr/freeldr/arch/i386/halstub.c new file mode 100644 index 00000000000..02aca2b67de --- /dev/null +++ b/boot/freeldr/freeldr/arch/i386/halstub.c @@ -0,0 +1,97 @@ +/* +* PROJECT: ReactOS Kernel +* LICENSE: GPL - See COPYING in the top level directory +* FILE: boot/freeldr/freeldr/arch/i386/hal/halstub.c +* PURPOSE: I/O Stub HAL Routines +* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) +*/ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +FASTCALL +xHalIoReadPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer) +{ + return IoReadPartitionTable(DeviceObject, + SectorSize, + ReturnRecognizedPartitions, + PartitionBuffer); +} + +UCHAR +NTAPI +xHalVectorToIDTEntry(IN ULONG Vector) +{ + /* Return the vector */ + return Vector; +} + +VOID +NTAPI +xHalHaltSystem(VOID) +{ + /* Halt execution */ + while (TRUE); +} + +/* GLOBALS *******************************************************************/ + +HAL_DISPATCH HalDispatchTable = +{ + HAL_DISPATCH_VERSION, + (pHalQuerySystemInformation)NULL, + (pHalSetSystemInformation)NULL, + (pHalQueryBusSlots)NULL, + 0, + (pHalExamineMBR)NULL, + (pHalIoAssignDriveLetters)NULL, + (pHalIoReadPartitionTable)xHalIoReadPartitionTable, + (pHalIoSetPartitionInformation)NULL, + (pHalIoWritePartitionTable)NULL, + (pHalHandlerForBus)NULL, + (pHalReferenceBusHandler)NULL, + (pHalReferenceBusHandler)NULL, + (pHalInitPnpDriver)NULL, + (pHalInitPowerManagement)NULL, + (pHalGetDmaAdapter)NULL, + (pHalGetInterruptTranslator)NULL, + (pHalStartMirroring)NULL, + (pHalEndMirroring)NULL, + (pHalMirrorPhysicalMemory)NULL, + (pHalEndOfBoot)NULL, + (pHalMirrorVerify)NULL +}; + +HAL_PRIVATE_DISPATCH HalPrivateDispatchTable = +{ + HAL_PRIVATE_DISPATCH_VERSION, + (pHalHandlerForBus)NULL, + (pHalHandlerForConfigSpace)NULL, + (pHalLocateHiberRanges)NULL, + (pHalRegisterBusHandler)NULL, + (pHalSetWakeEnable)NULL, + (pHalSetWakeAlarm)NULL, + (pHalTranslateBusAddress)NULL, + (pHalAssignSlotResources)NULL, + (pHalHaltSystem)xHalHaltSystem, + (pHalFindBusAddressTranslation)NULL, + (pHalResetDisplay)NULL, + (pHalAllocateMapRegisters)NULL, + (pKdSetupPciDeviceForDebugging)NULL, + (pKdReleasePciDeviceForDebugging)NULL, + (pKdGetAcpiTablePhase0)NULL, + (pKdCheckPowerButton)NULL, + (pHalVectorToIDTEntry)xHalVectorToIDTEntry, + (pKdMapPhysicalMemory64)NULL, + (pKdUnmapVirtualAddress)NULL +}; diff --git a/boot/freeldr/freeldr/arch/i386/loader.c b/boot/freeldr/freeldr/arch/i386/loader.c index 70ad27f2be0..c9ae5c454e1 100644 --- a/boot/freeldr/freeldr/arch/i386/loader.c +++ b/boot/freeldr/freeldr/arch/i386/loader.c @@ -17,7 +17,6 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _NTSYSTEM_ #include #define NDEBUG diff --git a/boot/freeldr/freeldr/arch/i386/ntoskrnl.c b/boot/freeldr/freeldr/arch/i386/ntoskrnl.c new file mode 100644 index 00000000000..dcc51ef2b59 --- /dev/null +++ b/boot/freeldr/freeldr/arch/i386/ntoskrnl.c @@ -0,0 +1,114 @@ +#include +#define NDEBUG +#include + +VOID +NTAPI +KeInitializeEvent( + IN PRKEVENT Event, + IN EVENT_TYPE Type, + IN BOOLEAN State) +{ +} + +VOID +FASTCALL +KiAcquireSpinLock( + IN PKSPIN_LOCK SpinLock) +{ +} + +VOID +FASTCALL +KiReleaseSpinLock( + IN PKSPIN_LOCK SpinLock) +{ +} + +VOID +NTAPI +KeSetTimeIncrement( + IN ULONG MaxIncrement, + IN ULONG MinIncrement) +{ +} + +NTKERNELAPI +VOID +FASTCALL +IoAssignDriveLetters( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN PSTRING NtDeviceName, + OUT PUCHAR NtSystemPath, + OUT PSTRING NtSystemPathString) +{ +} + +NTKERNELAPI +NTSTATUS +FASTCALL +IoSetPartitionInformation( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG PartitionNumber, + IN ULONG PartitionType) +{ + return STATUS_NOT_IMPLEMENTED; +} + +NTKERNELAPI +NTSTATUS +FASTCALL +IoWritePartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG SectorsPerTrack, + IN ULONG NumberOfHeads, + IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer) +{ + return STATUS_NOT_IMPLEMENTED; +} + +NTHALAPI +VOID +NTAPI +KeStallExecutionProcessor( + IN ULONG MicroSeconds) +{ + REGS Regs; + ULONG usec_this; + + // Int 15h AH=86h + // BIOS - WAIT (AT,PS) + // + // AH = 86h + // CX:DX = interval in microseconds + // Return: + // CF clear if successful (wait interval elapsed) + // CF set on error or AH=83h wait already in progress + // AH = status (see #00496) + + // Note: The resolution of the wait period is 977 microseconds on + // many systems because many BIOSes use the 1/1024 second fast + // interrupt from the AT real-time clock chip which is available on INT 70; + // because newer BIOSes may have much more precise timers available, it is + // not possible to use this function accurately for very short delays unless + // the precise behavior of the BIOS is known (or found through testing) + + while (MicroSeconds) + { + usec_this = MicroSeconds; + + if (usec_this > 4000000) + { + usec_this = 4000000; + } + + Regs.b.ah = 0x86; + Regs.w.cx = usec_this >> 16; + Regs.w.dx = usec_this & 0xffff; + Int386(0x15, &Regs, &Regs); + + MicroSeconds -= usec_this; + } +} diff --git a/boot/freeldr/freeldr/bootmgr.c b/boot/freeldr/freeldr/bootmgr.c index 2a8e7be272b..0959de69d69 100644 --- a/boot/freeldr/freeldr/bootmgr.c +++ b/boot/freeldr/freeldr/bootmgr.c @@ -119,6 +119,12 @@ VOID RunLoader(VOID) return; } + // Load additional SCSI driver (if any) + if (LoadBootDeviceDriver() != ESUCCESS) + { + UiMessageBoxCritical("Unable to load additional boot device driver"); + } + if (!IniFileInitialize()) { UiMessageBoxCritical("Error initializing .ini file"); diff --git a/boot/freeldr/freeldr/debug.c b/boot/freeldr/freeldr/debug.c index 6aebbd18252..0de49f52320 100644 --- a/boot/freeldr/freeldr/debug.c +++ b/boot/freeldr/freeldr/debug.c @@ -173,6 +173,12 @@ VOID DebugPrintHeader(ULONG Mask) case DPRINT_HWDETECT: DbgPrint("HWDETECT: "); break; + case DPRINT_PELOADER: + DbgPrint("PELOADER: "); + break; + case DPRINT_SCSIPORT: + DbgPrint("SCSIPORT: "); + break; default: DbgPrint("UNKNOWN: "); break; @@ -194,6 +200,12 @@ VOID DbgPrintMask(ULONG Mask, char *format, ...) return; } + // Disable file/line for scsiport messages + if (Mask & DPRINT_SCSIPORT) + { + DebugStartOfLine = FALSE; + } + // Print the header if we have started a new line if (DebugStartOfLine) { @@ -328,3 +340,22 @@ MsgBoxPrint(const char *Format, ...) return 0; } +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +KeBugCheckEx( + IN ULONG BugCheckCode, + IN ULONG_PTR BugCheckParameter1, + IN ULONG_PTR BugCheckParameter2, + IN ULONG_PTR BugCheckParameter3, + IN ULONG_PTR BugCheckParameter4) +{ + char Buffer[64]; + sprintf(Buffer, "*** STOP: 0x%08lX (0x%08lX, 0x%08lX, 0x%08lX, 0x%08lX)", + BugCheckCode, BugCheckParameter1, BugCheckParameter2, + BugCheckParameter3, BugCheckParameter4); + UiMessageBoxCritical(Buffer); + assert(FALSE); + for (;;); +} diff --git a/boot/freeldr/freeldr/disk/partition.c b/boot/freeldr/freeldr/disk/partition.c index 7dd07aa230f..8966e67187a 100644 --- a/boot/freeldr/freeldr/disk/partition.c +++ b/boot/freeldr/freeldr/disk/partition.c @@ -240,4 +240,152 @@ BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMA return TRUE; } +NTSTATUS +NTAPI +IopReadBootRecord( + IN PDEVICE_OBJECT DeviceObject, + IN ULONGLONG LogicalSectorNumber, + IN ULONG SectorSize, + OUT PMASTER_BOOT_RECORD BootRecord) +{ + ULONG FileId = (ULONG)DeviceObject; + LARGE_INTEGER Position; + ULONG BytesRead; + ULONG Status; + + Position.QuadPart = LogicalSectorNumber * SectorSize; + Status = ArcSeek(FileId, &Position, SeekAbsolute); + if (Status != ESUCCESS) + return STATUS_IO_DEVICE_ERROR; + + Status = ArcRead(FileId, BootRecord, SectorSize, &BytesRead); + if (Status != ESUCCESS || BytesRead != SectorSize) + return STATUS_IO_DEVICE_ERROR; + + return STATUS_SUCCESS; +} + +BOOLEAN +NTAPI +IopCopyPartitionRecord( + IN BOOLEAN ReturnRecognizedPartitions, + IN ULONG SectorSize, + IN PPARTITION_TABLE_ENTRY PartitionTableEntry, + OUT PARTITION_INFORMATION *PartitionEntry) +{ + BOOLEAN IsRecognized; + + IsRecognized = TRUE; /* FIXME */ + if (!IsRecognized && ReturnRecognizedPartitions) + return FALSE; + + PartitionEntry->StartingOffset.QuadPart = (ULONGLONG)PartitionTableEntry->SectorCountBeforePartition * SectorSize; + PartitionEntry->PartitionLength.QuadPart = (ULONGLONG)PartitionTableEntry->PartitionSectorCount * SectorSize; + PartitionEntry->HiddenSectors = 0; + PartitionEntry->PartitionNumber = 0; /* Will be filled later */ + PartitionEntry->PartitionType = PartitionTableEntry->SystemIndicator; + PartitionEntry->BootIndicator = (PartitionTableEntry->BootIndicator & 0x80) ? TRUE : FALSE; + PartitionEntry->RecognizedPartition = IsRecognized; + PartitionEntry->RewritePartition = FALSE; + + return TRUE; +} + +NTKERNELAPI +NTSTATUS +FASTCALL +IoReadPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer) +{ + PMASTER_BOOT_RECORD MasterBootRecord; + PDRIVE_LAYOUT_INFORMATION Partitions; + ULONG NbPartitions, i, Size; + NTSTATUS ret; + + *PartitionBuffer = NULL; + + if (SectorSize < sizeof(MASTER_BOOT_RECORD)) + return STATUS_NOT_SUPPORTED; + + MasterBootRecord = ExAllocatePool(NonPagedPool, SectorSize); + if (!MasterBootRecord) + return STATUS_NO_MEMORY; + + /* Read disk MBR */ + ret = IopReadBootRecord(DeviceObject, 0, SectorSize, MasterBootRecord); + if (!NT_SUCCESS(ret)) + { + ExFreePool(MasterBootRecord); + return ret; + } + + /* Check validity of boot record */ + if (MasterBootRecord->MasterBootRecordMagic != 0xaa55) + { + ExFreePool(MasterBootRecord); + return STATUS_NOT_SUPPORTED; + } + + /* Count number of partitions */ + NbPartitions = 0; + for (i = 0; i < 4; i++) + { + NbPartitions++; + + if (MasterBootRecord->PartitionTable[i].SystemIndicator == PARTITION_EXTENDED || + MasterBootRecord->PartitionTable[i].SystemIndicator == PARTITION_XINT13_EXTENDED) + { + /* FIXME: unhandled case; count number of partitions */ + UNIMPLEMENTED; + } + } + + if (NbPartitions == 0) + { + ExFreePool(MasterBootRecord); + return STATUS_NOT_SUPPORTED; + } + + /* Allocation space to store partitions */ + Size = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION, PartitionEntry) + + NbPartitions * sizeof(PARTITION_INFORMATION); + Partitions = ExAllocatePool(NonPagedPool, Size); + if (!Partitions) + { + ExFreePool(MasterBootRecord); + return STATUS_NO_MEMORY; + } + + /* Count number of partitions */ + NbPartitions = 0; + for (i = 0; i < 4; i++) + { + if (IopCopyPartitionRecord(ReturnRecognizedPartitions, + SectorSize, + &MasterBootRecord->PartitionTable[i], + &Partitions->PartitionEntry[NbPartitions])) + { + Partitions->PartitionEntry[NbPartitions].PartitionNumber = NbPartitions + 1; + NbPartitions++; + } + + if (MasterBootRecord->PartitionTable[i].SystemIndicator == PARTITION_EXTENDED || + MasterBootRecord->PartitionTable[i].SystemIndicator == PARTITION_XINT13_EXTENDED) + { + /* FIXME: unhandled case; copy partitions */ + UNIMPLEMENTED; + } + } + + Partitions->PartitionCount = NbPartitions; + Partitions->Signature = MasterBootRecord->Signature; + ExFreePool(MasterBootRecord); + + *PartitionBuffer = Partitions; + return STATUS_SUCCESS; +} + #endif diff --git a/boot/freeldr/freeldr/disk/scsiport.c b/boot/freeldr/freeldr/disk/scsiport.c new file mode 100644 index 00000000000..d8d15b12d84 --- /dev/null +++ b/boot/freeldr/freeldr/disk/scsiport.c @@ -0,0 +1,1701 @@ +#include + +#define _SCSIPORT_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define NDEBUG +#include + +#define DPRINTM2(fmt, ...) DPRINTM(DPRINT_SCSIPORT, "(%s:%d) SCSIPORT: " fmt, __FILE__, __LINE__, __VA_ARGS__) + +#undef UNIMPLEMENTED +#define UNIMPLEMENTED DPRINTM2("%s UNIMPLEMENTED\n", __FUNCTION__) + +#define SCSI_PORT_NEXT_REQUEST_READY 0x0008 + +typedef struct +{ + PVOID NonCachedExtension; + + ULONG BusNum; + ULONG MaxTargedIds; + + ULONG InterruptFlags; + + /* SRB extension stuff */ + ULONG SrbExtensionSize; + PVOID SrbExtensionBuffer; + + IO_SCSI_CAPABILITIES PortCapabilities; + + PHW_INITIALIZE HwInitialize; + PHW_STARTIO HwStartIo; + PHW_INTERRUPT HwInterrupt; + PHW_RESET_BUS HwResetBus; + + /* DMA related stuff */ + PADAPTER_OBJECT AdapterObject; + + ULONG CommonBufferLength; + + PVOID MiniPortDeviceExtension; +} SCSI_PORT_DEVICE_EXTENSION, *PSCSI_PORT_DEVICE_EXTENSION; + +PSCSI_PORT_DEVICE_EXTENSION ScsiDeviceExtensions[SCSI_MAXIMUM_BUSES]; + +ULONG +ntohl( + IN ULONG Value) +{ + FOUR_BYTE Dest; + PFOUR_BYTE Source = (PFOUR_BYTE)&Value; + + Dest.Byte0 = Source->Byte3; + Dest.Byte1 = Source->Byte2; + Dest.Byte2 = Source->Byte1; + Dest.Byte3 = Source->Byte0; + + return Dest.AsULong; +} + +BOOLEAN +SpiSendSynchronousSrb( + IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PSCSI_REQUEST_BLOCK Srb) +{ + BOOLEAN ret; + + ASSERT(!(Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE)); + + /* HACK: handle lack of interrupts */ + while (!(DeviceExtension->InterruptFlags & SCSI_PORT_NEXT_REQUEST_READY)) + { + KeStallExecutionProcessor(100 * 1000); + DeviceExtension->HwInterrupt(DeviceExtension->MiniPortDeviceExtension); + } + + DeviceExtension->InterruptFlags &= ~SCSI_PORT_NEXT_REQUEST_READY; + Srb->SrbFlags |= SRB_FLAGS_IS_ACTIVE; + + if (!DeviceExtension->HwStartIo( + DeviceExtension->MiniPortDeviceExtension, + Srb)) + { + ExFreePool(Srb); + return FALSE; + } + + /* HACK: handle lack of interrupts */ + while (Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE) + { + KeStallExecutionProcessor(100 * 1000); + DeviceExtension->HwInterrupt(DeviceExtension->MiniPortDeviceExtension); + } + + ret = SRB_STATUS(Srb->SrbStatus) == SRB_STATUS_SUCCESS; + ExFreePool(Srb); + + return ret; +} + +typedef struct tagDISKCONTEXT +{ + /* Device ID */ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + ULONG PathId; + ULONG TargetId; + ULONG Lun; + + /* Device characteristics */ + ULONG SectorSize; + ULONGLONG SectorOffset; + ULONGLONG SectorCount; + ULONGLONG SectorNumber; +} DISKCONTEXT; + +static LONG DiskClose(ULONG FileId) +{ + DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); + + ExFreePool(Context); + return ESUCCESS; +} + +static LONG DiskGetFileInformation(ULONG FileId, FILEINFORMATION* Information) +{ + DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); + + RtlZeroMemory(Information, sizeof(FILEINFORMATION)); + Information->EndingAddress.QuadPart = Context->SectorCount * Context->SectorSize; + Information->CurrentAddress.LowPart = Context->SectorNumber * Context->SectorSize; + + return ESUCCESS; +} + +static LONG DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) +{ + PSCSI_REQUEST_BLOCK Srb; + PCDB Cdb; + READ_CAPACITY_DATA ReadCapacityBuffer; + + DISKCONTEXT* Context; + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + ULONG ScsiBus, PathId, TargetId, Lun, Partition, PathSyntax; + ULONG SectorSize; + ULONGLONG SectorOffset = 0; + ULONGLONG SectorCount; + + /* Parse ARC path */ + if (!DissectArcPath2(Path, &ScsiBus, &TargetId, &Lun, &Partition, &PathSyntax)) + return EINVAL; + if (PathSyntax != 0) /* scsi() format */ + return EINVAL; + DeviceExtension = ScsiDeviceExtensions[ScsiBus]; + PathId = ScsiBus - DeviceExtension->BusNum; + + /* Get disk capacity and sector size */ + Srb = ExAllocatePool(PagedPool, sizeof(SCSI_REQUEST_BLOCK)); + if (!Srb) + return ENOMEM; + RtlZeroMemory(Srb, sizeof(SCSI_REQUEST_BLOCK)); + Srb->Length = sizeof(SCSI_REQUEST_BLOCK); + Srb->Function = SRB_FUNCTION_EXECUTE_SCSI; + Srb->PathId = PathId; + Srb->TargetId = TargetId; + Srb->Lun = Lun; + Srb->CdbLength = 10; + Srb->SrbFlags = SRB_FLAGS_DATA_IN; + Srb->DataTransferLength = sizeof(READ_CAPACITY_DATA); + Srb->TimeOutValue = 5; /* in seconds */ + Srb->DataBuffer = &ReadCapacityBuffer; + Cdb = (PCDB)Srb->Cdb; + Cdb->CDB10.OperationCode = SCSIOP_READ_CAPACITY; + if (!SpiSendSynchronousSrb(DeviceExtension, Srb)) + { + return EIO; + } + + /* Transform result to host endianness */ + SectorCount = ntohl(ReadCapacityBuffer.LogicalBlockAddress); + SectorSize = ntohl(ReadCapacityBuffer.BytesPerBlock); + + if (Partition != 0) + { + /* Need to offset start of disk and length */ + UNIMPLEMENTED; + return EIO; + } + + Context = ExAllocatePool(PagedPool, sizeof(DISKCONTEXT)); + if (!Context) + return ENOMEM; + Context->DeviceExtension = DeviceExtension; + Context->PathId = PathId; + Context->TargetId = TargetId; + Context->Lun = Lun; + Context->SectorSize = SectorSize; + Context->SectorOffset = SectorOffset; + Context->SectorCount = SectorCount; + Context->SectorNumber = 0; + FsSetDeviceSpecific(*FileId, Context); + + return ESUCCESS; +} + +static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count) +{ + DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); + PSCSI_REQUEST_BLOCK Srb; + PCDB Cdb; + ULONG FullSectors, NbSectors; + ULONG Lba; + + *Count = 0; + + if (N == 0) + return ESUCCESS; + + FullSectors = N / Context->SectorSize; + NbSectors = (N + Context->SectorSize - 1) / Context->SectorSize; + if (Context->SectorNumber + NbSectors >= Context->SectorCount) + return EINVAL; + if (FullSectors > 0xffff) + return EINVAL; + + /* Read full sectors */ + Lba = Context->SectorNumber; + if (FullSectors > 0) + { + Srb = ExAllocatePool(PagedPool, sizeof(SCSI_REQUEST_BLOCK)); + if (!Srb) + return ENOMEM; + + RtlZeroMemory(Srb, sizeof(SCSI_REQUEST_BLOCK)); + Srb->Length = sizeof(SCSI_REQUEST_BLOCK); + Srb->Function = SRB_FUNCTION_EXECUTE_SCSI; + Srb->PathId = Context->PathId; + Srb->TargetId = Context->TargetId; + Srb->Lun = Context->Lun; + Srb->CdbLength = 10; + Srb->SrbFlags = SRB_FLAGS_DATA_IN; + Srb->DataTransferLength = FullSectors * Context->SectorSize; + Srb->TimeOutValue = 5; /* in seconds */ + Srb->DataBuffer = Buffer; + Cdb = (PCDB)Srb->Cdb; + Cdb->CDB10.OperationCode = SCSIOP_READ; + Cdb->CDB10.LogicalUnitNumber = Srb->Lun; + Cdb->CDB10.LogicalBlockByte0 = (Lba >> 24) & 0xff; + Cdb->CDB10.LogicalBlockByte1 = (Lba >> 16) & 0xff; + Cdb->CDB10.LogicalBlockByte2 = (Lba >> 8) & 0xff; + Cdb->CDB10.LogicalBlockByte3 = Lba & 0xff; + Cdb->CDB10.TransferBlocksMsb = (FullSectors >> 8) & 0xff; + Cdb->CDB10.TransferBlocksLsb = FullSectors & 0xff; + if (!SpiSendSynchronousSrb(Context->DeviceExtension, Srb)) + { + return EIO; + } + Buffer = (PUCHAR)Buffer + FullSectors * Context->SectorSize; + N -= FullSectors * Context->SectorSize; + *Count += FullSectors * Context->SectorSize; + Lba += FullSectors; + } + + /* Read incomplete last sector */ + if (N > 0) + { + PUCHAR Sector; + + Sector = ExAllocatePool(PagedPool, Context->SectorSize); + if (!Sector) + return ENOMEM; + + Srb = ExAllocatePool(PagedPool, sizeof(SCSI_REQUEST_BLOCK)); + if (!Srb) + { + ExFreePool(Sector); + return ENOMEM; + } + + RtlZeroMemory(Srb, sizeof(SCSI_REQUEST_BLOCK)); + Srb->Length = sizeof(SCSI_REQUEST_BLOCK); + Srb->Function = SRB_FUNCTION_EXECUTE_SCSI; + Srb->PathId = Context->PathId; + Srb->TargetId = Context->TargetId; + Srb->Lun = Context->Lun; + Srb->CdbLength = 10; + Srb->SrbFlags = SRB_FLAGS_DATA_IN; + Srb->DataTransferLength = Context->SectorSize; + Srb->TimeOutValue = 5; /* in seconds */ + Srb->DataBuffer = Sector; + Cdb = (PCDB)Srb->Cdb; + Cdb->CDB10.OperationCode = SCSIOP_READ; + Cdb->CDB10.LogicalUnitNumber = Srb->Lun; + Cdb->CDB10.LogicalBlockByte0 = (Lba >> 24) & 0xff; + Cdb->CDB10.LogicalBlockByte1 = (Lba >> 16) & 0xff; + Cdb->CDB10.LogicalBlockByte2 = (Lba >> 8) & 0xff; + Cdb->CDB10.LogicalBlockByte3 = Lba & 0xff; + Cdb->CDB10.TransferBlocksMsb = 0; + Cdb->CDB10.TransferBlocksLsb = 1; + if (!SpiSendSynchronousSrb(Context->DeviceExtension, Srb)) + { + ExFreePool(Sector); + return EIO; + } + RtlCopyMemory(Buffer, Sector, N); + *Count += N; + ExFreePool(Sector); + } + + return ESUCCESS; +} + +static LONG DiskSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode) +{ + DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); + + if (SeekMode != SeekAbsolute) + return EINVAL; + if (Position->QuadPart & (Context->SectorSize - 1)) + return EINVAL; + + Context->SectorNumber = Position->QuadPart / Context->SectorSize; + return ESUCCESS; +} + +static const DEVVTBL DiskVtbl = { + DiskClose, + DiskGetFileInformation, + DiskOpen, + DiskRead, + DiskSeek, +}; + +NTSTATUS +SpiCreatePortConfig( + IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PHW_INITIALIZATION_DATA HwInitData, + OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, + IN BOOLEAN ZeroStruct) +{ + ULONG Bus; + + /* Zero out the struct if told so */ + if (ZeroStruct) + { + /* First zero the portconfig */ + RtlZeroMemory(ConfigInfo, sizeof(PORT_CONFIGURATION_INFORMATION)); + + /* Initialize the struct */ + ConfigInfo->Length = sizeof(PORT_CONFIGURATION_INFORMATION); + ConfigInfo->AdapterInterfaceType = HwInitData->AdapterInterfaceType; + ConfigInfo->InterruptMode = Latched; + ConfigInfo->DmaChannel = SP_UNINITIALIZED_VALUE; + ConfigInfo->DmaPort = SP_UNINITIALIZED_VALUE; + ConfigInfo->MaximumTransferLength = SP_UNINITIALIZED_VALUE; + ConfigInfo->MaximumNumberOfTargets = SCSI_MAXIMUM_TARGETS_PER_BUS; + + /* Store parameters */ + ConfigInfo->NeedPhysicalAddresses = HwInitData->NeedPhysicalAddresses; + ConfigInfo->MapBuffers = HwInitData->MapBuffers; + ConfigInfo->AutoRequestSense = HwInitData->AutoRequestSense; + ConfigInfo->ReceiveEvent = HwInitData->ReceiveEvent; + ConfigInfo->TaggedQueuing = HwInitData->TaggedQueuing; + ConfigInfo->MultipleRequestPerLu = HwInitData->MultipleRequestPerLu; + + /* Get the disk usage */ + ConfigInfo->AtdiskPrimaryClaimed = FALSE; // FIXME + ConfigInfo->AtdiskSecondaryClaimed = FALSE; // FIXME + + /* Initiator bus id is not set */ + for (Bus = 0; Bus < 8; Bus++) + ConfigInfo->InitiatorBusId[Bus] = (CCHAR)SP_UNINITIALIZED_VALUE; + } + + ConfigInfo->NumberOfPhysicalBreaks = 17; + + return STATUS_SUCCESS; +} + +VOID +DDKCDECLAPI +ScsiDebugPrint( + IN ULONG DebugPrintLevel, + IN PCCHAR DebugMessage, + IN ...) +{ + va_list ap; + CHAR Buffer[512]; + ULONG Length; + + if (DebugPrintLevel > 10) + return; + + va_start(ap, DebugMessage); + + /* Construct a string */ + Length = _vsnprintf(Buffer, 512, DebugMessage, ap); + + /* Check if we went past the buffer */ + if (Length == MAXULONG) + { + /* Terminate it if we went over-board */ + Buffer[sizeof(Buffer) - 1] = '\0'; + + /* Put maximum */ + Length = sizeof(Buffer); + } + + /* Print the message */ + DPRINTM(DPRINT_SCSIPORT, "%s", Buffer); + + /* Cleanup */ + va_end(ap); +} + +VOID +DDKAPI +ScsiPortCompleteRequest( + IN PVOID HwDeviceExtension, + IN UCHAR PathId, + IN UCHAR TargetId, + IN UCHAR Lun, + IN UCHAR SrbStatus) +{ + // FIXME + UNIMPLEMENTED; +} + +#undef ScsiPortConvertPhysicalAddressToUlong +ULONG +DDKAPI +ScsiPortConvertPhysicalAddressToUlong( + IN SCSI_PHYSICAL_ADDRESS Address) +{ + return Address.LowPart; +} + +SCSI_PHYSICAL_ADDRESS +DDKAPI +ScsiPortConvertUlongToPhysicalAddress( + IN ULONG UlongAddress) +{ + return RtlConvertUlongToLargeInteger(UlongAddress); +} + +VOID +DDKAPI +ScsiPortFlushDma( + IN PVOID DeviceExtension) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortFreeDeviceBase( + IN PVOID HwDeviceExtension, + IN PVOID MappedAddress) +{ + // Nothing to do +} + +ULONG +DDKAPI +ScsiPortGetBusData( + IN PVOID DeviceExtension, + IN ULONG BusDataType, + IN ULONG SystemIoBusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length) +{ + return HalGetBusDataByOffset(BusDataType, SystemIoBusNumber, SlotNumber, Buffer, 0, Length); +} + +PVOID +DDKAPI +ScsiPortGetDeviceBase( + IN PVOID HwDeviceExtension, + IN INTERFACE_TYPE BusType, + IN ULONG SystemIoBusNumber, + IN SCSI_PHYSICAL_ADDRESS IoAddress, + IN ULONG NumberOfBytes, + IN BOOLEAN InIoSpace) +{ + PHYSICAL_ADDRESS TranslatedAddress; + ULONG AddressSpace; + + AddressSpace = (ULONG)InIoSpace; + if (HalTranslateBusAddress(BusType, + SystemIoBusNumber, + IoAddress, + &AddressSpace, + &TranslatedAddress) == FALSE) + { + return NULL; + } + + /* I/O space */ + if (AddressSpace != 0) + return (PVOID)TranslatedAddress.u.LowPart; + + // FIXME + UNIMPLEMENTED; + return (PVOID)IoAddress.LowPart; +} + +PVOID +DDKAPI +ScsiPortGetLogicalUnit( + IN PVOID HwDeviceExtension, + IN UCHAR PathId, + IN UCHAR TargetId, + IN UCHAR Lun) +{ + // FIXME + UNIMPLEMENTED; + return NULL; +} + +SCSI_PHYSICAL_ADDRESS +DDKAPI +ScsiPortGetPhysicalAddress( + IN PVOID HwDeviceExtension, + IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, + IN PVOID VirtualAddress, + OUT ULONG *Length) +{ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + SCSI_PHYSICAL_ADDRESS PhysicalAddress; + ULONG BufferLength = 0; + ULONG Offset; + + DPRINTM2("ScsiPortGetPhysicalAddress(%p %p %p %p)\n", + HwDeviceExtension, Srb, VirtualAddress, Length); + + DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1; + + if (Srb == NULL || Srb->SenseInfoBuffer == VirtualAddress) + { + /* Simply look it up in the allocated common buffer */ + Offset = (PUCHAR)VirtualAddress - (PUCHAR)DeviceExtension->SrbExtensionBuffer; + + BufferLength = DeviceExtension->CommonBufferLength - Offset; + PhysicalAddress.QuadPart = Offset; + } + else + { + /* Nothing */ + *Length = 0; + PhysicalAddress.QuadPart = (LONGLONG)(SP_UNINITIALIZED_VALUE); + } + + *Length = BufferLength; + return PhysicalAddress; +} + +PSCSI_REQUEST_BLOCK +DDKAPI +ScsiPortGetSrb( + IN PVOID DeviceExtension, + IN UCHAR PathId, + IN UCHAR TargetId, + IN UCHAR Lun, + IN LONG QueueTag) +{ + // FIXME + UNIMPLEMENTED; + return NULL; +} + +NTSTATUS +SpiAllocateCommonBuffer( + IN OUT PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN ULONG NonCachedSize) +{ + PVOID CommonBuffer; + ULONG CommonBufferLength, BufSize; + + /* If size is 0, set it to 16 */ + if (!DeviceExtension->SrbExtensionSize) + DeviceExtension->SrbExtensionSize = 16; + + /* Calculate size */ + BufSize = DeviceExtension->SrbExtensionSize; + + /* Round it */ + BufSize = (BufSize + sizeof(LONGLONG) - 1) & ~(sizeof(LONGLONG) - 1); + + /* Sum up into the total common buffer length, and round it to page size */ + CommonBufferLength = + ROUND_TO_PAGES(NonCachedSize); + + /* Allocate it */ + if (!DeviceExtension->AdapterObject) + { + /* From nonpaged pool if there is no DMA */ + CommonBuffer = ExAllocatePool(NonPagedPool, CommonBufferLength); + } + else + { + /* Perform a full request since we have a DMA adapter*/ + UNIMPLEMENTED; + CommonBuffer = NULL; + } + + /* Fail in case of error */ + if (!CommonBuffer) + return STATUS_INSUFFICIENT_RESOURCES; + + /* Zero it */ + RtlZeroMemory(CommonBuffer, CommonBufferLength); + + /* Store its size in Device Extension */ + DeviceExtension->CommonBufferLength = CommonBufferLength; + + /* SrbExtension buffer is located at the beginning of the buffer */ + DeviceExtension->SrbExtensionBuffer = CommonBuffer; + + /* Non-cached extension buffer is located at the end of + the common buffer */ + if (NonCachedSize) + { + CommonBufferLength -= NonCachedSize; + DeviceExtension->NonCachedExtension = (PUCHAR)CommonBuffer + CommonBufferLength; + } + else + { + DeviceExtension->NonCachedExtension = NULL; + } + + return STATUS_SUCCESS; +} + +PVOID +DDKAPI +ScsiPortGetUncachedExtension( + IN PVOID HwDeviceExtension, + IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, + IN ULONG NumberOfBytes) +{ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + DEVICE_DESCRIPTION DeviceDescription; + ULONG MapRegistersCount; + NTSTATUS Status; + + DPRINTM2("ScsiPortGetUncachedExtension(%p %p %lu)\n", + HwDeviceExtension, ConfigInfo, NumberOfBytes); + + DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1; + + /* Check for allocated common DMA buffer */ + if (DeviceExtension->SrbExtensionBuffer != NULL) + { + return NULL; + } + + /* Check for DMA adapter object */ + if (DeviceExtension->AdapterObject == NULL) + { + /* Initialize DMA adapter description */ + RtlZeroMemory(&DeviceDescription, sizeof(DEVICE_DESCRIPTION)); + + DeviceDescription.Version = DEVICE_DESCRIPTION_VERSION; + DeviceDescription.Master = ConfigInfo->Master; + DeviceDescription.ScatterGather = ConfigInfo->ScatterGather; + DeviceDescription.DemandMode = ConfigInfo->DemandMode; + DeviceDescription.Dma32BitAddresses = ConfigInfo->Dma32BitAddresses; + DeviceDescription.BusNumber = ConfigInfo->SystemIoBusNumber; + DeviceDescription.DmaChannel = ConfigInfo->DmaChannel; + DeviceDescription.InterfaceType = ConfigInfo->AdapterInterfaceType; + DeviceDescription.DmaWidth = ConfigInfo->DmaWidth; + DeviceDescription.DmaSpeed = ConfigInfo->DmaSpeed; + DeviceDescription.MaximumLength = ConfigInfo->MaximumTransferLength; + DeviceDescription.DmaPort = ConfigInfo->DmaPort; + + /* Get a DMA adapter object */ +#if 0 + DeviceExtension->AdapterObject = + HalGetAdapter(&DeviceDescription, &MapRegistersCount); + + /* Fail in case of error */ + if (DeviceExtension->AdapterObject == NULL) + { + return NULL; + } +#else + MapRegistersCount = 0; +#endif + + /* Set number of physical breaks */ + if (ConfigInfo->NumberOfPhysicalBreaks != 0 && + MapRegistersCount > ConfigInfo->NumberOfPhysicalBreaks) + { + DeviceExtension->PortCapabilities.MaximumPhysicalPages = + ConfigInfo->NumberOfPhysicalBreaks; + } + else + { + DeviceExtension->PortCapabilities.MaximumPhysicalPages = MapRegistersCount; + } + } + + /* Update Srb extension size */ + if (DeviceExtension->SrbExtensionSize != ConfigInfo->SrbExtensionSize) + DeviceExtension->SrbExtensionSize = ConfigInfo->SrbExtensionSize; + + /* Allocate a common DMA buffer */ + Status = SpiAllocateCommonBuffer(DeviceExtension, NumberOfBytes); + + if (!NT_SUCCESS(Status)) + { + DPRINTM2("SpiAllocateCommonBuffer() failed with Status = 0x%08X!\n", Status); + return NULL; + } + + return DeviceExtension->NonCachedExtension; +} + +PVOID +DDKAPI +ScsiPortGetVirtualAddress( + IN PVOID HwDeviceExtension, + IN SCSI_PHYSICAL_ADDRESS PhysicalAddress) +{ + // FIXME + UNIMPLEMENTED; + return NULL; +} + +VOID +SpiScanDevice( + IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PCHAR ArcName, + IN ULONG ScsiBus, + IN ULONG TargetId, + IN ULONG Lun) +{ + ULONG FileId, i; + ULONG Status; + NTSTATUS ret; + struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer; + CHAR PartitionName[64]; + + /* Register device with partition(0) suffix */ + sprintf(PartitionName, "%spartition(0)", ArcName); + FsRegisterDevice(PartitionName, &DiskVtbl); + + /* Read device partition table */ + Status = ArcOpen(PartitionName, OpenReadOnly, &FileId); + if (Status == ESUCCESS) + { + ret = HALDISPATCH->HalIoReadPartitionTable((PDEVICE_OBJECT)FileId, 512, FALSE, &PartitionBuffer); + if (NT_SUCCESS(ret)) + { + for (i = 0; i < PartitionBuffer->PartitionCount; i++) + { + if (PartitionBuffer->PartitionEntry[i].PartitionType != PARTITION_ENTRY_UNUSED) + { + sprintf(PartitionName, "%spartition(%lu)", + ArcName, PartitionBuffer->PartitionEntry[i].PartitionNumber); + FsRegisterDevice(PartitionName, &DiskVtbl); + } + } + ExFreePool(PartitionBuffer); + } + ArcClose(FileId); + } +} + +VOID +SpiScanAdapter( + IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN ULONG ScsiBus, + IN ULONG PathId) +{ + CHAR ArcName[64]; + PSCSI_REQUEST_BLOCK Srb; + PCDB Cdb; + INQUIRYDATA InquiryBuffer; + ULONG TargetId; + ULONG Lun; + + if (!DeviceExtension->HwResetBus(DeviceExtension->MiniPortDeviceExtension, PathId)) + { + return; + } + + /* Remember the extension */ + ScsiDeviceExtensions[ScsiBus] = DeviceExtension; + + for (TargetId = 0; TargetId < DeviceExtension->MaxTargedIds; TargetId++) + { + Lun = 0; + do + { + DPRINTM2("Scanning SCSI device %d.%d.%d\n", + ScsiBus, TargetId, Lun); + + Srb = ExAllocatePool(PagedPool, sizeof(SCSI_REQUEST_BLOCK)); + if (!Srb) + break; + RtlZeroMemory(Srb, sizeof(SCSI_REQUEST_BLOCK)); + Srb->Length = sizeof(SCSI_REQUEST_BLOCK); + Srb->Function = SRB_FUNCTION_EXECUTE_SCSI; + Srb->PathId = PathId; + Srb->TargetId = TargetId; + Srb->Lun = Lun; + Srb->CdbLength = 6; + Srb->SrbFlags = SRB_FLAGS_DATA_IN; + Srb->DataTransferLength = INQUIRYDATABUFFERSIZE; + Srb->TimeOutValue = 5; /* in seconds */ + Srb->DataBuffer = &InquiryBuffer; + Cdb = (PCDB)Srb->Cdb; + Cdb->CDB6INQUIRY.OperationCode = SCSIOP_INQUIRY; + Cdb->CDB6INQUIRY.LogicalUnitNumber = Srb->Lun; + Cdb->CDB6INQUIRY.AllocationLength = Srb->DataTransferLength; + if (!SpiSendSynchronousSrb(DeviceExtension, Srb)) + { + /* Don't check next LUNs */ + break; + } + + /* Device exists, create its ARC name */ + if (InquiryBuffer.RemovableMedia) + { + sprintf(ArcName, "scsi(%ld)cdrom(%ld)fdisk(%ld)", + ScsiBus, TargetId, Lun); + FsRegisterDevice(ArcName, &DiskVtbl); + } + else + { + sprintf(ArcName, "scsi(%ld)disk(%ld)rdisk(%ld)", + ScsiBus, TargetId, Lun); + /* Now, check if it has partitions */ + SpiScanDevice(DeviceExtension, ArcName, PathId, TargetId, Lun); + } + + /* Check next LUN */ + Lun++; + } while (Lun < SCSI_MAXIMUM_LOGICAL_UNITS); + } +} + +VOID +SpiResourceToConfig( + IN PHW_INITIALIZATION_DATA HwInitializationData, + IN PCM_FULL_RESOURCE_DESCRIPTOR ResourceDescriptor, + IN OUT PPORT_CONFIGURATION_INFORMATION PortConfig) +{ + PACCESS_RANGE AccessRange; + PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialData; + ULONG RangeNumber; + ULONG Index; + + RangeNumber = 0; + + /* Loop through all entries */ + for (Index = 0; Index < ResourceDescriptor->PartialResourceList.Count; Index++) + { + PartialData = &ResourceDescriptor->PartialResourceList.PartialDescriptors[Index]; + + switch (PartialData->Type) + { + case CmResourceTypePort: + /* Copy access ranges */ + if (RangeNumber < HwInitializationData->NumberOfAccessRanges) + { + DPRINTM2("Got port at 0x%I64x, len 0x%x\n", + PartialData->u.Port.Start.QuadPart, PartialData->u.Port.Length); + AccessRange = &((*(PortConfig->AccessRanges))[RangeNumber]); + + AccessRange->RangeStart = PartialData->u.Port.Start; + AccessRange->RangeLength = PartialData->u.Port.Length; + + AccessRange->RangeInMemory = FALSE; + RangeNumber++; + } + break; + + case CmResourceTypeMemory: + /* Copy access ranges */ + if (RangeNumber < HwInitializationData->NumberOfAccessRanges) + { + DPRINTM2("Got memory at 0x%I64x, len 0x%x\n", + PartialData->u.Memory.Start.QuadPart, PartialData->u.Memory.Length); + AccessRange = &((*(PortConfig->AccessRanges))[RangeNumber]); + + AccessRange->RangeStart = PartialData->u.Memory.Start; + AccessRange->RangeLength = PartialData->u.Memory.Length; + + AccessRange->RangeInMemory = TRUE; + RangeNumber++; + } + break; + + case CmResourceTypeInterrupt: + /* Copy interrupt data */ + DPRINTM2("Got interrupt level %d, vector %d\n", + PartialData->u.Interrupt.Level, PartialData->u.Interrupt.Vector); + PortConfig->BusInterruptLevel = PartialData->u.Interrupt.Level; + PortConfig->BusInterruptVector = PartialData->u.Interrupt.Vector; + + /* Set interrupt mode accordingly to the resource */ + if (PartialData->Flags == CM_RESOURCE_INTERRUPT_LATCHED) + { + PortConfig->InterruptMode = Latched; + } + else if (PartialData->Flags == CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE) + { + PortConfig->InterruptMode = LevelSensitive; + } + break; + + case CmResourceTypeDma: + DPRINTM2("Got DMA channel %d, port %d\n", + PartialData->u.Dma.Channel, PartialData->u.Dma.Port); + PortConfig->DmaChannel = PartialData->u.Dma.Channel; + PortConfig->DmaPort = PartialData->u.Dma.Port; + break; + } + } +} + +BOOLEAN +SpiGetPciConfigData( + IN struct _HW_INITIALIZATION_DATA *HwInitializationData, + IN OUT PPORT_CONFIGURATION_INFORMATION PortConfig, + IN ULONG BusNumber, + IN OUT PPCI_SLOT_NUMBER NextSlotNumber) +{ + PCI_COMMON_CONFIG PciConfig; + PCI_SLOT_NUMBER SlotNumber; + ULONG DataSize; + ULONG DeviceNumber; + ULONG FunctionNumber; + CHAR VendorIdString[8]; + CHAR DeviceIdString[8]; + PCM_RESOURCE_LIST ResourceList; + NTSTATUS Status; + + RtlZeroMemory(&ResourceList, sizeof(PCM_RESOURCE_LIST)); + SlotNumber.u.AsULONG = 0; + + /* Loop through all devices */ + for (DeviceNumber = NextSlotNumber->u.bits.DeviceNumber; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++) + { + SlotNumber.u.bits.DeviceNumber = DeviceNumber; + + /* Loop through all functions */ + for (FunctionNumber = NextSlotNumber->u.bits.FunctionNumber; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++) + { + SlotNumber.u.bits.FunctionNumber = FunctionNumber; + + /* Get PCI config bytes */ + DataSize = HalGetBusDataByOffset( + PCIConfiguration, + BusNumber, + SlotNumber.u.AsULONG, + &PciConfig, + 0, + sizeof(ULONG)); + + /* If result of HalGetBusData is 0, then the bus is wrong */ + if (DataSize == 0) + return FALSE; + + /* If result is PCI_INVALID_VENDORID, then this device has no more + "Functions" */ + if (PciConfig.VendorID == PCI_INVALID_VENDORID) + break; + + sprintf(VendorIdString, "%04hx", PciConfig.VendorID); + sprintf(DeviceIdString, "%04hx", PciConfig.DeviceID); + + if (_strnicmp(VendorIdString, HwInitializationData->VendorId, HwInitializationData->VendorIdLength) || + _strnicmp(DeviceIdString, HwInitializationData->DeviceId, HwInitializationData->DeviceIdLength)) + { + /* It is not our device */ + continue; + } + + DPRINTM2( "Found device 0x%04hx 0x%04hx at %1lu %2lu %1lu\n", + PciConfig.VendorID, PciConfig.DeviceID, + BusNumber, + SlotNumber.u.bits.DeviceNumber, SlotNumber.u.bits.FunctionNumber); + + Status = HalAssignSlotResources(NULL, + NULL, + NULL, + NULL, + PCIBus, + BusNumber, + SlotNumber.u.AsULONG, + &ResourceList); + + if (!NT_SUCCESS(Status)) + break; + + /* Create configuration information */ + SpiResourceToConfig(HwInitializationData, + ResourceList->List, + PortConfig); + + /* Free the resource list */ + ExFreePool(ResourceList); + + /* Set dev & fn numbers */ + NextSlotNumber->u.bits.DeviceNumber = DeviceNumber; + NextSlotNumber->u.bits.FunctionNumber = FunctionNumber + 1; + + /* Save the slot number */ + PortConfig->SlotNumber = SlotNumber.u.AsULONG; + + return TRUE; + } + NextSlotNumber->u.bits.FunctionNumber = 0; + } + + NextSlotNumber->u.bits.DeviceNumber = 0; + + return FALSE; +} + +ULONG +DDKAPI +ScsiPortInitialize( + IN PVOID Argument1, + IN PVOID Argument2, + IN struct _HW_INITIALIZATION_DATA *HwInitializationData, + IN PVOID HwContext OPTIONAL) +{ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + ULONG DeviceExtensionSize; + PORT_CONFIGURATION_INFORMATION PortConfig; + BOOLEAN Again; + BOOLEAN FirstConfigCall = TRUE; + PCI_SLOT_NUMBER SlotNumber; + NTSTATUS Status; + + if (HwInitializationData->HwInitializationDataSize != sizeof(HW_INITIALIZATION_DATA)) + { + return STATUS_INVALID_PARAMETER; + } + + /* Check params for validity */ + if ((HwInitializationData->HwInitialize == NULL) || + (HwInitializationData->HwStartIo == NULL) || + (HwInitializationData->HwInterrupt == NULL) || + (HwInitializationData->HwFindAdapter == NULL) || + (HwInitializationData->HwResetBus == NULL)) + { + return STATUS_INVALID_PARAMETER; + } + + /* Zero starting slot number */ + SlotNumber.u.AsULONG = 0; + + while (TRUE) + { + Again = FALSE; + + DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) + HwInitializationData->DeviceExtensionSize; + DeviceExtension = MmHeapAlloc(DeviceExtensionSize); + if (!DeviceExtension) + { + return STATUS_NO_MEMORY; + } + RtlZeroMemory(DeviceExtension, DeviceExtensionSize); + DeviceExtension->InterruptFlags = SCSI_PORT_NEXT_REQUEST_READY; + DeviceExtension->HwInitialize = HwInitializationData->HwInitialize; + DeviceExtension->HwStartIo = HwInitializationData->HwStartIo; + DeviceExtension->HwInterrupt = HwInitializationData->HwInterrupt; + DeviceExtension->HwResetBus = HwInitializationData->HwResetBus; + DeviceExtension->MiniPortDeviceExtension = (PVOID)(DeviceExtension + 1); + + Status = SpiCreatePortConfig(DeviceExtension, + HwInitializationData, + &PortConfig, + FirstConfigCall); + if (Status != STATUS_SUCCESS) + { + MmHeapFree(DeviceExtension); + return Status; + } + + PortConfig.NumberOfAccessRanges = HwInitializationData->NumberOfAccessRanges; + PortConfig.AccessRanges = MmHeapAlloc(sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges); + if (!PortConfig.AccessRanges) + { + MmHeapFree(DeviceExtension); + return STATUS_NO_MEMORY; + } + RtlZeroMemory(PortConfig.AccessRanges, sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges); + + /* Search for matching PCI device */ + if ((HwInitializationData->AdapterInterfaceType == PCIBus) && + (HwInitializationData->VendorIdLength > 0) && + (HwInitializationData->VendorId != NULL) && + (HwInitializationData->DeviceIdLength > 0) && + (HwInitializationData->DeviceId != NULL)) + { + PortConfig.BusInterruptLevel = 0; + + /* Get PCI device data */ + DPRINTM2("VendorId '%.*s' DeviceId '%.*s'\n", + HwInitializationData->VendorIdLength, + HwInitializationData->VendorId, + HwInitializationData->DeviceIdLength, + HwInitializationData->DeviceId); + + if (!SpiGetPciConfigData(HwInitializationData, + &PortConfig, + 0, /* FIXME */ + &SlotNumber)) + { + /* Continue to the next bus, nothing here */ + MmHeapFree(DeviceExtension); + return STATUS_INTERNAL_ERROR; + } + + if (!PortConfig.BusInterruptLevel) + { + /* Bypass this slot, because no interrupt was assigned */ + MmHeapFree(DeviceExtension); + return STATUS_INTERNAL_ERROR; + } + } + + if (HwInitializationData->HwFindAdapter( + DeviceExtension->MiniPortDeviceExtension, + HwContext, + NULL, + NULL, + &PortConfig, + &Again) != SP_RETURN_FOUND) + { + MmHeapFree(DeviceExtension); + return STATUS_INTERNAL_ERROR; + } + + /* Copy all stuff which we ever need from PortConfig to the DeviceExtension */ + if (PortConfig.MaximumNumberOfTargets > SCSI_MAXIMUM_TARGETS_PER_BUS) + DeviceExtension->MaxTargedIds = SCSI_MAXIMUM_TARGETS_PER_BUS; + else + DeviceExtension->MaxTargedIds = PortConfig.MaximumNumberOfTargets; + + DeviceExtension->BusNum = PortConfig.SystemIoBusNumber; + + DPRINTM2("Adapter found: buses = %d, targets = %d\n", + PortConfig.NumberOfBuses, DeviceExtension->MaxTargedIds); + + /* Initialize adapter */ + if (!DeviceExtension->HwInitialize(DeviceExtension->MiniPortDeviceExtension)) + { + MmHeapFree(DeviceExtension); + return STATUS_INTERNAL_ERROR; + } + + /* Scan bus */ + { + ULONG ScsiBus; + for (ScsiBus = 0; ScsiBus < PortConfig.NumberOfBuses; ScsiBus++) + { + SpiScanAdapter(DeviceExtension, PortConfig.SystemIoBusNumber, ScsiBus); + PortConfig.SystemIoBusNumber++; + } + } + + FirstConfigCall = FALSE; + if (!Again) + { + break; + } + } + + return STATUS_SUCCESS; +} + +VOID +DDKAPI +ScsiPortIoMapTransfer( + IN PVOID HwDeviceExtension, + IN PSCSI_REQUEST_BLOCK Srb, + IN PVOID LogicalAddress, + IN ULONG Length) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortLogError( + IN PVOID HwDeviceExtension, + IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, + IN UCHAR PathId, + IN UCHAR TargetId, + IN UCHAR Lun, + IN ULONG ErrorCode, + IN ULONG UniqueId) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortMoveMemory( + IN PVOID WriteBuffer, + IN PVOID ReadBuffer, + IN ULONG Length) +{ + RtlMoveMemory(WriteBuffer, ReadBuffer, Length); +} + +VOID +DDKCDECLAPI +ScsiPortNotification( + IN SCSI_NOTIFICATION_TYPE NotificationType, + IN PVOID HwDeviceExtension, + IN ...) +{ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + PSCSI_REQUEST_BLOCK Srb; + va_list ap; + + DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1; + + va_start(ap, HwDeviceExtension); + + switch (NotificationType) + { + case RequestComplete: + /* Mask the SRB as completed */ + Srb = va_arg(ap, PSCSI_REQUEST_BLOCK); + Srb->SrbFlags &= ~SRB_FLAGS_IS_ACTIVE; + break; + + case NextRequest: + /* Say that device is ready */ + DeviceExtension->InterruptFlags |= SCSI_PORT_NEXT_REQUEST_READY; + break; + + default: + // FIXME + UNIMPLEMENTED; + } + + va_end(ap); +} + +VOID +DDKAPI +ScsiPortReadPortBufferUchar( + IN PUCHAR Port, + OUT PUCHAR Buffer, + IN ULONG Count) +{ + __inbytestring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortReadPortBufferUlong( + IN PULONG Port, + OUT PULONG Buffer, + IN ULONG Count) +{ + __indwordstring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortReadPortBufferUshort( + IN PUSHORT Port, + OUT PUSHORT Buffer, + IN ULONG Count) +{ + __inwordstring(H2I(Port), Buffer, Count); +} + +UCHAR +DDKAPI +ScsiPortReadPortUchar( + IN PUCHAR Port) +{ + DPRINTM2("ScsiPortReadPortUchar(%p)\n", + Port); + + return READ_PORT_UCHAR(Port); +} + +ULONG +DDKAPI +ScsiPortReadPortUlong( + IN PULONG Port) +{ + return READ_PORT_ULONG(Port); +} + +USHORT +DDKAPI +ScsiPortReadPortUshort( + IN PUSHORT Port) +{ + return READ_PORT_USHORT(Port); +} + +VOID +DDKAPI +ScsiPortReadRegisterBufferUchar( + IN PUCHAR Register, + IN PUCHAR Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortReadRegisterBufferUlong( + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortReadRegisterBufferUshort( + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +UCHAR +DDKAPI +ScsiPortReadRegisterUchar( + IN PUCHAR Register) +{ + return READ_REGISTER_UCHAR(Register); +} + +ULONG +DDKAPI +ScsiPortReadRegisterUlong( + IN PULONG Register) +{ + return READ_REGISTER_ULONG(Register); +} + +USHORT +DDKAPI +ScsiPortReadRegisterUshort( + IN PUSHORT Register) +{ + return READ_REGISTER_USHORT(Register); +} + +ULONG +DDKAPI +ScsiPortSetBusDataByOffset( + IN PVOID DeviceExtension, + IN ULONG BusDataType, + IN ULONG SystemIoBusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length) +{ + // FIXME + UNIMPLEMENTED; + return 0; +} + +VOID +DDKAPI +ScsiPortStallExecution( + IN ULONG Delay) +{ + KeStallExecutionProcessor(Delay); +} + +BOOLEAN +DDKAPI +ScsiPortValidateRange( + IN PVOID HwDeviceExtension, + IN INTERFACE_TYPE BusType, + IN ULONG SystemIoBusNumber, + IN SCSI_PHYSICAL_ADDRESS IoAddress, + IN ULONG NumberOfBytes, + IN BOOLEAN InIoSpace) +{ + // FIXME + UNIMPLEMENTED; + return TRUE; +} + +#if 0 +// ScsiPortWmi* +#endif + + +VOID +DDKAPI +ScsiPortWritePortBufferUchar( + IN PUCHAR Port, + IN PUCHAR Buffer, + IN ULONG Count) +{ + __outbytestring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortWritePortBufferUlong( + IN PULONG Port, + IN PULONG Buffer, + IN ULONG Count) +{ + __outdwordstring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortWritePortBufferUshort( + IN PUSHORT Port, + IN PUSHORT Buffer, + IN ULONG Count) +{ + __outwordstring(H2I(Port), Buffer, Count); +} + +VOID +DDKAPI +ScsiPortWritePortUchar( + IN PUCHAR Port, + IN UCHAR Value) +{ + WRITE_PORT_UCHAR(Port, Value); +} + +VOID +DDKAPI +ScsiPortWritePortUlong( + IN PULONG Port, + IN ULONG Value) +{ + WRITE_PORT_ULONG(Port, Value); +} + +VOID +DDKAPI +ScsiPortWritePortUshort( + IN PUSHORT Port, + IN USHORT Value) +{ + WRITE_PORT_USHORT(Port, Value); +} + +VOID +DDKAPI +ScsiPortWriteRegisterBufferUchar( + IN PUCHAR Register, + IN PUCHAR Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortWriteRegisterBufferUlong( + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortWriteRegisterBufferUshort( + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count) +{ + // FIXME + UNIMPLEMENTED; +} + +VOID +DDKAPI +ScsiPortWriteRegisterUchar( + IN PUCHAR Register, + IN ULONG Value) +{ + WRITE_REGISTER_UCHAR(Register, Value); +} + +VOID +DDKAPI +ScsiPortWriteRegisterUlong( + IN PULONG Register, + IN ULONG Value) +{ + WRITE_REGISTER_ULONG(Register, Value); +} + +VOID +DDKAPI +ScsiPortWriteRegisterUshort( + IN PUSHORT Register, + IN USHORT Value) +{ + WRITE_REGISTER_USHORT(Register, Value); +} + +ULONG +LoadBootDeviceDriver(VOID) +{ + struct + { + CHAR* Name; + PVOID Function; + } ExportTable[] = + { + { "ScsiDebugPrint", ScsiDebugPrint }, + { "ScsiPortCompleteRequest", ScsiPortCompleteRequest }, + { "ScsiPortConvertPhysicalAddressToUlong", ScsiPortConvertPhysicalAddressToUlong }, + { "ScsiPortConvertUlongToPhysicalAddress", ScsiPortConvertUlongToPhysicalAddress }, + { "ScsiPortFlushDma", ScsiPortFlushDma }, + { "ScsiPortFreeDeviceBase", ScsiPortFreeDeviceBase }, + { "ScsiPortGetBusData", ScsiPortGetBusData }, + { "ScsiPortGetDeviceBase", ScsiPortGetDeviceBase }, + { "ScsiPortGetLogicalUnit", ScsiPortGetLogicalUnit }, + { "ScsiPortGetPhysicalAddress", ScsiPortGetPhysicalAddress }, + { "ScsiPortGetSrb", ScsiPortGetSrb }, + { "ScsiPortGetUncachedExtension", ScsiPortGetUncachedExtension }, + { "ScsiPortGetVirtualAddress", ScsiPortGetVirtualAddress }, + { "ScsiPortInitialize", ScsiPortInitialize }, + { "ScsiPortIoMapTransfer", ScsiPortIoMapTransfer }, + { "ScsiPortLogError", ScsiPortLogError }, + { "ScsiPortMoveMemory", ScsiPortMoveMemory }, + { "ScsiPortNotification", ScsiPortNotification }, + { "ScsiPortReadPortBufferUchar", ScsiPortReadPortBufferUchar }, + { "ScsiPortReadPortBufferUlong", ScsiPortReadPortBufferUlong }, + { "ScsiPortReadPortBufferUshort", ScsiPortReadPortBufferUshort }, + { "ScsiPortReadPortUchar", ScsiPortReadPortUchar }, + { "ScsiPortReadPortUlong", ScsiPortReadPortUlong }, + { "ScsiPortReadPortUshort", ScsiPortReadPortUshort }, + { "ScsiPortReadRegisterBufferUchar", ScsiPortReadRegisterBufferUchar }, + { "ScsiPortReadRegisterBufferUlong", ScsiPortReadRegisterBufferUlong }, + { "ScsiPortReadRegisterBufferUshort", ScsiPortReadRegisterBufferUshort }, + { "ScsiPortReadRegisterUchar", ScsiPortReadRegisterUchar }, + { "ScsiPortReadRegisterUlong", ScsiPortReadRegisterUlong }, + { "ScsiPortReadRegisterUshort", ScsiPortReadRegisterUshort }, + { "ScsiPortSetBusDataByOffset", ScsiPortSetBusDataByOffset }, + { "ScsiPortStallExecution", ScsiPortStallExecution }, + { "ScsiPortValidateRange", ScsiPortValidateRange }, + { "ScsiPortWritePortBufferUchar", ScsiPortWritePortBufferUchar }, + { "ScsiPortWritePortBufferUlong", ScsiPortWritePortBufferUlong }, + { "ScsiPortWritePortBufferUshort", ScsiPortWritePortBufferUshort }, + { "ScsiPortWritePortUchar", ScsiPortWritePortUchar }, + { "ScsiPortWritePortUlong", ScsiPortWritePortUlong }, + { "ScsiPortWritePortUshort", ScsiPortWritePortUshort }, + { "ScsiPortWriteRegisterBufferUchar", ScsiPortWriteRegisterBufferUchar }, + { "ScsiPortWriteRegisterBufferUlong", ScsiPortWriteRegisterBufferUlong }, + { "ScsiPortWriteRegisterBufferUshort", ScsiPortWriteRegisterBufferUshort }, + { "ScsiPortWriteRegisterUchar", ScsiPortWriteRegisterUchar }, + { "ScsiPortWriteRegisterUlong", ScsiPortWriteRegisterUlong }, + { "ScsiPortWriteRegisterUshort", ScsiPortWriteRegisterUshort }, + }; + IMAGE_DOS_HEADER ImageDosHeader; + IMAGE_NT_HEADERS ImageNtHeaders; + IMAGE_EXPORT_DIRECTORY ImageExportDirectory; + CHAR* TableName[sizeof(ExportTable) / sizeof(ExportTable[0])]; + USHORT OrdinalTable[sizeof(ExportTable) / sizeof(ExportTable[0])]; + ULONG FunctionTable[sizeof(ExportTable) / sizeof(ExportTable[0])]; + + PIMAGE_NT_HEADERS NtHeaders; + LOADER_PARAMETER_BLOCK LoaderBlock; + PIMAGE_IMPORT_DESCRIPTOR ImportTable; + ULONG ImportTableSize; + PLDR_DATA_TABLE_ENTRY BootDdDTE, FreeldrDTE; + CHAR NtBootDdPath[MAX_PATH]; + PVOID ImageBase; + ULONG (NTAPI *EntryPoint)(IN PVOID DriverObject, IN PVOID RegistryPath); + ULONG i; + BOOLEAN Status; + + /* Some initialization of our temporary loader block */ + RtlZeroMemory(&LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK)); + InitializeListHead(&LoaderBlock.LoadOrderListHead); + + /* Create our fake executable header for freeldr.sys */ + RtlZeroMemory(&ImageDosHeader, sizeof(IMAGE_DOS_HEADER)); + RtlZeroMemory(&ImageNtHeaders, sizeof(IMAGE_NT_HEADERS)); + RtlZeroMemory(&ImageExportDirectory, sizeof(IMAGE_EXPORT_DIRECTORY)); + ImageDosHeader.e_magic = SWAPW(IMAGE_DOS_SIGNATURE); + ImageDosHeader.e_lfanew = SWAPD((ULONG_PTR)&ImageNtHeaders - (ULONG_PTR)&ImageDosHeader); + ImageNtHeaders.Signature = IMAGE_NT_SIGNATURE; + ImageNtHeaders.OptionalHeader.NumberOfRvaAndSizes = SWAPD(IMAGE_DIRECTORY_ENTRY_EXPORT + 1); + ImageNtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = + SWAPW((ULONG_PTR)&ImageExportDirectory - (ULONG_PTR)&ImageDosHeader); + ImageNtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size = 1; + ImageExportDirectory.NumberOfNames = sizeof(ExportTable) / sizeof(ExportTable[0]); + ImageExportDirectory.AddressOfNames = (ULONG_PTR)TableName - (ULONG_PTR)&ImageDosHeader; + ImageExportDirectory.AddressOfNameOrdinals = (ULONG_PTR)OrdinalTable - (ULONG_PTR)&ImageDosHeader; + ImageExportDirectory.NumberOfFunctions = sizeof(ExportTable) / sizeof(ExportTable[0]); + ImageExportDirectory.AddressOfFunctions = (ULONG_PTR)FunctionTable - (ULONG_PTR)&ImageDosHeader; + + /* Fill freeldr.sys export table */ + for (i = 0; i < sizeof(ExportTable) / sizeof(ExportTable[0]); i++) + { + TableName[i] = PaToVa((PVOID)((ULONG_PTR)ExportTable[i].Name - (ULONG_PTR)&ImageDosHeader)); + OrdinalTable[i] = i; + FunctionTable[i] = (ULONG)((ULONG_PTR)ExportTable[i].Function - (ULONG_PTR)&ImageDosHeader); + } + + /* Add freeldr.sys to list of loaded executables */ + RtlZeroMemory(FreeldrDTE, sizeof(LDR_DATA_TABLE_ENTRY)); + Status = WinLdrAllocateDataTableEntry(&LoaderBlock, "scsiport.sys", + "FREELDR.SYS", &ImageDosHeader, &FreeldrDTE); + if (!Status) + return EIO; + + /* Create full ntbootdd.sys path */ + MachDiskGetBootPath(NtBootDdPath, sizeof(NtBootDdPath)); + strcat(NtBootDdPath, "\\NTBOOTDD.SYS"); + + /* Load file */ + Status = WinLdrLoadImage(NtBootDdPath, LoaderBootDriver, &ImageBase); + if (!Status) + { + /* That's OK. File simply doesn't exist */ + return ESUCCESS; + } + + /* Fix imports */ + Status = WinLdrAllocateDataTableEntry(&LoaderBlock, "ntbootdd.sys", + "NTBOOTDD.SYS", ImageBase, &BootDdDTE); + if (!Status) + return EIO; + Status = WinLdrScanImportDescriptorTable(&LoaderBlock, "", BootDdDTE); + if (!Status) + return EIO; + + /* Change imports to PA */ + ImportTable = (PIMAGE_IMPORT_DESCRIPTOR)RtlImageDirectoryEntryToData(VaToPa(BootDdDTE->DllBase), + TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ImportTableSize); + for (;(ImportTable->Name != 0) && (ImportTable->FirstThunk != 0);ImportTable++) + { + PIMAGE_THUNK_DATA ThunkData = (PIMAGE_THUNK_DATA)VaToPa(RVA(BootDdDTE->DllBase, ImportTable->FirstThunk)); + + while (((PIMAGE_THUNK_DATA)ThunkData)->u1.AddressOfData != 0) + { + ThunkData->u1.Function = (ULONG)VaToPa((PVOID)ThunkData->u1.Function); + ThunkData++; + } + } + + /* Relocate image to PA */ + NtHeaders = RtlImageNtHeader(VaToPa(BootDdDTE->DllBase)); + if (!NtHeaders) + return EIO; + Status = LdrRelocateImageWithBias( + VaToPa(BootDdDTE->DllBase), + NtHeaders->OptionalHeader.ImageBase - (ULONG_PTR)BootDdDTE->DllBase, + "FreeLdr", + TRUE, + TRUE, /* in case of conflict still return success */ + FALSE); + if (!Status) + return EIO; + + /* Call the entrypoint */ + EntryPoint = VaToPa(BootDdDTE->EntryPoint); + (*EntryPoint)(NULL, NULL); + + return ESUCCESS; +} + +/* EOF */ diff --git a/boot/freeldr/freeldr/freeldr.c b/boot/freeldr/freeldr/freeldr.c index 3fa9b476b06..5761ed9460c 100644 --- a/boot/freeldr/freeldr/freeldr.c +++ b/boot/freeldr/freeldr/freeldr.c @@ -20,6 +20,9 @@ #include #include +VOID NTAPI HalpInitializePciStubs(VOID); +VOID NTAPI HalpInitBusHandler(VOID); + VOID BootMain(LPSTR CmdLine) { CmdLineParse(CmdLine); @@ -44,5 +47,7 @@ VOID BootMain(LPSTR CmdLine) return; } + HalpInitializePciStubs(); + HalpInitBusHandler(); RunLoader(); } diff --git a/boot/freeldr/freeldr/freeldr.rbuild b/boot/freeldr/freeldr/freeldr.rbuild index dc83aaa9878..b513dabca44 100644 --- a/boot/freeldr/freeldr/freeldr.rbuild +++ b/boot/freeldr/freeldr/freeldr.rbuild @@ -7,6 +7,7 @@ freeldr_startup freeldr_base64k freeldr_base + mini_hal freeldr_arch freeldr_main rossym diff --git a/boot/freeldr/freeldr/freeldr_arch.rbuild b/boot/freeldr/freeldr/freeldr_arch.rbuild index b4abb4a703c..2132587edcf 100644 --- a/boot/freeldr/freeldr/freeldr_arch.rbuild +++ b/boot/freeldr/freeldr/freeldr_arch.rbuild @@ -7,6 +7,7 @@ include/reactos/libs include/reactos/elf + @@ -14,6 +15,7 @@ archmach.c custom.c drivemap.c + halstub.c hardware.c hwacpi.c hwapm.c @@ -24,6 +26,7 @@ loader.c machpc.c miscboot.c + ntoskrnl.c pccons.c pcdisk.c pcmem.c diff --git a/boot/freeldr/freeldr/freeldr_base.rbuild b/boot/freeldr/freeldr/freeldr_base.rbuild index 9f42e74ee92..fd3487f3242 100644 --- a/boot/freeldr/freeldr/freeldr_base.rbuild +++ b/boot/freeldr/freeldr/freeldr_base.rbuild @@ -22,6 +22,7 @@ disk.c partition.c ramdisk.c + scsiport.c ext2.c diff --git a/boot/freeldr/freeldr/fs/fs.c b/boot/freeldr/freeldr/fs/fs.c index a2c5c495e2c..eb23215f789 100644 --- a/boot/freeldr/freeldr/fs/fs.c +++ b/boot/freeldr/freeldr/fs/fs.c @@ -319,6 +319,13 @@ LONG ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) FileData[DeviceId].FuncTable = NULL; return ret; } + else if (!*FileName) + { + /* Done, caller wanted to open the raw device */ + *FileId = DeviceId; + pDevice->ReferenceCount++; + return ESUCCESS; + } /* Try to detect the file system */ #ifndef _M_ARM diff --git a/boot/freeldr/freeldr/include/debug.h b/boot/freeldr/freeldr/include/debug.h index c7d57f6fb49..1e855360491 100644 --- a/boot/freeldr/freeldr/include/debug.h +++ b/boot/freeldr/freeldr/include/debug.h @@ -35,6 +35,7 @@ #define DPRINT_HWDETECT 0x00000400 // OR this with DebugPrintMask to enable hardware detection messages #define DPRINT_WINDOWS 0x00000800 // OR this with DebugPrintMask to enable messages from Windows loader #define DPRINT_PELOADER 0x00001000 // OR this with DebugPrintMask to enable messages from PE images loader +#define DPRINT_SCSIPORT 0x00002000 // OR this with DebugPrintMask to enable messages from SCSI miniport extern char* g_file; extern int g_line; diff --git a/boot/freeldr/freeldr/include/disk.h b/boot/freeldr/freeldr/include/disk.h index d29c31ac8c1..daaaa495e55 100644 --- a/boot/freeldr/freeldr/include/disk.h +++ b/boot/freeldr/freeldr/include/disk.h @@ -140,3 +140,5 @@ BOOLEAN DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITI BOOLEAN DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry); BOOLEAN DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry); BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord); + +ULONG LoadBootDeviceDriver(VOID); diff --git a/boot/freeldr/freeldr/include/freeldr.h b/boot/freeldr/freeldr/include/freeldr.h index b053700c922..c80fed6b6f8 100644 --- a/boot/freeldr/freeldr/include/freeldr.h +++ b/boot/freeldr/freeldr/include/freeldr.h @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,8 @@ #include #include #include +#include +#include /* file system headers */ #include #include diff --git a/boot/freeldr/freeldr/include/mm.h b/boot/freeldr/freeldr/include/mm.h index 36a47e0079f..a7840e37791 100644 --- a/boot/freeldr/freeldr/include/mm.h +++ b/boot/freeldr/freeldr/include/mm.h @@ -116,3 +116,7 @@ PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress PVOID MmHeapAlloc(ULONG MemorySize); VOID MmHeapFree(PVOID MemoryPointer); + +#define ExAllocatePool(pool, size) MmHeapAlloc(size) +#define ExAllocatePoolWithTag(pool, size, tag) MmHeapAlloc(size) +#define ExFreePool(p) MmHeapFree(p) diff --git a/boot/freeldr/freeldr/include/ntoskrnl.h b/boot/freeldr/freeldr/include/ntoskrnl.h new file mode 100644 index 00000000000..fee926ddce5 --- /dev/null +++ b/boot/freeldr/freeldr/include/ntoskrnl.h @@ -0,0 +1,19 @@ +#include +#undef _NTHAL_ +#undef DECLSPEC_IMPORT +#define DECLSPEC_IMPORT +#undef NTSYSAPI +#define NTSYSAPI + +#include + +typedef GUID UUID; + +/* Windows Device Driver Kit */ +#include +#include + +/* Disk stuff */ +typedef PVOID PLOADER_PARAMETER_BLOCK; +#include +#include diff --git a/boot/freeldr/freeldr/include/reactos.h b/boot/freeldr/freeldr/include/reactos.h index 0bc48f2cc15..82e23abb946 100644 --- a/boot/freeldr/freeldr/include/reactos.h +++ b/boot/freeldr/freeldr/include/reactos.h @@ -73,6 +73,14 @@ VOID ReactOSRunSetupLoader(VOID); // ARC Path Functions // /////////////////////////////////////////////////////////////////////////////////////// +BOOLEAN +DissectArcPath2( + IN CHAR* ArcPath, + OUT ULONG* x, + OUT ULONG* y, + OUT ULONG* z, + OUT ULONG* Partition, + OUT ULONG *PathSyntax); BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* BootPartition); VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, ULONG Disk, ULONG Partition); ULONG ConvertArcNameToBiosDriveNumber(PCHAR ArcPath); diff --git a/boot/freeldr/freeldr/mm/mm.c b/boot/freeldr/freeldr/mm/mm.c index c06bb00f632..f4a4c69b095 100644 --- a/boot/freeldr/freeldr/mm/mm.c +++ b/boot/freeldr/freeldr/mm/mm.c @@ -345,3 +345,54 @@ PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(ULONG *NoEntries) return RealPageLookupTable; } + +#undef ExAllocatePoolWithTag +NTKERNELAPI +PVOID +NTAPI +ExAllocatePoolWithTag( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag) +{ + return MmHeapAlloc(NumberOfBytes); +} + +#undef ExFreePool +NTKERNELAPI +VOID +NTAPI +ExFreePool( + IN PVOID P) +{ + MmHeapFree(P); +} + +PVOID +NTAPI +RtlAllocateHeap( + IN PVOID HeapHandle, + IN ULONG Flags, + IN SIZE_T Size) +{ + PVOID ptr; + + ptr = MmHeapAlloc(Size); + if (ptr && (Flags & HEAP_ZERO_MEMORY)) + { + RtlZeroMemory(ptr, Size); + } + + return ptr; +} + +BOOLEAN +NTAPI +RtlFreeHeap( + IN PVOID HeapHandle, + IN ULONG Flags, + IN PVOID HeapBase) +{ + MmHeapFree(HeapBase); + return TRUE; +} diff --git a/boot/freeldr/freeldr/reactos/arcname.c b/boot/freeldr/freeldr/reactos/arcname.c index e46022c6c6b..3ca69fadb51 100644 --- a/boot/freeldr/freeldr/reactos/arcname.c +++ b/boot/freeldr/freeldr/reactos/arcname.c @@ -104,6 +104,62 @@ BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* B return TRUE; } +/* PathSyntax: scsi() = 0, multi() = 1, ramdisk() = 2 */ +BOOLEAN +DissectArcPath2( + IN CHAR* ArcPath, + OUT ULONG* x, + OUT ULONG* y, + OUT ULONG* z, + OUT ULONG* Partition, + OUT ULONG *PathSyntax) +{ + /* Detect ramdisk() */ + if (_strnicmp(ArcPath, "ramdisk(0)", 10) == 0) + { + *x = *y = *z = 0; + *Partition = 1; + *PathSyntax = 2; + return TRUE; + } + /* Detect scsi()disk()rdisk()partition() */ + else if (sscanf(ArcPath, "scsi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x, y, z, Partition) == 4) + { + *PathSyntax = 0; + return TRUE; + } + /* Detect scsi()cdrom()fdisk() */ + else if (sscanf(ArcPath, "scsi(%lu)cdrom(%lu)fdisk(%lu)", x, y, z) == 3) + { + *Partition = 0; + *PathSyntax = 0; + return TRUE; + } + /* Detect multi()disk()rdisk()partition() */ + else if (sscanf(ArcPath, "multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x, y, z, Partition) == 4) + { + *PathSyntax = 1; + return TRUE; + } + /* Detect multi()disk()cdrom() */ + else if (sscanf(ArcPath, "multi(%lu)disk(%lu)cdrom(%lu)", x, y, z) == 3) + { + *Partition = 1; + *PathSyntax = 1; + return TRUE; + } + /* Detect multi()disk()fdisk() */ + else if (sscanf(ArcPath, "multi(%lu)disk(%lu)fdisk(%lu)", x, y, z) == 3) + { + *Partition = 1; + *PathSyntax = 1; + return TRUE; + } + + /* Unknown syntax */ + return FALSE; +} + VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, ULONG Disk, ULONG Partition) { char tmp[50]; diff --git a/boot/freeldr/freeldr/windows/peloader.c b/boot/freeldr/freeldr/windows/peloader.c index f4c731e7254..7a87e282545 100644 --- a/boot/freeldr/freeldr/windows/peloader.c +++ b/boot/freeldr/freeldr/windows/peloader.c @@ -56,7 +56,7 @@ WinLdrCheckForLoadedDll(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock, PLDR_DATA_TABLE_ENTRY DataTableEntry; LIST_ENTRY *ModuleEntry; - DPRINTM(DPRINT_PELOADER, "WinLdrCheckForLoadedDll: DllName %X, LoadedEntry: %X\n", + DPRINTM(DPRINT_PELOADER, "WinLdrCheckForLoadedDll: DllName %s, LoadedEntry: %X\n", DllName, LoadedEntry); /* Just go through each entry in the LoadOrderList and compare loaded module's @@ -277,7 +277,7 @@ WinLdrLoadImage(IN PCHAR FileName, Status = ArcOpen(FileName, OpenReadOnly, &FileId); if (Status != ESUCCESS) { - UiMessageBox("Can not open the file"); + //UiMessageBox("Can not open the file"); return FALSE; } diff --git a/boot/freeldr/freeldr/windows/winldr.c b/boot/freeldr/freeldr/windows/winldr.c index 0121773e3a8..4ba7b1bcb29 100644 --- a/boot/freeldr/freeldr/windows/winldr.c +++ b/boot/freeldr/freeldr/windows/winldr.c @@ -37,6 +37,7 @@ extern char reactos_arc_strings[32][256]; extern BOOLEAN UseRealHeap; extern ULONG LoaderPagesSpanned; +extern BOOLEAN AcpiPresent; BOOLEAN WinLdrCheckForLoadedDll(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock, @@ -196,6 +197,13 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, Extension->MinorVersion = VersionToBoot & 0xFF; Extension->Profile.Status = 2; + /* Check if ACPI is present */ + if (AcpiPresent) + { + /* See KiRosFrldrLpbToNtLpb for details */ + Extension->AcpiTable = (PVOID)1; + } + /* Load drivers database */ strcpy(MiscFiles, BootPath); strcat(MiscFiles, "AppPatch\\drvmain.sdb"); diff --git a/dll/cpl/desk/lang/pl-PL.rc b/dll/cpl/desk/lang/pl-PL.rc index 0c4761b23e3..01d7c796d70 100644 --- a/dll/cpl/desk/lang/pl-PL.rc +++ b/dll/cpl/desk/lang/pl-PL.rc @@ -63,7 +63,7 @@ BEGIN WS_VISIBLE | WS_BORDER, 7, 7, 232, 120 LTEXT "Schemat kolorw", IDC_STATIC, 7, 140, 64, 7 COMBOBOX IDC_APPEARANCE_UI_ITEM, 7, 169, 120, 54, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "&Effects...", IDC_APPEARANCE_EFFECTS, 182, 150, 56, 15 + PUSHBUTTON "&Efekty...", IDC_APPEARANCE_EFFECTS, 182, 150, 56, 15 PUSHBUTTON "Zaawansowane", IDC_APPEARANCE_ADVANCED, 182, 170, 56, 15 END @@ -108,24 +108,24 @@ END IDD_EFFAPPEARANCE DIALOGEX DISCARDABLE 0, 0, 285, 185 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE -CAPTION "Effects" +CAPTION "Efekty" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "&Use the following transition effect for menus and tooltips:",IDC_EFFAPPEARANCE_ANIMATION,"button", + CONTROL "&Uyj nastpujcego efektu przejcia dla menu i etykiet narzdzi:",IDC_EFFAPPEARANCE_ANIMATION,"button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 5, 285, 19 COMBOBOX IDC_EFFAPPEARANCE_ANIMATIONTYPE, 20, 25, 80, 19 , CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VSCROLL | WS_TABSTOP - CONTROL "U&se the following method to smooth edges of screen fonts:",IDC_EFFAPPEARANCE_SMOOTHING,"button", + CONTROL "U&yj nastpujcej metody wygadzania krawdzi czcionek ekranowych:",IDC_EFFAPPEARANCE_SMOOTHING,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 42, 285, 19 COMBOBOX IDC_EFFAPPEARANCE_SMOOTHINGTYPE, 20, 62, 80, 19 , CBS_DROPDOWNLIST | CBS_HASSTRINGS | CBS_SORT | WS_VSCROLL | WS_TABSTOP | WS_DISABLED - CONTROL "Us&e large icons",IDC_EFFAPPEARANCE_LARGEICONS,"button", + CONTROL "Uy&j duych ikon",IDC_EFFAPPEARANCE_LARGEICONS,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 80, 285, 19 - CONTROL "Show sh&adows under menus",IDC_EFFAPPEARANCE_SETDROPSHADOW,"button", + CONTROL "Pok&a cienie pod menu",IDC_EFFAPPEARANCE_SETDROPSHADOW,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 95, 285, 19 - CONTROL "Show &window contents while dragging",IDC_EFFAPPEARANCE_DRAGFULLWINDOWS,"button", + CONTROL "Poka za&warto okna podczas przecigania",IDC_EFFAPPEARANCE_DRAGFULLWINDOWS,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 110, 285, 19 - CONTROL "&Hide underlined letters for keyboard navigation until I press the Alt key",IDC_EFFAPPEARANCE_KEYBOARDCUES,"button", + CONTROL "U&kryj podkrelenie liter do nawigacji klawiatur dopki nie nacisn klawisza Alt",IDC_EFFAPPEARANCE_KEYBOARDCUES,"button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 125, 285, 19 - PUSHBUTTON "Cancel", IDCANCEL, 226, 165, 50, 14 + PUSHBUTTON "Anuluj", IDCANCEL, 226, 165, 50, 14 DEFPUSHBUTTON "OK", IDOK, 172, 165, 50, 14 END @@ -188,13 +188,13 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_SLIDEEFFECT "Slide effect" - IDS_FADEEFFECT "Fade effect" + IDS_SLIDEEFFECT "Efekt przewijania" + IDS_FADEEFFECT "Efekt przejcia" END STRINGTABLE DISCARDABLE BEGIN - IDS_STANDARDEFFECT "Standard" + IDS_STANDARDEFFECT "Standardowe" IDS_CLEARTYPEEFFECT "ClearType" END diff --git a/dll/directx/amstream/amstream.c b/dll/directx/amstream/amstream.c index 9e4d45aef04..f8ae2a6e39b 100644 --- a/dll/directx/amstream/amstream.c +++ b/dll/directx/amstream/amstream.c @@ -35,7 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(amstream); typedef struct { - IAMMultiMediaStream lpVtbl; + const IAMMultiMediaStreamVtbl *lpVtbl; LONG ref; IGraphBuilder* pFilterGraph; IPin* ipin; @@ -63,7 +63,7 @@ HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) return E_OUTOFMEMORY; } - object->lpVtbl.lpVtbl = &AM_Vtbl; + object->lpVtbl = &AM_Vtbl; object->ref = 1; *ppObj = object; @@ -129,7 +129,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetMediaStream(IAMMultiMediaStream MSPID PurposeId; unsigned int i; - TRACE("(%p/%p)->(%p,%p)\n", This, iface, idPurpose, ppMediaStream); + TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(idPurpose), ppMediaStream); for (i = 0; i < This->nbStreams; i++) { @@ -214,7 +214,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* if IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface; HRESULT hr = S_OK; - FIXME("(%p/%p)->(%x,%x,%p) partial stub!\n", This, iface, (DWORD)StreamType, dwFlags, pFilterGraph); + TRACE("(%p/%p)->(%x,%x,%p)\n", This, iface, (DWORD)StreamType, dwFlags, pFilterGraph); if (pFilterGraph) { @@ -238,9 +238,17 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream { IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface; - FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppGraphBuilder); + TRACE("(%p/%p)->(%p)\n", This, iface, ppGraphBuilder); - return E_NOTIMPL; + if (!ppGraphBuilder) + return E_POINTER; + + if (This->pFilterGraph) + return IFilterGraph_QueryInterface(This->pFilterGraph, &IID_IGraphBuilder, (void**)ppGraphBuilder); + else + *ppGraphBuilder = NULL; + + return S_OK; } static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream* iface, IMediaStreamFilter** ppFilter) @@ -260,7 +268,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream IMediaStream* pStream; IMediaStream** pNewStreams; - FIXME("(%p/%p)->(%p,%p,%x,%p) partial stub!\n", This, iface, pStreamObject, PurposeId, dwFlags, ppNewStream); + FIXME("(%p/%p)->(%p,%s,%x,%p) partial stub!\n", This, iface, pStreamObject, debugstr_guid(PurposeId), dwFlags, ppNewStream); if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo)) hr = DirectDrawMediaStream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream); @@ -341,6 +349,14 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* ifac goto end; } + /* If Initialize was not called before, we do it here */ + if (!This->pFilterGraph) + { + ret = IAMMultiMediaStream_Initialize(iface, STREAMTYPE_READ, 0, NULL); + if (FAILED(ret)) + goto end; + } + ret = IFilterGraph_QueryInterface(This->pFilterGraph, &IID_IGraphBuilder, (void**)&This->GraphBuilder); if(ret != S_OK) { diff --git a/dll/directx/amstream/mediastream.c b/dll/directx/amstream/mediastream.c index bf197aadcf7..dc4ec642cf9 100644 --- a/dll/directx/amstream/mediastream.c +++ b/dll/directx/amstream/mediastream.c @@ -29,13 +29,14 @@ #include "wingdi.h" #include "amstream_private.h" -#include "ddstream.h" #include "amstream.h" +#include "ddstream.h" + WINE_DEFAULT_DEBUG_CHANNEL(amstream); typedef struct { - IMediaStream lpVtbl; + const IMediaStreamVtbl *lpVtbl; LONG ref; IMultiMediaStream* Parent; MSPID PurposeId; @@ -43,7 +44,7 @@ typedef struct { } IMediaStreamImpl; typedef struct { - IDirectDrawMediaStream lpVtbl; + const IDirectDrawMediaStreamVtbl *lpVtbl; LONG ref; IMultiMediaStream* Parent; MSPID PurposeId; @@ -57,7 +58,7 @@ HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, S { IMediaStreamImpl* object; - TRACE("(%p,%p,%p)\n", Parent, pPurposeId, ppMediaStream); + TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl)); if (!object) @@ -66,7 +67,7 @@ HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, S return E_OUTOFMEMORY; } - object->lpVtbl.lpVtbl = &MediaStream_Vtbl; + object->lpVtbl = &MediaStream_Vtbl; object->ref = 1; object->Parent = Parent; @@ -197,7 +198,7 @@ HRESULT DirectDrawMediaStream_create(IMultiMediaStream* Parent, const MSPID* pPu { IDirectDrawMediaStreamImpl* object; - TRACE("(%p,%p,%p)\n", Parent, pPurposeId, ppMediaStream); + TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl)); if (!object) @@ -206,7 +207,7 @@ HRESULT DirectDrawMediaStream_create(IMultiMediaStream* Parent, const MSPID* pPu return E_OUTOFMEMORY; } - object->lpVtbl.lpVtbl = &DirectDrawMediaStream_Vtbl; + object->lpVtbl = &DirectDrawMediaStream_Vtbl; object->ref = 1; object->Parent = Parent; diff --git a/dll/directx/amstream/mediastreamfilter.c b/dll/directx/amstream/mediastreamfilter.c index af335fdeafe..4a4d7123e16 100644 --- a/dll/directx/amstream/mediastreamfilter.c +++ b/dll/directx/amstream/mediastreamfilter.c @@ -36,7 +36,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(amstream); typedef struct { - IMediaStreamFilter lpVtbl; + const IMediaStreamFilterVtbl *lpVtbl; LONG ref; CRITICAL_SECTION csFilter; FILTER_STATE state; @@ -63,7 +63,7 @@ HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj) return E_OUTOFMEMORY; } - object->lpVtbl.lpVtbl = &MediaStreamFilter_Vtbl; + object->lpVtbl = &MediaStreamFilter_Vtbl; object->ref = 1; *ppObj = object; @@ -120,7 +120,7 @@ static ULONG WINAPI MediaStreamFilterImpl_Release(IMediaStreamFilter * iface) if (!refCount) { - This->lpVtbl.lpVtbl = NULL; + This->lpVtbl = NULL; HeapFree(GetProcessHeap(), 0, This); } diff --git a/dll/directx/amstream/regsvr.c b/dll/directx/amstream/regsvr.c index 028c68de754..9c328914749 100644 --- a/dll/directx/amstream/regsvr.c +++ b/dll/directx/amstream/regsvr.c @@ -456,6 +456,13 @@ static struct regsvr_coclass const coclass_list[] = { "Both" }, + { &CLSID_MediaStreamFilter, + "SFilter Class", + NULL, + "amstream.dll", + "Both" + }, + { NULL } /* list terminator */ }; diff --git a/dll/directx/bdaplgin/bdaplgin.cpp b/dll/directx/bdaplgin/bdaplgin.cpp index ddc22972c36..39ddb8a2ccb 100644 --- a/dll/directx/bdaplgin/bdaplgin.cpp +++ b/dll/directx/bdaplgin/bdaplgin.cpp @@ -12,7 +12,6 @@ const GUID CBDADeviceControl_GUID = {STATIC_KSMETHODSETID_BdaChangeSync}; const GUID CBDAPinControl_GUID = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}}; - static INTERFACE_TABLE InterfaceTable[] = { {&CBDADeviceControl_GUID, CBDADeviceControl_fnConstructor}, diff --git a/dll/directx/bdaplgin/devicecontrol.cpp b/dll/directx/bdaplgin/devicecontrol.cpp index 3bbdfbe0df6..661eba547a0 100644 --- a/dll/directx/bdaplgin/devicecontrol.cpp +++ b/dll/directx/bdaplgin/devicecontrol.cpp @@ -469,7 +469,7 @@ CBDADeviceControl::GetControlNode(ULONG ulInputPinId, ULONG ulOutputPinId, ULONG #ifdef BDAPLGIN_TRACE WCHAR Buffer[100]; - swprintf(Buffer, L"CBDADeviceControl::GetControlNode: hr %lx, BytesReturned %lu PinId %lu Dummy %lu\n", hr, BytesReturned, PinId, Dummy); + swprintf(Buffer, L"CBDADeviceControl::GetControlNode: hr %lx, BytesReturned %lu PinId %lu\n", hr, BytesReturned, PinId); OutputDebugStringW(Buffer); #endif @@ -498,6 +498,10 @@ CBDADeviceControl_fnConstructor( IBaseFilter *pFilter = NULL; HANDLE hFile; +#ifdef BDAPLGIN_TRACE + OutputDebugStringW(L"CBDADeviceControl_fnConstructor\n"); +#endif + //DebugBreak(); // sanity check @@ -540,10 +544,6 @@ CBDADeviceControl_fnConstructor( // construct device control CBDADeviceControl * handler = new CBDADeviceControl(pUnkOuter, pFilter, hFile); -#ifdef BDAPLGIN_TRACE - OutputDebugStringW(L"CBDADeviceControl_fnConstructor\n"); -#endif - if (!handler) return E_OUTOFMEMORY; diff --git a/dll/directx/bdaplgin/pincontrol.cpp b/dll/directx/bdaplgin/pincontrol.cpp index 324f7a1f6a1..a5b99128b16 100644 --- a/dll/directx/bdaplgin/pincontrol.cpp +++ b/dll/directx/bdaplgin/pincontrol.cpp @@ -9,7 +9,8 @@ #include "precomp.h" -const GUID IID_IBDA_PinControl = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}}; +const GUID IID_IBDA_PinControl = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}}; +const GUID KSPROPSETID_BdaPinControl = {0x0ded49d5, 0xa8b7, 0x4d5d, {0x97, 0xa1, 0x12, 0xb0, 0xc1, 0x95, 0x87, 0x4d}}; const GUID IID_IPin = {0x56a86891, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; class CBDAPinControl : public IBDA_PinControl @@ -39,7 +40,11 @@ public: CBDAPinControl(HANDLE hFile, IBDA_NetworkProvider * pProvider, IPin * pConnectedPin) : m_Ref(0), m_Handle(hFile), m_pProvider(pProvider), m_pConnectedPin(pConnectedPin){}; - virtual ~CBDAPinControl(){}; + virtual ~CBDAPinControl() + { + //m_pConnectedPin->Release(); + //m_pProvider->Release(); + }; protected: LONG m_Ref; @@ -54,6 +59,7 @@ CBDAPinControl::QueryInterface( IN REFIID refiid, OUT PVOID* Output) { + *Output = NULL; if (IsEqualGUID(refiid, IID_IUnknown)) { *Output = PVOID(this); @@ -67,6 +73,15 @@ CBDAPinControl::QueryInterface( return NOERROR; } +#ifdef BDAPLGIN_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CBDAPinControl::QueryInterface: NoInterface for %s", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); +#endif + return E_NOINTERFACE; } //------------------------------------------------------------------- @@ -76,22 +91,50 @@ HRESULT STDMETHODCALLTYPE CBDAPinControl::GetPinID(ULONG *pulPinID) { + KSPROPERTY Property; + ULONG BytesReturned; + HRESULT hr; + + // setup request + Property.Set = KSPROPSETID_BdaPinControl; + Property.Id = KSPROPERTY_BDA_PIN_ID; + Property.Flags = KSPROPERTY_TYPE_GET; + + // perform request + hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), pulPinID, sizeof(ULONG), &BytesReturned); + #ifdef BDAPLGIN_TRACE - OutputDebugStringW(L"CBDAPinControl::GetPinID: NotImplemented\n"); + WCHAR Buffer[100]; + swprintf(Buffer, L"CBDAPinControl::GetPinID: hr %lx pulPinID %lu BytesReturned %lx\n", hr, *pulPinID, BytesReturned); + OutputDebugStringW(Buffer); #endif - return E_NOTIMPL; + return hr; } HRESULT STDMETHODCALLTYPE CBDAPinControl::GetPinType(ULONG *pulPinType) { + KSPROPERTY Property; + ULONG BytesReturned; + HRESULT hr; + + // setup request + Property.Set = KSPROPSETID_BdaPinControl; + Property.Id = KSPROPERTY_BDA_PIN_TYPE; + Property.Flags = KSPROPERTY_TYPE_GET; + + // perform request + hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), pulPinType, sizeof(ULONG), &BytesReturned); + #ifdef BDAPLGIN_TRACE - OutputDebugStringW(L"CBDAPinControl::GetPinType: NotImplemented\n"); + WCHAR Buffer[100]; + swprintf(Buffer, L"CBDAPinControl::GetPinType: hr %lx pulPinType %lu BytesReturned %lx\n", hr, *pulPinType, BytesReturned); + OutputDebugStringW(Buffer); #endif - return E_NOTIMPL; + return hr; } HRESULT @@ -112,15 +155,29 @@ CBDAPinControl_fnConstructor( REFIID riid, LPVOID * ppv) { + IPin * pConnectedPin = NULL; + IBDA_NetworkProvider * pNetworkProvider = NULL; + HANDLE hFile = INVALID_HANDLE_VALUE; + +#if 0 + if (!IsEqualGUID(riid, IID_IUnknown)) + { +#ifdef BDAPLGIN_TRACE + OutputDebugStringW(L"CBDAPinControl_fnConstructor: Expected IUnknown\n"); +#endif + return REGDB_E_CLASSNOTREG; + } + + HRESULT hr; IKsObject * pObject = NULL; - IPin * pPin = NULL, * pConnectedPin = NULL; + IPin * pPin = NULL; IEnumFilters *pEnumFilters = NULL; - IBDA_NetworkProvider * pNetworkProvider = NULL; + IBaseFilter * ppFilter[1]; PIN_INFO PinInfo; FILTER_INFO FilterInfo; - HANDLE hFile = INVALID_HANDLE_VALUE; + if (!pUnkOuter) return E_POINTER; @@ -225,6 +282,7 @@ CBDAPinControl_fnConstructor( // no network provider interface in graph return E_NOINTERFACE; } +#endif CBDAPinControl * handler = new CBDAPinControl(hFile, pNetworkProvider, pConnectedPin); @@ -232,6 +290,8 @@ CBDAPinControl_fnConstructor( OutputDebugStringW(L"CBDAPinControl_fnConstructor"); #endif + DebugBreak(); + if (!handler) return E_OUTOFMEMORY; diff --git a/dll/directx/bdaplgin/precomp.h b/dll/directx/bdaplgin/precomp.h index 4365afb807e..771a798f2c3 100644 --- a/dll/directx/bdaplgin/precomp.h +++ b/dll/directx/bdaplgin/precomp.h @@ -1,6 +1,7 @@ #ifndef PRECOMP_H__ #define PRECOMP_H__ +//#define BDAPLGIN_TRACE #define BUILDING_KS #define _KSDDK_ #include diff --git a/dll/directx/ksproxy/basicaudio.cpp b/dll/directx/ksproxy/basicaudio.cpp index 20b5e8aee24..7fec05f2140 100644 --- a/dll/directx/ksproxy/basicaudio.cpp +++ b/dll/directx/ksproxy/basicaudio.cpp @@ -8,8 +8,6 @@ */ #include "precomp.h" -const GUID IID_IBasicAudio = {0x56a868b3, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; - class CKsBasicAudio : public IBasicAudio, public IDistributorNotify { @@ -99,7 +97,7 @@ HRESULT STDMETHODCALLTYPE CKsBasicAudio::Stop() { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -107,7 +105,7 @@ HRESULT STDMETHODCALLTYPE CKsBasicAudio::Pause() { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -116,7 +114,7 @@ STDMETHODCALLTYPE CKsBasicAudio::Run( REFERENCE_TIME tStart) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -125,7 +123,7 @@ STDMETHODCALLTYPE CKsBasicAudio::SetSyncSource( IReferenceClock *pClock) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -133,7 +131,7 @@ HRESULT STDMETHODCALLTYPE CKsBasicAudio::NotifyGraphChange() { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -146,7 +144,7 @@ STDMETHODCALLTYPE CKsBasicAudio::GetTypeInfoCount( UINT *pctinfo) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -157,7 +155,7 @@ CKsBasicAudio::GetTypeInfo( LCID lcid, ITypeInfo **ppTInfo) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -170,7 +168,7 @@ CKsBasicAudio::GetIDsOfNames( LCID lcid, DISPID *rgDispId) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -186,7 +184,7 @@ CKsBasicAudio::Invoke( EXCEPINFO *pExcepInfo, UINT *puArgErr) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -199,7 +197,7 @@ STDMETHODCALLTYPE CKsBasicAudio::put_Volume( long lVolume) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -209,7 +207,7 @@ STDMETHODCALLTYPE CKsBasicAudio::get_Volume( long *plVolume) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -219,7 +217,7 @@ STDMETHODCALLTYPE CKsBasicAudio::put_Balance( long lBalance) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -229,7 +227,7 @@ STDMETHODCALLTYPE CKsBasicAudio::get_Balance( long *plBalance) { - OutputDebugString("UNIMPLEMENTED\n"); + OutputDebugStringW(L"UNIMPLEMENTED\n"); return E_NOTIMPL; } @@ -240,6 +238,8 @@ CKsBasicAudio_Constructor( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CKsBasicAudio_Constructor\n"); + CKsBasicAudio * handler = new CKsBasicAudio(); if (!handler) diff --git a/dll/directx/ksproxy/clockforward.cpp b/dll/directx/ksproxy/clockforward.cpp index a5889386f0a..cba65b3cdf0 100644 --- a/dll/directx/ksproxy/clockforward.cpp +++ b/dll/directx/ksproxy/clockforward.cpp @@ -8,7 +8,6 @@ */ #include "precomp.h" -const GUID IID_IDistributorNotify = {0x56a868af, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; const GUID KSCATEGORY_CLOCK = {0x53172480, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; class CKsClockForwarder : public IDistributorNotify, @@ -158,6 +157,8 @@ CKsClockForwarder_Constructor( HRESULT hr; HANDLE handle; + OutputDebugStringW(L"CKsClockForwarder_Constructor\n"); + // open default clock hr = KsOpenDefaultDevice(KSCATEGORY_CLOCK, GENERIC_READ | GENERIC_WRITE, &handle); diff --git a/dll/directx/ksproxy/cvpconfig.cpp b/dll/directx/ksproxy/cvpconfig.cpp index ffe4fc7bb5f..91d2006ad49 100644 --- a/dll/directx/ksproxy/cvpconfig.cpp +++ b/dll/directx/ksproxy/cvpconfig.cpp @@ -8,8 +8,6 @@ */ #include "precomp.h" -const GUID IID_IVPConfig = {0xbc29a660, 0x30e3, 0x11d0, {0x9e, 0x69, 0x0, 0xc0, 0x4f, 0xd7, 0xc1, 0x5b}}; - class CVPConfig : public IVPConfig, public IDistributorNotify { @@ -302,6 +300,8 @@ CVPConfig_Constructor( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CVPConfig_Constructor\n"); + CVPConfig * handler = new CVPConfig(); if (!handler) diff --git a/dll/directx/ksproxy/cvpvbiconfig.cpp b/dll/directx/ksproxy/cvpvbiconfig.cpp index 061d332c53f..016d060aa24 100644 --- a/dll/directx/ksproxy/cvpvbiconfig.cpp +++ b/dll/directx/ksproxy/cvpvbiconfig.cpp @@ -8,8 +8,6 @@ */ #include "precomp.h" -const GUID IID_IVPVBIConfig = {0xec529b00, 0x1a1f, 0x11d1, {0xba, 0xd9, 0x0, 0x60, 0x97, 0x44, 0x11, 0x1a}}; - class CVPVBIConfig : public IVPVBIConfig, public IDistributorNotify { @@ -274,6 +272,8 @@ CVPVBIConfig_Constructor( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CVPVBIConfig_Constructor\n"); + CVPVBIConfig * handler = new CVPVBIConfig(); if (!handler) diff --git a/dll/directx/ksproxy/datatype.cpp b/dll/directx/ksproxy/datatype.cpp index 37f47e231af..3d2d925f19c 100644 --- a/dll/directx/ksproxy/datatype.cpp +++ b/dll/directx/ksproxy/datatype.cpp @@ -11,9 +11,6 @@ /* FIXME guid mess */ const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; -const GUID IID_IKsDataTypeHandler = {0x5FFBAA02, 0x49A3, 0x11D0, {0x9F, 0x36, 0x00, 0xAA, 0x00, 0xA2, 0x16, 0xA1}}; -const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; - class CKsDataTypeHandler : public IKsDataTypeHandler { @@ -138,6 +135,8 @@ CKsDataTypeHandler_Constructor ( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CKsDataTypeHandler_Constructor\n"); + CKsDataTypeHandler * handler = new CKsDataTypeHandler(); if (!handler) diff --git a/dll/directx/ksproxy/enum_mediatypes.cpp b/dll/directx/ksproxy/enum_mediatypes.cpp new file mode 100644 index 00000000000..9895c2290cc --- /dev/null +++ b/dll/directx/ksproxy/enum_mediatypes.cpp @@ -0,0 +1,188 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/enum_mediatypes.cpp + * PURPOSE: IEnumMediaTypes interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumMediaTypes : public IEnumMediaTypes +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + HRESULT STDMETHODCALLTYPE Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG cMediaTypes); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes **ppEnum); + + + CEnumMediaTypes(ULONG MediaTypeCount, AM_MEDIA_TYPE * MediaTypes) : m_Ref(0), m_MediaTypeCount(MediaTypeCount), m_MediaTypes(MediaTypes), m_Index(0){}; + virtual ~CEnumMediaTypes(){}; + +protected: + LONG m_Ref; + ULONG m_MediaTypeCount; + AM_MEDIA_TYPE * m_MediaTypes; + ULONG m_Index; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IEnumMediaTypes)) + { + *Output = (IEnumMediaTypes*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CEnumMediaTypes::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IEnumMediaTypes +// + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Next( + ULONG cMediaTypes, + AM_MEDIA_TYPE **ppMediaTypes, + ULONG *pcFetched) +{ + ULONG i = 0; + AM_MEDIA_TYPE * MediaType; + + if (!ppMediaTypes) + return E_POINTER; + + if (cMediaTypes > 1 && !pcFetched) + return E_INVALIDARG; + + while(i < cMediaTypes) + { + if (m_Index + i >= m_MediaTypeCount) + break; + + MediaType = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + if (!MediaType) + break; + + CopyMemory(MediaType, &m_MediaTypes[m_Index + i], sizeof(AM_MEDIA_TYPE)); + ppMediaTypes[i] = MediaType; + i++; + } + + if (pcFetched) + { + *pcFetched = i; + } + + m_Index += i; + + if (i < cMediaTypes) + return S_FALSE; + else + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Skip( + ULONG cMediaTypes) +{ + if (cMediaTypes + m_Index >= m_MediaTypeCount) + { + return S_FALSE; + } + + m_Index += cMediaTypes; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Reset() +{ + m_Index = 0; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Clone( + IEnumMediaTypes **ppEnum) +{ + OutputDebugStringW(L"CEnumMediaTypes::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumMediaTypes_fnConstructor( + ULONG MediaTypeCount, + AM_MEDIA_TYPE * MediaTypes, + REFIID riid, + LPVOID * ppv) +{ + CEnumMediaTypes * handler = new CEnumMediaTypes(MediaTypeCount, MediaTypes); + +#ifdef KSPROXY_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CEnumMediaTypes_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + { + CoTaskMemFree(MediaTypes); + return E_OUTOFMEMORY; + } + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} + diff --git a/dll/directx/ksproxy/enumpins.cpp b/dll/directx/ksproxy/enumpins.cpp new file mode 100644 index 00000000000..5c0f0ecd7bd --- /dev/null +++ b/dll/directx/ksproxy/enumpins.cpp @@ -0,0 +1,159 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/enumpins.cpp + * PURPOSE: IEnumPins interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumPins : public IEnumPins +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + + HRESULT STDMETHODCALLTYPE Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG cPins); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumPins **ppEnum); + + CEnumPins(std::vector Pins) : m_Ref(0), m_Pins(Pins), m_Index(0){}; + virtual ~CEnumPins(){}; + +protected: + LONG m_Ref; + std::vector m_Pins; + ULONG m_Index; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumPins::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + *Output = NULL; + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IEnumPins)) + { + *Output = (IEnumPins*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + return E_NOINTERFACE; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Next( + ULONG cPins, + IPin **ppPins, + ULONG *pcFetched) +{ + ULONG i = 0; + + if (!ppPins) + return E_POINTER; + + if (cPins > 1 && !pcFetched) + return E_INVALIDARG; + + while(i < cPins) + { + if (m_Index + i >= m_Pins.size()) + break; + + ppPins[i] = m_Pins[m_Index + i]; + m_Pins[m_Index + i]->AddRef(); + + i++; + } + + if (pcFetched) + { + *pcFetched = i; + } + + m_Index += i; + if (i < cPins) + return S_FALSE; + else + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Skip( + ULONG cPins) +{ + if (cPins + m_Index >= m_Pins.size()) + { + return S_FALSE; + } + + m_Index += cPins; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Reset() +{ + m_Index = 0; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Clone( + IEnumPins **ppEnum) +{ + OutputDebugStringW(L"CEnumPins::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumPins_fnConstructor( + std::vector Pins, + REFIID riid, + LPVOID * ppv) +{ + CEnumPins * handler = new CEnumPins(Pins); + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file diff --git a/dll/directx/ksproxy/input_pin.cpp b/dll/directx/ksproxy/input_pin.cpp new file mode 100644 index 00000000000..2b08b16e89e --- /dev/null +++ b/dll/directx/ksproxy/input_pin.cpp @@ -0,0 +1,983 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS WDM Streaming ActiveMovie Proxy + * FILE: dll/directx/ksproxy/input_cpp.cpp + * PURPOSE: InputPin of Proxy Filter + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +const GUID IID_IKsPinEx = {0x7bb38260L, 0xd19c, 0x11d2, {0xb3, 0x8a, 0x00, 0xa0, 0xc9, 0x5e, 0xc2, 0x2e}}; +const GUID KSPROPSETID_Connection = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; + +KSPIN_INTERFACE StandardPinInterface = +{ + {STATIC_KSINTERFACESETID_Standard}, + KSINTERFACE_STANDARD_STREAMING, + 0 +}; + +KSPIN_MEDIUM StandardPinMedium = +{ + {STATIC_KSMEDIUMSETID_Standard}, + KSMEDIUM_TYPE_ANYINSTANCE, + 0 +}; + + +class CInputPin : public IPin, + public IKsPropertySet, + public IKsControl, + public IKsObject, + public IKsPinEx, + public IMemInputPin +/* + public IQualityControl, + public IKsPinPipe, + public ISpecifyPropertyPages, + public IStreamBuilder, + public IKsPinFactory, + public IKsAggregateControl +*/ +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + //IPin methods + HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE Disconnect(); + HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin); + HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); + HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); + HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); + HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); + HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); + HRESULT STDMETHODCALLTYPE EndOfStream(); + HRESULT STDMETHODCALLTYPE BeginFlush(); + HRESULT STDMETHODCALLTYPE EndFlush(); + HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); + + //IKsObject methods + HANDLE STDMETHODCALLTYPE KsGetObjectHandle(); + + //IKsPropertySet + HRESULT STDMETHODCALLTYPE Set(REFGUID guidPropSet, DWORD dwPropID, LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData, DWORD cbPropData); + HRESULT STDMETHODCALLTYPE Get(REFGUID guidPropSet, DWORD dwPropID, LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData, DWORD cbPropData, DWORD *pcbReturned); + HRESULT STDMETHODCALLTYPE QuerySupported(REFGUID guidPropSet, DWORD dwPropID, DWORD *pTypeSupport); + + //IKsControl + HRESULT STDMETHODCALLTYPE KsProperty(PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData, ULONG DataLength, ULONG* BytesReturned); + HRESULT STDMETHODCALLTYPE KsMethod(PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData, ULONG DataLength, ULONG* BytesReturned); + HRESULT STDMETHODCALLTYPE KsEvent(PKSEVENT Event, ULONG EventLength, LPVOID EventData, ULONG DataLength, ULONG* BytesReturned); + + //IKsPin + HRESULT STDMETHODCALLTYPE KsQueryMediums(PKSMULTIPLE_ITEM* MediumList); + HRESULT STDMETHODCALLTYPE KsQueryInterfaces(PKSMULTIPLE_ITEM* InterfaceList); + HRESULT STDMETHODCALLTYPE KsCreateSinkPinHandle(KSPIN_INTERFACE& Interface, KSPIN_MEDIUM& Medium); + HRESULT STDMETHODCALLTYPE KsGetCurrentCommunication(KSPIN_COMMUNICATION *Communication, KSPIN_INTERFACE *Interface, KSPIN_MEDIUM *Medium); + HRESULT STDMETHODCALLTYPE KsPropagateAcquire(); + HRESULT STDMETHODCALLTYPE KsDeliver(IMediaSample* Sample, ULONG Flags); + HRESULT STDMETHODCALLTYPE KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment); + IMemAllocator * STDMETHODCALLTYPE KsPeekAllocator(KSPEEKOPERATION Operation); + HRESULT STDMETHODCALLTYPE KsReceiveAllocator(IMemAllocator *MemAllocator); + HRESULT STDMETHODCALLTYPE KsRenegotiateAllocator(); + LONG STDMETHODCALLTYPE KsIncrementPendingIoCount(); + LONG STDMETHODCALLTYPE KsDecrementPendingIoCount(); + HRESULT STDMETHODCALLTYPE KsQualityNotify(ULONG Proportion, REFERENCE_TIME TimeDelta); + // IKsPinEx + VOID STDMETHODCALLTYPE KsNotifyError(IMediaSample* Sample, HRESULT hr); + + //IMemInputPin + HRESULT STDMETHODCALLTYPE GetAllocator(IMemAllocator **ppAllocator); + HRESULT STDMETHODCALLTYPE NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly); + HRESULT STDMETHODCALLTYPE GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps); + HRESULT STDMETHODCALLTYPE Receive(IMediaSample *pSample); + HRESULT STDMETHODCALLTYPE ReceiveMultiple(IMediaSample **pSamples, long nSamples, long *nSamplesProcessed); + HRESULT STDMETHODCALLTYPE ReceiveCanBlock( void); + + //--------------------------------------------------------------- + HRESULT STDMETHODCALLTYPE CheckFormat(const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE CreatePin(); + HRESULT STDMETHODCALLTYPE CreatePinHandle(PKSPIN_MEDIUM Medium, PKSPIN_INTERFACE Interface, PKSDATAFORMAT DataFormat); + CInputPin(IBaseFilter * ParentFilter, LPCWSTR PinName, HANDLE hFilter, ULONG PinId, KSPIN_COMMUNICATION Communication) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName), m_hFilter(hFilter), m_hPin(0), m_PinId(PinId), m_MemAllocator(0), m_IoCount(0), m_Communication(Communication), m_Pin(0){}; + virtual ~CInputPin(){}; + +protected: + LONG m_Ref; + IBaseFilter * m_ParentFilter; + LPCWSTR m_PinName; + HANDLE m_hFilter; + HANDLE m_hPin; + ULONG m_PinId; + IMemAllocator * m_MemAllocator; + LONG m_IoCount; + KSPIN_COMMUNICATION m_Communication; + KSPIN_INTERFACE m_Interface; + KSPIN_MEDIUM m_Medium; + IPin * m_Pin; +}; + +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + *Output = NULL; + + if (IsEqualGUID(refiid, IID_IUnknown) || + IsEqualGUID(refiid, IID_IPin)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IMemInputPin)) + { + *Output = (IMemInputPin*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IKsObject)) + { + if (!m_hPin) + { + HRESULT hr = CreatePin(); + if (FAILED(hr)) + return hr; + } + + *Output = (IKsObject*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IKsPropertySet)) + { + if (!m_hPin) + { + HRESULT hr = CreatePin(); + if (FAILED(hr)) + return hr; + } + + *Output = (IKsPropertySet*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IKsControl)) + { + if (!m_hPin) + { + HRESULT hr = CreatePin(); + if (FAILED(hr)) + return hr; + } + + *Output = (IKsControl*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IKsPin) || + IsEqualGUID(refiid, IID_IKsPinEx)) + { + if (!m_hPin) + { + HRESULT hr = CreatePin(); + if (FAILED(hr)) + return hr; + } + + *Output = (IKsPinEx*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CInputPin::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IMemInputPin +// + + // +HRESULT +STDMETHODCALLTYPE +CInputPin::GetAllocator(IMemAllocator **ppAllocator) +{ + OutputDebugStringW(L"CInputPin::GetAllocator\n"); + return VFW_E_NO_ALLOCATOR; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly) +{ + if (pAllocator) + { + pAllocator->AddRef(); + } + + if (m_MemAllocator) + { + m_MemAllocator->Release(); + } + + m_MemAllocator = pAllocator; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps) +{ + KSALLOCATOR_FRAMING Framing; + KSPROPERTY Property; + HRESULT hr; + ULONG BytesReturned; + + Property.Set = KSPROPSETID_Connection; + Property.Id = KSPROPERTY_CONNECTION_ALLOCATORFRAMING; + Property.Flags = KSPROPERTY_TYPE_SET; + + hr = KsProperty(&Property, sizeof(KSPROPERTY), (PVOID)&Framing, sizeof(KSALLOCATOR_FRAMING), &BytesReturned); + if (SUCCEEDED(hr)) + { + pProps->cBuffers = Framing.Frames; + pProps->cbBuffer = Framing.FrameSize; + pProps->cbAlign = Framing.FileAlignment; + pProps->cbPrefix = 0; + return hr; + } + else + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::Receive(IMediaSample *pSample) +{ + OutputDebugStringW(L"CInputPin::Receive NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::ReceiveMultiple(IMediaSample **pSamples, long nSamples, long *nSamplesProcessed) +{ + OutputDebugStringW(L"CInputPin::ReceiveMultiple NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::ReceiveCanBlock( void) +{ + OutputDebugStringW(L"CInputPin::ReceiveCanBlock NotImplemented\n"); + return S_FALSE; +} + + +//------------------------------------------------------------------- +// IKsPin +// + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsQueryMediums( + PKSMULTIPLE_ITEM* MediumList) +{ + return KsGetMultiplePinFactoryItems(m_hFilter, m_PinId, KSPROPERTY_PIN_MEDIUMS, (PVOID*)MediumList); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsQueryInterfaces( + PKSMULTIPLE_ITEM* InterfaceList) +{ + return KsGetMultiplePinFactoryItems(m_hFilter, m_PinId, KSPROPERTY_PIN_INTERFACES, (PVOID*)InterfaceList); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsCreateSinkPinHandle( + KSPIN_INTERFACE& Interface, + KSPIN_MEDIUM& Medium) +{ + OutputDebugStringW(L"CInputPin::KsCreateSinkPinHandle NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsGetCurrentCommunication( + KSPIN_COMMUNICATION *Communication, + KSPIN_INTERFACE *Interface, + KSPIN_MEDIUM *Medium) +{ + if (Communication) + { + *Communication = m_Communication; + } + + if (Interface) + { + if (!m_hPin) + return VFW_E_NOT_CONNECTED; + + CopyMemory(Interface, &m_Interface, sizeof(KSPIN_INTERFACE)); + } + + if (Medium) + { + if (!m_hPin) + return VFW_E_NOT_CONNECTED; + + CopyMemory(Medium, &m_Medium, sizeof(KSPIN_MEDIUM)); + } + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsPropagateAcquire() +{ + OutputDebugStringW(L"CInputPin::KsPropagateAcquire NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsDeliver( + IMediaSample* Sample, + ULONG Flags) +{ + return E_FAIL; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment) +{ + return NOERROR; +} + +IMemAllocator * +STDMETHODCALLTYPE +CInputPin::KsPeekAllocator(KSPEEKOPERATION Operation) +{ + if (Operation == KsPeekOperation_AddRef) + { + // add reference on allocator + m_MemAllocator->AddRef(); + } + + return m_MemAllocator; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsReceiveAllocator(IMemAllocator *MemAllocator) +{ + if (MemAllocator) + { + MemAllocator->AddRef(); + } + + if (m_MemAllocator) + { + m_MemAllocator->Release(); + } + + m_MemAllocator = MemAllocator; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsRenegotiateAllocator() +{ + return E_FAIL; +} + +LONG +STDMETHODCALLTYPE +CInputPin::KsIncrementPendingIoCount() +{ + return InterlockedIncrement((volatile LONG*)&m_IoCount); +} + +LONG +STDMETHODCALLTYPE +CInputPin::KsDecrementPendingIoCount() +{ + return InterlockedDecrement((volatile LONG*)&m_IoCount); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsQualityNotify( + ULONG Proportion, + REFERENCE_TIME TimeDelta) +{ + OutputDebugStringW(L"CInputPin::KsQualityNotify NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IKsPinEx +// + +VOID +STDMETHODCALLTYPE +CInputPin::KsNotifyError( + IMediaSample* Sample, + HRESULT hr) +{ + OutputDebugStringW(L"CInputPin::KsNotifyError NotImplemented\n"); +} + + +//------------------------------------------------------------------- +// IKsPropertySet +// +HRESULT +STDMETHODCALLTYPE +CInputPin::KsProperty( + PKSPROPERTY Property, + ULONG PropertyLength, + LPVOID PropertyData, + ULONG DataLength, + ULONG* BytesReturned) +{ + return KsSynchronousDeviceControl(m_hPin, IOCTL_KS_PROPERTY, (PVOID)Property, PropertyLength, (PVOID)PropertyData, DataLength, BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsMethod( + PKSMETHOD Method, + ULONG MethodLength, + LPVOID MethodData, + ULONG DataLength, + ULONG* BytesReturned) +{ + return KsSynchronousDeviceControl(m_hPin, IOCTL_KS_METHOD, (PVOID)Method, MethodLength, (PVOID)MethodData, DataLength, BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::KsEvent( + PKSEVENT Event, + ULONG EventLength, + LPVOID EventData, + ULONG DataLength, + ULONG* BytesReturned) +{ + if (EventLength) + return KsSynchronousDeviceControl(m_hPin, IOCTL_KS_ENABLE_EVENT, (PVOID)Event, EventLength, (PVOID)EventData, DataLength, BytesReturned); + else + return KsSynchronousDeviceControl(m_hPin, IOCTL_KS_DISABLE_EVENT, (PVOID)Event, EventLength, NULL, 0, BytesReturned); +} + + +//------------------------------------------------------------------- +// IKsPropertySet +// +HRESULT +STDMETHODCALLTYPE +CInputPin::Set( + REFGUID guidPropSet, + DWORD dwPropID, + LPVOID pInstanceData, + DWORD cbInstanceData, + LPVOID pPropData, + DWORD cbPropData) +{ + ULONG BytesReturned; + + if (cbInstanceData) + { + PKSPROPERTY Property = (PKSPROPERTY)CoTaskMemAlloc(sizeof(KSPROPERTY) + cbInstanceData); + if (!Property) + return E_OUTOFMEMORY; + + Property->Set = guidPropSet; + Property->Id = dwPropID; + Property->Flags = KSPROPERTY_TYPE_SET; + + CopyMemory((Property+1), pInstanceData, cbInstanceData); + + HRESULT hr = KsProperty(Property, sizeof(KSPROPERTY) + cbInstanceData, pPropData, cbPropData, &BytesReturned); + CoTaskMemFree(Property); + return hr; + } + else + { + KSPROPERTY Property; + + Property.Set = guidPropSet; + Property.Id = dwPropID; + Property.Flags = KSPROPERTY_TYPE_SET; + + HRESULT hr = KsProperty(&Property, sizeof(KSPROPERTY), pPropData, cbPropData, &BytesReturned); + return hr; + } +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::Get( + REFGUID guidPropSet, + DWORD dwPropID, + LPVOID pInstanceData, + DWORD cbInstanceData, + LPVOID pPropData, + DWORD cbPropData, + DWORD *pcbReturned) +{ + ULONG BytesReturned; + + if (cbInstanceData) + { + PKSPROPERTY Property = (PKSPROPERTY)CoTaskMemAlloc(sizeof(KSPROPERTY) + cbInstanceData); + if (!Property) + return E_OUTOFMEMORY; + + Property->Set = guidPropSet; + Property->Id = dwPropID; + Property->Flags = KSPROPERTY_TYPE_GET; + + CopyMemory((Property+1), pInstanceData, cbInstanceData); + + HRESULT hr = KsProperty(Property, sizeof(KSPROPERTY) + cbInstanceData, pPropData, cbPropData, &BytesReturned); + CoTaskMemFree(Property); + return hr; + } + else + { + KSPROPERTY Property; + + Property.Set = guidPropSet; + Property.Id = dwPropID; + Property.Flags = KSPROPERTY_TYPE_GET; + + HRESULT hr = KsProperty(&Property, sizeof(KSPROPERTY), pPropData, cbPropData, &BytesReturned); + return hr; + } +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::QuerySupported( + REFGUID guidPropSet, + DWORD dwPropID, + DWORD *pTypeSupport) +{ + KSPROPERTY Property; + ULONG BytesReturned; + + Property.Set = guidPropSet; + Property.Id = dwPropID; + Property.Flags = KSPROPERTY_TYPE_SETSUPPORT; + + return KsProperty(&Property, sizeof(KSPROPERTY), pTypeSupport, sizeof(DWORD), &BytesReturned); +} + + +//------------------------------------------------------------------- +// IKsObject +// +HANDLE +STDMETHODCALLTYPE +CInputPin::KsGetObjectHandle() +{ + OutputDebugStringW(L"CInputPin::KsGetObjectHandle CALLED\n"); + + //FIXME + // return pin handle + return m_hPin; +} + +//------------------------------------------------------------------- +// IPin interface +// +HRESULT +STDMETHODCALLTYPE +CInputPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CInputPin::Connect NotImplemented\n"); + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) +{ + HRESULT hr; + + if (m_Pin) + { + OutputDebugStringW(L"CInputPin::ReceiveConnection already connected\n"); + return VFW_E_ALREADY_CONNECTED; + } + + // first check format + hr = CheckFormat(pmt); + if (FAILED(hr)) + return hr; + + if (FAILED(CheckFormat(pmt))) + return hr; + + //FIXME create pin + m_Pin = pConnector; + m_Pin->AddRef(); + + OutputDebugStringW(L"CInputPin::ReceiveConnection NotImplemented\n"); + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::Disconnect( void) +{ + OutputDebugStringW(L"CInputPin::Disconnect NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::ConnectedTo(IPin **pPin) +{ + if (!pPin) + return E_POINTER; + + if (m_Pin) + { + // increment reference count + m_Pin->AddRef(); + *pPin = m_Pin; + return S_OK; + } + + *pPin = NULL; + return VFW_E_NOT_CONNECTED; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CInputPin::ConnectionMediaType NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryPinInfo(PIN_INFO *pInfo) +{ + wcscpy(pInfo->achName, m_PinName); + pInfo->dir = PINDIR_INPUT; + pInfo->pFilter = m_ParentFilter; + m_ParentFilter->AddRef(); + + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryDirection(PIN_DIRECTION *pPinDir) +{ + if (pPinDir) + { + *pPinDir = PINDIR_INPUT; + return S_OK; + } + + return E_POINTER; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryId(LPWSTR *Id) +{ + *Id = (LPWSTR)CoTaskMemAlloc((wcslen(m_PinName)+1)*sizeof(WCHAR)); + if (!*Id) + return E_OUTOFMEMORY; + + wcscpy(*Id, m_PinName); + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryAccept( + const AM_MEDIA_TYPE *pmt) +{ + return CheckFormat(pmt); +} +HRESULT +STDMETHODCALLTYPE +CInputPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) +{ + return CEnumMediaTypes_fnConstructor(0, NULL, IID_IEnumMediaTypes, (void**)ppEnum); +} +HRESULT +STDMETHODCALLTYPE +CInputPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) +{ + OutputDebugStringW(L"CInputPin::QueryInternalConnections NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::EndOfStream( void) +{ + OutputDebugStringW(L"CInputPin::EndOfStream NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::BeginFlush( void) +{ + OutputDebugStringW(L"CInputPin::BeginFlush NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::EndFlush( void) +{ + OutputDebugStringW(L"CInputPin::EndFlush NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) +{ + OutputDebugStringW(L"CInputPin::NewSegment NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +HRESULT +STDMETHODCALLTYPE +CInputPin::CheckFormat( + const AM_MEDIA_TYPE *pmt) +{ + KSP_PIN Property; + PKSMULTIPLE_ITEM MultipleItem; + PKSDATAFORMAT DataFormat; + ULONG BytesReturned; + HRESULT hr; + + // prepare request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_DATARANGES; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = m_PinId; + Property.Reserved = 0; + + // query for size of dataranges + hr = KsSynchronousDeviceControl(m_hFilter, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), NULL, 0, &BytesReturned); + + if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_MORE_DATA)) + { + // allocate dataranges buffer + MultipleItem = (PKSMULTIPLE_ITEM)CoTaskMemAlloc(BytesReturned); + + if (!MultipleItem) + return E_OUTOFMEMORY; + + // query dataranges + hr = KsSynchronousDeviceControl(m_hFilter, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)MultipleItem, BytesReturned, &BytesReturned); + + if (FAILED(hr)) + { + // failed to query data ranges + CoTaskMemFree(MultipleItem); + return hr; + } + + DataFormat = (PKSDATAFORMAT)(MultipleItem + 1); + for(ULONG Index = 0; Index < MultipleItem->Count; Index++) + { + if (IsEqualGUID(pmt->majortype, DataFormat->MajorFormat) && + IsEqualGUID(pmt->subtype, DataFormat->SubFormat) && + IsEqualGUID(pmt->formattype, DataFormat->Specifier)) + { + // format is supported + CoTaskMemFree(MultipleItem); + OutputDebugStringW(L"CInputPin::CheckFormat format OK\n"); + return S_OK; + } + DataFormat = (PKSDATAFORMAT)((ULONG_PTR)DataFormat + DataFormat->FormatSize); + } + //format is not supported + CoTaskMemFree(MultipleItem); + } + return S_FALSE; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::CreatePin() +{ + PKSMULTIPLE_ITEM MediumList; + PKSMULTIPLE_ITEM InterfaceList; + PKSMULTIPLE_ITEM DataFormatList = NULL; + PKSPIN_MEDIUM Medium; + PKSDATAFORMAT DataFormat; + PKSPIN_INTERFACE Interface; + HRESULT hr; + + // query for pin medium + hr = KsQueryMediums(&MediumList); + if (FAILED(hr)) + return hr; + + // query for pin interface + hr = KsQueryInterfaces(&InterfaceList); + if (FAILED(hr)) + { + // failed + CoTaskMemFree(MediumList); + return hr; + } + + // get data ranges + hr = KsGetMultiplePinFactoryItems(m_hFilter, m_PinId, KSPROPERTY_PIN_DATARANGES, (PVOID*)&DataFormatList); + if (FAILED(hr) || DataFormatList->Count == 0) + { + // failed + CoTaskMemFree(MediumList); + CoTaskMemFree(InterfaceList); + if (DataFormatList) + CoTaskMemFree(DataFormatList); + + return hr; + } + + if (MediumList->Count) + { + //use first available medium + Medium = (PKSPIN_MEDIUM)(MediumList + 1); + } + else + { + // default to standard medium + Medium = &StandardPinMedium; + } + + if (InterfaceList->Count) + { + //use first available interface + Interface = (PKSPIN_INTERFACE)(InterfaceList + 1); + } + else + { + // default to standard interface + Interface = &StandardPinInterface; + } + + //FIXME determine format + // use first available format + DataFormat = (PKSDATAFORMAT) (DataFormatList + 1); + + // now create pin + hr = CreatePinHandle(Medium, Interface, DataFormat); + + // free medium / interface / dataformat + CoTaskMemFree(DataFormatList); + CoTaskMemFree(MediumList); + CoTaskMemFree(InterfaceList); + + return hr; +} + +HRESULT +STDMETHODCALLTYPE +CInputPin::CreatePinHandle( + PKSPIN_MEDIUM Medium, + PKSPIN_INTERFACE Interface, + PKSDATAFORMAT DataFormat) +{ + PKSPIN_CONNECT PinConnect; + ULONG Length; + HRESULT hr; + + // calc format size + Length = sizeof(KSPIN_CONNECT) + DataFormat->FormatSize; + + // allocate pin connect + PinConnect = (PKSPIN_CONNECT)CoTaskMemAlloc(Length); + if (!PinConnect) + { + // failed + return E_OUTOFMEMORY; + } + + // setup request + CopyMemory(&PinConnect->Interface, Interface, sizeof(KSPIN_INTERFACE)); + CopyMemory(&PinConnect->Medium, Medium, sizeof(KSPIN_MEDIUM)); + PinConnect->PinId = m_PinId; + PinConnect->PinToHandle = NULL; + PinConnect->Priority.PriorityClass = KSPRIORITY_NORMAL; + PinConnect->Priority.PrioritySubClass = KSPRIORITY_NORMAL; + CopyMemory((PinConnect + 1), DataFormat, DataFormat->FormatSize); + + // create pin + hr = KsCreatePin(m_hFilter, PinConnect, GENERIC_WRITE, &m_hPin); + + // free pin connect + CoTaskMemFree(PinConnect); + + return hr; +} + +HRESULT +WINAPI +CInputPin_Constructor( + IBaseFilter * ParentFilter, + LPCWSTR PinName, + HANDLE hFilter, + ULONG PinId, + KSPIN_COMMUNICATION Communication, + REFIID riid, + LPVOID * ppv) +{ + CInputPin * handler = new CInputPin(ParentFilter, PinName, hFilter, PinId, Communication); + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return S_OK; +} diff --git a/dll/directx/ksproxy/interface.cpp b/dll/directx/ksproxy/interface.cpp index cd8dc806d84..4289cd1fc11 100644 --- a/dll/directx/ksproxy/interface.cpp +++ b/dll/directx/ksproxy/interface.cpp @@ -8,7 +8,6 @@ */ #include "precomp.h" -const GUID IID_IKsInterfaceHandler = {0xD3ABC7E0, 0x9A61, 0x11D0, {0xA4, 0x0D, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}; const GUID IID_IKsObject = {0x423c13a2, 0x2070, 0x11d0, {0x9e, 0xf7, 0x00, 0xaa, 0x00, 0xa2, 0x16, 0xa1}}; class CKsInterfaceHandler : public IKsInterfaceHandler @@ -119,6 +118,8 @@ CKsInterfaceHandler_Constructor( REFIID riid, LPVOID * ppv) { + OutputDebugStringW(L"CKsInterfaceHandler_Constructor\n"); + CKsInterfaceHandler * handler = new CKsInterfaceHandler(); if (!handler) diff --git a/dll/directx/ksproxy/ksproxy.rbuild b/dll/directx/ksproxy/ksproxy.rbuild index f7a0bbd3e6b..440e279e86a 100644 --- a/dll/directx/ksproxy/ksproxy.rbuild +++ b/dll/directx/ksproxy/ksproxy.rbuild @@ -10,7 +10,8 @@ ole32 setupapi msvcrt - + strmiids + ksuser -fno-exceptions -fno-rtti @@ -26,9 +27,13 @@ cvpconfig.cpp cvpvbiconfig.cpp datatype.cpp + enum_mediatypes.cpp + enumpins.cpp + input_pin.cpp interface.cpp ksproxy.cpp ksproxy.rc + output_pin.cpp proxy.cpp qualityforward.cpp diff --git a/dll/directx/ksproxy/output_pin.cpp b/dll/directx/ksproxy/output_pin.cpp new file mode 100644 index 00000000000..b29d12ac4b2 --- /dev/null +++ b/dll/directx/ksproxy/output_pin.cpp @@ -0,0 +1,267 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS WDM Streaming ActiveMovie Proxy + * FILE: dll/directx/ksproxy/input_cpp.cpp + * PURPOSE: InputPin of Proxy Filter + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class COutputPin : public IPin, + public IKsObject +/* + public IQualityControl, + public IKsPinEx, + public IKsPinPipe, + public ISpecifyPropertyPages, + public IStreamBuilder, + public IKsPropertySet, + public IKsPinFactory, + public IKsControl, + public IKsAggregateControl + public IMediaSeeking, + public IAMStreamConfig, + public IMemAllocatorNotifyCallbackTemp +*/ +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + //IPin methods + HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE Disconnect(); + HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin); + HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); + HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); + HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); + HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); + HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); + HRESULT STDMETHODCALLTYPE EndOfStream(); + HRESULT STDMETHODCALLTYPE BeginFlush(); + HRESULT STDMETHODCALLTYPE EndFlush(); + HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); + + //IKsObject methods + HANDLE STDMETHODCALLTYPE KsGetObjectHandle(); + + + COutputPin(IBaseFilter * ParentFilter, LPCWSTR PinName) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName){}; + virtual ~COutputPin(){}; + +protected: + LONG m_Ref; + IBaseFilter * m_ParentFilter; + LPCWSTR m_PinName; +}; + +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + *Output = NULL; + if (IsEqualGUID(refiid, IID_IUnknown) || + IsEqualGUID(refiid, IID_IPin)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IKsObject)) + { + *Output = (IKsObject*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"COutputPin::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IKsObject +// +HANDLE +STDMETHODCALLTYPE +COutputPin::KsGetObjectHandle() +{ + OutputDebugStringW(L"COutputPin::KsGetObjectHandle CALLED\n"); + + //FIXME + // return pin handle + return NULL; +} + +//------------------------------------------------------------------- +// IPin interface +// +HRESULT +STDMETHODCALLTYPE +COutputPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"COutputPin::Connect called\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +COutputPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"COutputPin::ReceiveConnection called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::Disconnect( void) +{ + OutputDebugStringW(L"COutputPin::Disconnect called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::ConnectedTo(IPin **pPin) +{ + *pPin = NULL; + OutputDebugStringW(L"COutputPin::ConnectedTo called\n"); + return VFW_E_NOT_CONNECTED; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"COutputPin::ConnectionMediaType called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryPinInfo(PIN_INFO *pInfo) +{ + wcscpy(pInfo->achName, m_PinName); + pInfo->dir = PINDIR_OUTPUT; + pInfo->pFilter = m_ParentFilter; + m_ParentFilter->AddRef(); + + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryDirection(PIN_DIRECTION *pPinDir) +{ + if (pPinDir) + { + *pPinDir = PINDIR_OUTPUT; + return S_OK; + } + + return E_POINTER; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryId(LPWSTR *Id) +{ + *Id = (LPWSTR)CoTaskMemAlloc((wcslen(m_PinName)+1)*sizeof(WCHAR)); + if (!*Id) + return E_OUTOFMEMORY; + + wcscpy(*Id, m_PinName); + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryAccept(const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"COutputPin::QueryAccept called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) +{ + OutputDebugStringW(L"COutputPin::EnumMediaTypes called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) +{ + OutputDebugStringW(L"COutputPin::QueryInternalConnections called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::EndOfStream( void) +{ + OutputDebugStringW(L"COutputPin::EndOfStream called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::BeginFlush( void) +{ + OutputDebugStringW(L"COutputPin::BeginFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::EndFlush( void) +{ + OutputDebugStringW(L"COutputPin::EndFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +COutputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) +{ + OutputDebugStringW(L"COutputPin::NewSegment called\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +COutputPin_Constructor( + IBaseFilter * ParentFilter, + LPCWSTR PinName, + REFIID riid, + LPVOID * ppv) +{ + COutputPin * handler = new COutputPin(ParentFilter, PinName); + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return S_OK; +} diff --git a/dll/directx/ksproxy/precomp.h b/dll/directx/ksproxy/precomp.h index cf72d8c8195..32953e94cb5 100644 --- a/dll/directx/ksproxy/precomp.h +++ b/dll/directx/ksproxy/precomp.h @@ -1,5 +1,6 @@ #pragma once +#define _FORCENAMELESSUNION #define BUILDING_KS #define _KSDDK_ #include @@ -14,8 +15,9 @@ #include #include #include - #include +#include +#include //#include typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); @@ -96,3 +98,43 @@ CKsProxy_Constructor( IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); + +/* input_pin.cpp */ +HRESULT +WINAPI +CInputPin_Constructor( + IBaseFilter * ParentFilter, + LPCWSTR PinName, + HANDLE hFilter, + ULONG PinId, + KSPIN_COMMUNICATION Communication, + REFIID riid, + LPVOID * ppv); + +/* output_pin.cpp */ +HRESULT +WINAPI +COutputPin_Constructor( + IBaseFilter * ParentFilter, + LPCWSTR PinName, + REFIID riid, + LPVOID * ppv); + +/* enumpins.cpp */ +HRESULT +WINAPI +CEnumPins_fnConstructor( + std::vector Pins, + REFIID riid, + LPVOID * ppv); + +/* enum_mediatypes.cpp */ +HRESULT +WINAPI +CEnumMediaTypes_fnConstructor( + ULONG MediaTypeCount, + AM_MEDIA_TYPE * MediaTypes, + REFIID riid, + LPVOID * ppv); + + diff --git a/dll/directx/ksproxy/proxy.cpp b/dll/directx/ksproxy/proxy.cpp index a6d82458cc7..0ff397c2062 100644 --- a/dll/directx/ksproxy/proxy.cpp +++ b/dll/directx/ksproxy/proxy.cpp @@ -8,15 +8,20 @@ */ #include "precomp.h" +const GUID IID_IPersistPropertyBag = {0x37D84F60, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}}; +const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; +const GUID IID_IBDA_DeviceControl = {0xFD0A5AF3, 0xB41D, 0x11d2, {0x9C, 0x95, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}}; /* Needs IKsClock, IKsNotifyEvent */ class CKsProxy : public IBaseFilter, public IAMovieSetup, + public IPersistPropertyBag, + public IKsObject +/* public IPersistStream, public ISpecifyPropertyPages, - public IPersistPropertyBag, public IReferenceClock, public IMediaSeeking, public IKsObject, @@ -27,12 +32,769 @@ class CKsProxy : public IBaseFilter, public IKsTopology, public IKsAggregateControl, public IAMDeviceRemoval +*/ { +public: + typedef std::vectorProxyPluginVector; + typedef std::vector PinVector; + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + // IBaseFilter methods + HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); + HRESULT STDMETHODCALLTYPE Stop( void); + HRESULT STDMETHODCALLTYPE Pause( void); + HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart); + HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State); + HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock); + HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **pClock); + HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum); + HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin); + HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo); + HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); + HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo); + + //IAMovieSetup methods + HRESULT STDMETHODCALLTYPE Register( void); + HRESULT STDMETHODCALLTYPE Unregister( void); + + // IPersistPropertyBag methods + HRESULT STDMETHODCALLTYPE InitNew( void); + HRESULT STDMETHODCALLTYPE Load(IPropertyBag *pPropBag, IErrorLog *pErrorLog); + HRESULT STDMETHODCALLTYPE Save(IPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties); + + // IKsObject + HANDLE STDMETHODCALLTYPE KsGetObjectHandle(); + + CKsProxy() : m_Ref(0), m_pGraph(0), m_ReferenceClock(0), m_FilterState(State_Stopped), m_hDevice(0), m_Plugins(), m_Pins() {}; + virtual ~CKsProxy() + { + if (m_hDevice) + CloseHandle(m_hDevice); + }; + + HRESULT STDMETHODCALLTYPE GetSupportedSets(LPGUID * pOutGuid, PULONG NumGuids); + HRESULT STDMETHODCALLTYPE LoadProxyPlugins(LPGUID pGuids, ULONG NumGuids); + HRESULT STDMETHODCALLTYPE GetNumberOfPins(PULONG NumPins); + HRESULT STDMETHODCALLTYPE GetPinInstanceCount(ULONG PinId, PKSPIN_CINSTANCES Instances); + HRESULT STDMETHODCALLTYPE GetPinDataflow(ULONG PinId, KSPIN_DATAFLOW * DataFlow); + HRESULT STDMETHODCALLTYPE GetPinName(ULONG PinId, KSPIN_DATAFLOW DataFlow, ULONG PinCount, LPWSTR * OutPinName); + HRESULT STDMETHODCALLTYPE GetPinCommunication(ULONG PinId, KSPIN_COMMUNICATION * Communication); + HRESULT STDMETHODCALLTYPE CreatePins(); +protected: + LONG m_Ref; + IFilterGraph *m_pGraph; + IReferenceClock * m_ReferenceClock; + FILTER_STATE m_FilterState; + HANDLE m_hDevice; + ProxyPluginVector m_Plugins; + PinVector m_Pins; }; +HRESULT +STDMETHODCALLTYPE +CKsProxy::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + *Output = NULL; + if (IsEqualGUID(refiid, IID_IUnknown) || + IsEqualGUID(refiid, IID_IBaseFilter)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + else if (IsEqualGUID(refiid, IID_IPersistPropertyBag)) + { + *Output = (IPersistPropertyBag*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IKsObject)) + { + *Output = (IKsObject*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + for(ULONG Index = 0; Index < m_Plugins.size(); Index++) + { + if (m_Pins[Index]) + { + HRESULT hr = m_Plugins[Index]->QueryInterface(refiid, Output); + if (SUCCEEDED(hr)) + { + WCHAR Buffer[100]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CKsProxy::QueryInterface plugin %lu supports interface %s\n", Index, lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + return hr; + } + } + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CKsProxy::QueryInterface: NoInterface for %s !!!\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IKsObject interface +// + +HANDLE +STDMETHODCALLTYPE +CKsProxy::KsGetObjectHandle() +{ + return m_hDevice; +} + +//------------------------------------------------------------------- +// IPersistPropertyBag interface +// +HRESULT +STDMETHODCALLTYPE +CKsProxy::InitNew( void) +{ + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetSupportedSets( + LPGUID * pOutGuid, + PULONG NumGuids) +{ + KSPROPERTY Property; + LPGUID pGuid; + ULONG NumProperty = 0; + ULONG NumMethods = 0; + ULONG NumEvents = 0; + ULONG Length; + ULONG BytesReturned; + HRESULT hr; + + Property.Set = GUID_NULL; + Property.Id = 0; + Property.Flags = KSPROPERTY_TYPE_SETSUPPORT; + + KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &NumProperty); + KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_METHOD, (PVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &NumMethods); + KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_ENABLE_EVENT, (PVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &NumEvents); + + Length = NumProperty + NumMethods + NumEvents; + + // allocate guid buffer + pGuid = (LPGUID)CoTaskMemAlloc(Length); + if (!pGuid) + { + // failed + return E_OUTOFMEMORY; + } + + NumProperty /= sizeof(GUID); + NumMethods /= sizeof(GUID); + NumEvents /= sizeof(GUID); + + // get all properties + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)pGuid, Length, &BytesReturned); + if (FAILED(hr)) + { + CoTaskMemFree(pGuid); + return E_FAIL; + } + Length -= BytesReturned; + + // get all methods + if (Length) + { + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_METHOD, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty], Length, &BytesReturned); + if (FAILED(hr)) + { + CoTaskMemFree(pGuid); + return E_FAIL; + } + Length -= BytesReturned; + } + + // get all events + if (Length) + { + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_ENABLE_EVENT, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty+NumMethods], Length, &BytesReturned); + if (FAILED(hr)) + { + CoTaskMemFree(pGuid); + return E_FAIL; + } + Length -= BytesReturned; + } + +#ifdef KSPROXY_TRACE + WCHAR Buffer[200]; + swprintf(Buffer, L"NumProperty %lu NumMethods %lu NumEvents %lu\n", NumProperty, NumMethods, NumEvents); + OutputDebugStringW(Buffer); +#endif + + *pOutGuid = pGuid; + *NumGuids = NumProperty+NumEvents+NumMethods; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::LoadProxyPlugins( + LPGUID pGuids, + ULONG NumGuids) +{ + ULONG Index; + LPOLESTR pStr; + HKEY hKey, hSubKey; + HRESULT hr; + IUnknown * pUnknown; + + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\MediaInterfaces", 0, KEY_READ, &hKey) != ERROR_SUCCESS) + { + OutputDebugStringW(L"CKsProxy::LoadProxyPlugins failed to open MediaInterfaces key\n"); + return E_FAIL; + } + + // enumerate all sets + for(Index = 0; Index < NumGuids; Index++) + { + // convert to string + hr = StringFromCLSID(pGuids[Index], &pStr); + if (FAILED(hr)) + return E_FAIL; + + // now try open class key + if (RegOpenKeyExW(hKey, pStr, 0, KEY_READ, &hSubKey) != ERROR_SUCCESS) + { + // no plugin for that set exists + CoTaskMemFree(pStr); + continue; + } + + // try load plugin + hr = CoCreateInstance(pGuids[Index], (IBaseFilter*)this, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&pUnknown); + if (SUCCEEDED(hr)) + { + // store plugin + m_Plugins.push_back(pUnknown); + } + // close key + RegCloseKey(hSubKey); + } + + // close media interfaces key + RegCloseKey(hKey); + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetNumberOfPins( + PULONG NumPins) +{ + KSPROPERTY Property; + ULONG BytesReturned; + + // setup request + Property.Set = KSPROPSETID_Pin; + Property.Id = KSPROPERTY_PIN_CTYPES; + Property.Flags = KSPROPERTY_TYPE_GET; + + return KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)NumPins, sizeof(ULONG), &BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetPinInstanceCount( + ULONG PinId, + PKSPIN_CINSTANCES Instances) +{ + KSP_PIN Property; + ULONG BytesReturned; + + // setup request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_CINSTANCES; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = PinId; + Property.Reserved = 0; + + return KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)Instances, sizeof(KSPIN_CINSTANCES), &BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetPinCommunication( + ULONG PinId, + KSPIN_COMMUNICATION * Communication) +{ + KSP_PIN Property; + ULONG BytesReturned; + + // setup request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_COMMUNICATION; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = PinId; + Property.Reserved = 0; + + return KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)Communication, sizeof(KSPIN_COMMUNICATION), &BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetPinDataflow( + ULONG PinId, + KSPIN_DATAFLOW * DataFlow) +{ + KSP_PIN Property; + ULONG BytesReturned; + + // setup request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_DATAFLOW; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = PinId; + Property.Reserved = 0; + + return KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)DataFlow, sizeof(KSPIN_DATAFLOW), &BytesReturned); +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetPinName( + ULONG PinId, + KSPIN_DATAFLOW DataFlow, + ULONG PinCount, + LPWSTR * OutPinName) +{ + KSP_PIN Property; + LPWSTR PinName; + ULONG BytesReturned; + HRESULT hr; + WCHAR Buffer[100]; + + // setup request + Property.Property.Set = KSPROPSETID_Pin; + Property.Property.Id = KSPROPERTY_PIN_NAME; + Property.Property.Flags = KSPROPERTY_TYPE_GET; + Property.PinId = PinId; + Property.Reserved = 0; + + // #1 try get it from pin directly + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), NULL, 0, &BytesReturned); + + if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_MORE_DATA)) + { + // allocate pin name + PinName = (LPWSTR)CoTaskMemAlloc(BytesReturned); + if (!PinName) + return E_OUTOFMEMORY; + + // retry with allocated buffer + hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), PinName, BytesReturned, &BytesReturned); + if (SUCCEEDED(hr)) + { + *OutPinName = PinName; + return hr; + } + + //free buffer + CoTaskMemFree(PinName); + } + + // + // TODO: retrieve pin name from topology node + // + + if (DataFlow == KSPIN_DATAFLOW_IN) + { + swprintf(Buffer, L"Input%lu", PinCount); + } + else + { + swprintf(Buffer, L"Output%lu", PinCount); + } + + // allocate pin name + PinName = (LPWSTR)CoTaskMemAlloc((wcslen(Buffer)+1) * sizeof(WCHAR)); + if (!PinName) + return E_OUTOFMEMORY; + + // copy pin name + wcscpy(PinName, Buffer); + + // store result + *OutPinName = PinName; + // done + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::CreatePins() +{ + ULONG NumPins, Index; + KSPIN_CINSTANCES Instances; + KSPIN_DATAFLOW DataFlow; + KSPIN_COMMUNICATION Communication; + HRESULT hr; + WCHAR Buffer[100]; + LPWSTR PinName; + IPin * pPin; + ULONG InputPin = 0; + ULONG OutputPin = 0; + + // get number of pins + hr = GetNumberOfPins(&NumPins); + if (FAILED(hr)) + return hr; + + for(Index = 0; Index < NumPins; Index++) + { + // query current instance count + hr = GetPinInstanceCount(Index, &Instances); + if (FAILED(hr)) + continue; + + // query pin communication; + hr = GetPinCommunication(Index, &Communication); + if (FAILED(hr)) + continue; + + if (Instances.CurrentCount == Instances.PossibleCount) + { + // already maximum reached for this pin + continue; + } + + // get direction of pin + hr = GetPinDataflow(Index, &DataFlow); + if (FAILED(hr)) + continue; + + if (DataFlow == KSPIN_DATAFLOW_IN) + hr = GetPinName(Index, DataFlow, InputPin, &PinName); + else + hr = GetPinName(Index, DataFlow, OutputPin, &PinName); + + if (FAILED(hr)) + continue; + + // construct the pins + if (DataFlow == KSPIN_DATAFLOW_IN) + { + hr = CInputPin_Constructor((IBaseFilter*)this, PinName, m_hDevice, Index, Communication, IID_IPin, (void**)&pPin); + if (FAILED(hr)) + { + CoTaskMemFree(PinName); + continue; + } + InputPin++; + } + else + { + hr = COutputPin_Constructor((IBaseFilter*)this, PinName, IID_IPin, (void**)&pPin); + if (FAILED(hr)) + { + CoTaskMemFree(PinName); + continue; + } + OutputPin++; + } + + // store pins + m_Pins.push_back(pPin); + + swprintf(Buffer, L"Index %lu DataFlow %lu Name %s\n", Index, DataFlow, PinName); + OutputDebugStringW(Buffer); + } + + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Load(IPropertyBag *pPropBag, IErrorLog *pErrorLog) +{ + HRESULT hr; + WCHAR Buffer[100]; + VARIANT varName; + LPGUID pGuid; + ULONG NumGuids = 0; + + // read device path + varName.vt = VT_BSTR; + hr = pPropBag->Read(L"DevicePath", &varName, pErrorLog); + + if (FAILED(hr)) + { + swprintf(Buffer, L"CKsProxy::Load Read %lx\n", hr); + OutputDebugStringW(Buffer); + return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError()); + } + + // open device + m_hDevice = CreateFileW(varName.bstrVal, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); + + if (m_hDevice == INVALID_HANDLE_VALUE) + { + // failed to open device + swprintf(Buffer, L"CKsProxy:: failed to open device with %lx\n", GetLastError()); + OutputDebugStringW(Buffer); + + return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError()); + } + + // get all supported sets + hr = GetSupportedSets(&pGuid, &NumGuids); + if (FAILED(hr)) + { + CloseHandle(m_hDevice); + m_hDevice = NULL; + return hr; + } + + // load all proxy plugins + hr = LoadProxyPlugins(pGuid, NumGuids); + if (FAILED(hr)) + { + CloseHandle(m_hDevice); + m_hDevice = NULL; + return hr; + } + + // free sets + CoTaskMemFree(pGuid); + + // now create the input / output pins + hr = CreatePins(); + + return hr; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Save(IPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) +{ + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IBaseFilter interface +// + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetClassID( + CLSID *pClassID) +{ + OutputDebugStringW(L"CKsProxy::GetClassID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Stop() +{ + OutputDebugStringW(L"CKsProxy::Stop : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Pause() +{ + OutputDebugStringW(L"CKsProxy::Pause : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Run( + REFERENCE_TIME tStart) +{ + OutputDebugStringW(L"CKsProxy::Run : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetState( + DWORD dwMilliSecsTimeout, + FILTER_STATE *State) +{ + *State = m_FilterState; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::SetSyncSource( + IReferenceClock *pClock) +{ + if (pClock) + { + pClock->AddRef(); + } + + if (m_ReferenceClock) + { + m_ReferenceClock->Release(); + } + + m_ReferenceClock = pClock; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::GetSyncSource( + IReferenceClock **pClock) +{ + if (!pClock) + return E_POINTER; + + if (m_ReferenceClock) + m_ReferenceClock->AddRef(); + + *pClock = m_ReferenceClock; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::EnumPins( + IEnumPins **ppEnum) +{ + return CEnumPins_fnConstructor(m_Pins, IID_IEnumPins, (void**)ppEnum); +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::FindPin( + LPCWSTR Id, IPin **ppPin) +{ + ULONG PinId; + + if (!ppPin) + return E_POINTER; + + // convert to pin + int ret = swscanf(Id, L"%u", &PinId); + + if (!ret || ret == EOF) + { + // invalid id + return VFW_E_NOT_FOUND; + } + + if (PinId >= m_Pins.size() || m_Pins[PinId] == NULL) + { + // invalid id + return VFW_E_NOT_FOUND; + } + + // found pin + *ppPin = m_Pins[PinId]; + m_Pins[PinId]->AddRef(); + + return S_OK; +} + + +HRESULT +STDMETHODCALLTYPE +CKsProxy::QueryFilterInfo( + FILTER_INFO *pInfo) +{ + if (!pInfo) + return E_POINTER; + + pInfo->achName[0] = L'\0'; + pInfo->pGraph = m_pGraph; + + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::JoinFilterGraph( + IFilterGraph *pGraph, + LPCWSTR pName) +{ + if (pGraph) + { + // joining filter graph + m_pGraph = pGraph; + } + else + { + // leaving graph + m_pGraph = 0; + } + + return S_OK; +} + + +HRESULT +STDMETHODCALLTYPE +CKsProxy::QueryVendorInfo( + LPWSTR *pVendorInfo) +{ + OutputDebugStringW(L"CKsProxy::QueryVendorInfo : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IAMovieSetup interface +// + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Register() +{ + OutputDebugStringW(L"CKsProxy::Register : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CKsProxy::Unregister() +{ + OutputDebugStringW(L"CKsProxy::Unregister : NotImplemented\n"); + return E_NOTIMPL; +} HRESULT WINAPI @@ -41,6 +803,23 @@ CKsProxy_Constructor( REFIID riid, LPVOID * ppv) { - OutputDebugString("CKsProxy_Constructor UNIMPLEMENTED\n"); - return E_NOTIMPL; + WCHAR Buffer[100]; + LPOLESTR pstr; + StringFromCLSID(riid, &pstr); + swprintf(Buffer, L"CKsProxy_Constructor pUnkOuter %p riid %s\n", pUnkOuter, pstr); + OutputDebugStringW(Buffer); + + CKsProxy * handler = new CKsProxy(); + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return S_OK; } diff --git a/dll/directx/ksproxy/qualityforward.cpp b/dll/directx/ksproxy/qualityforward.cpp index 45f8f3489e3..3081d834cbf 100644 --- a/dll/directx/ksproxy/qualityforward.cpp +++ b/dll/directx/ksproxy/qualityforward.cpp @@ -87,8 +87,6 @@ CKsQualityForwarder::KsFlushClient( OutputDebugString("UNIMPLEMENTED\n"); } - - HRESULT WINAPI CKsQualityForwarder_Constructor( @@ -99,6 +97,8 @@ CKsQualityForwarder_Constructor( HRESULT hr; HANDLE handle; + OutputDebugStringW(L"CKsQualityForwarder_Constructor\n"); + // open default clock hr = KsOpenDefaultDevice(KSCATEGORY_QUALITY, GENERIC_READ | GENERIC_WRITE, &handle); diff --git a/dll/directx/msdvbnp/classfactory.cpp b/dll/directx/msdvbnp/classfactory.cpp new file mode 100644 index 00000000000..89b61c486fe --- /dev/null +++ b/dll/directx/msdvbnp/classfactory.cpp @@ -0,0 +1,105 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msdvbnp/classfactory.cpp + * PURPOSE: IClassFactory interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; +const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; + +class CClassFactory : public IClassFactory +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject); + HRESULT WINAPI LockServer(BOOL fLock); + + CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst) : m_Ref(1), m_lpfnCI(lpfnCI), m_IID(riidInst) + {}; + + virtual ~CClassFactory(){}; + +protected: + LONG m_Ref; + LPFNCREATEINSTANCE m_lpfnCI; + IID * m_IID; +}; + +HRESULT +WINAPI +CClassFactory::QueryInterface( + REFIID riid, + LPVOID *ppvObj) +{ + *ppvObj = NULL; + if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) + { + *ppvObj = PVOID(this); + InterlockedIncrement(&m_Ref); + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT +WINAPI +CClassFactory::CreateInstance( + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID *ppvObject) +{ + *ppvObject = NULL; + + if ( m_IID == NULL || IsEqualCLSID(riid, *m_IID) || IsEqualCLSID(riid, IID_IUnknown)) + { + return m_lpfnCI(pUnkOuter, riid, ppvObject); + } + + return E_NOINTERFACE; +} + +HRESULT +WINAPI +CClassFactory::LockServer( + BOOL fLock) +{ + return E_NOTIMPL; +} + +IClassFactory * +CClassFactory_fnConstructor( + LPFNCREATEINSTANCE lpfnCI, + PLONG pcRefDll, + IID * riidInst) +{ + CClassFactory* factory = new CClassFactory(lpfnCI, pcRefDll, riidInst); + + if (!factory) + return NULL; + + if (pcRefDll) + InterlockedIncrement(pcRefDll); + + return (LPCLASSFACTORY)factory; +} diff --git a/dll/directx/msdvbnp/enum_mediatypes.cpp b/dll/directx/msdvbnp/enum_mediatypes.cpp new file mode 100644 index 00000000000..6cd887f358c --- /dev/null +++ b/dll/directx/msdvbnp/enum_mediatypes.cpp @@ -0,0 +1,189 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/enum_mediatypes.cpp + * PURPOSE: IEnumMediaTypes interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumMediaTypes : public IEnumMediaTypes +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + HRESULT STDMETHODCALLTYPE Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG cMediaTypes); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes **ppEnum); + + + CEnumMediaTypes(ULONG MediaTypeCount, AM_MEDIA_TYPE * MediaTypes) : m_Ref(0), m_MediaTypeCount(MediaTypeCount), m_MediaTypes(MediaTypes), m_Index(0){}; + virtual ~CEnumMediaTypes(){}; + +protected: + LONG m_Ref; + ULONG m_MediaTypeCount; + AM_MEDIA_TYPE * m_MediaTypes; + ULONG m_Index; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IEnumMediaTypes)) + { + *Output = (IEnumMediaTypes*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CEnumMediaTypes::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IEnumMediaTypes +// + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Next( + ULONG cMediaTypes, + AM_MEDIA_TYPE **ppMediaTypes, + ULONG *pcFetched) +{ + ULONG i = 0; + AM_MEDIA_TYPE * MediaType; + + if (!ppMediaTypes) + return E_POINTER; + + if (cMediaTypes > 1 && !pcFetched) + return E_INVALIDARG; + + while(i < cMediaTypes) + { + if (m_Index + i >= m_MediaTypeCount) + break; + + MediaType = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + if (!MediaType) + break; + + CopyMemory(MediaType, &m_MediaTypes[m_Index + i], sizeof(AM_MEDIA_TYPE)); + ppMediaTypes[i] = MediaType; + i++; + } + + if (pcFetched) + { + *pcFetched = i; + } + + m_Index += i; + + if (i < cMediaTypes) + return S_FALSE; + else + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Skip( + ULONG cMediaTypes) +{ + if (cMediaTypes + m_Index >= m_MediaTypeCount) + { + return S_FALSE; + } + + m_Index += cMediaTypes; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Reset() +{ + m_Index = 0; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumMediaTypes::Clone( + IEnumMediaTypes **ppEnum) +{ + OutputDebugStringW(L"CEnumMediaTypes::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumMediaTypes_fnConstructor( + IUnknown *pUnknown, + ULONG MediaTypeCount, + AM_MEDIA_TYPE * MediaTypes, + REFIID riid, + LPVOID * ppv) +{ + CEnumMediaTypes * handler = new CEnumMediaTypes(MediaTypeCount, MediaTypes); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CEnumMediaTypes_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + { + CoTaskMemFree(MediaTypes); + return E_OUTOFMEMORY; + } + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} + diff --git a/dll/directx/msdvbnp/enumpins.cpp b/dll/directx/msdvbnp/enumpins.cpp new file mode 100644 index 00000000000..567705907b7 --- /dev/null +++ b/dll/directx/msdvbnp/enumpins.cpp @@ -0,0 +1,177 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/enumpins.cpp + * PURPOSE: IEnumPins interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumPins : public IEnumPins +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + + HRESULT STDMETHODCALLTYPE Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG cPins); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumPins **ppEnum); + + CEnumPins(ULONG NumPins, IPin ** pins) : m_Ref(0), m_NumPins(NumPins), m_Pins(pins), m_Index(0){}; + virtual ~CEnumPins(){}; + +protected: + LONG m_Ref; + ULONG m_NumPins; + IPin ** m_Pins; + ULONG m_Index; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumPins::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IEnumPins)) + { + *Output = (IEnumPins*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CEnumPins::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Next( + ULONG cPins, + IPin **ppPins, + ULONG *pcFetched) +{ + ULONG i = 0; + + if (!ppPins) + return E_POINTER; + + if (cPins > 1 && !pcFetched) + return E_INVALIDARG; + + while(i < cPins) + { + if (m_Index + i >= m_NumPins) + break; + + ppPins[i] = m_Pins[m_Index + i]; + m_Pins[m_Index + i]->AddRef(); + + i++; + } + + if (pcFetched) + { + *pcFetched = i; + } + + m_Index += i; + + if (i < cPins) + return S_FALSE; + else + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Skip( + ULONG cPins) +{ + if (cPins + m_Index >= m_NumPins) + { + return S_FALSE; + } + + m_Index += cPins; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Reset() +{ + m_Index = 0; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CEnumPins::Clone( + IEnumPins **ppEnum) +{ + OutputDebugStringW(L"CEnumPins::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumPins_fnConstructor( + IUnknown *pUnknown, + ULONG NumPins, + IPin ** pins, + REFIID riid, + LPVOID * ppv) +{ + CEnumPins * handler = new CEnumPins(NumPins, pins); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CEnumPins_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file diff --git a/dll/directx/msdvbnp/msdvbnp.cpp b/dll/directx/msdvbnp/msdvbnp.cpp new file mode 100644 index 00000000000..037a67ef717 --- /dev/null +++ b/dll/directx/msdvbnp/msdvbnp.cpp @@ -0,0 +1,108 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/msdvbnp.cpp + * PURPOSE: COM Initialization + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ + +#include "precomp.h" + +const GUID CLSID_DVBTNetworkProvider = {0x216c62df, 0x6d7f, 0x4e9a, {0x85, 0x71, 0x5, 0xf1, 0x4e, 0xdb, 0x76, 0x6a}}; + +static INTERFACE_TABLE InterfaceTable[] = +{ + {&CLSID_DVBTNetworkProvider, CNetworkProvider_fnConstructor}, + {NULL, NULL} +}; + +extern "C" +BOOL +WINAPI +DllMain( + HINSTANCE hInstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + CoInitialize(NULL); + +#ifdef MSDVBNP_TRACE + OutputDebugStringW(L"MSDVBNP::DllMain()\n"); +#endif + + DisableThreadLibraryCalls(hInstDLL); + break; + default: + break; + } + + return TRUE; +} + + +extern "C" +KSDDKAPI +HRESULT +WINAPI +DllUnregisterServer(void) +{ + return S_OK; +} + +extern "C" +KSDDKAPI +HRESULT +WINAPI +DllRegisterServer(void) +{ + return S_OK; +} + +KSDDKAPI +HRESULT +WINAPI +DllGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID *ppv) +{ + UINT i; + HRESULT hres = E_OUTOFMEMORY; + IClassFactory * pcf = NULL; + + if (!ppv) + return E_INVALIDARG; + + *ppv = NULL; + + for (i = 0; InterfaceTable[i].riid; i++) + { + if (IsEqualIID(*InterfaceTable[i].riid, rclsid)) + { + pcf = CClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL); + break; + } + } + + if (!pcf) + { + return CLASS_E_CLASSNOTAVAILABLE; + } + + hres = pcf->QueryInterface(riid, ppv); + pcf->Release(); + + return hres; +} + +KSDDKAPI +HRESULT +WINAPI +DllCanUnloadNow(void) +{ + return S_OK; +} diff --git a/dll/directx/msdvbnp/msdvbnp.rbuild b/dll/directx/msdvbnp/msdvbnp.rbuild new file mode 100644 index 00000000000..6213d7d8f37 --- /dev/null +++ b/dll/directx/msdvbnp/msdvbnp.rbuild @@ -0,0 +1,31 @@ + + + + + + . + ntdll + kernel32 + advapi32 + ole32 + advapi32 + msvcrt + strmiids + + -fno-exceptions + -fno-rtti + + + /GR- + + + classfactory.cpp + enum_mediatypes.cpp + enumpins.cpp + msdvbnp.cpp + msdvbnp.rc + networkprovider.cpp + pin.cpp + scanningtuner.cpp + + diff --git a/dll/directx/msdvbnp/msdvbnp.rc b/dll/directx/msdvbnp/msdvbnp.rc new file mode 100644 index 00000000000..7df396e8fdf --- /dev/null +++ b/dll/directx/msdvbnp/msdvbnp.rc @@ -0,0 +1,12 @@ +#include + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Network Provider for MPEG2 based networks\0" +#define REACTOS_STR_INTERNAL_NAME "MSDvBNP.ax\0" +#define REACTOS_STR_ORIGINAL_FILENAME "MSDvBNP.ax\0" +#define REACTOS_STR_PRODUCT_VERSION "6.5.2600.3264\0" +#define REACTOS_STR_FILE_VERSION "6.5.2600.3264\0" + +#include diff --git a/dll/directx/msdvbnp/msdvbnp.spec b/dll/directx/msdvbnp/msdvbnp.spec new file mode 100644 index 00000000000..5baed04ed66 --- /dev/null +++ b/dll/directx/msdvbnp/msdvbnp.spec @@ -0,0 +1,4 @@ +@ stdcall DllCanUnloadNow() +@ stdcall DllGetClassObject(ptr ptr ptr) +@ stdcall DllRegisterServer() +@ stdcall DllUnregisterServer() diff --git a/dll/directx/msdvbnp/networkprovider.cpp b/dll/directx/msdvbnp/networkprovider.cpp new file mode 100644 index 00000000000..c69c2336e48 --- /dev/null +++ b/dll/directx/msdvbnp/networkprovider.cpp @@ -0,0 +1,378 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/networkprovider.cpp + * PURPOSE: IBDA_NetworkProvider interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CNetworkProvider : public IBaseFilter, + public IAMovieSetup, + public IBDA_NetworkProvider +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + // IBaseFilter methods + HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); + HRESULT STDMETHODCALLTYPE Stop( void); + HRESULT STDMETHODCALLTYPE Pause( void); + HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart); + HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State); + HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock); + HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **pClock); + HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum); + HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin); + HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo); + HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); + HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo); + + //IAMovieSetup methods + HRESULT STDMETHODCALLTYPE Register( void); + HRESULT STDMETHODCALLTYPE Unregister( void); + + //IBDA_NetworkProvider methods + HRESULT STDMETHODCALLTYPE PutSignalSource(ULONG ulSignalSource); + HRESULT STDMETHODCALLTYPE GetSignalSource(ULONG *pulSignalSource); + HRESULT STDMETHODCALLTYPE GetNetworkType(GUID *pguidNetworkType); + HRESULT STDMETHODCALLTYPE PutTuningSpace(REFGUID guidTuningSpace); + HRESULT STDMETHODCALLTYPE GetTuningSpace(GUID *pguidTuingSpace); + HRESULT STDMETHODCALLTYPE RegisterDeviceFilter(IUnknown *pUnkFilterControl, ULONG *ppvRegisitrationContext); + HRESULT STDMETHODCALLTYPE UnRegisterDeviceFilter(ULONG pvRegistrationContext); + + CNetworkProvider() : m_Ref(0), m_pGraph(0), m_ReferenceClock(0), m_FilterState(State_Stopped) {m_Pins[0] = 0;}; + virtual ~CNetworkProvider(){}; + +protected: + LONG m_Ref; + IFilterGraph *m_pGraph; + IReferenceClock * m_ReferenceClock; + FILTER_STATE m_FilterState; + IPin * m_Pins[1]; +}; + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + *Output = NULL; + + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IBaseFilter)) + { + *Output = (IBaseFilter*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_ITuner) || + IsEqualGUID(refiid, IID_IScanningTuner)) + { + // construct scanning tuner + return CScanningTunner_fnConstructor(NULL, refiid, Output); + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CNetworkProvider::QueryInterface: NoInterface for %s !!!\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IBaseFilter interface +// + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetClassID( + CLSID *pClassID) +{ + OutputDebugStringW(L"CNetworkProvider::GetClassID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Stop() +{ + OutputDebugStringW(L"CNetworkProvider::Stop : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Pause() +{ + OutputDebugStringW(L"CNetworkProvider::Pause : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Run( + REFERENCE_TIME tStart) +{ + OutputDebugStringW(L"CNetworkProvider::Run : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetState( + DWORD dwMilliSecsTimeout, + FILTER_STATE *State) +{ + *State = m_FilterState; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::SetSyncSource( + IReferenceClock *pClock) +{ + if (pClock) + { + pClock->AddRef(); + + } + + if (m_ReferenceClock) + { + m_ReferenceClock->Release(); + } + + m_ReferenceClock = pClock; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetSyncSource( + IReferenceClock **pClock) +{ + if (!pClock) + return E_POINTER; + + if (m_ReferenceClock) + m_ReferenceClock->AddRef(); + + *pClock = m_ReferenceClock; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::EnumPins( + IEnumPins **ppEnum) +{ + if (m_Pins[0] == 0) + { + HRESULT hr = CPin_fnConstructor(NULL, (IBaseFilter*)this, IID_IUnknown, (void**)&m_Pins[0]); + if (FAILED(hr)) + return hr; + } + + return CEnumPins_fnConstructor(NULL, 1, m_Pins, IID_IEnumPins, (void**)ppEnum); +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::FindPin( + LPCWSTR Id, IPin **ppPin) +{ + OutputDebugStringW(L"CNetworkProvider::FindPin : NotImplemented\n"); + return E_NOTIMPL; +} + + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::QueryFilterInfo( + FILTER_INFO *pInfo) +{ + if (!pInfo) + return E_POINTER; + + pInfo->achName[0] = L'\0'; + pInfo->pGraph = m_pGraph; + + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::JoinFilterGraph( + IFilterGraph *pGraph, + LPCWSTR pName) +{ + if (pGraph) + { + // joining filter graph + m_pGraph = pGraph; + } + else + { + // leaving graph + m_pGraph = 0; + } + + OutputDebugStringW(L"CNetworkProvider::JoinFilterGraph\n"); + return S_OK; +} + + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::QueryVendorInfo( + LPWSTR *pVendorInfo) +{ + OutputDebugStringW(L"CNetworkProvider::QueryVendorInfo : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IAMovieSetup interface +// + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Register() +{ + OutputDebugStringW(L"CNetworkProvider::Register : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::Unregister() +{ + OutputDebugStringW(L"CNetworkProvider::Unregister : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IBDA_NetworkProvider interface +// + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::PutSignalSource( + ULONG ulSignalSource) +{ + OutputDebugStringW(L"CNetworkProvider::PutSignalSource : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetSignalSource( + ULONG *pulSignalSource) +{ + OutputDebugStringW(L"CNetworkProvider::GetSignalSource : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetNetworkType( + GUID *pguidNetworkType) +{ + OutputDebugStringW(L"CNetworkProvider::GetNetworkType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::PutTuningSpace( + REFGUID guidTuningSpace) +{ + OutputDebugStringW(L"CNetworkProvider::PutTuningSpace : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::GetTuningSpace( + GUID *pguidTuingSpace) +{ + OutputDebugStringW(L"CNetworkProvider::GetTuningSpace : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::RegisterDeviceFilter( + IUnknown *pUnkFilterControl, + ULONG *ppvRegisitrationContext) +{ + OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CNetworkProvider::UnRegisterDeviceFilter(ULONG pvRegistrationContext) +{ + OutputDebugStringW(L"CNetworkProvider::UnRegisterDeviceFilter : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CNetworkProvider_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + CNetworkProvider * handler = new CNetworkProvider(); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CNetworkProvider_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + return NOERROR; +} diff --git a/dll/directx/msdvbnp/pin.cpp b/dll/directx/msdvbnp/pin.cpp new file mode 100644 index 00000000000..9662f809133 --- /dev/null +++ b/dll/directx/msdvbnp/pin.cpp @@ -0,0 +1,262 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/pin.cpp + * PURPOSE: IPin interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +const GUID KSDATAFORMAT_TYPE_BDA_ANTENNA = {0x71985f41, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}}; +const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; + +class CPin : public IPin +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + //IPin methods + HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE Disconnect(); + HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin); + HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); + HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); + HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); + HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); + HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); + HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); + HRESULT STDMETHODCALLTYPE EndOfStream(); + HRESULT STDMETHODCALLTYPE BeginFlush(); + HRESULT STDMETHODCALLTYPE EndFlush(); + HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); + + CPin(IBaseFilter * ParentFilter) : m_Ref(0), m_ParentFilter(ParentFilter){}; + virtual ~CPin(){}; + + static LPCWSTR PIN_ID; + +protected: + LONG m_Ref; + IBaseFilter * m_ParentFilter; +}; + + +LPCWSTR CPin::PIN_ID = L"Antenna Out"; + +HRESULT +STDMETHODCALLTYPE +CPin::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IPin)) + { + *Output = (IPin*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CPin::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IPin interface +// +HRESULT +STDMETHODCALLTYPE +CPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CPin::Connect called\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CPin::ReceiveConnection called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::Disconnect( void) +{ + OutputDebugStringW(L"CPin::Disconnect called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::ConnectedTo(IPin **pPin) +{ + OutputDebugStringW(L"CPin::ConnectedTo called\n"); + return VFW_E_NOT_CONNECTED; +} +HRESULT +STDMETHODCALLTYPE +CPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CPin::ConnectionMediaType called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryPinInfo(PIN_INFO *pInfo) +{ + wcscpy(pInfo->achName, PIN_ID); + pInfo->dir = PINDIR_OUTPUT; + pInfo->pFilter = m_ParentFilter; + m_ParentFilter->AddRef(); + + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryDirection(PIN_DIRECTION *pPinDir) +{ + if (pPinDir) + { + *pPinDir = PINDIR_OUTPUT; + return S_OK; + } + + return E_POINTER; +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryId(LPWSTR *Id) +{ + *Id = (LPWSTR)CoTaskMemAlloc(sizeof(PIN_ID)); + if (!*Id) + return E_OUTOFMEMORY; + + wcscpy(*Id, PIN_ID); + return S_OK; +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryAccept(const AM_MEDIA_TYPE *pmt) +{ + OutputDebugStringW(L"CPin::QueryAccept called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) +{ + AM_MEDIA_TYPE *MediaType = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + + if (!MediaType) + { + return E_OUTOFMEMORY; + } + + MediaType->majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA; + MediaType->subtype = MEDIASUBTYPE_None; + MediaType->formattype = FORMAT_None; + MediaType->bFixedSizeSamples = true; + MediaType->bTemporalCompression = false; + MediaType->lSampleSize = sizeof(CHAR); + MediaType->pUnk = NULL; + MediaType->cbFormat = 0; + MediaType->pbFormat = NULL; + + return CEnumMediaTypes_fnConstructor(NULL, 1, MediaType, IID_IEnumMediaTypes, (void**)ppEnum); +} +HRESULT +STDMETHODCALLTYPE +CPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) +{ + OutputDebugStringW(L"CPin::QueryInternalConnections called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::EndOfStream( void) +{ + OutputDebugStringW(L"CPin::EndOfStream called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::BeginFlush( void) +{ + OutputDebugStringW(L"CPin::BeginFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::EndFlush( void) +{ + OutputDebugStringW(L"CPin::EndFlush called\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) +{ + OutputDebugStringW(L"CPin::NewSegment called\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CPin_fnConstructor( + IUnknown *pUnknown, + IBaseFilter * ParentFilter, + REFIID riid, + LPVOID * ppv) +{ + CPin * handler = new CPin(ParentFilter); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CPin_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file diff --git a/dll/directx/msdvbnp/precomp.h b/dll/directx/msdvbnp/precomp.h new file mode 100644 index 00000000000..d20b9ac9d81 --- /dev/null +++ b/dll/directx/msdvbnp/precomp.h @@ -0,0 +1,82 @@ +#ifndef PRECOMP_H__ +#define PRECOMP_H__ + +#define MSDVBNP_TRACE +#define BUILDING_KS +#define _KSDDK_ +#include +//#include +#include +#define __STREAMS__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); + +typedef struct +{ + const GUID* riid; + LPFNCREATEINSTANCE lpfnCI; +} INTERFACE_TABLE; + +/* classfactory.cpp */ +IClassFactory * +CClassFactory_fnConstructor( + LPFNCREATEINSTANCE lpfnCI, + PLONG pcRefDll, + IID * riidInst); + +/* networkprovider.cpp */ +HRESULT +WINAPI +CNetworkProvider_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + +/* scanningtunner.cpp */ +HRESULT +WINAPI +CScanningTunner_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + +/* enumpins.cpp */ +HRESULT +WINAPI +CEnumPins_fnConstructor( + IUnknown *pUnknown, + ULONG NumPins, + IPin ** pins, + REFIID riid, + LPVOID * ppv); + +/* pin.cpp */ +HRESULT +WINAPI +CPin_fnConstructor( + IUnknown *pUnknown, + IBaseFilter * ParentFilter, + REFIID riid, + LPVOID * ppv); + +/* enum_mediatypes.cpp */ +HRESULT +WINAPI +CEnumMediaTypes_fnConstructor( + IUnknown *pUnknown, + ULONG MediaTypeCount, + AM_MEDIA_TYPE * MediaTypes, + REFIID riid, + LPVOID * ppv); + +#endif diff --git a/dll/directx/msdvbnp/scanningtuner.cpp b/dll/directx/msdvbnp/scanningtuner.cpp new file mode 100644 index 00000000000..0c9b7782d2b --- /dev/null +++ b/dll/directx/msdvbnp/scanningtuner.cpp @@ -0,0 +1,264 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Network Provider for MPEG2 based networks + * FILE: dll/directx/msdvbnp/networkprovider.cpp + * PURPOSE: IScanningTunner interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CScanningTunner : public IScanningTuner +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + //ITuner methods + HRESULT STDMETHODCALLTYPE get_TuningSpace(ITuningSpace **TuningSpace); + HRESULT STDMETHODCALLTYPE put_TuningSpace(ITuningSpace *TuningSpace); + HRESULT STDMETHODCALLTYPE EnumTuningSpaces(IEnumTuningSpaces **ppEnum); + HRESULT STDMETHODCALLTYPE get_TuneRequest(ITuneRequest **TuneRequest); + HRESULT STDMETHODCALLTYPE put_TuneRequest(ITuneRequest *TuneRequest); + HRESULT STDMETHODCALLTYPE Validate(ITuneRequest *TuneRequest); + HRESULT STDMETHODCALLTYPE get_PreferredComponentTypes(IComponentTypes **ComponentTypes); + HRESULT STDMETHODCALLTYPE put_PreferredComponentTypes(IComponentTypes *ComponentTypes); + HRESULT STDMETHODCALLTYPE get_SignalStrength(long *Strength); + HRESULT STDMETHODCALLTYPE TriggerSignalEvents(long Interval); + + //IScanningTuner methods + HRESULT STDMETHODCALLTYPE SeekUp(); + HRESULT STDMETHODCALLTYPE SeekDown(); + HRESULT STDMETHODCALLTYPE ScanUp(long MillisecondsPause); + HRESULT STDMETHODCALLTYPE ScanDown(long MillisecondsPause); + HRESULT STDMETHODCALLTYPE AutoProgram(); + + CScanningTunner() : m_Ref(0), m_TuningSpace(0){}; + virtual ~CScanningTunner(){}; + +protected: + LONG m_Ref; + ITuningSpace * m_TuningSpace; +}; + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + if (IsEqualGUID(refiid, IID_ITuner)) + { + *Output = (ITuner*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IScanningTuner)) + { + *Output = (IScanningTuner*)(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CScanningTunner::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +//ITuner +// +HRESULT +STDMETHODCALLTYPE +CScanningTunner::get_TuningSpace( + ITuningSpace **TuningSpace) +{ + OutputDebugStringW(L"CScanningTunner::get_TuningSpace\n"); + + *TuningSpace = m_TuningSpace; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::put_TuningSpace( + ITuningSpace *TuningSpace) +{ + OutputDebugStringW(L"CScanningTunner::put_TuningSpace\n"); + m_TuningSpace = TuningSpace; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::EnumTuningSpaces( + IEnumTuningSpaces **ppEnum) +{ + OutputDebugStringW(L"CScanningTunner::EnumTuningSpaces : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::get_TuneRequest( + ITuneRequest **TuneRequest) +{ + OutputDebugStringW(L"CScanningTunner::get_TuneRequest : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::put_TuneRequest( + ITuneRequest *TuneRequest) +{ + OutputDebugStringW(L"CScanningTunner::put_TuneRequest : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::Validate( + ITuneRequest *TuneRequest) +{ + OutputDebugStringW(L"CScanningTunner::Validate : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::get_PreferredComponentTypes( + IComponentTypes **ComponentTypes) +{ + OutputDebugStringW(L"CScanningTunner::get_PreferredComponentTypes : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::put_PreferredComponentTypes( + IComponentTypes *ComponentTypes) +{ + OutputDebugStringW(L"CScanningTunner::put_PreferredComponentTypes : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::get_SignalStrength( + long *Strength) +{ + OutputDebugStringW(L"CScanningTunner::get_SignalStrength : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::TriggerSignalEvents( + long Interval) +{ + OutputDebugStringW(L"CScanningTunner::TriggerSignalEvents : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +//IScanningTuner +HRESULT +STDMETHODCALLTYPE +CScanningTunner::SeekUp() +{ + OutputDebugStringW(L"CScanningTunner::SeekUp : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::SeekDown() +{ + OutputDebugStringW(L"CScanningTunner::SeekDown : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::ScanUp( + long MillisecondsPause) +{ + OutputDebugStringW(L"CScanningTunner::ScanUp : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::ScanDown( + long MillisecondsPause) +{ + OutputDebugStringW(L"CScanningTunner::ScanDown : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CScanningTunner::AutoProgram() +{ + OutputDebugStringW(L"CScanningTunner::AutoProgram : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CScanningTunner_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + CScanningTunner * handler = new CScanningTunner(); + +#ifdef MSDVBNP_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CScanningTunner_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!handler) + return E_OUTOFMEMORY; + + if (FAILED(handler->QueryInterface(riid, ppv))) + { + /* not supported */ + delete handler; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file diff --git a/dll/directx/msvidctl/classfactory.cpp b/dll/directx/msvidctl/classfactory.cpp new file mode 100644 index 00000000000..8af2a69546f --- /dev/null +++ b/dll/directx/msvidctl/classfactory.cpp @@ -0,0 +1,106 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/classfactory.cpp + * PURPOSE: ClassFactory interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; +const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; + +class CClassFactory : public IClassFactory +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject); + HRESULT WINAPI LockServer(BOOL fLock); + + CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst) : m_Ref(1), m_lpfnCI(lpfnCI), m_IID(riidInst) + {}; + + virtual ~CClassFactory(){}; + +protected: + LONG m_Ref; + LPFNCREATEINSTANCE m_lpfnCI; + IID * m_IID; +}; + +HRESULT +WINAPI +CClassFactory::QueryInterface( + REFIID riid, + LPVOID *ppvObj) +{ + *ppvObj = NULL; + if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) + { + *ppvObj = PVOID(this); + InterlockedIncrement(&m_Ref); + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT +WINAPI +CClassFactory::CreateInstance( + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID *ppvObject) +{ + *ppvObject = NULL; + + if ( m_IID == NULL || IsEqualCLSID(riid, *m_IID) || IsEqualCLSID(riid, IID_IUnknown)) + { + return m_lpfnCI(pUnkOuter, riid, ppvObject); + } + + return E_NOINTERFACE; +} + +HRESULT +WINAPI +CClassFactory::LockServer( + BOOL fLock) +{ + return E_NOTIMPL; +} + +IClassFactory * +CClassFactory_fnConstructor( + LPFNCREATEINSTANCE lpfnCI, + PLONG pcRefDll, + IID * riidInst) +{ + CClassFactory* factory = new CClassFactory(lpfnCI, pcRefDll, riidInst); + + if (!factory) + return NULL; + + if (pcRefDll) + InterlockedIncrement(pcRefDll); + + return (LPCLASSFACTORY)factory; +} + diff --git a/dll/directx/msvidctl/enumtuningspaces.cpp b/dll/directx/msvidctl/enumtuningspaces.cpp new file mode 100644 index 00000000000..22d3e31bd47 --- /dev/null +++ b/dll/directx/msvidctl/enumtuningspaces.cpp @@ -0,0 +1,142 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/tuningspace.cpp + * PURPOSE: ITuningSpace interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEnumTuningSpaces : public IEnumTuningSpaces +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + //delete this; + return 0; + } + return m_Ref; + } + + // IEnumTuningSpaces methods + HRESULT STDMETHODCALLTYPE Next(ULONG celt, ITuningSpace **rgelt, ULONG *pceltFetched); + HRESULT STDMETHODCALLTYPE Skip(ULONG celt); + HRESULT STDMETHODCALLTYPE Reset(); + HRESULT STDMETHODCALLTYPE Clone(IEnumTuningSpaces **ppEnum); + + CEnumTuningSpaces() : m_Ref(0){}; + + virtual ~CEnumTuningSpaces(){}; + +protected: + LONG m_Ref; +}; + +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IEnumTuningSpaces)) + { + *Output = (IEnumTuningSpaces*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CEnumTuningSpaces::QueryInterface: NoInterface for %s\n", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IEnumTuningSpaces +// +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::Next(ULONG celt, ITuningSpace **rgelt, ULONG *pceltFetched) +{ + OutputDebugStringW(L"CEnumTuningSpaces::Next : stub\n"); + return CTuningSpace_fnConstructor(NULL, IID_ITuningSpace, (void**)rgelt); + +} + +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::Skip(ULONG celt) +{ + OutputDebugStringW(L"CEnumTuningSpaces::Skip : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::Reset() +{ + OutputDebugStringW(L"CEnumTuningSpaces::Reset : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CEnumTuningSpaces::Clone(IEnumTuningSpaces **ppEnum) +{ + OutputDebugStringW(L"CEnumTuningSpaces::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CEnumTuningSpaces_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CEnumTuningSpaces * tuningspaces = new CEnumTuningSpaces(); + +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CEnumTuningSpaces_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!tuningspaces) + return E_OUTOFMEMORY; + + if (FAILED(tuningspaces->QueryInterface(riid, ppv))) + { + /* not supported */ + delete tuningspaces; + return E_NOINTERFACE; + } + + return NOERROR; +} + diff --git a/dll/directx/msvidctl/msvidctl.cpp b/dll/directx/msvidctl/msvidctl.cpp new file mode 100644 index 00000000000..b086e59d580 --- /dev/null +++ b/dll/directx/msvidctl/msvidctl.cpp @@ -0,0 +1,106 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS DVB + * FILE: dll/directx/msvidctl/msvidctl.cpp + * PURPOSE: ReactOS DVB Initialization + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ + +#include "precomp.h" + +static INTERFACE_TABLE InterfaceTable[] = +{ + {&CLSID_SystemTuningSpaces, CTuningSpaceContainer_fnConstructor}, + {NULL, NULL} +}; + +extern "C" +BOOL +WINAPI +DllMain( + HINSTANCE hInstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + CoInitialize(NULL); + +#ifdef MSDVBNP_TRACE + OutputDebugStringW(L"MSVIDCTL::DllMain()\n"); +#endif + + DisableThreadLibraryCalls(hInstDLL); + break; + default: + break; + } + + return TRUE; +} + + +extern "C" +KSDDKAPI +HRESULT +WINAPI +DllUnregisterServer(void) +{ + return S_OK; +} + +extern "C" +KSDDKAPI +HRESULT +WINAPI +DllRegisterServer(void) +{ + return S_OK; +} + +KSDDKAPI +HRESULT +WINAPI +DllGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID *ppv) +{ + UINT i; + HRESULT hres = E_OUTOFMEMORY; + IClassFactory * pcf = NULL; + + if (!ppv) + return E_INVALIDARG; + + *ppv = NULL; + + for (i = 0; InterfaceTable[i].riid; i++) + { + if (IsEqualIID(*InterfaceTable[i].riid, rclsid)) + { + pcf = CClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL); + break; + } + } + + if (!pcf) + { + return CLASS_E_CLASSNOTAVAILABLE; + } + + hres = pcf->QueryInterface(riid, ppv); + pcf->Release(); + + return hres; +} + +KSDDKAPI +HRESULT +WINAPI +DllCanUnloadNow(void) +{ + return S_OK; +} diff --git a/dll/directx/msvidctl/msvidctl.rbuild b/dll/directx/msvidctl/msvidctl.rbuild new file mode 100644 index 00000000000..a3da3fcbe09 --- /dev/null +++ b/dll/directx/msvidctl/msvidctl.rbuild @@ -0,0 +1,30 @@ + + + + + + . + ntdll + kernel32 + advapi32 + ole32 + advapi32 + msvcrt + strmiids + + -fno-exceptions + -fno-rtti + + + /GR- + + + classfactory.cpp + enumtuningspaces.cpp + msvidctl.cpp + msvidctl.rc + tunerequest.cpp + tuningspace.cpp + tuningspace_container.cpp + + diff --git a/dll/directx/msvidctl/msvidctl.rc b/dll/directx/msvidctl/msvidctl.rc new file mode 100644 index 00000000000..43187901fe4 --- /dev/null +++ b/dll/directx/msvidctl/msvidctl.rc @@ -0,0 +1,12 @@ +#include + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS ActiveX Control for Streaming Video\0" +#define REACTOS_STR_INTERNAL_NAME "MSVidCtl\0" +#define REACTOS_STR_ORIGINAL_FILENAME "MSVidCtl\0" +#define REACTOS_STR_PRODUCT_VERSION "6.05.2600.3264\0" +#define REACTOS_STR_FILE_VERSION "6.05.2600.3264\0" + +#include diff --git a/dll/directx/msvidctl/msvidctl.spec b/dll/directx/msvidctl/msvidctl.spec new file mode 100644 index 00000000000..5baed04ed66 --- /dev/null +++ b/dll/directx/msvidctl/msvidctl.spec @@ -0,0 +1,4 @@ +@ stdcall DllCanUnloadNow() +@ stdcall DllGetClassObject(ptr ptr ptr) +@ stdcall DllRegisterServer() +@ stdcall DllUnregisterServer() diff --git a/dll/directx/msvidctl/precomp.h b/dll/directx/msvidctl/precomp.h new file mode 100644 index 00000000000..a5b86272e2d --- /dev/null +++ b/dll/directx/msvidctl/precomp.h @@ -0,0 +1,72 @@ +#ifndef PRECOMP_H__ +#define PRECOMP_H__ + +#define MSVIDCTL_TRACE +#define BUILDING_KS +#define _KSDDK_ +#include +//#include +#include +#define __STREAMS__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); + +typedef struct +{ + const GUID* riid; + LPFNCREATEINSTANCE lpfnCI; +} INTERFACE_TABLE; + +/* classfactory.cpp */ +IClassFactory * +CClassFactory_fnConstructor( + LPFNCREATEINSTANCE lpfnCI, + PLONG pcRefDll, + IID * riidInst); + +/* tuningspace_container.cpp */ +HRESULT +WINAPI +CTuningSpaceContainer_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + +/* tuningspace.cpp */ +HRESULT +WINAPI +CTuningSpace_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + +/* tunerequest.cpp */ +HRESULT +WINAPI +CTuneRequest_fnConstructor( + IUnknown *pUnknown, + ITuningSpace * TuningSpace, + REFIID riid, + LPVOID * ppv); + +/* enumtuningspaces.cpp */ +HRESULT +WINAPI +CEnumTuningSpaces_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv); + + + +#endif diff --git a/dll/directx/msvidctl/tunerequest.cpp b/dll/directx/msvidctl/tunerequest.cpp new file mode 100644 index 00000000000..3bee7cfc194 --- /dev/null +++ b/dll/directx/msvidctl/tunerequest.cpp @@ -0,0 +1,331 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/tuningspace.cpp + * PURPOSE: ITuningRequest interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CTuneRequest : public IDVBTuneRequest +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + OutputDebugStringW(L"CTuneRequest::Release : delete\n"); + + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::Release : m_TuningSpace %p delete\n", m_TuningSpace); + OutputDebugStringW(Buffer); + + + m_TuningSpace->Release(); + //delete this; + return 0; + } + return m_Ref; + } + + //IDispatch methods + HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo); + HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); + HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); + HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); + + //ITuneRequest methods + HRESULT STDMETHODCALLTYPE get_TuningSpace(ITuningSpace **TuningSpace); + HRESULT STDMETHODCALLTYPE get_Components(IComponents **Components); + HRESULT STDMETHODCALLTYPE Clone(ITuneRequest **NewTuneRequest); + HRESULT STDMETHODCALLTYPE get_Locator(ILocator **Locator); + HRESULT STDMETHODCALLTYPE put_Locator(ILocator *Locator); + + //IDVBTuneRequest methods + HRESULT STDMETHODCALLTYPE get_ONID(long *ONID); + HRESULT STDMETHODCALLTYPE put_ONID(long ONID); + HRESULT STDMETHODCALLTYPE get_TSID(long *TSID); + HRESULT STDMETHODCALLTYPE put_TSID(long TSID); + HRESULT STDMETHODCALLTYPE get_SID(long *SID); + HRESULT STDMETHODCALLTYPE put_SID(long SID); + + CTuneRequest(ITuningSpace * TuningSpace) : m_Ref(0), m_ONID(-1), m_TSID(-1), m_SID(-1), m_Locator(0), m_TuningSpace(TuningSpace) + { + m_TuningSpace->AddRef(); + }; + + CTuneRequest(ITuningSpace * TuningSpace, LONG ONID, LONG TSID, LONG SID, ILocator * Locator) : m_Ref(1), m_ONID(ONID), m_TSID(TSID), m_SID(SID), m_Locator(Locator), m_TuningSpace(TuningSpace) + { + if (m_Locator) + m_Locator->AddRef(); + + m_TuningSpace->AddRef(); + }; + + virtual ~CTuneRequest(){}; + +protected: + LONG m_Ref; + LONG m_ONID; + LONG m_TSID; + LONG m_SID; + ILocator * m_Locator; + ITuningSpace * m_TuningSpace; +}; + + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_ITuneRequest)) + { + *Output = (ITuneRequest*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IDVBTuneRequest)) + { + *Output = (IDVBTuneRequest*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CTuneRequest::QueryInterface: NoInterface for %s", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IDispatch methods +// +HRESULT +STDMETHODCALLTYPE +CTuneRequest::GetTypeInfoCount(UINT *pctinfo) +{ + OutputDebugStringW(L"CTuneRequest::GetTypeInfoCount : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) +{ + OutputDebugStringW(L"CTuneRequest::GetTypeInfo : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuneRequest::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + OutputDebugStringW(L"CTuneRequest::GetIDsOfNames : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuneRequest::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + OutputDebugStringW(L"CTuneRequest::Invoke : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// ITuneRequest interface +// + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_TuningSpace(ITuningSpace **TuningSpace) +{ +#ifdef MSVIDCTL_TRACE + OutputDebugStringW(L"CTuneRequest::get_TuningSpace\n"); +#endif + + *TuningSpace = m_TuningSpace; + m_TuningSpace->AddRef(); + + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_Components(IComponents **Components) +{ + OutputDebugStringW(L"CTuneRequest::get_Components : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::Clone(ITuneRequest **NewTuneRequest) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::Clone %p\n", NewTuneRequest); + OutputDebugStringW(Buffer); +#endif + + *NewTuneRequest = new CTuneRequest(m_TuningSpace, m_ONID, m_TSID, m_SID, m_Locator); + + if (!*NewTuneRequest) + return E_OUTOFMEMORY; + + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_Locator(ILocator **Locator) +{ + OutputDebugStringW(L"CTuneRequest::get_Locator : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::put_Locator(ILocator *Locator) +{ + OutputDebugStringW(L"CTuneRequest::put_Locator : stub\n"); + m_Locator = Locator; + + return S_OK; +} + +//------------------------------------------------------------------- +// IDVBTuneRequest interface +// + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_ONID(long *ONID) +{ +#ifdef MSVIDCTL_TRACE + OutputDebugStringW(L"CTuneRequest::get_ONID\n"); +#endif + + *ONID = m_ONID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::put_ONID(long ONID) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::put_ONID : %lu\n", ONID); + OutputDebugStringW(Buffer); +#endif + + m_ONID = ONID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_TSID(long *TSID) +{ +#ifdef MSVIDCTL_TRACE + OutputDebugStringW(L"CTuneRequest::get_TSID\n"); +#endif + + *TSID = m_TSID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::put_TSID(long TSID) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::put_TSID : %lu\n", TSID); + OutputDebugStringW(Buffer); +#endif + + m_TSID = TSID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::get_SID(long *SID) +{ +#ifdef MSVIDCTL_TRACE + OutputDebugStringW(L"CTuneRequest::get_SID\n"); +#endif + + *SID = m_SID; + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuneRequest::put_SID(long SID) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuneRequest::put_SID : %lu\n", SID); + OutputDebugStringW(Buffer); +#endif + + m_SID = SID; + return S_OK; +} + +HRESULT +WINAPI +CTuneRequest_fnConstructor( + IUnknown *pUnknown, + ITuningSpace * TuningSpace, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CTuneRequest * request = new CTuneRequest(TuningSpace); + +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CTuneRequest_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!request) + return E_OUTOFMEMORY; + + if (FAILED(request->QueryInterface(riid, ppv))) + { + /* not supported */ + delete request; + return E_NOINTERFACE; + } + + return NOERROR; +} diff --git a/dll/directx/msvidctl/tuningspace.cpp b/dll/directx/msvidctl/tuningspace.cpp new file mode 100644 index 00000000000..035542e595d --- /dev/null +++ b/dll/directx/msvidctl/tuningspace.cpp @@ -0,0 +1,365 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/tuningspace.cpp + * PURPOSE: ITuningSpace interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +const GUID CLSID_DVBTNetworkProvider = {0x216c62df, 0x6d7f, 0x4e9a, {0x85, 0x71, 0x5, 0xf1, 0x4e, 0xdb, 0x76, 0x6a}}; + +class CTuningSpace : public IDVBTuningSpace +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuningSpace::Release : %p Ref %lu\n", this, m_Ref); + OutputDebugStringW(Buffer); + + if (!m_Ref) + { + //delete this; + return 0; + } + return m_Ref; + } + + // IDispatch methods + HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo); + HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); + HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); + HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); + + + //ITuningSpace methods + HRESULT STDMETHODCALLTYPE get_UniqueName(BSTR *Name); + HRESULT STDMETHODCALLTYPE put_UniqueName(BSTR Name); + HRESULT STDMETHODCALLTYPE get_FriendlyName(BSTR *Name); + HRESULT STDMETHODCALLTYPE put_FriendlyName(BSTR Name); + HRESULT STDMETHODCALLTYPE get_CLSID(BSTR *SpaceCLSID); + HRESULT STDMETHODCALLTYPE get_NetworkType(BSTR *NetworkTypeGuid); + HRESULT STDMETHODCALLTYPE put_NetworkType(BSTR NetworkTypeGuid); + HRESULT STDMETHODCALLTYPE get__NetworkType(GUID *NetworkTypeGuid); + HRESULT STDMETHODCALLTYPE put__NetworkType(REFCLSID NetworkTypeGuid); + HRESULT STDMETHODCALLTYPE CreateTuneRequest(ITuneRequest **TuneRequest); + HRESULT STDMETHODCALLTYPE EnumCategoryGUIDs(IEnumGUID **ppEnum); + HRESULT STDMETHODCALLTYPE EnumDeviceMonikers(IEnumMoniker **ppEnum); + HRESULT STDMETHODCALLTYPE get_DefaultPreferredComponentTypes(IComponentTypes **ComponentTypes); + HRESULT STDMETHODCALLTYPE put_DefaultPreferredComponentTypes(IComponentTypes *NewComponentTypes); + HRESULT STDMETHODCALLTYPE get_FrequencyMapping(BSTR *pMapping); + HRESULT STDMETHODCALLTYPE put_FrequencyMapping(BSTR Mapping); + HRESULT STDMETHODCALLTYPE get_DefaultLocator(ILocator **LocatorVal); + HRESULT STDMETHODCALLTYPE put_DefaultLocator(ILocator *LocatorVal); + HRESULT STDMETHODCALLTYPE Clone(ITuningSpace **NewTS); + // IDVBTuningSpace + HRESULT STDMETHODCALLTYPE get_SystemType(DVBSystemType *SysType); + HRESULT STDMETHODCALLTYPE put_SystemType(DVBSystemType SysType); + + CTuningSpace() : m_Ref(0){}; + + virtual ~CTuningSpace(){}; + +protected: + LONG m_Ref; +}; + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_ITuningSpace)) + { + *Output = (ITuningSpace*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IDVBTuningSpace)) + { + *Output = (IDVBTuningSpace*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CTuningSpace::QueryInterface: NoInterface for %s", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IDispatch methods +// +HRESULT +STDMETHODCALLTYPE +CTuningSpace::GetTypeInfoCount(UINT *pctinfo) +{ + OutputDebugStringW(L"CTuningSpace::GetTypeInfoCount : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) +{ + OutputDebugStringW(L"CTuningSpace::GetTypeInfo : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpace::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + OutputDebugStringW(L"CTuningSpace::GetIDsOfNames : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpace::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + OutputDebugStringW(L"CTuningSpace::Invoke : NotImplemented\n"); + return E_NOTIMPL; +} + + +//------------------------------------------------------------------- +// ITuningSpace interface +// + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_UniqueName(BSTR *Name) +{ + OutputDebugStringW(L"CTuningSpace::get_UniqueName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_UniqueName(BSTR Name) +{ + OutputDebugStringW(L"CTuningSpace::put_UniqueName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_FriendlyName(BSTR *Name) +{ + OutputDebugStringW(L"CTuningSpace::get_FriendlyName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_FriendlyName(BSTR Name) +{ + OutputDebugStringW(L"CTuningSpace::put_FriendlyName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_CLSID(BSTR *SpaceCLSID) +{ + OutputDebugStringW(L"CTuningSpace::get_CLSID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_NetworkType(BSTR *NetworkTypeGuid) +{ + OutputDebugStringW(L"CTuningSpace::get_NetworkType : stub\n"); + return StringFromCLSID(CLSID_DVBTNetworkProvider, (LPOLESTR*)NetworkTypeGuid); + +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_NetworkType(BSTR NetworkTypeGuid) +{ + OutputDebugStringW(L"CTuningSpace::put_NetworkType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get__NetworkType(GUID *NetworkTypeGuid) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuningSpace::get__NetworkType : %p stub\n", NetworkTypeGuid); + OutputDebugStringW(Buffer); +#endif + + CopyMemory(NetworkTypeGuid, &CLSID_DVBTNetworkProvider, sizeof(GUID)); + OutputDebugStringW(L"CTuningSpace::get__NetworkType : done\n"); + return S_OK; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put__NetworkType(REFCLSID NetworkTypeGuid) +{ + OutputDebugStringW(L"CTuningSpace::put__NetworkType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::CreateTuneRequest(ITuneRequest **TuneRequest) +{ + OutputDebugStringW(L"CTuningSpace::CreateTuneRequest : stub\n"); + return CTuneRequest_fnConstructor(NULL, (ITuningSpace*)this, IID_ITuneRequest, (void**)TuneRequest); +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::EnumCategoryGUIDs(IEnumGUID **ppEnum) +{ + OutputDebugStringW(L"CTuningSpace::EnumCategoryGUIDs : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::EnumDeviceMonikers(IEnumMoniker **ppEnum) +{ + OutputDebugStringW(L"CTuningSpace::EnumDeviceMonikers : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_DefaultPreferredComponentTypes(IComponentTypes **ComponentTypes) +{ + OutputDebugStringW(L"CTuningSpace::get_DefaultPreferredComponentTypes : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_DefaultPreferredComponentTypes(IComponentTypes *NewComponentTypes) +{ + OutputDebugStringW(L"CTuningSpace::put_DefaultPreferredComponentTypes : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_FrequencyMapping(BSTR *pMapping) +{ + OutputDebugStringW(L"CTuningSpace::get_FrequencyMapping : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_FrequencyMapping(BSTR Mapping) +{ + OutputDebugStringW(L"CTuningSpace::put_FrequencyMapping : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_DefaultLocator(ILocator **LocatorVal) +{ + OutputDebugStringW(L"CTuningSpace::get_DefaultLocator : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_DefaultLocator(ILocator *LocatorVal) +{ + OutputDebugStringW(L"CTuningSpace::put_DefaultLocator : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::Clone(ITuningSpace **NewTS) +{ + OutputDebugStringW(L"CTuningSpace::Clone : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// IDVBTuningSpace +// +HRESULT +STDMETHODCALLTYPE +CTuningSpace::get_SystemType(DVBSystemType *SysType) +{ + OutputDebugStringW(L"CTuningSpace::get_SystemType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpace::put_SystemType(DVBSystemType SysType) +{ + OutputDebugStringW(L"CTuningSpace::put_SystemType : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +WINAPI +CTuningSpace_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CTuningSpace * space = new CTuningSpace(); + +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CTuningSpace_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!space) + return E_OUTOFMEMORY; + + if (FAILED(space->QueryInterface(riid, ppv))) + { + /* not supported */ + delete space; + return E_NOINTERFACE; + } + + return NOERROR; +} + + diff --git a/dll/directx/msvidctl/tuningspace_container.cpp b/dll/directx/msvidctl/tuningspace_container.cpp new file mode 100644 index 00000000000..e25fdc7a600 --- /dev/null +++ b/dll/directx/msvidctl/tuningspace_container.cpp @@ -0,0 +1,272 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msvidctl/tuningspace_container.cpp + * PURPOSE: ITuningSpaceContainer interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#define _FORCENAMELESSUNION +#include "precomp.h" + + +class CTuningSpaceContainer : public ITuningSpaceContainer +{ +public: + + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + if (!m_Ref) + { + OutputDebugStringW(L"CTuningSpaceContainer::Release : delete\n"); + //delete this; + return 0; + } + return m_Ref; + } + + // IDispatch methods + HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo); + HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); + HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); + HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); + + //ITuningSpaceContainer methods + HRESULT STDMETHODCALLTYPE get_Count(long *Count); + HRESULT STDMETHODCALLTYPE get__NewEnum(IEnumVARIANT **NewEnum); + HRESULT STDMETHODCALLTYPE get_Item(VARIANT varIndex, ITuningSpace **TuningSpace); + HRESULT STDMETHODCALLTYPE put_Item(VARIANT varIndex, ITuningSpace *TuningSpace); + HRESULT STDMETHODCALLTYPE TuningSpacesForCLSID(BSTR SpaceCLSID, ITuningSpaces **NewColl); + HRESULT STDMETHODCALLTYPE _TuningSpacesForCLSID(REFCLSID SpaceCLSID, ITuningSpaces **NewColl); + HRESULT STDMETHODCALLTYPE TuningSpacesForName(BSTR Name, ITuningSpaces **NewColl); + HRESULT STDMETHODCALLTYPE FindID(ITuningSpace *TuningSpace, long *ID); + HRESULT STDMETHODCALLTYPE Add(ITuningSpace *TuningSpace, VARIANT *NewIndex); + HRESULT STDMETHODCALLTYPE get_EnumTuningSpaces(IEnumTuningSpaces **ppEnum); + HRESULT STDMETHODCALLTYPE Remove(VARIANT Index); + HRESULT STDMETHODCALLTYPE get_MaxCount(long *MaxCount); + HRESULT STDMETHODCALLTYPE put_MaxCount(long MaxCount); + + CTuningSpaceContainer() : m_Ref(0){}; + + virtual ~CTuningSpaceContainer(){}; + +protected: + LONG m_Ref; + +}; + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUID(refiid, IID_IUnknown)) + { + *Output = PVOID(this); + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_ITuningSpaceContainer)) + { + *Output = (ITuningSpaceContainer*)this; + reinterpret_cast(*Output)->AddRef(); + return NOERROR; + } + + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(refiid, &lpstr); + swprintf(Buffer, L"CTuningSpaceContainer::QueryInterface: NoInterface for %s", lpstr); + OutputDebugStringW(Buffer); + CoTaskMemFree(lpstr); + + + return E_NOINTERFACE; +} + +//------------------------------------------------------------------- +// IDispatch methods +// +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::GetTypeInfoCount(UINT *pctinfo) +{ + OutputDebugStringW(L"CTuningSpaceContainer::GetTypeInfoCount : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) +{ + OutputDebugStringW(L"CTuningSpaceContainer::GetTypeInfo : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + OutputDebugStringW(L"CTuningSpaceContainer::GetIDsOfNames : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + OutputDebugStringW(L"CTuningSpaceContainer::Invoke : NotImplemented\n"); + return E_NOTIMPL; +} + +//------------------------------------------------------------------- +// ITuningSpaceContainer methods +// + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get_Count(long *Count) +{ + OutputDebugStringW(L"CTuningSpaceContainer::get_Count : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get__NewEnum(IEnumVARIANT **NewEnum) +{ + OutputDebugStringW(L"CTuningSpaceContainer::get__NewEnum : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get_Item(VARIANT varIndex, ITuningSpace **TuningSpace) +{ +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[100]; + swprintf(Buffer, L"CTuningSpaceContainer::get_Item : type %x value %s stub\n", varIndex.vt, varIndex.bstrVal); + OutputDebugStringW(Buffer); +#endif + + return CTuningSpace_fnConstructor(NULL, IID_ITuningSpace, (void**)TuningSpace); +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::put_Item(VARIANT varIndex, ITuningSpace *TuningSpace) +{ + OutputDebugStringW(L"CTuningSpaceContainer::put_Item : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::TuningSpacesForCLSID(BSTR SpaceCLSID, ITuningSpaces **NewColl) +{ + OutputDebugStringW(L"CTuningSpaceContainer::TuningSpacesForCLSID : NotImplemented\n"); + return E_NOTIMPL; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::_TuningSpacesForCLSID(REFCLSID SpaceCLSID, ITuningSpaces **NewColl) +{ + OutputDebugStringW(L"CTuningSpaceContainer::_TuningSpacesForCLSID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::TuningSpacesForName(BSTR Name, ITuningSpaces **NewColl) +{ + OutputDebugStringW(L"CTuningSpaceContainer::TuningSpacesForName : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::FindID(ITuningSpace *TuningSpace, long *ID) +{ + OutputDebugStringW(L"CTuningSpaceContainer::FindID : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::Add(ITuningSpace *TuningSpace, VARIANT *NewIndex) +{ + OutputDebugStringW(L"CTuningSpaceContainer::Add : stub\n"); + TuningSpace->AddRef(); + NewIndex->vt = VT_BSTR; + InterlockedIncrement(&m_Ref); + return TuningSpace->get_FriendlyName(&NewIndex->bstrVal);; +} +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get_EnumTuningSpaces(IEnumTuningSpaces **ppEnum) +{ + OutputDebugStringW(L"CTuningSpaceContainer::get_EnumTuningSpaces : stub\n"); + return CEnumTuningSpaces_fnConstructor(NULL, IID_IEnumTuningSpaces, (void**)ppEnum); +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::Remove(VARIANT Index) +{ + OutputDebugStringW(L"CTuningSpaceContainer::Remove: NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::get_MaxCount(long *MaxCount) +{ + OutputDebugStringW(L"CTuningSpaceContainer::get_MaxCount : NotImplemented\n"); + return E_NOTIMPL; +} + +HRESULT +STDMETHODCALLTYPE +CTuningSpaceContainer::put_MaxCount(long MaxCount) +{ + OutputDebugStringW(L"CTuningSpaceContainer::put_MaxCount : NotImplemented\n"); + return E_NOTIMPL; +} + + +HRESULT +WINAPI +CTuningSpaceContainer_fnConstructor( + IUnknown *pUnknown, + REFIID riid, + LPVOID * ppv) +{ + // construct device control + CTuningSpaceContainer * provider = new CTuningSpaceContainer(); + +#ifdef MSVIDCTL_TRACE + WCHAR Buffer[MAX_PATH]; + LPOLESTR lpstr; + StringFromCLSID(riid, &lpstr); + swprintf(Buffer, L"CTuningSpaceContainer_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); + OutputDebugStringW(Buffer); +#endif + + if (!provider) + return E_OUTOFMEMORY; + + if (FAILED(provider->QueryInterface(riid, ppv))) + { + /* not supported */ + delete provider; + return E_NOINTERFACE; + } + + return NOERROR; +} \ No newline at end of file diff --git a/dll/directx/qedit/samplegrabber.c b/dll/directx/qedit/samplegrabber.c index 4e80f24f4d5..d09d5546b19 100644 --- a/dll/directx/qedit/samplegrabber.c +++ b/dll/directx/qedit/samplegrabber.c @@ -33,19 +33,353 @@ WINE_DEFAULT_DEBUG_CHANNEL(qedit); static WCHAR const vendor_name[] = { 'W', 'i', 'n', 'e', 0 }; +static WCHAR const pin_in_name[] = { 'I', 'n', 0 }; +static WCHAR const pin_out_name[] = { 'O', 'u', 't', 0 }; + +IEnumPins *pinsenum_create(IBaseFilter *filter, IPin **pins, ULONG pinCount); +IEnumMediaTypes *mediaenum_create(AM_MEDIA_TYPE *mtype); + +/* Fixed pins enumerator, holds filter referenced */ +typedef struct _PE_Impl { + IEnumPins pe; + IBaseFilter *filter; + LONG refCount; + ULONG numPins; + ULONG index; + IPin *pins[0]; +} PE_Impl; + + +/* IEnumPins interface implementation */ + +/* IUnknown */ +static ULONG WINAPI +Fixed_IEnumPins_AddRef(IEnumPins *iface) +{ + PE_Impl *This = (PE_Impl *)iface; + ULONG refCount = InterlockedIncrement(&This->refCount); + TRACE("(%p) new ref = %u\n", This, refCount); + return refCount; +} + +/* IUnknown */ +static ULONG WINAPI +Fixed_IEnumPins_Release(IEnumPins *iface) +{ + PE_Impl *This = (PE_Impl *)iface; + ULONG refCount = InterlockedDecrement(&This->refCount); + TRACE("(%p) new ref = %u\n", This, refCount); + if (refCount == 0) + { + IBaseFilter_Release(This->filter); + CoTaskMemFree(This); + return 0; + } + return refCount; +} + +/* IUnknown */ +static HRESULT WINAPI +Fixed_IEnumPins_QueryInterface(IEnumPins *iface, REFIID riid, void **ppvObject) +{ + PE_Impl *This = (PE_Impl *)iface; + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualIID(riid, &IID_IUnknown) || + IsEqualIID(riid, &IID_IEnumPins)) { + Fixed_IEnumPins_AddRef(iface); + *ppvObject = &(This->pins); + return S_OK; + } + *ppvObject = NULL; + WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppvObject); + return E_NOINTERFACE; +} + +/* IEnumPins */ +static HRESULT WINAPI +Fixed_IEnumPins_Next(IEnumPins *iface, ULONG nPins, IPin **pins, ULONG *fetched) +{ + PE_Impl *This = (PE_Impl *)iface; + ULONG count = 0; + TRACE("(%p)->(%u, %p, %p) index = %u\n", This, nPins, pins, fetched, This->index); + if (!nPins) + return E_INVALIDARG; + if (!pins || ((nPins != 1) && !fetched)) + return E_POINTER; + while ((count < nPins) && (This->index < This->numPins)) { + IPin *pin = This->pins[This->index++]; + IPin_AddRef(pin); + pins[count++] = pin; + } + if (fetched) + *fetched = count; + return (count == nPins) ? S_OK : S_FALSE; +} + +/* IEnumPins */ +static HRESULT WINAPI +Fixed_IEnumPins_Skip(IEnumPins *iface, ULONG nPins) +{ + PE_Impl *This = (PE_Impl *)iface; + TRACE("(%p)->(%u) index = %u\n", This, nPins, This->index); + nPins += This->index; + if (nPins >= This->numPins) { + This->index = This->numPins; + return S_FALSE; + } + This->index = nPins; + return S_OK; +} + +/* IEnumPins */ +static HRESULT WINAPI +Fixed_IEnumPins_Reset(IEnumPins *iface) +{ + PE_Impl *This = (PE_Impl *)iface; + TRACE("(%p)->() index = %u\n", This, This->index); + This->index = 0; + return S_OK; +} + +/* IEnumPins */ +static HRESULT WINAPI +Fixed_IEnumPins_Clone(IEnumPins *iface, IEnumPins **pins) +{ + PE_Impl *This = (PE_Impl *)iface; + TRACE("(%p)->(%p) index = %u\n", This, pins, This->index); + if (!pins) + return E_POINTER; + *pins = pinsenum_create(This->filter, This->pins, This->numPins); + if (!*pins) + return E_OUTOFMEMORY; + ((PE_Impl *)*pins)->index = This->index; + return S_OK; +} + + +/* Virtual tables and constructor */ + +static const IEnumPinsVtbl IEnumPins_VTable = +{ + Fixed_IEnumPins_QueryInterface, + Fixed_IEnumPins_AddRef, + Fixed_IEnumPins_Release, + Fixed_IEnumPins_Next, + Fixed_IEnumPins_Skip, + Fixed_IEnumPins_Reset, + Fixed_IEnumPins_Clone, +}; + +IEnumPins *pinsenum_create(IBaseFilter *filter, IPin **pins, ULONG pinCount) +{ + ULONG len = sizeof(PE_Impl) + (pinCount * sizeof(IPin *)); + PE_Impl *obj = CoTaskMemAlloc(len); + if (obj) { + ULONG i; + ZeroMemory(obj, len); + obj->pe.lpVtbl = &IEnumPins_VTable; + obj->refCount = 1; + obj->filter = filter; + obj->numPins = pinCount; + obj->index = 0; + for (i=0; ipins[i] = pins[i]; + IBaseFilter_AddRef(filter); + } + return &obj->pe; +} + + +/* Single media type enumerator */ +typedef struct _ME_Impl { + IEnumMediaTypes me; + LONG refCount; + BOOL past; + AM_MEDIA_TYPE mtype; +} ME_Impl; + + +/* IEnumMediaTypes interface implementation */ + +/* IUnknown */ +static ULONG WINAPI +Single_IEnumMediaTypes_AddRef(IEnumMediaTypes *iface) +{ + ME_Impl *This = (ME_Impl *)iface; + ULONG refCount = InterlockedIncrement(&This->refCount); + TRACE("(%p) new ref = %u\n", This, refCount); + return refCount; +} + +/* IUnknown */ +static ULONG WINAPI +Single_IEnumMediaTypes_Release(IEnumMediaTypes *iface) +{ + ME_Impl *This = (ME_Impl *)iface; + ULONG refCount = InterlockedDecrement(&This->refCount); + TRACE("(%p) new ref = %u\n", This, refCount); + if (refCount == 0) + { + if (This->mtype.pbFormat) + CoTaskMemFree(This->mtype.pbFormat); + CoTaskMemFree(This); + return 0; + } + return refCount; +} + +/* IUnknown */ +static HRESULT WINAPI +Single_IEnumMediaTypes_QueryInterface(IEnumMediaTypes *iface, REFIID riid, void **ppvObject) +{ + ME_Impl *This = (ME_Impl *)iface; + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualIID(riid, &IID_IUnknown) || + IsEqualIID(riid, &IID_IEnumMediaTypes)) { + Single_IEnumMediaTypes_AddRef(iface); + *ppvObject = &(This->me); + return S_OK; + } + *ppvObject = NULL; + WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppvObject); + return E_NOINTERFACE; +} + +/* IEnumMediaTypes */ +static HRESULT WINAPI +Single_IEnumMediaTypes_Next(IEnumMediaTypes *iface, ULONG nTypes, AM_MEDIA_TYPE **types, ULONG *fetched) +{ + ME_Impl *This = (ME_Impl *)iface; + ULONG count = 0; + TRACE("(%p)->(%u, %p, %p)\n", This, nTypes, types, fetched); + if (!nTypes) + return E_INVALIDARG; + if (!types || ((nTypes != 1) && !fetched)) + return E_POINTER; + if (!This->past) { + AM_MEDIA_TYPE *mtype = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + *mtype = This->mtype; + if (mtype->cbFormat) { + mtype->pbFormat = CoTaskMemAlloc(mtype->cbFormat); + CopyMemory(mtype->pbFormat, This->mtype.pbFormat, mtype->cbFormat); + } + *types = mtype; + This->past = TRUE; + count = 1; + } + if (fetched) + *fetched = count; + return (count == nTypes) ? S_OK : S_FALSE; +} + +/* IEnumMediaTypes */ +static HRESULT WINAPI +Single_IEnumMediaTypes_Skip(IEnumMediaTypes *iface, ULONG nTypes) +{ + ME_Impl *This = (ME_Impl *)iface; + TRACE("(%p)->(%u)\n", This, nTypes); + if (nTypes) + This->past = TRUE; + return This->past ? S_FALSE : S_OK; +} + +/* IEnumMediaTypes */ +static HRESULT WINAPI +Single_IEnumMediaTypes_Reset(IEnumMediaTypes *iface) +{ + ME_Impl *This = (ME_Impl *)iface; + TRACE("(%p)->()\n", This); + This->past = FALSE; + return S_OK; +} + +/* IEnumMediaTypes */ +static HRESULT WINAPI +Single_IEnumMediaTypes_Clone(IEnumMediaTypes *iface, IEnumMediaTypes **me) +{ + ME_Impl *This = (ME_Impl *)iface; + TRACE("(%p)->(%p)\n", This, me); + if (!me) + return E_POINTER; + *me = mediaenum_create(&This->mtype); + if (!*me) + return E_OUTOFMEMORY; + ((ME_Impl *)*me)->past = This->past; + return S_OK; +} + + +/* Virtual tables and constructor */ + +static const IEnumMediaTypesVtbl IEnumMediaTypes_VTable = +{ + Single_IEnumMediaTypes_QueryInterface, + Single_IEnumMediaTypes_AddRef, + Single_IEnumMediaTypes_Release, + Single_IEnumMediaTypes_Next, + Single_IEnumMediaTypes_Skip, + Single_IEnumMediaTypes_Reset, + Single_IEnumMediaTypes_Clone, +}; + +IEnumMediaTypes *mediaenum_create(AM_MEDIA_TYPE *mtype) +{ + ME_Impl *obj = CoTaskMemAlloc(sizeof(ME_Impl)); + if (obj) { + ZeroMemory(obj, sizeof(ME_Impl)); + obj->me.lpVtbl = &IEnumMediaTypes_VTable; + obj->refCount = 1; + obj->past = FALSE; + obj->mtype = *mtype; + obj->mtype.pUnk = NULL; + if (mtype->cbFormat) { + obj->mtype.pbFormat = CoTaskMemAlloc(mtype->cbFormat); + CopyMemory(obj->mtype.pbFormat, mtype->pbFormat, mtype->cbFormat); + } + else + obj->mtype.pbFormat = NULL; + } + return &obj->me; +} + + +/* Sample Grabber pin implementation */ +typedef struct _SG_Pin { + const IPinVtbl* lpVtbl; + PIN_DIRECTION dir; + WCHAR const *name; + struct _SG_Impl *sg; + IPin *pair; +} SG_Pin; /* Sample Grabber filter implementation */ typedef struct _SG_Impl { const IBaseFilterVtbl* IBaseFilter_Vtbl; const ISampleGrabberVtbl* ISampleGrabber_Vtbl; + const IMemInputPinVtbl* IMemInputPin_Vtbl; /* TODO: IMediaPosition, IMediaSeeking, IQualityControl */ LONG refCount; FILTER_INFO info; FILTER_STATE state; + AM_MEDIA_TYPE mtype; + SG_Pin pin_in; + SG_Pin pin_out; IMemAllocator *allocator; IReferenceClock *refClock; + IMemInputPin *memOutput; + ISampleGrabberCB *grabberIface; + LONG grabberMethod; + LONG oneShot; } SG_Impl; +enum { + OneShot_None, + OneShot_Wait, + OneShot_Past, +}; + /* Get the SampleGrabber implementation This pointer from various interface pointers */ static inline SG_Impl *impl_from_IBaseFilter(IBaseFilter *iface) { @@ -57,6 +391,11 @@ static inline SG_Impl *impl_from_ISampleGrabber(ISampleGrabber *iface) return (SG_Impl *)((char*)iface - FIELD_OFFSET(SG_Impl, ISampleGrabber_Vtbl)); } +static inline SG_Impl *impl_from_IMemInputPin(IMemInputPin *iface) +{ + return (SG_Impl *)((char*)iface - FIELD_OFFSET(SG_Impl, IMemInputPin_Vtbl)); +} + /* Cleanup at end of life */ static void SampleGrabber_cleanup(SG_Impl *This) @@ -68,6 +407,12 @@ static void SampleGrabber_cleanup(SG_Impl *This) IMemAllocator_Release(This->allocator); if (This->refClock) IReferenceClock_Release(This->refClock); + if (This->memOutput) + IMemInputPin_Release(This->memOutput); + if (This->grabberIface) + ISampleGrabberCB_Release(This->grabberIface); + if (This->mtype.pbFormat) + CoTaskMemFree(This->mtype.pbFormat); } /* Common helper AddRef called from all interfaces */ @@ -110,8 +455,11 @@ static HRESULT SampleGrabber_query(SG_Impl *This, REFIID riid, void **ppvObject) *ppvObject = &(This->ISampleGrabber_Vtbl); return S_OK; } - else if (IsEqualIID(riid, &IID_IMemInputPin)) - FIXME("IMemInputPin not implemented\n"); + else if (IsEqualIID(riid, &IID_IMemInputPin)) { + SampleGrabber_addref(This); + *ppvObject = &(This->IMemInputPin_Vtbl); + return S_OK; + } else if (IsEqualIID(riid, &IID_IMediaPosition)) FIXME("IMediaPosition not implemented\n"); else if (IsEqualIID(riid, &IID_IMediaSeeking)) @@ -123,6 +471,45 @@ static HRESULT SampleGrabber_query(SG_Impl *This, REFIID riid, void **ppvObject) return E_NOINTERFACE; } +/* Helper that calls installed sample callbacks */ +static void SampleGrabber_callback(SG_Impl *This, IMediaSample *sample) +{ + double time = 0.0; + REFERENCE_TIME tStart, tEnd; + if (SUCCEEDED(IMediaSample_GetTime(sample, &tStart, &tEnd))) + time = 1e-7 * tStart; + switch (This->grabberMethod) { + case 0: + { + ULONG ref = IMediaSample_AddRef(sample); + ISampleGrabberCB_SampleCB(This->grabberIface, time, sample); + ref = IMediaSample_Release(sample) + 1 - ref; + if (ref) + { + ERR("(%p) Callback referenced sample %p by %u\n", This, sample, ref); + /* ugly as hell but some apps are sooo buggy */ + while (ref--) + IMediaSample_Release(sample); + } + } + break; + case 1: + { + BYTE *data = 0; + long size = IMediaSample_GetActualDataLength(sample); + if (size && SUCCEEDED(IMediaSample_GetPointer(sample, &data)) && data) + ISampleGrabberCB_BufferCB(This->grabberIface, time, data, size); + } + break; + case -1: + break; + default: + FIXME("unsupported method %ld\n", (long int)This->grabberMethod); + /* do not bother us again */ + This->grabberMethod = -1; + } +} + /* SampleGrabber implementation of IBaseFilter interface */ @@ -236,10 +623,14 @@ static HRESULT WINAPI SampleGrabber_IBaseFilter_EnumPins(IBaseFilter *iface, IEnumPins **pins) { SG_Impl *This = impl_from_IBaseFilter(iface); - FIXME("(%p)->(%p): stub\n", This, pins); + IPin *pin[2]; + TRACE("(%p)->(%p)\n", This, pins); if (!pins) return E_POINTER; - return E_OUTOFMEMORY; + pin[0] = (IPin*)&This->pin_in.lpVtbl; + pin[1] = (IPin*)&This->pin_out.lpVtbl; + *pins = pinsenum_create(iface, pin, 2); + return *pins ? S_OK : E_OUTOFMEMORY; } /* IBaseFilter */ @@ -247,9 +638,21 @@ static HRESULT WINAPI SampleGrabber_IBaseFilter_FindPin(IBaseFilter *iface, LPCWSTR id, IPin **pin) { SG_Impl *This = impl_from_IBaseFilter(iface); - FIXME("(%p)->(%s, %p): stub\n", This, debugstr_w(id), pin); + TRACE("(%p)->(%s, %p)\n", This, debugstr_w(id), pin); if (!id || !pin) return E_POINTER; + if (!lstrcmpiW(id,pin_in_name)) + { + SampleGrabber_addref(This); + *pin = (IPin*)&(This->pin_in.lpVtbl); + return S_OK; + } + else if (!lstrcmpiW(id,pin_out_name)) + { + SampleGrabber_addref(This); + *pin = (IPin*)&(This->pin_out.lpVtbl); + return S_OK; + } *pin = NULL; return VFW_E_NOT_FOUND; } @@ -277,6 +680,7 @@ SampleGrabber_IBaseFilter_JoinFilterGraph(IBaseFilter *iface, IFilterGraph *grap This->info.pGraph = graph; if (name) lstrcpynW(This->info.achName,name,MAX_FILTER_NAME); + This->oneShot = OneShot_None; return S_OK; } @@ -321,8 +725,9 @@ static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetOneShot(ISampleGrabber *iface, BOOL oneShot) { SG_Impl *This = impl_from_ISampleGrabber(iface); - FIXME("(%p)->(%u): stub\n", This, oneShot); - return E_NOTIMPL; + TRACE("(%p)->(%u)\n", This, oneShot); + This->oneShot = oneShot ? OneShot_Wait : OneShot_None; + return S_OK; } /* ISampleGrabber */ @@ -330,10 +735,24 @@ static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetMediaType(ISampleGrabber *iface, const AM_MEDIA_TYPE *type) { SG_Impl *This = impl_from_ISampleGrabber(iface); - FIXME("(%p)->(%p): stub\n", This, type); + TRACE("(%p)->(%p)\n", This, type); if (!type) return E_POINTER; - return E_NOTIMPL; + TRACE("Media type: %s/%s ssize: %u format: %s (%u bytes)\n", + debugstr_guid(&type->majortype), debugstr_guid(&type->subtype), + type->lSampleSize, + debugstr_guid(&type->formattype), type->cbFormat); + if (This->mtype.pbFormat) + CoTaskMemFree(This->mtype.pbFormat); + This->mtype = *type; + This->mtype.pUnk = NULL; + if (type->cbFormat) { + This->mtype.pbFormat = CoTaskMemAlloc(type->cbFormat); + CopyMemory(This->mtype.pbFormat, type->pbFormat, type->cbFormat); + } + else + This->mtype.pbFormat = NULL; + return S_OK; } /* ISampleGrabber */ @@ -341,10 +760,17 @@ static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetConnectedMediaType(ISampleGrabber *iface, AM_MEDIA_TYPE *type) { SG_Impl *This = impl_from_ISampleGrabber(iface); - FIXME("(%p)->(%p): stub\n", This, type); + TRACE("(%p)->(%p)\n", This, type); if (!type) return E_POINTER; - return E_NOTIMPL; + if (!This->pin_in.pair) + return VFW_E_NOT_CONNECTED; + *type = This->mtype; + if (type->cbFormat) { + type->pbFormat = CoTaskMemAlloc(type->cbFormat); + CopyMemory(type->pbFormat, This->mtype.pbFormat, type->cbFormat); + } + return S_OK; } /* ISampleGrabber */ @@ -383,10 +809,475 @@ static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetCallback(ISampleGrabber *iface, ISampleGrabberCB *cb, LONG whichMethod) { SG_Impl *This = impl_from_ISampleGrabber(iface); - FIXME("(%p)->(%p, %u): stub\n", This, cb, whichMethod); + TRACE("(%p)->(%p, %u)\n", This, cb, whichMethod); + if (This->grabberIface) + ISampleGrabberCB_Release(This->grabberIface); + This->grabberIface = cb; + This->grabberMethod = whichMethod; + if (cb) + ISampleGrabberCB_AddRef(cb); + return S_OK; +} + + +/* SampleGrabber implementation of IMemInputPin interface */ + +/* IUnknown */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_QueryInterface(IMemInputPin *iface, REFIID riid, void **ppvObject) +{ + return SampleGrabber_query(impl_from_IMemInputPin(iface), riid, ppvObject); +} + +/* IUnknown */ +static ULONG WINAPI +SampleGrabber_IMemInputPin_AddRef(IMemInputPin *iface) +{ + return SampleGrabber_addref(impl_from_IMemInputPin(iface)); +} + +/* IUnknown */ +static ULONG WINAPI +SampleGrabber_IMemInputPin_Release(IMemInputPin *iface) +{ + return SampleGrabber_release(impl_from_IMemInputPin(iface)); +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_GetAllocator(IMemInputPin *iface, IMemAllocator **allocator) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + TRACE("(%p)->(%p) allocator = %p\n", This, allocator, This->allocator); + if (!allocator) + return E_POINTER; + *allocator = This->allocator; + if (!*allocator) + return VFW_E_NO_ALLOCATOR; + IMemAllocator_AddRef(*allocator); + return S_OK; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_NotifyAllocator(IMemInputPin *iface, IMemAllocator *allocator, BOOL readOnly) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + TRACE("(%p)->(%p, %u) allocator = %p\n", This, allocator, readOnly, This->allocator); + if (This->allocator == allocator) + return S_OK; + if (This->allocator) + IMemAllocator_Release(This->allocator); + This->allocator = allocator; + if (allocator) + IMemAllocator_AddRef(allocator); + return S_OK; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_GetAllocatorRequirements(IMemInputPin *iface, ALLOCATOR_PROPERTIES *props) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + FIXME("(%p)->(%p): semi-stub\n", This, props); + if (!props) + return E_POINTER; + return This->memOutput ? IMemInputPin_GetAllocatorRequirements(This->memOutput, props) : E_NOTIMPL; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_Receive(IMemInputPin *iface, IMediaSample *sample) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + HRESULT hr; + TRACE("(%p)->(%p) output = %p, grabber = %p\n", This, sample, This->memOutput, This->grabberIface); + if (!sample) + return E_POINTER; + if ((This->state != State_Running) || (This->oneShot == OneShot_Past)) + return S_FALSE; + if (This->grabberIface) + SampleGrabber_callback(This, sample); + hr = This->memOutput ? IMemInputPin_Receive(This->memOutput, sample) : S_OK; + if (This->oneShot == OneShot_Wait) { + This->oneShot = OneShot_Past; + hr = S_FALSE; + if (This->pin_out.pair) + IPin_EndOfStream(This->pin_out.pair); + } + return hr; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_ReceiveMultiple(IMemInputPin *iface, IMediaSample **samples, LONG nSamples, LONG *nProcessed) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + TRACE("(%p)->(%p, %u, %p) output = %p, grabber = %p\n", This, samples, nSamples, nProcessed, This->memOutput, This->grabberIface); + if (!samples || !nProcessed) + return E_POINTER; + if ((This->state != State_Running) || (This->oneShot == OneShot_Past)) + return S_FALSE; + if (This->grabberIface) { + LONG idx; + for (idx = 0; idx < nSamples; idx++) + SampleGrabber_callback(This, samples[idx]); + } + return This->memOutput ? IMemInputPin_ReceiveMultiple(This->memOutput, samples, nSamples, nProcessed) : S_OK; +} + +/* IMemInputPin */ +static HRESULT WINAPI +SampleGrabber_IMemInputPin_ReceiveCanBlock(IMemInputPin *iface) +{ + SG_Impl *This = impl_from_IMemInputPin(iface); + TRACE("(%p)\n", This); + return This->memOutput ? IMemInputPin_ReceiveCanBlock(This->memOutput) : S_OK; +} + + +/* SampleGrabber member pin implementation */ + +/* IUnknown */ +static ULONG WINAPI +SampleGrabber_IPin_AddRef(IPin *iface) +{ + return SampleGrabber_addref(((SG_Pin *)iface)->sg); +} + +/* IUnknown */ +static ULONG WINAPI +SampleGrabber_IPin_Release(IPin *iface) +{ + return SampleGrabber_release(((SG_Pin *)iface)->sg); +} + +/* IUnknown */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryInterface(IPin *iface, REFIID riid, void **ppvObject) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualIID(riid, &IID_IUnknown) || + IsEqualIID(riid, &IID_IPin)) { + SampleGrabber_addref(This->sg); + *ppvObject = This; + return S_OK; + } + else if (IsEqualIID(riid, &IID_IMemInputPin)) { + SampleGrabber_addref(This->sg); + *ppvObject = &(This->sg->IMemInputPin_Vtbl); + return S_OK; + } + *ppvObject = NULL; + WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppvObject); + return E_NOINTERFACE; +} + +/* IPin - input pin */ +static HRESULT WINAPI +SampleGrabber_In_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE *mtype) +{ + WARN("(%p, %p): unexpected\n", receiver, mtype); + return E_UNEXPECTED; +} + +/* IPin - output pin */ +static HRESULT WINAPI +SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE *type) +{ + SG_Pin *This = (SG_Pin *)iface; + HRESULT hr; + TRACE("(%p)->(%p, %p)\n", This, receiver, type); + if (!receiver) + return E_POINTER; + if (This->pair) + return VFW_E_ALREADY_CONNECTED; + if (This->sg->state != State_Stopped) + return VFW_E_NOT_STOPPED; + if (type) { + TRACE("Media type: %s/%s ssize: %u format: %s (%u bytes)\n", + debugstr_guid(&type->majortype), debugstr_guid(&type->subtype), + type->lSampleSize, + debugstr_guid(&type->formattype), type->cbFormat); + if (!IsEqualGUID(&This->sg->mtype.majortype,&GUID_NULL) && + !IsEqualGUID(&This->sg->mtype.majortype,&type->majortype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&This->sg->mtype.subtype,&MEDIASUBTYPE_None) && + !IsEqualGUID(&This->sg->mtype.subtype,&type->subtype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&This->sg->mtype.formattype,&GUID_NULL) && + !IsEqualGUID(&This->sg->mtype.formattype,&FORMAT_None) && + !IsEqualGUID(&This->sg->mtype.formattype,&type->formattype)) + return VFW_E_TYPE_NOT_ACCEPTED; + } + else + type = &This->sg->mtype; + if (!IsEqualGUID(&type->formattype, &FORMAT_None) && + !IsEqualGUID(&type->formattype, &GUID_NULL) && + !type->pbFormat) + return VFW_E_TYPE_NOT_ACCEPTED; + hr = IPin_ReceiveConnection(receiver,(IPin*)&This->lpVtbl,type); + if (FAILED(hr)) + return hr; + This->pair = receiver; + if (This->sg->memOutput) { + IMemInputPin_Release(This->sg->memOutput); + This->sg->memOutput = NULL; + } + IPin_QueryInterface(receiver,&IID_IMemInputPin,(void **)&(This->sg->memOutput)); + TRACE("(%p) Accepted IPin %p, IMemInputPin %p\n", This, receiver, This->sg->memOutput); + return S_OK; +} + +/* IPin - input pin */ +static HRESULT WINAPI +SampleGrabber_In_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_MEDIA_TYPE *type) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p, %p)\n", This, connector, type); + if (!connector) + return E_POINTER; + if (This->pair) + return VFW_E_ALREADY_CONNECTED; + if (This->sg->state != State_Stopped) + return VFW_E_NOT_STOPPED; + if (type) { + TRACE("Media type: %s/%s ssize: %u format: %s (%u bytes)\n", + debugstr_guid(&type->majortype), debugstr_guid(&type->subtype), + type->lSampleSize, + debugstr_guid(&type->formattype), type->cbFormat); + if (!IsEqualGUID(&This->sg->mtype.majortype,&GUID_NULL) && + !IsEqualGUID(&This->sg->mtype.majortype,&type->majortype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&This->sg->mtype.subtype,&MEDIASUBTYPE_None) && + !IsEqualGUID(&This->sg->mtype.subtype,&type->subtype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&This->sg->mtype.formattype,&GUID_NULL) && + !IsEqualGUID(&This->sg->mtype.formattype,&FORMAT_None) && + !IsEqualGUID(&This->sg->mtype.formattype,&type->formattype)) + return VFW_E_TYPE_NOT_ACCEPTED; + if (!IsEqualGUID(&type->formattype, &FORMAT_None) && + !IsEqualGUID(&type->formattype, &GUID_NULL) && + !type->pbFormat) + return VFW_E_TYPE_NOT_ACCEPTED; + if (This->sg->mtype.pbFormat) + CoTaskMemFree(This->sg->mtype.pbFormat); + This->sg->mtype = *type; + This->sg->mtype.pUnk = NULL; + if (type->cbFormat) { + This->sg->mtype.pbFormat = CoTaskMemAlloc(type->cbFormat); + CopyMemory(This->sg->mtype.pbFormat, type->pbFormat, type->cbFormat); + } + else + This->sg->mtype.pbFormat = NULL; + } + This->pair = connector; + TRACE("(%p) Accepted IPin %p\n", This, connector); + return S_OK; +} + +/* IPin - output pin */ +static HRESULT WINAPI +SampleGrabber_Out_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_MEDIA_TYPE *mtype) +{ + WARN("(%p, %p): unexpected\n", connector, mtype); + return E_UNEXPECTED; +} + +/* IPin - input pin */ +static HRESULT WINAPI +SampleGrabber_In_IPin_Disconnect(IPin *iface) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->() pair = %p\n", This, This->pair); + if (This->sg->state != State_Stopped) + return VFW_E_NOT_STOPPED; + if (This->pair) { + This->pair = NULL; + return S_OK; + } + return S_FALSE; +} + +/* IPin - output pin */ +static HRESULT WINAPI +SampleGrabber_Out_IPin_Disconnect(IPin *iface) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->() pair = %p\n", This, This->pair); + if (This->sg->state != State_Stopped) + return VFW_E_NOT_STOPPED; + if (This->pair) { + This->pair = NULL; + if (This->sg->memOutput) { + IMemInputPin_Release(This->sg->memOutput); + This->sg->memOutput = NULL; + } + return S_OK; + } + return S_FALSE; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_ConnectedTo(IPin *iface, IPin **pin) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p) pair = %p\n", This, pin, This->pair); + if (!pin) + return E_POINTER; + *pin = This->pair; + if (*pin) { + IPin_AddRef(*pin); + return S_OK; + } + return VFW_E_NOT_CONNECTED; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *mtype) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p)\n", This, mtype); + if (!mtype) + return E_POINTER; + if (!This->pair) + return VFW_E_NOT_CONNECTED; + *mtype = This->sg->mtype; + if (mtype->cbFormat) { + mtype->pbFormat = CoTaskMemAlloc(mtype->cbFormat); + CopyMemory(mtype->pbFormat, This->sg->mtype.pbFormat, mtype->cbFormat); + } + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryPinInfo(IPin *iface, PIN_INFO *info) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p)\n", This, info); + if (!info) + return E_POINTER; + SampleGrabber_addref(This->sg); + info->pFilter = (IBaseFilter *)This->sg; + info->dir = This->dir; + lstrcpynW(info->achName,This->name,MAX_PIN_NAME); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryDirection(IPin *iface, PIN_DIRECTION *dir) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p)\n", This, dir); + if (!dir) + return E_POINTER; + *dir = This->dir; + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryId(IPin *iface, LPWSTR *id) +{ + SG_Pin *This = (SG_Pin *)iface; + int len; + TRACE("(%p)->(%p)\n", This, id); + if (!id) + return E_POINTER; + len = sizeof(WCHAR)*(1+lstrlenW(This->name)); + *id = CoTaskMemAlloc(len); + CopyMemory(*id, This->name, len); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mtype) +{ + TRACE("(%p)\n", mtype); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **mtypes) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p)\n", This, mtypes); + if (!mtypes) + return E_POINTER; + *mtypes = mediaenum_create(&This->sg->mtype); + return *mtypes ? S_OK : E_OUTOFMEMORY; +} + +/* IPin - input pin */ +static HRESULT WINAPI +SampleGrabber_In_IPin_QueryInternalConnections(IPin *iface, IPin **pins, ULONG *nPins) +{ + SG_Pin *This = (SG_Pin *)iface; + TRACE("(%p)->(%p, %p) size = %u\n", This, pins, nPins, (nPins ? *nPins : 0)); + if (!nPins) + return E_POINTER; + if (*nPins) { + if (!pins) + return E_POINTER; + IPin_AddRef((IPin*)&This->sg->pin_out.lpVtbl); + *pins = (IPin*)&This->sg->pin_out.lpVtbl; + *nPins = 1; + return S_OK; + } + *nPins = 1; + return S_FALSE; +} + +/* IPin - output pin */ +static HRESULT WINAPI +SampleGrabber_Out_IPin_QueryInternalConnections(IPin *iface, IPin **pins, ULONG *nPins) +{ + WARN("(%p, %p): unexpected\n", pins, nPins); + if (nPins) + *nPins = 0; return E_NOTIMPL; } +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_EndOfStream(IPin *iface) +{ + FIXME(": stub\n"); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_BeginFlush(IPin *iface) +{ + FIXME(": stub\n"); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_EndFlush(IPin *iface) +{ + FIXME(": stub\n"); + return S_OK; +} + +/* IPin */ +static HRESULT WINAPI +SampleGrabber_IPin_NewSegment(IPin *iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double rate) +{ + FIXME(": stub\n"); + return S_OK; +} + /* SampleGrabber vtables and constructor */ @@ -423,6 +1314,63 @@ static const ISampleGrabberVtbl ISampleGrabber_VTable = SampleGrabber_ISampleGrabber_SetCallback, }; +static const IMemInputPinVtbl IMemInputPin_VTable = +{ + SampleGrabber_IMemInputPin_QueryInterface, + SampleGrabber_IMemInputPin_AddRef, + SampleGrabber_IMemInputPin_Release, + SampleGrabber_IMemInputPin_GetAllocator, + SampleGrabber_IMemInputPin_NotifyAllocator, + SampleGrabber_IMemInputPin_GetAllocatorRequirements, + SampleGrabber_IMemInputPin_Receive, + SampleGrabber_IMemInputPin_ReceiveMultiple, + SampleGrabber_IMemInputPin_ReceiveCanBlock, +}; + +static const IPinVtbl IPin_In_VTable = +{ + SampleGrabber_IPin_QueryInterface, + SampleGrabber_IPin_AddRef, + SampleGrabber_IPin_Release, + SampleGrabber_In_IPin_Connect, + SampleGrabber_In_IPin_ReceiveConnection, + SampleGrabber_In_IPin_Disconnect, + SampleGrabber_IPin_ConnectedTo, + SampleGrabber_IPin_ConnectionMediaType, + SampleGrabber_IPin_QueryPinInfo, + SampleGrabber_IPin_QueryDirection, + SampleGrabber_IPin_QueryId, + SampleGrabber_IPin_QueryAccept, + SampleGrabber_IPin_EnumMediaTypes, + SampleGrabber_In_IPin_QueryInternalConnections, + SampleGrabber_IPin_EndOfStream, + SampleGrabber_IPin_BeginFlush, + SampleGrabber_IPin_EndFlush, + SampleGrabber_IPin_NewSegment, +}; + +static const IPinVtbl IPin_Out_VTable = +{ + SampleGrabber_IPin_QueryInterface, + SampleGrabber_IPin_AddRef, + SampleGrabber_IPin_Release, + SampleGrabber_Out_IPin_Connect, + SampleGrabber_Out_IPin_ReceiveConnection, + SampleGrabber_Out_IPin_Disconnect, + SampleGrabber_IPin_ConnectedTo, + SampleGrabber_IPin_ConnectionMediaType, + SampleGrabber_IPin_QueryPinInfo, + SampleGrabber_IPin_QueryDirection, + SampleGrabber_IPin_QueryId, + SampleGrabber_IPin_QueryAccept, + SampleGrabber_IPin_EnumMediaTypes, + SampleGrabber_Out_IPin_QueryInternalConnections, + SampleGrabber_IPin_EndOfStream, + SampleGrabber_IPin_BeginFlush, + SampleGrabber_IPin_EndFlush, + SampleGrabber_IPin_NewSegment, +}; + HRESULT SampleGrabber_create(IUnknown *pUnkOuter, LPVOID *ppv) { SG_Impl* obj = NULL; @@ -442,11 +1390,29 @@ HRESULT SampleGrabber_create(IUnknown *pUnkOuter, LPVOID *ppv) obj->refCount = 1; obj->IBaseFilter_Vtbl = &IBaseFilter_VTable; obj->ISampleGrabber_Vtbl = &ISampleGrabber_VTable; + obj->IMemInputPin_Vtbl = &IMemInputPin_VTable; + obj->pin_in.lpVtbl = &IPin_In_VTable; + obj->pin_in.dir = PINDIR_INPUT; + obj->pin_in.name = pin_in_name; + obj->pin_in.sg = obj; + obj->pin_in.pair = NULL; + obj->pin_out.lpVtbl = &IPin_Out_VTable; + obj->pin_out.dir = PINDIR_OUTPUT; + obj->pin_out.name = pin_out_name; + obj->pin_out.sg = obj; + obj->pin_out.pair = NULL; obj->info.achName[0] = 0; obj->info.pGraph = NULL; obj->state = State_Stopped; + obj->mtype.majortype = GUID_NULL; + obj->mtype.subtype = MEDIASUBTYPE_None; + obj->mtype.formattype = FORMAT_None; obj->allocator = NULL; obj->refClock = NULL; + obj->memOutput = NULL; + obj->grabberIface = NULL; + obj->grabberMethod = -1; + obj->oneShot = OneShot_None; *ppv = obj; return S_OK; diff --git a/dll/directx/quartz/dsoundrender.c b/dll/directx/quartz/dsoundrender.c index edb170da136..1d87a7f0047 100644 --- a/dll/directx/quartz/dsoundrender.c +++ b/dll/directx/quartz/dsoundrender.c @@ -32,6 +32,7 @@ #include "evcode.h" #include "strmif.h" #include "dsound.h" +#include "amaudio.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -45,12 +46,14 @@ static const IPinVtbl DSoundRender_InputPin_Vtbl; static const IBasicAudioVtbl IBasicAudio_Vtbl; static const IReferenceClockVtbl IReferenceClock_Vtbl; static const IMediaSeekingVtbl IMediaSeeking_Vtbl; +static const IAMDirectSoundVtbl IAMDirectSound_Vtbl; typedef struct DSoundRenderImpl { const IBaseFilterVtbl * lpVtbl; const IBasicAudioVtbl *IBasicAudio_vtbl; const IReferenceClockVtbl *IReferenceClock_vtbl; + const IAMDirectSoundVtbl *IAMDirectSound_vtbl; LONG refCount; CRITICAL_SECTION csFilter; @@ -404,6 +407,7 @@ HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv) pDSoundRender->lpVtbl = &DSoundRender_Vtbl; pDSoundRender->IBasicAudio_vtbl = &IBasicAudio_Vtbl; pDSoundRender->IReferenceClock_vtbl = &IReferenceClock_Vtbl; + pDSoundRender->IAMDirectSound_vtbl = &IAMDirectSound_Vtbl; pDSoundRender->refCount = 1; InitializeCriticalSection(&pDSoundRender->csFilter); pDSoundRender->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": DSoundRenderImpl.csFilter"); @@ -473,6 +477,8 @@ static HRESULT WINAPI DSoundRender_QueryInterface(IBaseFilter * iface, REFIID ri *ppv = &This->IReferenceClock_vtbl; else if (IsEqualIID(riid, &IID_IMediaSeeking)) *ppv = &This->mediaSeeking.lpVtbl; + else if (IsEqualIID(riid, &IID_IAMDirectSound)) + *ppv = &This->IAMDirectSound_vtbl; if (*ppv) { @@ -1328,3 +1334,121 @@ static const IMediaSeekingVtbl IMediaSeeking_Vtbl = MediaSeekingImpl_GetRate, MediaSeekingImpl_GetPreroll }; + +/*** IUnknown methods ***/ +static HRESULT WINAPI AMDirectSound_QueryInterface(IAMDirectSound *iface, + REFIID riid, + LPVOID*ppvObj) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj); + + return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj); +} + +static ULONG WINAPI AMDirectSound_AddRef(IAMDirectSound *iface) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + TRACE("(%p/%p)->()\n", This, iface); + + return DSoundRender_AddRef((IBaseFilter*)This); +} + +static ULONG WINAPI AMDirectSound_Release(IAMDirectSound *iface) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + TRACE("(%p/%p)->()\n", This, iface); + + return DSoundRender_Release((IBaseFilter*)This); +} + +/*** IAMDirectSound methods ***/ +static HRESULT WINAPI AMDirectSound_GetDirectSoundInterface(IAMDirectSound *iface, IDirectSound **ds) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, ds); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_GetPrimaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer **buf) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, buf); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_GetSecondaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer **buf) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, buf); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_ReleaseDirectSoundInterface(IAMDirectSound *iface, IDirectSound *ds) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, ds); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_ReleasePrimaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer *buf) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, buf); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_ReleaseSecondaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer *buf) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, buf); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_SetFocusWindow(IAMDirectSound *iface, HWND hwnd, BOOL bgsilent) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p,%d): stub\n", This, iface, hwnd, bgsilent); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AMDirectSound_GetFocusWindow(IAMDirectSound *iface, HWND hwnd) +{ + ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface); + + FIXME("(%p/%p)->(%p): stub\n", This, iface, hwnd); + + return E_NOTIMPL; +} + +static const IAMDirectSoundVtbl IAMDirectSound_Vtbl = +{ + AMDirectSound_QueryInterface, + AMDirectSound_AddRef, + AMDirectSound_Release, + AMDirectSound_GetDirectSoundInterface, + AMDirectSound_GetPrimaryBufferInterface, + AMDirectSound_GetSecondaryBufferInterface, + AMDirectSound_ReleaseDirectSoundInterface, + AMDirectSound_ReleasePrimaryBufferInterface, + AMDirectSound_ReleaseSecondaryBufferInterface, + AMDirectSound_SetFocusWindow, + AMDirectSound_GetFocusWindow +}; diff --git a/dll/directx/quartz/filesource.c b/dll/directx/quartz/filesource.c index 5f6350fb99f..cb9282c8bb5 100644 --- a/dll/directx/quartz/filesource.c +++ b/dll/directx/quartz/filesource.c @@ -395,7 +395,8 @@ static HRESULT WINAPI AsyncReader_QueryInterface(IBaseFilter * iface, REFIID rii return S_OK; } - if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IMediaSeeking) && !IsEqualIID(riid, &IID_IVideoWindow)) + if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IMediaSeeking) && + !IsEqualIID(riid, &IID_IVideoWindow) && !IsEqualIID(riid, &IID_IBasicAudio)) FIXME("No interface for %s!\n", qzdebugstr_guid(riid)); return E_NOINTERFACE; diff --git a/dll/directx/quartz/pin.c b/dll/directx/quartz/pin.c index 2e24d520667..ca34d9331c5 100644 --- a/dll/directx/quartz/pin.c +++ b/dll/directx/quartz/pin.c @@ -765,9 +765,6 @@ HRESULT WINAPI OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDI { assert(pmtCandidate); dump_AM_MEDIA_TYPE(pmtCandidate); - if (!IsEqualGUID(&FORMAT_None, &pmtCandidate->formattype) - && !IsEqualGUID(&GUID_NULL, &pmtCandidate->formattype)) - assert(pmtCandidate->pbFormat); if (( !pmt || CompareMediaTypes(pmt, pmtCandidate, TRUE) ) && (This->pConnectSpecific(iface, pReceivePin, pmtCandidate) == S_OK)) { diff --git a/dll/directx/wine/d3d8/d3d8_main.c b/dll/directx/wine/d3d8/d3d8_main.c index 6300371842a..c471049714b 100644 --- a/dll/directx/wine/d3d8/d3d8_main.c +++ b/dll/directx/wine/d3d8/d3d8_main.c @@ -35,7 +35,7 @@ void WINAPI DebugSetMute(void) { /* nothing to do */ } -IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion) { +IDirect3D8* WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT SDKVersion) { IDirect3D8Impl* object; TRACE("SDKVersion = %x\n", SDKVersion); @@ -79,7 +79,12 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, BOOL bool, DWORD* toto) { HRESULT ret; - FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto); + static BOOL warned; + + if (TRACE_ON(d3d8) || !warned) { + FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto); + warned = TRUE; + } if (!vertexshader) return E_FAIL; @@ -109,7 +114,12 @@ HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL bool, DWORD* toto) { HRESULT ret; - FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto); + static BOOL warned; + + if (TRACE_ON(d3d8) || !warned) { + FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto); + warned = TRUE; + } if (!pixelshader) return E_FAIL; diff --git a/dll/directx/wine/d3d8/d3d8_private.h b/dll/directx/wine/d3d8/d3d8_private.h index 2c5f66f1d5f..4ba399b5d92 100644 --- a/dll/directx/wine/d3d8/d3d8_private.h +++ b/dll/directx/wine/d3d8/d3d8_private.h @@ -275,18 +275,6 @@ HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *devic UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN; -/* ------------------ */ -/* IDirect3DResource8 */ -/* ------------------ */ - -/***************************************************************************** - * Predeclare the interface implementation structures - */ -extern const IDirect3DResource8Vtbl Direct3DResource8_Vtbl DECLSPEC_HIDDEN; - -/***************************************************************************** - * IDirect3DResource8 implementation structure - */ struct IDirect3DResource8Impl { /* IUnknown fields */ diff --git a/dll/directx/wine/d3d8/device.c b/dll/directx/wine/d3d8/device.c index 5365640fd06..11697b2ff26 100644 --- a/dll/directx/wine/d3d8/device.c +++ b/dll/directx/wine/d3d8/device.c @@ -1047,7 +1047,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(LPDIRECT3DDEVICE8 iface) { return hr; } -static HRESULT WINAPI IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) { IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; HRESULT hr; diff --git a/dll/directx/wine/d3d9/d3d9_main.c b/dll/directx/wine/d3d9/d3d9_main.c index 339cc61c3be..c405a5747d7 100644 --- a/dll/directx/wine/d3d9/d3d9_main.c +++ b/dll/directx/wine/d3d9/d3d9_main.c @@ -33,7 +33,7 @@ void WINAPI DebugSetMute(void) { /* nothing to do */ } -IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) { +IDirect3D9* WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT SDKVersion) { IDirect3D9Impl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D9Impl)); object->lpVtbl = &Direct3D9_Vtbl; @@ -53,7 +53,7 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) { return (IDirect3D9*) object; } -HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **direct3d9ex) { +HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **direct3d9ex) { IDirect3D9 *ret; IDirect3D9Impl* object; diff --git a/dll/directx/wine/d3d9/d3d9_private.h b/dll/directx/wine/d3d9/d3d9_private.h index 7736beace67..eb3a032f18b 100644 --- a/dll/directx/wine/d3d9/d3d9_private.h +++ b/dll/directx/wine/d3d9/d3d9_private.h @@ -187,11 +187,6 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(IDirect3DDevice9Ex *iface, UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain) DECLSPEC_HIDDEN; extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex *iface, - D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9 **ppSB) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, - IDirect3DStateBlock9 **ppSB) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9Ex *iface, IDirect3DVertexDeclaration9 *pDecl) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9Ex *iface, @@ -228,9 +223,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(IDirect3DDevi UINT StartRegister, const BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(IDirect3DDevice9Ex *iface, UINT StartRegister, BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface, - D3DQUERYTYPE Type, IDirect3DQuery9 **ppQuery) DECLSPEC_HIDDEN; - /* ---------------- */ /* IDirect3DVolume9 */ @@ -470,6 +462,8 @@ typedef struct IDirect3DStateBlock9Impl { LPDIRECT3DDEVICE9EX parentDevice; } IDirect3DStateBlock9Impl; +HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device, + D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock) DECLSPEC_HIDDEN; /* --------------------------- */ /* IDirect3DVertexDeclaration9 */ @@ -564,4 +558,7 @@ typedef struct IDirect3DQuery9Impl { LPDIRECT3DDEVICE9EX parentDevice; } IDirect3DQuery9Impl; +HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, + D3DQUERYTYPE type) DECLSPEC_HIDDEN; + #endif /* __WINE_D3D9_PRIVATE_H */ diff --git a/dll/directx/wine/d3d9/device.c b/dll/directx/wine/d3d9/device.c index 6b70c84cf27..79a9ba01834 100644 --- a/dll/directx/wine/d3d9/device.c +++ b/dll/directx/wine/d3d9/device.c @@ -248,7 +248,7 @@ static ULONG WINAPI IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9EX iface) { return ref; } -static ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface) { +static ULONG WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; ULONG ref; @@ -452,7 +452,7 @@ static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX ifac return ret; } -static HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDevice9Ex *iface, +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDevice9Ex *iface, D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain9 **swapchain) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; @@ -541,7 +541,7 @@ static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data return ret; } -static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3DPRESENT_PARAMETERS* pPresentationParameters) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3DPRESENT_PARAMETERS* pPresentationParameters) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; WINED3DPRESENT_PARAMETERS localParameters; HRESULT hr; @@ -619,7 +619,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3DP return hr; } -static HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -1182,7 +1182,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX ifac return hr; } -static HRESULT WINAPI IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -1388,7 +1388,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX if return hr; } -static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface, D3DRENDERSTATETYPE State, DWORD Value) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface, D3DRENDERSTATETYPE State, DWORD Value) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -1414,6 +1414,97 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX return hr; } +static HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex *iface, + D3DSTATEBLOCKTYPE type, IDirect3DStateBlock9 **stateblock) +{ + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + IDirect3DStateBlock9Impl *object; + HRESULT hr; + + TRACE("iface %p, type %#x, stateblock %p.\n", iface, type, stateblock); + + if (type != D3DSBT_ALL && type != D3DSBT_PIXELSTATE && type != D3DSBT_VERTEXSTATE) + { + WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL.\n"); + return D3DERR_INVALIDCALL; + } + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate stateblock memory.\n"); + return E_OUTOFMEMORY; + } + + hr = stateblock_init(object, This, type, NULL); + if (FAILED(hr)) + { + WARN("Failed to initialize stateblock, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + TRACE("Created stateblock %p.\n", object); + *stateblock = (IDirect3DStateBlock9 *)object; + + return D3D_OK; +} + +static HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface) +{ + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hr; + + TRACE("iface %p.\n", iface); + + wined3d_mutex_lock(); + hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice); + wined3d_mutex_unlock(); + + return hr; +} + +static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **stateblock) +{ + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + IWineD3DStateBlock *wined3d_stateblock; + IDirect3DStateBlock9Impl *object; + HRESULT hr; + + TRACE("iface %p, stateblock %p.\n", iface, stateblock); + + wined3d_mutex_lock(); + hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice, &wined3d_stateblock); + wined3d_mutex_unlock(); + if (FAILED(hr)) + { + WARN("IWineD3DDevice_EndStateBlock() failed, hr %#x.\n", hr); + return hr; + } + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate stateblock memory.\n"); + IWineD3DStateBlock_Release(wined3d_stateblock); + return E_OUTOFMEMORY; + } + + hr = stateblock_init(object, This, 0, wined3d_stateblock); + if (FAILED(hr)) + { + WARN("Failed to initialize stateblock, hr %#x.\n", hr); + IWineD3DStateBlock_Release(wined3d_stateblock); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + TRACE("Created stateblock %p.\n", object); + *stateblock = (IDirect3DStateBlock9 *)object; + + return D3D_OK; +} + static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX iface, CONST D3DCLIPSTATUS9* pClipStatus) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -1559,7 +1650,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(IDirect3DDevice9Ex *i return hr; } -static HRESULT WINAPI IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; @@ -2178,6 +2269,37 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX ifa return hr; } +static HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface, + D3DQUERYTYPE type, IDirect3DQuery9 **query) +{ + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + IDirect3DQuery9Impl *object; + HRESULT hr; + + TRACE("iface %p, type %#x, query %p.\n", iface, type, query); + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate query memory.\n"); + return E_OUTOFMEMORY; + } + + hr = query_init(object, This, type); + if (FAILED(hr)) + { + WARN("Failed to initialize query, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + TRACE("Created query %p.\n", object); + if (query) *query = (IDirect3DQuery9 *)object; + else IDirect3DQuery9_Release((IDirect3DQuery9 *)object); + + return D3D_OK; +} + static HRESULT WINAPI IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(IDirect3DDevice9Ex *iface, UINT width, UINT height, float *rows, float *columns) { diff --git a/dll/directx/wine/d3d9/directx.c b/dll/directx/wine/d3d9/directx.c index 5f5e8f913d4..1fcc8c47fcf 100644 --- a/dll/directx/wine/d3d9/directx.c +++ b/dll/directx/wine/d3d9/directx.c @@ -407,7 +407,7 @@ static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UIN return ret; } -static HRESULT WINAPI IDirect3D9Impl_CreateDevice(IDirect3D9Ex *iface, UINT adapter, +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9Impl_CreateDevice(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, IDirect3DDevice9 **device) { @@ -465,7 +465,7 @@ static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex *ifa return D3DERR_DRIVERINTERNALERROR; } -static HRESULT WINAPI IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface, +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode, IDirect3DDevice9Ex **device) { diff --git a/dll/directx/wine/d3d9/query.c b/dll/directx/wine/d3d9/query.c index ecb2e718eeb..a38dc9d15fb 100644 --- a/dll/directx/wine/d3d9/query.c +++ b/dll/directx/wine/d3d9/query.c @@ -150,49 +150,24 @@ static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl = IDirect3DQuery9Impl_GetData }; +HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3DQUERYTYPE type) +{ + HRESULT hr; -/* IDirect3DDevice9 IDirect3DQuery9 Methods follow: */ -HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - IDirect3DQuery9Impl *object = NULL; - HRESULT hr = D3D_OK; + query->lpVtbl = &Direct3DQuery9_Vtbl; + query->ref = 1; - TRACE("iface %p, type %#x, query %p.\n", iface, Type, ppQuery); - - if (!ppQuery) + wined3d_mutex_lock(); + hr = IWineD3DDevice_CreateQuery(device->WineD3DDevice, type, &query->wineD3DQuery, (IUnknown *)query); + wined3d_mutex_unlock(); + if (FAILED(hr)) { - wined3d_mutex_lock(); - hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL); - wined3d_mutex_unlock(); - + WARN("Failed to create wined3d query, hr %#x.\n", hr); return hr; } - /* Allocate the storage for the device */ - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl)); - if (NULL == object) { - ERR("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n"); - return D3DERR_OUTOFVIDEOMEMORY; - } + query->parentDevice = (IDirect3DDevice9Ex *)device; + IDirect3DDevice9Ex_AddRef(query->parentDevice); - object->lpVtbl = &Direct3DQuery9_Vtbl; - object->ref = 1; - - wined3d_mutex_lock(); - hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object); - wined3d_mutex_unlock(); - - if (FAILED(hr)) { - - /* free up object */ - WARN("(%p) call to IWineD3DDevice_CreateQuery failed\n", This); - HeapFree(GetProcessHeap(), 0, object); - } else { - IDirect3DDevice9Ex_AddRef(iface); - object->parentDevice = iface; - *ppQuery = (LPDIRECT3DQUERY9) object; - TRACE("(%p) : Created query %p\n", This , object); - } - TRACE("(%p) : returning %x\n", This, hr); - return hr; + return D3D_OK; } diff --git a/dll/directx/wine/d3d9/stateblock.c b/dll/directx/wine/d3d9/stateblock.c index 7cd3ba629e0..c4941db254b 100644 --- a/dll/directx/wine/d3d9/stateblock.c +++ b/dll/directx/wine/d3d9/stateblock.c @@ -123,87 +123,33 @@ static const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl = IDirect3DStateBlock9Impl_Apply }; - -/* IDirect3DDevice9 IDirect3DStateBlock9 Methods follow: */ -HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9EX iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppStateBlock) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - IDirect3DStateBlock9Impl* object; - HRESULT hrc = D3D_OK; - - TRACE("iface %p, type %#x, stateblock %p.\n", iface, Type, ppStateBlock); - - if(Type != D3DSBT_ALL && Type != D3DSBT_PIXELSTATE && - Type != D3DSBT_VERTEXSTATE ) { - WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL\n"); - return D3DERR_INVALIDCALL; - } - - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl)); - if (NULL == object) return E_OUTOFMEMORY; - object->lpVtbl = &Direct3DStateBlock9_Vtbl; - object->ref = 1; - - wined3d_mutex_lock(); - hrc = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &object->wineD3DStateBlock, (IUnknown*)object); - wined3d_mutex_unlock(); - - if(hrc != D3D_OK){ - FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This); - HeapFree(GetProcessHeap(), 0, object); - } else { - IDirect3DDevice9Ex_AddRef(iface); - object->parentDevice = iface; - *ppStateBlock = (IDirect3DStateBlock9*)object; - TRACE("(%p) : Created stateblock %p\n", This, object); - } - TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object); - return hrc; -} - -HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface) +HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device, + D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; - TRACE("iface %p.\n", iface); + stateblock->lpVtbl = &Direct3DStateBlock9_Vtbl; + stateblock->ref = 1; - wined3d_mutex_lock(); - hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice); - wined3d_mutex_unlock(); - - return hr; -} - -HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **ppSB) -{ - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - IWineD3DStateBlock *wineD3DStateBlock; - IDirect3DStateBlock9Impl *object; - HRESULT hr; - - TRACE("iface %p, stateblock %p.\n", iface, ppSB); - - /* Tell wineD3D to endstateblock before anything else (in case we run out - * of memory later and cause locking problems) */ - wined3d_mutex_lock(); - hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock); - wined3d_mutex_unlock(); - - if (hr!= D3D_OK) + if (wined3d_stateblock) { - WARN("IWineD3DDevice_EndStateBlock returned an error\n"); - return hr; + stateblock->wineD3DStateBlock = wined3d_stateblock; + } + else + { + wined3d_mutex_lock(); + hr = IWineD3DDevice_CreateStateBlock(device->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)type, + &stateblock->wineD3DStateBlock, (IUnknown *)stateblock); + wined3d_mutex_unlock(); + if (FAILED(hr)) + { + WARN("Failed to create wined3d stateblock, hr %#x.\n", hr); + return hr; + } } - /* allocate a new IDirectD3DStateBlock */ - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl)); - if (!object) return E_OUTOFMEMORY; - object->ref = 1; - object->lpVtbl = &Direct3DStateBlock9_Vtbl; - object->wineD3DStateBlock = wineD3DStateBlock; - IDirect3DDevice9Ex_AddRef(iface); - object->parentDevice = iface; - *ppSB=(IDirect3DStateBlock9*)object; - TRACE("(%p) Returning *ppSB %p, wineD3DStateBlock %p\n", This, *ppSB, wineD3DStateBlock); + stateblock->parentDevice = (IDirect3DDevice9Ex *)device; + IDirect3DDevice9Ex_AddRef(stateblock->parentDevice); + return D3D_OK; } diff --git a/dll/directx/wine/d3d9/swapchain.c b/dll/directx/wine/d3d9/swapchain.c index 207504559ee..c692371a258 100644 --- a/dll/directx/wine/d3d9/swapchain.c +++ b/dll/directx/wine/d3d9/swapchain.c @@ -79,7 +79,7 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface) } /* IDirect3DSwapChain9 parts follow: */ -static HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) { +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) { IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; HRESULT hr; @@ -269,7 +269,7 @@ HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl return D3D_OK; } -HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) { +HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hrc = D3D_OK; IWineD3DSwapChain *swapchain = NULL; diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36.rbuild b/dll/directx/wine/d3dx9_36/d3dx9_36.rbuild index a09c4055f10..52fc95074c7 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36.rbuild +++ b/dll/directx/wine/d3dx9_36/d3dx9_36.rbuild @@ -22,6 +22,7 @@ shader.c sprite.c surface.c + texture.c util.c version.rc diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36.spec b/dll/directx/wine/d3dx9_36/d3dx9_36.spec index 08bb7f5db60..792408194d2 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36.spec +++ b/dll/directx/wine/d3dx9_36/d3dx9_36.spec @@ -11,7 +11,7 @@ @ stub D3DXCleanMesh @ stdcall D3DXColorAdjustContrast(ptr ptr long) @ stdcall D3DXColorAdjustSaturation(ptr ptr long) -@ stub D3DXCompileShader +@ stdcall D3DXCompileShader(ptr long ptr ptr ptr ptr long ptr ptr ptr) @ stub D3DXCompileShaderFromFileA @ stub D3DXCompileShaderFromFileW @ stub D3DXCompileShaderFromResourceA @@ -92,7 +92,7 @@ @ stub D3DXCreateTeapot @ stub D3DXCreateTextA @ stub D3DXCreateTextW -@ stub D3DXCreateTexture +@ stdcall D3DXCreateTexture(ptr long long long long long long ptr) @ stub D3DXCreateTextureFromFileA @ stub D3DXCreateTextureFromFileExA @ stub D3DXCreateTextureFromFileExW @@ -129,7 +129,7 @@ @ stub D3DXFillVolumeTexture @ stub D3DXFillVolumeTextureTX @ stub D3DXFilterTexture -@ stub D3DXFindShaderComment +@ stdcall D3DXFindShaderComment(ptr long ptr ptr) @ stub D3DXFloat16To32Array @ stub D3DXFloat32To16Array @ stub D3DXFrameAppendChild @@ -157,8 +157,8 @@ @ stdcall D3DXGetImageInfoFromResourceA(long str ptr) @ stdcall D3DXGetImageInfoFromResourceW(long wstr ptr) @ stdcall D3DXGetPixelShaderProfile(ptr) -@ stub D3DXGetShaderConstantTable -@ stub D3DXGetShaderConstantTableEx +@ stdcall D3DXGetShaderConstantTable(ptr ptr) +@ stdcall D3DXGetShaderConstantTableEx(ptr long ptr) @ stub D3DXGetShaderInputSemantics @ stub D3DXGetShaderOutputSemantics @ stub D3DXGetShaderSamplers diff --git a/dll/directx/wine/d3dx9_36/shader.c b/dll/directx/wine/d3dx9_36/shader.c index c05f7b74d90..e4de6b32dca 100644 --- a/dll/directx/wine/d3dx9_36/shader.c +++ b/dll/directx/wine/d3dx9_36/shader.c @@ -23,6 +23,7 @@ #include "windef.h" #include "wingdi.h" #include "d3dx9.h" +#include "d3dx9shader.h" #include "d3dx9_36_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3dx); @@ -134,6 +135,41 @@ LPCSTR WINAPI D3DXGetVertexShaderProfile(LPDIRECT3DDEVICE9 device) return NULL; } +HRESULT WINAPI D3DXFindShaderComment(CONST DWORD* byte_code, DWORD fourcc, LPCVOID* data, UINT* size) +{ + CONST DWORD *ptr = byte_code; + + TRACE("(%p, %x, %p, %p)", byte_code, fourcc, data, size); + + if (!byte_code) + return D3DERR_INVALIDCALL; + + while (*++ptr != D3DSIO_END) + { + /* Check if it is a comment */ + if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT) + { + DWORD comment_size = (*ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT; + + /* Check if this is the comment we are looking for */ + if (*(ptr + 1) == fourcc) + { + UINT ctab_size = (comment_size - 1) * sizeof(DWORD); + LPCVOID ctab_data = ptr + 2; + if (size) + *size = ctab_size; + if (data) + *data = ctab_data; + TRACE("Returning comment data at %p with size %d\n", ctab_data, ctab_size); + return D3D_OK; + } + ptr += comment_size; + } + } + + return S_FALSE; +} + HRESULT WINAPI D3DXAssembleShader(LPCSTR data, UINT data_len, CONST D3DXMACRO* defines, @@ -142,7 +178,7 @@ HRESULT WINAPI D3DXAssembleShader(LPCSTR data, LPD3DXBUFFER* shader, LPD3DXBUFFER* error_messages) { - FIXME("stub\n"); + FIXME("(%p, %d, %p, %p, %x, %p, %p): stub\n", data, data_len, defines, include, flags, shader, error_messages); return D3DERR_INVALIDCALL; } @@ -177,7 +213,7 @@ HRESULT WINAPI D3DXAssembleShaderFromFileW(LPCWSTR filename, LPD3DXBUFFER* shader, LPD3DXBUFFER* error_messages) { - FIXME("stub\n"); + FIXME("(%s, %p, %p, %x, %p, %p): stub\n", debugstr_w(filename), defines, include, flags, shader, error_messages); return D3DERR_INVALIDCALL; } @@ -220,3 +256,382 @@ HRESULT WINAPI D3DXAssembleShaderFromResourceW(HMODULE module, return D3DXAssembleShader(buffer, len, defines, include, flags, shader, error_messages); } + +HRESULT WINAPI D3DXCompileShader(LPCSTR pSrcData, + UINT srcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE * ppConstantTable) +{ + FIXME("(%p, %d, %p, %p, %p, %p, %d, %p, %p, %p): stub\n", + pSrcData, srcDataLen, pDefines, pInclude, pFunctionName, + pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); + return D3DERR_INVALIDCALL; +} + +static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl; + +typedef struct ID3DXConstantTableImpl { + const ID3DXConstantTableVtbl *lpVtbl; + LONG ref; + LPVOID ctab; + DWORD size; +} ID3DXConstantTableImpl; + +/*** IUnknown methods ***/ +static HRESULT WINAPI ID3DXConstantTableImpl_QueryInterface(ID3DXConstantTable* iface, REFIID riid, void** ppvObject) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_ID3DXConstantTable)) + { + ID3DXConstantTable_AddRef(iface); + *ppvObject = This; + return S_OK; + } + + ERR("Interface %s not found\n", debugstr_guid(riid)); + + return E_NOINTERFACE; +} + +static ULONG WINAPI ID3DXConstantTableImpl_AddRef(ID3DXConstantTable* iface) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + TRACE("(%p)->(): AddRef from %d\n", This, This->ref); + + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI ID3DXConstantTableImpl_Release(ID3DXConstantTable* iface) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(): Release from %d\n", This, ref + 1); + + if (!ref) + { + HeapFree(GetProcessHeap(), 0, This->ctab); + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +/*** ID3DXBuffer methods ***/ +static LPVOID WINAPI ID3DXConstantTableImpl_GetBufferPointer(ID3DXConstantTable* iface) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + TRACE("(%p)->()\n", This); + + return This->ctab; +} + +static DWORD WINAPI ID3DXConstantTableImpl_GetBufferSize(ID3DXConstantTable* iface) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + TRACE("(%p)->()\n", This); + + return This->size; +} + +/*** ID3DXConstantTable methods ***/ +static HRESULT WINAPI ID3DXConstantTableImpl_GetDesc(ID3DXConstantTable* iface, D3DXCONSTANTTABLE_DESC *desc) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p): stub\n", This, desc); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_GetConstantDesc(ID3DXConstantTable* iface, D3DXHANDLE constant, + D3DXCONSTANT_DESC *desc, UINT *count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p): stub\n", This, constant, desc, count); + + return E_NOTIMPL; +} + +static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstant(ID3DXConstantTable* iface, D3DXHANDLE constant, UINT index) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %d): stub\n", This, constant, index); + + return NULL; +} + +static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantByName(ID3DXConstantTable* iface, D3DXHANDLE constant, LPCSTR name) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %s): stub\n", This, constant, name); + + return NULL; +} + +static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantByElement(ID3DXConstantTable* iface, D3DXHANDLE constant, UINT index) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %d): stub\n", This, constant, index); + + return NULL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetDefaults(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p): stub\n", This, device); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetValue(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, LPCVOID data, UINT bytes) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, data, bytes); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetBool(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, BOOL b) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %d): stub\n", This, device, constant, b); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetBoolArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST BOOL* b, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, b, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetInt(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, D3DXHANDLE constant, INT n) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %d): stub\n", This, device, constant, n); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetIntArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST INT* n, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, n, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetFloat(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, FLOAT f) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %f): stub\n", This, device, constant, f); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetFloatArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST FLOAT* f, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, f, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetVector(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXVECTOR4* vector) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p): stub\n", This, device, constant, vector); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetVectorArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXVECTOR4* vector, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, vector, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrix(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX* matrix) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p): stub\n", This, device, constant, matrix); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX* matrix, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, matrix, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixPointerArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX** matrix, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, matrix, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTranspose(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX* matrix) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p): stub\n", This, device, constant, matrix); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTransposeArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX* matrix, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, matrix, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixTransposePointerArray(ID3DXConstantTable* iface, LPDIRECT3DDEVICE9 device, + D3DXHANDLE constant, CONST D3DXMATRIX** matrix, UINT count) +{ + ID3DXConstantTableImpl *This = (ID3DXConstantTableImpl *)iface; + + FIXME("(%p)->(%p, %p, %p, %d): stub\n", This, device, constant, matrix, count); + + return E_NOTIMPL; +} + +static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl = +{ + /*** IUnknown methods ***/ + ID3DXConstantTableImpl_QueryInterface, + ID3DXConstantTableImpl_AddRef, + ID3DXConstantTableImpl_Release, + /*** ID3DXBuffer methods ***/ + ID3DXConstantTableImpl_GetBufferPointer, + ID3DXConstantTableImpl_GetBufferSize, + /*** ID3DXConstantTable methods ***/ + ID3DXConstantTableImpl_GetDesc, + ID3DXConstantTableImpl_GetConstantDesc, + ID3DXConstantTableImpl_GetConstant, + ID3DXConstantTableImpl_GetConstantByName, + ID3DXConstantTableImpl_GetConstantByElement, + ID3DXConstantTableImpl_SetDefaults, + ID3DXConstantTableImpl_SetValue, + ID3DXConstantTableImpl_SetBool, + ID3DXConstantTableImpl_SetBoolArray, + ID3DXConstantTableImpl_SetInt, + ID3DXConstantTableImpl_SetIntArray, + ID3DXConstantTableImpl_SetFloat, + ID3DXConstantTableImpl_SetFloatArray, + ID3DXConstantTableImpl_SetVector, + ID3DXConstantTableImpl_SetVectorArray, + ID3DXConstantTableImpl_SetMatrix, + ID3DXConstantTableImpl_SetMatrixArray, + ID3DXConstantTableImpl_SetMatrixPointerArray, + ID3DXConstantTableImpl_SetMatrixTranspose, + ID3DXConstantTableImpl_SetMatrixTransposeArray, + ID3DXConstantTableImpl_SetMatrixTransposePointerArray +}; + +HRESULT WINAPI D3DXGetShaderConstantTableEx(CONST DWORD* pFunction, + DWORD flags, + LPD3DXCONSTANTTABLE* ppConstantTable) +{ + ID3DXConstantTableImpl* object; + HRESULT hr; + LPCVOID data; + UINT size; + + FIXME("(%p, %x, %p): semi-stub\n", pFunction, flags, ppConstantTable); + + if (!pFunction || !ppConstantTable) + return D3DERR_INVALIDCALL; + + hr = D3DXFindShaderComment(pFunction, MAKEFOURCC('C','T','A','B'), &data, &size); + if (hr != D3D_OK) + return D3DXERR_INVALIDDATA; + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXConstantTableImpl)); + if (!object) + { + ERR("Out of memory\n"); + return E_OUTOFMEMORY; + } + + object->lpVtbl = &ID3DXConstantTable_Vtbl; + object->ref = 1; + + object->ctab = HeapAlloc(GetProcessHeap(), 0, size); + if (!object->ctab) + { + HeapFree(GetProcessHeap(), 0, object); + ERR("Out of memory\n"); + return E_OUTOFMEMORY; + } + object->size = size; + memcpy(object->ctab, data, object->size); + + *ppConstantTable = (LPD3DXCONSTANTTABLE)object; + + return D3D_OK; +} + +HRESULT WINAPI D3DXGetShaderConstantTable(CONST DWORD* pFunction, + LPD3DXCONSTANTTABLE* ppConstantTable) +{ + TRACE("(%p, %p): Forwarded to D3DXGetShaderConstantTableEx\n", pFunction, ppConstantTable); + + return D3DXGetShaderConstantTableEx(pFunction, 0, ppConstantTable); +} diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index 4d8d1f61346..6de6de77ab2 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -47,7 +47,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx); */ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(LPCVOID data, UINT datasize, D3DXIMAGE_INFO *info) { - FIXME("stub\n"); + FIXME("(%p, %d, %p): stub\n", data, datasize, info); if(data && datasize && !info) return D3D_OK; if( !data || !datasize ) return D3DERR_INVALIDCALL; @@ -193,7 +193,9 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(LPDIRECT3DSURFACE9 pDestSurface, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo) { - FIXME("stub\n"); + FIXME("(%p, %p, %p, %p, %d, %p, %d, %x, %p): stub\n", pDestSurface, pDestPalette, + pDestRect, pSrcData, SrcDataSize, pSrcRect, dwFilter, Colorkey, pSrcInfo); + if( !pDestSurface || !pSrcData | !SrcDataSize ) return D3DERR_INVALIDCALL; return E_NOTIMPL; } diff --git a/dll/directx/wine/d3dx9_36/texture.c b/dll/directx/wine/d3dx9_36/texture.c new file mode 100644 index 00000000000..f47853a89df --- /dev/null +++ b/dll/directx/wine/d3dx9_36/texture.c @@ -0,0 +1,37 @@ +/* + * Copyright 2010 Christian Costa + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "wine/debug.h" +#include "d3dx9_36_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + +HRESULT WINAPI D3DXCreateTexture(LPDIRECT3DDEVICE9 pDevice, + UINT width, + UINT height, + UINT miplevels, + DWORD usage, + D3DFORMAT format, + D3DPOOL pool, + LPDIRECT3DTEXTURE9 *ppTexture) +{ + FIXME("(%p, %d, %d, %d, %x, %x, %x, %p): semi-stub\n", pDevice, width, height, miplevels, usage, format, + pool, ppTexture); + + return IDirect3DDevice9_CreateTexture(pDevice, width, height, miplevels, usage, format, pool, ppTexture, NULL); +} diff --git a/dll/directx/wine/ddraw/device.c b/dll/directx/wine/ddraw/device.c index 67fc6f5e266..13ecfa133ac 100644 --- a/dll/directx/wine/ddraw/device.c +++ b/dll/directx/wine/ddraw/device.c @@ -1705,13 +1705,13 @@ IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7 *iface) else return D3DERR_SCENE_NOT_IN_SCENE; } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_7_EndScene_FPUSetup(IDirect3DDevice7 *iface) { return IDirect3DDeviceImpl_7_EndScene(iface); } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_7_EndScene_FPUPreserve(IDirect3DDevice7 *iface) { HRESULT hr; @@ -1724,7 +1724,7 @@ IDirect3DDeviceImpl_7_EndScene_FPUPreserve(IDirect3DDevice7 *iface) return hr; } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3 *iface) { IDirect3DDeviceImpl *This = device_from_device3(iface); @@ -1732,7 +1732,7 @@ Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3 *iface) return IDirect3DDevice7_EndScene((IDirect3DDevice7 *)This); } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2 *iface) { IDirect3DDeviceImpl *This = device_from_device2(iface); @@ -1740,7 +1740,7 @@ Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2 *iface) return IDirect3DDevice7_EndScene((IDirect3DDevice7 *)This); } -static HRESULT WINAPI +static HRESULT WINAPI DECLSPEC_HOTPATCH Thunk_IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice *iface) { IDirect3DDeviceImpl *This = device_from_device1(iface); @@ -2580,7 +2580,8 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface, } if (!(colorop == WINED3DTOP_MODULATE && colorarg1 == WINED3DTA_TEXTURE && colorarg2 == WINED3DTA_CURRENT && - alphaop == WINED3DTOP_SELECTARG1 && alphaarg1 == (tex_alpha ? WINED3DTA_TEXTURE : WINED3DTA_CURRENT))) + alphaop == (tex_alpha ? WINED3DTOP_SELECTARG1 : WINED3DTOP_SELECTARG2) && + alphaarg1 == WINED3DTA_TEXTURE && alphaarg2 == WINED3DTA_CURRENT)) { ERR("Unexpected texture stage state setup, returning D3DTBLEND_MODULATE - likely erroneous\n"); } @@ -2852,16 +2853,12 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface, IWineD3DBaseTexture_Release(tex); } - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1); if (tex_alpha) - { - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE); - } + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1); else - { - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_CURRENT); - } - + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2); + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE); + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT); IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE); IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT); IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE); @@ -4664,15 +4661,11 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface, IWineD3DBaseTexture_Release(tex); } - /* alphaop is WINED3DTOP_SELECTARG1 if it's D3DTBLEND_MODULATE, so only modify alphaarg1 */ + /* Arg 1/2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */ if (tex_alpha) - { - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE); - } + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1); else - { - IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_CURRENT); - } + IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2); } LeaveCriticalSection(&ddraw_cs); diff --git a/dll/directx/wine/ddraw/main.c b/dll/directx/wine/ddraw/main.c index 079800d9a2b..bc23987ed81 100644 --- a/dll/directx/wine/ddraw/main.c +++ b/dll/directx/wine/ddraw/main.c @@ -302,7 +302,7 @@ err_out: * Arguments, return values: See DDRAW_Create * ***********************************************************************/ -HRESULT WINAPI +HRESULT WINAPI DECLSPEC_HOTPATCH DirectDrawCreate(GUID *GUID, LPDIRECTDRAW *DD, IUnknown *UnkOuter) @@ -325,7 +325,7 @@ DirectDrawCreate(GUID *GUID, * Arguments, return values: See DDRAW_Create * ***********************************************************************/ -HRESULT WINAPI +HRESULT WINAPI DECLSPEC_HOTPATCH DirectDrawCreateEx(GUID *GUID, LPVOID *DD, REFIID iid, @@ -742,14 +742,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) */ HRESULT WINAPI DllCanUnloadNow(void) { - HRESULT hr; - FIXME("(void): stub\n"); - - EnterCriticalSection(&ddraw_cs); - hr = S_FALSE; - LeaveCriticalSection(&ddraw_cs); - - return hr; + return S_FALSE; } /******************************************************************************* diff --git a/dll/directx/wine/ddraw/vertexbuffer.c b/dll/directx/wine/ddraw/vertexbuffer.c index df7528b45cb..f16cf124392 100644 --- a/dll/directx/wine/ddraw/vertexbuffer.c +++ b/dll/directx/wine/ddraw/vertexbuffer.c @@ -236,8 +236,17 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface, IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface; WINED3DBUFFER_DESC Desc; HRESULT hr; + DWORD wined3d_flags = 0; TRACE("(%p)->(%08x,%p,%p)\n", This, Flags, Data, Size); + /* Writeonly: Pointless. Event: Unsupported by native according to the sdk + * nosyslock: Not applicable + */ + if(!(Flags & DDLOCK_WAIT)) wined3d_flags |= WINED3DLOCK_DONOTWAIT; + if(Flags & DDLOCK_READONLY) wined3d_flags |= WINED3DLOCK_READONLY; + if(Flags & DDLOCK_NOOVERWRITE) wined3d_flags |= WINED3DLOCK_NOOVERWRITE; + if(Flags & DDLOCK_DISCARDCONTENTS) wined3d_flags |= WINED3DLOCK_DISCARD; + EnterCriticalSection(&ddraw_cs); if(Size) { @@ -253,7 +262,7 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface, } hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, 0 /* OffsetToLock */, - 0 /* SizeToLock, 0 == Full lock */, (BYTE **)Data, Flags); + 0 /* SizeToLock, 0 == Full lock */, (BYTE **)Data, wined3d_flags); LeaveCriticalSection(&ddraw_cs); return hr; } diff --git a/dll/directx/wine/ddraw/viewport.c b/dll/directx/wine/ddraw/viewport.c index 9b0698903f5..b637df1b0f5 100644 --- a/dll/directx/wine/ddraw/viewport.c +++ b/dll/directx/wine/ddraw/viewport.c @@ -255,14 +255,25 @@ IDirect3DViewportImpl_GetViewport(IDirect3DViewport3 *iface, TRACE("(%p/%p)->(%p)\n", This, iface, lpData); EnterCriticalSection(&ddraw_cs); - if (This->use_vp2 != 0) { - ERR(" Requesting to get a D3DVIEWPORT struct where a D3DVIEWPORT2 was set !\n"); - LeaveCriticalSection(&ddraw_cs); - return DDERR_INVALIDPARAMS; - } dwSize = lpData->dwSize; memset(lpData, 0, dwSize); - memcpy(lpData, &(This->viewports.vp1), dwSize); + if (!This->use_vp2) + memcpy(lpData, &(This->viewports.vp1), dwSize); + else { + D3DVIEWPORT vp1; + vp1.dwSize = sizeof(vp1); + vp1.dwX = This->viewports.vp2.dwX; + vp1.dwY = This->viewports.vp2.dwY; + vp1.dwWidth = This->viewports.vp2.dwWidth; + vp1.dwHeight = This->viewports.vp2.dwHeight; + vp1.dvMaxX = 0.0; + vp1.dvMaxY = 0.0; + vp1.dvScaleX = 0.0; + vp1.dvScaleY = 0.0; + vp1.dvMinZ = This->viewports.vp2.dvMinZ; + vp1.dvMaxZ = This->viewports.vp2.dvMaxZ; + memcpy(lpData, &vp1, dwSize); + } if (TRACE_ON(d3d7)) { TRACE(" returning D3DVIEWPORT :\n"); @@ -908,14 +919,25 @@ IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface, TRACE("(%p)->(%p)\n", This, lpData); EnterCriticalSection(&ddraw_cs); - if (This->use_vp2 != 1) { - ERR(" Requesting to get a D3DVIEWPORT2 struct where a D3DVIEWPORT was set !\n"); - LeaveCriticalSection(&ddraw_cs); - return DDERR_INVALIDPARAMS; - } dwSize = lpData->dwSize; memset(lpData, 0, dwSize); - memcpy(lpData, &(This->viewports.vp2), dwSize); + if (This->use_vp2) + memcpy(lpData, &(This->viewports.vp2), dwSize); + else { + D3DVIEWPORT2 vp2; + vp2.dwSize = sizeof(vp2); + vp2.dwX = This->viewports.vp1.dwX; + vp2.dwY = This->viewports.vp1.dwY; + vp2.dwWidth = This->viewports.vp1.dwWidth; + vp2.dwHeight = This->viewports.vp1.dwHeight; + vp2.dvClipX = 0.0; + vp2.dvClipY = 0.0; + vp2.dvClipWidth = 0.0; + vp2.dvClipHeight = 0.0; + vp2.dvMinZ = This->viewports.vp1.dvMinZ; + vp2.dvMaxZ = This->viewports.vp1.dvMaxZ; + memcpy(lpData, &vp2, dwSize); + } if (TRACE_ON(d3d7)) { TRACE(" returning D3DVIEWPORT2 :\n"); diff --git a/dll/directx/wine/wined3d/arb_program_shader.c b/dll/directx/wine/wined3d/arb_program_shader.c index 1fdae2a4105..cf7638605eb 100644 --- a/dll/directx/wine/wined3d/arb_program_shader.c +++ b/dll/directx/wine/wined3d/arb_program_shader.c @@ -41,6 +41,45 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d); #define GLINFO_LOCATION (*gl_info) +/* Extract a line. Note that this modifies the source string. */ +static char *get_line(char **ptr) +{ + char *p, *q; + + p = *ptr; + if (!(q = strstr(p, "\n"))) + { + if (!*p) return NULL; + *ptr += strlen(p); + return p; + } + *q = '\0'; + *ptr = q + 1; + + return p; +} + +static void shader_arb_dump_program_source(const char *source) +{ + unsigned long source_size; + char *ptr, *line, *tmp; + + source_size = strlen(source) + 1; + tmp = HeapAlloc(GetProcessHeap(), 0, source_size); + if (!tmp) + { + ERR("Failed to allocate %lu bytes for shader source.\n", source_size); + return; + } + memcpy(tmp, source, source_size); + + ptr = tmp; + while ((line = get_line(&ptr))) FIXME(" %s\n", line); + FIXME("\n"); + + HeapFree(GetProcessHeap(), 0, tmp); +} + /* GL locking for state handlers is done by the caller. */ static BOOL need_mova_const(IWineD3DBaseShader *shader, const struct wined3d_gl_info *gl_info) { @@ -1122,10 +1161,10 @@ static void gen_color_correction(struct wined3d_shader_buffer *buffer, const cha { DWORD mask; - if (is_yuv_fixup(fixup)) + if (is_complex_fixup(fixup)) { - enum yuv_fixup yuv_fixup = get_yuv_fixup(fixup); - FIXME("YUV fixup (%#x) not supported\n", yuv_fixup); + enum complex_fixup complex_fixup = get_complex_fixup(fixup); + FIXME("Complex fixup (%#x) not supported\n", complex_fixup); return; } @@ -1761,8 +1800,8 @@ static void pshader_hw_texkill(const struct wined3d_shader_instruction *ins) static void pshader_hw_tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; const struct wined3d_shader_dst_param *dst = &ins->dst[0]; DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major, ins->ctx->reg_maps->shader_version.minor); @@ -1856,8 +1895,8 @@ static void pshader_hw_texcoord(const struct wined3d_shader_instruction *ins) static void pshader_hw_texreg2ar(const struct wined3d_shader_instruction *ins) { struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; DWORD flags; DWORD reg1 = ins->dst[0].reg.idx; @@ -1904,7 +1943,8 @@ static void pshader_hw_texreg2rgb(const struct wined3d_shader_instruction *ins) static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device; const struct wined3d_shader_dst_param *dst = &ins->dst[0]; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; char reg_coord[40], dst_reg[50], src_reg[50]; @@ -1936,8 +1976,8 @@ static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) /* with projective textures, texbem only divides the static texture coord, not the displacement, * so we can't let the GL handle this. */ - if (((IWineD3DDeviceImpl*) This->baseShader.device)->stateBlock->textureState[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS] - & WINED3DTTFF_PROJECTED) { + if (device->stateBlock->textureState[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS] & WINED3DTTFF_PROJECTED) + { shader_addline(buffer, "RCP TB.w, %s.w;\n", reg_coord); shader_addline(buffer, "MUL TB.xy, %s, TB.w;\n", reg_coord); shader_addline(buffer, "ADD TA.xy, TA, TB;\n"); @@ -1975,8 +2015,8 @@ static void pshader_hw_texm3x2pad(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; DWORD flags; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; @@ -1997,10 +2037,10 @@ static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char src0_name[50], dst_name[50]; struct wined3d_shader_register tmp_reg = ins->dst[0].reg; BOOL is_color; @@ -2020,12 +2060,12 @@ static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD flags; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char dst_str[50]; char src0_name[50], dst_name[50]; BOOL is_color; @@ -2043,12 +2083,12 @@ static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD flags; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char dst_str[50]; char src0_name[50]; char dst_reg[50]; @@ -2085,11 +2125,11 @@ static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD flags; DWORD reg = ins->dst[0].reg.idx; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; char dst_str[50]; char src0_name[50]; @@ -3046,8 +3086,9 @@ static GLuint create_arb_blt_vertex_program(const struct wined3d_gl_info *gl_inf glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); if (pos != -1) { - FIXME("Vertex program error at position %d: %s\n", pos, + FIXME("Vertex program error at position %d: %s\n\n", pos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(blt_vprogram); } else { @@ -3108,8 +3149,9 @@ static GLuint create_arb_blt_fragment_program(const struct wined3d_gl_info *gl_i glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); if (pos != -1) { - FIXME("Fragment program error at position %d: %s\n", pos, + FIXME("Fragment program error at position %d: %s\n\n", pos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(blt_fprograms[tex_type]); } else { @@ -3564,8 +3606,9 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos); if (errPos != -1) { - FIXME("HW PixelShader Error at position %d: %s\n", + FIXME("HW PixelShader Error at position %d: %s\n\n", errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer->buffer); retval = 0; } else @@ -3974,8 +4017,9 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos); if (errPos != -1) { - FIXME("HW VertexShader Error at position %d: %s\n", + FIXME("HW VertexShader Error at position %d: %s\n\n", errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer->buffer); ret = -1; } else @@ -4448,8 +4492,7 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) { if (shader_is_pshader_version(baseShader->baseShader.reg_maps.shader_version.type)) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface; - struct arb_pshader_private *shader_data = This->baseShader.backend_data; + struct arb_pshader_private *shader_data = baseShader->baseShader.backend_data; UINT i; if(!shader_data) return; /* This can happen if a shader was never compiled */ @@ -4471,10 +4514,11 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) { HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); HeapFree(GetProcessHeap(), 0, shader_data); - This->baseShader.backend_data = NULL; - } else { - IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *) iface; - struct arb_vshader_private *shader_data = This->baseShader.backend_data; + baseShader->baseShader.backend_data = NULL; + } + else + { + struct arb_vshader_private *shader_data = baseShader->baseShader.backend_data; UINT i; if(!shader_data) return; /* This can happen if a shader was never compiled */ @@ -4496,7 +4540,7 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) { HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); HeapFree(GetProcessHeap(), 0, shader_data); - This->baseShader.backend_data = NULL; + baseShader->baseShader.backend_data = NULL; } } @@ -4565,8 +4609,7 @@ static BOOL shader_arb_dirty_const(IWineD3DDevice *iface) { return TRUE; } -static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, - struct shader_caps *pCaps) +static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps) { DWORD vs_consts = min(gl_info->limits.arb_vs_float_constants, gl_info->limits.arb_vs_native_constants); DWORD ps_consts = min(gl_info->limits.arb_ps_float_constants, gl_info->limits.arb_ps_native_constants); @@ -4574,7 +4617,7 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_ /* We don't have an ARB fixed function pipeline yet, so let the none backend set its caps, * then overwrite the shader specific ones */ - none_shader_backend.shader_get_caps(devtype, gl_info, pCaps); + none_shader_backend.shader_get_caps(gl_info, pCaps); if (gl_info->supported[ARB_VERTEX_PROGRAM]) { @@ -4630,8 +4673,8 @@ static BOOL shader_arb_color_fixup_supported(struct color_fixup_desc fixup) dump_color_fixup_desc(fixup); } - /* We support everything except YUV conversions. */ - if (!is_yuv_fixup(fixup)) + /* We support everything except complex conversions. */ + if (!is_complex_fixup(fixup)) { TRACE("[OK]\n"); return TRUE; @@ -4678,6 +4721,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_CMP */ pshader_hw_cmp, /* WINED3DSIH_CND */ pshader_hw_cnd, /* WINED3DSIH_CRS */ shader_hw_map2gl, + /* WINED3DSIH_CUT */ NULL, /* WINED3DSIH_DCL */ NULL, /* WINED3DSIH_DEF */ NULL, /* WINED3DSIH_DEFB */ NULL, @@ -4689,20 +4733,24 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_DSX */ shader_hw_map2gl, /* WINED3DSIH_DSY */ shader_hw_dsy, /* WINED3DSIH_ELSE */ shader_hw_else, + /* WINED3DSIH_EMIT */ NULL, /* WINED3DSIH_ENDIF */ shader_hw_endif, /* WINED3DSIH_ENDLOOP */ shader_hw_endloop, /* WINED3DSIH_ENDREP */ shader_hw_endrep, /* WINED3DSIH_EXP */ shader_hw_scalar_op, /* WINED3DSIH_EXPP */ shader_hw_scalar_op, /* WINED3DSIH_FRC */ shader_hw_map2gl, + /* WINED3DSIH_IADD */ NULL, /* WINED3DSIH_IF */ NULL /* Hardcoded into the shader */, /* WINED3DSIH_IFC */ shader_hw_ifc, + /* WINED3DSIH_IGE */ NULL, /* WINED3DSIH_LABEL */ shader_hw_label, /* WINED3DSIH_LIT */ shader_hw_map2gl, /* WINED3DSIH_LOG */ shader_hw_log_pow, /* WINED3DSIH_LOGP */ shader_hw_log_pow, /* WINED3DSIH_LOOP */ shader_hw_loop, /* WINED3DSIH_LRP */ shader_hw_lrp, + /* WINED3DSIH_LT */ NULL, /* WINED3DSIH_M3x2 */ shader_hw_mnxn, /* WINED3DSIH_M3x3 */ shader_hw_mnxn, /* WINED3DSIH_M3x4 */ shader_hw_mnxn, @@ -5229,7 +5277,7 @@ static void arbfp_free(IWineD3DDevice *iface) { } } -static void arbfp_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps) +static void arbfp_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps) { caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE | WINED3DTEXOPCAPS_SELECTARG1 | @@ -5858,8 +5906,9 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWi glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); if (pos != -1) { - FIXME("Fragment program error at position %d: %s\n", pos, + FIXME("Fragment program error at position %d: %s\n\n", pos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer.buffer); } else { @@ -6180,6 +6229,7 @@ struct arbfp_blit_priv { GLenum yuy2_rect_shader, yuy2_2d_shader; GLenum uyvy_rect_shader, uyvy_2d_shader; GLenum yv12_rect_shader, yv12_2d_shader; + GLenum p8_rect_shader, p8_2d_shader; }; static HRESULT arbfp_blit_alloc(IWineD3DDevice *iface) { @@ -6204,20 +6254,22 @@ static void arbfp_blit_free(IWineD3DDevice *iface) { GL_EXTCALL(glDeleteProgramsARB(1, &priv->uyvy_2d_shader)); GL_EXTCALL(glDeleteProgramsARB(1, &priv->yv12_rect_shader)); GL_EXTCALL(glDeleteProgramsARB(1, &priv->yv12_2d_shader)); - checkGLcall("Delete yuv programs"); + GL_EXTCALL(glDeleteProgramsARB(1, &priv->p8_rect_shader)); + GL_EXTCALL(glDeleteProgramsARB(1, &priv->p8_2d_shader)); + checkGLcall("Delete yuv and p8 programs"); LEAVE_GL(); HeapFree(GetProcessHeap(), 0, device->blit_priv); device->blit_priv = NULL; } -static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum yuv_fixup yuv_fixup, +static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum complex_fixup fixup, GLenum textype, char *luminance) { char chroma; const char *tex, *texinstr; - if (yuv_fixup == YUV_FIXUP_UYVY) { + if (fixup == COMPLEX_FIXUP_UYVY) { chroma = 'x'; *luminance = 'w'; } else { @@ -6445,8 +6497,74 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, GLenum textype, return TRUE; } +static GLuint gen_p8_shader(IWineD3DDeviceImpl *device, GLenum textype) +{ + GLenum shader; + struct wined3d_shader_buffer buffer; + struct arbfp_blit_priv *priv = device->blit_priv; + GLint pos; + + /* Shader header */ + if (!shader_buffer_init(&buffer)) + { + ERR("Failed to initialize shader buffer.\n"); + return 0; + } + + ENTER_GL(); + GL_EXTCALL(glGenProgramsARB(1, &shader)); + GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader)); + LEAVE_GL(); + if(!shader) { + shader_buffer_free(&buffer); + return 0; + } + + shader_addline(&buffer, "!!ARBfp1.0\n"); + shader_addline(&buffer, "TEMP index;\n"); + + /* { 255/256, 0.5/255*255/256, 0, 0 } */ + shader_addline(&buffer, "PARAM constants = { 0.996, 0.00195, 0, 0 };\n"); + + /* The alpha-component contains the palette index */ + if(textype == GL_TEXTURE_RECTANGLE_ARB) + shader_addline(&buffer, "TXP index, fragment.texcoord[0], texture[0], RECT;\n"); + else + shader_addline(&buffer, "TEX index, fragment.texcoord[0], texture[0], 2D;\n"); + + /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */ + shader_addline(&buffer, "MAD index.a, index.a, constants.x, constants.y;\n"); + + /* Use the alpha-component as an index in the palette to get the final color */ + shader_addline(&buffer, "TEX result.color, index.a, texture[1], 1D;\n"); + shader_addline(&buffer, "END\n"); + + ENTER_GL(); + GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(buffer.buffer), buffer.buffer)); + checkGLcall("glProgramStringARB()"); + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); + if (pos != -1) + { + FIXME("Fragment program error at position %d: %s\n\n", pos, + debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer.buffer); + } + + if (textype == GL_TEXTURE_RECTANGLE_ARB) + priv->p8_rect_shader = shader; + else + priv->p8_2d_shader = shader; + + shader_buffer_free(&buffer); + LEAVE_GL(); + + return shader; +} + /* Context activation is done by the caller. */ -static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixup, GLenum textype) +static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum complex_fixup yuv_fixup, GLenum textype) { GLenum shader; struct wined3d_shader_buffer buffer; @@ -6519,8 +6637,8 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu switch (yuv_fixup) { - case YUV_FIXUP_UYVY: - case YUV_FIXUP_YUY2: + case COMPLEX_FIXUP_UYVY: + case COMPLEX_FIXUP_YUY2: if (!gen_planar_yuv_read(&buffer, yuv_fixup, textype, &luminance_component)) { shader_buffer_free(&buffer); @@ -6528,7 +6646,7 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu } break; - case YUV_FIXUP_YV12: + case COMPLEX_FIXUP_YV12: if (!gen_yv12_read(&buffer, textype, &luminance_component)) { shader_buffer_free(&buffer); @@ -6562,8 +6680,9 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); if (pos != -1) { - FIXME("Fragment program error at position %d: %s\n", pos, + FIXME("Fragment program error at position %d: %s\n\n", pos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); + shader_arb_dump_program_source(buffer.buffer); } else { @@ -6579,20 +6698,22 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixu switch (yuv_fixup) { - case YUV_FIXUP_YUY2: + case COMPLEX_FIXUP_YUY2: if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yuy2_rect_shader = shader; else priv->yuy2_2d_shader = shader; break; - case YUV_FIXUP_UYVY: + case COMPLEX_FIXUP_UYVY: if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->uyvy_rect_shader = shader; else priv->uyvy_2d_shader = shader; break; - case YUV_FIXUP_YV12: + case COMPLEX_FIXUP_YV12: if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yv12_rect_shader = shader; else priv->yv12_2d_shader = shader; break; + default: + ERR("Unsupported complex fixup: %d\n", yuv_fixup); } return shader; @@ -6606,9 +6727,9 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatD IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface; float size[4] = {width, height, 1, 1}; struct arbfp_blit_priv *priv = device->blit_priv; - enum yuv_fixup yuv_fixup; + enum complex_fixup fixup; - if (!is_yuv_fixup(format_desc->color_fixup)) + if (!is_complex_fixup(format_desc->color_fixup)) { TRACE("Fixup:\n"); dump_color_fixup_desc(format_desc->color_fixup); @@ -6620,24 +6741,29 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatD return WINED3D_OK; } - yuv_fixup = get_yuv_fixup(format_desc->color_fixup); + fixup = get_complex_fixup(format_desc->color_fixup); - switch(yuv_fixup) + switch(fixup) { - case YUV_FIXUP_YUY2: + case COMPLEX_FIXUP_YUY2: shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yuy2_rect_shader : priv->yuy2_2d_shader; break; - case YUV_FIXUP_UYVY: + case COMPLEX_FIXUP_UYVY: shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->uyvy_rect_shader : priv->uyvy_2d_shader; break; - case YUV_FIXUP_YV12: + case COMPLEX_FIXUP_YV12: shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yv12_rect_shader : priv->yv12_2d_shader; break; + case COMPLEX_FIXUP_P8: + shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->p8_rect_shader : priv->p8_2d_shader; + if (!shader) shader = gen_p8_shader(device, textype); + break; + default: - FIXME("Unsupported YUV fixup %#x, not setting a shader\n", yuv_fixup); + FIXME("Unsupported complex fixup %#x, not setting a shader\n", fixup); ENTER_GL(); glEnable(textype); checkGLcall("glEnable(textype)"); @@ -6645,7 +6771,7 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatD return E_NOTIMPL; } - if (!shader) shader = gen_yuv_shader(device, yuv_fixup, textype); + if (!shader) shader = gen_yuv_shader(device, fixup, textype); ENTER_GL(); glEnable(GL_FRAGMENT_PROGRAM_ARB); @@ -6684,7 +6810,7 @@ static void arbfp_blit_unset(IWineD3DDevice *iface) { static BOOL arbfp_blit_color_fixup_supported(struct color_fixup_desc fixup) { - enum yuv_fixup yuv_fixup; + enum complex_fixup complex_fixup; if (TRACE_ON(d3d_shader) && TRACE_ON(d3d)) { @@ -6699,23 +6825,24 @@ static BOOL arbfp_blit_color_fixup_supported(struct color_fixup_desc fixup) } /* We only support YUV conversions. */ - if (!is_yuv_fixup(fixup)) + if (!is_complex_fixup(fixup)) { TRACE("[FAILED]\n"); return FALSE; } - yuv_fixup = get_yuv_fixup(fixup); - switch(yuv_fixup) + complex_fixup = get_complex_fixup(fixup); + switch(complex_fixup) { - case YUV_FIXUP_YUY2: - case YUV_FIXUP_UYVY: - case YUV_FIXUP_YV12: + case COMPLEX_FIXUP_YUY2: + case COMPLEX_FIXUP_UYVY: + case COMPLEX_FIXUP_YV12: + case COMPLEX_FIXUP_P8: TRACE("[OK]\n"); return TRUE; default: - FIXME("Unsupported YUV fixup %#x\n", yuv_fixup); + FIXME("Unsupported YUV fixup %#x\n", complex_fixup); TRACE("[FAILED]\n"); return FALSE; } diff --git a/dll/directx/wine/wined3d/ati_fragment_shader.c b/dll/directx/wine/wined3d/ati_fragment_shader.c index becd4475d0a..0f911e9dc15 100644 --- a/dll/directx/wine/wined3d/ati_fragment_shader.c +++ b/dll/directx/wine/wined3d/ati_fragment_shader.c @@ -1061,7 +1061,7 @@ static void atifs_enable(IWineD3DDevice *iface, BOOL enable) { LEAVE_GL(); } -static void atifs_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps) +static void atifs_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps) { caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE | WINED3DTEXOPCAPS_SELECTARG1 | diff --git a/dll/directx/wine/wined3d/baseshader.c b/dll/directx/wine/wined3d/baseshader.c deleted file mode 100644 index 14416c47197..00000000000 --- a/dll/directx/wine/wined3d/baseshader.c +++ /dev/null @@ -1,1439 +0,0 @@ -/* - * shaders implementation - * - * Copyright 2002-2003 Jason Edmeades - * Copyright 2002-2003 Raphael Junqueira - * Copyright 2004 Christian Costa - * Copyright 2005 Oliver Stieber - * Copyright 2006 Ivan Gyurdiev - * Copyright 2007-2008 Stefan Dösinger for CodeWeavers - * Copyright 2009 Henri Verbeet for CodeWeavers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "config.h" -#include -#include -#include "wined3d_private.h" - -WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); -WINE_DECLARE_DEBUG_CHANNEL(d3d); - -static const char *shader_opcode_names[] = -{ - /* WINED3DSIH_ABS */ "abs", - /* WINED3DSIH_ADD */ "add", - /* WINED3DSIH_BEM */ "bem", - /* WINED3DSIH_BREAK */ "break", - /* WINED3DSIH_BREAKC */ "breakc", - /* WINED3DSIH_BREAKP */ "breakp", - /* WINED3DSIH_CALL */ "call", - /* WINED3DSIH_CALLNZ */ "callnz", - /* WINED3DSIH_CMP */ "cmp", - /* WINED3DSIH_CND */ "cnd", - /* WINED3DSIH_CRS */ "crs", - /* WINED3DSIH_DCL */ "dcl", - /* WINED3DSIH_DEF */ "def", - /* WINED3DSIH_DEFB */ "defb", - /* WINED3DSIH_DEFI */ "defi", - /* WINED3DSIH_DP2ADD */ "dp2add", - /* WINED3DSIH_DP3 */ "dp3", - /* WINED3DSIH_DP4 */ "dp4", - /* WINED3DSIH_DST */ "dst", - /* WINED3DSIH_DSX */ "dsx", - /* WINED3DSIH_DSY */ "dsy", - /* WINED3DSIH_ELSE */ "else", - /* WINED3DSIH_ENDIF */ "endif", - /* WINED3DSIH_ENDLOOP */ "endloop", - /* WINED3DSIH_ENDREP */ "endrep", - /* WINED3DSIH_EXP */ "exp", - /* WINED3DSIH_EXPP */ "expp", - /* WINED3DSIH_FRC */ "frc", - /* WINED3DSIH_IF */ "if", - /* WINED3DSIH_IFC */ "ifc", - /* WINED3DSIH_LABEL */ "label", - /* WINED3DSIH_LIT */ "lit", - /* WINED3DSIH_LOG */ "log", - /* WINED3DSIH_LOGP */ "logp", - /* WINED3DSIH_LOOP */ "loop", - /* WINED3DSIH_LRP */ "lrp", - /* WINED3DSIH_M3x2 */ "m3x2", - /* WINED3DSIH_M3x3 */ "m3x3", - /* WINED3DSIH_M3x4 */ "m3x4", - /* WINED3DSIH_M4x3 */ "m4x3", - /* WINED3DSIH_M4x4 */ "m4x4", - /* WINED3DSIH_MAD */ "mad", - /* WINED3DSIH_MAX */ "max", - /* WINED3DSIH_MIN */ "min", - /* WINED3DSIH_MOV */ "mov", - /* WINED3DSIH_MOVA */ "mova", - /* WINED3DSIH_MUL */ "mul", - /* WINED3DSIH_NOP */ "nop", - /* WINED3DSIH_NRM */ "nrm", - /* WINED3DSIH_PHASE */ "phase", - /* WINED3DSIH_POW */ "pow", - /* WINED3DSIH_RCP */ "rcp", - /* WINED3DSIH_REP */ "rep", - /* WINED3DSIH_RET */ "ret", - /* WINED3DSIH_RSQ */ "rsq", - /* WINED3DSIH_SETP */ "setp", - /* WINED3DSIH_SGE */ "sge", - /* WINED3DSIH_SGN */ "sgn", - /* WINED3DSIH_SINCOS */ "sincos", - /* WINED3DSIH_SLT */ "slt", - /* WINED3DSIH_SUB */ "sub", - /* WINED3DSIH_TEX */ "texld", - /* WINED3DSIH_TEXBEM */ "texbem", - /* WINED3DSIH_TEXBEML */ "texbeml", - /* WINED3DSIH_TEXCOORD */ "texcrd", - /* WINED3DSIH_TEXDEPTH */ "texdepth", - /* WINED3DSIH_TEXDP3 */ "texdp3", - /* WINED3DSIH_TEXDP3TEX */ "texdp3tex", - /* WINED3DSIH_TEXKILL */ "texkill", - /* WINED3DSIH_TEXLDD */ "texldd", - /* WINED3DSIH_TEXLDL */ "texldl", - /* WINED3DSIH_TEXM3x2DEPTH */ "texm3x2depth", - /* WINED3DSIH_TEXM3x2PAD */ "texm3x2pad", - /* WINED3DSIH_TEXM3x2TEX */ "texm3x2tex", - /* WINED3DSIH_TEXM3x3 */ "texm3x3", - /* WINED3DSIH_TEXM3x3DIFF */ "texm3x3diff", - /* WINED3DSIH_TEXM3x3PAD */ "texm3x3pad", - /* WINED3DSIH_TEXM3x3SPEC */ "texm3x3spec", - /* WINED3DSIH_TEXM3x3TEX */ "texm3x3tex", - /* WINED3DSIH_TEXM3x3VSPEC */ "texm3x3vspec", - /* WINED3DSIH_TEXREG2AR */ "texreg2ar", - /* WINED3DSIH_TEXREG2GB */ "texreg2gb", - /* WINED3DSIH_TEXREG2RGB */ "texreg2rgb", -}; - -const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) -{ - switch (version_token >> 16) - { - case WINED3D_SM1_VS: - case WINED3D_SM1_PS: - return &sm1_shader_frontend; - - case WINED3D_SM4_PS: - case WINED3D_SM4_VS: - case WINED3D_SM4_GS: - return &sm4_shader_frontend; - - default: - FIXME("Unrecognised version token %#x\n", version_token); - return NULL; - } -} - -void shader_buffer_clear(struct wined3d_shader_buffer *buffer) -{ - buffer->buffer[0] = '\0'; - buffer->bsize = 0; - buffer->lineNo = 0; - buffer->newline = TRUE; -} - -BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) -{ - buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE); - if (!buffer->buffer) - { - ERR("Failed to allocate shader buffer memory.\n"); - return FALSE; - } - - shader_buffer_clear(buffer); - return TRUE; -} - -void shader_buffer_free(struct wined3d_shader_buffer *buffer) -{ - HeapFree(GetProcessHeap(), 0, buffer->buffer); -} - -int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *format, va_list args) -{ - char* base = buffer->buffer + buffer->bsize; - int rc; - - rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args); - - if (rc < 0 /* C89 */ || (unsigned int)rc > SHADER_PGMSIZE - 1 - buffer->bsize /* C99 */) - { - ERR("The buffer allocated for the shader program string " - "is too small at %d bytes.\n", SHADER_PGMSIZE); - buffer->bsize = SHADER_PGMSIZE - 1; - return -1; - } - - if (buffer->newline) { - TRACE("GL HW (%u, %u) : %s", buffer->lineNo + 1, buffer->bsize, base); - buffer->newline = FALSE; - } else { - TRACE("%s", base); - } - - buffer->bsize += rc; - if (buffer->buffer[buffer->bsize-1] == '\n') { - buffer->lineNo++; - buffer->newline = TRUE; - } - return 0; -} - -int shader_addline(struct wined3d_shader_buffer *buffer, const char *format, ...) -{ - int ret; - va_list args; - - va_start(args, format); - ret = shader_vaddline(buffer, format, args); - va_end(args); - - return ret; -} - -void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device, - IUnknown *parent, const struct wined3d_parent_ops *parent_ops) -{ - shader->ref = 1; - shader->device = (IWineD3DDevice *)device; - shader->parent = parent; - shader->parent_ops = parent_ops; - list_init(&shader->linked_programs); - list_add_head(&device->shaders, &shader->shader_list_entry); -} - -/* Convert floating point offset relative - * to a register file to an absolute offset for float constants */ -static unsigned int shader_get_float_offset(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx) -{ - switch (register_type) - { - case WINED3DSPR_CONST: return register_idx; - case WINED3DSPR_CONST2: return 2048 + register_idx; - case WINED3DSPR_CONST3: return 4096 + register_idx; - case WINED3DSPR_CONST4: return 6144 + register_idx; - default: - FIXME("Unsupported register type: %d\n", register_type); - return register_idx; - } -} - -static void shader_delete_constant_list(struct list* clist) { - - struct list *ptr; - struct local_constant* constant; - - ptr = list_head(clist); - while (ptr) { - constant = LIST_ENTRY(ptr, struct local_constant, entry); - ptr = list_next(clist, ptr); - HeapFree(GetProcessHeap(), 0, constant); - } - list_init(clist); -} - -static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit) -{ - DWORD idx, shift; - idx = bit >> 5; - shift = bit & 0x1f; - bitmap[idx] |= (1 << shift); -} - -static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct shader_reg_maps *reg_maps, - const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type) -{ - switch (reg->type) - { - case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */ - if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx; - else reg_maps->address |= 1 << reg->idx; - break; - - case WINED3DSPR_TEMP: - reg_maps->temporary |= 1 << reg->idx; - break; - - case WINED3DSPR_INPUT: - if (shader_type == WINED3D_SHADER_TYPE_PIXEL) - { - if (reg->rel_addr) - { - /* If relative addressing is used, we must assume that all registers - * are used. Even if it is a construct like v3[aL], we can't assume - * that v0, v1 and v2 aren't read because aL can be negative */ - unsigned int i; - for (i = 0; i < MAX_REG_INPUT; ++i) - { - ((IWineD3DPixelShaderImpl *)This)->input_reg_used[i] = TRUE; - } - } - else - { - ((IWineD3DPixelShaderImpl *)This)->input_reg_used[reg->idx] = TRUE; - } - } - else reg_maps->input_registers |= 1 << reg->idx; - break; - - case WINED3DSPR_RASTOUT: - if (reg->idx == 1) reg_maps->fog = 1; - break; - - case WINED3DSPR_MISCTYPE: - if (shader_type == WINED3D_SHADER_TYPE_PIXEL) - { - if (reg->idx == 0) reg_maps->vpos = 1; - else if (reg->idx == 1) reg_maps->usesfacing = 1; - } - break; - - case WINED3DSPR_CONST: - if (reg->rel_addr) - { - if (shader_type != WINED3D_SHADER_TYPE_PIXEL) - { - if (reg->idx < ((IWineD3DVertexShaderImpl *)This)->min_rel_offset) - { - ((IWineD3DVertexShaderImpl *)This)->min_rel_offset = reg->idx; - } - if (reg->idx > ((IWineD3DVertexShaderImpl *)This)->max_rel_offset) - { - ((IWineD3DVertexShaderImpl *)This)->max_rel_offset = reg->idx; - } - } - reg_maps->usesrelconstF = TRUE; - } - else - { - set_bitmap_bit(reg_maps->constf, reg->idx); - } - break; - - case WINED3DSPR_CONSTINT: - reg_maps->integer_constants |= (1 << reg->idx); - break; - - case WINED3DSPR_CONSTBOOL: - reg_maps->boolean_constants |= (1 << reg->idx); - break; - - case WINED3DSPR_COLOROUT: - reg_maps->highest_render_target = max(reg_maps->highest_render_target, reg->idx); - break; - - default: - TRACE("Not recording register of type %#x and idx %u\n", reg->type, reg->idx); - break; - } -} - -static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param) -{ - switch(instr) - { - case WINED3DSIH_M4x4: - case WINED3DSIH_M3x4: - return param == 1 ? 3 : 0; - - case WINED3DSIH_M4x3: - case WINED3DSIH_M3x3: - return param == 1 ? 2 : 0; - - case WINED3DSIH_M3x2: - return param == 1 ? 1 : 0; - - default: - return 0; - } -} - -static const char *semantic_names[] = -{ - /* WINED3DDECLUSAGE_POSITION */ "SV_POSITION", - /* WINED3DDECLUSAGE_BLENDWEIGHT */ "BLENDWEIGHT", - /* WINED3DDECLUSAGE_BLENDINDICES */ "BLENDINDICES", - /* WINED3DDECLUSAGE_NORMAL */ "NORMAL", - /* WINED3DDECLUSAGE_PSIZE */ "PSIZE", - /* WINED3DDECLUSAGE_TEXCOORD */ "TEXCOORD", - /* WINED3DDECLUSAGE_TANGENT */ "TANGENT", - /* WINED3DDECLUSAGE_BINORMAL */ "BINORMAL", - /* WINED3DDECLUSAGE_TESSFACTOR */ "TESSFACTOR", - /* WINED3DDECLUSAGE_POSITIONT */ "POSITIONT", - /* WINED3DDECLUSAGE_COLOR */ "COLOR", - /* WINED3DDECLUSAGE_FOG */ "FOG", - /* WINED3DDECLUSAGE_DEPTH */ "DEPTH", - /* WINED3DDECLUSAGE_SAMPLE */ "SAMPLE", -}; - -static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage) -{ - if (usage >= sizeof(semantic_names) / sizeof(*semantic_names)) - { - FIXME("Unrecognized usage %#x\n", usage); - return "UNRECOGNIZED"; - } - - return semantic_names[usage]; -} - -WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *name) -{ - unsigned int i; - - for (i = 0; i < sizeof(semantic_names) / sizeof(*semantic_names); ++i) - { - if (!strcmp(name, semantic_names[i])) return i; - } - - return ~0U; -} - -BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) -{ - return !strcmp(semantic_name, shader_semantic_name_from_usage(usage)); -} - -static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e, - const struct wined3d_shader_semantic *s) -{ - e->semantic_name = shader_semantic_name_from_usage(s->usage); - e->semantic_idx = s->usage_idx; - e->sysval_semantic = 0; - e->component_type = 0; - e->register_idx = s->reg.reg.idx; - e->mask = s->reg.write_mask; -} - -/* Note that this does not count the loop register - * as an address register. */ - -HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe, - struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature, - struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size) -{ - IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; - void *fe_data = This->baseShader.frontend_data; - struct wined3d_shader_version shader_version; - unsigned int cur_loop_depth = 0, max_loop_depth = 0; - const DWORD* pToken = byte_code; - - /* There are some minor differences between pixel and vertex shaders */ - - memset(reg_maps, 0, sizeof(*reg_maps)); - - /* get_registers_used is called on every compile on some 1.x shaders, which can result - * in stacking up a collection of local constants. Delete the old constants if existing - */ - shader_delete_constant_list(&This->baseShader.constantsF); - shader_delete_constant_list(&This->baseShader.constantsB); - shader_delete_constant_list(&This->baseShader.constantsI); - - fe->shader_read_header(fe_data, &pToken, &shader_version); - reg_maps->shader_version = shader_version; - - reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(*reg_maps->constf) * ((constf_size + 31) / 32)); - if(!reg_maps->constf) { - ERR("Out of memory\n"); - return E_OUTOFMEMORY; - } - - while (!fe->shader_is_end(fe_data, &pToken)) - { - struct wined3d_shader_instruction ins; - const char *comment; - UINT param_size; - - /* Skip comments */ - fe->shader_read_comment(&pToken, &comment); - if (comment) continue; - - /* Fetch opcode */ - fe->shader_read_opcode(fe_data, &pToken, &ins, ¶m_size); - - /* Unhandled opcode, and its parameters */ - if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) - { - TRACE("Skipping unrecognized instruction.\n"); - pToken += param_size; - continue; - } - - /* Handle declarations */ - if (ins.handler_idx == WINED3DSIH_DCL) - { - struct wined3d_shader_semantic semantic; - - fe->shader_read_semantic(&pToken, &semantic); - - switch (semantic.reg.reg.type) - { - /* Mark input registers used. */ - case WINED3DSPR_INPUT: - reg_maps->input_registers |= 1 << semantic.reg.reg.idx; - shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic); - break; - - /* Vshader: mark 3.0 output registers used, save token */ - case WINED3DSPR_OUTPUT: - reg_maps->output_registers |= 1 << semantic.reg.reg.idx; - shader_signature_from_semantic(&output_signature[semantic.reg.reg.idx], &semantic); - if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1; - break; - - /* Save sampler usage token */ - case WINED3DSPR_SAMPLER: - reg_maps->sampler_type[semantic.reg.reg.idx] = semantic.sampler_type; - break; - - default: - TRACE("Not recording DCL register type %#x.\n", semantic.reg.reg.type); - break; - } - } - else if (ins.handler_idx == WINED3DSIH_DEF) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); - if (!lconst) return E_OUTOFMEMORY; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - lconst->idx = dst.reg.idx; - - memcpy(lconst->value, pToken, 4 * sizeof(DWORD)); - pToken += 4; - - /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */ - if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL) - { - float *value = (float *) lconst->value; - if (value[0] < -1.0f) value[0] = -1.0f; - else if (value[0] > 1.0f) value[0] = 1.0f; - if (value[1] < -1.0f) value[1] = -1.0f; - else if (value[1] > 1.0f) value[1] = 1.0f; - if (value[2] < -1.0f) value[2] = -1.0f; - else if (value[2] > 1.0f) value[2] = 1.0f; - if (value[3] < -1.0f) value[3] = -1.0f; - else if (value[3] > 1.0f) value[3] = 1.0f; - } - - list_add_head(&This->baseShader.constantsF, &lconst->entry); - } - else if (ins.handler_idx == WINED3DSIH_DEFI) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); - if (!lconst) return E_OUTOFMEMORY; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - lconst->idx = dst.reg.idx; - - memcpy(lconst->value, pToken, 4 * sizeof(DWORD)); - pToken += 4; - - list_add_head(&This->baseShader.constantsI, &lconst->entry); - reg_maps->local_int_consts |= (1 << dst.reg.idx); - } - else if (ins.handler_idx == WINED3DSIH_DEFB) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); - if (!lconst) return E_OUTOFMEMORY; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - lconst->idx = dst.reg.idx; - - memcpy(lconst->value, pToken, sizeof(DWORD)); - ++pToken; - - list_add_head(&This->baseShader.constantsB, &lconst->entry); - reg_maps->local_bool_consts |= (1 << dst.reg.idx); - } - /* If there's a loop in the shader */ - else if (ins.handler_idx == WINED3DSIH_LOOP - || ins.handler_idx == WINED3DSIH_REP) - { - struct wined3d_shader_src_param src, rel_addr; - - fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr); - - /* Rep and Loop always use an integer constant for the control parameters */ - if (ins.handler_idx == WINED3DSIH_REP) - { - reg_maps->integer_constants |= 1 << src.reg.idx; - } - else - { - fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr); - reg_maps->integer_constants |= 1 << src.reg.idx; - } - - cur_loop_depth++; - if(cur_loop_depth > max_loop_depth) - max_loop_depth = cur_loop_depth; - } - else if (ins.handler_idx == WINED3DSIH_ENDLOOP - || ins.handler_idx == WINED3DSIH_ENDREP) - { - cur_loop_depth--; - } - /* For subroutine prototypes */ - else if (ins.handler_idx == WINED3DSIH_LABEL) - { - struct wined3d_shader_src_param src, rel_addr; - - fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr); - reg_maps->labels |= 1 << src.reg.idx; - } - /* Set texture, address, temporary registers */ - else - { - int i, limit; - BOOL color0_mov = FALSE; - - /* This will loop over all the registers and try to - * make a bitmask of the ones we're interested in. - * - * Relative addressing tokens are ignored, but that's - * okay, since we'll catch any address registers when - * they are initialized (required by spec) */ - - if (ins.dst_count) - { - struct wined3d_shader_dst_param dst_param; - struct wined3d_shader_src_param dst_rel_addr; - - fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr); - - shader_record_register_usage(This, reg_maps, &dst_param.reg, shader_version.type); - - /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and - * is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel - * shaders because TECRDOUT isn't used in them, but future register types might cause issues */ - if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX && shader_version.major < 3 - && dst_param.reg.type == WINED3DSPR_TEXCRDOUT) - { - reg_maps->texcoord_mask[dst_param.reg.idx] |= dst_param.write_mask; - } - - if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL) - { - IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)This; - - if(dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0) - { - /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to - * COLOROUT 0. If we know this in advance, the ARB shader backend can skip - * the mov and perform the sRGB write correction from the source register. - * - * However, if the mov is only partial, we can't do this, and if the write - * comes from an instruction other than MOV it is hard to do as well. If - * COLOROUT 0 is overwritten partially later, the marker is dropped again. */ - - ps->color0_mov = FALSE; - if (ins.handler_idx == WINED3DSIH_MOV) - { - /* Used later when the source register is read. */ - color0_mov = TRUE; - } - } - /* Also drop the MOV marker if the source register is overwritten prior to the shader - * end - */ - else if(dst_param.reg.type == WINED3DSPR_TEMP && dst_param.reg.idx == ps->color0_reg) - { - ps->color0_mov = FALSE; - } - } - - /* Declare 1.X samplers implicitly, based on the destination reg. number */ - if (shader_version.major == 1 - && (ins.handler_idx == WINED3DSIH_TEX - || ins.handler_idx == WINED3DSIH_TEXBEM - || ins.handler_idx == WINED3DSIH_TEXBEML - || ins.handler_idx == WINED3DSIH_TEXDP3TEX - || ins.handler_idx == WINED3DSIH_TEXM3x2TEX - || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC - || ins.handler_idx == WINED3DSIH_TEXM3x3TEX - || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC - || ins.handler_idx == WINED3DSIH_TEXREG2AR - || ins.handler_idx == WINED3DSIH_TEXREG2GB - || ins.handler_idx == WINED3DSIH_TEXREG2RGB)) - { - /* Fake sampler usage, only set reserved bit and ttype */ - DWORD sampler_code = dst_param.reg.idx; - - TRACE("Setting fake 2D sampler for 1.x pixelshader\n"); - reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D; - - /* texbem is only valid with < 1.4 pixel shaders */ - if (ins.handler_idx == WINED3DSIH_TEXBEM - || ins.handler_idx == WINED3DSIH_TEXBEML) - { - reg_maps->bumpmat |= 1 << dst_param.reg.idx; - if (ins.handler_idx == WINED3DSIH_TEXBEML) - { - reg_maps->luminanceparams |= 1 << dst_param.reg.idx; - } - } - } - else if (ins.handler_idx == WINED3DSIH_BEM) - { - reg_maps->bumpmat |= 1 << dst_param.reg.idx; - } - } - - if (ins.handler_idx == WINED3DSIH_NRM) - { - reg_maps->usesnrm = 1; - } - else if (ins.handler_idx == WINED3DSIH_DSY) - { - reg_maps->usesdsy = 1; - } - else if (ins.handler_idx == WINED3DSIH_DSX) - { - reg_maps->usesdsx = 1; - } - else if(ins.handler_idx == WINED3DSIH_TEXLDD) - { - reg_maps->usestexldd = 1; - } - else if(ins.handler_idx == WINED3DSIH_TEXLDL) - { - reg_maps->usestexldl = 1; - } - else if(ins.handler_idx == WINED3DSIH_MOVA) - { - reg_maps->usesmova = 1; - } - else if(ins.handler_idx == WINED3DSIH_IFC) - { - reg_maps->usesifc = 1; - } - else if(ins.handler_idx == WINED3DSIH_CALL) - { - reg_maps->usescall = 1; - } - - limit = ins.src_count + (ins.predicate ? 1 : 0); - for (i = 0; i < limit; ++i) - { - struct wined3d_shader_src_param src_param, src_rel_addr; - unsigned int count; - - fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr); - count = get_instr_extra_regcount(ins.handler_idx, i); - - shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type); - while (count) - { - ++src_param.reg.idx; - shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type); - --count; - } - - if(color0_mov) - { - IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) This; - if(src_param.reg.type == WINED3DSPR_TEMP && - src_param.swizzle == WINED3DSP_NOSWIZZLE) - { - ps->color0_mov = TRUE; - ps->color0_reg = src_param.reg.idx; - } - } - } - } - } - reg_maps->loop_depth = max_loop_depth; - - This->baseShader.functionLength = ((const char *)pToken - (const char *)byte_code); - - return WINED3D_OK; -} - -unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) -{ - DWORD map = 1 << max; - map |= map - 1; - map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers; - - return wined3d_log2i(map); -} - -static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic, - const struct wined3d_shader_version *shader_version) -{ - TRACE("dcl"); - - if (semantic->reg.reg.type == WINED3DSPR_SAMPLER) - { - switch (semantic->sampler_type) - { - case WINED3DSTT_2D: TRACE("_2d"); break; - case WINED3DSTT_CUBE: TRACE("_cube"); break; - case WINED3DSTT_VOLUME: TRACE("_volume"); break; - default: TRACE("_unknown_ttype(0x%08x)", semantic->sampler_type); - } - } - else - { - /* Pixel shaders 3.0 don't have usage semantics */ - if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL) - return; - else - TRACE("_"); - - switch (semantic->usage) - { - case WINED3DDECLUSAGE_POSITION: - TRACE("position%d", semantic->usage_idx); - break; - case WINED3DDECLUSAGE_BLENDINDICES: - TRACE("blend"); - break; - case WINED3DDECLUSAGE_BLENDWEIGHT: - TRACE("weight"); - break; - case WINED3DDECLUSAGE_NORMAL: - TRACE("normal%d", semantic->usage_idx); - break; - case WINED3DDECLUSAGE_PSIZE: - TRACE("psize"); - break; - case WINED3DDECLUSAGE_COLOR: - if (semantic->usage_idx == 0) TRACE("color"); - else TRACE("specular%d", (semantic->usage_idx - 1)); - break; - case WINED3DDECLUSAGE_TEXCOORD: - TRACE("texture%d", semantic->usage_idx); - break; - case WINED3DDECLUSAGE_TANGENT: - TRACE("tangent"); - break; - case WINED3DDECLUSAGE_BINORMAL: - TRACE("binormal"); - break; - case WINED3DDECLUSAGE_TESSFACTOR: - TRACE("tessfactor"); - break; - case WINED3DDECLUSAGE_POSITIONT: - TRACE("positionT%d", semantic->usage_idx); - break; - case WINED3DDECLUSAGE_FOG: - TRACE("fog"); - break; - case WINED3DDECLUSAGE_DEPTH: - TRACE("depth"); - break; - case WINED3DDECLUSAGE_SAMPLE: - TRACE("sample"); - break; - default: - FIXME("unknown_semantics(0x%08x)", semantic->usage); - } - } -} - -static void shader_dump_register(const struct wined3d_shader_register *reg, - const struct wined3d_shader_version *shader_version) -{ - static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"}; - static const char * const misctype_reg_names[] = {"vPos", "vFace"}; - UINT offset = reg->idx; - - switch (reg->type) - { - case WINED3DSPR_TEMP: - TRACE("r"); - break; - - case WINED3DSPR_INPUT: - TRACE("v"); - break; - - case WINED3DSPR_CONST: - case WINED3DSPR_CONST2: - case WINED3DSPR_CONST3: - case WINED3DSPR_CONST4: - TRACE("c"); - offset = shader_get_float_offset(reg->type, reg->idx); - break; - - case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */ - TRACE("%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a'); - break; - - case WINED3DSPR_RASTOUT: - TRACE("%s", rastout_reg_names[reg->idx]); - break; - - case WINED3DSPR_COLOROUT: - TRACE("oC"); - break; - - case WINED3DSPR_DEPTHOUT: - TRACE("oDepth"); - break; - - case WINED3DSPR_ATTROUT: - TRACE("oD"); - break; - - case WINED3DSPR_TEXCRDOUT: - /* Vertex shaders >= 3.0 use general purpose output registers - * (WINED3DSPR_OUTPUT), which can include an address token */ - if (shader_version->major >= 3) TRACE("o"); - else TRACE("oT"); - break; - - case WINED3DSPR_CONSTINT: - TRACE("i"); - break; - - case WINED3DSPR_CONSTBOOL: - TRACE("b"); - break; - - case WINED3DSPR_LABEL: - TRACE("l"); - break; - - case WINED3DSPR_LOOP: - TRACE("aL"); - break; - - case WINED3DSPR_SAMPLER: - TRACE("s"); - break; - - case WINED3DSPR_MISCTYPE: - if (reg->idx > 1) FIXME("Unhandled misctype register %d\n", reg->idx); - else TRACE("%s", misctype_reg_names[reg->idx]); - break; - - case WINED3DSPR_PREDICATE: - TRACE("p"); - break; - - case WINED3DSPR_IMMCONST: - TRACE("l"); - break; - - case WINED3DSPR_CONSTBUFFER: - TRACE("cb"); - break; - - default: - TRACE("unhandled_rtype(%#x)", reg->type); - break; - } - - if (reg->type == WINED3DSPR_IMMCONST) - { - TRACE("("); - switch (reg->immconst_type) - { - case WINED3D_IMMCONST_FLOAT: - TRACE("%.8e", *(const float *)reg->immconst_data); - break; - - case WINED3D_IMMCONST_FLOAT4: - TRACE("%.8e, %.8e, %.8e, %.8e", - *(const float *)®->immconst_data[0], *(const float *)®->immconst_data[1], - *(const float *)®->immconst_data[2], *(const float *)®->immconst_data[3]); - break; - - default: - TRACE("", reg->immconst_type); - break; - } - TRACE(")"); - } - else if (reg->type != WINED3DSPR_RASTOUT && reg->type != WINED3DSPR_MISCTYPE) - { - if (reg->array_idx != ~0U) - { - TRACE("%u[%u", offset, reg->array_idx); - if (reg->rel_addr) - { - TRACE(" + "); - shader_dump_src_param(reg->rel_addr, shader_version); - } - TRACE("]"); - } - else - { - if (reg->rel_addr) - { - TRACE("["); - shader_dump_src_param(reg->rel_addr, shader_version); - TRACE(" + "); - } - TRACE("%u", offset); - if (reg->rel_addr) TRACE("]"); - } - } -} - -void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, - const struct wined3d_shader_version *shader_version) -{ - DWORD write_mask = param->write_mask; - - shader_dump_register(¶m->reg, shader_version); - - if (write_mask != WINED3DSP_WRITEMASK_ALL) - { - static const char *write_mask_chars = "xyzw"; - - TRACE("."); - if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]); - if (write_mask & WINED3DSP_WRITEMASK_1) TRACE("%c", write_mask_chars[1]); - if (write_mask & WINED3DSP_WRITEMASK_2) TRACE("%c", write_mask_chars[2]); - if (write_mask & WINED3DSP_WRITEMASK_3) TRACE("%c", write_mask_chars[3]); - } -} - -void shader_dump_src_param(const struct wined3d_shader_src_param *param, - const struct wined3d_shader_version *shader_version) -{ - DWORD src_modifier = param->modifiers; - DWORD swizzle = param->swizzle; - - if (src_modifier == WINED3DSPSM_NEG - || src_modifier == WINED3DSPSM_BIASNEG - || src_modifier == WINED3DSPSM_SIGNNEG - || src_modifier == WINED3DSPSM_X2NEG - || src_modifier == WINED3DSPSM_ABSNEG) - TRACE("-"); - else if (src_modifier == WINED3DSPSM_COMP) - TRACE("1-"); - else if (src_modifier == WINED3DSPSM_NOT) - TRACE("!"); - - if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG) - TRACE("abs("); - - shader_dump_register(¶m->reg, shader_version); - - if (src_modifier) - { - switch (src_modifier) - { - case WINED3DSPSM_NONE: break; - case WINED3DSPSM_NEG: break; - case WINED3DSPSM_NOT: break; - case WINED3DSPSM_BIAS: TRACE("_bias"); break; - case WINED3DSPSM_BIASNEG: TRACE("_bias"); break; - case WINED3DSPSM_SIGN: TRACE("_bx2"); break; - case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break; - case WINED3DSPSM_COMP: break; - case WINED3DSPSM_X2: TRACE("_x2"); break; - case WINED3DSPSM_X2NEG: TRACE("_x2"); break; - case WINED3DSPSM_DZ: TRACE("_dz"); break; - case WINED3DSPSM_DW: TRACE("_dw"); break; - case WINED3DSPSM_ABSNEG: TRACE(")"); break; - case WINED3DSPSM_ABS: TRACE(")"); break; - default: - TRACE("_unknown_modifier(%#x)", src_modifier); - } - } - - if (swizzle != WINED3DSP_NOSWIZZLE) - { - static const char *swizzle_chars = "xyzw"; - DWORD swizzle_x = swizzle & 0x03; - DWORD swizzle_y = (swizzle >> 2) & 0x03; - DWORD swizzle_z = (swizzle >> 4) & 0x03; - DWORD swizzle_w = (swizzle >> 6) & 0x03; - - if (swizzle_x == swizzle_y - && swizzle_x == swizzle_z - && swizzle_x == swizzle_w) - { - TRACE(".%c", swizzle_chars[swizzle_x]); - } - else - { - TRACE(".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y], - swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]); - } - } -} - -/* Shared code in order to generate the bulk of the shader string. - * NOTE: A description of how to parse tokens can be found on msdn */ -void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer, - const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) -{ - IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; - IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */ - const struct wined3d_shader_frontend *fe = This->baseShader.frontend; - void *fe_data = This->baseShader.frontend_data; - struct wined3d_shader_src_param src_rel_addr[4]; - struct wined3d_shader_src_param src_param[4]; - struct wined3d_shader_version shader_version; - struct wined3d_shader_src_param dst_rel_addr; - struct wined3d_shader_dst_param dst_param; - struct wined3d_shader_instruction ins; - struct wined3d_shader_context ctx; - const DWORD *pToken = pFunction; - DWORD i; - - /* Initialize current parsing state */ - ctx.shader = iface; - ctx.reg_maps = reg_maps; - ctx.buffer = buffer; - ctx.backend_data = backend_ctx; - - ins.ctx = &ctx; - ins.dst = &dst_param; - ins.src = src_param; - This->baseShader.parse_state.current_row = 0; - - fe->shader_read_header(fe_data, &pToken, &shader_version); - - while (!fe->shader_is_end(fe_data, &pToken)) - { - const char *comment; - UINT param_size; - - /* Skip comment tokens */ - fe->shader_read_comment(&pToken, &comment); - if (comment) continue; - - /* Read opcode */ - fe->shader_read_opcode(fe_data, &pToken, &ins, ¶m_size); - - /* Unknown opcode and its parameters */ - if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) - { - TRACE("Skipping unrecognized instruction.\n"); - pToken += param_size; - continue; - } - - /* Nothing to do */ - if (ins.handler_idx == WINED3DSIH_DCL - || ins.handler_idx == WINED3DSIH_NOP - || ins.handler_idx == WINED3DSIH_DEF - || ins.handler_idx == WINED3DSIH_DEFI - || ins.handler_idx == WINED3DSIH_DEFB - || ins.handler_idx == WINED3DSIH_PHASE) - { - pToken += param_size; - continue; - } - - /* Destination token */ - if (ins.dst_count) fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr); - - /* Predication token */ - if (ins.predicate) ins.predicate = *pToken++; - - /* Other source tokens */ - for (i = 0; i < ins.src_count; ++i) - { - fe->shader_read_src_param(fe_data, &pToken, &src_param[i], &src_rel_addr[i]); - } - - /* Call appropriate function for output target */ - device->shader_backend->shader_handle_instruction(&ins); - } -} - -static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst) -{ - DWORD mmask = dst->modifiers; - - switch (dst->shift) - { - case 0: break; - case 13: TRACE("_d8"); break; - case 14: TRACE("_d4"); break; - case 15: TRACE("_d2"); break; - case 1: TRACE("_x2"); break; - case 2: TRACE("_x4"); break; - case 3: TRACE("_x8"); break; - default: TRACE("_unhandled_shift(%d)", dst->shift); break; - } - - if (mmask & WINED3DSPDM_SATURATE) TRACE("_sat"); - if (mmask & WINED3DSPDM_PARTIALPRECISION) TRACE("_pp"); - if (mmask & WINED3DSPDM_MSAMPCENTROID) TRACE("_centroid"); - - mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID); - if (mmask) - FIXME("_unrecognized_modifier(%#x)", mmask); -} - -void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) -{ - struct wined3d_shader_version shader_version; - const DWORD* pToken = pFunction; - const char *type_prefix; - DWORD i; - - TRACE("Parsing %p\n", pFunction); - - fe->shader_read_header(fe_data, &pToken, &shader_version); - - switch (shader_version.type) - { - case WINED3D_SHADER_TYPE_VERTEX: - type_prefix = "vs"; - break; - - case WINED3D_SHADER_TYPE_GEOMETRY: - type_prefix = "gs"; - break; - - case WINED3D_SHADER_TYPE_PIXEL: - type_prefix = "ps"; - break; - - default: - FIXME("Unhandled shader type %#x.\n", shader_version.type); - type_prefix = "unknown"; - break; - } - - TRACE("%s_%u_%u\n", type_prefix, shader_version.major, shader_version.minor); - - while (!fe->shader_is_end(fe_data, &pToken)) - { - struct wined3d_shader_instruction ins; - const char *comment; - UINT param_size; - - /* comment */ - fe->shader_read_comment(&pToken, &comment); - if (comment) - { - TRACE("//%s\n", comment); - continue; - } - - fe->shader_read_opcode(fe_data, &pToken, &ins, ¶m_size); - if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) - { - TRACE("Skipping unrecognized instruction.\n"); - pToken += param_size; - continue; - } - - if (ins.handler_idx == WINED3DSIH_DCL) - { - struct wined3d_shader_semantic semantic; - - fe->shader_read_semantic(&pToken, &semantic); - - shader_dump_decl_usage(&semantic, &shader_version); - shader_dump_ins_modifiers(&semantic.reg); - TRACE(" "); - shader_dump_dst_param(&semantic.reg, &shader_version); - } - else if (ins.handler_idx == WINED3DSIH_DEF) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - - TRACE("def c%u = %f, %f, %f, %f", shader_get_float_offset(dst.reg.type, dst.reg.idx), - *(const float *)(pToken), - *(const float *)(pToken + 1), - *(const float *)(pToken + 2), - *(const float *)(pToken + 3)); - pToken += 4; - } - else if (ins.handler_idx == WINED3DSIH_DEFI) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - - TRACE("defi i%u = %d, %d, %d, %d", dst.reg.idx, - *(pToken), - *(pToken + 1), - *(pToken + 2), - *(pToken + 3)); - pToken += 4; - } - else if (ins.handler_idx == WINED3DSIH_DEFB) - { - struct wined3d_shader_dst_param dst; - struct wined3d_shader_src_param rel_addr; - - fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr); - - TRACE("defb b%u = %s", dst.reg.idx, *pToken ? "true" : "false"); - ++pToken; - } - else - { - struct wined3d_shader_src_param dst_rel_addr, src_rel_addr; - struct wined3d_shader_dst_param dst_param; - struct wined3d_shader_src_param src_param; - - if (ins.dst_count) - { - fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr); - } - - /* Print out predication source token first - it follows - * the destination token. */ - if (ins.predicate) - { - fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr); - TRACE("("); - shader_dump_src_param(&src_param, &shader_version); - TRACE(") "); - } - - /* PixWin marks instructions with the coissue flag with a '+' */ - if (ins.coissue) TRACE("+"); - - TRACE("%s", shader_opcode_names[ins.handler_idx]); - - if (ins.handler_idx == WINED3DSIH_IFC - || ins.handler_idx == WINED3DSIH_BREAKC) - { - switch (ins.flags) - { - case COMPARISON_GT: TRACE("_gt"); break; - case COMPARISON_EQ: TRACE("_eq"); break; - case COMPARISON_GE: TRACE("_ge"); break; - case COMPARISON_LT: TRACE("_lt"); break; - case COMPARISON_NE: TRACE("_ne"); break; - case COMPARISON_LE: TRACE("_le"); break; - default: TRACE("_(%u)", ins.flags); - } - } - else if (ins.handler_idx == WINED3DSIH_TEX - && shader_version.major >= 2 - && (ins.flags & WINED3DSI_TEXLD_PROJECT)) - { - TRACE("p"); - } - - /* We already read the destination token, print it. */ - if (ins.dst_count) - { - shader_dump_ins_modifiers(&dst_param); - TRACE(" "); - shader_dump_dst_param(&dst_param, &shader_version); - } - - /* Other source tokens */ - for (i = ins.dst_count; i < (ins.dst_count + ins.src_count); ++i) - { - fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr); - TRACE(!i ? " " : ", "); - shader_dump_src_param(&src_param, &shader_version); - } - } - TRACE("\n"); - } -} - -void shader_cleanup(IWineD3DBaseShader *iface) -{ - IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)iface; - - ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_destroy(iface); - HeapFree(GetProcessHeap(), 0, This->baseShader.reg_maps.constf); - HeapFree(GetProcessHeap(), 0, This->baseShader.function); - shader_delete_constant_list(&This->baseShader.constantsF); - shader_delete_constant_list(&This->baseShader.constantsB); - shader_delete_constant_list(&This->baseShader.constantsI); - list_remove(&This->baseShader.shader_list_entry); - - if (This->baseShader.frontend && This->baseShader.frontend_data) - { - This->baseShader.frontend->shader_free(This->baseShader.frontend_data); - } -} - -static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {} -static void shader_none_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {} -static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {} -static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {} -static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {} -static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {} -static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {} -static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {} -static void shader_none_destroy(IWineD3DBaseShader *iface) {} -static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;} -static void shader_none_free(IWineD3DDevice *iface) {} -static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;} - -static void shader_none_get_caps(WINED3DDEVTYPE devtype, - const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps) -{ - /* Set the shader caps to 0 for the none shader backend */ - pCaps->VertexShaderVersion = 0; - pCaps->PixelShaderVersion = 0; - pCaps->PixelShader1xMaxValue = 0.0f; -} - -static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup) -{ - if (TRACE_ON(d3d_shader) && TRACE_ON(d3d)) - { - TRACE("Checking support for fixup:\n"); - dump_color_fixup_desc(fixup); - } - - /* Faked to make some apps happy. */ - if (!is_yuv_fixup(fixup)) - { - TRACE("[OK]\n"); - return TRUE; - } - - TRACE("[FAILED]\n"); - return FALSE; -} - -const shader_backend_t none_shader_backend = { - shader_none_handle_instruction, - shader_none_select, - shader_none_select_depth_blt, - shader_none_deselect_depth_blt, - shader_none_update_float_vertex_constants, - shader_none_update_float_pixel_constants, - shader_none_load_constants, - shader_none_load_np2fixup_constants, - shader_none_destroy, - shader_none_alloc, - shader_none_free, - shader_none_dirty_const, - shader_none_get_caps, - shader_none_color_fixup_supported, -}; diff --git a/dll/directx/wine/wined3d/buffer.c b/dll/directx/wine/wined3d/buffer.c index 20201b12eb3..e22d311beb9 100644 --- a/dll/directx/wine/wined3d/buffer.c +++ b/dll/directx/wine/wined3d/buffer.c @@ -3,7 +3,7 @@ * Copyright 2002-2005 Raphael Junqueira * Copyright 2004 Christian Costa * Copyright 2005 Oliver Stieber - * Copyright 2007 Stefan Dösinger for CodeWeavers + * Copyright 2007-2010 Stefan Dösinger for CodeWeavers * Copyright 2009 Henri Verbeet for CodeWeavers * * This library is free software; you can redistribute it and/or @@ -56,7 +56,13 @@ static inline BOOL buffer_add_dirty_area(struct wined3d_buffer *This, UINT offse } } - if(!offset && !size) + if(offset > This->resource.size || offset + size > This->resource.size) + { + WARN("Invalid range dirtified, marking entire buffer dirty\n"); + offset = 0; + size = This->resource.size; + } + else if(!offset && !size) { size = This->resource.size; } @@ -145,11 +151,6 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This) { TRACE("Gl usage = GL_STREAM_DRAW_ARB\n"); gl_usage = GL_STREAM_DRAW_ARB; - } - else - { - TRACE("Gl usage = GL_DYNAMIC_DRAW_ARB\n"); - gl_usage = GL_DYNAMIC_DRAW_ARB; if(gl_info->supported[APPLE_FLUSH_BUFFER_RANGE]) { @@ -157,6 +158,12 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This) checkGLcall("glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE)"); This->flags |= WINED3D_BUFFER_FLUSH; } + /* No setup is needed here for GL_ARB_map_buffer_range */ + } + else + { + TRACE("Gl usage = GL_DYNAMIC_DRAW_ARB\n"); + gl_usage = GL_DYNAMIC_DRAW_ARB; } /* Reserve memory for the buffer. The amount of data won't change @@ -483,7 +490,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This) * FLOAT16s if not supported. Also, we can't iterate over the array, so use macros to generate code for all * the attributes that our current fixed function pipeline implementation cares for. */ - BOOL support_d3dcolor = gl_info->supported[EXT_VERTEX_ARRAY_BGRA]; + BOOL support_d3dcolor = gl_info->supported[ARB_VERTEX_ARRAY_BGRA]; ret = buffer_check_attribute(This, si, WINED3D_FFP_POSITION, TRUE, TRUE, FALSE, &stride_this_run, &float16_used) || ret; ret = buffer_check_attribute(This, si, WINED3D_FFP_NORMAL, @@ -1026,6 +1033,51 @@ static WINED3DRESOURCETYPE STDMETHODCALLTYPE buffer_GetType(IWineD3DBuffer *ifac /* IWineD3DBuffer methods */ +static DWORD buffer_sanitize_flags(DWORD flags) +{ + /* Not all flags make sense together, but Windows never returns an error. Catch the + * cases that could cause issues */ + if(flags & WINED3DLOCK_READONLY) + { + if(flags & WINED3DLOCK_DISCARD) + { + WARN("WINED3DLOCK_READONLY combined with WINED3DLOCK_DISCARD, ignoring flags\n"); + return 0; + } + if(flags & WINED3DLOCK_NOOVERWRITE) + { + WARN("WINED3DLOCK_READONLY combined with WINED3DLOCK_NOOVERWRITE, ignoring flags\n"); + return 0; + } + } + else if((flags & (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE)) == (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE)) + { + WARN("WINED3DLOCK_DISCARD and WINED3DLOCK_NOOVERWRITE used together, ignoring\n"); + return 0; + } + + return flags; +} + +static GLbitfield buffer_gl_map_flags(DWORD d3d_flags) +{ + GLbitfield ret = 0; + + if (!(d3d_flags & WINED3DLOCK_READONLY)) ret = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT; + + if (d3d_flags & (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE)) + { + if(d3d_flags & WINED3DLOCK_DISCARD) ret |= GL_MAP_INVALIDATE_BUFFER_BIT; + ret |= GL_MAP_UNSYNCHRONIZED_BIT; + } + else + { + ret |= GL_MAP_READ_BIT; + } + + return ret; +} + static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, UINT size, BYTE **data, DWORD flags) { struct wined3d_buffer *This = (struct wined3d_buffer *)iface; @@ -1033,7 +1085,11 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, TRACE("iface %p, offset %u, size %u, data %p, flags %#x\n", iface, offset, size, data, flags); - if (!buffer_add_dirty_area(This, offset, size)) return E_OUTOFMEMORY; + flags = buffer_sanitize_flags(flags); + if (!(flags & WINED3DLOCK_READONLY)) + { + if (!buffer_add_dirty_area(This, offset, size)) return E_OUTOFMEMORY; + } count = InterlockedIncrement(&This->lock_count); @@ -1043,6 +1099,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, { IWineD3DDeviceImpl *device = This->resource.device; struct wined3d_context *context; + const struct wined3d_gl_info *gl_info; if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB) { @@ -1050,9 +1107,20 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, } context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + gl_info = context->gl_info; ENTER_GL(); GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object)); - This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB)); + + if (gl_info->supported[ARB_MAP_BUFFER_RANGE]) + { + GLbitfield mapflags = buffer_gl_map_flags(flags); + This->resource.allocatedMemory = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0, + This->resource.size, mapflags)); + } + else + { + This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB)); + } LEAVE_GL(); context_release(context); } @@ -1093,6 +1161,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface) if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER) && This->buffer_object) { IWineD3DDeviceImpl *device = This->resource.device; + const struct wined3d_gl_info *gl_info; struct wined3d_context *context; if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB) @@ -1101,10 +1170,21 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface) } context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + gl_info = context->gl_info; ENTER_GL(); GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object)); - if(This->flags & WINED3D_BUFFER_FLUSH) + if (gl_info->supported[ARB_MAP_BUFFER_RANGE]) + { + for(i = 0; i < This->modified_areas; i++) + { + GL_EXTCALL(glFlushMappedBufferRange(This->buffer_type_hint, + This->maps[i].offset, + This->maps[i].size)); + checkGLcall("glFlushMappedBufferRange"); + } + } + else if (This->flags & WINED3D_BUFFER_FLUSH) { for(i = 0; i < This->modified_areas; i++) { @@ -1196,8 +1276,7 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device, TRACE("size %#x, usage %#x, format %s, memory @ %p, iface @ %p.\n", buffer->resource.size, buffer->resource.usage, debug_d3dformat(buffer->resource.format_desc->format), buffer->resource.allocatedMemory, buffer); - /* TODO: GL_ARB_map_buffer_range */ - dynamic_buffer_ok = gl_info->supported[APPLE_FLUSH_BUFFER_RANGE]; + dynamic_buffer_ok = gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] || gl_info->supported[ARB_MAP_BUFFER_RANGE]; /* Observations show that drawStridedSlow is faster on dynamic VBs than converting + * drawStridedFast (half-life 2 and others). diff --git a/dll/directx/wine/wined3d/context.c b/dll/directx/wine/wined3d/context.c index 2aec7d6bfd3..08789855812 100644 --- a/dll/directx/wine/wined3d/context.c +++ b/dll/directx/wine/wined3d/context.c @@ -114,7 +114,7 @@ static void context_destroy_fbo(struct wined3d_context *context, GLuint *fbo) } /* GL locking is done by the caller */ -static void context_apply_attachment_filter_states(IWineD3DSurface *surface, BOOL force_preload) +static void context_apply_attachment_filter_states(IWineD3DSurface *surface) { const IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface; IWineD3DDeviceImpl *device = surface_impl->resource.device; @@ -148,7 +148,7 @@ static void context_apply_attachment_filter_states(IWineD3DSurface *surface, BOO IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture_impl); } - if (update_minfilter || update_magfilter || force_preload) + if (update_minfilter || update_magfilter) { GLenum target, bind_target; GLint old_binding; @@ -166,8 +166,6 @@ static void context_apply_attachment_filter_states(IWineD3DSurface *surface, BOO glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding); } - surface_internal_preload(surface, SRGB_RGB); - glBindTexture(bind_target, surface_impl->texture_name); if (update_minfilter) glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); if (update_magfilter) glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -208,7 +206,8 @@ void context_attach_depth_stencil_fbo(struct wined3d_context *context, } else { - context_apply_attachment_filter_states(depth_stencil, TRUE); + surface_prepare_texture(depth_stencil_impl, FALSE); + context_apply_attachment_filter_states(depth_stencil); if (format_flags & WINED3DFMT_FLAG_DEPTH) { @@ -253,14 +252,15 @@ void context_attach_depth_stencil_fbo(struct wined3d_context *context, void context_attach_surface_fbo(const struct wined3d_context *context, GLenum fbo_target, DWORD idx, IWineD3DSurface *surface) { - const IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface; + IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface; const struct wined3d_gl_info *gl_info = context->gl_info; TRACE("Attach surface %p to %u\n", surface, idx); if (surface) { - context_apply_attachment_filter_states(surface, TRUE); + surface_prepare_texture(surface_impl, FALSE); + context_apply_attachment_filter_states(surface); gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_COLOR_ATTACHMENT0 + idx, surface_impl->texture_target, surface_impl->texture_name, surface_impl->texture_level); @@ -431,10 +431,10 @@ static void context_apply_fbo_entry(struct wined3d_context *context, struct fbo_ for (i = 0; i < gl_info->limits.buffers; ++i) { if (device->render_targets[i]) - context_apply_attachment_filter_states(device->render_targets[i], FALSE); + context_apply_attachment_filter_states(device->render_targets[i]); } if (device->stencilBufferTarget) - context_apply_attachment_filter_states(device->stencilBufferTarget, FALSE); + context_apply_attachment_filter_states(device->stencilBufferTarget); } for (i = 0; i < gl_info->limits.buffers; ++i) @@ -532,32 +532,38 @@ void context_alloc_event_query(struct wined3d_context *context, struct wined3d_e if (context->free_event_query_count) { - query->id = context->free_event_queries[--context->free_event_query_count]; + query->object = context->free_event_queries[--context->free_event_query_count]; } else { - if (gl_info->supported[APPLE_FENCE]) + if (gl_info->supported[ARB_SYNC]) + { + /* Using ARB_sync, not much to do here. */ + query->object.sync = NULL; + TRACE("Allocated event query %p in context %p.\n", query->object.sync, context); + } + else if (gl_info->supported[APPLE_FENCE]) { ENTER_GL(); - GL_EXTCALL(glGenFencesAPPLE(1, &query->id)); + GL_EXTCALL(glGenFencesAPPLE(1, &query->object.id)); checkGLcall("glGenFencesAPPLE"); LEAVE_GL(); - TRACE("Allocated event query %u in context %p.\n", query->id, context); + TRACE("Allocated event query %u in context %p.\n", query->object.id, context); } else if(gl_info->supported[NV_FENCE]) { ENTER_GL(); - GL_EXTCALL(glGenFencesNV(1, &query->id)); + GL_EXTCALL(glGenFencesNV(1, &query->object.id)); checkGLcall("glGenFencesNV"); LEAVE_GL(); - TRACE("Allocated event query %u in context %p.\n", query->id, context); + TRACE("Allocated event query %u in context %p.\n", query->object.id, context); } else { WARN("Event queries not supported, not allocating query id.\n"); - query->id = 0; + query->object.id = 0; } } @@ -575,12 +581,12 @@ void context_free_event_query(struct wined3d_event_query *query) if (context->free_event_query_count >= context->free_event_query_size - 1) { UINT new_size = context->free_event_query_size << 1; - GLuint *new_data = HeapReAlloc(GetProcessHeap(), 0, context->free_event_queries, + union wined3d_gl_query_object *new_data = HeapReAlloc(GetProcessHeap(), 0, context->free_event_queries, new_size * sizeof(*context->free_event_queries)); if (!new_data) { - ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context); + ERR("Failed to grow free list, leaking query %u in context %p.\n", query->object.id, context); return; } @@ -588,7 +594,7 @@ void context_free_event_query(struct wined3d_event_query *query) context->free_event_queries = new_data; } - context->free_event_queries[context->free_event_query_count++] = query->id; + context->free_event_queries[context->free_event_query_count++] = query->object; } void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource, WINED3DRESOURCETYPE type) @@ -661,6 +667,7 @@ static void context_destroy_gl_resources(struct wined3d_context *context) struct fbo_entry *entry, *entry2; HGLRC restore_ctx; HDC restore_dc; + unsigned int i; restore_ctx = pwglGetCurrentContext(); restore_dc = pwglGetCurrentDC(); @@ -682,8 +689,12 @@ static void context_destroy_gl_resources(struct wined3d_context *context) { if (context->valid) { - if (gl_info->supported[APPLE_FENCE]) GL_EXTCALL(glDeleteFencesAPPLE(1, &event_query->id)); - else if (gl_info->supported[NV_FENCE]) GL_EXTCALL(glDeleteFencesNV(1, &event_query->id)); + if (gl_info->supported[ARB_SYNC]) + { + if (event_query->object.sync) GL_EXTCALL(glDeleteSync(event_query->object.sync)); + } + else if (gl_info->supported[APPLE_FENCE]) GL_EXTCALL(glDeleteFencesAPPLE(1, &event_query->object.id)); + else if (gl_info->supported[NV_FENCE]) GL_EXTCALL(glDeleteFencesNV(1, &event_query->object.id)); } event_query->context = NULL; } @@ -720,10 +731,24 @@ static void context_destroy_gl_resources(struct wined3d_context *context) if (gl_info->supported[ARB_OCCLUSION_QUERY]) GL_EXTCALL(glDeleteQueriesARB(context->free_occlusion_query_count, context->free_occlusion_queries)); - if (gl_info->supported[APPLE_FENCE]) - GL_EXTCALL(glDeleteFencesAPPLE(context->free_event_query_count, context->free_event_queries)); + if (gl_info->supported[ARB_SYNC]) + { + if (event_query->object.sync) GL_EXTCALL(glDeleteSync(event_query->object.sync)); + } + else if (gl_info->supported[APPLE_FENCE]) + { + for (i = 0; i < context->free_event_query_count; ++i) + { + GL_EXTCALL(glDeleteFencesAPPLE(1, &context->free_event_queries[i].id)); + } + } else if (gl_info->supported[NV_FENCE]) - GL_EXTCALL(glDeleteFencesNV(context->free_event_query_count, context->free_event_queries)); + { + for (i = 0; i < context->free_event_query_count; ++i) + { + GL_EXTCALL(glDeleteFencesNV(1, &context->free_event_queries[i].id)); + } + } checkGLcall("context cleanup"); } @@ -2131,6 +2156,8 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI if (context->render_offscreen) { FIXME("Activating for CTXUSAGE_BLIT for an offscreen target with ORM_FBO. This should be avoided.\n"); + surface_internal_preload(context->current_rt, SRGB_RGB); + ENTER_GL(); context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo); context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, context->current_rt); @@ -2189,6 +2216,9 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI } IWineD3DDeviceImpl_FindTexUnitMap(device); + device_preload_textures(device); + if (isStateDirty(context, STATE_VDECL)) + device_update_stream_info(device, context->gl_info); ENTER_GL(); for (i = 0; i < context->numDirtyEntries; ++i) diff --git a/dll/directx/wine/wined3d/device.c b/dll/directx/wine/wined3d/device.c index 34495d396d9..6682aa4635e 100644 --- a/dll/directx/wine/wined3d/device.c +++ b/dll/directx/wine/wined3d/device.c @@ -179,8 +179,6 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, { /* We need to deal with frequency data! */ IWineD3DVertexDeclarationImpl *declaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl; - UINT stream_count = This->stateBlock->streamIsUP ? 0 : declaration->num_streams; - const DWORD *streams = declaration->streams; unsigned int i; stream_info->use_map = 0; @@ -298,7 +296,7 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, stream_info->elements[idx].stream_idx = element->input_slot; stream_info->elements[idx].buffer_object = buffer_object; - if (!This->adapter->gl_info.supported[EXT_VERTEX_ARRAY_BGRA] + if (!This->adapter->gl_info.supported[ARB_VERTEX_ARRAY_BGRA] && element->format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) { stream_info->swizzle_map |= 1 << idx; @@ -307,17 +305,29 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, } } - /* Now call PreLoad on all the vertex buffers. In the very rare case - * that the buffers stopps converting PreLoad will dirtify the VDECL again. - * The vertex buffer can now use the strided structure in the device instead of finding its - * own again. - * - * NULL streams won't be recorded in the array, UP streams won't be either. A stream is only - * once in there. */ - for (i = 0; i < stream_count; ++i) + if (!This->stateBlock->streamIsUP) { - IWineD3DBuffer *vb = This->stateBlock->streamSource[streams[i]]; - if (vb) IWineD3DBuffer_PreLoad(vb); + WORD map = stream_info->use_map; + + /* PreLoad all the vertex buffers. */ + for (i = 0; map; map >>= 1, ++i) + { + struct wined3d_stream_info_element *element; + struct wined3d_buffer *buffer; + + if (!(map & 1)) continue; + + element = &stream_info->elements[i]; + buffer = (struct wined3d_buffer *)This->stateBlock->streamSource[element->stream_idx]; + IWineD3DBuffer_PreLoad((IWineD3DBuffer *)buffer); + + /* If PreLoad dropped the buffer object, update the stream info. */ + if (buffer->buffer_object != element->buffer_object) + { + element->buffer_object = 0; + element->data = buffer_get_sysmem(buffer) + (ptrdiff_t)element->data; + } + } } } @@ -332,7 +342,7 @@ static void stream_info_element_from_strided(const struct wined3d_gl_info *gl_in e->buffer_object = 0; } -void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, +static void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info) { unsigned int i; @@ -361,7 +371,7 @@ void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, { if (!stream_info->elements[i].format_desc) continue; - if (!gl_info->supported[EXT_VERTEX_ARRAY_BGRA] + if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && stream_info->elements[i].format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) { stream_info->swizzle_map |= 1 << i; @@ -370,6 +380,120 @@ void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, } } +static void device_trace_strided_stream_info(const struct wined3d_stream_info *stream_info) +{ + TRACE("Strided Data:\n"); + TRACE_STRIDED(stream_info, WINED3D_FFP_POSITION); + TRACE_STRIDED(stream_info, WINED3D_FFP_BLENDWEIGHT); + TRACE_STRIDED(stream_info, WINED3D_FFP_BLENDINDICES); + TRACE_STRIDED(stream_info, WINED3D_FFP_NORMAL); + TRACE_STRIDED(stream_info, WINED3D_FFP_PSIZE); + TRACE_STRIDED(stream_info, WINED3D_FFP_DIFFUSE); + TRACE_STRIDED(stream_info, WINED3D_FFP_SPECULAR); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD0); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD1); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD2); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD3); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD4); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD5); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD6); + TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD7); +} + +/* Context activation is done by the caller. */ +void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) +{ + struct wined3d_stream_info *stream_info = &device->strided_streams; + IWineD3DStateBlockImpl *stateblock = device->stateBlock; + BOOL vs = stateblock->vertexShader && device->vs_selected_mode != SHADER_NONE; + BOOL fixup = FALSE; + + if (device->up_strided) + { + /* Note: this is a ddraw fixed-function code path. */ + TRACE("=============================== Strided Input ================================\n"); + device_stream_info_from_strided(gl_info, device->up_strided, stream_info); + if (TRACE_ON(d3d)) device_trace_strided_stream_info(stream_info); + } + else + { + TRACE("============================= Vertex Declaration =============================\n"); + device_stream_info_from_declaration(device, vs, stream_info, &fixup); + } + + if (vs && !stream_info->position_transformed) + { + if (((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->half_float_conv_needed && !fixup) + { + TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion.\n"); + device->useDrawStridedSlow = TRUE; + } + else + { + device->useDrawStridedSlow = FALSE; + } + } + else + { + WORD slow_mask = (1 << WINED3D_FFP_PSIZE); + slow_mask |= -!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] + & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR)); + + if ((stream_info->position_transformed || (stream_info->use_map & slow_mask)) && !fixup) + { + device->useDrawStridedSlow = TRUE; + } + else + { + device->useDrawStridedSlow = FALSE; + } + } +} + +static void device_preload_texture(IWineD3DStateBlockImpl *stateblock, unsigned int idx) +{ + IWineD3DBaseTextureImpl *texture; + enum WINED3DSRGB srgb; + + if (!(texture = (IWineD3DBaseTextureImpl *)stateblock->textures[idx])) return; + srgb = stateblock->samplerState[idx][WINED3DSAMP_SRGBTEXTURE] ? SRGB_SRGB : SRGB_RGB; + texture->baseTexture.internal_preload((IWineD3DBaseTexture *)texture, srgb); +} + +void device_preload_textures(IWineD3DDeviceImpl *device) +{ + IWineD3DStateBlockImpl *stateblock = device->stateBlock; + unsigned int i; + + if (use_vs(stateblock)) + { + for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) + { + if (((IWineD3DBaseShaderImpl *)stateblock->vertexShader)->baseShader.reg_maps.sampler_type[i]) + device_preload_texture(stateblock, MAX_FRAGMENT_SAMPLERS + i); + } + } + + if (use_ps(stateblock)) + { + for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) + { + if (((IWineD3DBaseShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.sampler_type[i]) + device_preload_texture(stateblock, i); + } + } + else + { + WORD ffu_map = device->fixed_function_usage_map; + + for (i = 0; ffu_map; ffu_map >>= 1, ++i) + { + if (ffu_map & 1) + device_preload_texture(stateblock, i); + } + } +} + /********************************************************** * IUnknown parts follows **********************************************************/ @@ -596,7 +720,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UI IWineD3DSurfaceImpl *object; HRESULT hr; - TRACE("(%p) Create surface\n",This); + TRACE("iface %p, width %u, height %u, format %s (%#x), lockable %#x, discard %#x, level %u\n", + iface, Width, Height, debug_d3dformat(Format), Format, Lockable, Discard, Level); + TRACE("surface %p, usage %s (%#x), pool %s (%#x), multisample_type %#x, multisample_quality %u\n", + ppSurface, debug_d3dusage(Usage), Usage, debug_d3dpool(Pool), Pool, MultiSample, MultisampleQuality); + TRACE("surface_type %#x, parent %p, parent_ops %p.\n", Impl, parent, parent_ops); if (Impl == SURFACE_OPENGL && !This->adapter) { @@ -784,104 +912,33 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface return WINED3D_OK; } -static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUERYTYPE Type, IWineD3DQuery **ppQuery, IUnknown* parent) { +static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, + WINED3DQUERYTYPE type, IWineD3DQuery **query, IUnknown *parent) +{ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; - IWineD3DQueryImpl *object; /*NOTE: impl ref allowed since this is a create function */ - HRESULT hr = WINED3DERR_NOTAVAILABLE; - const IWineD3DQueryVtbl *vtable; + IWineD3DQueryImpl *object; + HRESULT hr; - /* Just a check to see if we support this type of query */ - switch(Type) { - case WINED3DQUERYTYPE_OCCLUSION: - TRACE("(%p) occlusion query\n", This); - if (gl_info->supported[ARB_OCCLUSION_QUERY]) - hr = WINED3D_OK; - else - WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY/NV_OCCLUSION_QUERY\n"); + TRACE("iface %p, type %#x, query %p, parent %p.\n", iface, type, query, parent); - vtable = &IWineD3DOcclusionQuery_Vtbl; - break; - - case WINED3DQUERYTYPE_EVENT: - if (!gl_info->supported[NV_FENCE] && !gl_info->supported[APPLE_FENCE]) - { - /* Half-Life 2 needs this query. It does not render the main menu correctly otherwise - * Pretend to support it, faking this query does not do much harm except potentially lowering performance - */ - FIXME("(%p) Event query: Unimplemented, but pretending to be supported\n", This); - } - vtable = &IWineD3DEventQuery_Vtbl; - hr = WINED3D_OK; - break; - - case WINED3DQUERYTYPE_VCACHE: - case WINED3DQUERYTYPE_RESOURCEMANAGER: - case WINED3DQUERYTYPE_VERTEXSTATS: - case WINED3DQUERYTYPE_TIMESTAMP: - case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: - case WINED3DQUERYTYPE_TIMESTAMPFREQ: - case WINED3DQUERYTYPE_PIPELINETIMINGS: - case WINED3DQUERYTYPE_INTERFACETIMINGS: - case WINED3DQUERYTYPE_VERTEXTIMINGS: - case WINED3DQUERYTYPE_PIXELTIMINGS: - case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: - case WINED3DQUERYTYPE_CACHEUTILIZATION: - default: - /* Use the base Query vtable until we have a special one for each query */ - vtable = &IWineD3DQuery_Vtbl; - FIXME("(%p) Unhandled query type %d\n", This, Type); + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate query memory.\n"); + return E_OUTOFMEMORY; } - if(NULL == ppQuery || hr != WINED3D_OK) { + + hr = query_init(object, This, type, parent); + if (FAILED(hr)) + { + WARN("Failed to initialize query, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); return hr; } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if(!object) - { - ERR("Out of memory\n"); - *ppQuery = NULL; - return WINED3DERR_OUTOFVIDEOMEMORY; - } + TRACE("Created query %p.\n", object); + *query = (IWineD3DQuery *)object; - object->lpVtbl = vtable; - object->type = Type; - object->state = QUERY_CREATED; - object->device = This; - object->parent = parent; - object->ref = 1; - - *ppQuery = (IWineD3DQuery *)object; - - /* allocated the 'extended' data based on the type of query requested */ - switch(Type){ - case WINED3DQUERYTYPE_OCCLUSION: - object->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_occlusion_query)); - ((struct wined3d_occlusion_query *)object->extendedData)->context = NULL; - break; - - case WINED3DQUERYTYPE_EVENT: - object->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_event_query)); - ((struct wined3d_event_query *)object->extendedData)->context = NULL; - break; - - case WINED3DQUERYTYPE_VCACHE: - case WINED3DQUERYTYPE_RESOURCEMANAGER: - case WINED3DQUERYTYPE_VERTEXSTATS: - case WINED3DQUERYTYPE_TIMESTAMP: - case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: - case WINED3DQUERYTYPE_TIMESTAMPFREQ: - case WINED3DQUERYTYPE_PIPELINETIMINGS: - case WINED3DQUERYTYPE_INTERFACETIMINGS: - case WINED3DQUERYTYPE_VERTEXTIMINGS: - case WINED3DQUERYTYPE_PIXELTIMINGS: - case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: - case WINED3DQUERYTYPE_CACHEUTILIZATION: - default: - object->extendedData = 0; - FIXME("(%p) Unhandled query type %d\n",This , Type); - } - TRACE("(%p) : Created Query %p\n", This, object); return WINED3D_OK; } @@ -1663,14 +1720,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, } } - /* Delete the palette conversion shader if it is around */ - if(This->paletteConversionShader) { - ENTER_GL(); - GL_EXTCALL(glDeleteProgramsARB(1, &This->paletteConversionShader)); - LEAVE_GL(); - This->paletteConversionShader = 0; - } - /* Delete the pbuffer context if there is any */ if(This->pbufferContext) context_destroy(This, This->pbufferContext); @@ -3054,15 +3103,17 @@ static void device_update_fixed_function_usage_map(IWineD3DDeviceImpl *This) { } } -static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) { +static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info) +{ unsigned int i, tex; WORD ffu_map; device_update_fixed_function_usage_map(This); ffu_map = This->fixed_function_usage_map; - if (This->max_ffp_textures == This->max_ffp_texture_stages || - This->stateBlock->lowest_disabled_stage <= This->max_ffp_textures) { + if (This->max_ffp_textures == gl_info->limits.texture_stages + || This->stateBlock->lowest_disabled_stage <= This->max_ffp_textures) + { for (i = 0; ffu_map; ffu_map >>= 1, ++i) { if (!(ffu_map & 1)) continue; @@ -3092,7 +3143,8 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) { } } -static void device_map_psamplers(IWineD3DDeviceImpl *This) { +static void device_map_psamplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info) +{ const WINED3DSAMPLER_TEXTURE_TYPE *sampler_type = ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.sampler_type; unsigned int i; @@ -3102,7 +3154,8 @@ static void device_map_psamplers(IWineD3DDeviceImpl *This) { { device_map_stage(This, i, i); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i)); - if (i < MAX_TEXTURES) { + if (i < gl_info->limits.texture_stages) + { markTextureStagesDirty(This, i); } } @@ -3133,11 +3186,12 @@ static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const DWORD *pshad return !vshader_sampler_tokens[current_mapping - MAX_FRAGMENT_SAMPLERS]; } -static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) { +static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct wined3d_gl_info *gl_info) +{ const WINED3DSAMPLER_TEXTURE_TYPE *vshader_sampler_type = ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.sampler_type; const WINED3DSAMPLER_TEXTURE_TYPE *pshader_sampler_type = NULL; - int start = min(MAX_COMBINED_SAMPLERS, This->adapter->gl_info.limits.combined_samplers) - 1; + int start = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers) - 1; int i; if (ps) { @@ -3174,7 +3228,9 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) { } } -void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) { +void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) +{ + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; BOOL vs = use_vs(This->stateBlock); BOOL ps = use_ps(This->stateBlock); /* @@ -3184,15 +3240,10 @@ void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) { * -> When the mapping of a stage is changed, sampler and ALL texture stage states have * to be reset. Because of that try to work with a 1:1 mapping as much as possible */ - if (ps) { - device_map_psamplers(This); - } else { - device_map_fixed_function_samplers(This); - } + if (ps) device_map_psamplers(This, gl_info); + else device_map_fixed_function_samplers(This, gl_info); - if (vs) { - device_map_vsamplers(This, ps); - } + if (vs) device_map_vsamplers(This, ps, gl_info); } static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader *pShader) { @@ -3806,11 +3857,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface, static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD Value) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; DWORD oldValue = This->updateStateBlock->textureState[Stage][Type]; + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; TRACE("(%p) : Stage=%d, Type=%s(%d), Value=%d\n", This, Stage, debug_d3dtexturestate(Type), Type, Value); - if (Stage >= MAX_TEXTURES) { - WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring\n", Stage, MAX_TEXTURES - 1); + if (Stage >= gl_info->limits.texture_stages) + { + WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring.\n", + Stage, gl_info->limits.texture_stages - 1); return WINED3D_OK; } @@ -3891,6 +3945,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, DWORD stage, IWineD3DBaseTexture *texture) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; IWineD3DBaseTexture *prev; TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture); @@ -3949,7 +4004,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADER); } - if (!prev && stage < MAX_TEXTURES) + if (!prev && stage < gl_info->limits.texture_stages) { /* The source arguments for color and alpha ops have different * meanings when a NULL texture is bound, so the COLOROP and @@ -3968,7 +4023,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, IWineD3DBaseTexture_Release(prev); - if (!texture && stage < MAX_TEXTURES) + if (!texture && stage < gl_info->limits.texture_stages) { IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_COLOROP)); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_ALPHAOP)); @@ -4206,7 +4261,6 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa const WINED3DVIEWPORT *vp = &This->stateBlock->viewport; UINT drawable_width, drawable_height; IWineD3DSurfaceImpl *depth_stencil = (IWineD3DSurfaceImpl *) This->stencilBufferTarget; - IWineD3DSwapChainImpl *swapchain = NULL; struct wined3d_context *context; /* When we're clearing parts of the drawable, make sure that the target surface is well up to date in the @@ -4376,12 +4430,7 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa LEAVE_GL(); - if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)target, &IID_IWineD3DSwapChain, (void **)&swapchain))) { - if (target == (IWineD3DSurfaceImpl*) swapchain->frontBuffer) { - wglFlush(); - } - IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain); - } + wglFlush(); /* Flush to ensure ordering across contexts. */ context_release(context); @@ -5340,6 +5389,9 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; struct wined3d_context *context; + if (rect) IWineD3DSurface_LoadLocation(surface, SFLAG_INDRAWABLE, NULL); + IWineD3DSurface_ModifyLocation(surface, SFLAG_INDRAWABLE, TRUE); + if (!surface_is_offscreen(surface)) { TRACE("Surface %p is onscreen\n", surface); @@ -5386,6 +5438,9 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, checkGLcall("glClear"); LEAVE_GL(); + + wglFlush(); /* Flush to ensure ordering across contexts. */ + context_release(context); } @@ -5685,6 +5740,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *ifa if(Swapchain->backBuffer[0]) { IWineD3DSurface_SetContainer(Swapchain->backBuffer[0], (IWineD3DBase *) Swapchain); ((IWineD3DSurfaceImpl *)Swapchain->backBuffer[0])->Flags |= SFLAG_SWAPCHAIN; + Swapchain->presentParms.BackBufferWidth = BackImpl->currentDesc.Width; + Swapchain->presentParms.BackBufferHeight = BackImpl->currentDesc.Height; + Swapchain->presentParms.BackBufferFormat = BackImpl->resource.format_desc->format; } else { HeapFree(GetProcessHeap(), 0, Swapchain->backBuffer); Swapchain->backBuffer = NULL; @@ -5738,6 +5796,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED break; } + /* Make sure the drawables are up-to-date. Note that loading the + * destination surface isn't strictly required if we overwrite the + * entire surface. */ + IWineD3DSurface_LoadLocation(src_surface, SFLAG_INDRAWABLE, NULL); + IWineD3DSurface_LoadLocation(dst_surface, SFLAG_INDRAWABLE, NULL); + /* Attach src surface to src fbo */ src_swapchain = get_swapchain(src_surface); dst_swapchain = get_swapchain(dst_surface); @@ -5753,9 +5817,6 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED GLenum buffer = surface_get_gl_buffer(src_surface); TRACE("Source surface %p is onscreen\n", src_surface); - /* Make sure the drawable is up to date. In the offscreen case - * attach_surface_fbo() implicitly takes care of this. */ - IWineD3DSurface_LoadLocation(src_surface, SFLAG_INDRAWABLE, NULL); if(buffer == GL_FRONT) { RECT windowsize; @@ -5792,9 +5853,6 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED GLenum buffer = surface_get_gl_buffer(dst_surface); TRACE("Destination surface %p is onscreen\n", dst_surface); - /* Make sure the drawable is up to date. In the offscreen case - * attach_surface_fbo() implicitly takes care of this. */ - IWineD3DSurface_LoadLocation(dst_surface, SFLAG_INDRAWABLE, NULL); if(buffer == GL_FRONT) { RECT windowsize; @@ -5839,6 +5897,9 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED } LEAVE_GL(); + + wglFlush(); /* Flush to ensure ordering across contexts. */ + context_release(context); IWineD3DSurface_ModifyLocation(dst_surface, SFLAG_INDRAWABLE, TRUE); @@ -6982,20 +7043,19 @@ HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, for (i = 0; i < PATCHMAP_SIZE; ++i) list_init(&device->patches[i]); select_shader_mode(&adapter->gl_info, &device->ps_selected_mode, &device->vs_selected_mode); - device->shader_backend = select_shader_backend(adapter, device_type); + device->shader_backend = adapter->shader_backend; memset(&shader_caps, 0, sizeof(shader_caps)); - device->shader_backend->shader_get_caps(device_type, &adapter->gl_info, &shader_caps); + device->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps); device->d3d_vshader_constantF = shader_caps.MaxVertexShaderConst; device->d3d_pshader_constantF = shader_caps.MaxPixelShaderConst; device->vs_clipping = shader_caps.VSClipping; memset(&ffp_caps, 0, sizeof(ffp_caps)); - fragment_pipeline = select_fragment_implementation(adapter, device_type); + fragment_pipeline = adapter->fragment_pipe; device->frag_pipe = fragment_pipeline; - fragment_pipeline->get_caps(device_type, &adapter->gl_info, &ffp_caps); + fragment_pipeline->get_caps(&adapter->gl_info, &ffp_caps); device->max_ffp_textures = ffp_caps.MaxSimultaneousTextures; - device->max_ffp_texture_stages = ffp_caps.MaxTextureBlendStages; hr = compile_state_table(device->StateTable, device->multistate_funcs, &adapter->gl_info, ffp_vertexstate_template, fragment_pipeline, misc_state_template); @@ -7006,7 +7066,7 @@ HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, return hr; } - device->blitter = select_blit_implementation(adapter, device_type); + device->blitter = adapter->blitter; return WINED3D_OK; } diff --git a/dll/directx/wine/wined3d/directx.c b/dll/directx/wine/wined3d/directx.c index 855f97ffdda..812e5ccc9e8 100644 --- a/dll/directx/wine/wined3d/directx.c +++ b/dll/directx/wine/wined3d/directx.c @@ -30,6 +30,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DECLARE_DEBUG_CHANNEL(d3d_caps); #define GLINFO_LOCATION (*gl_info) +#define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024) +#define MAKEDWORD_VERSION(maj, min) ((maj & 0xffff) << 16) | (min & 0xffff) /* The d3d device ID */ static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } }; @@ -43,17 +45,10 @@ static const struct { /* APPLE */ {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE, 0 }, {"GL_APPLE_fence", APPLE_FENCE, 0 }, - {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER, 0 }, - {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422, 0 }, {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS, 0 }, {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE, 0 }, - - /* ATI */ - {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL, 0 }, - {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3, 0 }, - {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE, 0 }, - {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER, 0 }, - {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC, 0 }, + {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER, 0 }, + {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422, 0 }, /* ARB */ {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT, 0 }, @@ -66,7 +61,9 @@ static const struct { {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT, 0 }, {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4, 0 }, {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL, 0 }, + {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX, 0 }, {"GL_ARB_imaging", ARB_IMAGING, 0 }, + {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE, 0 }, {"GL_ARB_multisample", ARB_MULTISAMPLE, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */ {"GL_ARB_multitexture", ARB_MULTITEXTURE, 0 }, {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY, 0 }, @@ -74,6 +71,10 @@ static const struct { {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS, 0 }, {"GL_ARB_point_sprite", ARB_POINT_SPRITE, 0 }, {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX, 0 }, + {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS, 0 }, + {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD, 0 }, + {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100, 0 }, + {"GL_ARB_sync", ARB_SYNC, 0 }, {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP, 0 }, {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION, 0 }, {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP, 0 }, @@ -85,23 +86,30 @@ static const struct { {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0) }, {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE, 0 }, {"GL_ARB_texture_rg", ARB_TEXTURE_RG, 0 }, + {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA, 0 }, {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND, 0 }, {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT, 0 }, {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM, 0 }, {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER, 0 }, - {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS, 0 }, - {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD, 0 }, - {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX, 0 }, + + /* ATI */ + {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER, 0 }, + {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL, 0 }, + {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC, 0 }, + {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3, 0 }, + {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE, 0 }, /* EXT */ {"GL_EXT_blend_color", EXT_BLEND_COLOR, 0 }, - {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX, 0 }, {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE, 0 }, {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE, 0 }, + {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX, 0 }, {"GL_EXT_fog_coord", EXT_FOG_COORD, 0 }, {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT, 0 }, {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE, 0 }, {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT, 0 }, + {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 }, + {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4, 0 }, {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL, 0 }, {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE, 0 }, {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS, 0 }, @@ -110,42 +118,36 @@ static const struct { {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE, 0 }, {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP, 0 }, {"GL_EXT_texture3D", EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2) }, - {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC, 0 }, {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC, 0 }, + {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC, 0 }, {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD, 0 }, {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE, 0 }, {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3, 0 }, - {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 }, - {"GL_EXT_texture_swizzle", EXT_TEXTURE_SWIZZLE, 0 }, {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC, 0 }, - {"GL_EXT_texture_lod", EXT_TEXTURE_LOD, 0 }, {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS, 0 }, + {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 }, {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA, 0 }, - {"GL_EXT_vertex_shader", EXT_VERTEX_SHADER, 0 }, - {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 }, /* NV */ - {"GL_NV_half_float", NV_HALF_FLOAT, 0 }, + {"GL_NV_depth_clamp", NV_DEPTH_CLAMP, 0 }, {"GL_NV_fence", NV_FENCE, 0 }, {"GL_NV_fog_distance", NV_FOG_DISTANCE, 0 }, {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM, 0 }, {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2, 0 }, + {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION, 0 }, + {"GL_NV_half_float", NV_HALF_FLOAT, 0 }, + {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT, 0 }, {"GL_NV_register_combiners", NV_REGISTER_COMBINERS, 0 }, {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2, 0 }, {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION, 0 }, {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4, 0 }, {"GL_NV_texture_shader", NV_TEXTURE_SHADER, 0 }, {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2, 0 }, - {"GL_NV_texture_shader3", NV_TEXTURE_SHADER3, 0 }, - {"GL_NV_occlusion_query", NV_OCCLUSION_QUERY, 0 }, {"GL_NV_vertex_program", NV_VERTEX_PROGRAM, 0 }, {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1, 0 }, {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2, 0 }, {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION, 0 }, {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3, 0 }, - {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION, 0 }, - {"GL_NV_depth_clamp", NV_DEPTH_CLAMP, 0 }, - {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT, 0 }, /* SGI */ {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP, 0 }, @@ -435,9 +437,9 @@ static DWORD ver_for_ext(GL_SupportedExt ext) } static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (vendor != VENDOR_ATI) return FALSE; + if (card_vendor != HW_VENDOR_ATI) return FALSE; if (device == CARD_ATI_RADEON_9500) return TRUE; if (device == CARD_ATI_RADEON_X700) return TRUE; if (device == CARD_ATI_RADEON_X1600) return TRUE; @@ -445,9 +447,9 @@ static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const c } static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (vendor == VENDOR_NVIDIA) + if (card_vendor == HW_VENDOR_NVIDIA) { if (device == CARD_NVIDIA_GEFORCEFX_5800 || device == CARD_NVIDIA_GEFORCEFX_5600) { @@ -458,7 +460,7 @@ static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl } static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to @@ -470,18 +472,15 @@ static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_re * like client storage might be supported on other implementations too, but GL_APPLE_flush_render * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So * the chance that other implementations support them is rather small since Win32 QuickTime uses - * DirectDraw, not OpenGL. */ - if (gl_info->supported[APPLE_FENCE] - && gl_info->supported[APPLE_CLIENT_STORAGE] - && gl_info->supported[APPLE_FLUSH_RENDER] - && gl_info->supported[APPLE_YCBCR_422]) + * DirectDraw, not OpenGL. + * + * This test has been moved into wined3d_guess_gl_vendor() + */ + if (gl_vendor == GL_VENDOR_APPLE) { return TRUE; } - else - { - return FALSE; - } + return FALSE; } /* Context activation is done by the caller. */ @@ -554,31 +553,29 @@ static void test_pbo_functionality(struct wined3d_gl_info *gl_info) } static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - return vendor == VENDOR_INTEL && match_apple(gl_info, gl_renderer, vendor, device); + return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE); } static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (!match_apple(gl_info, gl_renderer, vendor, device)) return FALSE; - if (vendor != VENDOR_ATI) return FALSE; + if (gl_vendor != GL_VENDOR_APPLE) return FALSE; + if (card_vendor != HW_VENDOR_ATI) return FALSE; if (device == CARD_ATI_RADEON_X1600) return FALSE; return TRUE; } static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (vendor != VENDOR_ATI) return FALSE; - if (match_apple(gl_info, gl_renderer, vendor, device)) return FALSE; - if (strstr(gl_renderer, "DRI")) return FALSE; /* Filter out Mesa DRI drivers. */ - return TRUE; + return (gl_vendor == GL_VENDOR_ATI); + } static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card. @@ -592,7 +589,7 @@ static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char /* A GL context is provided by the caller */ static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { GLenum error; DWORD data[16]; @@ -619,15 +616,15 @@ static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const } static BOOL match_apple_nvts(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { - if (!match_apple(gl_info, gl_renderer, vendor, device)) return FALSE; + if (!match_apple(gl_info, gl_renderer, gl_vendor, card_vendor, device)) return FALSE; return gl_info->supported[NV_TEXTURE_SHADER]; } /* A GL context is provided by the caller */ static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { GLuint prog; BOOL ret = FALSE; @@ -793,7 +790,6 @@ static void quirk_apple_nvts(struct wined3d_gl_info *gl_info) { gl_info->supported[NV_TEXTURE_SHADER] = FALSE; gl_info->supported[NV_TEXTURE_SHADER2] = FALSE; - gl_info->supported[NV_TEXTURE_SHADER3] = FALSE; } static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info) @@ -804,7 +800,7 @@ static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info) struct driver_quirk { BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device); + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device); void (*apply)(struct wined3d_gl_info *gl_info); const char *description; }; @@ -923,51 +919,51 @@ static const struct driver_version_information driver_version_table[] = * TNT/Geforce1/2 up to 71.x - driver uses numbering 7.1.8.6 for 71.86 * * All version numbers used below are from the Linux nvidia drivers. */ - {VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", 1, 8, 6 }, - {VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", 1, 8, 6 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", 1, 8, 6 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", 6, 4, 3 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", 1, 8, 6 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", 6, 10, 9371 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", 6, 10, 9371 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", 6, 10, 9371 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", 15, 11, 7516 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", 15, 11, 7516 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", 15, 11, 7516 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", 15, 11, 8585 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", 15, 11, 8585 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", 15, 11, 8585 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", 15, 11, 8618 }, - {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", 1, 8, 6 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", 1, 8, 6 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", 1, 8, 6 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", 6, 4, 3 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", 1, 8, 6 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", 6, 10, 9371 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", 6, 10, 9371 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", 6, 10, 9371 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", 15, 11, 7516 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", 15, 11, 7516 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", 15, 11, 7516 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", 15, 11, 8585 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", 15, 11, 8585 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", 15, 11, 8585 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", 15, 11, 8618 }, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", 15, 11, 8618 }, /* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode. */ - {VENDOR_ATI, CARD_ATI_RADEON_9500, "ATI Radeon 9500", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_X700, "ATI Radeon X700 SE", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_X1600, "ATI Radeon X1600 Series", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD2300, "ATI Mobility Radeon HD 2300", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD2600, "ATI Mobility Radeon HD 2600", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD2900, "ATI Radeon HD 2900 XT", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD4350, "ATI Radeon HD 4350", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD4600, "ATI Radeon HD 4600 Series", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD4700, "ATI Radeon HD 4700 Series", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD4800, "ATI Radeon HD 4800 Series", 14, 10, 6764 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD5700, "ATI Radeon HD 5700 Series", 14, 10, 8681 }, - {VENDOR_ATI, CARD_ATI_RADEON_HD5800, "ATI Radeon HD 5800 Series", 14, 10, 8681 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_9500, "ATI Radeon 9500", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_X700, "ATI Radeon X700 SE", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_X1600, "ATI Radeon X1600 Series", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2300, "ATI Mobility Radeon HD 2300", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2600, "ATI Mobility Radeon HD 2600", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2900, "ATI Radeon HD 2900 XT", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4350, "ATI Radeon HD 4350", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4600, "ATI Radeon HD 4600 Series", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4700, "ATI Radeon HD 4700 Series", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4800, "ATI Radeon HD 4800 Series", 14, 10, 6764 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD5700, "ATI Radeon HD 5700 Series", 14, 10, 8681 }, + {HW_VENDOR_ATI, CARD_ATI_RADEON_HD5800, "ATI Radeon HD 5800 Series", 14, 10, 8681 }, /* TODO: Add information about legacy ATI hardware, Intel and other cards. */ }; @@ -995,14 +991,15 @@ static void init_driver_info(struct wined3d_driver_info *driver_info, switch (vendor) { - case VENDOR_ATI: + case HW_VENDOR_ATI: driver_info->name = "ati2dvag.dll"; break; - case VENDOR_NVIDIA: + case HW_VENDOR_NVIDIA: driver_info->name = "nv4_disp.dll"; break; + case HW_VENDOR_INTEL: default: FIXME_(d3d_caps)("Unhandled vendor %04x.\n", vendor); driver_info->name = "Display"; @@ -1077,13 +1074,13 @@ static void init_driver_info(struct wined3d_driver_info *driver_info, /* Context activation is done by the caller. */ static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) + enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device) { unsigned int i; for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i) { - if (!quirk_table[i].match(gl_info, gl_renderer, vendor, device)) continue; + if (!quirk_table[i].match(gl_info, gl_renderer, gl_vendor, card_vendor, device)) continue; TRACE_(d3d_caps)("Applying driver quirk \"%s\".\n", quirk_table[i].description); quirk_table[i].apply(gl_info); } @@ -1110,34 +1107,760 @@ static DWORD wined3d_parse_gl_version(const char *gl_version) return MAKEDWORD_VERSION(major, minor); } -static enum wined3d_pci_vendor wined3d_guess_vendor(const char *gl_vendor, const char *gl_renderer) +static enum wined3d_gl_vendor wined3d_guess_gl_vendor(struct wined3d_gl_info *gl_info, const char *gl_vendor_string, const char *gl_renderer) { - if (strstr(gl_vendor, "NVIDIA")) - return VENDOR_NVIDIA; - if (strstr(gl_vendor, "ATI")) - return VENDOR_ATI; + /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from + * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to + * detect the Apple OpenGL implementation to apply some extension fixups afterwards. + * + * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks + * aren't sufficient either because a Linux binary may display on a macos X server via remote X11. + * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions + * like client storage might be supported on other implementations too, but GL_APPLE_flush_render + * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So + * the chance that other implementations support them is rather small since Win32 QuickTime uses + * DirectDraw, not OpenGL. */ + if (gl_info->supported[APPLE_FENCE] + && gl_info->supported[APPLE_CLIENT_STORAGE] + && gl_info->supported[APPLE_FLUSH_RENDER] + && gl_info->supported[APPLE_YCBCR_422]) + return GL_VENDOR_APPLE; - if (strstr(gl_vendor, "Intel(R)") + if (strstr(gl_vendor_string, "NVIDIA")) + return GL_VENDOR_NVIDIA; + + if (strstr(gl_vendor_string, "ATI")) + return GL_VENDOR_ATI; + + if (strstr(gl_vendor_string, "Intel(R)") || strstr(gl_renderer, "Intel(R)") - || strstr(gl_vendor, "Intel Inc.")) - return VENDOR_INTEL; + || strstr(gl_vendor_string, "Intel Inc.")) + return GL_VENDOR_INTEL; - if (strstr(gl_vendor, "Mesa") - || strstr(gl_vendor, "DRI R300 Project") - || strstr(gl_vendor, "Tungsten Graphics, Inc") - || strstr(gl_vendor, "VMware, Inc.")) - return VENDOR_MESA; + if (strstr(gl_vendor_string, "Mesa") + || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.") + || strstr(gl_vendor_string, "DRI R300 Project") + || strstr(gl_vendor_string, "X.Org R300 Project") + || strstr(gl_vendor_string, "Tungsten Graphics, Inc") + || strstr(gl_vendor_string, "VMware, Inc.") + || strstr(gl_renderer, "Mesa") + || strstr(gl_renderer, "Gallium")) + return GL_VENDOR_MESA; - FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning VENDOR_WINE.\n", debugstr_a(gl_vendor)); + FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_WINE.\n", debugstr_a(gl_vendor_string)); - return VENDOR_WINE; + return GL_VENDOR_WINE; } -static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer, - enum wined3d_pci_vendor *vendor, unsigned int *vidmem) +static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer) { - /* Below is a list of Nvidia and ATI GPUs. Both vendors have dozens of + if (strstr(gl_vendor_string, "NVIDIA")) + return HW_VENDOR_NVIDIA; + + if (strstr(gl_vendor_string, "ATI") + || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.") + || strstr(gl_vendor_string, "X.Org R300 Project") + || strstr(gl_vendor_string, "DRI R300 Project")) + return HW_VENDOR_ATI; + + if (strstr(gl_vendor_string, "Intel(R)") + || strstr(gl_renderer, "Intel(R)") + || strstr(gl_vendor_string, "Intel Inc.")) + return HW_VENDOR_INTEL; + + if (strstr(gl_vendor_string, "Mesa") + || strstr(gl_vendor_string, "Tungsten Graphics, Inc") + || strstr(gl_vendor_string, "VMware, Inc.")) + return HW_VENDOR_WINE; + + FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string)); + + return HW_VENDOR_NVIDIA; +} + + + +enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more + * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx. + */ + if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3]) + { + /* Geforce 200 - highend */ + if (strstr(gl_renderer, "GTX 280") + || strstr(gl_renderer, "GTX 285") + || strstr(gl_renderer, "GTX 295")) + { + *vidmem = 1024; + return CARD_NVIDIA_GEFORCE_GTX280; + } + + /* Geforce 200 - midend high */ + if (strstr(gl_renderer, "GTX 275")) + { + *vidmem = 896; + return CARD_NVIDIA_GEFORCE_GTX275; + } + + /* Geforce 200 - midend */ + if (strstr(gl_renderer, "GTX 260")) + { + *vidmem = 1024; + return CARD_NVIDIA_GEFORCE_GTX260; + } + /* Geforce 200 - midend */ + if (strstr(gl_renderer, "GT 240")) + { + *vidmem = 512; + return CARD_NVIDIA_GEFORCE_GT240; + } + + /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */ + if (strstr(gl_renderer, "9800") + || strstr(gl_renderer, "GTS 150") + || strstr(gl_renderer, "GTS 250")) + { + *vidmem = 512; + return CARD_NVIDIA_GEFORCE_9800GT; + } + + /* Geforce9 - midend */ + if (strstr(gl_renderer, "9600")) + { + *vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */ + return CARD_NVIDIA_GEFORCE_9600GT; + } + + /* Geforce9 - midend low / Geforce 200 - low */ + if (strstr(gl_renderer, "9500") + || strstr(gl_renderer, "GT 120") + || strstr(gl_renderer, "GT 130")) + { + *vidmem = 256; /* The 9500GT has 256-1024MB */ + return CARD_NVIDIA_GEFORCE_9500GT; + } + + /* Geforce9 - lowend */ + if (strstr(gl_renderer, "9400")) + { + *vidmem = 256; /* The 9400GT has 256-1024MB */ + return CARD_NVIDIA_GEFORCE_9400GT; + } + + /* Geforce9 - lowend low */ + if (strstr(gl_renderer, "9100") + || strstr(gl_renderer, "9200") + || strstr(gl_renderer, "9300") + || strstr(gl_renderer, "G 100")) + { + *vidmem = 256; /* The 9100-9300 cards have 256MB */ + return CARD_NVIDIA_GEFORCE_9200; + } + + /* Geforce8 - highend */ + if (strstr(gl_renderer, "8800")) + { + *vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */ + return CARD_NVIDIA_GEFORCE_8800GTS; + } + + /* Geforce8 - midend mobile */ + if (strstr(gl_renderer, "8600 M")) + { + *vidmem = 512; + return CARD_NVIDIA_GEFORCE_8600MGT; + } + + /* Geforce8 - midend */ + if (strstr(gl_renderer, "8600") + || strstr(gl_renderer, "8700")) + { + *vidmem = 256; + return CARD_NVIDIA_GEFORCE_8600GT; + } + + /* Geforce8 - lowend */ + if (strstr(gl_renderer, "8100") + || strstr(gl_renderer, "8200") + || strstr(gl_renderer, "8300") + || strstr(gl_renderer, "8400") + || strstr(gl_renderer, "8500")) + { + *vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */ + return CARD_NVIDIA_GEFORCE_8300GS; + } + + /* Geforce7 - highend */ + if (strstr(gl_renderer, "7800") + || strstr(gl_renderer, "7900") + || strstr(gl_renderer, "7950") + || strstr(gl_renderer, "Quadro FX 4") + || strstr(gl_renderer, "Quadro FX 5")) + { + *vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */ + return CARD_NVIDIA_GEFORCE_7800GT; + } + + /* Geforce7 midend */ + if (strstr(gl_renderer, "7600") + || strstr(gl_renderer, "7700")) + { + *vidmem = 256; /* The 7600 uses 256-512MB */ + return CARD_NVIDIA_GEFORCE_7600; + } + + /* Geforce7 lower medium */ + if (strstr(gl_renderer, "7400")) + { + *vidmem = 256; /* The 7400 uses 256-512MB */ + return CARD_NVIDIA_GEFORCE_7400; + } + + /* Geforce7 lowend */ + if (strstr(gl_renderer, "7300")) + { + *vidmem = 256; /* Mac Pros with this card have 256 MB */ + return CARD_NVIDIA_GEFORCE_7300; + } + + /* Geforce6 highend */ + if (strstr(gl_renderer, "6800")) + { + *vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */ + return CARD_NVIDIA_GEFORCE_6800; + } + + /* Geforce6 - midend */ + if (strstr(gl_renderer, "6600") + || strstr(gl_renderer, "6610") + || strstr(gl_renderer, "6700")) + { + *vidmem = 128; /* A 6600GT has 128-256MB */ + return CARD_NVIDIA_GEFORCE_6600GT; + } + + /* Geforce6/7 lowend */ + *vidmem = 64; /* */ + return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */ + } + + if (WINE_D3D9_CAPABLE(gl_info)) + { + /* GeforceFX - highend */ + if (strstr(gl_renderer, "5800") + || strstr(gl_renderer, "5900") + || strstr(gl_renderer, "5950") + || strstr(gl_renderer, "Quadro FX")) + { + *vidmem = 256; /* 5800-5900 cards use 256MB */ + return CARD_NVIDIA_GEFORCEFX_5800; + } + + /* GeforceFX - midend */ + if (strstr(gl_renderer, "5600") + || strstr(gl_renderer, "5650") + || strstr(gl_renderer, "5700") + || strstr(gl_renderer, "5750")) + { + *vidmem = 128; /* A 5600 uses 128-256MB */ + return CARD_NVIDIA_GEFORCEFX_5600; + } + + /* GeforceFX - lowend */ + *vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */ + return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */ + } + + if (WINE_D3D8_CAPABLE(gl_info)) + { + if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4")) + { + *vidmem = 64; /* Geforce4 Ti cards have 64-128MB */ + return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */ + } + + *vidmem = 64; /* Geforce3 cards have 64-128MB */ + return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */ + } + + if (WINE_D3D7_CAPABLE(gl_info)) + { + if (strstr(gl_renderer, "GeForce4 MX")) + { + /* Most Geforce4MX GPUs have at least 64MB of memory, some + * early models had 32MB but most have 64MB or even 128MB. */ + *vidmem = 64; + return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */ + } + + if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR")) + { + *vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */ + return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */ + } + + if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2")) + { + *vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */ + return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */ + } + + /* Most Geforce1 cards have 32MB, there are also some rare 16 + * and 64MB (Dell) models. */ + *vidmem = 32; + return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */ + } + + if (strstr(gl_renderer, "TNT2")) + { + *vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */ + return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */ + } + + *vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */ + return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */ + +} + +enum wined3d_pci_device select_card_ati_binary(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx + * + * Beware: renderer string do not match exact card model, + * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */ + if (WINE_D3D9_CAPABLE(gl_info)) + { + /* Radeon EG CYPRESS XT / PRO HD5800 - highend */ + if (strstr(gl_renderer, "HD 5800") /* Radeon EG CYPRESS HD58xx generic renderer string */ + || strstr(gl_renderer, "HD 5850") /* Radeon EG CYPRESS XT */ + || strstr(gl_renderer, "HD 5870")) /* Radeon EG CYPRESS PRO */ + { + *vidmem = 1024; /* note: HD58xx cards use 1024MB */ + return CARD_ATI_RADEON_HD5800; + } + + /* Radeon EG JUNIPER XT / LE HD5700 - midend */ + if (strstr(gl_renderer, "HD 5700") /* Radeon EG JUNIPER HD57xx generic renderer string */ + || strstr(gl_renderer, "HD 5750") /* Radeon EG JUNIPER LE */ + || strstr(gl_renderer, "HD 5770")) /* Radeon EG JUNIPER XT */ + { + *vidmem = 512; /* note: HD5770 cards use 1024MB and HD5750 cards use 512MB or 1024MB */ + return CARD_ATI_RADEON_HD5700; + } + + /* Radeon R7xx HD4800 - highend */ + if (strstr(gl_renderer, "HD 4800") /* Radeon RV7xx HD48xx generic renderer string */ + || strstr(gl_renderer, "HD 4830") /* Radeon RV770 */ + || strstr(gl_renderer, "HD 4850") /* Radeon RV770 */ + || strstr(gl_renderer, "HD 4870") /* Radeon RV770 */ + || strstr(gl_renderer, "HD 4890")) /* Radeon RV790 */ + { + *vidmem = 512; /* note: HD4890 cards use 1024MB */ + return CARD_ATI_RADEON_HD4800; + } + + /* Radeon R740 HD4700 - midend */ + if (strstr(gl_renderer, "HD 4700") /* Radeon RV770 */ + || strstr(gl_renderer, "HD 4770")) /* Radeon RV740 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4700; + } + + /* Radeon R730 HD4600 - midend */ + if (strstr(gl_renderer, "HD 4600") /* Radeon RV730 */ + || strstr(gl_renderer, "HD 4650") /* Radeon RV730 */ + || strstr(gl_renderer, "HD 4670")) /* Radeon RV730 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4600; + } + + /* Radeon R710 HD4500/HD4350 - lowend */ + if (strstr(gl_renderer, "HD 4350") /* Radeon RV710 */ + || strstr(gl_renderer, "HD 4550")) /* Radeon RV710 */ + { + *vidmem = 256; + return CARD_ATI_RADEON_HD4350; + } + + /* Radeon R6xx HD2900/HD3800 - highend */ + if (strstr(gl_renderer, "HD 2900") + || strstr(gl_renderer, "HD 3870") + || strstr(gl_renderer, "HD 3850")) + { + *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */ + return CARD_ATI_RADEON_HD2900; + } + + /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */ + if (strstr(gl_renderer, "HD 2600") + || strstr(gl_renderer, "HD 3830") + || strstr(gl_renderer, "HD 3690") + || strstr(gl_renderer, "HD 3650")) + { + *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */ + return CARD_ATI_RADEON_HD2600; + } + + /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */ + if (strstr(gl_renderer, "HD 2300") + || strstr(gl_renderer, "HD 2400") + || strstr(gl_renderer, "HD 3470") + || strstr(gl_renderer, "HD 3450") + || strstr(gl_renderer, "HD 3430") + || strstr(gl_renderer, "HD 3400")) + { + *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */ + return CARD_ATI_RADEON_HD2300; + } + + /* Radeon R6xx/R7xx integrated */ + if (strstr(gl_renderer, "HD 3100") + || strstr(gl_renderer, "HD 3200") + || strstr(gl_renderer, "HD 3300")) + { + *vidmem = 128; /* 128MB */ + return CARD_ATI_RADEON_HD3200; + } + + /* Radeon R5xx */ + if (strstr(gl_renderer, "X1600") + || strstr(gl_renderer, "X1650") + || strstr(gl_renderer, "X1800") + || strstr(gl_renderer, "X1900") + || strstr(gl_renderer, "X1950")) + { + *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */ + return CARD_ATI_RADEON_X1600; + } + + /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */ + if (strstr(gl_renderer, "X700") + || strstr(gl_renderer, "X800") + || strstr(gl_renderer, "X850") + || strstr(gl_renderer, "X1300") + || strstr(gl_renderer, "X1400") + || strstr(gl_renderer, "X1450") + || strstr(gl_renderer, "X1550")) + { + *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */ + return CARD_ATI_RADEON_X700; + } + + /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */ + if (strstr(gl_renderer, "Radeon Xpress")) + { + *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */ + return CARD_ATI_RADEON_XPRESS_200M; + } + + /* Radeon R3xx */ + *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */ + return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */ + } + + if (WINE_D3D8_CAPABLE(gl_info)) + { + *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */ + return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */ + } + + if (WINE_D3D7_CAPABLE(gl_info)) + { + *vidmem = 32; /* There are models with up to 64MB */ + return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */ + } + + *vidmem = 16; /* There are 16-32MB models */ + return CARD_ATI_RAGE_128PRO; + +} + +enum wined3d_pci_device select_card_intel_binary(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + if (strstr(gl_renderer, "X3100")) + { + /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */ + *vidmem = 128; + return CARD_INTEL_X3100; + } + + if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM")) + { + /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */ + *vidmem = 64; + return CARD_INTEL_I945GM; + } + + if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM; + if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G; + if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G; + if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G; + if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G; + return CARD_INTEL_I915G; + +} + +enum wined3d_pci_device (select_card_ati_mesa)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx + * + * Beware: renderer string do not match exact card model, + * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */ + if (strstr(gl_renderer, "Gallium")) + { + /* Radeon R7xx HD4800 - highend */ + if (strstr(gl_renderer, "R700") /* Radeon R7xx HD48xx generic renderer string */ + || strstr(gl_renderer, "RV770") /* Radeon RV770 */ + || strstr(gl_renderer, "RV790")) /* Radeon RV790 */ + { + *vidmem = 512; /* note: HD4890 cards use 1024MB */ + return CARD_ATI_RADEON_HD4800; + } + + /* Radeon R740 HD4700 - midend */ + if (strstr(gl_renderer, "RV740")) /* Radeon RV740 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4700; + } + + /* Radeon R730 HD4600 - midend */ + if (strstr(gl_renderer, "RV730")) /* Radeon RV730 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4600; + } + + /* Radeon R710 HD4500/HD4350 - lowend */ + if (strstr(gl_renderer, "RV710")) /* Radeon RV710 */ + { + *vidmem = 256; + return CARD_ATI_RADEON_HD4350; + } + + /* Radeon R6xx HD2900/HD3800 - highend */ + if (strstr(gl_renderer, "R600") + || strstr(gl_renderer, "RV670") + || strstr(gl_renderer, "R680")) + { + *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */ + return CARD_ATI_RADEON_HD2900; + } + + /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */ + if (strstr(gl_renderer, "RV630") + || strstr(gl_renderer, "RV635")) + { + *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */ + return CARD_ATI_RADEON_HD2600; + } + + /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */ + if (strstr(gl_renderer, "RV610") + || strstr(gl_renderer, "RV620")) + { + *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */ + return CARD_ATI_RADEON_HD2300; + } + + /* Radeon R6xx/R7xx integrated */ + if (strstr(gl_renderer, "RS780") + || strstr(gl_renderer, "RS880")) + { + *vidmem = 128; /* 128MB */ + return CARD_ATI_RADEON_HD3200; + } + + /* Radeon R5xx */ + if (strstr(gl_renderer, "RV530") + || strstr(gl_renderer, "RV535") + || strstr(gl_renderer, "RV560") + || strstr(gl_renderer, "R520") + || strstr(gl_renderer, "RV570") + || strstr(gl_renderer, "R580")) + { + *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */ + return CARD_ATI_RADEON_X1600; + } + + /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */ + if (strstr(gl_renderer, "R410") + || strstr(gl_renderer, "R420") + || strstr(gl_renderer, "R423") + || strstr(gl_renderer, "R430") + || strstr(gl_renderer, "R480") + || strstr(gl_renderer, "R481") + || strstr(gl_renderer, "RV410") + || strstr(gl_renderer, "RV515") + || strstr(gl_renderer, "RV516")) + { + *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */ + return CARD_ATI_RADEON_X700; + } + + /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */ + if (strstr(gl_renderer, "RS400") + || strstr(gl_renderer, "RS480") + || strstr(gl_renderer, "RS482") + || strstr(gl_renderer, "RS485") + || strstr(gl_renderer, "RS600") + || strstr(gl_renderer, "RS690") + || strstr(gl_renderer, "RS740")) + { + *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */ + return CARD_ATI_RADEON_XPRESS_200M; + } + + /* Radeon R3xx */ + if (strstr(gl_renderer, "R300") + || strstr(gl_renderer, "RV350") + || strstr(gl_renderer, "RV351") + || strstr(gl_renderer, "RV360") + || strstr(gl_renderer, "RV370") + || strstr(gl_renderer, "R350") + || strstr(gl_renderer, "R360")) + { + *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */ + return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */ + } + } + + if (WINE_D3D9_CAPABLE(gl_info)) + { + /* Radeon R7xx HD4800 - highend */ + if (strstr(gl_renderer, "(R700") /* Radeon R7xx HD48xx generic renderer string */ + || strstr(gl_renderer, "(RV770") /* Radeon RV770 */ + || strstr(gl_renderer, "(RV790")) /* Radeon RV790 */ + { + *vidmem = 512; /* note: HD4890 cards use 1024MB */ + return CARD_ATI_RADEON_HD4800; + } + + /* Radeon R740 HD4700 - midend */ + if (strstr(gl_renderer, "(RV740")) /* Radeon RV740 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4700; + } + + /* Radeon R730 HD4600 - midend */ + if (strstr(gl_renderer, "(RV730")) /* Radeon RV730 */ + { + *vidmem = 512; + return CARD_ATI_RADEON_HD4600; + } + + /* Radeon R710 HD4500/HD4350 - lowend */ + if (strstr(gl_renderer, "(RV710")) /* Radeon RV710 */ + { + *vidmem = 256; + return CARD_ATI_RADEON_HD4350; + } + + /* Radeon R6xx HD2900/HD3800 - highend */ + if (strstr(gl_renderer, "(R600") + || strstr(gl_renderer, "(RV670") + || strstr(gl_renderer, "(R680")) + { + *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */ + return CARD_ATI_RADEON_HD2900; + } + + /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */ + if (strstr(gl_renderer, "(RV630") + || strstr(gl_renderer, "(RV635")) + { + *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */ + return CARD_ATI_RADEON_HD2600; + } + + /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */ + if (strstr(gl_renderer, "(RV610") + || strstr(gl_renderer, "(RV620")) + { + *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */ + return CARD_ATI_RADEON_HD2300; + } + + /* Radeon R6xx/R7xx integrated */ + if (strstr(gl_renderer, "(RS780") + || strstr(gl_renderer, "(RS880")) + { + *vidmem = 128; /* 128MB */ + return CARD_ATI_RADEON_HD3200; + } + } + + if (WINE_D3D8_CAPABLE(gl_info)) + { + *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */ + return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */ + } + + if (WINE_D3D7_CAPABLE(gl_info)) + { + *vidmem = 32; /* There are models with up to 64MB */ + return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */ + } + + *vidmem = 16; /* There are 16-32MB models */ + return CARD_ATI_RAGE_128PRO; + +} + +enum wined3d_pci_device (select_card_nvidia_mesa)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + FIXME_(d3d_caps)("Card selection not handled for Mesa Nouveau driver\n"); + if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600; + if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3; + if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE; + if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT; + return CARD_NVIDIA_RIVA_128; +} + +enum wined3d_pci_device (select_card_intel_mesa)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ) +{ + FIXME_(d3d_caps)("Card selection not handled for Mesa Intel driver\n"); + return CARD_INTEL_I915G; +} + + +struct vendor_card_selection +{ + enum wined3d_gl_vendor gl_vendor; + enum wined3d_pci_vendor card_vendor; + const char *description; /* Description of the card selector i.e. Apple OS/X Intel */ + enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + unsigned int *vidmem ); +}; + +static const struct vendor_card_selection vendor_card_select_table[] = +{ + {GL_VENDOR_NVIDIA, HW_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary}, + {GL_VENDOR_APPLE, HW_VENDOR_NVIDIA, "Apple OSX NVidia binary driver", select_card_nvidia_binary}, + {GL_VENDOR_APPLE, HW_VENDOR_ATI, "Apple OSX AMD/ATI binary driver", select_card_ati_binary}, + {GL_VENDOR_APPLE, HW_VENDOR_INTEL, "Apple OSX Intel binary driver", select_card_intel_binary}, + {GL_VENDOR_ATI, HW_VENDOR_ATI, "AMD/ATI binary driver", select_card_ati_binary}, + {GL_VENDOR_MESA, HW_VENDOR_ATI, "Mesa AMD/ATI driver", select_card_ati_mesa}, + {GL_VENDOR_MESA, HW_VENDOR_NVIDIA, "Mesa Nouveau driver", select_card_nvidia_mesa}, + {GL_VENDOR_MESA, HW_VENDOR_INTEL, "Mesa Intel driver", select_card_intel_mesa} +}; + + +static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer, + enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor, unsigned int *vidmem) +{ + /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of * different GPUs with roughly the same features. In most cases GPUs from a * certain family differ in clockspeeds, the amount of video memory and the * number of shader pipelines. @@ -1192,451 +1915,84 @@ static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info * * memory behind our backs if really needed. Note that the amount of video * memory can be overruled using a registry setting. */ - switch (*vendor) + int i; + + for (i = 0; i < (sizeof(vendor_card_select_table) / sizeof(*vendor_card_select_table)); ++i) { - case VENDOR_NVIDIA: - /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more - * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx. - */ - if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3]) - { - /* Geforce 200 - highend */ - if (strstr(gl_renderer, "GTX 280") - || strstr(gl_renderer, "GTX 285") - || strstr(gl_renderer, "GTX 295")) - { - *vidmem = 1024; - return CARD_NVIDIA_GEFORCE_GTX280; - } - - /* Geforce 200 - midend high */ - if (strstr(gl_renderer, "GTX 275")) - { - *vidmem = 896; - return CARD_NVIDIA_GEFORCE_GTX275; - } - - /* Geforce 200 - midend */ - if (strstr(gl_renderer, "GTX 260")) - { - *vidmem = 1024; - return CARD_NVIDIA_GEFORCE_GTX260; - } - /* Geforce 200 - midend */ - if (strstr(gl_renderer, "GT 240")) - { - *vidmem = 512; - return CARD_NVIDIA_GEFORCE_GT240; - } - - /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */ - if (strstr(gl_renderer, "9800") - || strstr(gl_renderer, "GTS 150") - || strstr(gl_renderer, "GTS 250")) - { - *vidmem = 512; - return CARD_NVIDIA_GEFORCE_9800GT; - } - - /* Geforce9 - midend */ - if (strstr(gl_renderer, "9600")) - { - *vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */ - return CARD_NVIDIA_GEFORCE_9600GT; - } - - /* Geforce9 - midend low / Geforce 200 - low */ - if (strstr(gl_renderer, "9500") - || strstr(gl_renderer, "GT 120") - || strstr(gl_renderer, "GT 130")) - { - *vidmem = 256; /* The 9500GT has 256-1024MB */ - return CARD_NVIDIA_GEFORCE_9500GT; - } - - /* Geforce9 - lowend */ - if (strstr(gl_renderer, "9400")) - { - *vidmem = 256; /* The 9400GT has 256-1024MB */ - return CARD_NVIDIA_GEFORCE_9400GT; - } - - /* Geforce9 - lowend low */ - if (strstr(gl_renderer, "9100") - || strstr(gl_renderer, "9200") - || strstr(gl_renderer, "9300") - || strstr(gl_renderer, "G 100")) - { - *vidmem = 256; /* The 9100-9300 cards have 256MB */ - return CARD_NVIDIA_GEFORCE_9200; - } - - /* Geforce8 - highend */ - if (strstr(gl_renderer, "8800")) - { - *vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */ - return CARD_NVIDIA_GEFORCE_8800GTS; - } - - /* Geforce8 - midend mobile */ - if (strstr(gl_renderer, "8600 M")) - { - *vidmem = 512; - return CARD_NVIDIA_GEFORCE_8600MGT; - } - - /* Geforce8 - midend */ - if (strstr(gl_renderer, "8600") - || strstr(gl_renderer, "8700")) - { - *vidmem = 256; - return CARD_NVIDIA_GEFORCE_8600GT; - } - - /* Geforce8 - lowend */ - if (strstr(gl_renderer, "8100") - || strstr(gl_renderer, "8200") - || strstr(gl_renderer, "8300") - || strstr(gl_renderer, "8400") - || strstr(gl_renderer, "8500")) - { - *vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */ - return CARD_NVIDIA_GEFORCE_8300GS; - } - - /* Geforce7 - highend */ - if (strstr(gl_renderer, "7800") - || strstr(gl_renderer, "7900") - || strstr(gl_renderer, "7950") - || strstr(gl_renderer, "Quadro FX 4") - || strstr(gl_renderer, "Quadro FX 5")) - { - *vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */ - return CARD_NVIDIA_GEFORCE_7800GT; - } - - /* Geforce7 midend */ - if (strstr(gl_renderer, "7600") - || strstr(gl_renderer, "7700")) - { - *vidmem = 256; /* The 7600 uses 256-512MB */ - return CARD_NVIDIA_GEFORCE_7600; - } - - /* Geforce7 lower medium */ - if (strstr(gl_renderer, "7400")) - { - *vidmem = 256; /* The 7400 uses 256-512MB */ - return CARD_NVIDIA_GEFORCE_7400; - } - - /* Geforce7 lowend */ - if (strstr(gl_renderer, "7300")) - { - *vidmem = 256; /* Mac Pros with this card have 256 MB */ - return CARD_NVIDIA_GEFORCE_7300; - } - - /* Geforce6 highend */ - if (strstr(gl_renderer, "6800")) - { - *vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */ - return CARD_NVIDIA_GEFORCE_6800; - } - - /* Geforce6 - midend */ - if (strstr(gl_renderer, "6600") - || strstr(gl_renderer, "6610") - || strstr(gl_renderer, "6700")) - { - *vidmem = 128; /* A 6600GT has 128-256MB */ - return CARD_NVIDIA_GEFORCE_6600GT; - } - - /* Geforce6/7 lowend */ - *vidmem = 64; /* */ - return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */ - } - - if (WINE_D3D9_CAPABLE(gl_info)) - { - /* GeforceFX - highend */ - if (strstr(gl_renderer, "5800") - || strstr(gl_renderer, "5900") - || strstr(gl_renderer, "5950") - || strstr(gl_renderer, "Quadro FX")) - { - *vidmem = 256; /* 5800-5900 cards use 256MB */ - return CARD_NVIDIA_GEFORCEFX_5800; - } - - /* GeforceFX - midend */ - if (strstr(gl_renderer, "5600") - || strstr(gl_renderer, "5650") - || strstr(gl_renderer, "5700") - || strstr(gl_renderer, "5750")) - { - *vidmem = 128; /* A 5600 uses 128-256MB */ - return CARD_NVIDIA_GEFORCEFX_5600; - } - - /* GeforceFX - lowend */ - *vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */ - return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */ - } - - if (WINE_D3D8_CAPABLE(gl_info)) - { - if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4")) - { - *vidmem = 64; /* Geforce4 Ti cards have 64-128MB */ - return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */ - } - - *vidmem = 64; /* Geforce3 cards have 64-128MB */ - return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */ - } - - if (WINE_D3D7_CAPABLE(gl_info)) - { - if (strstr(gl_renderer, "GeForce4 MX")) - { - /* Most Geforce4MX GPUs have at least 64MB of memory, some - * early models had 32MB but most have 64MB or even 128MB. */ - *vidmem = 64; - return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */ - } - - if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR")) - { - *vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */ - return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */ - } - - if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2")) - { - *vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */ - return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */ - } - - /* Most Geforce1 cards have 32MB, there are also some rare 16 - * and 64MB (Dell) models. */ - *vidmem = 32; - return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */ - } - - if (strstr(gl_renderer, "TNT2")) - { - *vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */ - return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */ - } - - *vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */ - return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */ - - case VENDOR_ATI: - /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx - * - * Beware: renderer string do not match exact card model, - * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */ - if (WINE_D3D9_CAPABLE(gl_info)) - { - /* Radeon EG CYPRESS XT / PRO HD5800 - highend */ - if (strstr(gl_renderer, "HD 5800") /* Radeon EG CYPRESS HD58xx generic renderer string */ - || strstr(gl_renderer, "HD 5850") /* Radeon EG CYPRESS XT */ - || strstr(gl_renderer, "HD 5870")) /* Radeon EG CYPRESS PRO */ - { - *vidmem = 1024; /* note: HD58xx cards use 1024MB */ - return CARD_ATI_RADEON_HD5800; - } - - /* Radeon EG JUNIPER XT / LE HD5700 - midend */ - if (strstr(gl_renderer, "HD 5700") /* Radeon EG JUNIPER HD57xx generic renderer string */ - || strstr(gl_renderer, "HD 5750") /* Radeon EG JUNIPER LE */ - || strstr(gl_renderer, "HD 5770")) /* Radeon EG JUNIPER XT */ - { - *vidmem = 512; /* note: HD5770 cards use 1024MB and HD5750 cards use 512MB or 1024MB */ - return CARD_ATI_RADEON_HD5700; - } - - /* Radeon R7xx HD4800 - highend */ - if (strstr(gl_renderer, "HD 4800") /* Radeon RV7xx HD48xx generic renderer string */ - || strstr(gl_renderer, "HD 4830") /* Radeon RV770 */ - || strstr(gl_renderer, "HD 4850") /* Radeon RV770 */ - || strstr(gl_renderer, "HD 4870") /* Radeon RV770 */ - || strstr(gl_renderer, "HD 4890")) /* Radeon RV790 */ - { - *vidmem = 512; /* note: HD4890 cards use 1024MB */ - return CARD_ATI_RADEON_HD4800; - } - - /* Radeon R740 HD4700 - midend */ - if (strstr(gl_renderer, "HD 4700") /* Radeon RV770 */ - || strstr(gl_renderer, "HD 4770")) /* Radeon RV740 */ - { - *vidmem = 512; - return CARD_ATI_RADEON_HD4700; - } - - /* Radeon R730 HD4600 - midend */ - if (strstr(gl_renderer, "HD 4600") /* Radeon RV730 */ - || strstr(gl_renderer, "HD 4650") /* Radeon RV730 */ - || strstr(gl_renderer, "HD 4670")) /* Radeon RV730 */ - { - *vidmem = 512; - return CARD_ATI_RADEON_HD4600; - } - - /* Radeon R710 HD4500/HD4350 - lowend */ - if (strstr(gl_renderer, "HD 4350") /* Radeon RV710 */ - || strstr(gl_renderer, "HD 4550")) /* Radeon RV710 */ - { - *vidmem = 256; - return CARD_ATI_RADEON_HD4350; - } - - /* Radeon R6xx HD2900/HD3800 - highend */ - if (strstr(gl_renderer, "HD 2900") - || strstr(gl_renderer, "HD 3870") - || strstr(gl_renderer, "HD 3850")) - { - *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */ - return CARD_ATI_RADEON_HD2900; - } - - /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */ - if (strstr(gl_renderer, "HD 2600") - || strstr(gl_renderer, "HD 3830") - || strstr(gl_renderer, "HD 3690") - || strstr(gl_renderer, "HD 3650")) - { - *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */ - return CARD_ATI_RADEON_HD2600; - } - - /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */ - if (strstr(gl_renderer, "HD 2300") - || strstr(gl_renderer, "HD 2400") - || strstr(gl_renderer, "HD 3470") - || strstr(gl_renderer, "HD 3450") - || strstr(gl_renderer, "HD 3430") - || strstr(gl_renderer, "HD 3400")) - { - *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */ - return CARD_ATI_RADEON_HD2300; - } - - /* Radeon R6xx/R7xx integrated */ - if (strstr(gl_renderer, "HD 3100") - || strstr(gl_renderer, "HD 3200") - || strstr(gl_renderer, "HD 3300")) - { - *vidmem = 128; /* 128MB */ - return CARD_ATI_RADEON_HD3200; - } - - /* Radeon R5xx */ - if (strstr(gl_renderer, "X1600") - || strstr(gl_renderer, "X1650") - || strstr(gl_renderer, "X1800") - || strstr(gl_renderer, "X1900") - || strstr(gl_renderer, "X1950")) - { - *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */ - return CARD_ATI_RADEON_X1600; - } - - /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */ - if (strstr(gl_renderer, "X700") - || strstr(gl_renderer, "X800") - || strstr(gl_renderer, "X850") - || strstr(gl_renderer, "X1300") - || strstr(gl_renderer, "X1400") - || strstr(gl_renderer, "X1450") - || strstr(gl_renderer, "X1550")) - { - *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */ - return CARD_ATI_RADEON_X700; - } - - /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */ - if (strstr(gl_renderer, "Radeon Xpress")) - { - *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */ - return CARD_ATI_RADEON_XPRESS_200M; - } - - /* Radeon R3xx */ - *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */ - return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */ - } - - if (WINE_D3D8_CAPABLE(gl_info)) - { - *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */ - return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */ - } - - if (WINE_D3D7_CAPABLE(gl_info)) - { - *vidmem = 32; /* There are models with up to 64MB */ - return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */ - } - - *vidmem = 16; /* There are 16-32MB models */ - return CARD_ATI_RAGE_128PRO; - - case VENDOR_INTEL: - if (strstr(gl_renderer, "X3100")) - { - /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */ - *vidmem = 128; - return CARD_INTEL_X3100; - } - - if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM")) - { - /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */ - *vidmem = 64; - return CARD_INTEL_I945GM; - } - - if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM; - if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G; - if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G; - if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G; - if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G; - return CARD_INTEL_I915G; - - case VENDOR_MESA: - case VENDOR_WINE: - default: - /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice - * for Nvidia was because the hardware and drivers they make are of good quality. This makes - * them a good generic choice. */ - *vendor = VENDOR_NVIDIA; - if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600; - if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3; - if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE; - if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT; - return CARD_NVIDIA_RIVA_128; + if ((vendor_card_select_table[i].gl_vendor != *gl_vendor) + || (vendor_card_select_table[i].card_vendor != *card_vendor)) + continue; + TRACE_(d3d_caps)("Applying card_selector \"%s\".\n", vendor_card_select_table[i].description); + return vendor_card_select_table[i].select_card(gl_info, gl_renderer, vidmem); } + + FIXME_(d3d_caps)("No card selector available for GL vendor %d and card vendor %04x.\n", + *gl_vendor, *card_vendor); + + /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice + * for Nvidia was because the hardware and drivers they make are of good quality. This makes + * them a good generic choice. */ + *card_vendor = HW_VENDOR_NVIDIA; + if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600; + if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3; + if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE; + if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT; + return CARD_NVIDIA_RIVA_128; +} + +static const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter) +{ + const struct wined3d_gl_info *gl_info = &adapter->gl_info; + int vs_selected_mode, ps_selected_mode; + + select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode); + if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) + && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_fragment_pipeline; + else if (ps_selected_mode == SHADER_ATI) return &atifs_fragment_pipeline; + else if (gl_info->supported[NV_REGISTER_COMBINERS] + && gl_info->supported[NV_TEXTURE_SHADER2]) return &nvts_fragment_pipeline; + else if (gl_info->supported[NV_REGISTER_COMBINERS]) return &nvrc_fragment_pipeline; + else return &ffp_fragment_pipeline; +} + +static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter) +{ + int vs_selected_mode, ps_selected_mode; + + select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode); + if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend; + if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend; + return &none_shader_backend; +} + +static const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter) +{ + const struct wined3d_gl_info *gl_info = &adapter->gl_info; + int vs_selected_mode, ps_selected_mode; + + select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode); + if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) + && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit; + else return &ffp_blit; } /* Context activation is done by the caller. */ -static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, struct wined3d_gl_info *gl_info) +static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter) { + struct wined3d_driver_info *driver_info = &adapter->driver_info; + struct wined3d_gl_info *gl_info = &adapter->gl_info; const char *GL_Extensions = NULL; const char *WGL_Extensions = NULL; - const char *gl_string = NULL; - enum wined3d_pci_vendor vendor; + const char *gl_vendor_str, *gl_renderer_str, *gl_version_str; + struct fragment_caps fragment_caps; + enum wined3d_gl_vendor gl_vendor; + enum wined3d_pci_vendor card_vendor; enum wined3d_pci_device device; GLint gl_max; GLfloat gl_floatv[2]; unsigned i; HDC hdc; unsigned int vidmem=0; - char *gl_renderer; DWORD gl_version; size_t len; @@ -1644,48 +2000,34 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str ENTER_GL(); - gl_string = (const char *)glGetString(GL_RENDERER); - TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_string)); - if (!gl_string) + gl_renderer_str = (const char *)glGetString(GL_RENDERER); + TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str)); + if (!gl_renderer_str) { LEAVE_GL(); ERR_(d3d_caps)("Received a NULL GL_RENDERER.\n"); return FALSE; } - len = strlen(gl_string) + 1; - gl_renderer = HeapAlloc(GetProcessHeap(), 0, len); - if (!gl_renderer) - { - LEAVE_GL(); - ERR_(d3d_caps)("Failed to allocate gl_renderer memory.\n"); - return FALSE; - } - memcpy(gl_renderer, gl_string, len); - - gl_string = (const char *)glGetString(GL_VENDOR); - TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_string)); - if (!gl_string) + gl_vendor_str = (const char *)glGetString(GL_VENDOR); + TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str)); + if (!gl_vendor_str) { LEAVE_GL(); ERR_(d3d_caps)("Received a NULL GL_VENDOR.\n"); - HeapFree(GetProcessHeap(), 0, gl_renderer); return FALSE; } - vendor = wined3d_guess_vendor(gl_string, gl_renderer); - TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x)\n", debugstr_a(gl_string), vendor); /* Parse the GL_VERSION field into major and minor information */ - gl_string = (const char *)glGetString(GL_VERSION); - TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_string)); - if (!gl_string) + gl_version_str = (const char *)glGetString(GL_VERSION); + TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_version_str)); + if (!gl_version_str) { LEAVE_GL(); ERR_(d3d_caps)("Received a NULL GL_VERSION.\n"); - HeapFree(GetProcessHeap(), 0, gl_renderer); return FALSE; } - gl_version = wined3d_parse_gl_version(gl_string); + gl_version = wined3d_parse_gl_version(gl_version_str); /* * Initialize openGL extension related variables @@ -1694,7 +2036,6 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str memset(gl_info->supported, 0, sizeof(gl_info->supported)); gl_info->limits.buffers = 1; gl_info->limits.textures = 1; - gl_info->limits.texture_stages = 1; gl_info->limits.fragment_samplers = 1; gl_info->limits.vertex_samplers = 0; gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers; @@ -1734,7 +2075,6 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str { LEAVE_GL(); ERR_(d3d_caps)("Received a NULL GL_EXTENSIONS.\n"); - HeapFree(GetProcessHeap(), 0, gl_renderer); return FALSE; } @@ -1831,6 +2171,12 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE; } } + if (gl_info->supported[ARB_MAP_BUFFER_RANGE]) + { + /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same + * functionality. Prefer the ARB extension */ + gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE; + } if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) { TRACE_(d3d_caps)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n"); @@ -1841,6 +2187,11 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str TRACE_(d3d_caps)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n"); gl_info->supported[ARB_DEPTH_CLAMP] = TRUE; } + if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) + { + TRACE_(d3d_caps)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n"); + gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE; + } if (gl_info->supported[NV_TEXTURE_SHADER2]) { if (gl_info->supported[NV_REGISTER_COMBINERS]) @@ -1851,6 +2202,13 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE; } } + + if (gl_info->supported[NV_REGISTER_COMBINERS]) + { + glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max); + gl_info->limits.general_combiners = gl_max; + TRACE_(d3d_caps)("Max general combiners: %d.\n", gl_max); + } if (gl_info->supported[ARB_DRAW_BUFFERS]) { glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max); @@ -1863,18 +2221,6 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->limits.textures = min(MAX_TEXTURES, gl_max); TRACE_(d3d_caps)("Max textures: %d.\n", gl_info->limits.textures); - if (gl_info->supported[NV_REGISTER_COMBINERS]) - { - GLint tmp; - glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &tmp); - gl_info->limits.texture_stages = min(MAX_TEXTURES, tmp); - } - else - { - gl_info->limits.texture_stages = min(MAX_TEXTURES, gl_max); - } - TRACE_(d3d_caps)("Max texture stages: %d.\n", gl_info->limits.texture_stages); - if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) { GLint tmp; @@ -1998,6 +2344,11 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->limits.glsl_varyings = gl_max; TRACE_(d3d_caps)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4); } + if (gl_info->supported[ARB_SHADING_LANGUAGE_100]) + { + const char *str = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB); + TRACE_(d3d_caps)("GLSL version string: %s.\n", debugstr_a(str)); + } if (gl_info->supported[NV_LIGHT_MAX_EXPONENT]) { glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess); @@ -2024,7 +2375,6 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE; gl_info->supported[NV_TEXTURE_SHADER] = FALSE; gl_info->supported[NV_TEXTURE_SHADER2] = FALSE; - gl_info->supported[NV_TEXTURE_SHADER3] = FALSE; } if (gl_info->supported[NV_HALF_FLOAT]) { @@ -2043,6 +2393,14 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str LEAVE_GL(); + adapter->fragment_pipe = select_fragment_implementation(adapter); + adapter->shader_backend = select_shader_backend(adapter); + adapter->blitter = select_blit_implementation(adapter); + + adapter->fragment_pipe->get_caps(gl_info, &fragment_caps); + gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages; + TRACE_(d3d_caps)("Max texture stages: %u.\n", gl_info->limits.texture_stages); + /* In some cases the number of texture stages can be larger than the number * of samplers. The GF4 for example can use only 2 samplers (no fragment * shaders), but 8 texture stages (register combiners). */ @@ -2113,8 +2471,12 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str gl_info->limits.buffers = 1; } - device = wined3d_guess_card(gl_info, gl_renderer, &vendor, &vidmem); - TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", vendor, device); + gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str); + card_vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str); + TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str), gl_vendor, card_vendor); + + device = wined3d_guess_card(gl_info, gl_renderer_str, &gl_vendor, &card_vendor, &vidmem); + TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor, device); /* If we have an estimate use it, else default to 64MB; */ if(vidmem) @@ -2176,11 +2538,10 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, str } } - fixup_extensions(gl_info, gl_renderer, vendor, device); - init_driver_info(driver_info, vendor, device); + fixup_extensions(gl_info, gl_renderer_str, gl_vendor, card_vendor, device); + init_driver_info(driver_info, card_vendor, device); add_gl_compat_wrappers(gl_info); - HeapFree(GetProcessHeap(), 0, gl_renderer); return TRUE; } @@ -2644,7 +3005,10 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U continue; if(cfgs[i].blueSize != blueSize) continue; - if(cfgs[i].alphaSize != alphaSize) + /* Not all drivers report alpha-less formats since they use 32-bit anyway, so accept alpha even if we didn't ask for it. */ + if(alphaSize && cfgs[i].alphaSize != alphaSize) + continue; + if(cfgs[i].colorSize != (glDesc->byte_count << 3)) continue; TRACE("Found iPixelFormat=%d to support MultiSampleType=%d for format %s\n", cfgs[i].iPixelFormat, MultiSampleType, debug_d3dformat(SurfaceFormat)); @@ -2748,8 +3112,6 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter static BOOL CheckBumpMapCapability(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc) { - const struct fragment_pipeline *fp; - switch(format_desc->format) { case WINED3DFMT_R8G8_SNORM: @@ -2760,8 +3122,7 @@ static BOOL CheckBumpMapCapability(struct wined3d_adapter *adapter, /* Ask the fixed function pipeline implementation if it can deal * with the conversion. If we've got a GL extension giving native * support this will be an identity conversion. */ - fp = select_fragment_implementation(adapter, DeviceType); - if (fp->color_fixup_supported(format_desc->color_fixup)) + if (adapter->fragment_pipe->color_fixup_supported(format_desc->color_fixup)) { TRACE_(d3d_caps)("[OK]\n"); return TRUE; @@ -2951,8 +3312,6 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc) { const struct wined3d_gl_info *gl_info = &adapter->gl_info; - const shader_backend_t *shader_backend; - const struct fragment_pipeline *fp; switch (format_desc->format) { @@ -3030,8 +3389,7 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, /* Ask the shader backend if it can deal with the conversion. If * we've got a GL extension giving native support this will be an * identity conversion. */ - shader_backend = select_shader_backend(adapter, DeviceType); - if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup)) + if (adapter->shader_backend->shader_color_fixup_supported(format_desc->color_fixup)) { TRACE_(d3d_caps)("[OK]\n"); return TRUE; @@ -3147,10 +3505,8 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC] || gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC]) { - shader_backend = select_shader_backend(adapter, DeviceType); - fp = select_fragment_implementation(adapter, DeviceType); - if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup) - && fp->color_fixup_supported(format_desc->color_fixup)) + if (adapter->shader_backend->shader_color_fixup_supported(format_desc->color_fixup) + && adapter->fragment_pipe->color_fixup_supported(format_desc->color_fixup)) { TRACE_(d3d_caps)("[OK]\n"); return TRUE; @@ -3186,8 +3542,6 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter, const struct GlPixelFormatDesc *adapter_format_desc, WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *check_format_desc, WINED3DSURFTYPE SurfaceType) { - const struct blit_shader *blitter; - if(SurfaceType == SURFACE_GDI) { switch(check_format_desc->format) { @@ -3223,8 +3577,7 @@ static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter, const struct if (CheckDepthStencilCapability(adapter, adapter_format_desc, check_format_desc)) return TRUE; /* If opengl can't process the format natively, the blitter may be able to convert it */ - blitter = select_blit_implementation(adapter, DeviceType); - if (blitter->color_fixup_supported(check_format_desc->color_fixup)) + if (adapter->blitter->color_fixup_supported(check_format_desc->color_fixup)) { TRACE_(d3d_caps)("[OK]\n"); return TRUE; @@ -3789,8 +4142,6 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, int ps_selected_mode; struct shader_caps shader_caps; struct fragment_caps fragment_caps; - const shader_backend_t *shader_backend; - const struct fragment_pipeline *frag_pipeline = NULL; DWORD ckey_caps, blit_caps, fx_caps; TRACE_(d3d_caps)("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This, Adapter, DeviceType, pCaps); @@ -4167,12 +4518,10 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, pCaps->VertexTextureFilterCaps = 0; memset(&shader_caps, 0, sizeof(shader_caps)); - shader_backend = select_shader_backend(adapter, DeviceType); - shader_backend->shader_get_caps(DeviceType, &adapter->gl_info, &shader_caps); + adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps); memset(&fragment_caps, 0, sizeof(fragment_caps)); - frag_pipeline = select_fragment_implementation(adapter, DeviceType); - frag_pipeline->get_caps(DeviceType, &adapter->gl_info, &fragment_caps); + adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps); /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */ pCaps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps; @@ -4697,7 +5046,7 @@ BOOL InitAdapters(IWineD3DImpl *This) goto nogl_adapter; } - ret = IWineD3DImpl_FillGLCaps(&adapter->driver_info, &adapter->gl_info); + ret = IWineD3DImpl_FillGLCaps(adapter); if(!ret) { ERR("Failed to initialize gl caps for default adapter\n"); WineD3D_ReleaseFakeGLContext(&fake_gl_ctx); @@ -4729,8 +5078,8 @@ BOOL InitAdapters(IWineD3DImpl *This) if (gl_info->supported[WGL_ARB_PIXEL_FORMAT]) { int attribute; - int attribs[10]; - int values[10]; + int attribs[11]; + int values[11]; int nAttribs = 0; attribute = WGL_NUMBER_PIXEL_FORMATS_ARB; @@ -4742,6 +5091,7 @@ BOOL InitAdapters(IWineD3DImpl *This) attribs[nAttribs++] = WGL_GREEN_BITS_ARB; attribs[nAttribs++] = WGL_BLUE_BITS_ARB; attribs[nAttribs++] = WGL_ALPHA_BITS_ARB; + attribs[nAttribs++] = WGL_COLOR_BITS_ARB; attribs[nAttribs++] = WGL_DEPTH_BITS_ARB; attribs[nAttribs++] = WGL_STENCIL_BITS_ARB; attribs[nAttribs++] = WGL_DRAW_TO_WINDOW_ARB; @@ -4762,12 +5112,13 @@ BOOL InitAdapters(IWineD3DImpl *This) cfgs->greenSize = values[1]; cfgs->blueSize = values[2]; cfgs->alphaSize = values[3]; - cfgs->depthSize = values[4]; - cfgs->stencilSize = values[5]; - cfgs->windowDrawable = values[6]; - cfgs->iPixelType = values[7]; - cfgs->doubleBuffer = values[8]; - cfgs->auxBuffers = values[9]; + cfgs->colorSize = values[4]; + cfgs->depthSize = values[5]; + cfgs->stencilSize = values[6]; + cfgs->windowDrawable = values[7]; + cfgs->iPixelType = values[8]; + cfgs->doubleBuffer = values[9]; + cfgs->auxBuffers = values[10]; cfgs->pbufferDrawable = FALSE; /* Check for pbuffer support when it is around as @@ -4794,7 +5145,7 @@ BOOL InitAdapters(IWineD3DImpl *This) } } - TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable, cfgs->pbufferDrawable); + TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, samples=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->numSamples, cfgs->windowDrawable, cfgs->pbufferDrawable); cfgs++; } } @@ -4828,6 +5179,7 @@ BOOL InitAdapters(IWineD3DImpl *This) cfgs->greenSize = ppfd.cGreenBits; cfgs->blueSize = ppfd.cBlueBits; cfgs->alphaSize = ppfd.cAlphaBits; + cfgs->colorSize = ppfd.cColorBits; cfgs->depthSize = ppfd.cDepthBits; cfgs->stencilSize = ppfd.cStencilBits; cfgs->pbufferDrawable = 0; diff --git a/dll/directx/wine/wined3d/drawprim.c b/dll/directx/wine/wined3d/drawprim.c index dbeb7993f9f..b29d012b9d1 100644 --- a/dll/directx/wine/wined3d/drawprim.c +++ b/dll/directx/wine/wined3d/drawprim.c @@ -334,7 +334,7 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, WINED3DFORMAT format GL_EXTCALL(glVertexAttrib4ubvARB(index, ptr)); break; case WINED3DFMT_B8G8R8A8_UNORM: - if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) + if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) { const DWORD *src = ptr; DWORD c = *src & 0xff00ff00; @@ -690,6 +690,9 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT /* Finished updating the screen, restore lock */ LEAVE_GL(); + + wglFlush(); /* Flush to ensure ordering across contexts. */ + context_release(context); TRACE("Done all gl drawing\n"); @@ -1100,7 +1103,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, if(patch->has_texcoords) { vtxStride += 4 * sizeof(float); } - memset(&patch->strided, 0, sizeof(&patch->strided)); + memset(&patch->strided, 0, sizeof(patch->strided)); patch->strided.position.format = WINED3DFMT_R32G32B32_FLOAT; patch->strided.position.lpData = (BYTE *) patch->mem; patch->strided.position.dwStride = vtxStride; diff --git a/dll/directx/wine/wined3d/glsl_shader.c b/dll/directx/wine/wined3d/glsl_shader.c index 90b5092d38f..cb23ee6aa0e 100644 --- a/dll/directx/wine/wined3d/glsl_shader.c +++ b/dll/directx/wine/wined3d/glsl_shader.c @@ -156,6 +156,20 @@ struct glsl_vshader_private UINT num_gl_shaders, shader_array_size; }; +static const char *debug_gl_shader_type(GLenum type) +{ + switch (type) + { +#define WINED3D_TO_STR(u) case u: return #u + WINED3D_TO_STR(GL_VERTEX_SHADER_ARB); + WINED3D_TO_STR(GL_GEOMETRY_SHADER_ARB); + WINED3D_TO_STR(GL_FRAGMENT_SHADER_ARB); +#undef WINED3D_TO_STR + default: + return wine_dbg_sprintf("UNKNOWN(%#x)", type); + } +} + /* Extract a line from the info log. * Note that this modifies the source string. */ static char *get_info_log_line(char **ptr) @@ -238,6 +252,81 @@ static void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLhandleA } } +/* GL locking is done by the caller. */ +static void shader_glsl_dump_program_source(const struct wined3d_gl_info *gl_info, GLhandleARB program) +{ + GLint i, object_count, source_size; + GLhandleARB *objects; + char *source = NULL; + + GL_EXTCALL(glGetObjectParameterivARB(program, GL_OBJECT_ATTACHED_OBJECTS_ARB, &object_count)); + objects = HeapAlloc(GetProcessHeap(), 0, object_count * sizeof(*objects)); + if (!objects) + { + ERR("Failed to allocate object array memory.\n"); + return; + } + + GL_EXTCALL(glGetAttachedObjectsARB(program, object_count, NULL, objects)); + for (i = 0; i < object_count; ++i) + { + char *ptr, *line; + GLint tmp; + + GL_EXTCALL(glGetObjectParameterivARB(objects[i], GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &tmp)); + + if (!source || source_size < tmp) + { + HeapFree(GetProcessHeap(), 0, source); + + source = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, tmp); + if (!source) + { + ERR("Failed to allocate %d bytes for shader source.\n", tmp); + HeapFree(GetProcessHeap(), 0, objects); + return; + } + source_size = tmp; + } + + FIXME("Object %u:\n", objects[i]); + GL_EXTCALL(glGetObjectParameterivARB(objects[i], GL_OBJECT_SUBTYPE_ARB, &tmp)); + FIXME(" GL_OBJECT_SUBTYPE_ARB: %s.\n", debug_gl_shader_type(tmp)); + GL_EXTCALL(glGetObjectParameterivARB(objects[i], GL_OBJECT_COMPILE_STATUS_ARB, &tmp)); + FIXME(" GL_OBJECT_COMPILE_STATUS_ARB: %d.\n", tmp); + FIXME("\n"); + + ptr = source; + GL_EXTCALL(glGetShaderSourceARB(objects[i], source_size, NULL, source)); + while ((line = get_info_log_line(&ptr))) FIXME(" %s\n", line); + FIXME("\n"); + } + + HeapFree(GetProcessHeap(), 0, source); + HeapFree(GetProcessHeap(), 0, objects); +} + +/* GL locking is done by the caller. */ +static void shader_glsl_validate_link(const struct wined3d_gl_info *gl_info, GLhandleARB program) +{ + GLint tmp; + + if (!TRACE_ON(d3d_shader) && !FIXME_ON(d3d_shader)) return; + + GL_EXTCALL(glGetObjectParameterivARB(program, GL_OBJECT_TYPE_ARB, &tmp)); + if (tmp == GL_PROGRAM_OBJECT_ARB) + { + GL_EXTCALL(glGetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB, &tmp)); + if (!tmp) + { + FIXME("Program %u link status invalid.\n", program); + shader_glsl_dump_program_source(gl_info, program); + } + } + + print_glsl_info_log(gl_info, program); +} + /** * Loads (pixel shader) samplers */ @@ -1083,6 +1172,8 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont } } + shader_addline(buffer, "const float FLT_MAX = 1e38;\n"); + /* Start the main program */ shader_addline(buffer, "void main() {\n"); if(pshader && reg_maps->vpos) { @@ -1194,8 +1285,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * static const char * const hwrastout_reg_names[] = { "gl_Position", "gl_FogFragCoord", "gl_PointSize" }; IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; - const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; char pshader = shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type); *is_color = FALSE; @@ -1552,7 +1642,8 @@ static inline const char *shader_get_comp_op(DWORD op) } } -static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, glsl_sample_function_t *sample_function) +static void shader_glsl_get_sample_function(const struct wined3d_gl_info *gl_info, + DWORD sampler_type, DWORD flags, glsl_sample_function_t *sample_function) { BOOL projected = flags & WINED3D_GLSL_SAMPLE_PROJECTED; BOOL texrect = flags & WINED3D_GLSL_SAMPLE_RECT; @@ -1564,9 +1655,21 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, gls case WINED3DSTT_1D: if(lod) { sample_function->name = projected ? "texture1DProjLod" : "texture1DLod"; - } else if(grad) { - sample_function->name = projected ? "texture1DProjGradARB" : "texture1DGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = projected ? "texture1DProjGrad" : "texture1DGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = projected ? "texture1DProjGradARB" : "texture1DGradARB"; + else + { + FIXME("Unsupported 1D grad function.\n"); + sample_function->name = "unsupported1DGrad"; + } + } + else + { sample_function->name = projected ? "texture1DProj" : "texture1D"; } sample_function->coord_mask = WINED3DSP_WRITEMASK_0; @@ -1575,20 +1678,41 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, gls if(texrect) { if(lod) { sample_function->name = projected ? "texture2DRectProjLod" : "texture2DRectLod"; - } else if(grad) { - /* What good are texrect grad functions? I don't know, but GL_EXT_gpu_shader4 defines them. - * There is no GL_ARB_shader_texture_lod spec yet, so I don't know if they're defined there - */ - sample_function->name = projected ? "shadow2DRectProjGradARB" : "shadow2DRectGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = projected ? "texture2DRectProjGrad" : "texture2DRectGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = projected ? "texture2DRectProjGradARB" : "texture2DRectGradARB"; + else + { + FIXME("Unsupported RECT grad function.\n"); + sample_function->name = "unsupported2DRectGrad"; + } + } + else + { sample_function->name = projected ? "texture2DRectProj" : "texture2DRect"; } } else { if(lod) { sample_function->name = projected ? "texture2DProjLod" : "texture2DLod"; - } else if(grad) { - sample_function->name = projected ? "texture2DProjGradARB" : "texture2DGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = projected ? "texture2DProjGrad" : "texture2DGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = projected ? "texture2DProjGradARB" : "texture2DGradARB"; + else + { + FIXME("Unsupported 2D grad function.\n"); + sample_function->name = "unsupported2DGrad"; + } + } + else + { sample_function->name = projected ? "texture2DProj" : "texture2D"; } } @@ -1597,9 +1721,21 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, gls case WINED3DSTT_CUBE: if(lod) { sample_function->name = "textureCubeLod"; - } else if(grad) { - sample_function->name = "textureCubeGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = "textureCubeGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = "textureCubeGradARB"; + else + { + FIXME("Unsupported Cube grad function.\n"); + sample_function->name = "unsupportedCubeGrad"; + } + } + else + { sample_function->name = "textureCube"; } sample_function->coord_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; @@ -1607,9 +1743,21 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, gls case WINED3DSTT_VOLUME: if(lod) { sample_function->name = projected ? "texture3DProjLod" : "texture3DLod"; - } else if(grad) { - sample_function->name = projected ? "texture3DProjGradARB" : "texture3DGradARB"; - } else { + } + else if (grad) + { + if (gl_info->supported[EXT_GPU_SHADER4]) + sample_function->name = projected ? "texture3DProjGrad" : "texture3DGrad"; + else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + sample_function->name = projected ? "texture3DProjGradARB" : "texture3DGradARB"; + else + { + FIXME("Unsupported 3D grad function.\n"); + sample_function->name = "unsupported3DGrad"; + } + } + else + { sample_function->name = projected ? "texture3DProj" : "texture3D"; } sample_function->coord_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; @@ -1681,10 +1829,10 @@ static void shader_glsl_color_correction(const struct wined3d_shader_instruction if (!mask) return; /* Nothing to do */ - if (is_yuv_fixup(fixup)) + if (is_complex_fixup(fixup)) { - enum yuv_fixup yuv_fixup = get_yuv_fixup(fixup); - FIXME("YUV fixup (%#x) not supported\n", yuv_fixup); + enum complex_fixup complex_fixup = get_complex_fixup(fixup); + FIXME("Complex fixup (%#x) not supported\n",complex_fixup); return; } @@ -1822,6 +1970,7 @@ static void shader_glsl_arith(const struct wined3d_shader_instruction *ins) /* Process the WINED3DSIO_MOV opcode using GLSL (dst = src) */ static void shader_glsl_mov(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; glsl_src_param_t src0_param; DWORD write_mask; @@ -1847,12 +1996,26 @@ static void shader_glsl_mov(const struct wined3d_shader_instruction *ins) { /* We need to *round* to the nearest int here. */ unsigned int mask_size = shader_glsl_get_write_mask_size(write_mask); - if (mask_size > 1) { - shader_addline(buffer, "ivec%d(floor(abs(%s) + vec%d(0.5)) * sign(%s)));\n", mask_size, src0_param.param_str, mask_size, src0_param.param_str); - } else { - shader_addline(buffer, "int(floor(abs(%s) + 0.5) * sign(%s)));\n", src0_param.param_str, src0_param.param_str); + + if (gl_info->supported[EXT_GPU_SHADER4]) + { + if (mask_size > 1) + shader_addline(buffer, "ivec%d(round(%s)));\n", mask_size, src0_param.param_str); + else + shader_addline(buffer, "int(round(%s)));\n", src0_param.param_str); } - } else { + else + { + if (mask_size > 1) + shader_addline(buffer, "ivec%d(floor(abs(%s) + vec%d(0.5)) * sign(%s)));\n", + mask_size, src0_param.param_str, mask_size, src0_param.param_str); + else + shader_addline(buffer, "int(floor(abs(%s) + 0.5) * sign(%s)));\n", + src0_param.param_str, src0_param.param_str); + } + } + else + { shader_addline(buffer, "%s);\n", src0_param.param_str); } } @@ -1942,10 +2105,15 @@ static void shader_glsl_log(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src0_param); - if (dst_size > 1) { - shader_addline(buffer, "vec%d(log2(abs(%s))));\n", dst_size, src0_param.param_str); - } else { - shader_addline(buffer, "log2(abs(%s)));\n", src0_param.param_str); + if (dst_size > 1) + { + shader_addline(buffer, "vec%d(%s == 0.0 ? -FLT_MAX : log2(abs(%s))));\n", + dst_size, src0_param.param_str, src0_param.param_str); + } + else + { + shader_addline(buffer, "%s == 0.0 ? -FLT_MAX : log2(abs(%s)));\n", + src0_param.param_str, src0_param.param_str); } } @@ -1966,7 +2134,6 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins) case WINED3DSIH_MAX: instruction = "max"; break; case WINED3DSIH_ABS: instruction = "abs"; break; case WINED3DSIH_FRC: instruction = "fract"; break; - case WINED3DSIH_NRM: instruction = "normalize"; break; case WINED3DSIH_EXP: instruction = "exp2"; break; case WINED3DSIH_DSX: instruction = "dFdx"; break; case WINED3DSIH_DSY: instruction = "ycorrection.y * dFdy"; break; @@ -1993,6 +2160,22 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins) shader_addline(buffer, "));\n"); } +static void shader_glsl_nrm(const struct wined3d_shader_instruction *ins) +{ + struct wined3d_shader_buffer *buffer = ins->ctx->buffer; + glsl_src_param_t src_param; + DWORD write_mask; + char dst_mask[6]; + + write_mask = shader_glsl_get_write_mask(ins->dst, dst_mask); + shader_glsl_add_src_param(ins, &ins->src[0], write_mask, &src_param); + + shader_addline(buffer, "tmp0.x = length(%s);\n", src_param.param_str); + shader_glsl_append_dst(buffer, ins); + shader_addline(buffer, "tmp0.x == 0.0 ? (%s * FLT_MAX) : (%s / tmp0.x));", + src_param.param_str, src_param.param_str); +} + /** Process the WINED3DSIO_EXPP instruction in GLSL: * For shader model 1.x, do the following (and honor the writemask, so use a temporary variable): * dst.x = 2^(floor(src)) @@ -2046,10 +2229,15 @@ static void shader_glsl_rcp(const struct wined3d_shader_instruction *ins) mask_size = shader_glsl_get_write_mask_size(write_mask); shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &src_param); - if (mask_size > 1) { - shader_addline(ins->ctx->buffer, "vec%d(1.0 / %s));\n", mask_size, src_param.param_str); - } else { - shader_addline(ins->ctx->buffer, "1.0 / %s);\n", src_param.param_str); + if (mask_size > 1) + { + shader_addline(ins->ctx->buffer, "vec%d(%s == 0.0 ? FLT_MAX : 1.0 / %s));\n", + mask_size, src_param.param_str, src_param.param_str); + } + else + { + shader_addline(ins->ctx->buffer, "%s == 0.0 ? FLT_MAX : 1.0 / %s);\n", + src_param.param_str, src_param.param_str); } } @@ -2065,10 +2253,15 @@ static void shader_glsl_rsq(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &src_param); - if (mask_size > 1) { - shader_addline(buffer, "vec%d(inversesqrt(%s)));\n", mask_size, src_param.param_str); - } else { - shader_addline(buffer, "inversesqrt(%s));\n", src_param.param_str); + if (mask_size > 1) + { + shader_addline(buffer, "vec%d(%s == 0.0 ? FLT_MAX : inversesqrt(abs(%s))));\n", + mask_size, src_param.param_str, src_param.param_str); + } + else + { + shader_addline(buffer, "%s == 0.0 ? FLT_MAX : inversesqrt(abs(%s)));\n", + src_param.param_str, src_param.param_str); } } @@ -2671,10 +2864,11 @@ static void shader_glsl_ret(const struct wined3d_shader_instruction *ins) ********************************************/ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major, ins->ctx->reg_maps->shader_version.minor); + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_sample_function_t sample_function; DWORD sample_flags = 0; WINED3DSAMPLER_TEXTURE_TYPE sampler_type; @@ -2728,7 +2922,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins) sample_flags |= WINED3D_GLSL_SAMPLE_RECT; } - shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, sample_flags, &sample_function); mask |= sample_function.coord_mask; if (shader_version < WINED3D_SHADER_VERSION(2,0)) swizzle = WINED3DSP_NOSWIZZLE; @@ -2762,7 +2956,7 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins) { IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; - const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_sample_function_t sample_function; glsl_src_param_t coord_param, dx_param, dy_param; DWORD sample_flags = WINED3D_GLSL_SAMPLE_GRAD; @@ -2770,7 +2964,7 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins) DWORD sampler_idx; DWORD swizzle = ins->src[1].swizzle; - if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] && !gl_info->supported[EXT_GPU_SHADER4]) { FIXME("texldd used, but not supported by hardware. Falling back to regular tex\n"); return shader_glsl_tex(ins); @@ -2783,7 +2977,7 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins) sample_flags |= WINED3D_GLSL_SAMPLE_RECT; } - shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, sample_flags, &sample_function); shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &coord_param); shader_glsl_add_src_param(ins, &ins->src[2], sample_function.coord_mask, &dx_param); shader_glsl_add_src_param(ins, &ins->src[3], sample_function.coord_mask, &dy_param); @@ -2796,7 +2990,7 @@ static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins) { IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; - const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_sample_function_t sample_function; glsl_src_param_t coord_param, lod_param; DWORD sample_flags = WINED3D_GLSL_SAMPLE_LOD; @@ -2810,12 +3004,12 @@ static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins) IWineD3DBaseTexture_GetTextureDimensions(deviceImpl->stateBlock->textures[sampler_idx]) == GL_TEXTURE_RECTANGLE_ARB) { sample_flags |= WINED3D_GLSL_SAMPLE_RECT; } - shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, sample_flags, &sample_function); shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &coord_param); shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &lod_param); - if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] + if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] && !gl_info->supported[EXT_GPU_SHADER4] && shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type)) { /* The GLSL spec claims the Lod sampling functions are only supported in vertex shaders. @@ -2877,6 +3071,7 @@ static void shader_glsl_texcoord(const struct wined3d_shader_instruction *ins) * then perform a 1D texture lookup from stage dstregnum, place into dst. */ static void shader_glsl_texdp3tex(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; glsl_sample_function_t sample_function; DWORD sampler_idx = ins->dst[0].reg.idx; @@ -2891,7 +3086,7 @@ static void shader_glsl_texdp3tex(const struct wined3d_shader_instruction *ins) * * It is a dependent read - not valid with conditional NP2 textures */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); mask_size = shader_glsl_get_write_mask_size(sample_function.coord_mask); switch(mask_size) @@ -2990,7 +3185,7 @@ static void shader_glsl_texm3x2pad(const struct wined3d_shader_instruction *ins) * Calculate the 1st or 2nd row of a 3-row matrix multiplication. */ static void shader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; @@ -3004,6 +3199,7 @@ static void shader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins) static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; @@ -3014,7 +3210,7 @@ static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param); shader_addline(buffer, "tmp0.y = dot(T%u.xyz, %s);\n", reg, src0_param.param_str); - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); /* Sample the texture using the calculated coordinates */ shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xy"); @@ -3025,10 +3221,11 @@ static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins) static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins) { DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; DWORD reg = ins->dst[0].reg.idx; - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[reg]; glsl_sample_function_t sample_function; @@ -3036,7 +3233,7 @@ static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins) shader_addline(ins->ctx->buffer, "tmp0.z = dot(T%u.xyz, %s);\n", reg, src0_param.param_str); /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); /* Sample the texture using the calculated coordinates */ shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xyz"); @@ -3049,11 +3246,11 @@ static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins) static void shader_glsl_texm3x3(const struct wined3d_shader_instruction *ins) { DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; glsl_src_param_t src0_param; char dst_mask[6]; DWORD reg = ins->dst[0].reg.idx; - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param); @@ -3068,7 +3265,8 @@ static void shader_glsl_texm3x3(const struct wined3d_shader_instruction *ins) * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */ static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; DWORD reg = ins->dst[0].reg.idx; glsl_src_param_t src0_param; glsl_src_param_t src1_param; @@ -3087,7 +3285,7 @@ static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins shader_addline(buffer, "tmp0.xyz = -reflect((%s), normalize(tmp0.xyz));\n", src1_param.param_str); /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(stype, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, stype, 0, &sample_function); /* Sample the texture */ shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xyz"); @@ -3099,7 +3297,8 @@ static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state; @@ -3119,7 +3318,7 @@ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *in shader_addline(buffer, "tmp0.xyz = -reflect(tmp1.xyz, normalize(tmp0.xyz));\n"); /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); /* Sample the texture using the calculated coordinates */ shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xyz"); @@ -3133,8 +3332,9 @@ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *in */ static void shader_glsl_texbem(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_sample_function_t sample_function; glsl_src_param_t coord_param; WINED3DSAMPLER_TEXTURE_TYPE sampler_type; @@ -3148,7 +3348,7 @@ static void shader_glsl_texbem(const struct wined3d_shader_instruction *ins) sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx]; /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); mask = sample_function.coord_mask; shader_glsl_write_mask_to_str(mask, coord_mask); @@ -3207,6 +3407,7 @@ static void shader_glsl_bem(const struct wined3d_shader_instruction *ins) * Sample 2D texture at dst using the alpha & red (wx) components of src as texture coordinates */ static void shader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; DWORD sampler_idx = ins->dst[0].reg.idx; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx]; @@ -3214,7 +3415,7 @@ static void shader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_ALL, &src0_param); - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "%s.wx", src0_param.reg_name); } @@ -3223,6 +3424,7 @@ static void shader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins) * Sample 2D texture at dst using the green & blue (yz) components of src as texture coordinates */ static void shader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; DWORD sampler_idx = ins->dst[0].reg.idx; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx]; @@ -3230,7 +3432,7 @@ static void shader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_ALL, &src0_param); - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "%s.yz", src0_param.reg_name); } @@ -3239,13 +3441,14 @@ static void shader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins) * Sample texture at dst using the rgb (xyz) components of src as texture coordinates */ static void shader_glsl_texreg2rgb(const struct wined3d_shader_instruction *ins) { + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; DWORD sampler_idx = ins->dst[0].reg.idx; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx]; glsl_sample_function_t sample_function; /* Dependent read, not valid with conditional NP2 */ - shader_glsl_get_sample_function(sampler_type, 0, &sample_function); + shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function); shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &src0_param); shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, @@ -3759,6 +3962,10 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context */ shader_addline(buffer, "#extension GL_ARB_texture_rectangle : enable\n"); } + if (gl_info->supported[EXT_GPU_SHADER4]) + { + shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); + } /* Base Declarations */ shader_generate_glsl_declarations(context, buffer, (IWineD3DBaseShader *)This, reg_maps, &priv_ctx); @@ -3846,6 +4053,11 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context shader_addline(buffer, "#version 120\n"); + if (gl_info->supported[EXT_GPU_SHADER4]) + { + shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); + } + memset(&priv_ctx, 0, sizeof(priv_ctx)); priv_ctx.cur_vs_args = args; @@ -4149,7 +4361,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, /* Link the program */ TRACE("Linking GLSL shader program %u\n", programId); GL_EXTCALL(glLinkProgramARB(programId)); - print_glsl_info_log(gl_info, programId); + shader_glsl_validate_link(gl_info, programId); entry->vuniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * gl_info->limits.glsl_vs_float_constants); @@ -4230,10 +4442,12 @@ static void set_glsl_shader_program(const struct wined3d_context *context, * load them now to have them hardcoded in the GLSL program. This saves some CPU cycles * later */ - if(pshader && !((IWineD3DPixelShaderImpl*)pshader)->baseShader.load_local_constsF) { + if (pshader && !((IWineD3DBaseShaderImpl *)pshader)->baseShader.load_local_constsF) + { hardcode_local_constants((IWineD3DBaseShaderImpl *) pshader, gl_info, programId, 'P'); } - if(vshader && !((IWineD3DVertexShaderImpl*)vshader)->baseShader.load_local_constsF) { + if (vshader && !((IWineD3DBaseShaderImpl *)vshader)->baseShader.load_local_constsF) + { hardcode_local_constants((IWineD3DBaseShaderImpl *) vshader, gl_info, programId, 'V'); } } @@ -4303,7 +4517,7 @@ static GLhandleARB create_glsl_blt_shader(const struct wined3d_gl_info *gl_info, GL_EXTCALL(glAttachObjectARB(program_id, pshader_id)); GL_EXTCALL(glLinkProgramARB(program_id)); - print_glsl_info_log(gl_info, program_id); + shader_glsl_validate_link(gl_info, program_id); /* Once linked we can mark the shaders for deletion. They will be deleted once the program * is destroyed @@ -4394,8 +4608,6 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device; struct shader_glsl_priv *priv = device->shader_priv; const struct wined3d_gl_info *gl_info; - IWineD3DPixelShaderImpl *ps = NULL; - IWineD3DVertexShaderImpl *vs = NULL; struct wined3d_context *context; /* Note: Do not use QueryInterface here to find out which shader type this is because this code @@ -4405,12 +4617,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { if(pshader) { struct glsl_pshader_private *shader_data; - ps = (IWineD3DPixelShaderImpl *) This; - shader_data = ps->baseShader.backend_data; + shader_data = This->baseShader.backend_data; if(!shader_data || shader_data->num_gl_shaders == 0) { HeapFree(GetProcessHeap(), 0, shader_data); - ps->baseShader.backend_data = NULL; + This->baseShader.backend_data = NULL; return; } @@ -4425,12 +4636,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { } } else { struct glsl_vshader_private *shader_data; - vs = (IWineD3DVertexShaderImpl *) This; - shader_data = vs->baseShader.backend_data; + shader_data = This->baseShader.backend_data; if(!shader_data || shader_data->num_gl_shaders == 0) { HeapFree(GetProcessHeap(), 0, shader_data); - vs->baseShader.backend_data = NULL; + This->baseShader.backend_data = NULL; return; } @@ -4466,7 +4676,7 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { if(pshader) { UINT i; - struct glsl_pshader_private *shader_data = ps->baseShader.backend_data; + struct glsl_pshader_private *shader_data = This->baseShader.backend_data; ENTER_GL(); for(i = 0; i < shader_data->num_gl_shaders; i++) { @@ -4476,11 +4686,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { } LEAVE_GL(); HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); - HeapFree(GetProcessHeap(), 0, shader_data); - ps->baseShader.backend_data = NULL; - } else { + } + else + { UINT i; - struct glsl_vshader_private *shader_data = vs->baseShader.backend_data; + struct glsl_vshader_private *shader_data = This->baseShader.backend_data; ENTER_GL(); for(i = 0; i < shader_data->num_gl_shaders; i++) { @@ -4490,10 +4700,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { } LEAVE_GL(); HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); - HeapFree(GetProcessHeap(), 0, shader_data); - vs->baseShader.backend_data = NULL; } + HeapFree(GetProcessHeap(), 0, This->baseShader.backend_data); + This->baseShader.backend_data = NULL; + context_release(context); } @@ -4632,8 +4843,7 @@ static BOOL shader_glsl_dirty_const(IWineD3DDevice *iface) { return FALSE; } -static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, - const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps) +static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps) { /* Nvidia Geforce6/7 or Ati R4xx/R5xx cards with GLSL support, support VS 3.0 but older Nvidia/Ati * models with GLSL support only support 2.0. In case of nvidia we can detect VS 2.0 support based @@ -4697,7 +4907,7 @@ static BOOL shader_glsl_color_fixup_supported(struct color_fixup_desc fixup) } /* We support everything except YUV conversions. */ - if (!is_yuv_fixup(fixup)) + if (!is_complex_fixup(fixup)) { TRACE("[OK]\n"); return TRUE; @@ -4720,6 +4930,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_CMP */ shader_glsl_cmp, /* WINED3DSIH_CND */ shader_glsl_cnd, /* WINED3DSIH_CRS */ shader_glsl_cross, + /* WINED3DSIH_CUT */ NULL, /* WINED3DSIH_DCL */ NULL, /* WINED3DSIH_DEF */ NULL, /* WINED3DSIH_DEFB */ NULL, @@ -4731,20 +4942,24 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_DSX */ shader_glsl_map2gl, /* WINED3DSIH_DSY */ shader_glsl_map2gl, /* WINED3DSIH_ELSE */ shader_glsl_else, + /* WINED3DSIH_EMIT */ NULL, /* WINED3DSIH_ENDIF */ shader_glsl_end, /* WINED3DSIH_ENDLOOP */ shader_glsl_end, /* WINED3DSIH_ENDREP */ shader_glsl_end, /* WINED3DSIH_EXP */ shader_glsl_map2gl, /* WINED3DSIH_EXPP */ shader_glsl_expp, /* WINED3DSIH_FRC */ shader_glsl_map2gl, + /* WINED3DSIH_IADD */ NULL, /* WINED3DSIH_IF */ shader_glsl_if, /* WINED3DSIH_IFC */ shader_glsl_ifc, + /* WINED3DSIH_IGE */ NULL, /* WINED3DSIH_LABEL */ shader_glsl_label, /* WINED3DSIH_LIT */ shader_glsl_lit, /* WINED3DSIH_LOG */ shader_glsl_log, /* WINED3DSIH_LOGP */ shader_glsl_log, /* WINED3DSIH_LOOP */ shader_glsl_loop, /* WINED3DSIH_LRP */ shader_glsl_lrp, + /* WINED3DSIH_LT */ NULL, /* WINED3DSIH_M3x2 */ shader_glsl_mnxn, /* WINED3DSIH_M3x3 */ shader_glsl_mnxn, /* WINED3DSIH_M3x4 */ shader_glsl_mnxn, @@ -4757,7 +4972,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_MOVA */ shader_glsl_mov, /* WINED3DSIH_MUL */ shader_glsl_arith, /* WINED3DSIH_NOP */ NULL, - /* WINED3DSIH_NRM */ shader_glsl_map2gl, + /* WINED3DSIH_NRM */ shader_glsl_nrm, /* WINED3DSIH_PHASE */ NULL, /* WINED3DSIH_POW */ shader_glsl_pow, /* WINED3DSIH_RCP */ shader_glsl_rcp, diff --git a/dll/directx/wine/wined3d/nvidia_texture_shader.c b/dll/directx/wine/wined3d/nvidia_texture_shader.c index 82a71dab3b9..64bb883d6c8 100644 --- a/dll/directx/wine/wined3d/nvidia_texture_shader.c +++ b/dll/directx/wine/wined3d/nvidia_texture_shader.c @@ -627,8 +627,7 @@ static void nvts_enable(IWineD3DDevice *iface, BOOL enable) { LEAVE_GL(); } -static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, - const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps) +static void nvrc_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps) { pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD | WINED3DTEXOPCAPS_ADDSIGNED | @@ -671,7 +670,7 @@ static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, WINED3DTEXOPCAPS_PREMODULATE */ #endif - pCaps->MaxTextureBlendStages = gl_info->limits.texture_stages; + pCaps->MaxTextureBlendStages = min(MAX_TEXTURES, gl_info->limits.general_combiners); pCaps->MaxSimultaneousTextures = gl_info->limits.textures; pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_TSSARGTEMP; diff --git a/dll/directx/wine/wined3d/query.c b/dll/directx/wine/wined3d/query.c index 1280a3b629d..3860e2c95b5 100644 --- a/dll/directx/wine/wined3d/query.c +++ b/dll/directx/wine/wined3d/query.c @@ -24,15 +24,164 @@ #include "config.h" #include "wined3d_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d); +#define GLINFO_LOCATION (*gl_info) + +static HRESULT wined3d_event_query_init(const struct wined3d_gl_info *gl_info, struct wined3d_event_query **query) +{ + struct wined3d_event_query *ret; + *query = NULL; + if (!gl_info->supported[ARB_SYNC] && !gl_info->supported[NV_FENCE] + && !gl_info->supported[APPLE_FENCE]) return E_NOTIMPL; + + ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret)); + if (!ret) + { + ERR("Failed to allocate a wined3d event query structure.\n"); + return E_OUTOFMEMORY; + } + ret->context = NULL; + *query = ret; + return WINED3D_OK; +} + +static void wined3d_event_query_destroy(struct wined3d_event_query *query) +{ + if (query->context) context_free_event_query(query); + HeapFree(GetProcessHeap(), 0, query); +} + +static enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) +{ + struct wined3d_context *context; + const struct wined3d_gl_info *gl_info; + enum wined3d_event_query_result ret; + BOOL fence_result; + + TRACE("(%p) : device %p\n", query, device); + + if (query->context == NULL) + { + TRACE("Query not started\n"); + return WINED3D_EVENT_QUERY_NOT_STARTED; + } + + if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId()) + { + WARN("Event query tested from wrong thread\n"); + return WINED3D_EVENT_QUERY_WRONG_THREAD; + } + + context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); + gl_info = context->gl_info; + + ENTER_GL(); + + if (gl_info->supported[ARB_SYNC]) + { + GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, 0)); + checkGLcall("glClientWaitSync"); + + switch (gl_ret) + { + case GL_ALREADY_SIGNALED: + case GL_CONDITION_SATISFIED: + ret = WINED3D_EVENT_QUERY_OK; + break; + + case GL_TIMEOUT_EXPIRED: + ret = WINED3D_EVENT_QUERY_WAITING; + break; + + case GL_WAIT_FAILED: + default: + ERR("glClientWaitSync returned %#x.\n", gl_ret); + ret = WINED3D_EVENT_QUERY_ERROR; + } + } + else if (gl_info->supported[APPLE_FENCE]) + { + fence_result = GL_EXTCALL(glTestFenceAPPLE(query->object.id)); + checkGLcall("glTestFenceAPPLE"); + if (fence_result) ret = WINED3D_EVENT_QUERY_OK; + else ret = WINED3D_EVENT_QUERY_WAITING; + } + else if (gl_info->supported[NV_FENCE]) + { + fence_result = GL_EXTCALL(glTestFenceNV(query->object.id)); + checkGLcall("glTestFenceNV"); + if (fence_result) ret = WINED3D_EVENT_QUERY_OK; + else ret = WINED3D_EVENT_QUERY_WAITING; + } + else + { + ERR("Event query created despite lack of GL support\n"); + ret = WINED3D_EVENT_QUERY_ERROR; + } + + LEAVE_GL(); + + context_release(context); + return ret; +} + +static void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) +{ + const struct wined3d_gl_info *gl_info; + struct wined3d_context *context; + + if (query->context) + { + if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId()) + { + context_free_event_query(query); + context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + context_alloc_event_query(context, query); + } + else + { + context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); + } + } + else + { + context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + context_alloc_event_query(context, query); + } + + gl_info = context->gl_info; + + ENTER_GL(); + + if (gl_info->supported[ARB_SYNC]) + { + if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync)); + checkGLcall("glDeleteSync"); + query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)); + checkGLcall("glFenceSync"); + } + else if (gl_info->supported[APPLE_FENCE]) + { + GL_EXTCALL(glSetFenceAPPLE(query->object.id)); + checkGLcall("glSetFenceAPPLE"); + } + else if (gl_info->supported[NV_FENCE]) + { + GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV)); + checkGLcall("glSetFenceNV"); + } + + LEAVE_GL(); + + context_release(context); +} + /* * Occlusion Queries: * http://www.gris.uni-tuebingen.de/~bartz/Publications/paper/hww98.pdf * http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt */ -WINE_DEFAULT_DEBUG_CHANNEL(d3d); -#define GLINFO_LOCATION This->device->adapter->gl_info - /* ******************************************* IWineD3DQuery IUnknown parts follow ******************************************* */ @@ -70,17 +219,16 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) { if (This->type == WINED3DQUERYTYPE_EVENT) { struct wined3d_event_query *query = This->extendedData; - - if (query->context) context_free_event_query(query); + if (query) wined3d_event_query_destroy(query); } else if (This->type == WINED3DQUERYTYPE_OCCLUSION) { struct wined3d_occlusion_query *query = This->extendedData; if (query->context) context_free_occlusion_query(query); + HeapFree(GetProcessHeap(), 0, This->extendedData); } - HeapFree(GetProcessHeap(), 0, This->extendedData); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -101,168 +249,6 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetParent(IWineD3DQuery *iface, IUnknown return WINED3D_OK; } -static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags){ - IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface; - HRESULT res = S_OK; - - TRACE("(%p) : type %#x, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, This->type, pData, dwSize, dwGetDataFlags); - - switch (This->type){ - - case WINED3DQUERYTYPE_VCACHE: - { - - WINED3DDEVINFO_VCACHE *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VCACHE\n", This); - if(pData == NULL || dwSize == 0) break; - data->Pattern = WINEMAKEFOURCC('C','A','C','H'); - data->OptMethod = 0; /*0 get longest strips, 1 optimize vertex cache*/ - data->CacheSize = 0; /*cache size, only required if OptMethod == 1*/ - data->MagicNumber = 0; /*only required if OptMethod == 1 (used internally)*/ - - } - break; - case WINED3DQUERYTYPE_RESOURCEMANAGER: - { - WINED3DDEVINFO_RESOURCEMANAGER *data = pData; - int i; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_RESOURCEMANAGER\n", This); - if(pData == NULL || dwSize == 0) break; - for(i = 0; i < WINED3DRTYPECOUNT; i++){ - /*I'm setting the default values to 1 so as to reduce the risk of a div/0 in the caller*/ - /* isTextureResident could be used to get some of this information */ - data->stats[i].bThrashing = FALSE; - data->stats[i].ApproxBytesDownloaded = 1; - data->stats[i].NumEvicts = 1; - data->stats[i].NumVidCreates = 1; - data->stats[i].LastPri = 1; - data->stats[i].NumUsed = 1; - data->stats[i].NumUsedInVidMem = 1; - data->stats[i].WorkingSet = 1; - data->stats[i].WorkingSetBytes = 1; - data->stats[i].TotalManaged = 1; - data->stats[i].TotalBytes = 1; - } - - } - break; - case WINED3DQUERYTYPE_VERTEXSTATS: - { - WINED3DDEVINFO_VERTEXSTATS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VERTEXSTATS\n", This); - if(pData == NULL || dwSize == 0) break; - data->NumRenderedTriangles = 1; - data->NumExtraClippingTriangles = 1; - - } - break; - case WINED3DQUERYTYPE_TIMESTAMP: - { - UINT64* data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMP\n", This); - if(pData == NULL || dwSize == 0) break; - *data = 1; /*Don't know what this is supposed to be*/ - } - break; - case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: - { - BOOL* data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMPDISJOINT\n", This); - if(pData == NULL || dwSize == 0) break; - *data = FALSE; /*Don't know what this is supposed to be*/ - } - break; - case WINED3DQUERYTYPE_TIMESTAMPFREQ: - { - UINT64* data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMPFREQ\n", This); - if(pData == NULL || dwSize == 0) break; - *data = 1; /*Don't know what this is supposed to be*/ - } - break; - case WINED3DQUERYTYPE_PIPELINETIMINGS: - { - WINED3DDEVINFO_PIPELINETIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_PIPELINETIMINGS\n", This); - if(pData == NULL || dwSize == 0) break; - - data->VertexProcessingTimePercent = 1.0f; - data->PixelProcessingTimePercent = 1.0f; - data->OtherGPUProcessingTimePercent = 97.0f; - data->GPUIdleTimePercent = 1.0f; - } - break; - case WINED3DQUERYTYPE_INTERFACETIMINGS: - { - WINED3DDEVINFO_INTERFACETIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_INTERFACETIMINGS\n", This); - - if(pData == NULL || dwSize == 0) break; - data->WaitingForGPUToUseApplicationResourceTimePercent = 1.0f; - data->WaitingForGPUToAcceptMoreCommandsTimePercent = 1.0f; - data->WaitingForGPUToStayWithinLatencyTimePercent = 1.0f; - data->WaitingForGPUExclusiveResourceTimePercent = 1.0f; - data->WaitingForGPUOtherTimePercent = 96.0f; - } - - break; - case WINED3DQUERYTYPE_VERTEXTIMINGS: - { - WINED3DDEVINFO_STAGETIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VERTEXTIMINGS\n", This); - - if(pData == NULL || dwSize == 0) break; - data->MemoryProcessingPercent = 50.0f; - data->ComputationProcessingPercent = 50.0f; - - } - break; - case WINED3DQUERYTYPE_PIXELTIMINGS: - { - WINED3DDEVINFO_STAGETIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_PIXELTIMINGS\n", This); - - if(pData == NULL || dwSize == 0) break; - data->MemoryProcessingPercent = 50.0f; - data->ComputationProcessingPercent = 50.0f; - } - break; - case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: - { - WINED3DDEVINFO_BANDWIDTHTIMINGS *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_BANDWIDTHTIMINGS\n", This); - - if(pData == NULL || dwSize == 0) break; - data->MaxBandwidthUtilized = 1.0f; - data->FrontEndUploadMemoryUtilizedPercent = 1.0f; - data->VertexRateUtilizedPercent = 1.0f; - data->TriangleSetupRateUtilizedPercent = 1.0f; - data->FillRateUtilizedPercent = 97.0f; - } - break; - case WINED3DQUERYTYPE_CACHEUTILIZATION: - { - WINED3DDEVINFO_CACHEUTILIZATION *data = pData; - FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_CACHEUTILIZATION\n", This); - - if(pData == NULL || dwSize == 0) break; - data->TextureCacheHitRate = 1.0f; - data->PostTransformVertexCacheHitRate = 1.0f; - } - - - break; - default: - FIXME("(%p) Unhandled query type %d\n",This , This->type); - - }; - - /*dwGetDataFlags = 0 || D3DGETDATA_FLUSH - D3DGETDATA_FLUSH may return WINED3DERR_DEVICELOST if the device is lost - */ - return res; /* S_OK if the query data is available*/ -} - static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) { IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface; struct wined3d_occlusion_query *query = This->extendedData; @@ -341,108 +327,44 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) { IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface; struct wined3d_event_query *query = This->extendedData; - struct wined3d_context *context; BOOL *data = pData; + enum wined3d_event_query_result ret; TRACE("(%p) : type D3DQUERY_EVENT, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags); if (!pData || !dwSize) return S_OK; - - if (!query->context) + if (!query) { - TRACE("Query not started, returning TRUE.\n"); + WARN("(%p): Event query not supported by GL, reporting GPU idle\n", This); *data = TRUE; - return S_OK; } - if (query->context->tid != GetCurrentThreadId()) + ret = wined3d_event_query_test(query, This->device); + switch(ret) { - /* See comment in IWineD3DQuery::Issue, event query codeblock */ - FIXME("Wrong thread, reporting GPU idle.\n"); - *data = TRUE; + case WINED3D_EVENT_QUERY_OK: + case WINED3D_EVENT_QUERY_NOT_STARTED: + *data = TRUE; + break; - return S_OK; + case WINED3D_EVENT_QUERY_WAITING: + *data = FALSE; + break; + + case WINED3D_EVENT_QUERY_WRONG_THREAD: + FIXME("(%p) Wrong thread, reporting GPU idle.\n", This); + *data = TRUE; + break; + + case WINED3D_EVENT_QUERY_ERROR: + ERR("The GL event query failed, returning D3DERR_INVALIDCALL\n"); + return WINED3DERR_INVALIDCALL; } - context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); - - ENTER_GL(); - - if (context->gl_info->supported[APPLE_FENCE]) - { - *data = GL_EXTCALL(glTestFenceAPPLE(query->id)); - checkGLcall("glTestFenceAPPLE"); - } - else if (context->gl_info->supported[NV_FENCE]) - { - *data = GL_EXTCALL(glTestFenceNV(query->id)); - checkGLcall("glTestFenceNV"); - } - else - { - WARN("(%p): reporting GPU idle\n", This); - *data = TRUE; - } - - LEAVE_GL(); - - context_release(context); - return S_OK; } -static DWORD WINAPI IWineD3DQueryImpl_GetDataSize(IWineD3DQuery* iface){ - IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface; - int dataSize = 0; - TRACE("(%p) : type %#x\n", This, This->type); - switch(This->type){ - case WINED3DQUERYTYPE_VCACHE: - dataSize = sizeof(WINED3DDEVINFO_VCACHE); - break; - case WINED3DQUERYTYPE_RESOURCEMANAGER: - dataSize = sizeof(WINED3DDEVINFO_RESOURCEMANAGER); - break; - case WINED3DQUERYTYPE_VERTEXSTATS: - dataSize = sizeof(WINED3DDEVINFO_VERTEXSTATS); - break; - case WINED3DQUERYTYPE_EVENT: - dataSize = sizeof(BOOL); - break; - case WINED3DQUERYTYPE_TIMESTAMP: - dataSize = sizeof(UINT64); - break; - case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: - dataSize = sizeof(BOOL); - break; - case WINED3DQUERYTYPE_TIMESTAMPFREQ: - dataSize = sizeof(UINT64); - break; - case WINED3DQUERYTYPE_PIPELINETIMINGS: - dataSize = sizeof(WINED3DDEVINFO_PIPELINETIMINGS); - break; - case WINED3DQUERYTYPE_INTERFACETIMINGS: - dataSize = sizeof(WINED3DDEVINFO_INTERFACETIMINGS); - break; - case WINED3DQUERYTYPE_VERTEXTIMINGS: - dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS); - break; - case WINED3DQUERYTYPE_PIXELTIMINGS: - dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS); - break; - case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: - dataSize = sizeof(WINED3DQUERYTYPE_BANDWIDTHTIMINGS); - break; - case WINED3DQUERYTYPE_CACHEUTILIZATION: - dataSize = sizeof(WINED3DDEVINFO_CACHEUTILIZATION); - break; - default: - FIXME("(%p) Unhandled query type %d\n",This , This->type); - dataSize = 0; - } - return dataSize; -} - static DWORD WINAPI IWineD3DEventQueryImpl_GetDataSize(IWineD3DQuery* iface){ TRACE("(%p) : type D3DQUERY_EVENT\n", iface); @@ -460,7 +382,6 @@ static WINED3DQUERYTYPE WINAPI IWineD3DQueryImpl_GetType(IWineD3DQuery* iface){ return This->type; } - static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) { IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface; @@ -468,43 +389,11 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD if (dwIssueFlags & WINED3DISSUE_END) { struct wined3d_event_query *query = This->extendedData; - struct wined3d_context *context; - if (query->context) - { - if (query->context->tid != GetCurrentThreadId()) - { - context_free_event_query(query); - context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD); - context_alloc_event_query(context, query); - } - else - { - context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); - } - } - else - { - context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD); - context_alloc_event_query(context, query); - } + /* Faked event query support */ + if (!query) return WINED3D_OK; - ENTER_GL(); - - if (context->gl_info->supported[APPLE_FENCE]) - { - GL_EXTCALL(glSetFenceAPPLE(query->id)); - checkGLcall("glSetFenceAPPLE"); - } - else if (context->gl_info->supported[NV_FENCE]) - { - GL_EXTCALL(glSetFenceNV(query->id, GL_ALL_COMPLETED_NV)); - checkGLcall("glSetFenceNV"); - } - - LEAVE_GL(); - - context_release(context); + wined3d_event_query_issue(query, This->device); } else if(dwIssueFlags & WINED3DISSUE_BEGIN) { @@ -604,43 +493,7 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */ } -static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags){ - IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface; - - TRACE("(%p) : dwIssueFlags %#x, type %#x\n", This, dwIssueFlags, This->type); - - /* The fixme is printed when the app asks for the resulting data */ - WARN("(%p) : Unhandled query type %#x\n", This, This->type); - - if(dwIssueFlags & WINED3DISSUE_BEGIN) { - This->state = QUERY_BUILDING; - } else { - This->state = QUERY_SIGNALLED; - } - - return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */ -} - - -/********************************************************** - * IWineD3DQuery VTbl follows - **********************************************************/ - -const IWineD3DQueryVtbl IWineD3DQuery_Vtbl = -{ - /*** IUnknown methods ***/ - IWineD3DQueryImpl_QueryInterface, - IWineD3DQueryImpl_AddRef, - IWineD3DQueryImpl_Release, - /*** IWineD3Dquery methods ***/ - IWineD3DQueryImpl_GetParent, - IWineD3DQueryImpl_GetData, - IWineD3DQueryImpl_GetDataSize, - IWineD3DQueryImpl_GetType, - IWineD3DQueryImpl_Issue -}; - -const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl = +static const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl = { /*** IUnknown methods ***/ IWineD3DQueryImpl_QueryInterface, @@ -654,7 +507,7 @@ const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl = IWineD3DEventQueryImpl_Issue }; -const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl = +static const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl = { /*** IUnknown methods ***/ IWineD3DQueryImpl_QueryInterface, @@ -667,3 +520,72 @@ const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl = IWineD3DQueryImpl_GetType, IWineD3DOcclusionQueryImpl_Issue }; + +HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, + WINED3DQUERYTYPE type, IUnknown *parent) +{ + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; + HRESULT hr; + + switch (type) + { + case WINED3DQUERYTYPE_OCCLUSION: + TRACE("Occlusion query.\n"); + if (!gl_info->supported[ARB_OCCLUSION_QUERY]) + { + WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY.\n"); + return WINED3DERR_NOTAVAILABLE; + } + query->lpVtbl = &IWineD3DOcclusionQuery_Vtbl; + query->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_occlusion_query)); + if (!query->extendedData) + { + ERR("Failed to allocate occlusion query extended data.\n"); + return E_OUTOFMEMORY; + } + ((struct wined3d_occlusion_query *)query->extendedData)->context = NULL; + break; + + case WINED3DQUERYTYPE_EVENT: + TRACE("Event query.\n"); + query->lpVtbl = &IWineD3DEventQuery_Vtbl; + hr = wined3d_event_query_init(gl_info, (struct wined3d_event_query **) &query->extendedData); + if (hr == E_NOTIMPL) + { + /* Half-Life 2 needs this query. It does not render the main + * menu correctly otherwise. Pretend to support it, faking + * this query does not do much harm except potentially + * lowering performance. */ + FIXME("Event query: Unimplemented, but pretending to be supported.\n"); + } + else if(FAILED(hr)) + { + return hr; + } + break; + + case WINED3DQUERYTYPE_VCACHE: + case WINED3DQUERYTYPE_RESOURCEMANAGER: + case WINED3DQUERYTYPE_VERTEXSTATS: + case WINED3DQUERYTYPE_TIMESTAMP: + case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: + case WINED3DQUERYTYPE_TIMESTAMPFREQ: + case WINED3DQUERYTYPE_PIPELINETIMINGS: + case WINED3DQUERYTYPE_INTERFACETIMINGS: + case WINED3DQUERYTYPE_VERTEXTIMINGS: + case WINED3DQUERYTYPE_PIXELTIMINGS: + case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: + case WINED3DQUERYTYPE_CACHEUTILIZATION: + default: + FIXME("Unhandled query type %#x.\n", type); + return WINED3DERR_NOTAVAILABLE; + } + + query->type = type; + query->state = QUERY_CREATED; + query->device = device; + query->parent = parent; + query->ref = 1; + + return WINED3D_OK; +} diff --git a/dll/directx/wine/wined3d/shader.c b/dll/directx/wine/wined3d/shader.c index 398ea641835..307cadf804c 100644 --- a/dll/directx/wine/wined3d/shader.c +++ b/dll/directx/wine/wined3d/shader.c @@ -26,10 +26,1433 @@ #include #include +#include #include "wined3d_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); +WINE_DECLARE_DEBUG_CHANNEL(d3d); + +static const char *shader_opcode_names[] = +{ + /* WINED3DSIH_ABS */ "abs", + /* WINED3DSIH_ADD */ "add", + /* WINED3DSIH_BEM */ "bem", + /* WINED3DSIH_BREAK */ "break", + /* WINED3DSIH_BREAKC */ "breakc", + /* WINED3DSIH_BREAKP */ "breakp", + /* WINED3DSIH_CALL */ "call", + /* WINED3DSIH_CALLNZ */ "callnz", + /* WINED3DSIH_CMP */ "cmp", + /* WINED3DSIH_CND */ "cnd", + /* WINED3DSIH_CRS */ "crs", + /* WINED3DSIH_CUT */ "cut", + /* WINED3DSIH_DCL */ "dcl", + /* WINED3DSIH_DEF */ "def", + /* WINED3DSIH_DEFB */ "defb", + /* WINED3DSIH_DEFI */ "defi", + /* WINED3DSIH_DP2ADD */ "dp2add", + /* WINED3DSIH_DP3 */ "dp3", + /* WINED3DSIH_DP4 */ "dp4", + /* WINED3DSIH_DST */ "dst", + /* WINED3DSIH_DSX */ "dsx", + /* WINED3DSIH_DSY */ "dsy", + /* WINED3DSIH_ELSE */ "else", + /* WINED3DSIH_EMIT */ "emit", + /* WINED3DSIH_ENDIF */ "endif", + /* WINED3DSIH_ENDLOOP */ "endloop", + /* WINED3DSIH_ENDREP */ "endrep", + /* WINED3DSIH_EXP */ "exp", + /* WINED3DSIH_EXPP */ "expp", + /* WINED3DSIH_FRC */ "frc", + /* WINED3DSIH_IADD */ "iadd", + /* WINED3DSIH_IF */ "if", + /* WINED3DSIH_IFC */ "ifc", + /* WINED3DSIH_IGE */ "ige", + /* WINED3DSIH_LABEL */ "label", + /* WINED3DSIH_LIT */ "lit", + /* WINED3DSIH_LOG */ "log", + /* WINED3DSIH_LOGP */ "logp", + /* WINED3DSIH_LOOP */ "loop", + /* WINED3DSIH_LRP */ "lrp", + /* WINED3DSIH_LT */ "lt", + /* WINED3DSIH_M3x2 */ "m3x2", + /* WINED3DSIH_M3x3 */ "m3x3", + /* WINED3DSIH_M3x4 */ "m3x4", + /* WINED3DSIH_M4x3 */ "m4x3", + /* WINED3DSIH_M4x4 */ "m4x4", + /* WINED3DSIH_MAD */ "mad", + /* WINED3DSIH_MAX */ "max", + /* WINED3DSIH_MIN */ "min", + /* WINED3DSIH_MOV */ "mov", + /* WINED3DSIH_MOVA */ "mova", + /* WINED3DSIH_MUL */ "mul", + /* WINED3DSIH_NOP */ "nop", + /* WINED3DSIH_NRM */ "nrm", + /* WINED3DSIH_PHASE */ "phase", + /* WINED3DSIH_POW */ "pow", + /* WINED3DSIH_RCP */ "rcp", + /* WINED3DSIH_REP */ "rep", + /* WINED3DSIH_RET */ "ret", + /* WINED3DSIH_RSQ */ "rsq", + /* WINED3DSIH_SETP */ "setp", + /* WINED3DSIH_SGE */ "sge", + /* WINED3DSIH_SGN */ "sgn", + /* WINED3DSIH_SINCOS */ "sincos", + /* WINED3DSIH_SLT */ "slt", + /* WINED3DSIH_SUB */ "sub", + /* WINED3DSIH_TEX */ "texld", + /* WINED3DSIH_TEXBEM */ "texbem", + /* WINED3DSIH_TEXBEML */ "texbeml", + /* WINED3DSIH_TEXCOORD */ "texcrd", + /* WINED3DSIH_TEXDEPTH */ "texdepth", + /* WINED3DSIH_TEXDP3 */ "texdp3", + /* WINED3DSIH_TEXDP3TEX */ "texdp3tex", + /* WINED3DSIH_TEXKILL */ "texkill", + /* WINED3DSIH_TEXLDD */ "texldd", + /* WINED3DSIH_TEXLDL */ "texldl", + /* WINED3DSIH_TEXM3x2DEPTH */ "texm3x2depth", + /* WINED3DSIH_TEXM3x2PAD */ "texm3x2pad", + /* WINED3DSIH_TEXM3x2TEX */ "texm3x2tex", + /* WINED3DSIH_TEXM3x3 */ "texm3x3", + /* WINED3DSIH_TEXM3x3DIFF */ "texm3x3diff", + /* WINED3DSIH_TEXM3x3PAD */ "texm3x3pad", + /* WINED3DSIH_TEXM3x3SPEC */ "texm3x3spec", + /* WINED3DSIH_TEXM3x3TEX */ "texm3x3tex", + /* WINED3DSIH_TEXM3x3VSPEC */ "texm3x3vspec", + /* WINED3DSIH_TEXREG2AR */ "texreg2ar", + /* WINED3DSIH_TEXREG2GB */ "texreg2gb", + /* WINED3DSIH_TEXREG2RGB */ "texreg2rgb", +}; + +static const char *semantic_names[] = +{ + /* WINED3DDECLUSAGE_POSITION */ "SV_POSITION", + /* WINED3DDECLUSAGE_BLENDWEIGHT */ "BLENDWEIGHT", + /* WINED3DDECLUSAGE_BLENDINDICES */ "BLENDINDICES", + /* WINED3DDECLUSAGE_NORMAL */ "NORMAL", + /* WINED3DDECLUSAGE_PSIZE */ "PSIZE", + /* WINED3DDECLUSAGE_TEXCOORD */ "TEXCOORD", + /* WINED3DDECLUSAGE_TANGENT */ "TANGENT", + /* WINED3DDECLUSAGE_BINORMAL */ "BINORMAL", + /* WINED3DDECLUSAGE_TESSFACTOR */ "TESSFACTOR", + /* WINED3DDECLUSAGE_POSITIONT */ "POSITIONT", + /* WINED3DDECLUSAGE_COLOR */ "COLOR", + /* WINED3DDECLUSAGE_FOG */ "FOG", + /* WINED3DDECLUSAGE_DEPTH */ "DEPTH", + /* WINED3DDECLUSAGE_SAMPLE */ "SAMPLE", +}; + +static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage) +{ + if (usage >= sizeof(semantic_names) / sizeof(*semantic_names)) + { + FIXME("Unrecognized usage %#x.\n", usage); + return "UNRECOGNIZED"; + } + + return semantic_names[usage]; +} + +static WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *name) +{ + unsigned int i; + + for (i = 0; i < sizeof(semantic_names) / sizeof(*semantic_names); ++i) + { + if (!strcmp(name, semantic_names[i])) return i; + } + + return ~0U; +} + +BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) +{ + return !strcmp(semantic_name, shader_semantic_name_from_usage(usage)); +} + +static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e, + const struct wined3d_shader_semantic *s) +{ + e->semantic_name = shader_semantic_name_from_usage(s->usage); + e->semantic_idx = s->usage_idx; + e->sysval_semantic = 0; + e->component_type = 0; + e->register_idx = s->reg.reg.idx; + e->mask = s->reg.write_mask; +} + +static const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) +{ + switch (version_token >> 16) + { + case WINED3D_SM1_VS: + case WINED3D_SM1_PS: + return &sm1_shader_frontend; + + case WINED3D_SM4_PS: + case WINED3D_SM4_VS: + case WINED3D_SM4_GS: + return &sm4_shader_frontend; + + default: + FIXME("Unrecognised version token %#x\n", version_token); + return NULL; + } +} + +void shader_buffer_clear(struct wined3d_shader_buffer *buffer) +{ + buffer->buffer[0] = '\0'; + buffer->bsize = 0; + buffer->lineNo = 0; + buffer->newline = TRUE; +} + +BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) +{ + buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE); + if (!buffer->buffer) + { + ERR("Failed to allocate shader buffer memory.\n"); + return FALSE; + } + + shader_buffer_clear(buffer); + return TRUE; +} + +void shader_buffer_free(struct wined3d_shader_buffer *buffer) +{ + HeapFree(GetProcessHeap(), 0, buffer->buffer); +} + +int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *format, va_list args) +{ + char *base = buffer->buffer + buffer->bsize; + int rc; + + rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args); + + if (rc < 0 /* C89 */ || (unsigned int)rc > SHADER_PGMSIZE - 1 - buffer->bsize /* C99 */) + { + ERR("The buffer allocated for the shader program string " + "is too small at %d bytes.\n", SHADER_PGMSIZE); + buffer->bsize = SHADER_PGMSIZE - 1; + return -1; + } + + if (buffer->newline) + { + TRACE("GL HW (%u, %u) : %s", buffer->lineNo + 1, buffer->bsize, base); + buffer->newline = FALSE; + } + else + { + TRACE("%s", base); + } + + buffer->bsize += rc; + if (buffer->buffer[buffer->bsize-1] == '\n') + { + ++buffer->lineNo; + buffer->newline = TRUE; + } + + return 0; +} + +int shader_addline(struct wined3d_shader_buffer *buffer, const char *format, ...) +{ + va_list args; + int ret; + + va_start(args, format); + ret = shader_vaddline(buffer, format, args); + va_end(args); + + return ret; +} + +static void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device, + IUnknown *parent, const struct wined3d_parent_ops *parent_ops) +{ + shader->ref = 1; + shader->device = (IWineD3DDevice *)device; + shader->parent = parent; + shader->parent_ops = parent_ops; + list_init(&shader->linked_programs); + list_add_head(&device->shaders, &shader->shader_list_entry); +} + +/* Convert floating point offset relative to a register file to an absolute + * offset for float constants. */ +static unsigned int shader_get_float_offset(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx) +{ + switch (register_type) + { + case WINED3DSPR_CONST: return register_idx; + case WINED3DSPR_CONST2: return 2048 + register_idx; + case WINED3DSPR_CONST3: return 4096 + register_idx; + case WINED3DSPR_CONST4: return 6144 + register_idx; + default: + FIXME("Unsupported register type: %u.\n", register_type); + return register_idx; + } +} + +static void shader_delete_constant_list(struct list *clist) +{ + struct local_constant *constant; + struct list *ptr; + + ptr = list_head(clist); + while (ptr) + { + constant = LIST_ENTRY(ptr, struct local_constant, entry); + ptr = list_next(clist, ptr); + HeapFree(GetProcessHeap(), 0, constant); + } + list_init(clist); +} + +static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit) +{ + DWORD idx, shift; + idx = bit >> 5; + shift = bit & 0x1f; + bitmap[idx] |= (1 << shift); +} + +static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct shader_reg_maps *reg_maps, + const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type) +{ + switch (reg->type) + { + case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */ + if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx; + else reg_maps->address |= 1 << reg->idx; + break; + + case WINED3DSPR_TEMP: + reg_maps->temporary |= 1 << reg->idx; + break; + + case WINED3DSPR_INPUT: + if (shader_type == WINED3D_SHADER_TYPE_PIXEL) + { + if (reg->rel_addr) + { + /* If relative addressing is used, we must assume that all registers + * are used. Even if it is a construct like v3[aL], we can't assume + * that v0, v1 and v2 aren't read because aL can be negative */ + unsigned int i; + for (i = 0; i < MAX_REG_INPUT; ++i) + { + ((IWineD3DPixelShaderImpl *)shader)->input_reg_used[i] = TRUE; + } + } + else + { + ((IWineD3DPixelShaderImpl *)shader)->input_reg_used[reg->idx] = TRUE; + } + } + else reg_maps->input_registers |= 1 << reg->idx; + break; + + case WINED3DSPR_RASTOUT: + if (reg->idx == 1) reg_maps->fog = 1; + break; + + case WINED3DSPR_MISCTYPE: + if (shader_type == WINED3D_SHADER_TYPE_PIXEL) + { + if (reg->idx == 0) reg_maps->vpos = 1; + else if (reg->idx == 1) reg_maps->usesfacing = 1; + } + break; + + case WINED3DSPR_CONST: + if (reg->rel_addr) + { + if (shader_type != WINED3D_SHADER_TYPE_PIXEL) + { + if (reg->idx < ((IWineD3DVertexShaderImpl *)shader)->min_rel_offset) + { + ((IWineD3DVertexShaderImpl *)shader)->min_rel_offset = reg->idx; + } + if (reg->idx > ((IWineD3DVertexShaderImpl *)shader)->max_rel_offset) + { + ((IWineD3DVertexShaderImpl *)shader)->max_rel_offset = reg->idx; + } + } + reg_maps->usesrelconstF = TRUE; + } + else + { + set_bitmap_bit(reg_maps->constf, reg->idx); + } + break; + + case WINED3DSPR_CONSTINT: + reg_maps->integer_constants |= (1 << reg->idx); + break; + + case WINED3DSPR_CONSTBOOL: + reg_maps->boolean_constants |= (1 << reg->idx); + break; + + case WINED3DSPR_COLOROUT: + reg_maps->highest_render_target = max(reg_maps->highest_render_target, reg->idx); + break; + + default: + TRACE("Not recording register of type %#x and idx %u\n", reg->type, reg->idx); + break; + } +} + +static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param) +{ + switch (instr) + { + case WINED3DSIH_M4x4: + case WINED3DSIH_M3x4: + return param == 1 ? 3 : 0; + + case WINED3DSIH_M4x3: + case WINED3DSIH_M3x3: + return param == 1 ? 2 : 0; + + case WINED3DSIH_M3x2: + return param == 1 ? 1 : 0; + + default: + return 0; + } +} + +/* Note that this does not count the loop register as an address register. */ +static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe, + struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature, + struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size) +{ + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface; + unsigned int cur_loop_depth = 0, max_loop_depth = 0; + void *fe_data = shader->baseShader.frontend_data; + struct wined3d_shader_version shader_version; + const DWORD *ptr = byte_code; + + memset(reg_maps, 0, sizeof(*reg_maps)); + + /* get_registers_used() is called on every compile on some 1.x shaders, + * which can result in stacking up a collection of local constants. + * Delete the old constants if existing. */ + shader_delete_constant_list(&shader->baseShader.constantsF); + shader_delete_constant_list(&shader->baseShader.constantsB); + shader_delete_constant_list(&shader->baseShader.constantsI); + + fe->shader_read_header(fe_data, &ptr, &shader_version); + reg_maps->shader_version = shader_version; + + reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(*reg_maps->constf) * ((constf_size + 31) / 32)); + if (!reg_maps->constf) + { + ERR("Failed to allocate constant map memory.\n"); + return E_OUTOFMEMORY; + } + + while (!fe->shader_is_end(fe_data, &ptr)) + { + struct wined3d_shader_instruction ins; + const char *comment; + UINT comment_size; + UINT param_size; + + /* Skip comments. */ + fe->shader_read_comment(&ptr, &comment, &comment_size); + if (comment) continue; + + /* Fetch opcode. */ + fe->shader_read_opcode(fe_data, &ptr, &ins, ¶m_size); + + /* Unhandled opcode, and its parameters. */ + if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) + { + TRACE("Skipping unrecognized instruction.\n"); + ptr += param_size; + continue; + } + + /* Handle declarations. */ + if (ins.handler_idx == WINED3DSIH_DCL) + { + struct wined3d_shader_semantic semantic; + + fe->shader_read_semantic(&ptr, &semantic); + + switch (semantic.reg.reg.type) + { + /* Mark input registers used. */ + case WINED3DSPR_INPUT: + reg_maps->input_registers |= 1 << semantic.reg.reg.idx; + shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic); + break; + + /* Vertex shader: mark 3.0 output registers used, save token. */ + case WINED3DSPR_OUTPUT: + reg_maps->output_registers |= 1 << semantic.reg.reg.idx; + shader_signature_from_semantic(&output_signature[semantic.reg.reg.idx], &semantic); + if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1; + break; + + /* Save sampler usage token. */ + case WINED3DSPR_SAMPLER: + reg_maps->sampler_type[semantic.reg.reg.idx] = semantic.sampler_type; + break; + + default: + TRACE("Not recording DCL register type %#x.\n", semantic.reg.reg.type); + break; + } + } + else if (ins.handler_idx == WINED3DSIH_DEF) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); + if (!lconst) return E_OUTOFMEMORY; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + lconst->idx = dst.reg.idx; + + memcpy(lconst->value, ptr, 4 * sizeof(DWORD)); + ptr += 4; + + /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */ + if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL) + { + float *value = (float *)lconst->value; + if (value[0] < -1.0f) value[0] = -1.0f; + else if (value[0] > 1.0f) value[0] = 1.0f; + if (value[1] < -1.0f) value[1] = -1.0f; + else if (value[1] > 1.0f) value[1] = 1.0f; + if (value[2] < -1.0f) value[2] = -1.0f; + else if (value[2] > 1.0f) value[2] = 1.0f; + if (value[3] < -1.0f) value[3] = -1.0f; + else if (value[3] > 1.0f) value[3] = 1.0f; + } + + list_add_head(&shader->baseShader.constantsF, &lconst->entry); + } + else if (ins.handler_idx == WINED3DSIH_DEFI) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); + if (!lconst) return E_OUTOFMEMORY; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + lconst->idx = dst.reg.idx; + + memcpy(lconst->value, ptr, 4 * sizeof(DWORD)); + ptr += 4; + + list_add_head(&shader->baseShader.constantsI, &lconst->entry); + reg_maps->local_int_consts |= (1 << dst.reg.idx); + } + else if (ins.handler_idx == WINED3DSIH_DEFB) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); + if (!lconst) return E_OUTOFMEMORY; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + lconst->idx = dst.reg.idx; + + memcpy(lconst->value, ptr, sizeof(DWORD)); + ++ptr; + + list_add_head(&shader->baseShader.constantsB, &lconst->entry); + reg_maps->local_bool_consts |= (1 << dst.reg.idx); + } + /* If there's a loop in the shader. */ + else if (ins.handler_idx == WINED3DSIH_LOOP + || ins.handler_idx == WINED3DSIH_REP) + { + struct wined3d_shader_src_param src, rel_addr; + + fe->shader_read_src_param(fe_data, &ptr, &src, &rel_addr); + + /* Rep and Loop always use an integer constant for the control parameters. */ + if (ins.handler_idx == WINED3DSIH_REP) + { + reg_maps->integer_constants |= 1 << src.reg.idx; + } + else + { + fe->shader_read_src_param(fe_data, &ptr, &src, &rel_addr); + reg_maps->integer_constants |= 1 << src.reg.idx; + } + + cur_loop_depth++; + if (cur_loop_depth > max_loop_depth) max_loop_depth = cur_loop_depth; + } + else if (ins.handler_idx == WINED3DSIH_ENDLOOP + || ins.handler_idx == WINED3DSIH_ENDREP) + { + cur_loop_depth--; + } + /* For subroutine prototypes. */ + else if (ins.handler_idx == WINED3DSIH_LABEL) + { + struct wined3d_shader_src_param src, rel_addr; + + fe->shader_read_src_param(fe_data, &ptr, &src, &rel_addr); + reg_maps->labels |= 1 << src.reg.idx; + } + /* Set texture, address, temporary registers. */ + else + { + BOOL color0_mov = FALSE; + int i, limit; + + /* This will loop over all the registers and try to + * make a bitmask of the ones we're interested in. + * + * Relative addressing tokens are ignored, but that's + * okay, since we'll catch any address registers when + * they are initialized (required by spec). */ + if (ins.dst_count) + { + struct wined3d_shader_src_param dst_rel_addr; + struct wined3d_shader_dst_param dst_param; + + fe->shader_read_dst_param(fe_data, &ptr, &dst_param, &dst_rel_addr); + + shader_record_register_usage(shader, reg_maps, &dst_param.reg, shader_version.type); + + /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and + * is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel + * shaders because TECRDOUT isn't used in them, but future register types might cause issues */ + if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX && shader_version.major < 3 + && dst_param.reg.type == WINED3DSPR_TEXCRDOUT) + { + reg_maps->texcoord_mask[dst_param.reg.idx] |= dst_param.write_mask; + } + + if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL) + { + IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader; + + if (dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0) + { + /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to + * COLOROUT 0. If we know this in advance, the ARB shader backend can skip + * the mov and perform the sRGB write correction from the source register. + * + * However, if the mov is only partial, we can't do this, and if the write + * comes from an instruction other than MOV it is hard to do as well. If + * COLOROUT 0 is overwritten partially later, the marker is dropped again. */ + + ps->color0_mov = FALSE; + if (ins.handler_idx == WINED3DSIH_MOV) + { + /* Used later when the source register is read. */ + color0_mov = TRUE; + } + } + /* Also drop the MOV marker if the source register is overwritten prior to the shader + * end + */ + else if (dst_param.reg.type == WINED3DSPR_TEMP && dst_param.reg.idx == ps->color0_reg) + { + ps->color0_mov = FALSE; + } + } + + /* Declare 1.x samplers implicitly, based on the destination reg. number. */ + if (shader_version.major == 1 + && (ins.handler_idx == WINED3DSIH_TEX + || ins.handler_idx == WINED3DSIH_TEXBEM + || ins.handler_idx == WINED3DSIH_TEXBEML + || ins.handler_idx == WINED3DSIH_TEXDP3TEX + || ins.handler_idx == WINED3DSIH_TEXM3x2TEX + || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC + || ins.handler_idx == WINED3DSIH_TEXM3x3TEX + || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC + || ins.handler_idx == WINED3DSIH_TEXREG2AR + || ins.handler_idx == WINED3DSIH_TEXREG2GB + || ins.handler_idx == WINED3DSIH_TEXREG2RGB)) + { + /* Fake sampler usage, only set reserved bit and type. */ + DWORD sampler_code = dst_param.reg.idx; + + TRACE("Setting fake 2D sampler for 1.x pixelshader.\n"); + reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D; + + /* texbem is only valid with < 1.4 pixel shaders */ + if (ins.handler_idx == WINED3DSIH_TEXBEM + || ins.handler_idx == WINED3DSIH_TEXBEML) + { + reg_maps->bumpmat |= 1 << dst_param.reg.idx; + if (ins.handler_idx == WINED3DSIH_TEXBEML) + { + reg_maps->luminanceparams |= 1 << dst_param.reg.idx; + } + } + } + else if (ins.handler_idx == WINED3DSIH_BEM) + { + reg_maps->bumpmat |= 1 << dst_param.reg.idx; + } + } + + if (ins.handler_idx == WINED3DSIH_NRM) reg_maps->usesnrm = 1; + else if (ins.handler_idx == WINED3DSIH_DSY) reg_maps->usesdsy = 1; + else if (ins.handler_idx == WINED3DSIH_DSX) reg_maps->usesdsx = 1; + else if (ins.handler_idx == WINED3DSIH_TEXLDD) reg_maps->usestexldd = 1; + else if (ins.handler_idx == WINED3DSIH_TEXLDL) reg_maps->usestexldl = 1; + else if (ins.handler_idx == WINED3DSIH_MOVA) reg_maps->usesmova = 1; + else if (ins.handler_idx == WINED3DSIH_IFC) reg_maps->usesifc = 1; + else if (ins.handler_idx == WINED3DSIH_CALL) reg_maps->usescall = 1; + + limit = ins.src_count + (ins.predicate ? 1 : 0); + for (i = 0; i < limit; ++i) + { + struct wined3d_shader_src_param src_param, src_rel_addr; + unsigned int count; + + fe->shader_read_src_param(fe_data, &ptr, &src_param, &src_rel_addr); + count = get_instr_extra_regcount(ins.handler_idx, i); + + shader_record_register_usage(shader, reg_maps, &src_param.reg, shader_version.type); + while (count) + { + ++src_param.reg.idx; + shader_record_register_usage(shader, reg_maps, &src_param.reg, shader_version.type); + --count; + } + + if (color0_mov) + { + IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader; + if (src_param.reg.type == WINED3DSPR_TEMP + && src_param.swizzle == WINED3DSP_NOSWIZZLE) + { + ps->color0_mov = TRUE; + ps->color0_reg = src_param.reg.idx; + } + } + } + } + } + reg_maps->loop_depth = max_loop_depth; + + shader->baseShader.functionLength = ((const char *)ptr - (const char *)byte_code); + + return WINED3D_OK; +} + +unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) +{ + DWORD map = 1 << max; + map |= map - 1; + map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers; + + return wined3d_log2i(map); +} + +static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic, + const struct wined3d_shader_version *shader_version) +{ + TRACE("dcl"); + + if (semantic->reg.reg.type == WINED3DSPR_SAMPLER) + { + switch (semantic->sampler_type) + { + case WINED3DSTT_2D: TRACE("_2d"); break; + case WINED3DSTT_CUBE: TRACE("_cube"); break; + case WINED3DSTT_VOLUME: TRACE("_volume"); break; + default: TRACE("_unknown_ttype(0x%08x)", semantic->sampler_type); + } + } + else + { + /* Pixel shaders 3.0 don't have usage semantics. */ + if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL) return; + else TRACE("_"); + + switch (semantic->usage) + { + case WINED3DDECLUSAGE_POSITION: + TRACE("position%u", semantic->usage_idx); + break; + + case WINED3DDECLUSAGE_BLENDINDICES: + TRACE("blend"); + break; + + case WINED3DDECLUSAGE_BLENDWEIGHT: + TRACE("weight"); + break; + + case WINED3DDECLUSAGE_NORMAL: + TRACE("normal%u", semantic->usage_idx); + break; + + case WINED3DDECLUSAGE_PSIZE: + TRACE("psize"); + break; + + case WINED3DDECLUSAGE_COLOR: + if (semantic->usage_idx == 0) TRACE("color"); + else TRACE("specular%u", (semantic->usage_idx - 1)); + break; + + case WINED3DDECLUSAGE_TEXCOORD: + TRACE("texture%u", semantic->usage_idx); + break; + + case WINED3DDECLUSAGE_TANGENT: + TRACE("tangent"); + break; + + case WINED3DDECLUSAGE_BINORMAL: + TRACE("binormal"); + break; + + case WINED3DDECLUSAGE_TESSFACTOR: + TRACE("tessfactor"); + break; + + case WINED3DDECLUSAGE_POSITIONT: + TRACE("positionT%u", semantic->usage_idx); + break; + + case WINED3DDECLUSAGE_FOG: + TRACE("fog"); + break; + + case WINED3DDECLUSAGE_DEPTH: + TRACE("depth"); + break; + + case WINED3DDECLUSAGE_SAMPLE: + TRACE("sample"); + break; + + default: + FIXME("unknown_semantics(0x%08x)", semantic->usage); + } + } +} + +static void shader_dump_register(const struct wined3d_shader_register *reg, + const struct wined3d_shader_version *shader_version) +{ + static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"}; + static const char * const misctype_reg_names[] = {"vPos", "vFace"}; + UINT offset = reg->idx; + + switch (reg->type) + { + case WINED3DSPR_TEMP: + TRACE("r"); + break; + + case WINED3DSPR_INPUT: + TRACE("v"); + break; + + case WINED3DSPR_CONST: + case WINED3DSPR_CONST2: + case WINED3DSPR_CONST3: + case WINED3DSPR_CONST4: + TRACE("c"); + offset = shader_get_float_offset(reg->type, reg->idx); + break; + + case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */ + TRACE("%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a'); + break; + + case WINED3DSPR_RASTOUT: + TRACE("%s", rastout_reg_names[reg->idx]); + break; + + case WINED3DSPR_COLOROUT: + TRACE("oC"); + break; + + case WINED3DSPR_DEPTHOUT: + TRACE("oDepth"); + break; + + case WINED3DSPR_ATTROUT: + TRACE("oD"); + break; + + case WINED3DSPR_TEXCRDOUT: + /* Vertex shaders >= 3.0 use general purpose output registers + * (WINED3DSPR_OUTPUT), which can include an address token. */ + if (shader_version->major >= 3) TRACE("o"); + else TRACE("oT"); + break; + + case WINED3DSPR_CONSTINT: + TRACE("i"); + break; + + case WINED3DSPR_CONSTBOOL: + TRACE("b"); + break; + + case WINED3DSPR_LABEL: + TRACE("l"); + break; + + case WINED3DSPR_LOOP: + TRACE("aL"); + break; + + case WINED3DSPR_SAMPLER: + TRACE("s"); + break; + + case WINED3DSPR_MISCTYPE: + if (reg->idx > 1) FIXME("Unhandled misctype register %u.\n", reg->idx); + else TRACE("%s", misctype_reg_names[reg->idx]); + break; + + case WINED3DSPR_PREDICATE: + TRACE("p"); + break; + + case WINED3DSPR_IMMCONST: + TRACE("l"); + break; + + case WINED3DSPR_CONSTBUFFER: + TRACE("cb"); + break; + + default: + TRACE("unhandled_rtype(%#x)", reg->type); + break; + } + + if (reg->type == WINED3DSPR_IMMCONST) + { + TRACE("("); + switch (reg->immconst_type) + { + case WINED3D_IMMCONST_FLOAT: + TRACE("%.8e", *(const float *)reg->immconst_data); + break; + + case WINED3D_IMMCONST_FLOAT4: + TRACE("%.8e, %.8e, %.8e, %.8e", + *(const float *)®->immconst_data[0], *(const float *)®->immconst_data[1], + *(const float *)®->immconst_data[2], *(const float *)®->immconst_data[3]); + break; + + default: + TRACE("", reg->immconst_type); + break; + } + TRACE(")"); + } + else if (reg->type != WINED3DSPR_RASTOUT && reg->type != WINED3DSPR_MISCTYPE) + { + if (reg->array_idx != ~0U) + { + TRACE("%u[%u", offset, reg->array_idx); + if (reg->rel_addr) + { + TRACE(" + "); + shader_dump_src_param(reg->rel_addr, shader_version); + } + TRACE("]"); + } + else + { + if (reg->rel_addr) + { + TRACE("["); + shader_dump_src_param(reg->rel_addr, shader_version); + TRACE(" + "); + } + TRACE("%u", offset); + if (reg->rel_addr) TRACE("]"); + } + } +} + +void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, + const struct wined3d_shader_version *shader_version) +{ + DWORD write_mask = param->write_mask; + + shader_dump_register(¶m->reg, shader_version); + + if (write_mask != WINED3DSP_WRITEMASK_ALL) + { + static const char *write_mask_chars = "xyzw"; + + TRACE("."); + if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]); + if (write_mask & WINED3DSP_WRITEMASK_1) TRACE("%c", write_mask_chars[1]); + if (write_mask & WINED3DSP_WRITEMASK_2) TRACE("%c", write_mask_chars[2]); + if (write_mask & WINED3DSP_WRITEMASK_3) TRACE("%c", write_mask_chars[3]); + } +} + +void shader_dump_src_param(const struct wined3d_shader_src_param *param, + const struct wined3d_shader_version *shader_version) +{ + DWORD src_modifier = param->modifiers; + DWORD swizzle = param->swizzle; + + if (src_modifier == WINED3DSPSM_NEG + || src_modifier == WINED3DSPSM_BIASNEG + || src_modifier == WINED3DSPSM_SIGNNEG + || src_modifier == WINED3DSPSM_X2NEG + || src_modifier == WINED3DSPSM_ABSNEG) + TRACE("-"); + else if (src_modifier == WINED3DSPSM_COMP) + TRACE("1-"); + else if (src_modifier == WINED3DSPSM_NOT) + TRACE("!"); + + if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG) + TRACE("abs("); + + shader_dump_register(¶m->reg, shader_version); + + if (src_modifier) + { + switch (src_modifier) + { + case WINED3DSPSM_NONE: break; + case WINED3DSPSM_NEG: break; + case WINED3DSPSM_NOT: break; + case WINED3DSPSM_BIAS: TRACE("_bias"); break; + case WINED3DSPSM_BIASNEG: TRACE("_bias"); break; + case WINED3DSPSM_SIGN: TRACE("_bx2"); break; + case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break; + case WINED3DSPSM_COMP: break; + case WINED3DSPSM_X2: TRACE("_x2"); break; + case WINED3DSPSM_X2NEG: TRACE("_x2"); break; + case WINED3DSPSM_DZ: TRACE("_dz"); break; + case WINED3DSPSM_DW: TRACE("_dw"); break; + case WINED3DSPSM_ABSNEG: TRACE(")"); break; + case WINED3DSPSM_ABS: TRACE(")"); break; + default: TRACE("_unknown_modifier(%#x)", src_modifier); + } + } + + if (swizzle != WINED3DSP_NOSWIZZLE) + { + static const char *swizzle_chars = "xyzw"; + DWORD swizzle_x = swizzle & 0x03; + DWORD swizzle_y = (swizzle >> 2) & 0x03; + DWORD swizzle_z = (swizzle >> 4) & 0x03; + DWORD swizzle_w = (swizzle >> 6) & 0x03; + + if (swizzle_x == swizzle_y + && swizzle_x == swizzle_z + && swizzle_x == swizzle_w) + { + TRACE(".%c", swizzle_chars[swizzle_x]); + } + else + { + TRACE(".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y], + swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]); + } + } +} + +/* Shared code in order to generate the bulk of the shader string. + * NOTE: A description of how to parse tokens can be found on MSDN. */ +void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer, + const shader_reg_maps *reg_maps, const DWORD *byte_code, void *backend_ctx) +{ + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface; + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device; + const struct wined3d_shader_frontend *fe = shader->baseShader.frontend; + void *fe_data = shader->baseShader.frontend_data; + struct wined3d_shader_src_param src_rel_addr[4]; + struct wined3d_shader_src_param src_param[4]; + struct wined3d_shader_version shader_version; + struct wined3d_shader_src_param dst_rel_addr; + struct wined3d_shader_dst_param dst_param; + struct wined3d_shader_instruction ins; + struct wined3d_shader_context ctx; + const DWORD *ptr = byte_code; + DWORD i; + + /* Initialize current parsing state. */ + ctx.shader = iface; + ctx.gl_info = &device->adapter->gl_info; + ctx.reg_maps = reg_maps; + ctx.buffer = buffer; + ctx.backend_data = backend_ctx; + + ins.ctx = &ctx; + ins.dst = &dst_param; + ins.src = src_param; + shader->baseShader.parse_state.current_row = 0; + + fe->shader_read_header(fe_data, &ptr, &shader_version); + + while (!fe->shader_is_end(fe_data, &ptr)) + { + const char *comment; + UINT comment_size; + UINT param_size; + + /* Skip comment tokens. */ + fe->shader_read_comment(&ptr, &comment, &comment_size); + if (comment) continue; + + /* Read opcode. */ + fe->shader_read_opcode(fe_data, &ptr, &ins, ¶m_size); + + /* Unknown opcode and its parameters. */ + if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) + { + TRACE("Skipping unrecognized instruction.\n"); + ptr += param_size; + continue; + } + + /* Nothing to do. */ + if (ins.handler_idx == WINED3DSIH_DCL + || ins.handler_idx == WINED3DSIH_NOP + || ins.handler_idx == WINED3DSIH_DEF + || ins.handler_idx == WINED3DSIH_DEFI + || ins.handler_idx == WINED3DSIH_DEFB + || ins.handler_idx == WINED3DSIH_PHASE) + { + ptr += param_size; + continue; + } + + /* Destination token */ + if (ins.dst_count) fe->shader_read_dst_param(fe_data, &ptr, &dst_param, &dst_rel_addr); + + /* Predication token */ + if (ins.predicate) ins.predicate = *ptr++; + + /* Other source tokens */ + for (i = 0; i < ins.src_count; ++i) + { + fe->shader_read_src_param(fe_data, &ptr, &src_param[i], &src_rel_addr[i]); + } + + /* Call appropriate function for output target */ + device->shader_backend->shader_handle_instruction(&ins); + } +} + +static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst) +{ + DWORD mmask = dst->modifiers; + + switch (dst->shift) + { + case 0: break; + case 13: TRACE("_d8"); break; + case 14: TRACE("_d4"); break; + case 15: TRACE("_d2"); break; + case 1: TRACE("_x2"); break; + case 2: TRACE("_x4"); break; + case 3: TRACE("_x8"); break; + default: TRACE("_unhandled_shift(%d)", dst->shift); break; + } + + if (mmask & WINED3DSPDM_SATURATE) TRACE("_sat"); + if (mmask & WINED3DSPDM_PARTIALPRECISION) TRACE("_pp"); + if (mmask & WINED3DSPDM_MSAMPCENTROID) TRACE("_centroid"); + + mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID); + if (mmask) FIXME("_unrecognized_modifier(%#x)", mmask); +} + +static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *byte_code) +{ + struct wined3d_shader_version shader_version; + const DWORD *ptr = byte_code; + const char *type_prefix; + DWORD i; + + TRACE("Parsing %p.\n", byte_code); + + fe->shader_read_header(fe_data, &ptr, &shader_version); + + switch (shader_version.type) + { + case WINED3D_SHADER_TYPE_VERTEX: + type_prefix = "vs"; + break; + + case WINED3D_SHADER_TYPE_GEOMETRY: + type_prefix = "gs"; + break; + + case WINED3D_SHADER_TYPE_PIXEL: + type_prefix = "ps"; + break; + + default: + FIXME("Unhandled shader type %#x.\n", shader_version.type); + type_prefix = "unknown"; + break; + } + + TRACE("%s_%u_%u\n", type_prefix, shader_version.major, shader_version.minor); + + while (!fe->shader_is_end(fe_data, &ptr)) + { + struct wined3d_shader_instruction ins; + const char *comment; + UINT comment_size; + UINT param_size; + + /* comment */ + fe->shader_read_comment(&ptr, &comment, &comment_size); + if (comment) + { + if (comment_size > 4 && *(const DWORD *)comment == WINEMAKEFOURCC('T', 'E', 'X', 'T')) + { + const char *end = comment + comment_size; + const char *ptr = comment + 4; + const char *line = ptr; + + TRACE("// TEXT\n"); + while (ptr != end) + { + if (*ptr == '\n') + { + UINT len = ptr - line; + if (len && *(ptr - 1) == '\r') --len; + TRACE("// %s\n", debugstr_an(line, len)); + line = ++ptr; + } + else ++ptr; + } + if (line != ptr) TRACE("// %s\n", debugstr_an(line, ptr - line)); + } + else TRACE("// %s\n", debugstr_an(comment, comment_size)); + continue; + } + + fe->shader_read_opcode(fe_data, &ptr, &ins, ¶m_size); + if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) + { + TRACE("Skipping unrecognized instruction.\n"); + ptr += param_size; + continue; + } + + if (ins.handler_idx == WINED3DSIH_DCL) + { + struct wined3d_shader_semantic semantic; + + fe->shader_read_semantic(&ptr, &semantic); + + shader_dump_decl_usage(&semantic, &shader_version); + shader_dump_ins_modifiers(&semantic.reg); + TRACE(" "); + shader_dump_dst_param(&semantic.reg, &shader_version); + } + else if (ins.handler_idx == WINED3DSIH_DEF) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + + TRACE("def c%u = %f, %f, %f, %f", shader_get_float_offset(dst.reg.type, dst.reg.idx), + *(const float *)(ptr), + *(const float *)(ptr + 1), + *(const float *)(ptr + 2), + *(const float *)(ptr + 3)); + ptr += 4; + } + else if (ins.handler_idx == WINED3DSIH_DEFI) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + + TRACE("defi i%u = %d, %d, %d, %d", dst.reg.idx, + *(ptr), + *(ptr + 1), + *(ptr + 2), + *(ptr + 3)); + ptr += 4; + } + else if (ins.handler_idx == WINED3DSIH_DEFB) + { + struct wined3d_shader_src_param rel_addr; + struct wined3d_shader_dst_param dst; + + fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); + + TRACE("defb b%u = %s", dst.reg.idx, *ptr ? "true" : "false"); + ++ptr; + } + else + { + struct wined3d_shader_src_param dst_rel_addr, src_rel_addr; + struct wined3d_shader_dst_param dst_param; + struct wined3d_shader_src_param src_param; + + if (ins.dst_count) + { + fe->shader_read_dst_param(fe_data, &ptr, &dst_param, &dst_rel_addr); + } + + /* Print out predication source token first - it follows + * the destination token. */ + if (ins.predicate) + { + fe->shader_read_src_param(fe_data, &ptr, &src_param, &src_rel_addr); + TRACE("("); + shader_dump_src_param(&src_param, &shader_version); + TRACE(") "); + } + + /* PixWin marks instructions with the coissue flag with a '+' */ + if (ins.coissue) TRACE("+"); + + TRACE("%s", shader_opcode_names[ins.handler_idx]); + + if (ins.handler_idx == WINED3DSIH_IFC + || ins.handler_idx == WINED3DSIH_BREAKC) + { + switch (ins.flags) + { + case COMPARISON_GT: TRACE("_gt"); break; + case COMPARISON_EQ: TRACE("_eq"); break; + case COMPARISON_GE: TRACE("_ge"); break; + case COMPARISON_LT: TRACE("_lt"); break; + case COMPARISON_NE: TRACE("_ne"); break; + case COMPARISON_LE: TRACE("_le"); break; + default: TRACE("_(%u)", ins.flags); + } + } + else if (ins.handler_idx == WINED3DSIH_TEX + && shader_version.major >= 2 + && (ins.flags & WINED3DSI_TEXLD_PROJECT)) + { + TRACE("p"); + } + + /* We already read the destination token, print it. */ + if (ins.dst_count) + { + shader_dump_ins_modifiers(&dst_param); + TRACE(" "); + shader_dump_dst_param(&dst_param, &shader_version); + } + + /* Other source tokens */ + for (i = ins.dst_count; i < (ins.dst_count + ins.src_count); ++i) + { + fe->shader_read_src_param(fe_data, &ptr, &src_param, &src_rel_addr); + TRACE(!i ? " " : ", "); + shader_dump_src_param(&src_param, &shader_version); + } + } + TRACE("\n"); + } +} + +static void shader_cleanup(IWineD3DBaseShader *iface) +{ + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface; + + ((IWineD3DDeviceImpl *)shader->baseShader.device)->shader_backend->shader_destroy(iface); + HeapFree(GetProcessHeap(), 0, shader->baseShader.reg_maps.constf); + HeapFree(GetProcessHeap(), 0, shader->baseShader.function); + shader_delete_constant_list(&shader->baseShader.constantsF); + shader_delete_constant_list(&shader->baseShader.constantsB); + shader_delete_constant_list(&shader->baseShader.constantsI); + list_remove(&shader->baseShader.shader_list_entry); + + if (shader->baseShader.frontend && shader->baseShader.frontend_data) + { + shader->baseShader.frontend->shader_free(shader->baseShader.frontend_data); + } +} + +static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {} +static void shader_none_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {} +static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {} +static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {} +static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {} +static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {} +static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {} +static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {} +static void shader_none_destroy(IWineD3DBaseShader *iface) {} +static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;} +static void shader_none_free(IWineD3DDevice *iface) {} +static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;} + +static void shader_none_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps) +{ + /* Set the shader caps to 0 for the none shader backend */ + caps->VertexShaderVersion = 0; + caps->PixelShaderVersion = 0; + caps->PixelShader1xMaxValue = 0.0f; +} + +static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup) +{ + if (TRACE_ON(d3d_shader) && TRACE_ON(d3d)) + { + TRACE("Checking support for fixup:\n"); + dump_color_fixup_desc(fixup); + } + + /* Faked to make some apps happy. */ + if (!is_complex_fixup(fixup)) + { + TRACE("[OK]\n"); + return TRUE; + } + + TRACE("[FAILED]\n"); + return FALSE; +} + +const shader_backend_t none_shader_backend = { + shader_none_handle_instruction, + shader_none_select, + shader_none_select_depth_blt, + shader_none_deselect_depth_blt, + shader_none_update_float_vertex_constants, + shader_none_update_float_pixel_constants, + shader_none_load_constants, + shader_none_load_np2fixup_constants, + shader_none_destroy, + shader_none_alloc, + shader_none_free, + shader_none_dirty_const, + shader_none_get_caps, + shader_none_color_fixup_supported, +}; static void shader_get_parent(IWineD3DBaseShaderImpl *shader, IUnknown **parent) { diff --git a/dll/directx/wine/wined3d/shader_sm1.c b/dll/directx/wine/wined3d/shader_sm1.c index 64876b38032..aa1da56c5ba 100644 --- a/dll/directx/wine/wined3d/shader_sm1.c +++ b/dll/directx/wine/wined3d/shader_sm1.c @@ -641,9 +641,10 @@ static void shader_sm1_read_semantic(const DWORD **ptr, struct wined3d_shader_se shader_parse_dst_param(dst_token, NULL, &semantic->reg); } -static void shader_sm1_read_comment(const DWORD **ptr, const char **comment) +static void shader_sm1_read_comment(const DWORD **ptr, const char **comment, UINT *comment_size) { DWORD token = **ptr; + UINT size; if ((token & WINED3DSI_OPCODE_MASK) != WINED3D_SM1_OP_COMMENT) { @@ -651,8 +652,10 @@ static void shader_sm1_read_comment(const DWORD **ptr, const char **comment) return; } + size = (token & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT; *comment = (const char *)++(*ptr); - *ptr += (token & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT; + *comment_size = size * sizeof(DWORD); + *ptr += size; } static BOOL shader_sm1_is_end(void *data, const DWORD **ptr) diff --git a/dll/directx/wine/wined3d/shader_sm4.c b/dll/directx/wine/wined3d/shader_sm4.c index 91aa882c888..b4637904f10 100644 --- a/dll/directx/wine/wined3d/shader_sm4.c +++ b/dll/directx/wine/wined3d/shader_sm4.c @@ -49,10 +49,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); enum wined3d_sm4_opcode { WINED3D_SM4_OP_ADD = 0x00, + WINED3D_SM4_OP_BREAK = 0x02, + WINED3D_SM4_OP_BREAKC = 0x03, + WINED3D_SM4_OP_CUT = 0x09, WINED3D_SM4_OP_DP3 = 0x10, WINED3D_SM4_OP_DP4 = 0x11, + WINED3D_SM4_OP_EMIT = 0x13, + WINED3D_SM4_OP_ENDIF = 0x15, + WINED3D_SM4_OP_ENDLOOP = 0x16, WINED3D_SM4_OP_EXP = 0x19, + WINED3D_SM4_OP_IADD = 0x1e, + WINED3D_SM4_OP_IF = 0x1f, + WINED3D_SM4_OP_IGE = 0x21, WINED3D_SM4_OP_LOG = 0x2f, + WINED3D_SM4_OP_LT = 0x31, WINED3D_SM4_OP_MIN = 0x33, WINED3D_SM4_OP_MAX = 0x34, WINED3D_SM4_OP_MOV = 0x36, @@ -102,10 +112,20 @@ struct sysval_map static const struct wined3d_sm4_opcode_info opcode_table[] = { {WINED3D_SM4_OP_ADD, WINED3DSIH_ADD, 1, 2}, + {WINED3D_SM4_OP_BREAK, WINED3DSIH_BREAK, 0, 0}, + {WINED3D_SM4_OP_BREAKC, WINED3DSIH_BREAKP, 0, 1}, + {WINED3D_SM4_OP_CUT, WINED3DSIH_CUT, 0, 0}, {WINED3D_SM4_OP_DP3, WINED3DSIH_DP3, 1, 2}, {WINED3D_SM4_OP_DP4, WINED3DSIH_DP4, 1, 2}, + {WINED3D_SM4_OP_EMIT, WINED3DSIH_EMIT, 0, 0}, + {WINED3D_SM4_OP_ENDIF, WINED3DSIH_ENDIF, 0, 0}, + {WINED3D_SM4_OP_ENDLOOP,WINED3DSIH_ENDLOOP, 0, 0}, {WINED3D_SM4_OP_EXP, WINED3DSIH_EXP, 1, 1}, + {WINED3D_SM4_OP_IADD, WINED3DSIH_IADD, 1, 2}, + {WINED3D_SM4_OP_IF, WINED3DSIH_IF, 0, 1}, + {WINED3D_SM4_OP_IGE, WINED3DSIH_IGE, 1, 2}, {WINED3D_SM4_OP_LOG, WINED3DSIH_LOG, 1, 1}, + {WINED3D_SM4_OP_LT, WINED3DSIH_LT, 1, 2}, {WINED3D_SM4_OP_MIN, WINED3DSIH_MIN, 1, 2}, {WINED3D_SM4_OP_MAX, WINED3DSIH_MAX, 1, 2}, {WINED3D_SM4_OP_MOV, WINED3DSIH_MOV, 1, 1}, @@ -386,9 +406,9 @@ static void shader_sm4_read_semantic(const DWORD **ptr, struct wined3d_shader_se FIXME("ptr %p, semantic %p stub!\n", ptr, semantic); } -static void shader_sm4_read_comment(const DWORD **ptr, const char **comment) +static void shader_sm4_read_comment(const DWORD **ptr, const char **comment, UINT *comment_size) { - FIXME("ptr %p, comment %p stub!\n", ptr, comment); + FIXME("ptr %p, comment %p, comment_size %p stub!\n", ptr, comment, comment_size); *comment = NULL; } diff --git a/dll/directx/wine/wined3d/state.c b/dll/directx/wine/wined3d/state.c index adb426b904b..5efe069bb19 100644 --- a/dll/directx/wine/wined3d/state.c +++ b/dll/directx/wine/wined3d/state.c @@ -584,6 +584,10 @@ static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock, stru glEnable(GL_DEPTH_CLAMP); checkGLcall("glEnable(GL_DEPTH_CLAMP)"); } + else + { + FIXME("Clipping disabled, but ARB_depth_clamp isn't supported.\n"); + } } if (enable & WINED3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); } @@ -3523,7 +3527,6 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine if(stateblock->textures[sampler]) { BOOL srgb = stateblock->samplerState[sampler][WINED3DSAMP_SRGBTEXTURE]; IWineD3DBaseTextureImpl *tex_impl = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler]; - tex_impl->baseTexture.internal_preload(stateblock->textures[sampler], srgb ? SRGB_SRGB : SRGB_RGB); IWineD3DBaseTexture_BindTexture(stateblock->textures[sampler], srgb); basetexture_apply_state_changes(stateblock->textures[sampler], stateblock->textureState[sampler], stateblock->samplerState[sampler], gl_info); @@ -3597,9 +3600,9 @@ void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w } } else { /* Disabled the pixel shader - color ops weren't applied - * while it was enabled, so re-apply them. - */ - for(i=0; i < MAX_TEXTURES; i++) { + * while it was enabled, so re-apply them. */ + for (i = 0; i < context->gl_info->limits.texture_stages; ++i) + { if(!isStateDirty(context, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP))) { device->StateTable[STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP)].apply (STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock, context); @@ -3880,62 +3883,18 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock glLoadIdentity(); checkGLcall("glLoadIdentity"); - if(context->last_was_rhw) { - double X, Y, height, width, minZ, maxZ; + if (context->last_was_rhw) + { + double x = stateblock->viewport.X; + double y = stateblock->viewport.Y; + double w = stateblock->viewport.Width; + double h = stateblock->viewport.Height; - X = stateblock->viewport.X; - Y = stateblock->viewport.Y; - height = stateblock->viewport.Height; - width = stateblock->viewport.Width; - minZ = stateblock->viewport.MinZ; - maxZ = stateblock->viewport.MaxZ; - - if (!stateblock->device->untransformed) - { - /* Transformed vertices are supposed to bypass the whole transform pipeline including - * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to - * suppress depth clipping. This can be done because it is an orthogonal projection and - * the Z coordinate does not affect the size of the primitives. Half Life 1 and Prince of - * Persia 3D need this. - * - * Note that using minZ and maxZ here doesn't entirely fix the problem, since view frustum - * clipping is still enabled, but it seems to fix it for all apps tested so far. A minor - * problem can be witnessed in half-life 1 engine based games, the weapon is clipped close - * to the viewer. - * - * Also note that this breaks z comparison against z values filled in with clear, - * but no app depending on that and disabled clipping has been found yet. Comparing - * primitives against themselves works, so the Z buffer is still intact for normal hidden - * surface removal. - * - * We could disable clipping entirely by setting the near to infinity and far to -infinity, - * but this would break Z buffer operation. Raising the range to something less than - * infinity would help a bit at the cost of Z precision, but it wouldn't eliminate the - * problem either. - */ - TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ); - if (context->render_offscreen) - { - glOrtho(X, X + width, -Y, -Y - height, -minZ, -maxZ); - } else { - glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ); - } - } else { - /* If the app mixes transformed and untransformed primitives we can't use the coordinate system - * trick above because this would mess up transformed and untransformed Z order. Pass the z position - * unmodified to opengl. - * - * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline - * replacement shader. - */ - TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, 1.0, -1.0); - if (context->render_offscreen) - { - glOrtho(X, X + width, -Y, -Y - height, 0.0, -1.0); - } else { - glOrtho(X, X + width, Y + height, Y, 0.0, -1.0); - } - } + TRACE("Calling glOrtho with x %.8e, y %.8e, w %.8e, h %.8e.\n", x, y, w, h); + if (context->render_offscreen) + glOrtho(x, x + w, -y, -y - h, 0.0, -1.0); + else + glOrtho(x, x + w, y + h, y, 0.0, -1.0); checkGLcall("glOrtho"); /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */ @@ -4167,7 +4126,7 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, GL_EXTCALL(glVertexAttrib4NubvARB(i, ptr)); break; case WINED3DFMT_B8G8R8A8_UNORM: - if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) + if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) { const DWORD *src = (const DWORD *)ptr; DWORD c = *src & 0xff00ff00; @@ -4479,87 +4438,11 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB loadTexCoords(context, stateblock, si, &curVBO); } -static inline void drawPrimitiveTraceDataLocations(const struct wined3d_stream_info *dataLocations) -{ - /* Dump out what parts we have supplied */ - TRACE("Strided Data:\n"); - TRACE_STRIDED((dataLocations), WINED3D_FFP_POSITION); - TRACE_STRIDED((dataLocations), WINED3D_FFP_BLENDWEIGHT); - TRACE_STRIDED((dataLocations), WINED3D_FFP_BLENDINDICES); - TRACE_STRIDED((dataLocations), WINED3D_FFP_NORMAL); - TRACE_STRIDED((dataLocations), WINED3D_FFP_PSIZE); - TRACE_STRIDED((dataLocations), WINED3D_FFP_DIFFUSE); - TRACE_STRIDED((dataLocations), WINED3D_FFP_SPECULAR); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD0); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD1); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD2); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD3); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD4); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD5); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD6); - TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD7); -} - static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) { - const struct wined3d_gl_info *gl_info = context->gl_info; IWineD3DDeviceImpl *device = stateblock->device; - BOOL fixup = FALSE; - struct wined3d_stream_info *dataLocations = &device->strided_streams; - BOOL useVertexShaderFunction; - BOOL load_numbered = FALSE; - BOOL load_named = FALSE; - - useVertexShaderFunction = (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader) ? TRUE : FALSE; - - if(device->up_strided) { - /* Note: this is a ddraw fixed-function code path */ - TRACE("================ Strided Input ===================\n"); - device_stream_info_from_strided(gl_info, device->up_strided, dataLocations); - - if(TRACE_ON(d3d)) { - drawPrimitiveTraceDataLocations(dataLocations); - } - } else { - /* Note: This is a fixed function or shader codepath. - * This means it must handle both types of strided data. - * Shaders must go through here to zero the strided data, even if they - * don't set any declaration at all - */ - TRACE("================ Vertex Declaration ===================\n"); - device_stream_info_from_declaration(device, useVertexShaderFunction, dataLocations, &fixup); - } - - if (dataLocations->position_transformed) useVertexShaderFunction = FALSE; - - if(useVertexShaderFunction) { - if(((IWineD3DVertexDeclarationImpl *) stateblock->vertexDecl)->half_float_conv_needed && !fixup) { - TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion\n"); - device->useDrawStridedSlow = TRUE; - } else { - load_numbered = TRUE; - device->useDrawStridedSlow = FALSE; - } - } - else - { - WORD slow_mask = (1 << WINED3D_FFP_PSIZE); - slow_mask |= -!gl_info->supported[EXT_VERTEX_ARRAY_BGRA] - & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR)); - - if (fixup || (!dataLocations->position_transformed - && !(dataLocations->use_map & slow_mask))) - { - /* Load the vertex data using named arrays */ - load_named = TRUE; - device->useDrawStridedSlow = FALSE; - } - else - { - TRACE("Not loading vertex data\n"); - device->useDrawStridedSlow = TRUE; - } - } + BOOL load_numbered = use_vs(stateblock) && !device->useDrawStridedSlow; + BOOL load_named = !use_vs(stateblock) && !device->useDrawStridedSlow; if (context->numberedArraysLoaded && !load_numbered) { @@ -4576,13 +4459,13 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi if (load_numbered) { TRACE("Loading numbered arrays\n"); - loadNumberedArrays(stateblock, dataLocations, context); + loadNumberedArrays(stateblock, &device->strided_streams, context); context->numberedArraysLoaded = TRUE; } else if (load_named) { TRACE("Loading vertex data\n"); - loadVertexData(context, stateblock, dataLocations); + loadVertexData(context, stateblock, &device->strided_streams); context->namedArraysLoaded = TRUE; } } @@ -5634,8 +5517,7 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = { /* Context activation is done by the caller. */ static void ffp_enable(IWineD3DDevice *iface, BOOL enable) { } -static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, - const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps) +static void ffp_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps) { pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD | WINED3DTEXOPCAPS_ADDSIGNED | @@ -5670,7 +5552,7 @@ static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, if (gl_info->supported[ARB_TEXTURE_ENV_DOT3]) pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_DOTPRODUCT3; - pCaps->MaxTextureBlendStages = gl_info->limits.texture_stages; + pCaps->MaxTextureBlendStages = gl_info->limits.textures; pCaps->MaxSimultaneousTextures = gl_info->limits.textures; } @@ -5725,6 +5607,43 @@ static void multistate_apply_3(DWORD state, IWineD3DStateBlockImpl *stateblock, stateblock->device->multistate_funcs[state][2](state, stateblock, context); } +static void prune_invalid_states(struct StateEntry *state_table, const struct wined3d_gl_info *gl_info) +{ + unsigned int start, last, i; + + start = STATE_TEXTURESTAGE(gl_info->limits.texture_stages, 0); + last = STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE); + for (i = start; i <= last; ++i) + { + state_table[i].representative = 0; + state_table[i].apply = state_undefined; + } + + start = STATE_TRANSFORM(WINED3DTS_TEXTURE0 + gl_info->limits.texture_stages); + last = STATE_TRANSFORM(WINED3DTS_TEXTURE0 + MAX_TEXTURES - 1); + for (i = start; i <= last; ++i) + { + state_table[i].representative = 0; + state_table[i].apply = state_undefined; + } +} + +static void validate_state_table(struct StateEntry *state_table) +{ + unsigned int i; + + for (i = 0; i < STATE_HIGHEST + 1; ++i) + { + DWORD rep = state_table[i].representative; + if (rep && !state_table[rep].representative) + { + ERR("State %s (%#x) has invalid representative %s (%#x).\n", + debug_d3dstate(i), i, debug_d3dstate(rep), rep); + state_table[i].representative = 0; + } + } +} + HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs, const struct wined3d_gl_info *gl_info, const struct StateEntryTemplate *vertex, const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc) @@ -5824,6 +5743,9 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_ } } + prune_invalid_states(StateTable, gl_info); + validate_state_table(StateTable); + return WINED3D_OK; out_of_mem: diff --git a/dll/directx/wine/wined3d/surface.c b/dll/directx/wine/wined3d/surface.c index 8dcc6915bbf..d17d35cc16d 100644 --- a/dll/directx/wine/wined3d/surface.c +++ b/dll/directx/wine/wined3d/surface.c @@ -1253,6 +1253,37 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb) TRACE("Updated target %d\n", This->texture_target); } +/* Context activation is done by the caller. */ +void surface_prepare_texture(IWineD3DSurfaceImpl *surface, BOOL srgb) +{ + DWORD alloc_flag = srgb ? SFLAG_SRGBALLOCATED : SFLAG_ALLOCATED; + GLenum format, internal, type; + GLsizei width, height; + CONVERT_TYPES convert; + int bpp; + + if (surface->Flags & alloc_flag) return; + + d3dfmt_get_conv(surface, TRUE, TRUE, &format, &internal, &type, &convert, &bpp, srgb); + if(convert != NO_CONVERSION) surface->Flags |= SFLAG_CONVERTED; + else surface->Flags &= ~SFLAG_CONVERTED; + + if ((surface->Flags & SFLAG_NONPOW2) && !(surface->Flags & SFLAG_OVERSIZE)) + { + width = surface->pow2Width; + height = surface->pow2Height; + } + else + { + width = surface->glRect.right - surface->glRect.left; + height = surface->glRect.bottom - surface->glRect.top; + } + + surface_bind_and_dirtify(surface, srgb); + surface_allocate_surface(surface, internal, width, height, format, type); + surface->Flags |= alloc_flag; +} + static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This) { IWineD3DDeviceImpl *device = This->resource.device; @@ -1822,7 +1853,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ * in which the main render target uses p8. Some games like GTA Vice City use P8 for texturing which * conflicts with this. */ - if (!(gl_info->supported[EXT_PALETTED_TEXTURE] || (gl_info->supported[ARB_FRAGMENT_PROGRAM] + if (!(gl_info->supported[EXT_PALETTED_TEXTURE] || (device->blitter->color_fixup_supported(This->resource.format_desc->color_fixup) && device->render_targets && This == (IWineD3DSurfaceImpl*)device->render_targets[0])) || colorkey_active || !use_texturing) { @@ -1836,7 +1867,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ *convert = CONVERT_PALETTED; } } - else if (!gl_info->supported[EXT_PALETTED_TEXTURE] && gl_info->supported[ARB_FRAGMENT_PROGRAM]) + else if (!gl_info->supported[EXT_PALETTED_TEXTURE] && device->blitter->color_fixup_supported(This->resource.format_desc->color_fixup)) { *format = GL_ALPHA; *type = GL_UNSIGNED_BYTE; @@ -2553,34 +2584,10 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve * The 8bit pixel data will be used as an index in this palette texture to retrieve the final color. */ TRACE("Using fragment shaders for emulating 8-bit paletted texture support\n"); + device->blitter->set_shader((IWineD3DDevice *) device, This->resource.format_desc, + This->texture_target, This->pow2Width, This->pow2Height); + ENTER_GL(); - - /* Create the fragment program if we don't have it */ - if(!device->paletteConversionShader) - { - const char *fragment_palette_conversion = - "!!ARBfp1.0\n" - "TEMP index;\n" - /* { 255/256, 0.5/255*255/256, 0, 0 } */ - "PARAM constants = { 0.996, 0.00195, 0, 0 };\n" - /* The alpha-component contains the palette index */ - "TEX index, fragment.texcoord[0], texture[0], 2D;\n" - /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */ - "MAD index.a, index.a, constants.x, constants.y;\n" - /* Use the alpha-component as an index in the palette to get the final color */ - "TEX result.color, index.a, texture[1], 1D;\n" - "END"; - - glEnable(GL_FRAGMENT_PROGRAM_ARB); - GL_EXTCALL(glGenProgramsARB(1, &device->paletteConversionShader)); - GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader)); - GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(fragment_palette_conversion), fragment_palette_conversion)); - glDisable(GL_FRAGMENT_PROGRAM_ARB); - } - - glEnable(GL_FRAGMENT_PROGRAM_ARB); - GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader)); - GL_EXTCALL(glActiveTextureARB(GL_TEXTURE1)); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); @@ -2594,7 +2601,6 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve /* Rebind the texture because it isn't bound anymore */ glBindTexture(This->texture_target, This->texture_name); - LEAVE_GL(); } } @@ -2700,7 +2706,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BO static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL srgb) { /* TODO: check for locks */ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; - IWineD3DDeviceImpl *device = This->resource.device; IWineD3DBaseTexture *baseTexture = NULL; TRACE("(%p)Checking to see if the container is a base texture\n", This); @@ -2711,13 +2716,11 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL } else { - struct wined3d_context *context = NULL; GLuint *name; TRACE("(%p) : Binding surface\n", This); name = srgb ? &This->texture_name_srgb : &This->texture_name; - if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); ENTER_GL(); @@ -2751,8 +2754,6 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL checkGLcall("glBindTexture"); LEAVE_GL(); - - if (context) context_release(context); } } @@ -3447,6 +3448,9 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine } LEAVE_GL(); + + wglFlush(); /* Flush to ensure ordering across contexts. */ + context_release(context); /* The texture is now most up to date - If the surface is a render target and has a drawable, this @@ -3921,9 +3925,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const /* Leave the opengl state valid for blitting */ myDevice->blitter->unset_shader((IWineD3DDevice *) myDevice); - /* Flush in case the drawable is used by multiple GL contexts */ - if(dstSwapchain && (This == (IWineD3DSurfaceImpl *) dstSwapchain->frontBuffer || dstSwapchain->num_contexts >= 2)) - wglFlush(); + wglFlush(); /* Flush to ensure ordering across contexts. */ context_release(context); @@ -4552,7 +4554,11 @@ void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *co else context_bind_fbo(context, GL_FRAMEBUFFER, NULL); LEAVE_GL(); - } else { + + wglFlush(); /* Flush to ensure ordering across contexts. */ + } + else + { FIXME("No up to date depth stencil location\n"); } } else if (location == SFLAG_DS_ONSCREEN) { @@ -4569,7 +4575,11 @@ void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *co if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER, &context->current_fbo->id); LEAVE_GL(); - } else { + + wglFlush(); /* Flush to ensure ordering across contexts. */ + } + else + { FIXME("No up to date depth stencil location\n"); } } else { @@ -4656,11 +4666,10 @@ static inline void cube_coords_float(const RECT *r, UINT w, UINT h, struct float static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT *rect_in) { IWineD3DDeviceImpl *device = This->resource.device; + IWineD3DBaseTextureImpl *texture; struct wined3d_context *context; struct coords coords[4]; RECT rect; - IWineD3DSwapChain *swapchain; - IWineD3DBaseTexture *texture; GLenum bind_target; struct float_rect f; @@ -4802,25 +4811,16 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT LEAVE_GL(); - if(SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DSwapChain, (void **) &swapchain))) - { - /* Make sure to flush the buffers. This is needed in apps like Red Alert II and Tiberian SUN that use multiple WGL contexts. */ - if(((IWineD3DSwapChainImpl*)swapchain)->frontBuffer == (IWineD3DSurface*)This || - ((IWineD3DSwapChainImpl*)swapchain)->num_contexts >= 2) - wglFlush(); + wglFlush(); /* Flush to ensure ordering across contexts. */ - IWineD3DSwapChain_Release(swapchain); - } else { - /* We changed the filtering settings on the texture. Inform the container about this to get the filters - * reset properly next draw - */ - if(SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DBaseTexture, (void **) &texture))) - { - ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT; - ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; - ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE; - IWineD3DBaseTexture_Release(texture); - } + /* We changed the filtering settings on the texture. Inform the + * container about this to get the filters reset properly next draw. */ + if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)This, &IID_IWineD3DBaseTexture, (void **)&texture))) + { + texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT; + texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; + texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE; + IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture); } context_release(context); @@ -4977,7 +4977,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D { /* Upload from system memory */ BOOL srgb = flag == SFLAG_INSRGBTEX; - DWORD alloc_flag = srgb ? SFLAG_SRGBALLOCATED : SFLAG_ALLOCATED; struct wined3d_context *context = NULL; d3dfmt_get_conv(This, TRUE /* We need color keying */, TRUE /* We will use textures */, @@ -5004,6 +5003,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D } if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); + + surface_prepare_texture(This, srgb); surface_bind_and_dirtify(This, srgb); if(This->CKeyFlags & WINEDDSD_CKSRCBLT) { @@ -5037,17 +5038,13 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D return WINED3DERR_OUTOFVIDEOMEMORY; } d3dfmt_convert_surface(This->resource.allocatedMemory, mem, pitch, width, height, outpitch, convert, This); - - This->Flags |= SFLAG_CONVERTED; } else if (This->resource.format_desc->format == WINED3DFMT_P8_UINT - && (gl_info->supported[EXT_PALETTED_TEXTURE] || gl_info->supported[ARB_FRAGMENT_PROGRAM])) + && (gl_info->supported[EXT_PALETTED_TEXTURE] || device->blitter->color_fixup_supported(This->resource.format_desc->color_fixup))) { d3dfmt_p8_upload_palette(iface, convert); - This->Flags &= ~SFLAG_CONVERTED; mem = This->resource.allocatedMemory; } else { - This->Flags &= ~SFLAG_CONVERTED; mem = This->resource.allocatedMemory; } @@ -5058,10 +5055,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D if ((This->Flags & SFLAG_NONPOW2) && !(This->Flags & SFLAG_OVERSIZE)) { TRACE("non power of two support\n"); - if(!(This->Flags & alloc_flag)) { - surface_allocate_surface(This, internal, This->pow2Width, This->pow2Height, format, type); - This->Flags |= alloc_flag; - } if (mem || (This->Flags & SFLAG_PBO)) { surface_upload_data(This, internal, This->currentDesc.Width, This->currentDesc.Height, format, type, mem); } @@ -5069,10 +5062,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D /* When making the realloc conditional, keep in mind that GL_APPLE_client_storage may be in use, and This->resource.allocatedMemory * changed. So also keep track of memory changes. In this case the texture has to be reallocated */ - if(!(This->Flags & alloc_flag)) { - surface_allocate_surface(This, internal, This->glRect.right - This->glRect.left, This->glRect.bottom - This->glRect.top, format, type); - This->Flags |= alloc_flag; - } if (mem || (This->Flags & SFLAG_PBO)) { surface_upload_data(This, internal, This->glRect.right - This->glRect.left, This->glRect.bottom - This->glRect.top, format, type, mem); } diff --git a/dll/directx/wine/wined3d/swapchain.c b/dll/directx/wine/wined3d/swapchain.c index 6493704014b..cbdb961f705 100644 --- a/dll/directx/wine/wined3d/swapchain.c +++ b/dll/directx/wine/wined3d/swapchain.c @@ -217,6 +217,8 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO unsigned int sync; int retval; + IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride); + context = context_acquire(This->device, This->backBuffer[0], CTXUSAGE_RESOURCELOAD); /* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */ @@ -272,12 +274,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO IWineD3DSurface_BltFast(This->backBuffer[0], 0, 0, This->device->logo_surface, NULL, WINEDDBLTFAST_SRCCOLORKEY); } - TRACE("presetting HDC %p\n", This->context[0]->hdc); - - /* Don't call checkGLcall, as glGetError is not applicable here */ - if (hDestWindowOverride && This->win_handle != hDestWindowOverride) { - IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride); - } + TRACE("Presenting HDC %p.\n", context->hdc); render_to_fbo = This->render_to_fbo; @@ -343,7 +340,8 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO swapchain_blit(This, context, &src_rect, &dst_rect); } - SwapBuffers(This->context[0]->hdc); /* TODO: cycle through the swapchain buffers */ + if (This->num_contexts > 1) wglFinish(); + SwapBuffers(context->hdc); /* TODO: cycle through the swapchain buffers */ TRACE("SwapBuffers called, Starting new frame\n"); /* FPS support */ @@ -521,7 +519,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_SetDestWindowOverride(IWineD3DSwapCh WINED3DLOCKED_RECT r; BYTE *mem; - if(window == This->win_handle) return WINED3D_OK; + if (!window || window == This->win_handle) return WINED3D_OK; TRACE("Performing dest override of swapchain %p from window %p to %p\n", This, This->win_handle, window); if (This->context[0] == This->device->contexts[0]) @@ -913,10 +911,15 @@ err: HeapFree(GetProcessHeap(), 0, swapchain->backBuffer); } - if (swapchain->context && swapchain->context[0]) + if (swapchain->context) { - context_release(swapchain->context[0]); - context_destroy(device, swapchain->context[0]); + if (swapchain->context[0]) + { + context_release(swapchain->context[0]); + context_destroy(device, swapchain->context[0]); + swapchain->num_contexts = 0; + } + HeapFree(GetProcessHeap(), 0, swapchain->context); } if (swapchain->frontBuffer) IWineD3DSurface_Release(swapchain->frontBuffer); diff --git a/dll/directx/wine/wined3d/utils.c b/dll/directx/wine/wined3d/utils.c index c1e921da976..2ff16752c33 100644 --- a/dll/directx/wine/wined3d/utils.c +++ b/dll/directx/wine/wined3d/utils.c @@ -387,7 +387,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, - {WINED3DFMT_R16G16_UNORM, GL_RGB16_EXT, GL_RGB16_EXT, GL_RGBA16_EXT, + {WINED3DFMT_R16G16_UNORM, GL_RGB16, GL_RGB16, GL_RGBA16, GL_RGB, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, @@ -395,7 +395,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = { GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, - {WINED3DFMT_R16G16B16A16_UNORM, GL_RGBA16_EXT, GL_RGBA16_EXT, 0, + {WINED3DFMT_R16G16B16A16_UNORM, GL_RGBA16, GL_RGBA16, 0, GL_RGBA, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET, WINED3D_GL_EXT_NONE}, @@ -445,7 +445,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = { GL_RGBA, GL_BYTE, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, NV_TEXTURE_SHADER}, - {WINED3DFMT_R16G16_SNORM, GL_RGB16_EXT, GL_RGB16_EXT, 0, + {WINED3DFMT_R16G16_SNORM, GL_RGB16, GL_RGB16, 0, GL_BGR, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, @@ -506,7 +506,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = { GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH, ARB_DEPTH_TEXTURE}, - {WINED3DFMT_L16_UNORM, GL_LUMINANCE16_EXT, GL_LUMINANCE16_EXT, 0, + {WINED3DFMT_L16_UNORM, GL_LUMINANCE16, GL_LUMINANCE16, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE}, @@ -950,7 +950,7 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3 if(wined3d_settings.offscreen_rendering_mode != ORM_FBO) { WARN("No FBO support, or no FBO ORM, guessing filter info from GL caps\n"); - if (vendor == VENDOR_NVIDIA && gl_info->supported[ARB_TEXTURE_FLOAT]) + if (vendor == HW_VENDOR_NVIDIA && gl_info->supported[ARB_TEXTURE_FLOAT]) { TRACE("Nvidia card with texture_float support: Assuming float16 blending\n"); filtered = TRUE; @@ -1088,17 +1088,20 @@ static void apply_format_fixups(struct wined3d_gl_info *gl_info) if (!gl_info->supported[APPLE_YCBCR_422]) { idx = getFmtIdx(WINED3DFMT_YUY2); - gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YUY2); + gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2); idx = getFmtIdx(WINED3DFMT_UYVY); - gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_UYVY); + gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY); } idx = getFmtIdx(WINED3DFMT_YV12); gl_info->gl_formats[idx].heightscale = 1.5f; - gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YV12); + gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12); - if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) + idx = getFmtIdx(WINED3DFMT_P8_UINT); + gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8); + + if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) { idx = getFmtIdx(WINED3DFMT_B8G8R8A8_UNORM); gl_info->gl_formats[idx].gl_vtx_format = GL_BGRA; @@ -1786,6 +1789,51 @@ const char* debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype) { } } +const char *debug_d3dstate(DWORD state) +{ + if (STATE_IS_RENDER(state)) + return wine_dbg_sprintf("STATE_RENDER(%s)", debug_d3drenderstate(state - STATE_RENDER(0))); + if (STATE_IS_TEXTURESTAGE(state)) + { + DWORD texture_stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); + DWORD texture_state = state - STATE_TEXTURESTAGE(texture_stage, 0); + return wine_dbg_sprintf("STATE_TEXTURESTAGE(%#x, %s)", + texture_stage, debug_d3dtexturestate(texture_state)); + } + if (STATE_IS_SAMPLER(state)) + return wine_dbg_sprintf("STATE_SAMPLER(%#x)", state - STATE_SAMPLER(0)); + if (STATE_IS_PIXELSHADER(state)) + return "STATE_PIXELSHADER"; + if (STATE_IS_TRANSFORM(state)) + return wine_dbg_sprintf("STATE_TRANSFORM(%s)", debug_d3dtstype(state - STATE_TRANSFORM(0))); + if (STATE_IS_STREAMSRC(state)) + return "STATE_STREAMSRC"; + if (STATE_IS_INDEXBUFFER(state)) + return "STATE_INDEXBUFFER"; + if (STATE_IS_VDECL(state)) + return "STATE_VDECL"; + if (STATE_IS_VSHADER(state)) + return "STATE_VSHADER"; + if (STATE_IS_VIEWPORT(state)) + return "STATE_VIEWPORT"; + if (STATE_IS_VERTEXSHADERCONSTANT(state)) + return "STATE_VERTEXSHADERCONSTANT"; + if (STATE_IS_PIXELSHADERCONSTANT(state)) + return "STATE_PIXELSHADERCONSTANT"; + if (STATE_IS_ACTIVELIGHT(state)) + return wine_dbg_sprintf("STATE_ACTIVELIGHT(%#x)", state - STATE_ACTIVELIGHT(0)); + if (STATE_IS_SCISSORRECT(state)) + return "STATE_SCISSORRECT"; + if (STATE_IS_CLIPPLANE(state)) + return wine_dbg_sprintf("STATE_CLIPPLANE(%#x)", state - STATE_CLIPPLANE(0)); + if (STATE_IS_MATERIAL(state)) + return "STATE_MATERIAL"; + if (STATE_IS_FRONTFACE(state)) + return "STATE_FRONTFACE"; + + return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state); +} + const char* debug_d3dpool(WINED3DPOOL Pool) { switch (Pool) { #define POOL_TO_STR(p) case p: return #p @@ -1868,8 +1916,8 @@ static const char *debug_fixup_channel_source(enum fixup_channel_source source) WINED3D_TO_STR(CHANNEL_SOURCE_Y); WINED3D_TO_STR(CHANNEL_SOURCE_Z); WINED3D_TO_STR(CHANNEL_SOURCE_W); - WINED3D_TO_STR(CHANNEL_SOURCE_YUV0); - WINED3D_TO_STR(CHANNEL_SOURCE_YUV1); + WINED3D_TO_STR(CHANNEL_SOURCE_COMPLEX0); + WINED3D_TO_STR(CHANNEL_SOURCE_COMPLEX1); #undef WINED3D_TO_STR default: FIXME("Unrecognized fixup_channel_source %#x\n", source); @@ -1877,26 +1925,27 @@ static const char *debug_fixup_channel_source(enum fixup_channel_source source) } } -static const char *debug_yuv_fixup(enum yuv_fixup yuv_fixup) +static const char *debug_complex_fixup(enum complex_fixup fixup) { - switch(yuv_fixup) + switch(fixup) { #define WINED3D_TO_STR(x) case x: return #x - WINED3D_TO_STR(YUV_FIXUP_YUY2); - WINED3D_TO_STR(YUV_FIXUP_UYVY); - WINED3D_TO_STR(YUV_FIXUP_YV12); + WINED3D_TO_STR(COMPLEX_FIXUP_YUY2); + WINED3D_TO_STR(COMPLEX_FIXUP_UYVY); + WINED3D_TO_STR(COMPLEX_FIXUP_YV12); + WINED3D_TO_STR(COMPLEX_FIXUP_P8); #undef WINED3D_TO_STR default: - FIXME("Unrecognized YUV fixup %#x\n", yuv_fixup); + FIXME("Unrecognized complex fixup %#x\n", fixup); return "unrecognized"; } } void dump_color_fixup_desc(struct color_fixup_desc fixup) { - if (is_yuv_fixup(fixup)) + if (is_complex_fixup(fixup)) { - TRACE("\tYUV: %s\n", debug_yuv_fixup(get_yuv_fixup(fixup))); + TRACE("\tComplex: %s\n", debug_complex_fixup(get_complex_fixup(fixup))); return; } @@ -2795,40 +2844,3 @@ void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, else if (gl_info->supported[ATI_FRAGMENT_SHADER]) *ps_selected = SHADER_ATI; else *ps_selected = SHADER_NONE; } - -const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, WINED3DDEVTYPE device_type) -{ - int vs_selected_mode, ps_selected_mode; - - select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode); - if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend; - if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend; - return &none_shader_backend; -} - -const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter, - WINED3DDEVTYPE device_type) -{ - const struct wined3d_gl_info *gl_info = &adapter->gl_info; - int vs_selected_mode, ps_selected_mode; - - select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode); - if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) - && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_fragment_pipeline; - else if (ps_selected_mode == SHADER_ATI) return &atifs_fragment_pipeline; - else if (gl_info->supported[NV_REGISTER_COMBINERS] - && gl_info->supported[NV_TEXTURE_SHADER2]) return &nvts_fragment_pipeline; - else if (gl_info->supported[NV_REGISTER_COMBINERS]) return &nvrc_fragment_pipeline; - else return &ffp_fragment_pipeline; -} - -const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, WINED3DDEVTYPE device_type) -{ - const struct wined3d_gl_info *gl_info = &adapter->gl_info; - int vs_selected_mode, ps_selected_mode; - - select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode); - if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) - && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit; - else return &ffp_blit; -} diff --git a/dll/directx/wine/wined3d/wined3d.rbuild b/dll/directx/wine/wined3d/wined3d.rbuild index 7262e66e4b5..5a42ff6064a 100644 --- a/dll/directx/wine/wined3d/wined3d.rbuild +++ b/dll/directx/wine/wined3d/wined3d.rbuild @@ -16,7 +16,6 @@ ati_fragment_shader.c arb_program_shader.c - baseshader.c basetexture.c buffer.c clipper.c diff --git a/dll/directx/wine/wined3d/wined3d_gl.h b/dll/directx/wine/wined3d/wined3d_gl.h index d6d9794933f..f8097d65cb9 100644 --- a/dll/directx/wine/wined3d/wined3d_gl.h +++ b/dll/directx/wine/wined3d/wined3d_gl.h @@ -75,6 +75,9 @@ typedef double GLclampd; typedef void GLvoid; typedef ptrdiff_t GLintptr; typedef ptrdiff_t GLsizeiptr; +typedef INT64 GLint64; +typedef UINT64 GLuint64; +typedef struct __GLsync *GLsync; /* Booleans */ #define GL_FALSE 0x0 @@ -804,6 +807,197 @@ typedef ptrdiff_t GLsizeiptr; #define GL_SAMPLE_COVERAGE_INVERT 0x80AB #define GL_MULTISAMPLE_BIT 0x20000000 +/* GL_VERSION_2_0 */ +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882a +#define GL_DRAW_BUFFER6 0x882b +#define GL_DRAW_BUFFER7 0x882c +#define GL_DRAW_BUFFER8 0x882d +#define GL_DRAW_BUFFER9 0x882e +#define GL_DRAW_BUFFER10 0x882f +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883d +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886a +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8b30 +#define GL_VERTEX_SHADER 0x8b31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8b49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8b4a +#define GL_MAX_VARYING_FLOATS 0x8b4b +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8b4c +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8b4d +#define GL_SHADER_TYPE 0x8b4f +#define GL_FLOAT_VEC2 0x8b50 +#define GL_FLOAT_VEC3 0x8b51 +#define GL_FLOAT_VEC4 0x8b52 +#define GL_INT_VEC2 0x8b53 +#define GL_INT_VEC3 0x8b54 +#define GL_INT_VEC4 0x8b55 +#define GL_BOOL 0x8b56 +#define GL_BOOL_VEC2 0x8b57 +#define GL_BOOL_VEC3 0x8b58 +#define GL_BOOL_VEC4 0x8b59 +#define GL_FLOAT_MAT2 0x8b5a +#define GL_FLOAT_MAT3 0x8b5b +#define GL_FLOAT_MAT4 0x8b5c +#define GL_SAMPLER_1D 0x8b5d +#define GL_SAMPLER_2D 0x8b5e +#define GL_SAMPLER_3D 0x8b5f +#define GL_SAMPLER_CUBE 0x8b60 +#define GL_SAMPLER_1D_SHADOW 0x8b61 +#define GL_SAMPLER_2D_SHADOW 0x8b62 +#define GL_DELETE_STATUS 0x8b80 +#define GL_COMPILE_STATUS 0x8b81 +#define GL_LINK_STATUS 0x8b82 +#define GL_VALIDATE_STATUS 0x8b83 +#define GL_INFO_LOG_LENGTH 0x8b84 +#define GL_ATTACHED_SHADERS 0x8b85 +#define GL_ACTIVE_UNIFORMS 0x8b86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8b87 +#define GL_SHADER_SOURCE_LENGTH 0x8b88 +#define GL_ACTIVE_ATTRIBUTES 0x8b89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8b8a +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8b8b +#define GL_SHADING_LANGUAGE_VERSION 0x8b8c +#define GL_CURRENT_PROGRAM 0x8b8d +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8ca0 +#define GL_LOWER_LEFT 0x8ca1 +#define GL_UPPER_LEFT 0x8ca2 +#define GL_STENCIL_BACK_REF 0x8ca3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8ca4 +#define GL_STENCIL_BACK_WRITEMASK 0x8ca5 +typedef char GLchar; +#endif +typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha); +typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSPROC)(GLsizei n, const GLenum *bufs); +typedef void (WINE_GLAPI *PGLFNSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (WINE_GLAPI *PGLFNSTENCILFUNCSEPARATEPROC)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (WINE_GLAPI *PGLFNSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); +typedef void (WINE_GLAPI *PGLFNATTACHSHADERPROC)(GLuint program, GLuint shader); +typedef void (WINE_GLAPI *PGLFNBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar *name); +typedef void (WINE_GLAPI *PGLFNCOMPILESHADERPROC)(GLuint shader); +typedef GLuint (WINE_GLAPI *PGLFNCREATEPROGRAMPROC)(void); +typedef GLuint (WINE_GLAPI *PGLFNCREATESHADERPROC)(GLenum type); +typedef void (WINE_GLAPI *PGLFNDELETEPROGRAMPROC)(GLuint program); +typedef void (WINE_GLAPI *PGLFNDELETESHADERPROC)(GLuint shader); +typedef void (WINE_GLAPI *PGLFNDETACHSHADERPROC)(GLuint program, GLuint shader); +typedef void (WINE_GLAPI *PGLFNDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void (WINE_GLAPI *PGLFNENABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void (WINE_GLAPI *PGLFNGETACTIVEATTRIBPROC)(GLuint program, + GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (WINE_GLAPI *PGLFNGETACTIVEUNIFORMPROC)(GLuint program, + GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (WINE_GLAPI *PGLFNGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (WINE_GLAPI *PGLFNGETATTRIBLOCATIONPROC)(GLuint program, const GLchar *name); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMINFOLOGPROC)(GLuint program, + GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (WINE_GLAPI *PGLFNGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (WINE_GLAPI *PGLFNGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (WINE_GLAPI *PGLFNGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar *name); +typedef void (WINE_GLAPI *PGLFNGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETUNIFORMIVPROC)(GLuint program, GLint location, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (WINE_GLAPI *PGLFNISPROGRAMPROC)(GLuint program); +typedef GLboolean (WINE_GLAPI *PGLFNISSHADERPROC)(GLuint shader); +typedef void (WINE_GLAPI *PGLFNLINKPROGRAMPROC)(GLuint program); +typedef void (WINE_GLAPI *PGLFNSHADERSOURCEPROC)(GLuint shader, + GLsizei count, const GLchar* *string, const GLint *length); +typedef void (WINE_GLAPI *PGLFNUSEPROGRAMPROC)(GLuint program); +typedef void (WINE_GLAPI *PGLFNUNIFORM1FPROC)(GLint location, GLfloat v0); +typedef void (WINE_GLAPI *PGLFNUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1); +typedef void (WINE_GLAPI *PGLFNUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (WINE_GLAPI *PGLFNUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (WINE_GLAPI *PGLFNUNIFORM1IPROC)(GLint location, GLint v0); +typedef void (WINE_GLAPI *PGLFNUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); +typedef void (WINE_GLAPI *PGLFNUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2); +typedef void (WINE_GLAPI *PGLFNUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (WINE_GLAPI *PGLFNUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *PGLFNUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *PGLFNUNIFORMMATRIX2FVPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORMMATRIX3FVPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNUNIFORMMATRIX4FVPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *PGLFNVALIDATEPROGRAMPROC)(GLuint program); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DPROC)(GLuint index, GLdouble x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SPROC)(GLuint index, GLshort x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NIVPROC)(GLuint index, const GLint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4IVPROC)(GLuint index, const GLint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SVPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4USVPROC)(GLuint index, const GLushort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBPOINTERPROC)(GLuint index, + GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); + void (WINE_GLAPI *glAccum)(GLenum op, GLfloat value) DECLSPEC_HIDDEN; void (WINE_GLAPI *glAlphaFunc)(GLenum func, GLclampf ref) DECLSPEC_HIDDEN; GLboolean (WINE_GLAPI *glAreTexturesResident)(GLsizei n, const GLuint *textures, GLboolean *residences) DECLSPEC_HIDDEN; @@ -1524,68 +1718,273 @@ BOOL (WINAPI *pwglShareLists)(HGLRC, HGLRC) DECLSPEC_HIDDEN; USE_WGL_FUNC(wglMakeCurrent) \ USE_WGL_FUNC(wglShareLists) +/* OpenGL extensions. */ +typedef enum wined3d_gl_extension +{ + WINED3D_GL_EXT_NONE, -/**************************************************** - * OpenGL Extensions (EXT and ARB) - * #defines and functions pointer - ****************************************************/ + /* APPLE */ + APPLE_CLIENT_STORAGE, + APPLE_FENCE, + APPLE_FLOAT_PIXELS, + APPLE_FLUSH_BUFFER_RANGE, + APPLE_FLUSH_RENDER, + APPLE_YCBCR_422, + /* ARB */ + ARB_COLOR_BUFFER_FLOAT, + ARB_DEPTH_BUFFER_FLOAT, + ARB_DEPTH_CLAMP, + ARB_DEPTH_TEXTURE, + ARB_DRAW_BUFFERS, + ARB_FRAGMENT_PROGRAM, + ARB_FRAGMENT_SHADER, + ARB_FRAMEBUFFER_OBJECT, + ARB_GEOMETRY_SHADER4, + ARB_HALF_FLOAT_PIXEL, + ARB_HALF_FLOAT_VERTEX, + ARB_IMAGING, + ARB_MAP_BUFFER_RANGE, + ARB_MULTISAMPLE, + ARB_MULTITEXTURE, + ARB_OCCLUSION_QUERY, + ARB_PIXEL_BUFFER_OBJECT, + ARB_POINT_PARAMETERS, + ARB_POINT_SPRITE, + ARB_PROVOKING_VERTEX, + ARB_SHADER_OBJECTS, + ARB_SHADER_TEXTURE_LOD, + ARB_SHADING_LANGUAGE_100, + ARB_SYNC, + ARB_TEXTURE_BORDER_CLAMP, + ARB_TEXTURE_COMPRESSION, + ARB_TEXTURE_CUBE_MAP, + ARB_TEXTURE_ENV_ADD, + ARB_TEXTURE_ENV_COMBINE, + ARB_TEXTURE_ENV_DOT3, + ARB_TEXTURE_FLOAT, + ARB_TEXTURE_MIRRORED_REPEAT, + ARB_TEXTURE_NON_POWER_OF_TWO, + ARB_TEXTURE_RECTANGLE, + ARB_TEXTURE_RG, + ARB_VERTEX_ARRAY_BGRA, + ARB_VERTEX_BLEND, + ARB_VERTEX_BUFFER_OBJECT, + ARB_VERTEX_PROGRAM, + ARB_VERTEX_SHADER, + /* ATI */ + ATI_FRAGMENT_SHADER, + ATI_SEPARATE_STENCIL, + ATI_TEXTURE_COMPRESSION_3DC, + ATI_TEXTURE_ENV_COMBINE3, + ATI_TEXTURE_MIRROR_ONCE, + /* EXT */ + EXT_BLEND_COLOR, + EXT_BLEND_EQUATION_SEPARATE, + EXT_BLEND_FUNC_SEPARATE, + EXT_BLEND_MINMAX, + EXT_FOG_COORD, + EXT_FRAMEBUFFER_BLIT, + EXT_FRAMEBUFFER_MULTISAMPLE, + EXT_FRAMEBUFFER_OBJECT, + EXT_GPU_PROGRAM_PARAMETERS, + EXT_GPU_SHADER4, + EXT_PACKED_DEPTH_STENCIL, + EXT_PALETTED_TEXTURE, + EXT_POINT_PARAMETERS, + EXT_PROVOKING_VERTEX, + EXT_SECONDARY_COLOR, + EXT_STENCIL_TWO_SIDE, + EXT_STENCIL_WRAP, + EXT_TEXTURE3D, + EXT_TEXTURE_COMPRESSION_RGTC, + EXT_TEXTURE_COMPRESSION_S3TC, + EXT_TEXTURE_ENV_ADD, + EXT_TEXTURE_ENV_COMBINE, + EXT_TEXTURE_ENV_DOT3, + EXT_TEXTURE_FILTER_ANISOTROPIC, + EXT_TEXTURE_LOD_BIAS, + EXT_TEXTURE_SRGB, + EXT_VERTEX_ARRAY_BGRA, + /* NVIDIA */ + NV_DEPTH_CLAMP, + NV_FENCE, + NV_FOG_DISTANCE, + NV_FRAGMENT_PROGRAM, + NV_FRAGMENT_PROGRAM2, + NV_FRAGMENT_PROGRAM_OPTION, + NV_HALF_FLOAT, + NV_LIGHT_MAX_EXPONENT, + NV_REGISTER_COMBINERS, + NV_REGISTER_COMBINERS2, + NV_TEXGEN_REFLECTION, + NV_TEXTURE_ENV_COMBINE4, + NV_TEXTURE_SHADER, + NV_TEXTURE_SHADER2, + NV_VERTEX_PROGRAM, + NV_VERTEX_PROGRAM1_1, + NV_VERTEX_PROGRAM2, + NV_VERTEX_PROGRAM2_OPTION, + NV_VERTEX_PROGRAM3, + /* SGI */ + SGIS_GENERATE_MIPMAP, + SGI_VIDEO_SYNC, + /* WGL extensions */ + WGL_ARB_PBUFFER, + WGL_ARB_PIXEL_FORMAT, + WGL_WINE_PIXEL_FORMAT_PASSTHROUGH, + /* Internally used */ + WINE_NORMALIZED_TEXRECT, + + WINED3D_GL_EXT_COUNT, +} GL_SupportedExt; + +/* GL_APPLE_client_storage */ +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85b2 +#endif + +/* GL_APPLE_fence */ +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8a0a +#define GL_FENCE_APPLE 0x8a0b +#endif +typedef void (WINE_GLAPI *PGLFNGENFENCESAPPLEPROC)(GLsizei, GLuint *); +typedef void (WINE_GLAPI *PGLFNDELETEFENCESAPPLEPROC)(GLuint, const GLuint *); +typedef void (WINE_GLAPI *PGLFNSETFENCEAPPLEPROC)(GLuint); +typedef GLboolean (WINE_GLAPI *PGLFNTESTFENCEAPPLEPROC)(GLuint); +typedef void (WINE_GLAPI *PGLFNFINISHFENCEAPPLEPROC)(GLuint); +typedef GLboolean (WINE_GLAPI *PGLFNISFENCEAPPLEPROC)(GLuint); +typedef GLboolean (WINE_GLAPI *PGLFNTESTOBJECTAPPLEPROC)(GLenum, GLuint); +typedef void (WINE_GLAPI *PGLFNFINISHOBJECTAPPLEPROC)(GLenum, GLuint); + +/* GL_APPLE_float_pixels */ +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140b +#define GL_COLOR_FLOAT_APPLE 0x8a0f +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881a +#define GL_RGB_FLOAT16_APPLE 0x881b +#define GL_ALPHA_FLOAT16_APPLE 0x881c +#define GL_INTENSITY_FLOAT16_APPLE 0x881d +#define GL_LUMINANCE_FLOAT16_APPLE 0x881e +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881f +#endif + +/* GL_APPLE_flush_buffer_range */ +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8a12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8a13 +typedef void (WINE_GLAPI *PGLFNBUFFERPARAMETERIAPPLE)(GLenum target, GLenum pname, GLint param); +typedef void (WINE_GLAPI *PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE)(GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +/* GL_APPLE_flush_render */ +typedef void (WINE_GLAPI *PGLFNFLUSHRENDERAPPLEPROC)(void); +typedef void (WINE_GLAPI *PGLFNFINISHRENDERAPPLEPROC)(void); + +/* GL_APPLE_ycbcr_422 */ +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85b9 +#define UNSIGNED_SHORT_8_8_APPLE 0x85ba +#define UNSIGNED_SHORT_8_8_REV_APPLE 0x85bb +#endif /* GL_ARB_color_buffer_float */ #ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891a +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891b +#define GL_CLAMP_READ_COLOR_ARB 0x891c +#define GL_FIXED_ONLY_ARB 0x891d #endif -typedef void (WINE_GLAPI *PGLFNCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +typedef void (WINE_GLAPI *PGLFNCLAMPCOLORARBPROC)(GLenum target, GLenum clamp); /* GL_ARB_depth_buffer_float */ #ifndef GL_ARB_depth_buffer_float #define GL_ARB_depth_buffer_float 1 -#define GL_DEPTH_COMPONENT32F 0x8cac -#define GL_DEPTH32F_STENCIL8 0x8cad -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8dad +#define GL_DEPTH_COMPONENT32F 0x8cac +#define GL_DEPTH32F_STENCIL8 0x8cad +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8dad #endif /* GL_ARB_depth_clamp */ #ifndef GL_ARB_depth_clamp #define GL_ARB_depth_clamp 1 -#define GL_DEPTH_CLAMP 0x864f +#define GL_DEPTH_CLAMP 0x864f #endif /* GL_ARB_depth_texture */ #ifndef GL_ARB_depth_texture #define GL_ARB_depth_texture 1 -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#define GL_DEPTH_COMPONENT16_ARB 0x81a5 +#define GL_DEPTH_COMPONENT24_ARB 0x81a6 +#define GL_DEPTH_COMPONENT32_ARB 0x81a7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884a +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884b #endif /* GL_ARB_draw_buffers */ #ifndef GL_ARB_draw_buffers #define GL_ARB_draw_buffers 1 -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882a +#define GL_DRAW_BUFFER6_ARB 0x882b +#define GL_DRAW_BUFFER7_ARB 0x882c +#define GL_DRAW_BUFFER8_ARB 0x882d +#define GL_DRAW_BUFFER9_ARB 0x882e +#define GL_DRAW_BUFFER10_ARB 0x882f +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif +typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC)(GLsizei n, const GLenum *bufs); + +/* GL_ARB_fragment_program */ +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880a +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880b +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880c +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880d +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880e +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880f +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +/* GL_ARB_fragment_shader */ +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8b30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8b49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8b8b #endif -typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); /* GL_ARB_framebuffer_object */ #ifndef GL_ARB_framebuffer_object @@ -1665,58 +2064,59 @@ typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *buf #define GL_DEPTH24_STENCIL8 0x88f0 #define GL_TEXTURE_STENCIL_SIZE 0x88f1 #endif -typedef GLboolean (WINE_GLAPI * PGLFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers); -typedef void (WINE_GLAPI * PGLFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers); -typedef void (WINE_GLAPI * PGLFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, +typedef GLboolean (WINE_GLAPI *PGLFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers); +typedef void (WINE_GLAPI *PGLFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers); +typedef void (WINE_GLAPI *PGLFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (WINE_GLAPI * PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, +typedef void (WINE_GLAPI *PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (WINE_GLAPI * PGLFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); -typedef GLboolean (WINE_GLAPI * PGLFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); -typedef void (WINE_GLAPI * PGLFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); -typedef void (WINE_GLAPI * PGLFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers); -typedef void (WINE_GLAPI * PGLFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers); -typedef GLenum (WINE_GLAPI * PGLFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef GLboolean (WINE_GLAPI *PGLFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); +typedef void (WINE_GLAPI *PGLFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); +typedef void (WINE_GLAPI *PGLFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers); +typedef void (WINE_GLAPI *PGLFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers); +typedef GLenum (WINE_GLAPI *PGLFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, +typedef void (WINE_GLAPI *PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, +typedef void (WINE_GLAPI *PGLFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (WINE_GLAPI * PGLFNGLGENERATEMIPMAPPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGLGENERATEMIPMAPPROC)(GLenum target); /* GL_ARB_geometry_shader4 */ #ifndef GL_ARB_geometry_shader4 -#define GL_GEOMETRY_SHADER_ARB 0x8dd9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8dda -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8ddb -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8ddc -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8c29 -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8ddd -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8dde -#define GL_MAX_VARYING_COMPONENTS_ARB 0x8b4b -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8ddf -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8de0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8de1 -#define GL_LINES_ADJACENCY_ARB 0x000a -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000b -#define GL_TRIANGLES_ADJACENCY_ARB 0x000c -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000d -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8da8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8da9 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8da7 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8cd4 -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_ARB_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_ARB 0x8dd9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8dda +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8ddb +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8ddc +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8c29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8ddd +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8dde +#define GL_MAX_VARYING_COMPONENTS_ARB 0x8b4b +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8ddf +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8de0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8de1 +#define GL_LINES_ADJACENCY_ARB 0x000a +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000b +#define GL_TRIANGLES_ADJACENCY_ARB 0x000c +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000d +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8da8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8da9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8da7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8cd4 +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 #endif typedef void (WINE_GLAPI *PGLFNPROGRAMPARAMETERIARBPROC)(GLuint program, GLenum pname, GLint value); typedef void (WINE_GLAPI *PGLFNFRAMEBUFFERTEXTUREARBPROC)(GLenum target, GLenum attachment, @@ -1726,380 +2126,1067 @@ typedef void (WINE_GLAPI *PGLFNFRAMEBUFFERTEXTURELAYERARBPROC)(GLenum target, GL typedef void (WINE_GLAPI *PGLFNFRAMEBUFFERTEXTUREFACEARBPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +/* GL_ARB_half_float_pixel */ +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#define GL_HALF_FLOAT_ARB 0x140b +#endif + +/* GL_ARB_half_float_vertex */ +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +/* No _ARB, see extension spec */ +#define GL_HALF_FLOAT 0x140b +#endif + /* GL_ARB_imaging */ #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800a +#define GL_FUNC_REVERSE_SUBTRACT 0x800b +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801a +#define GL_MAX_CONVOLUTION_HEIGHT 0x801b +#define GL_POST_CONVOLUTION_RED_SCALE 0x801d +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801f +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801e +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801f +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802a +#define GL_HISTOGRAM_ALPHA_SIZE 0x802b +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802c +#define GL_HISTOGRAM_SINK 0x802d +#define GL_MINMAX 0x802e +#define GL_MINMAX_FORMAT 0x802f +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80b1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80b2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80b3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80b4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80b5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80b6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80b7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80b8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80b9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80ba +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80bb +#define GL_COLOR_TABLE 0x80d0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80d1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80d2 +#define GL_PROXY_COLOR_TABLE 0x80d3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80d4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80d5 +#define GL_COLOR_TABLE_SCALE 0x80d6 +#define GL_COLOR_TABLE_BIAS 0x80d7 +#define GL_COLOR_TABLE_FORMAT 0x80d8 +#define GL_COLOR_TABLE_WIDTH 0x80d9 +#define GL_COLOR_TABLE_RED_SIZE 0x80da +#define GL_COLOR_TABLE_GREEN_SIZE 0x80db +#define GL_COLOR_TABLE_BLUE_SIZE 0x80dc +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80dd +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80de +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80df +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 #endif -typedef void (WINE_GLAPI *PGLFNBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONPROC) (GLenum mode); +typedef void (WINE_GLAPI *PGLFNBLENDCOLORPROC)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONPROC)(GLenum mode); + +/* GL_ARB_map_buffer_range */ +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif +typedef GLvoid *(WINE_GLAPI *PGLFNMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (WINE_GLAPI *PGLFNFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length); + +/* GL_ARB_multisample */ +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809d +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809e +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809f +#define GL_SAMPLE_COVERAGE_ARB 0x80a0 +#define GL_SAMPLE_BUFFERS_ARB 0x80a8 +#define GL_SAMPLES_ARB 0x80a9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80aa +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80ab +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif +typedef void (WINE_GLAPI *WINED3D_PFNGLSAMPLECOVERAGEARBPROC)(GLclampf value, GLboolean invert); + /* GL_ARB_multitexture */ #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#define GL_TEXTURE0_ARB 0x84c0 +#define GL_TEXTURE1_ARB 0x84c1 +#define GL_TEXTURE2_ARB 0x84c2 +#define GL_TEXTURE3_ARB 0x84c3 +#define GL_TEXTURE4_ARB 0x84c4 +#define GL_TEXTURE5_ARB 0x84c5 +#define GL_TEXTURE6_ARB 0x84c6 +#define GL_TEXTURE7_ARB 0x84c7 +#define GL_TEXTURE8_ARB 0x84c8 +#define GL_TEXTURE9_ARB 0x84c9 +#define GL_TEXTURE10_ARB 0x84ca +#define GL_TEXTURE11_ARB 0x84cb +#define GL_TEXTURE12_ARB 0x84cc +#define GL_TEXTURE13_ARB 0x84cd +#define GL_TEXTURE14_ARB 0x84ce +#define GL_TEXTURE15_ARB 0x84cf +#define GL_TEXTURE16_ARB 0x84d0 +#define GL_TEXTURE17_ARB 0x84d1 +#define GL_TEXTURE18_ARB 0x84d2 +#define GL_TEXTURE19_ARB 0x84d3 +#define GL_TEXTURE20_ARB 0x84d4 +#define GL_TEXTURE21_ARB 0x84d5 +#define GL_TEXTURE22_ARB 0x84d6 +#define GL_TEXTURE23_ARB 0x84d7 +#define GL_TEXTURE24_ARB 0x84d8 +#define GL_TEXTURE25_ARB 0x84d9 +#define GL_TEXTURE26_ARB 0x84da +#define GL_TEXTURE27_ARB 0x84db +#define GL_TEXTURE28_ARB 0x84dc +#define GL_TEXTURE29_ARB 0x84dd +#define GL_TEXTURE30_ARB 0x84de +#define GL_TEXTURE31_ARB 0x84df +#define GL_ACTIVE_TEXTURE_ARB 0x84e0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84e1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84e2 #endif -typedef void (WINE_GLAPI *WINED3D_PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (WINE_GLAPI *WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLACTIVETEXTUREARBPROC)(GLenum texture); +typedef void (WINE_GLAPI *WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC)(GLenum texture); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FARBPROC)(GLenum target, GLfloat s); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FVARBPROC)(GLenum target, const GLfloat *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FARBPROC)(GLenum target, GLfloat s, GLfloat t); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FVARBPROC)(GLenum target, const GLfloat *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FARBPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FVARBPROC)(GLenum target, const GLfloat *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FARBPROC)(GLenum target, + GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FVARBPROC)(GLenum target, const GLfloat *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2SVARBPROC)(GLenum target, const GLshort *v); +typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4SVARBPROC)(GLenum target, const GLshort *v); -/* GL_ARB_texture_cube_map */ -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +/* GL_ARB_occlusion_query */ +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#endif +typedef void (WINE_GLAPI *PGLFNGENQUERIESARBPROC)(GLsizei n, GLuint *queries); +typedef void (WINE_GLAPI *PGLFNDELETEQUERIESARBPROC)(GLsizei n, const GLuint *queries); +typedef GLboolean (WINE_GLAPI *PGLFNISQUERYARBPROC)(GLuint query); +typedef void (WINE_GLAPI *PGLFNBEGINQUERYARBPROC)(GLenum target, GLuint query); +typedef void (WINE_GLAPI *PGLFNENDQUERYARBPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGETQUERYIVARBPROC)(GLenum target, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETQUERYOBJECTIVARBPROC)(GLuint query, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETQUERYOBJECTUIVARBPROC)(GLuint query, GLenum pname, GLuint *params); + +/* GL_ARB_pixel_buffer_object */ +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88eb +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88ec +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ed +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88ef #endif /* GL_ARB_point_parameters */ #ifndef GL_ARB_point_parameters #define GL_ARB_point_parameters 1 -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif +typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFARBPROC)(GLenum pname, GLfloat param); +typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFVARBPROC)(GLenum pname, const GLfloat *params); + +/* GL_ARB_point_sprite */ +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 #endif -typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); /* GL_ARB_provoking_vertex */ #ifndef GL_ARB_provoking_vertex #define GL_ARB_provoking_vertex 1 -#define GL_FIRST_VERTEX_CONVENTION 0x8e4d -#define GL_LAST_VERTEX_CONVENTION 0x8e4e -#define GL_PROVOKING_VERTEX 0x8e4f -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8e4c +#define GL_FIRST_VERTEX_CONVENTION 0x8e4d +#define GL_LAST_VERTEX_CONVENTION 0x8e4e +#define GL_PROVOKING_VERTEX 0x8e4f +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8e4c +#endif +typedef void (WINE_GLAPI *PGLFNGLPROVOKINGVERTEXPROC)(GLenum mode); + +/* GL_ARB_shader_objects */ +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +typedef char GLcharARB; +typedef unsigned int GLhandleARB; +#define GL_PROGRAM_OBJECT_ARB 0x8b40 +#define GL_OBJECT_TYPE_ARB 0x8b4e +#define GL_OBJECT_SUBTYPE_ARB 0x8b4f +#define GL_OBJECT_DELETE_STATUS_ARB 0x8b80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8b81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8b82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8b83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8b84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8b85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8b86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8b87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8b88 +#define GL_SHADER_OBJECT_ARB 0x8b48 +#define GL_FLOAT_VEC2_ARB 0x8b50 +#define GL_FLOAT_VEC3_ARB 0x8b51 +#define GL_FLOAT_VEC4_ARB 0x8b52 +#define GL_INT_VEC2_ARB 0x8b53 +#define GL_INT_VEC3_ARB 0x8b54 +#define GL_INT_VEC4_ARB 0x8b55 +#define GL_BOOL_ARB 0x8b56 +#define GL_BOOL_VEC2_ARB 0x8b57 +#define GL_BOOL_VEC3_ARB 0x8b58 +#define GL_BOOL_VEC4_ARB 0x8b59 +#define GL_FLOAT_MAT2_ARB 0x8b5a +#define GL_FLOAT_MAT3_ARB 0x8b5b +#define GL_FLOAT_MAT4_ARB 0x8b5c +#define GL_SAMPLER_1D_ARB 0x8b5d +#define GL_SAMPLER_2D_ARB 0x8b5e +#define GL_SAMPLER_3D_ARB 0x8b5f +#define GL_SAMPLER_CUBE_ARB 0x8b60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8b61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8b62 +#define GL_SAMPLER_2D_RECT_ARB 0x8b63 +#define GL_SAMPELR_2D_RECT_SHADOW_ARB 0x8b64 +#endif + +/* GL_ARB_shading_language_100 */ +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8b8c +#endif + +/* GL_ARB_sync */ +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xffffffffffffffffULL +#define GL_ALREADY_SIGNALED 0x911a +#define GL_TIMEOUT_EXPIRED 0x911b +#define GL_CONDITION_SATISFIED 0x911c +#define GL_WAIT_FAILED 0x911d +#endif +typedef GLsync (WINE_GLAPI *PGLFNFENCESYNCPROC)(GLenum condition, GLbitfield flags); +typedef GLboolean (WINE_GLAPI *PGLFNISSYNCPROC)(GLsync sync); +typedef GLvoid (WINE_GLAPI *PGLFNDELETESYNCPROC)(GLsync sync); +typedef GLenum (WINE_GLAPI *PGLFNCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef GLvoid (WINE_GLAPI *PGLFNWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef GLvoid (WINE_GLAPI *PGLFNGETINTEGER64VPROC)(GLenum pname, GLint64 *params); +typedef GLvoid (WINE_GLAPI *PGLFNGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei bufsize, + GLsizei *length, GLint *values); + +/* GL_ARB_texture_border_clamp */ +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812d +#endif + +/* GL_ARB_texture_cube_map */ +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851a +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851b +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851c +#endif + +/* GL_ARB_texture_env_dot3 */ +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86ae +#define GL_DOT3_RGBA_ARB 0x86af +#endif + +/* GL_ARB_texture_float */ +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_RGBA16F_ARB 0x881a +#define GL_RGB16F_ARB 0x881b +#endif + +/* GL_ARB_texture_mirrored_repeat */ +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +/* GL_ARB_texture_rectangle */ +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84f5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84f6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84f7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84f8 +#define GL_SAMPLER_2D_RECT_ARB 0x8b63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8b64 +#endif + +/* GL_ARB_texture_rg */ +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822a +#define GL_RG8 0x822b +#define GL_RG16 0x822c +#define GL_R16F 0x822d +#define GL_R32F 0x822e +#define GL_RG16F 0x822f +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823a +#define GL_RG32I 0x823b +#define GL_RG32UI 0x823c #endif -typedef void (WINE_GLAPI * PGLFNGLPROVOKINGVERTEXPROC)(GLenum mode); /* GL_ARB_vertex_blend */ #ifndef GL_ARB_vertex_blend #define GL_ARB_vertex_blend 1 -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F +#define GL_MAX_VERTEX_UNITS_ARB 0x86a4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86a5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86a6 +#define GL_VERTEX_BLEND_ARB 0x86a7 +#define GL_CURRENT_WEIGHT_ARB 0x86a8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86a9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86aa +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86ab +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86ac +#define GL_WEIGHT_ARRAY_ARB 0x86ad +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850a +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872a +#define GL_MODELVIEW11_ARB 0x872b +#define GL_MODELVIEW12_ARB 0x872c +#define GL_MODELVIEW13_ARB 0x872d +#define GL_MODELVIEW14_ARB 0x872e +#define GL_MODELVIEW15_ARB 0x872f +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873a +#define GL_MODELVIEW27_ARB 0x873b +#define GL_MODELVIEW28_ARB 0x873c +#define GL_MODELVIEW29_ARB 0x873d +#define GL_MODELVIEW30_ARB 0x873e +#define GL_MODELVIEW31_ARB 0x873f #endif -typedef void (WINE_GLAPI * PGLFNGLWEIGHTPOINTERARB) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTBV) (GLint size, const GLbyte *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTSV) (GLint size, const GLshort *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTIV) (GLint size, const GLint *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTFV) (GLint size, const GLfloat *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTDV) (GLint size, const GLdouble *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTUBV) (GLint size, const GLubyte *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTUSV) (GLint size, const GLushort *weights); -typedef void (WINE_GLAPI * PGLFNGLWEIGHTUIV) (GLint size, const GLuint *weights); -typedef void (WINE_GLAPI * PGLFNGLVERTEXBLENDARB) (GLint count); -/* GL_ARB_pixel_buffer_object */ -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -/* GL_EXT_framebuffer_object */ -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +typedef void (WINE_GLAPI *PGLFNGLWEIGHTPOINTERARB)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTBV)(GLint size, const GLbyte *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTSV)(GLint size, const GLshort *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTIV)(GLint size, const GLint *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTFV)(GLint size, const GLfloat *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTDV)(GLint size, const GLdouble *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTUBV)(GLint size, const GLubyte *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTUSV)(GLint size, const GLushort *weights); +typedef void (WINE_GLAPI *PGLFNGLWEIGHTUIV)(GLint size, const GLuint *weights); +typedef void (WINE_GLAPI *PGLFNGLVERTEXBLENDARB)(GLint count); +/* GL_ARB_vertex_buffer_object */ +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889a +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889b +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889c +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889d +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889e +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889f +#define GL_READ_ONLY_ARB 0x88b8 +#define GL_WRITE_ONLY_ARB 0x88b9 +#define GL_READ_WRITE_ARB 0x88ba +#define GL_BUFFER_ACCESS_ARB 0x88bb +#define GL_BUFFER_MAPPED_ARB 0x88bc +#define GL_BUFFER_MAP_POINTER_ARB 0x88bd +#define GL_STREAM_DRAW_ARB 0x88e0 +#define GL_STREAM_READ_ARB 0x88e1 +#define GL_STREAM_COPY_ARB 0x88e2 +#define GL_STATIC_DRAW_ARB 0x88e4 +#define GL_STATIC_READ_ARB 0x88e5 +#define GL_STATIC_COPY_ARB 0x88e6 +#define GL_DYNAMIC_DRAW_ARB 0x88e8 +#define GL_DYNAMIC_READ_ARB 0x88e9 +#define GL_DYNAMIC_COPY_ARB 0x88ea #endif -typedef GLboolean (WINE_GLAPI * PGLFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers); -typedef void (WINE_GLAPI * PGLFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers); -typedef void (WINE_GLAPI * PGLFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (WINE_GLAPI * PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params); -typedef GLboolean (WINE_GLAPI * PGLFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer); -typedef void (WINE_GLAPI * PGLFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer); -typedef void (WINE_GLAPI * PGLFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers); -typedef void (WINE_GLAPI * PGLFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers); -typedef GLenum (WINE_GLAPI * PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (WINE_GLAPI * PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGLGENERATEMIPMAPEXTPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNBINDBUFFERARBPROC)(GLenum target, GLuint buffer); +typedef void (WINE_GLAPI *PGLFNDELETEBUFFERSARBPROC)(GLsizei n, const GLuint *buffers); +typedef void (WINE_GLAPI *PGLFNGENBUFFERSARBPROC)(GLsizei n, GLuint *buffers); +typedef GLboolean (WINE_GLAPI *PGLFNISBUFFERARBPROC)(GLuint buffer); +typedef void (WINE_GLAPI *PGLFNBUFFERDATAARBPROC)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (WINE_GLAPI *PGLFNBUFFERSUBDATAARBPROC)(GLenum target, + GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNGETBUFFERSUBDATAARBPROC)(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (WINE_GLAPI *PGLFNMAPBUFFERARBPROC)(GLenum target, GLenum access); +typedef GLboolean (WINE_GLAPI *PGLFNUNMAPBUFFERARBPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGETBUFFERPARAMETERIVARBPROC)(GLenum target, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETBUFFERPOINTERVARBPROC)(GLenum target, GLenum pname, GLvoid* *params); + +/* GL_ARB_vertex_program */ +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886a +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88a0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88a1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88a2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88a3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88a4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88a5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88a6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88a7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88a8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88a9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88aa +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88ab +#define GL_PROGRAM_ATTRIBS_ARB 0x88ac +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88ad +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88ae +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88af +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88b0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88b1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88b2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88b3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88b4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88b5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88b6 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864b +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88b7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862f +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862e +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88c0 +#define GL_MATRIX1_ARB 0x88c1 +#define GL_MATRIX2_ARB 0x88c2 +#define GL_MATRIX3_ARB 0x88c3 +#define GL_MATRIX4_ARB 0x88c4 +#define GL_MATRIX5_ARB 0x88c5 +#define GL_MATRIX6_ARB 0x88c6 +#define GL_MATRIX7_ARB 0x88c7 +#define GL_MATRIX8_ARB 0x88c8 +#define GL_MATRIX9_ARB 0x88c9 +#define GL_MATRIX10_ARB 0x88ca +#define GL_MATRIX11_ARB 0x88cb +#define GL_MATRIX12_ARB 0x88cc +#define GL_MATRIX13_ARB 0x88cd +#define GL_MATRIX14_ARB 0x88ce +#define GL_MATRIX15_ARB 0x88cf +#define GL_MATRIX16_ARB 0x88d0 +#define GL_MATRIX17_ARB 0x88d1 +#define GL_MATRIX18_ARB 0x88d2 +#define GL_MATRIX19_ARB 0x88d3 +#define GL_MATRIX20_ARB 0x88d4 +#define GL_MATRIX21_ARB 0x88d5 +#define GL_MATRIX22_ARB 0x88d6 +#define GL_MATRIX23_ARB 0x88d7 +#define GL_MATRIX24_ARB 0x88d8 +#define GL_MATRIX25_ARB 0x88d9 +#define GL_MATRIX26_ARB 0x88da +#define GL_MATRIX27_ARB 0x88db +#define GL_MATRIX28_ARB 0x88dc +#define GL_MATRIX29_ARB 0x88dd +#define GL_MATRIX30_ARB 0x88de +#define GL_MATRIX31_ARB 0x88df +#endif +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DARBPROC)(GLuint index, GLdouble x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DVARBPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FARBPROC)(GLuint index, GLfloat x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FVARBPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SARBPROC)(GLuint index, GLshort x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DARBPROC)(GLuint index, GLdouble x, GLdouble y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DVARBPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FARBPROC)(GLuint index, GLfloat x, GLfloat y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FVARBPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SARBPROC)(GLuint index, GLshort x, GLshort y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DVARBPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FVARBPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NBVARBPROC)(GLuint index, const GLbyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NIVARBPROC)(GLuint index, const GLint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NSVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBARBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBVARBPROC)(GLuint index, const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUIVARBPROC)(GLuint index, const GLuint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUSVARBPROC)(GLuint index, const GLushort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4BVARBPROC)(GLuint index, const GLbyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DVARBPROC)(GLuint index, const GLdouble *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FVARBPROC)(GLuint index, const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4IVARBPROC)(GLuint index, const GLint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SVARBPROC)(GLuint index, const GLshort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UBVARBPROC)(GLuint index, const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UIVARBPROC)(GLuint index, const GLuint *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4USVARBPROC)(GLuint index, const GLushort *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBPOINTERARBPROC)(GLuint index, GLint size, + GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (WINE_GLAPI *PGLFNENABLEVERTEXATTRIBARRAYARBPROC)(GLuint index); +typedef void (WINE_GLAPI *PGLFNDISABLEVERTEXATTRIBARRAYARBPROC)(GLuint index); +typedef void (WINE_GLAPI *PGLFNPROGRAMSTRINGARBPROC)(GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (WINE_GLAPI *PGLFNBINDPROGRAMARBPROC)(GLenum target, GLuint program); +typedef void (WINE_GLAPI *PGLFNDELETEPROGRAMSARBPROC)(GLsizei n, const GLuint *programs); +typedef void (WINE_GLAPI *PGLFNGENPROGRAMSARBPROC)(GLsizei n, GLuint *programs); +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4DARBPROC)(GLenum target, + GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble *params); +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4FARBPROC)(GLenum target, + GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4DARBPROC)(GLenum target, + GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble *params); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4FARBPROC)(GLenum target, + GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMENVPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMENVPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMLOCALPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMLOCALPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMIVARBPROC)(GLenum target, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETPROGRAMSTRINGARBPROC)(GLenum target, GLenum pname, GLvoid *string); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBDVARBPROC)(GLuint index, GLenum pname, GLdouble *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBFVARBPROC)(GLuint index, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBIVARBPROC)(GLuint index, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBPOINTERVARBPROC)(GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (WINE_GLAPI *PGLFNISPROGRAMARBPROC)(GLuint program); + +/* GL_ARB_vertex_shader */ +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8b31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8b4a +#define GL_MAX_VARYING_FLOATS_ARB 0x8b4b +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8b4c +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8b4d +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8b89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8b8a +#endif +typedef void (WINE_GLAPI *WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC)(GLhandleARB obj, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC)(GLhandleARB obj, GLenum pname, GLfloat *params); +typedef GLint (WINE_GLAPI *WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB *name); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETACTIVEUNIFORMARBPROC)(GLhandleARB programObj, GLuint index, + GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1IARBPROC)(GLint location, GLint v0); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2IARBPROC)(GLint location, GLint v0, GLint v1); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3IARBPROC)(GLint location, GLint v0, GLint v1, GLint v2); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4IARBPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1FARBPROC)(GLint location, GLfloat v0); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2FARBPROC)(GLint location, GLfloat v0, GLfloat v1); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3FARBPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4FARBPROC)(GLint location, + GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1IVARBPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2IVARBPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3IVARBPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4IVARBPROC)(GLint location, GLsizei count, const GLint *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1FVARBPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2FVARBPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3FVARBPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4FVARBPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETUNIFORMFVARBPROC)(GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETUNIFORMIVARBPROC)(GLhandleARB programObj, GLint location, GLint *params); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETINFOLOGARBPROC)(GLhandleARB obj, + GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (WINE_GLAPI *WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC)(GLhandleARB programObj); +typedef GLhandleARB (WINE_GLAPI *WINED3D_PFNGLCREATESHADEROBJECTARBPROC)(GLenum shaderType); +typedef void (WINE_GLAPI *WINED3D_PFNGLSHADERSOURCEARBPROC)(GLhandleARB shaderObj, + GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (WINE_GLAPI *WINED3D_PFNGLCOMPILESHADERARBPROC)(GLhandleARB shaderObj); +typedef GLhandleARB (WINE_GLAPI *WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC)(void); +typedef void (WINE_GLAPI *WINED3D_PFNGLATTACHOBJECTARBPROC)(GLhandleARB containerObj, GLhandleARB obj); +typedef void (WINE_GLAPI *WINED3D_PFNGLLINKPROGRAMARBPROC)(GLhandleARB programObj); +typedef void (WINE_GLAPI *WINED3D_PFNGLDETACHOBJECTARBPROC)(GLhandleARB containerObj, GLhandleARB attachedObj); +typedef void (WINE_GLAPI *WINED3D_PFNGLDELETEOBJECTARBPROC)(GLhandleARB obj); +typedef void (WINE_GLAPI *WINED3D_PFNGLVALIDATEPROGRAMARBPROC)(GLhandleARB programObj); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC)(GLhandleARB containerObj, + GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLhandleARB (WINE_GLAPI *WINED3D_PFNGLGETHANDLEARBPROC)(GLenum pname); +typedef void (WINE_GLAPI *WINED3D_PFNGLGETSHADERSOURCEARBPROC)(GLhandleARB obj, + GLsizei maxLength, GLsizei *length, GLcharARB *source); +typedef void (WINE_GLAPI *WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC)(GLhandleARB programObj, + GLuint index, const GLcharARB *name); +typedef GLint (WINE_GLAPI *WINED3D_PFNGLGETATTRIBLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB *name); + +/* GL_ATI_fragment_shader */ +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896a +#define GL_CND0_ATI 0x896b +#define GL_DOT2_ADD_ATI 0x896c +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896d +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif +typedef GLuint (WINE_GLAPI *PGLFNGENFRAGMENTSHADERSATI)(GLuint range); +typedef void (WINE_GLAPI *PGLFNBINDFRAGMENTSHADERATI)(GLuint id); +typedef void (WINE_GLAPI *PGLFNDELETEFRAGMENTSHADERATI)(GLuint id); +typedef void (WINE_GLAPI *PGLFNBEGINFRAGMENTSHADERATI)(void); +typedef void (WINE_GLAPI *PGLFNENDFRAGMENTSHADERATI)(void); +typedef void (WINE_GLAPI *PGLFNPASSTEXCOORDATI)(GLuint dst, GLuint coord, GLenum swizzle); +typedef void (WINE_GLAPI *PGLFNSAMPLEMAPATI)(GLuint dst, GLuint interp, GLenum swizzle); +typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP1ATI)(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP2ATI)(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod); +typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP3ATI)(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, + GLuint arg3Mod); +typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP1ATI)(GLenum op, GLuint dst, GLuint dstMod, + GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP2ATI)(GLenum op, GLuint dst, GLuint dstMod, + GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, + GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP3ATI)(GLenum op, GLuint dst, GLuint dstMod, + GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, + GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, + GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (WINE_GLAPI *PGLFNSETFRAGMENTSHADERCONSTANTATI)(GLuint dst, const GLfloat *value); + +/* GL_ATI_separate_stencil */ +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif +typedef void (WINE_GLAPI *PGLFNSTENCILOPSEPARATEATIPROC)(GLenum, GLenum, GLenum, GLenum); +typedef void (WINE_GLAPI *PGLFNSTENCILFUNCSEPARATEATIPROC)(GLenum, GLenum, GLint, GLuint); + +/* GL_ATI_texture_compression_3dc */ +#ifndef GL_ATI_texture_compression_3dc +#define GL_ATI_texture_compression_3dc 1 +#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 +#endif + +/* GL_ATI_texture_env_combine3 */ +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +/* #define ONE */ +/* #define ZERO */ +#endif + +/* GL_ATI_texture_mirror_once */ +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +/* GL_EXT_blend_equation_separate */ +typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONSEPARATEEXTPROC)(GLenum modeRGB, GLenum modeAlpha); + +/* GL_EXT_blend_func_separate */ +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80c8 +#define GL_BLEND_SRC_RGB_EXT 0x80c9 +#define GL_BLEND_DST_ALPHA_EXT 0x80ca +#define GL_BLEND_SRC_ALPHA_EXT 0x80cb +#endif +typedef void (WINE_GLAPI *PGLFNBLENDFUNCSEPARATEEXTPROC)(GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorAlpha, GLenum dfactorAlpha); + +/* GL_EXT_fog_coord */ +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDFEXTPROC)(GLfloat coord); +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDFVEXTPROC)(const GLfloat *coord); +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDDEXTPROC)(GLdouble coord); +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDDVEXTPROC)(const GLdouble *coord); +typedef void (WINE_GLAPI *PGLFNGLFOGCOORDPOINTEREXTPROC)(GLenum type, GLsizei stride, GLvoid *data); + /* GL_EXT_framebuffer_blit */ #ifndef GL_EXT_framebuffer_blit #define GL_EXT_framebuffer_blit 1 -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#define GL_READ_FRAMEBUFFER_EXT 0x8ca8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8ca9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8ca6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8caa #endif -typedef void (WINE_GLAPI * PGLFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (WINE_GLAPI *PGLFNGLBLITFRAMEBUFFEREXTPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); /* GL_EXT_framebuffer_multisample */ #ifndef GL_EXT_framebuffer_multisample #define GL_EXT_framebuffer_multisample 1 -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8cab -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8d56 -#define GL_MAX_SAMPLES_EXT 0x8d57 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8cab +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8d56 +#define GL_MAX_SAMPLES_EXT 0x8d57 #endif -typedef void (WINE_GLAPI * PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (WINE_GLAPI *PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, + GLenum internalformat, GLsizei width, GLsizei height); + +/* GL_EXT_framebuffer_object */ +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_FRAMEBUFFER_EXT 0x8d40 +#define GL_RENDERBUFFER_EXT 0x8d41 +#define GL_STENCIL_INDEX1_EXT 0x8d46 +#define GL_STENCIL_INDEX4_EXT 0x8d47 +#define GL_STENCIL_INDEX8_EXT 0x8d48 +#define GL_STENCIL_INDEX16_EXT 0x8d49 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8d42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8d43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8d44 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8d50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8d51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8d52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8d53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8d54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8d55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8cd0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8cd1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8cd2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8cd3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8cd4 +#define GL_COLOR_ATTACHMENT0_EXT 0x8ce0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8ce1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8ce2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8ce3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8ce4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8ce5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8ce6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8ce7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8ce8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8ce9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8cea +#define GL_COLOR_ATTACHMENT11_EXT 0x8ceb +#define GL_COLOR_ATTACHMENT12_EXT 0x8cec +#define GL_COLOR_ATTACHMENT13_EXT 0x8ced +#define GL_COLOR_ATTACHMENT14_EXT 0x8cee +#define GL_COLOR_ATTACHMENT15_EXT 0x8cef +#define GL_DEPTH_ATTACHMENT_EXT 0x8d00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8d20 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8cd5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8cd6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8cd7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8cd9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8cda +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8cdb +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8cdc +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8cdd +#define GL_FRAMEBUFFER_BINDING_EXT 0x8ca6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8ca7 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8cdF +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84e8 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#endif +typedef GLboolean (WINE_GLAPI *PGLFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers); +typedef void (WINE_GLAPI *PGLFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers); +typedef void (WINE_GLAPI *PGLFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, + GLenum internalformat, GLsizei width, GLsizei height); +typedef void (WINE_GLAPI *PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params); +typedef GLboolean (WINE_GLAPI *PGLFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer); +typedef void (WINE_GLAPI *PGLFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer); +typedef void (WINE_GLAPI *PGLFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers); +typedef void (WINE_GLAPI *PGLFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers); +typedef GLenum (WINE_GLAPI *PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment, + GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (WINE_GLAPI *PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target, + GLenum attachment, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGLGENERATEMIPMAPEXTPROC)(GLenum target); + +/* GL_EXT_gpu_program_parameters */ +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETERS4FVEXTPROC)(GLenum target, + GLuint index, GLsizei count, const float *params); +typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC)(GLenum target, + GLuint index, GLsizei count, const float *params); +#endif + +/* GL_EXT_gpu_shader4 */ +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88fd +#define GL_SAMPLER_1D_ARRAY_EXT 0x8dc0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8dc1 +#define GL_SAMPLER_BUFFER_EXT 0x8dc2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8dc3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8dc4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8dc5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8dc6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8dc7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8dc8 +#define GL_INT_SAMPLER_1D_EXT 0x8dc9 +#define GL_INT_SAMPLER_2D_EXT 0x8dca +#define GL_INT_SAMPLER_3D_EXT 0x8dcb +#define GL_INT_SAMPLER_CUBE_EXT 0x8dcc +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8dcd +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8dce +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8dcf +#define GL_INT_SAMPLER_BUFFER_EXT 0x8dd0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8dd1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8dd2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8dd3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8dd4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8dd5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8dd6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8dd7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8dd8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +#endif +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1IEXTPROC)(GLuint index, GLint x); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2IEXTPROC)(GLuint index, GLint x, GLint y); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3IEXTPROC)(GLuint index, GLint x, GLint y, GLint z); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4IEXTPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1UIEXTPROC)(GLuint index, GLuint x); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2UIEXTPROC)(GLuint index, GLuint x, GLuint y); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3UIEXTPROC)(GLuint index, GLuint x, GLuint y, GLuint z); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4UIEXTPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1IVEXTPROC)(GLuint index, const GLint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2IVEXTPROC)(GLuint index, const GLint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3IVEXTPROC)(GLuint index, const GLint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4IVEXTPROC)(GLuint index, const GLint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1UIVEXTPROC)(GLuint index, const GLuint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2UIVEXTPROC)(GLuint index, const GLuint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3UIVEXTPROC)(GLuint index, const GLuint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4UIVEXTPROC)(GLuint index, const GLuint *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4BVEXTPROC)(GLuint index, const GLbyte *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4SVEXTPROC)(GLuint index, const GLshort *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4UBVEXTPROC)(GLuint index, const GLubyte *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4USVEXTPROC)(GLuint index, const GLushort *v); +typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBIPOINTEREXTPROC)(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *pointer); +typedef GLvoid (WINE_GLAPI *PGLFNGETVERTEXATTRIBIIVEXTPROC)(GLuint index, GLenum pname, GLint *params); +typedef GLvoid (WINE_GLAPI *PGLFNGETVERTEXATTRIBIUIVEXTPROC)(GLuint index, GLenum pname, GLuint *params); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM1UIEXTPROC)(GLint location, GLuint v0); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM2UIEXTPROC)(GLint location, GLuint v0, GLuint v1); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM3UIEXTPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM4UIEXTPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM1UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM2UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM3UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value); +typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM4UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value); +typedef GLvoid (WINE_GLAPI *PGLFNGETUNIFORMUIVEXTPROC)(GLuint program, GLint location, const GLuint *params); +typedef GLvoid (WINE_GLAPI *PGLFNBINDFRAGDATALOCATIONEXTPROC)(GLuint program, GLuint color_number, const GLchar *name); +typedef GLint (WINE_GLAPI *PGLFNGETFRAGDATALOCATIONEXTPROC)(GLuint program, const GLchar *name); /* GL_EXT_packed_depth_stencil */ #ifndef GL_EXT_packed_depth_stencil #define GL_EXT_packed_depth_stencil 1 -#define GL_DEPTH_STENCIL_EXT 0x84f9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84fa -#define GL_DEPTH24_STENCIL8_EXT 0x88f0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88f1 +#define GL_DEPTH_STENCIL_EXT 0x84f9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84fa +#define GL_DEPTH24_STENCIL8_EXT 0x88f0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88f1 #endif -/* GL_EXT_secondary_color */ -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); /* GL_EXT_paletted_texture */ #ifndef GL_EXT_paletted_texture #define GL_EXT_paletted_texture 1 -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#define GL_COLOR_INDEX1_EXT 0x80e2 +#define GL_COLOR_INDEX2_EXT 0x80e3 +#define GL_COLOR_INDEX4_EXT 0x80e4 +#define GL_COLOR_INDEX8_EXT 0x80e5 +#define GL_COLOR_INDEX12_EXT 0x80e6 +#define GL_COLOR_INDEX16_EXT 0x80e7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ed #endif -typedef void (WINE_GLAPI * PGLFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (WINE_GLAPI *PGLFNGLCOLORTABLEEXTPROC)(GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, const GLvoid *table); + /* GL_EXT_point_parameters */ #ifndef GL_EXT_point_parameters #define GL_EXT_point_parameters 1 -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 #endif -typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFEXTPROC)(GLenum pname, GLfloat param); +typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFVEXTPROC)(GLenum pname, const GLfloat *params); /* GL_EXT_provoking_vertex */ #ifndef GL_EXT_provoking_vertex @@ -2109,2025 +3196,1304 @@ typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const #define GL_PROVOKING_VERTEX_EXT 0x8e4f #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8e4c #endif -typedef void (WINE_GLAPI * PGLFNGLPROVOKINGVERTEXEXTPROC)(GLenum mode); +typedef void (WINE_GLAPI *PGLFNGLPROVOKINGVERTEXEXTPROC)(GLenum mode); + +/* GL_EXT_secondary_color */ +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845a +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845b +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845c +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845d +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845e +#endif +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3FEXTPROC)(GLfloat red, GLfloat green, GLfloat blue); +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3FVEXTPROC)(const GLfloat *v); +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3UBEXTPROC)(GLubyte red, GLubyte green, GLubyte blue); +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3UBVEXTPROC)(const GLubyte *v); +typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLORPOINTEREXTPROC)(GLint size, GLenum type, + GLsizei stride, const GLvoid *pointer); + +/* GL_EXT_stencil_two_side */ +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif +typedef void (WINE_GLAPI *PGLFNACTIVESTENCILFACEEXTPROC)(GLenum face); + +/* GL_EXT_stencil_wrap */ +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_texture3D */ #ifndef GL_EXT_texture3D #define GL_EXT_texture3D 1 -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#define GL_PACK_SKIP_IMAGES_EXT 0x806b +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806c +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806d +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806e +#define GL_TEXTURE_3D_EXT 0x806f +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 #endif -typedef void (WINE_GLAPI * PGLFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (WINE_GLAPI * PGLFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -/* GL_EXT_texture_env_combine */ -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_SUBTRACT_EXT 0x84E7 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE3_RGB_EXT 0x8583 -#define GL_SOURCE4_RGB_EXT 0x8584 -#define GL_SOURCE5_RGB_EXT 0x8585 -#define GL_SOURCE6_RGB_EXT 0x8586 -#define GL_SOURCE7_RGB_EXT 0x8587 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_SOURCE3_ALPHA_EXT 0x858B -#define GL_SOURCE4_ALPHA_EXT 0x858C -#define GL_SOURCE5_ALPHA_EXT 0x858D -#define GL_SOURCE6_ALPHA_EXT 0x858E -#define GL_SOURCE7_ALPHA_EXT 0x858F -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND3_RGB_EXT 0x8593 -#define GL_OPERAND4_RGB_EXT 0x8594 -#define GL_OPERAND5_RGB_EXT 0x8595 -#define GL_OPERAND6_RGB_EXT 0x8596 -#define GL_OPERAND7_RGB_EXT 0x8597 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#define GL_OPERAND3_ALPHA_EXT 0x859B -#define GL_OPERAND4_ALPHA_EXT 0x859C -#define GL_OPERAND5_ALPHA_EXT 0x859D -#define GL_OPERAND6_ALPHA_EXT 0x859E -#define GL_OPERAND7_ALPHA_EXT 0x859F -#endif -/* GL_EXT_texture_env_dot3 */ -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif -/* GL_EXT_texture_lod_bias */ -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif -/* GL_ARB_texture_border_clamp */ -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif -/* GL_ARB_texture_mirrored_repeat (full support GL1.4) */ -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif -/* GL_ATI_texture_mirror_once */ -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif -/* GL_ARB_texture_env_dot3 */ -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif -/* GL_EXT_texture_env_dot3 */ -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif -/* GL_EXT_texture_sRGB */ -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif -/* GL_ARB_texture_float */ -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#endif -/* GL_ARB_texture_rg */ -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif -/* GL_EXT_texture_swizzle */ -#ifndef GL_EXT_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif -/* GL_ARB_half_float_pixel */ -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif -/* GL_ARB_vertex_program */ -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (WINE_GLAPI * PGLFNENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (WINE_GLAPI * PGLFNDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (WINE_GLAPI * PGLFNPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (WINE_GLAPI * PGLFNBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (WINE_GLAPI * PGLFNDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (WINE_GLAPI * PGLFNGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (WINE_GLAPI * PGLFNISPROGRAMARBPROC) (GLuint program); -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif -/* GL_ARB_multisample */ -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif -typedef void (WINE_GLAPI * WINED3D_PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -/* GL_ARB_vertex_buffer_object */ -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif -typedef void (WINE_GLAPI * PGLFNBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (WINE_GLAPI * PGLFNDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (WINE_GLAPI * PGLFNGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (WINE_GLAPI * PGLFNISBUFFERARBPROC) (GLuint buffer); -typedef void (WINE_GLAPI * PGLFNBUFFERDATAARBPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (WINE_GLAPI * PGLFNBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (WINE_GLAPI * PGLFNMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (WINE_GLAPI * PGLFNUNMAPBUFFERARBPROC) (GLenum target); -typedef void (WINE_GLAPI * PGLFNGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -/* GL_EXT_blend_equation_separate */ -typedef void (WINE_GLAPI * PGLFNBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -/* GL_EXT_blend_func_separate */ -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif -typedef void (WINE_GLAPI * PGLFNBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -/* GL_EXT_fog_coord */ -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif /* GL_EXT_fog_coord */ -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (WINE_GLAPI * PGLFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, GLvoid *data); -/* GL_ARB_shader_objects (GLSL) */ -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPELR_2D_RECT_SHADOW_ARB 0x8B64 -#endif -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif -typedef void (WINE_GLAPI * WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef GLint (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (WINE_GLAPI * WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (WINE_GLAPI * WINED3D_PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (WINE_GLAPI * WINED3D_PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (WINE_GLAPI * WINED3D_PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (WINE_GLAPI * WINED3D_PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (WINE_GLAPI * WINED3D_PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef void (WINE_GLAPI * WINED3D_PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef void (WINE_GLAPI * WINED3D_PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (WINE_GLAPI * WINED3D_PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -typedef void (WINE_GLAPI * WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef GLint (WINE_GLAPI * WINED3D_PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -/* GL_ARB_pixel_buffer_object */ -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif -/* GL_EXT_texture */ -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +typedef void (WINE_GLAPI *PGLFNGLTEXIMAGE3DEXTPROC)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (WINE_GLAPI *PGLFNGLTEXSUBIMAGE3DEXTPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + +/* GL_EXT_texture_compression_rgtc */ +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8dbb +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8dbc +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8dbd +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8dbe #endif + /* GL_EXT_texture_compression_s3tc */ #ifndef GL_EXT_texture_compression_s3tc #define GL_EXT_texture_compression_s3tc 1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83f0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83f1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83f2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83f3 #endif -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (WINE_GLAPI * PGLFNGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); -/* GL_EXT_stencil_wrap */ -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (WINE_GLAPI *PGLFNGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void *img); + +/* GL_EXT_texture_env_combine */ +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_SUBTRACT_EXT 0x84e7 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE3_RGB_EXT 0x8583 +#define GL_SOURCE4_RGB_EXT 0x8584 +#define GL_SOURCE5_RGB_EXT 0x8585 +#define GL_SOURCE6_RGB_EXT 0x8586 +#define GL_SOURCE7_RGB_EXT 0x8587 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858a +#define GL_SOURCE3_ALPHA_EXT 0x858b +#define GL_SOURCE4_ALPHA_EXT 0x858c +#define GL_SOURCE5_ALPHA_EXT 0x858d +#define GL_SOURCE6_ALPHA_EXT 0x858e +#define GL_SOURCE7_ALPHA_EXT 0x858f +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND3_RGB_EXT 0x8593 +#define GL_OPERAND4_RGB_EXT 0x8594 +#define GL_OPERAND5_RGB_EXT 0x8595 +#define GL_OPERAND6_RGB_EXT 0x8596 +#define GL_OPERAND7_RGB_EXT 0x8597 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859a +#define GL_OPERAND3_ALPHA_EXT 0x859b +#define GL_OPERAND4_ALPHA_EXT 0x859c +#define GL_OPERAND5_ALPHA_EXT 0x859d +#define GL_OPERAND6_ALPHA_EXT 0x859e +#define GL_OPERAND7_ALPHA_EXT 0x859f #endif -/* GL_ARB_half_float_vertex */ -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex -/* No _ARB, see extension spec */ -#define GL_HALF_FLOAT 0x140B +/* GL_EXT_texture_env_dot3 */ +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 #endif -/* GL_NV_half_float */ -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -typedef unsigned short GLhalfNV; -#define GL_HALF_FLOAT_NV 0x140B + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84fe +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84ff #endif -typedef void (WINE_GLAPI * PGLFNVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (WINE_GLAPI * PGLFNVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (WINE_GLAPI * PGLFNVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (WINE_GLAPI * PGLFNVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (WINE_GLAPI * PGLFNNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (WINE_GLAPI * PGLFNCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (WINE_GLAPI * PGLFNCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (WINE_GLAPI * PGLFNTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (WINE_GLAPI * PGLFNTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (WINE_GLAPI * PGLFNTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (WINE_GLAPI * PGLFNTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (WINE_GLAPI * PGLFNFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (WINE_GLAPI * PGLFNSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (WINE_GLAPI * PGLFNSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (WINE_GLAPI * PGLFNVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); + +/* GL_EXT_texture_lod_bias */ +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84fd +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +/* GL_EXT_texture_sRGB */ +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8c40 +#define GL_SRGB8_EXT 0x8c41 +#define GL_SRGB_ALPHA_EXT 0x8c42 +#define GL_SRGB8_ALPHA8_EXT 0x8c43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8c44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8c45 +#define GL_SLUMINANCE_EXT 0x8c46 +#define GL_SLUMINANCE8_EXT 0x8c47 +#define GL_COMPRESSED_SRGB_EXT 0x8c48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8c49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8c4a +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8c4b +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8c4c +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8c4d +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8c4e +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8c4f +#endif + +/* GL_NV_depth_clamp */ +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864f +#endif + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84f2 +#define GL_FENCE_STATUS_NV 0x84f3 +#define GL_FENCE_CONDITION_NV 0x84f4 +#endif +typedef void (WINE_GLAPI *PGLFNGENFENCESNVPROC)(GLsizei, GLuint *); +typedef void (WINE_GLAPI *PGLFNDELETEFENCESNVPROC)(GLuint, const GLuint *); +typedef void (WINE_GLAPI *PGLFNSETFENCENVPROC)(GLuint, GLenum); +typedef GLboolean (WINE_GLAPI *PGLFNTESTFENCENVPROC)(GLuint); +typedef void (WINE_GLAPI *PGLFNFINISHFENCENVPROC)(GLuint); +typedef GLboolean (WINE_GLAPI *PGLFNISFENCENVPROC)(GLuint); +typedef void (WINE_GLAPI *PGLFNGETFENCEIVNVPROC)(GLuint, GLenum, GLint *); /* GL_NV_fog_distance */ #ifndef GL_NV_fog_distance #define GL_NV_fog_distance 1 -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#define GL_FOG_DISTANCE_MODE_NV 0x855a +#define GL_EYE_RADIAL_NV 0x855b +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855c /* reuse GL_EYE_PLANE */ #endif -/* GL_NV_texgen_reflection */ -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 + +/* GL_NV_half_float */ +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140b #endif -/* GL_NV_texture_env_combine4 */ -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B +typedef void (WINE_GLAPI *PGLFNVERTEX2HNVPROC)(GLhalfNV x, GLhalfNV y); +typedef void (WINE_GLAPI *PGLFNVERTEX2HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEX3HNVPROC)(GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (WINE_GLAPI *PGLFNVERTEX3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEX4HNVPROC)(GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (WINE_GLAPI *PGLFNVERTEX4HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNNORMAL3HNVPROC)(GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (WINE_GLAPI *PGLFNNORMAL3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNCOLOR3HNVPROC)(GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (WINE_GLAPI *PGLFNCOLOR3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNCOLOR4HNVPROC)(GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (WINE_GLAPI *PGLFNCOLOR4HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNTEXCOORD1HNVPROC)(GLhalfNV s); +typedef void (WINE_GLAPI *PGLFNTEXCOORD1HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNTEXCOORD2HNVPROC)(GLhalfNV s, GLhalfNV t); +typedef void (WINE_GLAPI *PGLFNTEXCOORD2HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNTEXCOORD3HNVPROC)(GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (WINE_GLAPI *PGLFNTEXCOORD3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNTEXCOORD4HNVPROC)(GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (WINE_GLAPI *PGLFNTEXCOORD4HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD1HNVPROC)(GLenum target, GLhalfNV s); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD1HVNVPROC)(GLenum target, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD2HNVPROC)(GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD2HVNVPROC)(GLenum target, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD3HNVPROC)(GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD3HVNVPROC)(GLenum target, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD4HNVPROC)(GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD4HVNVPROC)(GLenum target, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNFOGCOORDHNVPROC)(GLhalfNV fog); +typedef void (WINE_GLAPI *PGLFNFOGCOORDHVNVPROC)(const GLhalfNV *fog); +typedef void (WINE_GLAPI *PGLFNSECONDARYCOLOR3HNVPROC)(GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (WINE_GLAPI *PGLFNSECONDARYCOLOR3HVNVPROC)(const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXWEIGHTHNVPROC)(GLhalfNV weight); +typedef void (WINE_GLAPI *PGLFNVERTEXWEIGHTHVNVPROC)(const GLhalfNV *weight); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1HNVPROC)(GLuint index, GLhalfNV x); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1HVNVPROC)(GLuint index, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2HNVPROC)(GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2HVNVPROC)(GLuint index, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3HNVPROC)(GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3HVNVPROC)(GLuint index, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4HNVPROC)(GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4HVNVPROC)(GLuint index, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS1HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS2HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS3HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS4HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v); + +/* GL_NV_light_max_exponent */ +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 #endif + /* GL_NV_register_combiners */ #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852a +#define GL_CONSTANT_COLOR1_NV 0x852b +#define GL_PRIMARY_COLOR_NV 0x852c +#define GL_SECONDARY_COLOR_NV 0x852d +#define GL_SPARE0_NV 0x852e +#define GL_SPARE1_NV 0x852f +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853a +#define GL_HALF_BIAS_NEGATE_NV 0x853b +#define GL_SIGNED_IDENTITY_NV 0x853c +#define GL_SIGNED_NEGATE_NV 0x853d +#define GL_SCALE_BY_TWO_NV 0x853e +#define GL_SCALE_BY_FOUR_NV 0x853f +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854a +#define GL_COMBINER_CD_OUTPUT_NV 0x854b +#define GL_COMBINER_SUM_OUTPUT_NV 0x854c +#define GL_MAX_GENERAL_COMBINERS_NV 0x854d +#define GL_NUM_GENERAL_COMBINERS_NV 0x854e +#define GL_COLOR_SUM_CLAMP_NV 0x854f +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 /* reuse GL_TEXTURE0_ARB */ /* reuse GL_TEXTURE1_ARB */ /* reuse GL_ZERO */ /* reuse GL_NONE */ /* reuse GL_FOG */ #endif -typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (WINE_GLAPI * PGLFNCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (WINE_GLAPI * PGLFNCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (WINE_GLAPI * PGLFNFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (WINE_GLAPI * PGLFNGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERFVNVPROC)(GLenum pname, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERFNVPROC)(GLenum pname, GLfloat param); +typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERIVNVPROC)(GLenum pname, const GLint *params); +typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERINVPROC)(GLenum pname, GLint param); +typedef void (WINE_GLAPI *PGLFNCOMBINERINPUTNVPROC)(GLenum stage, GLenum portion, + GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (WINE_GLAPI *PGLFNCOMBINEROUTPUTNVPROC)(GLenum stage, GLenum portion, + GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, + GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (WINE_GLAPI *PGLFNFINALCOMBINERINPUTNVPROC)(GLenum variable, GLenum input, + GLenum mapping, GLenum componentUsage); +typedef void (WINE_GLAPI *PGLFNGETCOMBINERINPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion, + GLenum variable, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETCOMBINERINPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion, + GLenum variable, GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETCOMBINEROUTPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion, + GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETCOMBINEROUTPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion, + GLenum pname, GLint *params); +typedef void (WINE_GLAPI *PGLFNGETFINALCOMBINERINPUTPARAMETERFVNVPROC)(GLenum variable, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETFINALCOMBINERINPUTPARAMETERIVNVPROC)(GLenum variable, GLenum pname, GLint *params); + /* GL_NV_register_combiners2 */ #ifndef GL_NV_register_combiners2 #define GL_NV_register_combiners2 1 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 #endif -typedef void (WINE_GLAPI * PGLFNCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +typedef void (WINE_GLAPI *PGLFNCOMBINERSTAGEPARAMETERFVNVPROC)(GLenum stage, GLenum pname, const GLfloat *params); +typedef void (WINE_GLAPI *PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC)(GLenum stage, GLenum pname, GLfloat *params); + +/* GL_NV_texgen_reflection */ +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +/* GL_NV_texture_env_combine4 */ +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858b +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859b +#endif + /* GL_NV_texture_shader */ #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864c +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864d +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864e +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86d9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86da +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86db +#define GL_DSDT_MAG_INTENSITY_NV 0x86dc +#define GL_SHADER_CONSISTENT_NV 0x86dd +#define GL_TEXTURE_SHADER_NV 0x86de +#define GL_SHADER_OPERATION_NV 0x86df +#define GL_CULL_MODES_NV 0x86e0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86e1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86e2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86e3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86e4 +#define GL_CONST_EYE_NV 0x86e5 +#define GL_PASS_THROUGH_NV 0x86e6 +#define GL_CULL_FRAGMENT_NV 0x86e7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86e8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86e9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86ea +#define GL_DOT_PRODUCT_NV 0x86ec +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ed +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86ee +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86f0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86f1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86f2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86f3 +#define GL_HILO_NV 0x86f4 +#define GL_DSDT_NV 0x86f5 +#define GL_DSDT_MAG_NV 0x86f6 +#define GL_DSDT_MAG_VIB_NV 0x86f7 +#define GL_HILO16_NV 0x86f8 +#define GL_SIGNED_HILO_NV 0x86f9 +#define GL_SIGNED_HILO16_NV 0x86fa +#define GL_SIGNED_RGBA_NV 0x86fb +#define GL_SIGNED_RGBA8_NV 0x86fc +#define GL_SIGNED_RGB_NV 0x86fe +#define GL_SIGNED_RGB8_NV 0x86ff +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870a +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870b +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870c +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870d +#define GL_HI_SCALE_NV 0x870e +#define GL_LO_SCALE_NV 0x870f +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871a +#define GL_TEXTURE_HI_SIZE_NV 0x871b +#define GL_TEXTURE_LO_SIZE_NV 0x871c +#define GL_TEXTURE_DS_SIZE_NV 0x871d +#define GL_TEXTURE_DT_SIZE_NV 0x871e +#define GL_TEXTURE_MAG_SIZE_NV 0x871f #endif + /* GL_NV_texture_shader2 */ #ifndef GL_NV_texture_shader2 #define GL_NV_texture_shader2 1 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif -/* GL_NV_texture_shader3 */ -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif -/* GL_ATI_texture_env_combine3 */ -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -/* #define ONE */ -/* #define ZERO */ -#endif - -/** - * Point sprites - */ -/* GL_ARB_point_sprite */ -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif -/** - * @TODO: GL_NV_point_sprite - */ - -/** - * Occlusion Queries - */ -/* GL_ARB_occlusion_query */ -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#endif -typedef void (WINE_GLAPI * PGLFNGENQUERIESARBPROC) (GLsizei n, GLuint *queries); -typedef void (WINE_GLAPI * PGLFNDELETEQUERIESARBPROC) (GLsizei n, const GLuint *queries); -typedef GLboolean (WINE_GLAPI * PGLFNISQUERYARBPROC) (GLuint query); -typedef void (WINE_GLAPI * PGLFNBEGINQUERYARBPROC) (GLenum target, GLuint query); -typedef void (WINE_GLAPI * PGLFNENDQUERYARBPROC) (GLenum target); -typedef void (WINE_GLAPI * PGLFNGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETQUERYOBJECTIVARBPROC) (GLuint query, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETQUERYOBJECTUIVARBPROC) (GLuint query, GLenum pname, GLuint *params); -/* GL_HP_occlusion_test isn't complete, but it's constants are used by GL_NV_occlusion_query */ -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8165 -#endif -/* GL_NV_occlusion_query */ -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif -typedef void (WINE_GLAPI * PGLFNGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (WINE_GLAPI * PGLFNDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (WINE_GLAPI * PGLFNISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (WINE_GLAPI * PGLFNBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (WINE_GLAPI * PGLFNENDOCCLUSIONQUERYNVPROC) (void); -typedef void (WINE_GLAPI * PGLFNGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -/* GL_EXT_stencil_two_side */ -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif -typedef void (WINE_GLAPI * PGLFNACTIVESTENCILFACEEXTPROC) (GLenum face); -/* GL_ATI_separate_stencil */ -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif -typedef void (WINE_GLAPI * PGLFNSTENCILOPSEPARATEATIPROC) (GLenum, GLenum, GLenum, GLenum); -typedef void (WINE_GLAPI * PGLFNSTENCILFUNCSEPARATEATIPROC) (GLenum, GLenum, GLint, GLuint); -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif -typedef void (WINE_GLAPI * PGLFNGENFENCESNVPROC) (GLsizei, GLuint *); -typedef void (WINE_GLAPI * PGLFNDELETEFENCESNVPROC) (GLuint, const GLuint *); -typedef void (WINE_GLAPI * PGLFNSETFENCENVPROC) (GLuint, GLenum); -typedef GLboolean (WINE_GLAPI * PGLFNTESTFENCENVPROC) (GLuint); -typedef void (WINE_GLAPI * PGLFNFINISHFENCENVPROC) (GLuint); -typedef GLboolean (WINE_GLAPI * PGLFNISFENCENVPROC) (GLuint); -typedef void (WINE_GLAPI * PGLFNGETFENCEIVNVPROC) (GLuint, GLenum, GLint *); -/* GL_APPLE_fence */ -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif -typedef void (WINE_GLAPI * PGLFNGENFENCESAPPLEPROC) (GLsizei, GLuint *); -typedef void (WINE_GLAPI * PGLFNDELETEFENCESAPPLEPROC) (GLuint, const GLuint *); -typedef void (WINE_GLAPI * PGLFNSETFENCEAPPLEPROC) (GLuint); -typedef GLboolean (WINE_GLAPI * PGLFNTESTFENCEAPPLEPROC) (GLuint); -typedef void (WINE_GLAPI * PGLFNFINISHFENCEAPPLEPROC) (GLuint); -typedef GLboolean (WINE_GLAPI * PGLFNISFENCEAPPLEPROC) (GLuint); -typedef GLboolean (WINE_GLAPI * PGLFNTESTOBJECTAPPLEPROC) (GLenum, GLuint); -typedef void (WINE_GLAPI * PGLFNFINISHOBJECTAPPLEPROC) (GLenum, GLuint); -/* GL_APPLE_client_storage */ -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif -/* GLX_SGI_video_sync */ -typedef int (WINE_GLAPI * PGLXFNGETVIDEOSYNCSGIPROC) (unsigned int *); -typedef int (WINE_GLAPI * PGLXFNWAITVIDEOSYNCSGIPROC) (int, int, unsigned int *); - -/* GL_SGIS_generate_mipmap */ -#ifndef GLX_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#define GLX_SGIS_generate_mipmap -#endif - -/* GL_NV_depth_clamp */ -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -/* GL_APPLE_flush_render */ -typedef void (WINE_GLAPI * PGLFNFLUSHRENDERAPPLEPROC) (void); -typedef void (WINE_GLAPI * PGLFNFINISHRENDERAPPLEPROC) (void); - -/* GL_APPLE_ycbcr_422 */ -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -/* GL_ARB_texture_rectangle */ -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#endif - -/* GL_APPLE_float_pixels */ -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels -#define GL_HALF_APPLE 0x140B -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#endif - -/* GL_EXT_gpu_program_parameters */ -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters -typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const float *params); -typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const float *params); -#endif - -/* GL_NV_light_max_exponent */ -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -/* GL_ATI_fragment_shader */ -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader -typedef GLuint (WINE_GLAPI *PGLFNGENFRAGMENTSHADERSATI) (GLuint range); -typedef void (WINE_GLAPI *PGLFNBINDFRAGMENTSHADERATI) (GLuint id); -typedef void (WINE_GLAPI *PGLFNDELETEFRAGMENTSHADERATI) (GLuint id); -typedef void (WINE_GLAPI *PGLFNBEGINFRAGMENTSHADERATI) (void); -typedef void (WINE_GLAPI *PGLFNENDFRAGMENTSHADERATI) (void); -typedef void (WINE_GLAPI *PGLFNPASSTEXCOORDATI) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (WINE_GLAPI *PGLFNSAMPLEMAPATI) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP1ATI) (GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod); -typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP2ATI) (GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, - GLuint arg2Mod); -typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP3ATI) (GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, - GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, - GLuint arg3Mod); -typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP1ATI) (GLenum op, GLuint dst, GLuint dstMod, - GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP2ATI) (GLenum op, GLuint dst, GLuint dstMod, - GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, - GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP3ATI) (GLenum op, GLuint dst, GLuint dstMod, - GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, - GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, - GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (WINE_GLAPI *PGLFNSETFRAGMENTSHADERCONSTANTATI) (GLuint dst, const GLfloat *value); -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif -/* GL_ATI_texture_compression_3dc */ -#ifndef GL_ATI_texture_compression_3dc -#define GL_ATI_texture_compression_3dc -#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 -#endif -/* GL_EXT_texture_compression_rgtc */ -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86ef #endif /* GL_NV_vertex_program2_option */ #ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_NV_vertex_program2_option 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88f4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88f5 #endif -/* GL_APPLE_flush_buffer_range */ -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -typedef void (WINE_GLAPI *PGLFNBUFFERPARAMETERIAPPLE) (GLenum target, GLenum pname, GLint param); -typedef void (WINE_GLAPI *PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE) (GLenum target, GLintptr offset, GLsizeiptr size); +/* GL_SGIS_generate_mipmap */ +#ifndef GLX_SGIS_generate_mipmap +#define GLX_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 #endif -/* GL_VERSION_2_0 */ -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -typedef char GLchar; -#endif -typedef void (WINE_GLAPI * PGLFNBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (WINE_GLAPI * PGLFNDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (WINE_GLAPI * PGLFNSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (WINE_GLAPI * PGLFNSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (WINE_GLAPI * PGLFNSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (WINE_GLAPI * PGLFNATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (WINE_GLAPI * PGLFNBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (WINE_GLAPI * PGLFNCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (WINE_GLAPI * PGLFNCREATEPROGRAMPROC) (void); -typedef GLuint (WINE_GLAPI * PGLFNCREATESHADERPROC) (GLenum type); -typedef void (WINE_GLAPI * PGLFNDELETEPROGRAMPROC) (GLuint program); -typedef void (WINE_GLAPI * PGLFNDELETESHADERPROC) (GLuint shader); -typedef void (WINE_GLAPI * PGLFNDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (WINE_GLAPI * PGLFNDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (WINE_GLAPI * PGLFNENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (WINE_GLAPI * PGLFNGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (WINE_GLAPI * PGLFNGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (WINE_GLAPI * PGLFNGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (WINE_GLAPI * PGLFNGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (WINE_GLAPI * PGLFNGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (WINE_GLAPI * PGLFNGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (WINE_GLAPI * PGLFNGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (WINE_GLAPI * PGLFNGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (WINE_GLAPI * PGLFNISPROGRAMPROC) (GLuint program); -typedef GLboolean (WINE_GLAPI * PGLFNISSHADERPROC) (GLuint shader); -typedef void (WINE_GLAPI * PGLFNLINKPROGRAMPROC) (GLuint program); -typedef void (WINE_GLAPI * PGLFNSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (WINE_GLAPI * PGLFNUSEPROGRAMPROC) (GLuint program); -typedef void (WINE_GLAPI * PGLFNUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (WINE_GLAPI * PGLFNUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (WINE_GLAPI * PGLFNUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (WINE_GLAPI * PGLFNUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (WINE_GLAPI * PGLFNUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (WINE_GLAPI * PGLFNUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (WINE_GLAPI * PGLFNUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (WINE_GLAPI * PGLFNUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (WINE_GLAPI * PGLFNUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * PGLFNUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (WINE_GLAPI * PGLFNVALIDATEPROGRAMPROC) (GLuint program); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); - - -/**************************************************** - * OpenGL Official Version - * defines - ****************************************************/ -/* GL_VERSION_1_3 */ -#if !defined(GL_DOT3_RGBA) -# define GL_DOT3_RGBA 0x8741 -#endif -#if !defined(GL_SUBTRACT) -# define GL_SUBTRACT 0x84E7 -#endif - - -/**************************************************** - * Enumerated types - ****************************************************/ -#define WINE_DEFAULT_VIDMEM 64*1024*1024 - -#define MAKEDWORD_VERSION(maj, min) ((maj & 0x0000FFFF) << 16) | (min & 0x0000FFFF) - -/* OpenGL Supported Extensions (ARB and EXT) */ -typedef enum _GL_SupportedExt { - WINED3D_GL_EXT_NONE, - /* ARB */ - ARB_COLOR_BUFFER_FLOAT, - ARB_DEPTH_BUFFER_FLOAT, - ARB_DEPTH_CLAMP, - ARB_DEPTH_TEXTURE, - ARB_DRAW_BUFFERS, - ARB_FRAGMENT_PROGRAM, - ARB_FRAGMENT_SHADER, - ARB_FRAMEBUFFER_OBJECT, - ARB_GEOMETRY_SHADER4, - ARB_IMAGING, - ARB_MULTISAMPLE, - ARB_MULTITEXTURE, - ARB_OCCLUSION_QUERY, - ARB_POINT_PARAMETERS, - ARB_PROVOKING_VERTEX, - ARB_PIXEL_BUFFER_OBJECT, - ARB_POINT_SPRITE, - ARB_TEXTURE_COMPRESSION, - ARB_TEXTURE_CUBE_MAP, - ARB_TEXTURE_ENV_ADD, - ARB_TEXTURE_ENV_COMBINE, - ARB_TEXTURE_ENV_DOT3, - ARB_TEXTURE_FLOAT, - ARB_HALF_FLOAT_PIXEL, - ARB_TEXTURE_BORDER_CLAMP, - ARB_TEXTURE_MIRRORED_REPEAT, - ARB_TEXTURE_NON_POWER_OF_TWO, - ARB_TEXTURE_RECTANGLE, - ARB_TEXTURE_RG, - ARB_VERTEX_PROGRAM, - ARB_VERTEX_BLEND, - ARB_VERTEX_BUFFER_OBJECT, - ARB_VERTEX_SHADER, - ARB_SHADER_OBJECTS, - ARB_SHADER_TEXTURE_LOD, - ARB_HALF_FLOAT_VERTEX, - /* EXT */ - EXT_BLEND_COLOR, - EXT_BLEND_MINMAX, - EXT_BLEND_EQUATION_SEPARATE, - EXT_BLEND_FUNC_SEPARATE, - EXT_FOG_COORD, - EXT_FRAMEBUFFER_OBJECT, - EXT_FRAMEBUFFER_BLIT, - EXT_FRAMEBUFFER_MULTISAMPLE, - EXT_PACKED_DEPTH_STENCIL, - EXT_PALETTED_TEXTURE, - EXT_PIXEL_BUFFER_OBJECT, - EXT_POINT_PARAMETERS, - EXT_PROVOKING_VERTEX, - EXT_SECONDARY_COLOR, - EXT_STENCIL_TWO_SIDE, - EXT_STENCIL_WRAP, - EXT_TEXTURE3D, - EXT_TEXTURE_COMPRESSION_S3TC, - EXT_TEXTURE_COMPRESSION_RGTC, - EXT_TEXTURE_FILTER_ANISOTROPIC, - EXT_TEXTURE_LOD, - EXT_TEXTURE_LOD_BIAS, - EXT_TEXTURE_ENV_ADD, - EXT_TEXTURE_ENV_COMBINE, - EXT_TEXTURE_ENV_DOT3, - EXT_TEXTURE_SRGB, - EXT_TEXTURE_SWIZZLE, - EXT_GPU_PROGRAM_PARAMETERS, - EXT_VERTEX_ARRAY_BGRA, - /* NVIDIA */ - NV_HALF_FLOAT, - NV_FOG_DISTANCE, - NV_FRAGMENT_PROGRAM, - NV_FRAGMENT_PROGRAM2, - NV_OCCLUSION_QUERY, - NV_REGISTER_COMBINERS, - NV_REGISTER_COMBINERS2, - NV_TEXGEN_REFLECTION, - NV_TEXTURE_ENV_COMBINE4, - NV_TEXTURE_SHADER, - NV_TEXTURE_SHADER2, - NV_TEXTURE_SHADER3, - NV_VERTEX_PROGRAM, - NV_VERTEX_PROGRAM1_1, - NV_VERTEX_PROGRAM2, - NV_VERTEX_PROGRAM2_OPTION, - NV_VERTEX_PROGRAM3, - NV_FRAGMENT_PROGRAM_OPTION, - NV_FENCE, - NV_DEPTH_CLAMP, - NV_LIGHT_MAX_EXPONENT, - /* ATI */ - ATI_SEPARATE_STENCIL, - ATI_TEXTURE_ENV_COMBINE3, - ATI_TEXTURE_MIRROR_ONCE, - EXT_VERTEX_SHADER, - ATI_FRAGMENT_SHADER, - ATI_TEXTURE_COMPRESSION_3DC, - /* APPLE */ - APPLE_FENCE, - APPLE_CLIENT_STORAGE, - APPLE_FLUSH_RENDER, - APPLE_YCBCR_422, - APPLE_FLOAT_PIXELS, - APPLE_FLUSH_BUFFER_RANGE, - /* SGI */ - SGI_VIDEO_SYNC, - SGIS_GENERATE_MIPMAP, - - /* Internally used */ - WINE_NORMALIZED_TEXRECT, - - /* WGL extensions */ - WGL_ARB_PBUFFER, - WGL_ARB_PIXEL_FORMAT, - WGL_WINE_PIXEL_FORMAT_PASSTHROUGH, - - WINED3D_GL_EXT_COUNT, -} GL_SupportedExt; - - -/**************************************************** - * #Defines - ****************************************************/ -#define GL_EXT_FUNCS_GEN \ - /** ARB Extensions **/ \ - /* GL_ARB_color_buffer_float */ \ - USE_GL_FUNC(PGLFNCLAMPCOLORARBPROC, glClampColorARB, ARB_COLOR_BUFFER_FLOAT, NULL )\ - /* GL_ARB_draw_buffers */ \ - USE_GL_FUNC(PGLFNDRAWBUFFERSARBPROC, glDrawBuffersARB, ARB_DRAW_BUFFERS, NULL )\ - /* GL_ARB_framebuffer_object */ \ - USE_GL_FUNC(PGLFNGLISRENDERBUFFERPROC, glIsRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBINDRENDERBUFFERPROC, glBindRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSPROC, glGenRenderbuffers, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVPROC, glGetRenderbufferParameteriv, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLISFRAMEBUFFERPROC, glIsFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFERPROC, glBindFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSPROC, glGenFramebuffers, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSPROC, glCheckFramebufferStatus, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DPROC, glFramebufferTexture1D, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DPROC, glFramebufferTexture3D, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURELAYERPROC, glFramebufferTextureLayer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC, glGetFramebufferAttachmentParameteriv, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFERPROC, glBlitFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENERATEMIPMAPPROC, glGenerateMipmap, ARB_FRAMEBUFFER_OBJECT, NULL )\ - /* GL_ARB_geometry_shader4 */ \ - USE_GL_FUNC(PGLFNPROGRAMPARAMETERIARBPROC, glProgramParameteriARB, ARB_GEOMETRY_SHADER4, NULL ) \ - USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREARBPROC, glFramebufferTextureARB, ARB_GEOMETRY_SHADER4, NULL ) \ - USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTURELAYERARBPROC, glFramebufferTextureLayerARB, ARB_GEOMETRY_SHADER4, NULL ) \ - USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREFACEARBPROC, glFramebufferTextureFaceARB, ARB_GEOMETRY_SHADER4, NULL ) \ - /* GL_ARB_imaging, GL_EXT_blend_minmax */ \ - USE_GL_FUNC(PGLFNBLENDCOLORPROC, glBlendColorEXT, EXT_BLEND_COLOR, NULL )\ - USE_GL_FUNC(PGLFNBLENDEQUATIONPROC, glBlendEquationEXT, EXT_BLEND_MINMAX, NULL )\ - /* GL_ARB_multisample */ \ - USE_GL_FUNC(WINED3D_PFNGLSAMPLECOVERAGEARBPROC, glSampleCoverageARB, ARB_MULTISAMPLE, NULL )\ - /* GL_ARB_multitexture */ \ - USE_GL_FUNC(WINED3D_PFNGLACTIVETEXTUREARBPROC, glActiveTextureARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC, glClientActiveTextureARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FARBPROC, glMultiTexCoord1fARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FVARBPROC, glMultiTexCoord1fvARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FARBPROC, glMultiTexCoord2fARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FVARBPROC, glMultiTexCoord2fvARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FARBPROC, glMultiTexCoord3fARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FVARBPROC, glMultiTexCoord3fvARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FARBPROC, glMultiTexCoord4fARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FVARBPROC, glMultiTexCoord4fvARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2SVARBPROC, glMultiTexCoord2svARB, ARB_MULTITEXTURE, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4SVARBPROC, glMultiTexCoord4svARB, ARB_MULTITEXTURE, NULL )\ - /* GL_ARB_occlusion_query */ \ - USE_GL_FUNC(PGLFNGENQUERIESARBPROC, glGenQueriesARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNDELETEQUERIESARBPROC, glDeleteQueriesARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNBEGINQUERYARBPROC, glBeginQueryARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNENDQUERYARBPROC, glEndQueryARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNGETQUERYOBJECTIVARBPROC, glGetQueryObjectivARB, ARB_OCCLUSION_QUERY, NULL )\ - USE_GL_FUNC(PGLFNGETQUERYOBJECTUIVARBPROC, glGetQueryObjectuivARB, ARB_OCCLUSION_QUERY, NULL )\ - /* GL_ARB_point_parameters */ \ - USE_GL_FUNC(PGLFNGLPOINTPARAMETERFARBPROC, glPointParameterfARB, ARB_POINT_PARAMETERS, NULL )\ - USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVARBPROC, glPointParameterfvARB, ARB_POINT_PARAMETERS, NULL )\ - /* GL_ARB_provoking_vertex */ \ - USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXPROC, glProvokingVertex, ARB_PROVOKING_VERTEX, NULL)\ - /* GL_ARB_texture_compression */ \ - USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE2DPROC, glCompressedTexImage2DARB, ARB_TEXTURE_COMPRESSION,NULL )\ - USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE3DPROC, glCompressedTexImage3DARB, ARB_TEXTURE_COMPRESSION,NULL )\ - USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC, glCompressedTexSubImage2DARB, ARB_TEXTURE_COMPRESSION,NULL )\ - USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedTexSubImage3DARB, ARB_TEXTURE_COMPRESSION,NULL )\ - USE_GL_FUNC(PGLFNGETCOMPRESSEDTEXIMAGEPROC, glGetCompressedTexImageARB, ARB_TEXTURE_COMPRESSION,NULL )\ - /* GL_ARB_vertex_blend */ \ - USE_GL_FUNC(PGLFNGLWEIGHTPOINTERARB, glWeightPointerARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTBV, glWeightbvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTSV, glWeightsvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTIV, glWeightivARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTFV, glWeightfvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTDV, glWeightdvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTUBV, glWeightubvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTUSV, glWeightusvARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLWEIGHTUIV, glWeightuivARB, ARB_VERTEX_BLEND, NULL )\ - USE_GL_FUNC(PGLFNGLVERTEXBLENDARB, glVertexBlendARB, ARB_VERTEX_BLEND, NULL )\ - /* GL_ARB_vertex_buffer_object */ \ - USE_GL_FUNC(PGLFNBINDBUFFERARBPROC, glBindBufferARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNDELETEBUFFERSARBPROC, glDeleteBuffersARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNGENBUFFERSARBPROC, glGenBuffersARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNISBUFFERARBPROC, glIsBufferARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNBUFFERDATAARBPROC, glBufferDataARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNBUFFERSUBDATAARBPROC, glBufferSubDataARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNGETBUFFERSUBDATAARBPROC, glGetBufferSubDataARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNMAPBUFFERARBPROC, glMapBufferARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNUNMAPBUFFERARBPROC, glUnmapBufferARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNGETBUFFERPARAMETERIVARBPROC, glGetBufferParameterivARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - USE_GL_FUNC(PGLFNGETBUFFERPOINTERVARBPROC, glGetBufferPointervARB, ARB_VERTEX_BUFFER_OBJECT,NULL)\ - /** EXT Extensions **/ \ - /* GL_EXT_blend_equation_separate */ \ - USE_GL_FUNC(PGLFNBLENDFUNCSEPARATEEXTPROC, glBlendFuncSeparateEXT, EXT_BLEND_FUNC_SEPARATE, NULL)\ - /* GL_EXT_blend_func_separate */ \ - USE_GL_FUNC(PGLFNBLENDEQUATIONSEPARATEEXTPROC, glBlendEquationSeparateEXT, EXT_BLEND_EQUATION_SEPARATE, NULL)\ - /* GL_EXT_fog_coord */ \ - USE_GL_FUNC(PGLFNGLFOGCOORDFEXTPROC, glFogCoordfEXT, EXT_FOG_COORD, NULL )\ - USE_GL_FUNC(PGLFNGLFOGCOORDFVEXTPROC, glFogCoordfvEXT, EXT_FOG_COORD, NULL )\ - USE_GL_FUNC(PGLFNGLFOGCOORDDEXTPROC, glFogCoorddEXT, EXT_FOG_COORD, NULL )\ - USE_GL_FUNC(PGLFNGLFOGCOORDDVEXTPROC, glFogCoorddvEXT, EXT_FOG_COORD, NULL )\ - USE_GL_FUNC(PGLFNGLFOGCOORDPOINTEREXTPROC, glFogCoordPointerEXT, EXT_FOG_COORD, NULL )\ - /* GL_EXT_framebuffer_object */ \ - USE_GL_FUNC(PGLFNGLISRENDERBUFFEREXTPROC, glIsRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBINDRENDERBUFFEREXTPROC, glBindRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSEXTPROC, glDeleteRenderbuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSEXTPROC, glGenRenderbuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEEXTPROC, glRenderbufferStorageEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLISFRAMEBUFFEREXTPROC, glIsFramebufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFEREXTPROC, glBindFramebufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSEXTPROC, glDeleteFramebuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSEXTPROC, glGenFramebuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, glCheckFramebufferStatusEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC, glFramebufferTexture1DEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC, glFramebufferTexture2DEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC, glFramebufferTexture3DEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC, glFramebufferRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGENERATEMIPMAPEXTPROC, glGenerateMipmapEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC, glGetRenderbufferParameterivEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC, glGetFramebufferAttachmentParameterivEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ - /* GL_EXT_framebuffer_blit */ \ - USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFEREXTPROC, glBlitFramebufferEXT, EXT_FRAMEBUFFER_BLIT, NULL )\ - /* GL_EXT_framebuffer_multisample */ \ - USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC, glRenderbufferStorageMultisampleEXT, EXT_FRAMEBUFFER_MULTISAMPLE, NULL )\ - /* GL_EXT_paletted_texture */ \ - USE_GL_FUNC(PGLFNGLCOLORTABLEEXTPROC, glColorTableEXT, EXT_PALETTED_TEXTURE, NULL )\ - /* GL_EXT_point_parameters */ \ - USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC, glPointParameterfEXT, EXT_POINT_PARAMETERS, NULL )\ - USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC, glPointParameterfvEXT, EXT_POINT_PARAMETERS, NULL )\ - /* GL_EXT_provoking_vertex */ \ - USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXEXTPROC, glProvokingVertexEXT, EXT_PROVOKING_VERTEX, NULL)\ - /* GL_EXT_secondary_color */ \ - USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC, glSecondaryColor3ubEXT, EXT_SECONDARY_COLOR, NULL )\ - USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBVEXTPROC, glSecondaryColor3ubvEXT, EXT_SECONDARY_COLOR, NULL )\ - USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FEXTPROC, glSecondaryColor3fEXT, EXT_SECONDARY_COLOR, NULL )\ - USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FVEXTPROC, glSecondaryColor3fvEXT, EXT_SECONDARY_COLOR, NULL )\ - USE_GL_FUNC(PGLFNGLSECONDARYCOLORPOINTEREXTPROC, glSecondaryColorPointerEXT, EXT_SECONDARY_COLOR, NULL )\ - /* GL_EXT_texture3D */ \ - USE_GL_FUNC(PGLFNGLTEXIMAGE3DEXTPROC, glTexImage3DEXT, EXT_TEXTURE3D, glTexImage3D)\ - USE_GL_FUNC(PGLFNGLTEXSUBIMAGE3DEXTPROC, glTexSubImage3DEXT, EXT_TEXTURE3D, glTexSubImage3D)\ - /* GL_ARB_vertex_program */ \ - USE_GL_FUNC(PGLFNGENPROGRAMSARBPROC, glGenProgramsARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNBINDPROGRAMARBPROC, glBindProgramARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNPROGRAMSTRINGARBPROC, glProgramStringARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNDELETEPROGRAMSARBPROC, glDeleteProgramsARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNPROGRAMENVPARAMETER4FVARBPROC, glProgramEnvParameter4fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETER4FVARBPROC, glProgramLocalParameter4fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointerARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNENABLEVERTEXATTRIBARRAYARBPROC, glEnableVertexAttribArrayARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNDISABLEVERTEXATTRIBARRAYARBPROC, glDisableVertexAttribArrayARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1DARBPROC, glVertexAttrib1dARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1DVARBPROC, glVertexAttrib1dvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1FARBPROC, glVertexAttrib1fARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1FVARBPROC, glVertexAttrib1fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1SARBPROC, glVertexAttrib1sARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1SVARBPROC, glVertexAttrib1svARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2DARBPROC, glVertexAttrib2dARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2DVARBPROC, glVertexAttrib2dvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2FARBPROC, glVertexAttrib2fARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2FVARBPROC, glVertexAttrib2fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2SARBPROC, glVertexAttrib2sARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2SVARBPROC, glVertexAttrib2svARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3DARBPROC, glVertexAttrib3dARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3DVARBPROC, glVertexAttrib3dvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3FARBPROC, glVertexAttrib3fARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3FVARBPROC, glVertexAttrib3fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3SARBPROC, glVertexAttrib3sARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3SVARBPROC, glVertexAttrib3svARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NBVARBPROC, glVertexAttrib4NbvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NIVARBPROC, glVertexAttrib4NivARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NSVARBPROC, glVertexAttrib4NsvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBARBPROC, glVertexAttrib4NubARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBVARBPROC, glVertexAttrib4NubvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NUIVARBPROC, glVertexAttrib4NuivARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4NUSVARBPROC, glVertexAttrib4NusvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4BVARBPROC, glVertexAttrib4bvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4DARBPROC, glVertexAttrib4dARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4DVARBPROC, glVertexAttrib4dvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4FARBPROC, glVertexAttrib4fARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4FVARBPROC, glVertexAttrib4fvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4IVARBPROC, glVertexAttrib4ivARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4SARBPROC, glVertexAttrib4sARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4SVARBPROC, glVertexAttrib4svARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4UBVARBPROC, glVertexAttrib4ubvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4UIVARBPROC, glVertexAttrib4uivARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4USVARBPROC, glVertexAttrib4usvARB, ARB_VERTEX_PROGRAM, NULL )\ - USE_GL_FUNC(PGLFNGETPROGRAMIVARBPROC, glGetProgramivARB, ARB_VERTEX_PROGRAM, NULL )\ - /* GL_ARB_shader_objects */ \ - USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC, glGetObjectParameterivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC, glGetObjectParameterfvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC, glGetUniformLocationARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETACTIVEUNIFORMARBPROC, glGetActiveUniformARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC, glUniform1iARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IARBPROC, glUniform2iARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IARBPROC, glUniform3iARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IARBPROC, glUniform4iARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC, glUniform1fARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FARBPROC, glUniform2fARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FARBPROC, glUniform3fARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FARBPROC, glUniform4fARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM1FVARBPROC, glUniform1fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FVARBPROC, glUniform2fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FVARBPROC, glUniform3fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FVARBPROC, glUniform4fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IVARBPROC, glUniform1ivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IVARBPROC, glUniform2ivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IVARBPROC, glUniform3ivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IVARBPROC, glUniform4ivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC, glUniformMatrix2fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC, glUniformMatrix3fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC, glUniformMatrix4fvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMFVARBPROC, glGetUniformfvARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMIVARBPROC, glGetUniformivARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETINFOLOGARBPROC, glGetInfoLogARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC, glUseProgramObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLCREATESHADEROBJECTARBPROC, glCreateShaderObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLSHADERSOURCEARBPROC, glShaderSourceARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLCOMPILESHADERARBPROC, glCompileShaderARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC, glCreateProgramObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLATTACHOBJECTARBPROC, glAttachObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLLINKPROGRAMARBPROC, glLinkProgramARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLDETACHOBJECTARBPROC, glDetachObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLDELETEOBJECTARBPROC, glDeleteObjectARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLVALIDATEPROGRAMARBPROC, glValidateProgramARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC, glGetAttachedObjectsARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETHANDLEARBPROC, glGetHandleARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETSHADERSOURCEARBPROC, glGetShaderSourceARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC, glBindAttribLocationARB, ARB_SHADER_OBJECTS, NULL )\ - USE_GL_FUNC(WINED3D_PFNGLGETATTRIBLOCATIONARBPROC, glGetAttribLocationARB, ARB_SHADER_OBJECTS, NULL )\ - /* GL_EXT_stencil_two_side */ \ - USE_GL_FUNC(PGLFNACTIVESTENCILFACEEXTPROC, glActiveStencilFaceEXT, EXT_STENCIL_TWO_SIDE, NULL )\ - /* GL_ATI_separate_stencil */ \ - USE_GL_FUNC(PGLFNSTENCILOPSEPARATEATIPROC, glStencilOpSeparateATI, ATI_SEPARATE_STENCIL, NULL )\ - USE_GL_FUNC(PGLFNSTENCILFUNCSEPARATEATIPROC, glStencilFuncSeparateATI, ATI_SEPARATE_STENCIL, NULL )\ - /* GL_NV_half_float */ \ - USE_GL_FUNC(PGLFNVERTEX2HNVPROC, glVertex2hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX2HVNVPROC, glVertex2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX3HNVPROC, glVertex3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX3HVNVPROC, glVertex3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX4HNVPROC, glVertex4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEX4HVNVPROC, glVertex4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNNORMAL3HNVPROC, glNormal3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNNORMAL3HVNVPROC, glNormal3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNCOLOR3HNVPROC, glColor3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNCOLOR3HVNVPROC, glColor3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNCOLOR4HNVPROC, glColor4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNCOLOR4HVNVPROC, glColor4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD1HNVPROC, glTexCoord1hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD1HVNVPROC, glTexCoord1hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD2HNVPROC, glTexCoord2hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD2HVNVPROC, glTexCoord2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD3HNVPROC, glTexCoord3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD3HVNVPROC, glTexCoord3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD4HNVPROC, glTexCoord4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNTEXCOORD4HVNVPROC, glTexCoord4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD1HNVPROC, glMultiTexCoord1hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD1HVNVPROC, glMultiTexCoord1hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD2HNVPROC, glMultiTexCoord2hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD2HVNVPROC, glMultiTexCoord2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD3HNVPROC, glMultiTexCoord3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD3HVNVPROC, glMultiTexCoord3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD4HNVPROC, glMultiTexCoord4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNMULTITEXCOORD4HVNVPROC, glMultiTexCoord4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNFOGCOORDHNVPROC, glFogCoordhNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNFOGCOORDHVNVPROC, glFogCoordhvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNSECONDARYCOLOR3HNVPROC, glSecondaryColor3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNSECONDARYCOLOR3HVNVPROC, glSecondaryColor3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXWEIGHTHNVPROC, glVertexWeighthNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXWEIGHTHVNVPROC, glVertexWeighthvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1HNVPROC, glVertexAttrib1hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB1HVNVPROC, glVertexAttrib1hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2HNVPROC, glVertexAttrib2hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB2HVNVPROC, glVertexAttrib2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3HNVPROC, glVertexAttrib3hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB3HVNVPROC, glVertexAttrib3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4HNVPROC, glVertexAttrib4hNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIB4HVNVPROC, glVertexAttrib4hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBS1HVNVPROC, glVertexAttribs1hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBS2HVNVPROC, glVertexAttribs2hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBS3HVNVPROC, glVertexAttribs3hvNV, NV_HALF_FLOAT, NULL )\ - USE_GL_FUNC(PGLFNVERTEXATTRIBS4HVNVPROC, glVertexAttribs4hvNV, NV_HALF_FLOAT, NULL )\ - /* GL_NV_register_combiners */ \ - USE_GL_FUNC(PGLFNCOMBINERINPUTNVPROC, glCombinerInputNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINEROUTPUTNVPROC, glCombinerOutputNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINERPARAMETERFNVPROC, glCombinerParameterfNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINERPARAMETERFVNVPROC, glCombinerParameterfvNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINERPARAMETERINVPROC, glCombinerParameteriNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNCOMBINERPARAMETERIVNVPROC, glCombinerParameterivNV, NV_REGISTER_COMBINERS, NULL )\ - USE_GL_FUNC(PGLFNFINALCOMBINERINPUTNVPROC, glFinalCombinerInputNV, NV_REGISTER_COMBINERS, NULL )\ - /* GL_NV_fence */ \ - USE_GL_FUNC(PGLFNGENFENCESNVPROC, glGenFencesNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNDELETEFENCESNVPROC, glDeleteFencesNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNSETFENCENVPROC, glSetFenceNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNTESTFENCENVPROC, glTestFenceNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNFINISHFENCENVPROC, glFinishFenceNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNISFENCENVPROC, glIsFenceNV, NV_FENCE, NULL )\ - USE_GL_FUNC(PGLFNGETFENCEIVNVPROC, glGetFenceivNV, NV_FENCE, NULL )\ - /* GL_APPLE_fence */ \ - USE_GL_FUNC(PGLFNGENFENCESAPPLEPROC, glGenFencesAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNDELETEFENCESAPPLEPROC, glDeleteFencesAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNSETFENCEAPPLEPROC, glSetFenceAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNTESTFENCEAPPLEPROC, glTestFenceAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNFINISHFENCEAPPLEPROC, glFinishFenceAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNISFENCEAPPLEPROC, glIsFenceAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNTESTOBJECTAPPLEPROC, glTestObjectAPPLE, APPLE_FENCE, NULL )\ - USE_GL_FUNC(PGLFNFINISHOBJECTAPPLEPROC, glFinishObjectAPPLE, APPLE_FENCE, NULL )\ - /* GLX_SGI_video_sync */ \ - USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC, glXGetVideoSyncSGI, SGI_VIDEO_SYNC, NULL )\ - USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC, glXWaitVideoSyncSGI, SGI_VIDEO_SYNC, NULL )\ - /* GL_APPLE_flush_render */ \ - USE_GL_FUNC(PGLFNFLUSHRENDERAPPLEPROC, glFlushRenderAPPLE, APPLE_FLUSH_RENDER, NULL )\ - USE_GL_FUNC(PGLFNFINISHRENDERAPPLEPROC, glFinishRenderAPPLE, APPLE_FLUSH_RENDER, NULL )\ - /* GL_EXT_gpu_program_parameters */ \ - USE_GL_FUNC(PGLFNPROGRAMENVPARAMETERS4FVEXTPROC, glProgramEnvParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS,NULL )\ - USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC, glProgramLocalParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS,NULL )\ - /* GL_ATI_fragment_shader */ \ - USE_GL_FUNC(PGLFNGENFRAGMENTSHADERSATI, glGenFragmentShadersATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNBINDFRAGMENTSHADERATI, glBindFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNDELETEFRAGMENTSHADERATI, glDeleteFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNBEGINFRAGMENTSHADERATI, glBeginFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNENDFRAGMENTSHADERATI, glEndFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNPASSTEXCOORDATI, glPassTexCoordATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNSAMPLEMAPATI, glSampleMapATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNCOLORFRAGMENTOP1ATI, glColorFragmentOp1ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNCOLORFRAGMENTOP2ATI, glColorFragmentOp2ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNCOLORFRAGMENTOP3ATI, glColorFragmentOp3ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNALPHAFRAGMENTOP1ATI, glAlphaFragmentOp1ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNALPHAFRAGMENTOP2ATI, glAlphaFragmentOp2ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNALPHAFRAGMENTOP3ATI, glAlphaFragmentOp3ATI, ATI_FRAGMENT_SHADER, NULL )\ - USE_GL_FUNC(PGLFNSETFRAGMENTSHADERCONSTANTATI, glSetFragmentShaderConstantATI, ATI_FRAGMENT_SHADER, NULL )\ - /* GL_APPLE_flush_buffer_range */ \ - USE_GL_FUNC(PGLFNBUFFERPARAMETERIAPPLE, glBufferParameteriAPPLE, APPLE_FLUSH_BUFFER_RANGE,NULL)\ - USE_GL_FUNC(PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE, glFlushMappedBufferRangeAPPLE, APPLE_FLUSH_BUFFER_RANGE,NULL) - - -/**************************************************** - * OpenGL WGL defines and functions pointer - ****************************************************/ +/* GLX_SGI_video_sync */ +typedef int (WINE_GLAPI *PGLXFNGETVIDEOSYNCSGIPROC)(unsigned int *); +typedef int (WINE_GLAPI *PGLXFNWAITVIDEOSYNCSGIPROC)(int, int, unsigned int *); /* WGL_ARB_extensions_string */ -typedef const char * (WINAPI * WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +typedef const char *(WINAPI *WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc); + /* WGL_ARB_multisample */ #ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 #endif -/* WGL_ARB_pixel_format */ -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif -typedef BOOL (WINAPI * WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -/* WGL_ARB_make_current_read */ -typedef BOOL (WINAPI * WINED3D_PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * WINED3D_PFNWGLGETCURRENTREADDCARBPROC) (void); + /* WGL_ARB_pbuffer */ #ifndef WGL_ARB_pbuffer #define WGL_ARB_pbuffer 1 -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 +#define WGL_DRAW_TO_PBUFFER_ARB 0x202d +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202e +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202f +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 #endif DECLARE_HANDLE(HPBUFFERARB); -typedef HPBUFFERARB (WINAPI * WINED3D_PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * WINED3D_PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef int (WINAPI * WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); -typedef BOOL (WINAPI * WINED3D_PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * WINED3D_PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +typedef HPBUFFERARB (WINAPI *WINED3D_PFNWGLCREATEPBUFFERARBPROC)(HDC hDC, int iPixelFormat, + int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI *WINED3D_PFNWGLGETPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer); +typedef int (WINAPI *WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (WINAPI *WINED3D_PFNWGLDESTROYPBUFFERARBPROC)(HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI *WINED3D_PFNWGLQUERYPBUFFERARBPROC)(HPBUFFERARB hPbuffer, int iAttribute, int *piValue); + +/* WGL_ARB_pixel_format */ +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200a +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203a +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203b +#define WGL_SHARE_DEPTH_ARB 0x200c +#define WGL_SHARE_STENCIL_ARB 0x200d +#define WGL_SHARE_ACCUM_ARB 0x200e +#define WGL_SUPPORT_GDI_ARB 0x200f +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201a +#define WGL_ALPHA_BITS_ARB 0x201b +#define WGL_ALPHA_SHIFT_ARB 0x201c +#define WGL_ACCUM_BITS_ARB 0x201d +#define WGL_ACCUM_RED_BITS_ARB 0x201e +#define WGL_ACCUM_GREEN_BITS_ARB 0x201f +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202a +#define WGL_TYPE_RGBA_ARB 0x202b +#define WGL_TYPE_COLORINDEX_ARB 0x202c +#endif +typedef BOOL (WINAPI *WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC hdc, int iPixelFormat, + int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI *WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC)(HDC hdc, int iPixelFormat, + int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI *WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int *piAttribIList, + const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); + +/* WGL_ARB_pixel_format_float */ #ifndef WGL_ARB_pixel_format_float #define WGL_ARB_pixel_format_float 1 -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21a0 #endif + /* WGL_WINE_pixel_format_passthrough */ -typedef BOOL (WINAPI * WINED3D_PFNWGLSETPIXELFORMATWINE) (HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR* ppfd); +typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelFormat, + const PIXELFORMATDESCRIPTOR *ppfd); + +#define GL_EXT_FUNCS_GEN \ + /* GL_APPLE_fence */ \ + USE_GL_FUNC(PGLFNGENFENCESAPPLEPROC, \ + glGenFencesAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNDELETEFENCESAPPLEPROC, \ + glDeleteFencesAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNSETFENCEAPPLEPROC, \ + glSetFenceAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNTESTFENCEAPPLEPROC, \ + glTestFenceAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNFINISHFENCEAPPLEPROC, \ + glFinishFenceAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNISFENCEAPPLEPROC, \ + glIsFenceAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNTESTOBJECTAPPLEPROC, \ + glTestObjectAPPLE, APPLE_FENCE, NULL) \ + USE_GL_FUNC(PGLFNFINISHOBJECTAPPLEPROC, \ + glFinishObjectAPPLE, APPLE_FENCE, NULL) \ + /* GL_APPLE_flush_buffer_range */ \ + USE_GL_FUNC(PGLFNBUFFERPARAMETERIAPPLE, \ + glBufferParameteriAPPLE, APPLE_FLUSH_BUFFER_RANGE, NULL) \ + USE_GL_FUNC(PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE, \ + glFlushMappedBufferRangeAPPLE, APPLE_FLUSH_BUFFER_RANGE, NULL) \ + /* GL_APPLE_flush_render */ \ + USE_GL_FUNC(PGLFNFLUSHRENDERAPPLEPROC, \ + glFlushRenderAPPLE, APPLE_FLUSH_RENDER, NULL) \ + USE_GL_FUNC(PGLFNFINISHRENDERAPPLEPROC, \ + glFinishRenderAPPLE, APPLE_FLUSH_RENDER, NULL) \ + /* GL_ARB_color_buffer_float */ \ + USE_GL_FUNC(PGLFNCLAMPCOLORARBPROC, \ + glClampColorARB, ARB_COLOR_BUFFER_FLOAT, NULL) \ + /* GL_ARB_draw_buffers */ \ + USE_GL_FUNC(PGLFNDRAWBUFFERSARBPROC, \ + glDrawBuffersARB, ARB_DRAW_BUFFERS, NULL) \ + /* GL_ARB_framebuffer_object */ \ + USE_GL_FUNC(PGLFNGLISRENDERBUFFERPROC, \ + glIsRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBINDRENDERBUFFERPROC, \ + glBindRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSPROC, \ + glDeleteRenderbuffers, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSPROC, \ + glGenRenderbuffers, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEPROC, \ + glRenderbufferStorage, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC, \ + glRenderbufferStorageMultisample, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVPROC, \ + glGetRenderbufferParameteriv, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLISFRAMEBUFFERPROC, \ + glIsFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFERPROC, \ + glBindFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSPROC, \ + glDeleteFramebuffers, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSPROC, \ + glGenFramebuffers, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSPROC, \ + glCheckFramebufferStatus, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DPROC, \ + glFramebufferTexture1D, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DPROC, \ + glFramebufferTexture2D, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DPROC, \ + glFramebufferTexture3D, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURELAYERPROC, \ + glFramebufferTextureLayer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFERPROC, \ + glFramebufferRenderbuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC, \ + glGetFramebufferAttachmentParameteriv, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFERPROC, \ + glBlitFramebuffer, ARB_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENERATEMIPMAPPROC, \ + glGenerateMipmap, ARB_FRAMEBUFFER_OBJECT, NULL) \ + /* GL_ARB_geometry_shader4 */ \ + USE_GL_FUNC(PGLFNPROGRAMPARAMETERIARBPROC, \ + glProgramParameteriARB, ARB_GEOMETRY_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREARBPROC, \ + glFramebufferTextureARB, ARB_GEOMETRY_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTURELAYERARBPROC, \ + glFramebufferTextureLayerARB, ARB_GEOMETRY_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREFACEARBPROC, \ + glFramebufferTextureFaceARB, ARB_GEOMETRY_SHADER4, NULL) \ + /* GL_ARB_imaging, GL_EXT_blend_minmax */ \ + USE_GL_FUNC(PGLFNBLENDCOLORPROC, \ + glBlendColorEXT, EXT_BLEND_COLOR, NULL) \ + USE_GL_FUNC(PGLFNBLENDEQUATIONPROC, \ + glBlendEquationEXT, EXT_BLEND_MINMAX, NULL) \ + /* GL_ARB_map_buffer_range */ \ + USE_GL_FUNC(PGLFNMAPBUFFERRANGEPROC, \ + glMapBufferRange, ARB_MAP_BUFFER_RANGE, NULL) \ + USE_GL_FUNC(PGLFNFLUSHMAPPEDBUFFERRANGEPROC, \ + glFlushMappedBufferRange, ARB_MAP_BUFFER_RANGE, NULL) \ + /* GL_ARB_multisample */ \ + USE_GL_FUNC(WINED3D_PFNGLSAMPLECOVERAGEARBPROC, \ + glSampleCoverageARB, ARB_MULTISAMPLE, NULL) \ + /* GL_ARB_multitexture */ \ + USE_GL_FUNC(WINED3D_PFNGLACTIVETEXTUREARBPROC, \ + glActiveTextureARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC, \ + glClientActiveTextureARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FARBPROC, \ + glMultiTexCoord1fARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FVARBPROC, \ + glMultiTexCoord1fvARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FARBPROC, \ + glMultiTexCoord2fARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FVARBPROC, \ + glMultiTexCoord2fvARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FARBPROC, \ + glMultiTexCoord3fARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FVARBPROC, \ + glMultiTexCoord3fvARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FARBPROC, \ + glMultiTexCoord4fARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FVARBPROC, \ + glMultiTexCoord4fvARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2SVARBPROC, \ + glMultiTexCoord2svARB, ARB_MULTITEXTURE, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4SVARBPROC, \ + glMultiTexCoord4svARB, ARB_MULTITEXTURE, NULL) \ + /* GL_ARB_occlusion_query */ \ + USE_GL_FUNC(PGLFNGENQUERIESARBPROC, \ + glGenQueriesARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNDELETEQUERIESARBPROC, \ + glDeleteQueriesARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNBEGINQUERYARBPROC, \ + glBeginQueryARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNENDQUERYARBPROC, \ + glEndQueryARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNGETQUERYOBJECTIVARBPROC, \ + glGetQueryObjectivARB, ARB_OCCLUSION_QUERY, NULL) \ + USE_GL_FUNC(PGLFNGETQUERYOBJECTUIVARBPROC, \ + glGetQueryObjectuivARB, ARB_OCCLUSION_QUERY, NULL) \ + /* GL_ARB_point_parameters */ \ + USE_GL_FUNC(PGLFNGLPOINTPARAMETERFARBPROC, \ + glPointParameterfARB, ARB_POINT_PARAMETERS, NULL) \ + USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVARBPROC, \ + glPointParameterfvARB, ARB_POINT_PARAMETERS, NULL) \ + /* GL_ARB_provoking_vertex */ \ + USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXPROC, \ + glProvokingVertex, ARB_PROVOKING_VERTEX, NULL) \ + /* GL_ARB_shader_objects */ \ + USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC, \ + glGetObjectParameterivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC, \ + glGetObjectParameterfvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC, \ + glGetUniformLocationARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETACTIVEUNIFORMARBPROC, \ + glGetActiveUniformARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC, \ + glUniform1iARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IARBPROC, \ + glUniform2iARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IARBPROC, \ + glUniform3iARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IARBPROC, \ + glUniform4iARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC, \ + glUniform1fARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FARBPROC, \ + glUniform2fARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FARBPROC, \ + glUniform3fARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FARBPROC, \ + glUniform4fARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM1FVARBPROC, \ + glUniform1fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FVARBPROC, \ + glUniform2fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FVARBPROC, \ + glUniform3fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FVARBPROC, \ + glUniform4fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IVARBPROC, \ + glUniform1ivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IVARBPROC, \ + glUniform2ivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IVARBPROC, \ + glUniform3ivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IVARBPROC, \ + glUniform4ivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC, \ + glUniformMatrix2fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC, \ + glUniformMatrix3fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC, \ + glUniformMatrix4fvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMFVARBPROC, \ + glGetUniformfvARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMIVARBPROC, \ + glGetUniformivARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETINFOLOGARBPROC, \ + glGetInfoLogARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC, \ + glUseProgramObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLCREATESHADEROBJECTARBPROC, \ + glCreateShaderObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLSHADERSOURCEARBPROC, \ + glShaderSourceARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLCOMPILESHADERARBPROC, \ + glCompileShaderARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC, \ + glCreateProgramObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLATTACHOBJECTARBPROC, \ + glAttachObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLLINKPROGRAMARBPROC, \ + glLinkProgramARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLDETACHOBJECTARBPROC, \ + glDetachObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLDELETEOBJECTARBPROC, \ + glDeleteObjectARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLVALIDATEPROGRAMARBPROC, \ + glValidateProgramARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC, \ + glGetAttachedObjectsARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETHANDLEARBPROC, \ + glGetHandleARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETSHADERSOURCEARBPROC, \ + glGetShaderSourceARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC, \ + glBindAttribLocationARB, ARB_SHADER_OBJECTS, NULL) \ + USE_GL_FUNC(WINED3D_PFNGLGETATTRIBLOCATIONARBPROC, \ + glGetAttribLocationARB, ARB_SHADER_OBJECTS, NULL) \ + /* GL_ARB_sync */ \ + USE_GL_FUNC(PGLFNFENCESYNCPROC, \ + glFenceSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNISSYNCPROC, \ + glIsSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNDELETESYNCPROC, \ + glDeleteSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNCLIENTWAITSYNCPROC, \ + glClientWaitSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNWAITSYNCPROC, \ + glWaitSync, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNGETINTEGER64VPROC, \ + glGetInteger64v, ARB_SYNC, NULL) \ + USE_GL_FUNC(PGLFNGETSYNCIVPROC, \ + glGetSynciv, ARB_SYNC, NULL) \ + /* GL_ARB_texture_compression */ \ + USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE2DPROC, \ + glCompressedTexImage2DARB, ARB_TEXTURE_COMPRESSION, NULL) \ + USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE3DPROC, \ + glCompressedTexImage3DARB, ARB_TEXTURE_COMPRESSION, NULL) \ + USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC, \ + glCompressedTexSubImage2DARB, ARB_TEXTURE_COMPRESSION, NULL) \ + USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC, \ + glCompressedTexSubImage3DARB, ARB_TEXTURE_COMPRESSION, NULL) \ + USE_GL_FUNC(PGLFNGETCOMPRESSEDTEXIMAGEPROC, \ + glGetCompressedTexImageARB, ARB_TEXTURE_COMPRESSION, NULL) \ + /* GL_ARB_vertex_blend */ \ + USE_GL_FUNC(PGLFNGLWEIGHTPOINTERARB, \ + glWeightPointerARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTBV, \ + glWeightbvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTSV, \ + glWeightsvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTIV, \ + glWeightivARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTFV, \ + glWeightfvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTDV, \ + glWeightdvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTUBV, \ + glWeightubvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTUSV, \ + glWeightusvARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLWEIGHTUIV, \ + glWeightuivARB, ARB_VERTEX_BLEND, NULL) \ + USE_GL_FUNC(PGLFNGLVERTEXBLENDARB, \ + glVertexBlendARB, ARB_VERTEX_BLEND, NULL) \ + /* GL_ARB_vertex_buffer_object */ \ + USE_GL_FUNC(PGLFNBINDBUFFERARBPROC, \ + glBindBufferARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNDELETEBUFFERSARBPROC, \ + glDeleteBuffersARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGENBUFFERSARBPROC, \ + glGenBuffersARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNISBUFFERARBPROC, \ + glIsBufferARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNBUFFERDATAARBPROC, \ + glBufferDataARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNBUFFERSUBDATAARBPROC, \ + glBufferSubDataARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGETBUFFERSUBDATAARBPROC, \ + glGetBufferSubDataARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNMAPBUFFERARBPROC, \ + glMapBufferARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNUNMAPBUFFERARBPROC, \ + glUnmapBufferARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGETBUFFERPARAMETERIVARBPROC, \ + glGetBufferParameterivARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGETBUFFERPOINTERVARBPROC, \ + glGetBufferPointervARB, ARB_VERTEX_BUFFER_OBJECT, NULL) \ + /* GL_ARB_vertex_program */ \ + USE_GL_FUNC(PGLFNGENPROGRAMSARBPROC, \ + glGenProgramsARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNBINDPROGRAMARBPROC, \ + glBindProgramARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNPROGRAMSTRINGARBPROC, \ + glProgramStringARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNDELETEPROGRAMSARBPROC, \ + glDeleteProgramsARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNPROGRAMENVPARAMETER4FVARBPROC, \ + glProgramEnvParameter4fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETER4FVARBPROC, \ + glProgramLocalParameter4fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBPOINTERARBPROC, \ + glVertexAttribPointerARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNENABLEVERTEXATTRIBARRAYARBPROC, \ + glEnableVertexAttribArrayARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNDISABLEVERTEXATTRIBARRAYARBPROC, \ + glDisableVertexAttribArrayARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1DARBPROC, \ + glVertexAttrib1dARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1DVARBPROC, \ + glVertexAttrib1dvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1FARBPROC, \ + glVertexAttrib1fARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1FVARBPROC, \ + glVertexAttrib1fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1SARBPROC, \ + glVertexAttrib1sARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1SVARBPROC, \ + glVertexAttrib1svARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2DARBPROC, \ + glVertexAttrib2dARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2DVARBPROC, \ + glVertexAttrib2dvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2FARBPROC, \ + glVertexAttrib2fARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2FVARBPROC, \ + glVertexAttrib2fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2SARBPROC, \ + glVertexAttrib2sARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2SVARBPROC, \ + glVertexAttrib2svARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3DARBPROC, \ + glVertexAttrib3dARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3DVARBPROC, \ + glVertexAttrib3dvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3FARBPROC, \ + glVertexAttrib3fARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3FVARBPROC, \ + glVertexAttrib3fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3SARBPROC, \ + glVertexAttrib3sARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3SVARBPROC, \ + glVertexAttrib3svARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NBVARBPROC, \ + glVertexAttrib4NbvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NIVARBPROC, \ + glVertexAttrib4NivARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NSVARBPROC, \ + glVertexAttrib4NsvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBARBPROC, \ + glVertexAttrib4NubARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBVARBPROC, \ + glVertexAttrib4NubvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NUIVARBPROC, \ + glVertexAttrib4NuivARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4NUSVARBPROC, \ + glVertexAttrib4NusvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4BVARBPROC, \ + glVertexAttrib4bvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4DARBPROC, \ + glVertexAttrib4dARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4DVARBPROC, \ + glVertexAttrib4dvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4FARBPROC, \ + glVertexAttrib4fARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4FVARBPROC, \ + glVertexAttrib4fvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4IVARBPROC, \ + glVertexAttrib4ivARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4SARBPROC, \ + glVertexAttrib4sARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4SVARBPROC, \ + glVertexAttrib4svARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4UBVARBPROC, \ + glVertexAttrib4ubvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4UIVARBPROC, \ + glVertexAttrib4uivARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4USVARBPROC, \ + glVertexAttrib4usvARB, ARB_VERTEX_PROGRAM, NULL) \ + USE_GL_FUNC(PGLFNGETPROGRAMIVARBPROC, \ + glGetProgramivARB, ARB_VERTEX_PROGRAM, NULL) \ + /* GL_ATI_fragment_shader */ \ + USE_GL_FUNC(PGLFNGENFRAGMENTSHADERSATI, \ + glGenFragmentShadersATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNBINDFRAGMENTSHADERATI, \ + glBindFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNDELETEFRAGMENTSHADERATI, \ + glDeleteFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNBEGINFRAGMENTSHADERATI, \ + glBeginFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNENDFRAGMENTSHADERATI, \ + glEndFragmentShaderATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNPASSTEXCOORDATI, \ + glPassTexCoordATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNSAMPLEMAPATI, \ + glSampleMapATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNCOLORFRAGMENTOP1ATI, \ + glColorFragmentOp1ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNCOLORFRAGMENTOP2ATI, \ + glColorFragmentOp2ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNCOLORFRAGMENTOP3ATI, \ + glColorFragmentOp3ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNALPHAFRAGMENTOP1ATI, \ + glAlphaFragmentOp1ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNALPHAFRAGMENTOP2ATI, \ + glAlphaFragmentOp2ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNALPHAFRAGMENTOP3ATI, \ + glAlphaFragmentOp3ATI, ATI_FRAGMENT_SHADER, NULL) \ + USE_GL_FUNC(PGLFNSETFRAGMENTSHADERCONSTANTATI, \ + glSetFragmentShaderConstantATI, ATI_FRAGMENT_SHADER, NULL) \ + /* GL_ATI_separate_stencil */ \ + USE_GL_FUNC(PGLFNSTENCILOPSEPARATEATIPROC, \ + glStencilOpSeparateATI, ATI_SEPARATE_STENCIL, NULL) \ + USE_GL_FUNC(PGLFNSTENCILFUNCSEPARATEATIPROC, \ + glStencilFuncSeparateATI, ATI_SEPARATE_STENCIL, NULL) \ + /* GL_EXT_blend_equation_separate */ \ + USE_GL_FUNC(PGLFNBLENDFUNCSEPARATEEXTPROC, \ + glBlendFuncSeparateEXT, EXT_BLEND_FUNC_SEPARATE, NULL) \ + /* GL_EXT_blend_func_separate */ \ + USE_GL_FUNC(PGLFNBLENDEQUATIONSEPARATEEXTPROC, \ + glBlendEquationSeparateEXT, EXT_BLEND_EQUATION_SEPARATE, NULL) \ + /* GL_EXT_fog_coord */ \ + USE_GL_FUNC(PGLFNGLFOGCOORDFEXTPROC, \ + glFogCoordfEXT, EXT_FOG_COORD, NULL) \ + USE_GL_FUNC(PGLFNGLFOGCOORDFVEXTPROC, \ + glFogCoordfvEXT, EXT_FOG_COORD, NULL) \ + USE_GL_FUNC(PGLFNGLFOGCOORDDEXTPROC, \ + glFogCoorddEXT, EXT_FOG_COORD, NULL) \ + USE_GL_FUNC(PGLFNGLFOGCOORDDVEXTPROC, \ + glFogCoorddvEXT, EXT_FOG_COORD, NULL) \ + USE_GL_FUNC(PGLFNGLFOGCOORDPOINTEREXTPROC, \ + glFogCoordPointerEXT, EXT_FOG_COORD, NULL) \ + /* GL_EXT_framebuffer_blit */ \ + USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFEREXTPROC, \ + glBlitFramebufferEXT, EXT_FRAMEBUFFER_BLIT, NULL) \ + /* GL_EXT_framebuffer_multisample */ \ + USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC, \ + glRenderbufferStorageMultisampleEXT, EXT_FRAMEBUFFER_MULTISAMPLE, NULL) \ + /* GL_EXT_framebuffer_object */ \ + USE_GL_FUNC(PGLFNGLISRENDERBUFFEREXTPROC, \ + glIsRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBINDRENDERBUFFEREXTPROC, \ + glBindRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSEXTPROC, \ + glDeleteRenderbuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSEXTPROC, \ + glGenRenderbuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEEXTPROC, \ + glRenderbufferStorageEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLISFRAMEBUFFEREXTPROC, \ + glIsFramebufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFEREXTPROC, \ + glBindFramebufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSEXTPROC, \ + glDeleteFramebuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSEXTPROC, \ + glGenFramebuffersEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, \ + glCheckFramebufferStatusEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC, \ + glFramebufferTexture1DEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC, \ + glFramebufferTexture2DEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC, \ + glFramebufferTexture3DEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC, \ + glFramebufferRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGENERATEMIPMAPEXTPROC, \ + glGenerateMipmapEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC, \ + glGetRenderbufferParameterivEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC, \ + glGetFramebufferAttachmentParameterivEXT, EXT_FRAMEBUFFER_OBJECT, NULL) \ + /* GL_EXT_gpu_program_parameters */ \ + USE_GL_FUNC(PGLFNPROGRAMENVPARAMETERS4FVEXTPROC, \ + glProgramEnvParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS, NULL) \ + USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC, \ + glProgramLocalParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS, NULL) \ + /* GL_EXT_gpu_shader4 */\ + USE_GL_FUNC(PGLFNVERTEXATTRIBI1IEXTPROC, \ + glVertexAttribI1iEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI2IEXTPROC, \ + glVertexAttribI2iEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI3IEXTPROC, \ + glVertexAttribI3iEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4IEXTPROC, \ + glVertexAttribI4iEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI1UIEXTPROC, \ + glVertexAttribI1uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI2UIEXTPROC, \ + glVertexAttribI2uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI3UIEXTPROC, \ + glVertexAttribI3uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4UIEXTPROC, \ + glVertexAttribI4uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI1IVEXTPROC, \ + glVertexAttribI1ivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI2IVEXTPROC, \ + glVertexAttribI2ivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI3IVEXTPROC, \ + glVertexAttribI3ivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4IVEXTPROC, \ + glVertexAttribI4ivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI1UIVEXTPROC, \ + glVertexAttribI1uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI2UIVEXTPROC, \ + glVertexAttribI2uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI3UIVEXTPROC, \ + glVertexAttribI3uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4UIVEXTPROC, \ + glVertexAttribI4uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4BVEXTPROC, \ + glVertexAttribI4bvEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4SVEXTPROC, \ + glVertexAttribI4svEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4UBVEXTPROC, \ + glVertexAttribI4ubvEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBI4USVEXTPROC, \ + glVertexAttribI4usvEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBIPOINTEREXTPROC, \ + glVertexAttribIPointerEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNGETVERTEXATTRIBIIVEXTPROC, \ + glVertexAttribIivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNGETVERTEXATTRIBIUIVEXTPROC, \ + glVertexAttribIuivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM1UIEXTPROC, \ + glUniform1uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM2UIEXTPROC, \ + glUniform2uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM3UIEXTPROC, \ + glUniform3uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM4UIEXTPROC, \ + glUniform4uiEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM1UIVEXTPROC, \ + glUniform1uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM2UIVEXTPROC, \ + glUniform2uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM3UIVEXTPROC, \ + glUniform3uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNUNIFORM4UIVEXTPROC, \ + glUniform4uivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNGETUNIFORMUIVEXTPROC, \ + glGetUniformuivEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNBINDFRAGDATALOCATIONEXTPROC, \ + glBindFragDataLocationEXT, EXT_GPU_SHADER4, NULL) \ + USE_GL_FUNC(PGLFNGETFRAGDATALOCATIONEXTPROC, \ + glGetFragDataLocationEXT, EXT_GPU_SHADER4, NULL) \ + /* GL_EXT_paletted_texture */ \ + USE_GL_FUNC(PGLFNGLCOLORTABLEEXTPROC, \ + glColorTableEXT, EXT_PALETTED_TEXTURE, NULL) \ + /* GL_EXT_point_parameters */ \ + USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC, \ + glPointParameterfEXT, EXT_POINT_PARAMETERS, NULL) \ + USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC, \ + glPointParameterfvEXT, EXT_POINT_PARAMETERS, NULL) \ + /* GL_EXT_provoking_vertex */ \ + USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXEXTPROC, \ + glProvokingVertexEXT, EXT_PROVOKING_VERTEX, NULL) \ + /* GL_EXT_secondary_color */ \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC, \ + glSecondaryColor3ubEXT, EXT_SECONDARY_COLOR, NULL) \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBVEXTPROC, \ + glSecondaryColor3ubvEXT, EXT_SECONDARY_COLOR, NULL) \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FEXTPROC, \ + glSecondaryColor3fEXT, EXT_SECONDARY_COLOR, NULL) \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FVEXTPROC, \ + glSecondaryColor3fvEXT, EXT_SECONDARY_COLOR, NULL) \ + USE_GL_FUNC(PGLFNGLSECONDARYCOLORPOINTEREXTPROC, \ + glSecondaryColorPointerEXT, EXT_SECONDARY_COLOR, NULL) \ + /* GL_EXT_stencil_two_side */ \ + USE_GL_FUNC(PGLFNACTIVESTENCILFACEEXTPROC, \ + glActiveStencilFaceEXT, EXT_STENCIL_TWO_SIDE, NULL) \ + /* GL_EXT_texture3D */ \ + USE_GL_FUNC(PGLFNGLTEXIMAGE3DEXTPROC, \ + glTexImage3DEXT, EXT_TEXTURE3D, glTexImage3D) \ + USE_GL_FUNC(PGLFNGLTEXSUBIMAGE3DEXTPROC, \ + glTexSubImage3DEXT, EXT_TEXTURE3D, glTexSubImage3D) \ + /* GL_NV_fence */ \ + USE_GL_FUNC(PGLFNGENFENCESNVPROC, \ + glGenFencesNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNDELETEFENCESNVPROC, \ + glDeleteFencesNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNSETFENCENVPROC, \ + glSetFenceNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNTESTFENCENVPROC, \ + glTestFenceNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNFINISHFENCENVPROC, \ + glFinishFenceNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNISFENCENVPROC, \ + glIsFenceNV, NV_FENCE, NULL) \ + USE_GL_FUNC(PGLFNGETFENCEIVNVPROC, \ + glGetFenceivNV, NV_FENCE, NULL) \ + /* GL_NV_half_float */ \ + USE_GL_FUNC(PGLFNVERTEX2HNVPROC, \ + glVertex2hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX2HVNVPROC, \ + glVertex2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX3HNVPROC, \ + glVertex3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX3HVNVPROC, \ + glVertex3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX4HNVPROC, \ + glVertex4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEX4HVNVPROC, \ + glVertex4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNNORMAL3HNVPROC, \ + glNormal3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNNORMAL3HVNVPROC, \ + glNormal3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNCOLOR3HNVPROC, \ + glColor3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNCOLOR3HVNVPROC, \ + glColor3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNCOLOR4HNVPROC, \ + glColor4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNCOLOR4HVNVPROC, \ + glColor4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD1HNVPROC, \ + glTexCoord1hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD1HVNVPROC, \ + glTexCoord1hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD2HNVPROC, \ + glTexCoord2hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD2HVNVPROC, \ + glTexCoord2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD3HNVPROC, \ + glTexCoord3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD3HVNVPROC, \ + glTexCoord3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD4HNVPROC, \ + glTexCoord4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNTEXCOORD4HVNVPROC, \ + glTexCoord4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD1HNVPROC, \ + glMultiTexCoord1hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD1HVNVPROC, \ + glMultiTexCoord1hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD2HNVPROC, \ + glMultiTexCoord2hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD2HVNVPROC, \ + glMultiTexCoord2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD3HNVPROC, \ + glMultiTexCoord3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD3HVNVPROC, \ + glMultiTexCoord3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD4HNVPROC, \ + glMultiTexCoord4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNMULTITEXCOORD4HVNVPROC, \ + glMultiTexCoord4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNFOGCOORDHNVPROC, \ + glFogCoordhNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNFOGCOORDHVNVPROC, \ + glFogCoordhvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNSECONDARYCOLOR3HNVPROC, \ + glSecondaryColor3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNSECONDARYCOLOR3HVNVPROC, \ + glSecondaryColor3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXWEIGHTHNVPROC, \ + glVertexWeighthNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXWEIGHTHVNVPROC, \ + glVertexWeighthvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1HNVPROC, \ + glVertexAttrib1hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB1HVNVPROC, \ + glVertexAttrib1hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2HNVPROC, \ + glVertexAttrib2hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB2HVNVPROC, \ + glVertexAttrib2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3HNVPROC, \ + glVertexAttrib3hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB3HVNVPROC, \ + glVertexAttrib3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4HNVPROC, \ + glVertexAttrib4hNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIB4HVNVPROC, \ + glVertexAttrib4hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBS1HVNVPROC, \ + glVertexAttribs1hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBS2HVNVPROC, \ + glVertexAttribs2hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBS3HVNVPROC, \ + glVertexAttribs3hvNV, NV_HALF_FLOAT, NULL) \ + USE_GL_FUNC(PGLFNVERTEXATTRIBS4HVNVPROC, \ + glVertexAttribs4hvNV, NV_HALF_FLOAT, NULL) \ + /* GL_NV_register_combiners */ \ + USE_GL_FUNC(PGLFNCOMBINERINPUTNVPROC, \ + glCombinerInputNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINEROUTPUTNVPROC, \ + glCombinerOutputNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINERPARAMETERFNVPROC, \ + glCombinerParameterfNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINERPARAMETERFVNVPROC, \ + glCombinerParameterfvNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINERPARAMETERINVPROC, \ + glCombinerParameteriNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNCOMBINERPARAMETERIVNVPROC, \ + glCombinerParameterivNV, NV_REGISTER_COMBINERS, NULL) \ + USE_GL_FUNC(PGLFNFINALCOMBINERINPUTNVPROC, \ + glFinalCombinerInputNV, NV_REGISTER_COMBINERS, NULL) \ + /* GLX_SGI_video_sync */ \ + USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC, \ + glXGetVideoSyncSGI, SGI_VIDEO_SYNC, NULL) \ + USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC, \ + glXWaitVideoSyncSGI, SGI_VIDEO_SYNC, NULL) #define WGL_EXT_FUNCS_GEN \ - USE_GL_FUNC(WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC, wglGetPixelFormatAttribivARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC, wglGetPixelFormatAttribfvARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLMAKECONTEXTCURRENTARBPROC, wglMakeContextCurrentARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLGETCURRENTREADDCARBPROC, wglGetCurrentReadDCARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB, 0, NULL) \ - USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE, wglSetPixelFormatWINE, 0, NULL) - - -/**************************************************** - * Structures - ****************************************************/ - -struct wined3d_fbo_ops -{ - PGLFNGLISRENDERBUFFERPROC glIsRenderbuffer; - PGLFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; - PGLFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; - PGLFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; - PGLFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; - PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; - PGLFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv; - PGLFNGLISFRAMEBUFFERPROC glIsFramebuffer; - PGLFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; - PGLFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; - PGLFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; - PGLFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; - PGLFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; - PGLFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; - PGLFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; - PGLFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; - PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv; - PGLFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; - PGLFNGLGENERATEMIPMAPPROC glGenerateMipmap; -}; - -struct wined3d_gl_limits -{ - UINT buffers; - UINT lights; - UINT textures; - UINT texture_stages; - UINT fragment_samplers; - UINT vertex_samplers; - UINT combined_samplers; - UINT sampler_stages; - UINT clipplanes; - UINT texture_size; - UINT texture3d_size; - float pointsize_max; - float pointsize_min; - UINT point_sprite_units; - UINT blends; - UINT anisotropy; - float shininess; - - UINT glsl_varyings; - UINT glsl_vs_float_constants; - UINT glsl_ps_float_constants; - - UINT arb_vs_float_constants; - UINT arb_vs_native_constants; - UINT arb_vs_instructions; - UINT arb_vs_temps; - UINT arb_ps_float_constants; - UINT arb_ps_local_constants; - UINT arb_ps_native_constants; - UINT arb_ps_instructions; - UINT arb_ps_temps; -}; - -#define USE_GL_FUNC(type, pfn, ext, replace) type pfn; - -struct wined3d_gl_info -{ - UINT vidmem; - struct wined3d_gl_limits limits; - DWORD reserved_glsl_constants; - DWORD quirks; - BOOL supported[WINED3D_GL_EXT_COUNT]; - GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1]; - - struct wined3d_fbo_ops fbo_ops; - /* GL function pointers */ - GL_EXT_FUNCS_GEN - /* WGL function pointers */ - WGL_EXT_FUNCS_GEN - - struct GlPixelFormatDesc *gl_formats; -}; - -#undef USE_GL_FUNC + USE_GL_FUNC(WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC, wglGetPixelFormatAttribivARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC, wglGetPixelFormatAttribfvARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB, 0, NULL) \ + USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE, wglSetPixelFormatWINE, 0, NULL) #endif /* __WINE_WINED3D_GL */ diff --git a/dll/directx/wine/wined3d/wined3d_private.h b/dll/directx/wine/wined3d/wined3d_private.h index de0bcdc2c54..1d5cd974645 100644 --- a/dll/directx/wine/wined3d/wined3d_private.h +++ b/dll/directx/wine/wined3d/wined3d_private.h @@ -61,15 +61,16 @@ enum fixup_channel_source CHANNEL_SOURCE_Y = 3, CHANNEL_SOURCE_Z = 4, CHANNEL_SOURCE_W = 5, - CHANNEL_SOURCE_YUV0 = 6, - CHANNEL_SOURCE_YUV1 = 7, + CHANNEL_SOURCE_COMPLEX0 = 6, + CHANNEL_SOURCE_COMPLEX1 = 7, }; -enum yuv_fixup +enum complex_fixup { - YUV_FIXUP_YUY2 = 0, - YUV_FIXUP_UYVY = 1, - YUV_FIXUP_YV12 = 2, + COMPLEX_FIXUP_YUY2 = 0, + COMPLEX_FIXUP_UYVY = 1, + COMPLEX_FIXUP_YV12 = 2, + COMPLEX_FIXUP_P8 = 3, }; #include @@ -103,14 +104,14 @@ static inline struct color_fixup_desc create_color_fixup_desc( return fixup; } -static inline struct color_fixup_desc create_yuv_fixup_desc(enum yuv_fixup yuv_fixup) +static inline struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup) { struct color_fixup_desc fixup = { - 0, yuv_fixup & (1 << 0) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0, - 0, yuv_fixup & (1 << 1) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0, - 0, yuv_fixup & (1 << 2) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0, - 0, yuv_fixup & (1 << 3) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0, + 0, complex_fixup & (1 << 0) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0, + 0, complex_fixup & (1 << 1) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0, + 0, complex_fixup & (1 << 2) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0, + 0, complex_fixup & (1 << 3) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0, }; return fixup; } @@ -120,19 +121,19 @@ static inline BOOL is_identity_fixup(struct color_fixup_desc fixup) return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup)); } -static inline BOOL is_yuv_fixup(struct color_fixup_desc fixup) +static inline BOOL is_complex_fixup(struct color_fixup_desc fixup) { - return fixup.x_source == CHANNEL_SOURCE_YUV0 || fixup.x_source == CHANNEL_SOURCE_YUV1; + return fixup.x_source == CHANNEL_SOURCE_COMPLEX0 || fixup.x_source == CHANNEL_SOURCE_COMPLEX1; } -static inline enum yuv_fixup get_yuv_fixup(struct color_fixup_desc fixup) +static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup) { - enum yuv_fixup yuv_fixup = 0; - if (fixup.x_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 0); - if (fixup.y_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 1); - if (fixup.z_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 2); - if (fixup.w_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 3); - return yuv_fixup; + enum complex_fixup complex_fixup = 0; + if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 0); + if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 1); + if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 2); + if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 3); + return complex_fixup; } void *wined3d_rb_alloc(size_t size) DECLSPEC_HIDDEN; @@ -410,6 +411,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER WINED3DSIH_CMP, WINED3DSIH_CND, WINED3DSIH_CRS, + WINED3DSIH_CUT, WINED3DSIH_DCL, WINED3DSIH_DEF, WINED3DSIH_DEFB, @@ -421,20 +423,24 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER WINED3DSIH_DSX, WINED3DSIH_DSY, WINED3DSIH_ELSE, + WINED3DSIH_EMIT, WINED3DSIH_ENDIF, WINED3DSIH_ENDLOOP, WINED3DSIH_ENDREP, WINED3DSIH_EXP, WINED3DSIH_EXPP, WINED3DSIH_FRC, + WINED3DSIH_IADD, WINED3DSIH_IF, WINED3DSIH_IFC, + WINED3DSIH_IGE, WINED3DSIH_LABEL, WINED3DSIH_LIT, WINED3DSIH_LOG, WINED3DSIH_LOGP, WINED3DSIH_LOOP, WINED3DSIH_LRP, + WINED3DSIH_LT, WINED3DSIH_M3x2, WINED3DSIH_M3x3, WINED3DSIH_M3x4, @@ -544,6 +550,7 @@ typedef struct shader_reg_maps struct wined3d_shader_context { IWineD3DBaseShader *shader; + const struct wined3d_gl_info *gl_info; const struct shader_reg_maps *reg_maps; struct wined3d_shader_buffer *buffer; void *backend_data; @@ -619,7 +626,7 @@ struct wined3d_shader_frontend void (*shader_read_dst_param)(void *data, const DWORD **ptr, struct wined3d_shader_dst_param *dst_param, struct wined3d_shader_src_param *dst_rel_addr); void (*shader_read_semantic)(const DWORD **ptr, struct wined3d_shader_semantic *semantic); - void (*shader_read_comment)(const DWORD **ptr, const char **comment); + void (*shader_read_comment)(const DWORD **ptr, const char **comment, UINT *comment_size); BOOL (*shader_is_end)(void *data, const DWORD **ptr); }; @@ -714,7 +721,7 @@ typedef struct { HRESULT (*shader_alloc_private)(IWineD3DDevice *iface); void (*shader_free_private)(IWineD3DDevice *iface); BOOL (*shader_dirtifyable_constants)(IWineD3DDevice *iface); - void (*shader_get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct shader_caps *caps); + void (*shader_get_caps)(const struct wined3d_gl_info *gl_info, struct shader_caps *caps); BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup); void (*shader_add_instruction_modifiers)(const struct wined3d_shader_instruction *ins); } shader_backend_t; @@ -988,8 +995,10 @@ extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(MAX_CLIPPLANES - 1)) #define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIPPLANES)) +#define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL) #define STATE_FRONTFACE (STATE_MATERIAL + 1) +#define STATE_IS_FRONTFACE(a) ((a) == STATE_FRONTFACE) #define STATE_HIGHEST (STATE_FRONTFACE) @@ -1008,13 +1017,28 @@ struct wined3d_occlusion_query struct wined3d_context *context; }; +union wined3d_gl_query_object +{ + GLuint id; + GLsync sync; +}; + struct wined3d_event_query { struct list entry; - GLuint id; + union wined3d_gl_query_object object; struct wined3d_context *context; }; +enum wined3d_event_query_result +{ + WINED3D_EVENT_QUERY_OK, + WINED3D_EVENT_QUERY_WAITING, + WINED3D_EVENT_QUERY_NOT_STARTED, + WINED3D_EVENT_QUERY_WRONG_THREAD, + WINED3D_EVENT_QUERY_ERROR +}; + struct wined3d_context { const struct wined3d_gl_info *gl_info; @@ -1084,7 +1108,7 @@ struct wined3d_context UINT free_occlusion_query_count; struct list occlusion_queries; - GLuint *free_event_queries; + union wined3d_gl_query_object *free_event_queries; UINT free_event_query_size; UINT free_event_query_count; struct list event_queries; @@ -1122,7 +1146,7 @@ struct fragment_caps struct fragment_pipeline { void (*enable_extension)(IWineD3DDevice *iface, BOOL enable); - void (*get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps); + void (*get_caps)(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps); HRESULT (*alloc_private)(IWineD3DDevice *iface); void (*free_private)(IWineD3DDevice *iface); BOOL (*color_fixup_supported)(struct color_fixup_desc fixup); @@ -1224,7 +1248,7 @@ typedef struct WineD3D_PixelFormat { int iPixelFormat; /* WGL pixel format */ int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */ - int redSize, greenSize, blueSize, alphaSize; + int redSize, greenSize, blueSize, alphaSize, colorSize; int depthSize, stencilSize; BOOL windowDrawable; BOOL pbufferDrawable; @@ -1233,13 +1257,23 @@ typedef struct WineD3D_PixelFormat int numSamples; } WineD3D_PixelFormat; +enum wined3d_gl_vendor +{ + GL_VENDOR_WINE, + GL_VENDOR_APPLE, + GL_VENDOR_ATI, + GL_VENDOR_INTEL, + GL_VENDOR_MESA, + GL_VENDOR_NVIDIA, +}; + + enum wined3d_pci_vendor { - VENDOR_WINE = 0x0000, - VENDOR_MESA = 0x0001, - VENDOR_ATI = 0x1002, - VENDOR_NVIDIA = 0x10de, - VENDOR_INTEL = 0x8086, + HW_VENDOR_WINE = 0x0000, + HW_VENDOR_ATI = 0x1002, + HW_VENDOR_NVIDIA = 0x10de, + HW_VENDOR_INTEL = 0x8086, }; enum wined3d_pci_device @@ -1323,6 +1357,85 @@ enum wined3d_pci_device CARD_INTEL_X3100 = 0x2a02, /* Found in Macs. Same as GMA 965? */ }; +struct wined3d_fbo_ops +{ + PGLFNGLISRENDERBUFFERPROC glIsRenderbuffer; + PGLFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; + PGLFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; + PGLFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; + PGLFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; + PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; + PGLFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv; + PGLFNGLISFRAMEBUFFERPROC glIsFramebuffer; + PGLFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; + PGLFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; + PGLFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; + PGLFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; + PGLFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; + PGLFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; + PGLFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; + PGLFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; + PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv; + PGLFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; + PGLFNGLGENERATEMIPMAPPROC glGenerateMipmap; +}; + +struct wined3d_gl_limits +{ + UINT buffers; + UINT lights; + UINT textures; + UINT texture_stages; + UINT fragment_samplers; + UINT vertex_samplers; + UINT combined_samplers; + UINT general_combiners; + UINT sampler_stages; + UINT clipplanes; + UINT texture_size; + UINT texture3d_size; + float pointsize_max; + float pointsize_min; + UINT point_sprite_units; + UINT blends; + UINT anisotropy; + float shininess; + + UINT glsl_varyings; + UINT glsl_vs_float_constants; + UINT glsl_ps_float_constants; + + UINT arb_vs_float_constants; + UINT arb_vs_native_constants; + UINT arb_vs_instructions; + UINT arb_vs_temps; + UINT arb_ps_float_constants; + UINT arb_ps_local_constants; + UINT arb_ps_native_constants; + UINT arb_ps_instructions; + UINT arb_ps_temps; +}; + +struct wined3d_gl_info +{ + UINT vidmem; + struct wined3d_gl_limits limits; + DWORD reserved_glsl_constants; + DWORD quirks; + BOOL supported[WINED3D_GL_EXT_COUNT]; + GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1]; + + struct wined3d_fbo_ops fbo_ops; +#define USE_GL_FUNC(type, pfn, ext, replace) type pfn; + /* GL function pointers */ + GL_EXT_FUNCS_GEN + /* WGL function pointers */ + WGL_EXT_FUNCS_GEN +#undef USE_GL_FUNC + + struct GlPixelFormatDesc *gl_formats; +}; + struct wined3d_driver_info { enum wined3d_pci_vendor vendor; @@ -1348,6 +1461,10 @@ struct wined3d_adapter unsigned int TextureRam; /* Amount of texture memory both video ram + AGP/TurboCache/HyperMemory/.. */ unsigned int UsedTextureRam; LUID luid; + + const struct fragment_pipeline *fragment_pipe; + const shader_backend_t *shader_backend; + const struct blit_shader *blitter; }; BOOL initPixelFormats(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor) DECLSPEC_HIDDEN; @@ -1497,7 +1614,7 @@ struct IWineD3DDeviceImpl const struct fragment_pipeline *frag_pipe; const struct blit_shader *blitter; - unsigned int max_ffp_textures, max_ffp_texture_stages; + unsigned int max_ffp_textures; DWORD d3d_vshader_constantF, d3d_pshader_constantF; /* Advertised d3d caps, not GL ones */ DWORD vs_clipping; @@ -1547,7 +1664,6 @@ struct IWineD3DDeviceImpl UINT NumberOfPalettes; PALETTEENTRY **palettes; UINT currentPalette; - UINT paletteConversionShader; /* For rendering to a texture using glCopyTexImage */ GLenum *draw_buffers; @@ -1602,14 +1718,14 @@ struct IWineD3DDeviceImpl HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags, IUnknown *parent, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN; +void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN; LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN; void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN; void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN; void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN; -void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, - const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info) DECLSPEC_HIDDEN; +void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count, const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) DECLSPEC_HIDDEN; void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) DECLSPEC_HIDDEN; @@ -1745,6 +1861,7 @@ typedef struct IWineD3DBaseTextureClass void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN; BOOL surface_init_sysmem(IWineD3DSurface *iface) DECLSPEC_HIDDEN; BOOL surface_is_offscreen(IWineD3DSurface *iface) DECLSPEC_HIDDEN; +void surface_prepare_texture(IWineD3DSurfaceImpl *surface, BOOL srgb) DECLSPEC_HIDDEN; typedef struct IWineD3DBaseTextureImpl { @@ -2342,9 +2459,8 @@ typedef struct IWineD3DQueryImpl void *extendedData; } IWineD3DQueryImpl; -extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl DECLSPEC_HIDDEN; -extern const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl DECLSPEC_HIDDEN; -extern const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl DECLSPEC_HIDDEN; +HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, + WINED3DQUERYTYPE type, IUnknown *parent) DECLSPEC_HIDDEN; /* IWineD3DBuffer */ @@ -2495,6 +2611,7 @@ const char *debug_d3ddeclusage(BYTE usage) DECLSPEC_HIDDEN; const char *debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType) DECLSPEC_HIDDEN; const char *debug_d3drenderstate(DWORD state) DECLSPEC_HIDDEN; const char *debug_d3dsamplerstate(DWORD state) DECLSPEC_HIDDEN; +const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN; const char *debug_d3dtexturefiltertype(WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN; const char *debug_d3dtexturestate(DWORD state) DECLSPEC_HIDDEN; const char *debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype) DECLSPEC_HIDDEN; @@ -2552,12 +2669,6 @@ void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED UINT wined3d_log2i(UINT32 x) DECLSPEC_HIDDEN; unsigned int count_bits(unsigned int mask) DECLSPEC_HIDDEN; -const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, - WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN; -const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter, - WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN; -const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, - WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN; void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected) DECLSPEC_HIDDEN; typedef struct local_constant { @@ -2601,8 +2712,6 @@ int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *fmt, va_li extern BOOL vshader_get_input(IWineD3DVertexShader *iface, BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN; -extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) DECLSPEC_HIDDEN; - /***************************************************************************** * IDirect3DBaseShader implementation structure */ @@ -2651,7 +2760,6 @@ typedef struct IWineD3DBaseShaderImpl { void shader_buffer_clear(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN; BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN; void shader_buffer_free(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN; -void shader_cleanup(IWineD3DBaseShader *iface) DECLSPEC_HIDDEN; void shader_dump_src_param(const struct wined3d_shader_src_param *param, const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN; void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, @@ -2659,16 +2767,7 @@ void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) DECLSPEC_HIDDEN; void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer, const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) DECLSPEC_HIDDEN; -HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe, - struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature, - struct wined3d_shader_signature_element *output_signature, - const DWORD *byte_code, DWORD constf_size) DECLSPEC_HIDDEN; -void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device, - IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN; BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) DECLSPEC_HIDDEN; -const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) DECLSPEC_HIDDEN; -void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) DECLSPEC_HIDDEN; -WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *semantic_name) DECLSPEC_HIDDEN; static inline BOOL shader_is_pshader_version(enum wined3d_shader_type type) { diff --git a/dll/win32/actxprxy/actxprxy.rbuild b/dll/win32/actxprxy/actxprxy.rbuild index 87a50a17c83..f5272b585cf 100644 --- a/dll/win32/actxprxy/actxprxy.rbuild +++ b/dll/win32/actxprxy/actxprxy.rbuild @@ -9,20 +9,29 @@ . wine - actxprxy_interface actxprxy_proxy ntdll rpcrt4 + ole32 + oleaut32 + uuid pseh usrmarshal.c - - actxprxy_servprov.idl - - "{ 0xb8da6310, 0xe19b, 0x11d0, { 0x93, 0x3c, 0x00, 0xa0, 0xc9, 0x0d, 0xca, 0xa9 } }" + + actxprxy_activscp.idl + actxprxy_comcat.idl + actxprxy_docobj.idl + actxprxy_hlink.idl + actxprxy_htiframe.idl + actxprxy_objsafe.idl + actxprxy_ocmm.idl actxprxy_servprov.idl + + actxprxy_urlhist.idl + diff --git a/base/system/msiexec/version.rc b/dll/win32/actxprxy/actxprxy_activscp.idl similarity index 64% rename from base/system/msiexec/version.rc rename to dll/win32/actxprxy/actxprxy_activscp.idl index 077759431e2..c056a0ebd15 100644 --- a/base/system/msiexec/version.rc +++ b/dll/win32/actxprxy/actxprxy_activscp.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004 Mike McCormack + * Copyright 2009 Alexandre Julliard * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -16,13 +16,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WINE_FILEDESCRIPTION_STR "Wine Installer" -#define WINE_FILENAME_STR "msiexec.exe" -#define WINE_FILETYPE VFT_APP -#define WINE_FILEVERSION 3,1,4000,1823 -#define WINE_FILEVERSION_STR "3.1.4000.1823" -#define WINE_PRODUCTVERSION 3,1,4000,1823 -#define WINE_PRODUCTVERSION_STR "3.1.4000.1823" -#define WINE_PRODUCTNAME_STR "Wine Installer" +/* just a wrapper for activscp.idl */ -#include "wine/wine_common_ver.rc" +#include "activscp.idl" diff --git a/dll/win32/actxprxy/actxprxy_comcat.idl b/dll/win32/actxprxy/actxprxy_comcat.idl new file mode 100644 index 00000000000..6c8155fe29f --- /dev/null +++ b/dll/win32/actxprxy/actxprxy_comcat.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for comcat.idl */ + +#include "comcat.idl" diff --git a/dll/win32/actxprxy/actxprxy_docobj.idl b/dll/win32/actxprxy/actxprxy_docobj.idl new file mode 100644 index 00000000000..711c3851e3d --- /dev/null +++ b/dll/win32/actxprxy/actxprxy_docobj.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for docobj.idl */ + +#include "docobj.idl" diff --git a/dll/win32/actxprxy/actxprxy_hlink.idl b/dll/win32/actxprxy/actxprxy_hlink.idl new file mode 100644 index 00000000000..820967d2de4 --- /dev/null +++ b/dll/win32/actxprxy/actxprxy_hlink.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for hlink.idl */ + +#include "hlink.idl" diff --git a/dll/win32/actxprxy/actxprxy_htiframe.idl b/dll/win32/actxprxy/actxprxy_htiframe.idl new file mode 100644 index 00000000000..146b0a2e4c6 --- /dev/null +++ b/dll/win32/actxprxy/actxprxy_htiframe.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for htiframe.idl */ + +#include "htiframe.idl" diff --git a/dll/win32/actxprxy/actxprxy_objsafe.idl b/dll/win32/actxprxy/actxprxy_objsafe.idl new file mode 100644 index 00000000000..67e878b69cd --- /dev/null +++ b/dll/win32/actxprxy/actxprxy_objsafe.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for objsafe.idl */ + +#include "objsafe.idl" diff --git a/dll/win32/actxprxy/actxprxy_ocmm.idl b/dll/win32/actxprxy/actxprxy_ocmm.idl new file mode 100644 index 00000000000..2df49ce8995 --- /dev/null +++ b/dll/win32/actxprxy/actxprxy_ocmm.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for ocmm.idl */ + +#include "ocmm.idl" diff --git a/dll/win32/actxprxy/actxprxy_shobjidl.idl b/dll/win32/actxprxy/actxprxy_shobjidl.idl new file mode 100644 index 00000000000..71912fd0eb4 --- /dev/null +++ b/dll/win32/actxprxy/actxprxy_shobjidl.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for shobjidl.idl */ + +#include "shobjidl.idl" diff --git a/dll/win32/actxprxy/actxprxy_urlhist.idl b/dll/win32/actxprxy/actxprxy_urlhist.idl new file mode 100644 index 00000000000..18861b3a713 --- /dev/null +++ b/dll/win32/actxprxy/actxprxy_urlhist.idl @@ -0,0 +1,21 @@ +/* + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* just a wrapper for urlhist.idl */ + +#include "urlhist.idl" diff --git a/dll/win32/actxprxy/usrmarshal.c b/dll/win32/actxprxy/usrmarshal.c index 9d5318fcec5..f2aacf85a30 100644 --- a/dll/win32/actxprxy/usrmarshal.c +++ b/dll/win32/actxprxy/usrmarshal.c @@ -32,6 +32,8 @@ #include "winerror.h" #include "objbase.h" #include "servprov.h" +#include "comcat.h" +#include "docobj.h" #include "wine/debug.h" @@ -62,3 +64,107 @@ HRESULT __RPC_STUB IServiceProvider_QueryService_Stub( return IServiceProvider_QueryService(This, guidService, riid, (void **)ppvObject); } + +HRESULT CALLBACK ICatInformation_EnumClassesOfCategories_Proxy( + ICatInformation *This, + ULONG cImplemented, + CATID rgcatidImpl[], + ULONG cRequired, + CATID rgcatidReq[], + IEnumCLSID** ppenumClsid ) +{ + TRACE("(%p)\n", This); + return ICatInformation_RemoteEnumClassesOfCategories_Proxy( This, cImplemented, rgcatidImpl, + cRequired, rgcatidReq, ppenumClsid ); +} + +HRESULT __RPC_STUB ICatInformation_EnumClassesOfCategories_Stub( + ICatInformation *This, + ULONG cImplemented, + CATID rgcatidImpl[], + ULONG cRequired, + CATID rgcatidReq[], + IEnumCLSID** ppenumClsid ) +{ + TRACE("(%p)\n", This); + return ICatInformation_EnumClassesOfCategories( This, cImplemented, rgcatidImpl, + cRequired, rgcatidReq, ppenumClsid ); +} + +HRESULT CALLBACK ICatInformation_IsClassOfCategories_Proxy( + ICatInformation *This, + REFCLSID rclsid, + ULONG cImplemented, + CATID rgcatidImpl[], + ULONG cRequired, + CATID rgcatidReq[] ) +{ + TRACE("(%p)\n", This); + return ICatInformation_RemoteIsClassOfCategories_Proxy( This, rclsid, cImplemented, rgcatidImpl, + cRequired, rgcatidReq ); +} + +HRESULT __RPC_STUB ICatInformation_IsClassOfCategories_Stub( + ICatInformation *This, + REFCLSID rclsid, + ULONG cImplemented, + CATID rgcatidImpl[], + ULONG cRequired, + CATID rgcatidReq[] ) +{ + TRACE("(%p)\n", This); + return ICatInformation_IsClassOfCategories( This, rclsid, cImplemented, rgcatidImpl, + cRequired, rgcatidReq ); +} + +HRESULT CALLBACK IPrint_Print_Proxy( + IPrint *This, + DWORD grfFlags, + DVTARGETDEVICE **pptd, + PAGESET **ppPageSet, + STGMEDIUM *pstgmOptions, + IContinueCallback *pcallback, + LONG nFirstPage, + LONG *pcPagesPrinted, + LONG *pnLastPage ) +{ + TRACE("(%p)\n", This); + return IPrint_RemotePrint_Proxy( This, grfFlags, pptd, ppPageSet, (RemSTGMEDIUM *)pstgmOptions, + pcallback, nFirstPage, pcPagesPrinted, pnLastPage ); +} + +HRESULT __RPC_STUB IPrint_Print_Stub( + IPrint *This, + DWORD grfFlags, + DVTARGETDEVICE **pptd, + PAGESET **ppPageSet, + RemSTGMEDIUM *pstgmOptions, + IContinueCallback *pcallback, + LONG nFirstPage, + LONG *pcPagesPrinted, + LONG *pnLastPage ) +{ + TRACE("(%p)\n", This); + return IPrint_Print( This, grfFlags, pptd, ppPageSet, (STGMEDIUM *)pstgmOptions, + pcallback, nFirstPage, pcPagesPrinted, pnLastPage ); +} + +HRESULT CALLBACK IEnumOleDocumentViews_Next_Proxy( + IEnumOleDocumentViews *This, + ULONG cViews, + IOleDocumentView **rgpView, + ULONG *pcFetched ) +{ + TRACE("(%p)\n", This); + return IEnumOleDocumentViews_RemoteNext_Proxy( This, cViews, rgpView, pcFetched ); +} + +HRESULT __RPC_STUB IEnumOleDocumentViews_Next_Stub( + IEnumOleDocumentViews *This, + ULONG cViews, + IOleDocumentView **rgpView, + ULONG *pcFetched ) +{ + TRACE("(%p)\n", This); + return IEnumOleDocumentViews_Next( This, cViews, rgpView, pcFetched ); +} diff --git a/dll/win32/advapi32/service/sctrl.c b/dll/win32/advapi32/service/sctrl.c index 3094951b911..ca6f1648fe0 100644 --- a/dll/win32/advapi32/service/sctrl.c +++ b/dll/win32/advapi32/service/sctrl.c @@ -22,7 +22,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi); typedef struct _ACTIVE_SERVICE { - CLIENT_HANDLE hService; + SERVICE_STATUS_HANDLE hServiceStatus; UNICODE_STRING ServiceName; union { @@ -32,7 +32,6 @@ typedef struct _ACTIVE_SERVICE LPHANDLER_FUNCTION HandlerFunction; LPHANDLER_FUNCTION_EX HandlerFunctionEx; LPVOID HandlerContext; - SERVICE_STATUS ServiceStatus; BOOL bUnicode; LPWSTR Arguments; } ACTIVE_SERVICE, *PACTIVE_SERVICE; @@ -199,6 +198,7 @@ ScConnectControlPipe(HANDLE *hPipe) NTSTATUS Status; WCHAR NtControlPipeName[MAX_PATH + 1]; RTL_QUERY_REGISTRY_TABLE QueryTable[2]; + DWORD dwProcessId; /* Get the service number and create the named pipe */ RtlZeroMemory(&QueryTable, @@ -249,37 +249,34 @@ ScConnectControlPipe(HANDLE *hPipe) return ERROR_FAILED_SERVICE_CONTROLLER_CONNECT; } - /* Share the SERVICE_HANDLE handle with the SCM */ + /* Pass the ProcessId to the SCM */ + dwProcessId = GetCurrentProcessId(); WriteFile(*hPipe, - (DWORD *)&lpActiveServices->hService, - sizeof(CLIENT_HANDLE), + &dwProcessId, + sizeof(DWORD), &dwBytesWritten, NULL); - TRACE("Sent SERVICE_HANDLE %lu\n", lpActiveServices->hService); + TRACE("Sent Process ID %lu\n", dwProcessId); + return ERROR_SUCCESS; } static DWORD -ScStartService(PSCM_CONTROL_PACKET ControlPacket) +ScStartService(PACTIVE_SERVICE lpService, + PSCM_CONTROL_PACKET ControlPacket) { - PACTIVE_SERVICE lpService; HANDLE ThreadHandle; DWORD ThreadId; TRACE("ScStartService() called\n"); - TRACE("client handle: %lu\n", ControlPacket->hClient); TRACE("Size: %lu\n", ControlPacket->dwSize); TRACE("Service: %S\n", &ControlPacket->szArguments[0]); - lpService = (PACTIVE_SERVICE)ControlPacket->hClient; - if (lpService == NULL) - { - TRACE("Service not found\n"); - return ERROR_SERVICE_DOES_NOT_EXIST; - } + /* Set the service status handle */ + lpService->hServiceStatus = ControlPacket->hServiceStatus; lpService->Arguments = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, @@ -309,21 +306,13 @@ ScStartService(PSCM_CONTROL_PACKET ControlPacket) static DWORD -ScControlService(PSCM_CONTROL_PACKET ControlPacket) +ScControlService(PACTIVE_SERVICE lpService, + PSCM_CONTROL_PACKET ControlPacket) { - PACTIVE_SERVICE lpService; - TRACE("ScControlService() called\n"); TRACE("Size: %lu\n", ControlPacket->dwSize); TRACE("Service: %S\n", &ControlPacket->szArguments[0]); - lpService = (PACTIVE_SERVICE)ControlPacket->hClient; - if (lpService == NULL) - { - TRACE("Service not found\n"); - return ERROR_SERVICE_DOES_NOT_EXIST; - } - if (lpService->HandlerFunction) { (lpService->HandlerFunction)(ControlPacket->dwControl); @@ -356,6 +345,10 @@ ScServiceDispatcher(HANDLE hPipe, DWORD Count; BOOL bResult; DWORD dwRunningServices = 0; + LPWSTR lpServiceName; + PACTIVE_SERVICE lpService; + SCM_REPLY_PACKET ReplyPacket; + DWORD dwError; TRACE("ScDispatcherLoop() called\n"); @@ -379,25 +372,52 @@ ScServiceDispatcher(HANDLE hPipe, return FALSE; } - /* Execute command */ - switch (ControlPacket->dwControl) + lpServiceName = &ControlPacket->szArguments[0]; + TRACE("Service: %S\n", lpServiceName); + + lpService = ScLookupServiceByServiceName(lpServiceName); + if (lpService != NULL) { - case SERVICE_CONTROL_START: - TRACE("Start command - recieved SERVICE_CONTROL_START\n"); - if (ScStartService(ControlPacket) == ERROR_SUCCESS) - dwRunningServices++; - break; + /* Execute command */ + switch (ControlPacket->dwControl) + { + case SERVICE_CONTROL_START: + TRACE("Start command - recieved SERVICE_CONTROL_START\n"); + dwError = ScStartService(lpService, ControlPacket); + if (dwError == ERROR_SUCCESS) + dwRunningServices++; + break; - case SERVICE_CONTROL_STOP: - TRACE("Stop command - recieved SERVICE_CONTROL_STOP\n"); - if (ScControlService(ControlPacket) == ERROR_SUCCESS) - dwRunningServices--; - break; + case SERVICE_CONTROL_STOP: + TRACE("Stop command - recieved SERVICE_CONTROL_STOP\n"); + dwError = ScControlService(lpService, ControlPacket); + if (dwError == ERROR_SUCCESS) + dwRunningServices--; + break; - default: - TRACE("Command %lu received", ControlPacket->dwControl); - ScControlService(ControlPacket); - continue; + default: + TRACE("Command %lu received", ControlPacket->dwControl); + dwError = ScControlService(lpService, ControlPacket); + break; + } + } + else + { + dwError = ERROR_NOT_FOUND; + } + + ReplyPacket.dwError = dwError; + + /* Send the reply packet */ + bResult = WriteFile(hPipe, + &ReplyPacket, + sizeof(ReplyPacket), + &Count, + NULL); + if (bResult == FALSE) + { + ERR("Pipe write failed (Error: %lu)\n", GetLastError()); + return FALSE; } if (dwRunningServices == 0) @@ -461,9 +481,9 @@ RegisterServiceCtrlHandlerW(LPCWSTR lpServiceName, Service->HandlerFunction = lpHandlerProc; Service->HandlerFunctionEx = NULL; - TRACE("RegisterServiceCtrlHandler returning %lu\n", Service->hService); + TRACE("RegisterServiceCtrlHandler returning %lu\n", Service->hServiceStatus); - return (SERVICE_STATUS_HANDLE)Service->hService; + return Service->hServiceStatus; } @@ -520,9 +540,9 @@ RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, Service->HandlerFunctionEx = lpHandlerProc; Service->HandlerContext = lpContext; - TRACE("RegisterServiceCtrlHandlerEx returning %lu\n", Service->hService); + TRACE("RegisterServiceCtrlHandlerEx returning %lu\n", Service->hServiceStatus); - return (SERVICE_STATUS_HANDLE)Service->hService; + return Service->hServiceStatus; } @@ -631,9 +651,18 @@ SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, TRACE("SetServiceStatus() called\n"); TRACE("hServiceStatus %lu\n", hServiceStatus); - /* Call to services.exe using RPC */ - dwError = RSetServiceStatus((RPC_SERVICE_STATUS_HANDLE)hServiceStatus, - lpServiceStatus); + RpcTryExcept + { + /* Call to services.exe using RPC */ + dwError = RSetServiceStatus((RPC_SERVICE_STATUS_HANDLE)hServiceStatus, + lpServiceStatus); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + dwError = ScmRpcStatusToWinError(RpcExceptionCode()); + } + RpcEndExcept; + if (dwError != ERROR_SUCCESS) { ERR("ScmrSetServiceStatus() failed (Error %lu)\n", dwError); @@ -683,7 +712,7 @@ StartServiceCtrlDispatcherA(const SERVICE_TABLE_ENTRYA * lpServiceStartTable) RtlCreateUnicodeStringFromAsciiz(&lpActiveServices[i].ServiceName, lpServiceStartTable[i].lpServiceName); lpActiveServices[i].Main.lpFuncA = lpServiceStartTable[i].lpServiceProc; - lpActiveServices[i].hService = (CLIENT_HANDLE)&lpActiveServices[i]; + lpActiveServices[i].hServiceStatus = 0; lpActiveServices[i].bUnicode = FALSE; } @@ -773,7 +802,7 @@ StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW * lpServiceStartTable) RtlCreateUnicodeString(&lpActiveServices[i].ServiceName, lpServiceStartTable[i].lpServiceName); lpActiveServices[i].Main.lpFuncW = lpServiceStartTable[i].lpServiceProc; - lpActiveServices[i].hService = (CLIENT_HANDLE)&lpActiveServices[i]; + lpActiveServices[i].hServiceStatus = 0; lpActiveServices[i].bUnicode = TRUE; } diff --git a/dll/win32/atl/atl_ax.c b/dll/win32/atl/atl_ax.c index da595a4e24b..2afc7460328 100644 --- a/dll/win32/atl/atl_ax.c +++ b/dll/win32/atl/atl_ax.c @@ -1208,7 +1208,7 @@ HWND WINAPI AtlAxCreateDialogA(HINSTANCE hInst, LPCSTR name, HWND owner, DLGPROC int length; WCHAR *nameW; - if ( HIWORD(name) == 0 ) + if (IS_INTRESOURCE(name)) return AtlAxCreateDialogW( hInst, (LPCWSTR) name, owner, dlgProc, param ); length = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 ); diff --git a/dll/win32/atl/atl_main.c b/dll/win32/atl/atl_main.c index 374b0d26f24..75f9a11116c 100644 --- a/dll/win32/atl/atl_main.c +++ b/dll/win32/atl/atl_main.c @@ -97,6 +97,19 @@ HRESULT WINAPI AtlModuleInit(_ATL_MODULEW* pM, _ATL_OBJMAP_ENTRYW* p, HINSTANCE return S_OK; } +static _ATL_OBJMAP_ENTRYW_V1 *get_objmap_entry( _ATL_MODULEW *mod, unsigned int index ) +{ + _ATL_OBJMAP_ENTRYW_V1 *ret; + + if (mod->cbSize == ATLVer1Size) + ret = (_ATL_OBJMAP_ENTRYW_V1 *)mod->m_pObjMap + index; + else + ret = (_ATL_OBJMAP_ENTRYW_V1 *)(mod->m_pObjMap + index); + + if (!ret->pclsid) ret = NULL; + return ret; +} + HRESULT WINAPI AtlModuleLoadTypeLib(_ATL_MODULEW *pM, LPCOLESTR lpszIndex, BSTR *pbstrPath, ITypeLib **ppTypeLib) { @@ -158,6 +171,7 @@ HRESULT WINAPI AtlModuleAddTermFunc(_ATL_MODULEW *pM, _ATL_TERMFUNC *pFunc, DWOR HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEW *pM, DWORD dwClsContext, DWORD dwFlags) { + _ATL_OBJMAP_ENTRYW_V1 *obj; HRESULT hRes = S_OK; int i=0; @@ -166,10 +180,9 @@ HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEW *pM, DWORD dwClsContex if (pM == NULL) return E_INVALIDARG; - while(pM->m_pObjMap[i].pclsid != NULL) + while ((obj = get_objmap_entry( pM, i++ ))) { IUnknown* pUnknown; - _ATL_OBJMAP_ENTRYW *obj = &(pM->m_pObjMap[i]); HRESULT rc; TRACE("Registering object %i\n",i); @@ -185,7 +198,6 @@ HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEW *pM, DWORD dwClsContex IUnknown_Release(pUnknown); } } - i++; } return hRes; @@ -269,6 +281,7 @@ HRESULT WINAPI AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY* pE */ HRESULT WINAPI AtlModuleRegisterServer(_ATL_MODULEW* pM, BOOL bRegTypeLib, const CLSID* clsid) { + const _ATL_OBJMAP_ENTRYW_V1 *obj; int i; HRESULT hRes; @@ -277,12 +290,10 @@ HRESULT WINAPI AtlModuleRegisterServer(_ATL_MODULEW* pM, BOOL bRegTypeLib, const if (pM == NULL) return E_INVALIDARG; - for (i = 0; pM->m_pObjMap[i].pclsid != NULL; i++) /* register CLSIDs */ + for (i = 0; (obj = get_objmap_entry( pM, i )) != NULL; i++) /* register CLSIDs */ { - if (!clsid || IsEqualCLSID(pM->m_pObjMap[i].pclsid, clsid)) + if (!clsid || IsEqualCLSID(obj->pclsid, clsid)) { - const _ATL_OBJMAP_ENTRYW *obj = &pM->m_pObjMap[i]; - TRACE("Registering clsid %s\n", debugstr_guid(obj->pclsid)); hRes = obj->pfnUpdateRegistry(TRUE); /* register */ if (FAILED(hRes)) @@ -351,6 +362,7 @@ HRESULT WINAPI AtlUnmarshalPtr(IStream *stm, const IID *iid, IUnknown **ppUnk) HRESULT WINAPI AtlModuleGetClassObject(_ATL_MODULEW *pm, REFCLSID rclsid, REFIID riid, LPVOID *ppv) { + _ATL_OBJMAP_ENTRYW_V1 *obj; int i; HRESULT hres = CLASS_E_CLASSNOTAVAILABLE; @@ -359,12 +371,10 @@ HRESULT WINAPI AtlModuleGetClassObject(_ATL_MODULEW *pm, REFCLSID rclsid, if (pm == NULL) return E_INVALIDARG; - for (i = 0; pm->m_pObjMap[i].pclsid != NULL; i++) + for (i = 0; (obj = get_objmap_entry( pm, i )) != NULL; i++) { - if (IsEqualCLSID(pm->m_pObjMap[i].pclsid, rclsid)) + if (IsEqualCLSID(obj->pclsid, rclsid)) { - _ATL_OBJMAP_ENTRYW *obj = &pm->m_pObjMap[i]; - TRACE("found object %i\n", i); if (obj->pfnGetClassObject) { diff --git a/dll/win32/atl/atlbase.h b/dll/win32/atl/atlbase.h index 49c13e439a3..59cdddf1b77 100644 --- a/dll/win32/atl/atlbase.h +++ b/dll/win32/atl/atlbase.h @@ -33,6 +33,28 @@ typedef LPCWSTR (WINAPI _ATL_DESCRIPTIONFUNCW)(void); typedef const struct _ATL_CATMAP_ENTRY* (_ATL_CATMAPFUNC)(void); typedef void (WINAPI _ATL_TERMFUNC)(DWORD dw); +typedef struct _ATL_OBJMAP_ENTRYA_V1_TAG +{ + const CLSID* pclsid; + HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister); + _ATL_CREATORFUNC* pfnGetClassObject; + _ATL_CREATORFUNC* pfnCreateInstance; + IUnknown* pCF; + DWORD dwRegister; + _ATL_DESCRIPTIONFUNCA* pfnGetObjectDescription; +}_ATL_OBJMAP_ENTRYA_V1; + +typedef struct _ATL_OBJMAP_ENTRYW_V1_TAG +{ + const CLSID* pclsid; + HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister); + _ATL_CREATORFUNC* pfnGetClassObject; + _ATL_CREATORFUNC* pfnCreateInstance; + IUnknown* pCF; + DWORD dwRegister; + _ATL_DESCRIPTIONFUNCW* pfnGetObjectDescription; +} _ATL_OBJMAP_ENTRYW_V1; + typedef struct _ATL_OBJMAP_ENTRYA_TAG { const CLSID* pclsid; diff --git a/dll/win32/atl/registrar.c b/dll/win32/atl/registrar.c index b2efda989ad..70c1384ca9b 100644 --- a/dll/win32/atl/registrar.c +++ b/dll/win32/atl/registrar.c @@ -758,39 +758,44 @@ static HRESULT do_register_dll_server(IRegistrar *pRegistrar, LPCOLESTR wszDll, LPCOLESTR wszId, BOOL do_register, const struct _ATL_REGMAP_ENTRY* pMapEntries) { - WCHAR buf[MAX_PATH]; + IRegistrar *registrar; HRESULT hres; const struct _ATL_REGMAP_ENTRY *pMapEntry; static const WCHAR wszModule[] = {'M','O','D','U','L','E',0}; static const WCHAR wszRegistry[] = {'R','E','G','I','S','T','R','Y',0}; - static const WCHAR wszCLSID_ATLRegistrar[] = - {'C','L','S','I','D','_','A','T','L','R','e','g','i','s','t','r','a','r',0}; - if (!pRegistrar) - Registrar_create(NULL, &IID_IRegistrar, (void**)&pRegistrar); + if (pRegistrar) + registrar = pRegistrar; + else + Registrar_create(NULL, &IID_IRegistrar, (void**)®istrar); - IRegistrar_AddReplacement(pRegistrar, wszModule, wszDll); + IRegistrar_AddReplacement(registrar, wszModule, wszDll); for (pMapEntry = pMapEntries; pMapEntry && pMapEntry->szKey; pMapEntry++) - IRegistrar_AddReplacement(pRegistrar, pMapEntry->szKey, pMapEntry->szData); - - StringFromGUID2(&CLSID_ATLRegistrar, buf, sizeof(buf)/sizeof(buf[0])); - IRegistrar_AddReplacement(pRegistrar, wszCLSID_ATLRegistrar, buf); + IRegistrar_AddReplacement(registrar, pMapEntry->szKey, pMapEntry->szData); if(do_register) - hres = IRegistrar_ResourceRegisterSz(pRegistrar, wszDll, wszId, wszRegistry); + hres = IRegistrar_ResourceRegisterSz(registrar, wszDll, wszId, wszRegistry); else - hres = IRegistrar_ResourceUnregisterSz(pRegistrar, wszDll, wszId, wszRegistry); + hres = IRegistrar_ResourceUnregisterSz(registrar, wszDll, wszId, wszRegistry); - IRegistrar_Release(pRegistrar); + if(registrar != pRegistrar) + IRegistrar_Release(registrar); return hres; } static HRESULT do_register_server(BOOL do_register) { - static const WCHAR wszDll[] = {'a','t','l','.','d','l','l',0}; - return do_register_dll_server(NULL, wszDll, MAKEINTRESOURCEW(101), do_register, NULL); + static const WCHAR CLSID_ATLRegistrarW[] = + {'C','L','S','I','D','_','A','T','L','R','e','g','i','s','t','r','a','r',0}; + static const WCHAR atl_dllW[] = {'a','t','l','.','d','l','l',0}; + + WCHAR clsid_str[40]; + const struct _ATL_REGMAP_ENTRY reg_map[] = {{CLSID_ATLRegistrarW, clsid_str}, {NULL,NULL}}; + + StringFromGUID2(&CLSID_ATLRegistrar, clsid_str, sizeof(clsid_str)/sizeof(WCHAR)); + return do_register_dll_server(NULL, atl_dllW, MAKEINTRESOURCEW(101), do_register, reg_map); } /*********************************************************************** diff --git a/dll/win32/clusapi/clusapi.c b/dll/win32/clusapi/clusapi.c index fa90de31ef3..f782d43708b 100644 --- a/dll/win32/clusapi/clusapi.c +++ b/dll/win32/clusapi/clusapi.c @@ -40,7 +40,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(clusapi); */ DWORD WINAPI GetNodeClusterState(LPCWSTR lpszNodeName, LPDWORD pdwClusterState) { - FIXME("(%s,%p,%u) stub!\n",debugstr_w(lpszNodeName),pdwClusterState, *pdwClusterState); + FIXME("(%s,%p) stub!\n",debugstr_w(lpszNodeName),pdwClusterState); *pdwClusterState = 0; @@ -97,7 +97,7 @@ DWORD WINAPI ClusterCloseEnum(HCLUSENUM hEnum) */ DWORD WINAPI ClusterEnum(HCLUSENUM hEnum, DWORD dwIndex, LPDWORD lpdwType, LPWSTR lpszName, LPDWORD lpcchName) { - FIXME("(%p, %u, %u, %p, %u) stub!\n", hEnum, dwIndex, *lpdwType, lpszName, *lpcchName); + FIXME("(%p, %u, %p, %p, %u) stub!\n", hEnum, dwIndex, lpdwType, lpszName, *lpcchName); return ERROR_NO_MORE_ITEMS; } diff --git a/dll/win32/credui/credui.rc b/dll/win32/credui/credui.rc index f66a9428043..5f4762ebc1c 100644 --- a/dll/win32/credui/credui.rc +++ b/dll/win32/credui/credui.rc @@ -28,18 +28,22 @@ IDB_BANNER BITMAP LOADONCALL DISCARDABLE banner.bmp #include "credui_Da.rc" -#include "credui_De.rc" #include "credui_En.rc" -#include "credui_Es.rc" -#include "credui_Fr.rc" #include "credui_Ko.rc" -#include "credui_Lt.rc" #include "credui_Nl.rc" #include "credui_No.rc" #include "credui_Pl.rc" #include "credui_Pt.rc" +#include "credui_Sv.rc" +#include "credui_Zh.rc" + +/* UTF-8 */ +#include "credui_De.rc" +#include "credui_Es.rc" +#include "credui_Fr.rc" +#include "credui_It.rc" +#include "credui_Lt.rc" #include "credui_Ro.rc" #include "credui_Ru.rc" #include "credui_Si.rc" -#include "credui_Sv.rc" -#include "credui_Zh.rc" +#include "credui_Uk.rc" diff --git a/dll/win32/credui/credui_Fr.rc b/dll/win32/credui/credui_Fr.rc index d2e63be4140..387a86d39a1 100644 --- a/dll/win32/credui/credui_Fr.rc +++ b/dll/win32/credui/credui_Fr.rc @@ -52,4 +52,3 @@ STRINGTABLE DISCARDABLE IDS_CAPSLOCKONTITLE "VERR.MAJ est activé" IDS_CAPSLOCKON "Le verrouillage majuscule étant activé, cela pourrait provoquer une erreur lors de la saisie de votre mot de passe.\n\nAppuyez sur la touche VERR.MAJ de votre clavier afin de désactiver le verrouilage majuscule avant\nde saisir votre mot de passe." } -#pragma code_page(default) diff --git a/dll/win32/credui/credui_It.rc b/dll/win32/credui/credui_It.rc new file mode 100644 index 00000000000..f7708f4b5d1 --- /dev/null +++ b/dll/win32/credui/credui_It.rc @@ -0,0 +1,55 @@ +/* + * Italian language resource file for Credentials UI + * + * Copyright 2010 Luca Bennati + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "credui_resources.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL + +IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149 +STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "IDS_TITLEFORMAT" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL IDB_BANNER,-1,"Static",SS_BITMAP | SS_CENTERIMAGE,0, + 0,213,37 + LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP + LTEXT "&Nome Utente:",-1,8,62,72,12,SS_CENTERIMAGE + CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 + LTEXT "&Password:",-1,8,80,72,12,SS_CENTERIMAGE + EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "&Ricorda la mia password",IDC_SAVE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12 + DEFPUSHBUTTON "OK",IDOK,97,128,50,14 + PUSHBUTTON "Annulla",IDCANCEL,156,128,50,14 +END + +STRINGTABLE DISCARDABLE +{ + IDS_TITLEFORMAT "Connetti a %s" + IDS_MESSAGEFORMAT "Connettendo a %s" + IDS_INCORRECTPASSWORDTITLE "Accesso fallito" + IDS_INCORRECTPASSWORD "Assicurati che il tuo nome utente\ne password siano corrette." + IDS_CAPSLOCKONTITLE "Il Caps Lock è acceso" + IDS_CAPSLOCKON "Avere Caps Lock acceso può portarti a immettere la password incorrettamente.\n\nPremere il tasto Caps Lock sulla tua tastiera per spegnere Caps Lock prima\n di immettere la tua password." +} diff --git a/dll/win32/credui/credui_Lt.rc b/dll/win32/credui/credui_Lt.rc index c98a861cc8a..4eb6ebaf9b4 100644 --- a/dll/win32/credui/credui_Lt.rc +++ b/dll/win32/credui/credui_Lt.rc @@ -53,4 +53,3 @@ STRINGTABLE DISCARDABLE IDS_CAPSLOCKONTITLE "Didžiųjų raidžių būsena įjungta" IDS_CAPSLOCKON "Kai įjungta didžiųjų raidžių būsena, savo slaptažodį galite įvesti neteisingai.\n\nPaspauskite didžiųjų raidžių klaviatūros klavišą didžiųjų raidžių būsenai išjungti\nprieš rinkdami savo slaptažodį." } -#pragma code_page(default) diff --git a/dll/win32/credui/credui_Si.rc b/dll/win32/credui/credui_Si.rc index 068ec970338..34915e668b5 100644 --- a/dll/win32/credui/credui_Si.rc +++ b/dll/win32/credui/credui_Si.rc @@ -52,5 +52,3 @@ STRINGTABLE DISCARDABLE IDS_CAPSLOCKONTITLE "Caps Lock je vključen" IDS_CAPSLOCKON "Vključen Caps Lock je lahko vzrok nepravilnega vnosa gesla.\n\nPritisnite tipko Caps Lock, s čimer ga izklopite\nin ponovno vnesite geslo." } - -#pragma code_page(default) diff --git a/dll/win32/credui/credui_Uk.rc b/dll/win32/credui/credui_Uk.rc new file mode 100644 index 00000000000..e7c04ab7af6 --- /dev/null +++ b/dll/win32/credui/credui_Uk.rc @@ -0,0 +1,56 @@ +/* + * Ukrainian language resource file for Credentials UI + * + * Copyright 2007 Robert Shearman (for CodeWeavers) + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "credui_resources.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +IDD_CREDDIALOG DIALOG DISCARDABLE 0, 0, 213, 149 +STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "IDS_TITLEFORMAT" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL IDB_BANNER,-1,"Static",SS_BITMAP | SS_CENTERIMAGE,0, + 0,213,37 + LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP + LTEXT "&Користувач:",-1,8,62,72,12,SS_CENTERIMAGE + CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 + LTEXT "&Пароль:",-1,8,80,72,12,SS_CENTERIMAGE + EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "&Запам'ятати мій пароль",IDC_SAVE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,80,98,126,12 + DEFPUSHBUTTON "OK",IDOK,97,128,50,14 + PUSHBUTTON "Скасувати",IDCANCEL,156,128,50,14 +END + +STRINGTABLE DISCARDABLE +{ + IDS_TITLEFORMAT "Під'єднатись до %s" + IDS_MESSAGEFORMAT "Під'єднуюсь до %s" + IDS_INCORRECTPASSWORDTITLE "Вхід не відбувся" + IDS_INCORRECTPASSWORD "Переконайтесь що ім'я користувача\nі пароль правильні." + IDS_CAPSLOCKONTITLE "Caps Lock включений" + IDS_CAPSLOCKON "Пароль може бути введений неправильно через натиснену клавішу Caps Lock.\n\nВимкніть Caps Lock перед\nвведенням паролю." +} diff --git a/dll/win32/crypt32/chain.c b/dll/win32/crypt32/chain.c index 28a22064440..6cdd103e666 100644 --- a/dll/win32/crypt32/chain.c +++ b/dll/win32/crypt32/chain.c @@ -686,8 +686,12 @@ static BOOL url_matches(LPCWSTR constraint, LPCWSTR name, authority_end = strchrW(name, '?'); if (!authority_end) authority_end = name + strlenW(name); - /* Remove any port number from the authority */ - for (colon = authority_end; colon >= name && *colon != ':'; colon--) + /* Remove any port number from the authority. The userinfo portion + * of an authority may contain a colon, so stop if a userinfo portion + * is found (indicated by '@'). + */ + for (colon = authority_end; colon >= name && *colon != ':' && + *colon != '@'; colon--) ; if (*colon == ':') authority_end = colon; @@ -3376,7 +3380,7 @@ BOOL WINAPI CertVerifyCertificateChainPolicy(LPCSTR szPolicyOID, TRACE("(%s, %p, %p, %p)\n", debugstr_a(szPolicyOID), pChainContext, pPolicyPara, pPolicyStatus); - if (!HIWORD(szPolicyOID)) + if (IS_INTOID(szPolicyOID)) { switch (LOWORD(szPolicyOID)) { diff --git a/dll/win32/crypt32/crypt32.rc b/dll/win32/crypt32/crypt32.rc index aae358df5a7..c656a8c551b 100644 --- a/dll/win32/crypt32/crypt32.rc +++ b/dll/win32/crypt32/crypt32.rc @@ -24,13 +24,16 @@ #include "version.rc" -#include "crypt32_De.rc" #include "crypt32_En.rc" -#include "crypt32_Fr.rc" #include "crypt32_Ko.rc" + +/* UTF-8 */ +#include "crypt32_De.rc" +#include "crypt32_Fr.rc" #include "crypt32_Lt.rc" #include "crypt32_Nl.rc" #include "crypt32_No.rc" #include "crypt32_Pt.rc" #include "crypt32_Ro.rc" #include "crypt32_Sv.rc" +#include "crypt32_Uk.rc" diff --git a/dll/win32/crypt32/crypt32_Fr.rc b/dll/win32/crypt32/crypt32_Fr.rc index 3438f2e4109..b98636dee82 100644 --- a/dll/win32/crypt32/crypt32_Fr.rc +++ b/dll/win32/crypt32/crypt32_Fr.rc @@ -242,4 +242,3 @@ STRINGTABLE DISCARDABLE IDS_NETSCAPE_SMIME_CA "AC S/MIME" IDS_NETSCAPE_SIGN_CA "Signature CA" } -#pragma code_page(default) diff --git a/dll/win32/crypt32/crypt32_Uk.rc b/dll/win32/crypt32/crypt32_Uk.rc new file mode 100644 index 00000000000..d26a456d44b --- /dev/null +++ b/dll/win32/crypt32/crypt32_Uk.rc @@ -0,0 +1,247 @@ +/* + * crypt32 dll resources + * + * Copyright (C) 2006 Juan Lang + * + * Ukrainian language support + * Copyright (C) 2010 igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "cryptres.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_AUTHORITY_KEY_ID "Authority Key Identifier" + IDS_KEY_ATTRIBUTES "Властивості Ключа" + IDS_KEY_USAGE_RESTRICTION "Key Usage Restriction" + IDS_SUBJECT_ALT_NAME "Subject Alternative Name" + IDS_ISSUER_ALT_NAME "Issuer Alternative Name" + IDS_BASIC_CONSTRAINTS "Основні Обмеження" + IDS_KEY_USAGE "Використання Ключа" + IDS_CERT_POLICIES "Політика Сертифікатів" + IDS_SUBJECT_KEY_IDENTIFIER "Subject Key Identifier" + IDS_CRL_REASON_CODE "CRL Reason Code" + IDS_CRL_DIST_POINTS "CRL Distribution Points" + IDS_ENHANCED_KEY_USAGE "Розширене Використання Ключа" + IDS_AUTHORITY_INFO_ACCESS "Authority Information Access" + IDS_CERT_EXTENSIONS "Розширення Сертифікатів" + IDS_NEXT_UPDATE_LOCATION "Next Update Location" + IDS_YES_OR_NO_TRUST "Yes or No Trust" + IDS_EMAIL_ADDRESS "Адреса Ел. Пошти" + IDS_UNSTRUCTURED_NAME "Unstructured Name" + IDS_CONTENT_TYPE "Тип Вмісту" + IDS_MESSAGE_DIGEST "Message Digest" + IDS_SIGNING_TIME "Час Входу" + IDS_COUNTER_SIGN "Counter Sign" + IDS_CHALLENGE_PASSWORD "Challenge Password" + IDS_UNSTRUCTURED_ADDRESS "Unstructured Address" + IDS_SMIME_CAPABILITIES "SMIME Capabilities" + IDS_PREFER_SIGNED_DATA "Prefer Signed Data" + IDS_CPS "CPS" + IDS_USER_NOTICE "User Notice" + IDS_OCSP "On-line Certificate Status Protocol" + IDS_CA_ISSUER "Certification Authority Issuer" + IDS_CERT_TEMPLATE_NAME "Certification Template Name" + IDS_CERT_TYPE "Тип Сертифікату" + IDS_CERT_MANIFOLD "Certificate Manifold" + IDS_NETSCAPE_CERT_TYPE "Netscape Cert Type" + IDS_NETSCAPE_BASE_URL "Netscape Base URL" + IDS_NETSCAPE_REVOCATION_URL "Netscape Revocation URL" + IDS_NETSCAPE_CA_REVOCATION_URL "Netscape CA Revocation URL" + IDS_NETSCAPE_CERT_RENEWAL_URL "Netscape Cert Renewal URL" + IDS_NETSCAPE_CA_POLICY_URL "Netscape CA Policy URL" + IDS_NETSCAPE_SSL_SERVER_NAME "Netscape SSL ServerName" + IDS_NETSCAPE_COMMENT "Netscape Коментар" + IDS_SPC_SP_AGENCY_INFO "SpcSpAgencyInfo" + IDS_SPC_FINANCIAL_CRITERIA "SpcFinancialCriteria" + IDS_SPC_MINIMAL_CRITERIA "SpcMinimalCriteria" + IDS_COUNTRY "Країна/Регіон" + IDS_ORGANIZATION "Організація" + IDS_ORGANIZATIONAL_UNIT "Organizational Unit" + IDS_COMMON_NAME "Common Name" + IDS_LOCALITY "Locality" + IDS_STATE_OR_PROVINCE "State or Province" + IDS_TITLE "Title" + IDS_GIVEN_NAME "Given Name" + IDS_INITIALS "Ініціали" + IDS_SUR_NAME "Sur Name" + IDS_DOMAIN_COMPONENT "Domain Component" + IDS_STREET_ADDRESS "Street Address" + IDS_SERIAL_NUMBER "Серійний номер" + IDS_CA_VERSION "CA Version" + IDS_CROSS_CA_VERSION "Cross CA Version" + IDS_SERIALIZED_SIG_SERIAL_NUMBER "Serialized Signature Serial Number" + IDS_PRINCIPAL_NAME "Principal Name" + IDS_WINDOWS_PRODUCT_UPDATE "Windows Product Update" + IDS_ENROLLMENT_NAME_VALUE_PAIR "Enrollment Name Value Pair" + IDS_OS_VERSION "OS Version" + IDS_ENROLLMENT_CSP "Enrollment CSP" + IDS_CRL_NUMBER "CRL Number" + IDS_DELTA_CRL_INDICATOR "Delta CRL Indicator" + IDS_ISSUING_DIST_POINT "Issuing Distribution Point" + IDS_FRESHEST_CRL "Freshest CRL" + IDS_NAME_CONSTRAINTS "Name Constraints" + IDS_POLICY_MAPPINGS "Policy Mappings" + IDS_POLICY_CONSTRAINTS "Policy Constraints" + IDS_CROSS_CERT_DIST_POINTS "Cross-Certificate Distribution Points" + IDS_APPLICATION_POLICIES "Application Policies" + IDS_APPLICATION_POLICY_MAPPINGS "Application Policy Mappings" + IDS_APPLICATION_POLICY_CONSTRAINTS "Application Policy Constraints" + IDS_CMC_DATA "CMC Data" + IDS_CMC_RESPONSE "CMC Response" + IDS_UNSIGNED_CMC_REQUEST "Unsigned CMC Request" + IDS_CMC_STATUS_INFO "CMC Status Info" + IDS_CMC_EXTENSIONS "CMC Extensions" + IDS_CMC_ATTRIBUTES "CMC Attributes" + IDS_PKCS_7_DATA "PKCS 7 Data" + IDS_PKCS_7_SIGNED "PKCS 7 Signed" + IDS_PKCS_7_ENVELOPED "PKCS 7 Enveloped" + IDS_PKCS_7_SIGNED_ENVELOPED "PKCS 7 Signed Enveloped" + IDS_PKCS_7_DIGESTED "PKCS 7 Digested" + IDS_PKCS_7_ENCRYPTED "PKCS 7 Encrypted" + IDS_PREVIOUS_CA_CERT_HASH "Previous CA Certificate Hash" + IDS_CRL_VIRTUAL_BASE "Virtual Base CRL Number" + IDS_CRL_NEXT_PUBLISH "Next CRL Publish" + IDS_CA_EXCHANGE "CA Encryption Certificate" + IDS_KEY_RECOVERY_AGENT "Key Recovery Agent" + IDS_CERTIFICATE_TEMPLATE "Certificate Template Information" + IDS_ENTERPRISE_ROOT_OID "Enterprise Root OID" + IDS_RDN_DUMMY_SIGNER "Dummy Signer" + IDS_ARCHIVED_KEY_ATTR "Encrypted Private Key" + IDS_CRL_SELF_CDP "Published CRL Locations" + IDS_REQUIRE_CERT_CHAIN_POLICY "Enforce Certificate Chain Policy" + IDS_TRANSACTION_ID "Transaction Id" + IDS_SENDER_NONCE "Sender Nonce" + IDS_RECIPIENT_NONCE "Recipient Nonce" + IDS_REG_INFO "Reg Info" + IDS_GET_CERTIFICATE "Get Certificate" + IDS_GET_CRL "Get CRL" + IDS_REVOKE_REQUEST "Revoke Request" + IDS_QUERY_PENDING "Query Pending" + IDS_SORTED_CTL "Certificate Trust List" + IDS_ARCHIVED_KEY_CERT_HASH "Archived Key Certificate Hash" + IDS_PRIVATE_KEY_USAGE_PERIOD "Private Key Usage Period" + IDS_CLIENT_INFORMATION "Клієнські Дані" + IDS_SERVER_AUTHENTICATION "Server Authentication" + IDS_CLIENT_AUTHENTICATION "Client Authentication" + IDS_CODE_SIGNING "Code Signing" + IDS_SECURE_EMAIL "Secure Email" + IDS_TIME_STAMPING "Time Stamping" + IDS_MICROSOFT_TRUST_LIST_SIGNING "Microsoft Trust List Signing" + IDS_MICROSOFT_TIME_STAMPING "Microsoft Time Stamping" + IDS_IPSEC_END_SYSTEM "IP security end system" + IDS_IPSEC_TUNNEL "IP security tunnel termination" + IDS_IPSEC_USER "IP security user" + IDS_EFS "Encrypting File System" + IDS_WHQL_CRYPTO "Windows Hardware Driver Verification" + IDS_NT5_CRYPTO "Windows System Component Verification" + IDS_OEM_WHQL_CRYPTO "OEM Windows System Component Verification" + IDS_EMBEDDED_NT_CRYPTO "Embedded Windows System Component Verification" + IDS_KEY_PACK_LICENSES "Key Pack Licenses" + IDS_LICENSE_SERVER "License Server Verification" + IDS_SMART_CARD_LOGON "Smart Card Logon" + IDS_DIGITAL_RIGHTS "Digital Rights" + IDS_QUALIFIED_SUBORDINATION "Qualified Subordination" + IDS_KEY_RECOVERY "Key Recovery" + IDS_DOCUMENT_SIGNING "Document Signing" + IDS_IPSEC_IKE_INTERMEDIATE "IP security IKE intermediate" + IDS_FILE_RECOVERY "File Recovery" + IDS_ROOT_LIST_SIGNER "Root List Signer" + IDS_ANY_APPLICATION_POLICIES "All application policies" + IDS_DS_EMAIL_REPLICATION "Directory Service Email Replication" + IDS_ENROLLMENT_AGENT "Certificate Request Agent" + IDS_LIFETIME_SIGNING "Lifetime Signing" + IDS_ANY_CERT_POLICY "All issuance policies" +} + +STRINGTABLE DISCARDABLE +{ + IDS_LOCALIZEDNAME_ROOT "Trusted Root Certification Authorities" + IDS_LOCALIZEDNAME_MY "Personal" + IDS_LOCALIZEDNAME_CA "Intermediate Certification Authorities" + IDS_LOCALIZEDNAME_ADDRESSBOOK "Other People" + IDS_LOCALIZEDNAME_TRUSTEDPUBLISHER "Trusted Publishers" + IDS_LOCALIZEDNAME_DISALLOWED "Untrusted Certificates" +} + +STRINGTABLE DISCARDABLE +{ + IDS_KEY_ID "KeyID=" + IDS_CERT_ISSUER "Certificate Issuer" + IDS_CERT_SERIAL_NUMBER "Certificate Serial Number=" + IDS_ALT_NAME_OTHER_NAME "Інше Ім'я=" + IDS_ALT_NAME_RFC822_NAME "Адреса Ел. Пошти=" + IDS_ALT_NAME_DNS_NAME "DNS Name=" + IDS_ALT_NAME_DIRECTORY_NAME "Directory Address" + IDS_ALT_NAME_URL "URL=" + IDS_ALT_NAME_IP_ADDRESS "IP Адреса=" + IDS_ALT_NAME_MASK "Маска=" + IDS_ALT_NAME_REGISTERED_ID "Registered ID=" + IDS_USAGE_UNKNOWN "Unknown Key Usage" + IDS_SUBJECT_TYPE "Subject Type=" + IDS_SUBJECT_TYPE_CA "CA" + IDS_SUBJECT_TYPE_END_CERT "End Entity" + IDS_PATH_LENGTH "Path Length Constraint=" + IDS_PATH_LENGTH_NONE "None" + IDS_INFO_NOT_AVAILABLE "Information Not Available" + IDS_AIA "Authority Info Access" + IDS_ACCESS_METHOD "Access Method=" + IDS_ACCESS_METHOD_OCSP "OCSP" + IDS_ACCESS_METHOD_CA_ISSUERS "CA Issuers" + IDS_ACCESS_METHOD_UNKNOWN "Unknown Access Method" + IDS_ACCESS_LOCATION "Alternative Name" + IDS_CRL_DIST_POINT "CRL Distribution Point" + IDS_CRL_DIST_POINT_NAME "Distribution Point Name" + IDS_CRL_DIST_POINT_FULL_NAME "Full Name" + IDS_CRL_DIST_POINT_RDN_NAME "RDN Name" + IDS_CRL_DIST_POINT_REASON "CRL Reason=" + IDS_CRL_DIST_POINT_ISSUER "CRL Issuer" + IDS_REASON_KEY_COMPROMISE "Key Compromise" + IDS_REASON_CA_COMPROMISE "CA Compromise" + IDS_REASON_AFFILIATION_CHANGED "Affiliation Changed" + IDS_REASON_SUPERSEDED "Superseded" + IDS_REASON_CESSATION_OF_OPERATION "Operation Ceased" + IDS_REASON_CERTIFICATE_HOLD "Certificate Hold" + IDS_FINANCIAL_CRITERIA "Фінансові Дані=" + IDS_FINANCIAL_CRITERIA_AVAILABLE "Available" + IDS_FINANCIAL_CRITERIA_NOT_AVAILABLE "Not Available" + IDS_FINANCIAL_CRITERIA_MEETS_CRITERIA "Meets Criteria=" + IDS_YES "Yes" + IDS_NO "No" + IDS_DIGITAL_SIGNATURE "Цифровий Підпис" + IDS_NON_REPUDIATION "Non-Repudiation" + IDS_KEY_ENCIPHERMENT "Key Encipherment" + IDS_DATA_ENCIPHERMENT "Data Encipherment" + IDS_KEY_AGREEMENT "Key Agreement" + IDS_CERT_SIGN "Certificate Signing" + IDS_OFFLINE_CRL_SIGN "Off-line CRL Signing" + IDS_CRL_SIGN "CRL Signing" + IDS_ENCIPHER_ONLY "Encipher Only" + IDS_DECIPHER_ONLY "Decipher Only" + IDS_NETSCAPE_SSL_CLIENT "SSL Client Authentication" + IDS_NETSCAPE_SSL_SERVER "SSL Server Authentication" + IDS_NETSCAPE_SMIME "S/MIME" + IDS_NETSCAPE_SIGN "Signature" + IDS_NETSCAPE_SSL_CA "SSL CA" + IDS_NETSCAPE_SMIME_CA "S/MIME CA" + IDS_NETSCAPE_SIGN_CA "Signature CA" +} diff --git a/dll/win32/crypt32/crypt32_private.h b/dll/win32/crypt32/crypt32_private.h index cbdf5116f9c..8385bf50713 100644 --- a/dll/win32/crypt32/crypt32_private.h +++ b/dll/win32/crypt32/crypt32_private.h @@ -405,4 +405,8 @@ void ContextList_Free(struct ContextList *list); #define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1)) #define POINTER_ALIGN_DWORD_PTR(p) ((LPVOID)ALIGN_DWORD_PTR((DWORD_PTR)(p))) +/* Check if the OID is a small int + */ +#define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0) + #endif diff --git a/dll/win32/crypt32/decode.c b/dll/win32/crypt32/decode.c index 1fd23837395..fb3d36e8124 100644 --- a/dll/win32/crypt32/decode.c +++ b/dll/win32/crypt32/decode.c @@ -5578,7 +5578,7 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, SetLastError(ERROR_FILE_NOT_FOUND); return NULL; } - if (!HIWORD(lpszStructType)) + if (IS_INTOID(lpszStructType)) { switch (LOWORD(lpszStructType)) { diff --git a/dll/win32/crypt32/encode.c b/dll/win32/crypt32/encode.c index b7bbc83600c..c58b0e638e9 100644 --- a/dll/win32/crypt32/encode.c +++ b/dll/win32/crypt32/encode.c @@ -4305,7 +4305,7 @@ static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType, return NULL; } - if (!HIWORD(lpszStructType)) + if (IS_INTOID(lpszStructType)) { switch (LOWORD(lpszStructType)) { diff --git a/dll/win32/crypt32/main.c b/dll/win32/crypt32/main.c index 1a5972fe843..5844b1841e5 100644 --- a/dll/win32/crypt32/main.c +++ b/dll/win32/crypt32/main.c @@ -161,8 +161,13 @@ BOOL WINAPI I_CryptSetTls(DWORD dwTlsIndex, LPVOID lpTlsValue) BOOL WINAPI I_CryptFreeTls(DWORD dwTlsIndex, DWORD unknown) { + BOOL ret; + TRACE("(%d, %d)\n", dwTlsIndex, unknown); - return TlsFree(dwTlsIndex); + + ret = TlsFree(dwTlsIndex); + if (!ret) SetLastError( E_INVALIDARG ); + return ret; } BOOL WINAPI I_CryptGetOssGlobal(DWORD x) diff --git a/dll/win32/crypt32/object.c b/dll/win32/crypt32/object.c index 3d18c505fb4..b3f82936172 100644 --- a/dll/win32/crypt32/object.c +++ b/dll/win32/crypt32/object.c @@ -2525,7 +2525,7 @@ static CryptFormatObjectFunc CRYPT_GetBuiltinFormatFunction(DWORD encodingType, SetLastError(ERROR_FILE_NOT_FOUND); return NULL; } - if (!HIWORD(lpszStructType)) + if (IS_INTOID(lpszStructType)) { switch (LOWORD(lpszStructType)) { diff --git a/dll/win32/crypt32/oid.c b/dll/win32/crypt32/oid.c index 68a48520dac..ea30d9ccd45 100644 --- a/dll/win32/crypt32/oid.c +++ b/dll/win32/crypt32/oid.c @@ -170,7 +170,7 @@ static char *CRYPT_GetKeyName(DWORD dwEncodingType, LPCSTR pszFuncName, * "EncodingType 2" would be expected if it were a mask. Instead native * stores values in "EncodingType 3". */ - if (!HIWORD(pszOID)) + if (IS_INTOID(pszOID)) { snprintf(numericOID, sizeof(numericOID), "#%d", LOWORD(pszOID)); oid = numericOID; @@ -255,7 +255,7 @@ BOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule, { struct OIDFunction *func; - if (HIWORD(rgFuncEntry[i].pszOID)) + if (!IS_INTOID(rgFuncEntry[i].pszOID)) func = CryptMemAlloc(sizeof(struct OIDFunction) + strlen(rgFuncEntry[i].pszOID) + 1); else @@ -263,7 +263,7 @@ BOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule, if (func) { func->encoding = GET_CERT_ENCODING_TYPE(dwEncodingType); - if (HIWORD(rgFuncEntry[i].pszOID)) + if (!IS_INTOID(rgFuncEntry[i].pszOID)) { LPSTR oid; @@ -402,9 +402,9 @@ BOOL WINAPI CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet, { if (function->encoding == GET_CERT_ENCODING_TYPE(dwEncodingType)) { - if (HIWORD(pszOID)) + if (!IS_INTOID(pszOID)) { - if (HIWORD(function->entry.pszOID) && + if (!IS_INTOID(function->entry.pszOID) && !strcasecmp(function->entry.pszOID, pszOID)) { *ppvFuncAddr = function->entry.pvFuncAddr; @@ -1398,7 +1398,7 @@ static void init_oid_info(void) for (i = 0; i < sizeof(oidInfoConstructors) / sizeof(oidInfoConstructors[0]); i++) { - if (HIWORD(oidInfoConstructors[i].pwszName)) + if (!IS_INTRESOURCE(oidInfoConstructors[i].pwszName)) { struct OIDInfo *info; diff --git a/dll/win32/crypt32/store.c b/dll/win32/crypt32/store.c index 153d3aa71ea..a8923949974 100644 --- a/dll/win32/crypt32/store.c +++ b/dll/win32/crypt32/store.c @@ -745,7 +745,7 @@ HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, TRACE("(%s, %08x, %08lx, %08x, %p)\n", debugstr_a(lpszStoreProvider), dwMsgAndCertEncodingType, hCryptProv, dwFlags, pvPara); - if (!HIWORD(lpszStoreProvider)) + if (IS_INTOID(lpszStoreProvider)) { switch (LOWORD(lpszStoreProvider)) { diff --git a/dll/win32/cryptdlg/cryptdlg.rc b/dll/win32/cryptdlg/cryptdlg.rc index dd9f97f4fde..7ea41c57407 100644 --- a/dll/win32/cryptdlg/cryptdlg.rc +++ b/dll/win32/cryptdlg/cryptdlg.rc @@ -22,11 +22,15 @@ #include "winuser.h" #include "cryptres.h" -#include "cryptdlg_De.rc" #include "cryptdlg_En.rc" -#include "cryptdlg_Fr.rc" #include "cryptdlg_Ko.rc" -#include "cryptdlg_Lt.rc" #include "cryptdlg_Nl.rc" + +/* UTF-8 */ +#include "cryptdlg_De.rc" +#include "cryptdlg_Fr.rc" +#include "cryptdlg_Lt.rc" +#include "cryptdlg_Uk.rc" #include "cryptdlg_Pt.rc" #include "cryptdlg_Ro.rc" + diff --git a/dll/win32/cryptdlg/cryptdlg_Fr.rc b/dll/win32/cryptdlg/cryptdlg_Fr.rc index 1deeaa31587..25d8a644ecf 100644 --- a/dll/win32/cryptdlg/cryptdlg_Fr.rc +++ b/dll/win32/cryptdlg/cryptdlg_Fr.rc @@ -40,4 +40,3 @@ STRINGTABLE DISCARDABLE IDS_NOTICE_NUM "Numéro de l'avis =" IDS_NOTICE_TEXT "Texte de l'avis =" } -#pragma code_page(default) diff --git a/dll/win32/cryptdlg/cryptdlg_Uk.rc b/dll/win32/cryptdlg/cryptdlg_Uk.rc new file mode 100644 index 00000000000..d90226f9abc --- /dev/null +++ b/dll/win32/cryptdlg/cryptdlg_Uk.rc @@ -0,0 +1,42 @@ +/* + * cryptdlg dll resources + * + * Copyright 2008 Juan Lang + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "cryptres.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_CERT_POLICY "Certificate Policy" + IDS_POLICY_ID "Policy Identifier: " + IDS_POLICY_QUALIFIER_INFO "Policy Qualifier Info" + IDS_POLICY_QUALIFIER_ID "Policy Qualifier Id=" + IDS_CPS "CPS" /* Certification Practice Statement */ + IDS_USER_NOTICE "User Notice" + IDS_QUALIFIER "Qualifier" + IDS_NOTICE_REF "Notice Reference" + IDS_ORGANIZATION "Організація=" + IDS_NOTICE_NUM "Notice Number=" + IDS_NOTICE_TEXT "Notice Text=" +} diff --git a/dll/win32/cryptdlg/main.c b/dll/win32/cryptdlg/main.c index 1971578dbf5..f6653ec2c78 100644 --- a/dll/win32/cryptdlg/main.c +++ b/dll/win32/cryptdlg/main.c @@ -535,7 +535,7 @@ static BOOL CRYPT_FormatCPS(DWORD dwCertEncodingType, pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &cpsValue, &size))) { LPCWSTR headingSep, sep; - DWORD headingSepLen, sepLen; + DWORD sepLen; if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE) { @@ -547,8 +547,8 @@ static BOOL CRYPT_FormatCPS(DWORD dwCertEncodingType, headingSep = colonSpace; sep = commaSep; } + sepLen = strlenW(sep); - headingSepLen = strlenW(headingSep); if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE) { diff --git a/dll/win32/cryptnet/cryptnet_main.c b/dll/win32/cryptnet/cryptnet_main.c index 9301a56733b..0b4e31dd9b7 100644 --- a/dll/win32/cryptnet/cryptnet_main.c +++ b/dll/win32/cryptnet/cryptnet_main.c @@ -40,6 +40,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(cryptnet); +#define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0) + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); @@ -92,9 +94,7 @@ HRESULT WINAPI DllUnregisterServer(void) static const char *url_oid_to_str(LPCSTR oid) { - if (HIWORD(oid)) - return oid; - else + if (IS_INTOID(oid)) { static char buf[10]; @@ -115,6 +115,8 @@ static const char *url_oid_to_str(LPCSTR oid) return buf; } } + else + return oid; } typedef BOOL (WINAPI *UrlDllGetObjectUrlFunc)(LPCSTR, LPVOID, DWORD, @@ -123,18 +125,6 @@ typedef BOOL (WINAPI *UrlDllGetObjectUrlFunc)(LPCSTR, LPVOID, DWORD, static BOOL WINAPI CRYPT_GetUrlFromCertificateIssuer(LPCSTR pszUrlOid, LPVOID pvPara, DWORD dwFlags, PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, PCRYPT_URL_INFO pUrlInfo, DWORD *pcbUrlInfo, LPVOID pvReserved) -{ - /* FIXME: This depends on the AIA (authority info access) extension being - * supported in crypt32. - */ - FIXME("\n"); - SetLastError(CRYPT_E_NOT_FOUND); - return FALSE; -} - -static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, - LPVOID pvPara, DWORD dwFlags, PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, - PCRYPT_URL_INFO pUrlInfo, DWORD *pcbUrlInfo, LPVOID pvReserved) { PCCERT_CONTEXT cert = pvPara; PCERT_EXTENSION ext; @@ -146,39 +136,37 @@ static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, SetLastError(CRYPT_E_NOT_FOUND); return FALSE; } - if ((ext = CertFindExtension(szOID_CRL_DIST_POINTS, + if ((ext = CertFindExtension(szOID_AUTHORITY_INFO_ACCESS, cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) { - CRL_DIST_POINTS_INFO *info; + CERT_AUTHORITY_INFO_ACCESS *aia; DWORD size; - ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_CRL_DIST_POINTS, + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_AUTHORITY_INFO_ACCESS, ext->Value.pbData, ext->Value.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, - &info, &size); + &aia, &size); if (ret) { DWORD i, cUrl, bytesNeeded = sizeof(CRYPT_URL_ARRAY); - for (i = 0, cUrl = 0; i < info->cDistPoint; i++) - if (info->rgDistPoint[i].DistPointName.dwDistPointNameChoice - == CRL_DIST_POINT_FULL_NAME) + for (i = 0, cUrl = 0; i < aia->cAccDescr; i++) + if (!strcmp(aia->rgAccDescr[i].pszAccessMethod, + szOID_PKIX_CA_ISSUERS)) { - DWORD j; - CERT_ALT_NAME_INFO *name = - &info->rgDistPoint[i].DistPointName.u.FullName; - - for (j = 0; j < name->cAltEntry; j++) - if (name->rgAltEntry[j].dwAltNameChoice == - CERT_ALT_NAME_URL) + if (aia->rgAccDescr[i].AccessLocation.dwAltNameChoice == + CERT_ALT_NAME_URL) + { + if (aia->rgAccDescr[i].AccessLocation.u.pwszURL) { - if (name->rgAltEntry[j].u.pwszURL) - { - cUrl++; - bytesNeeded += sizeof(LPWSTR) + - (lstrlenW(name->rgAltEntry[j].u.pwszURL) + 1) - * sizeof(WCHAR); - } + cUrl++; + bytesNeeded += sizeof(LPWSTR) + + (lstrlenW(aia->rgAccDescr[i].AccessLocation.u. + pwszURL) + 1) * sizeof(WCHAR); } + } + else + FIXME("unsupported alt name type %d\n", + aia->rgAccDescr[i].AccessLocation.dwAltNameChoice); } if (!pcbUrlArray) { @@ -203,28 +191,22 @@ static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, (LPWSTR *)((BYTE *)pUrlArray + sizeof(CRYPT_URL_ARRAY)); nextUrl = (LPWSTR)((BYTE *)pUrlArray + sizeof(CRYPT_URL_ARRAY) + cUrl * sizeof(LPWSTR)); - for (i = 0; i < info->cDistPoint; i++) - if (info->rgDistPoint[i].DistPointName.dwDistPointNameChoice - == CRL_DIST_POINT_FULL_NAME) + for (i = 0; i < aia->cAccDescr; i++) + if (!strcmp(aia->rgAccDescr[i].pszAccessMethod, + szOID_PKIX_CA_ISSUERS)) { - DWORD j; - CERT_ALT_NAME_INFO *name = - &info->rgDistPoint[i].DistPointName.u.FullName; - - for (j = 0; j < name->cAltEntry; j++) - if (name->rgAltEntry[j].dwAltNameChoice == - CERT_ALT_NAME_URL) + if (aia->rgAccDescr[i].AccessLocation.dwAltNameChoice + == CERT_ALT_NAME_URL) + { + if (aia->rgAccDescr[i].AccessLocation.u.pwszURL) { - if (name->rgAltEntry[j].u.pwszURL) - { - lstrcpyW(nextUrl, - name->rgAltEntry[j].u.pwszURL); - pUrlArray->rgwszUrl[pUrlArray->cUrl++] = - nextUrl; - nextUrl += - (lstrlenW(name->rgAltEntry[j].u.pwszURL) + 1); - } + lstrcpyW(nextUrl, + aia->rgAccDescr[i].AccessLocation.u.pwszURL); + pUrlArray->rgwszUrl[pUrlArray->cUrl++] = + nextUrl; + nextUrl += (lstrlenW(nextUrl) + 1); } + } } } if (ret) @@ -247,7 +229,7 @@ static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, } } } - LocalFree(info); + LocalFree(aia); } } else @@ -255,6 +237,136 @@ static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, return ret; } +static BOOL CRYPT_GetUrlFromCRLDistPointsExt(const CRYPT_DATA_BLOB *value, + PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, PCRYPT_URL_INFO pUrlInfo, + DWORD *pcbUrlInfo) +{ + BOOL ret; + CRL_DIST_POINTS_INFO *info; + DWORD size; + + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_CRL_DIST_POINTS, + value->pbData, value->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size); + if (ret) + { + DWORD i, cUrl, bytesNeeded = sizeof(CRYPT_URL_ARRAY); + + for (i = 0, cUrl = 0; i < info->cDistPoint; i++) + if (info->rgDistPoint[i].DistPointName.dwDistPointNameChoice + == CRL_DIST_POINT_FULL_NAME) + { + DWORD j; + CERT_ALT_NAME_INFO *name = + &info->rgDistPoint[i].DistPointName.u.FullName; + + for (j = 0; j < name->cAltEntry; j++) + if (name->rgAltEntry[j].dwAltNameChoice == + CERT_ALT_NAME_URL) + { + if (name->rgAltEntry[j].u.pwszURL) + { + cUrl++; + bytesNeeded += sizeof(LPWSTR) + + (lstrlenW(name->rgAltEntry[j].u.pwszURL) + 1) + * sizeof(WCHAR); + } + } + } + if (!pcbUrlArray) + { + SetLastError(E_INVALIDARG); + ret = FALSE; + } + else if (!pUrlArray) + *pcbUrlArray = bytesNeeded; + else if (*pcbUrlArray < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + *pcbUrlArray = bytesNeeded; + ret = FALSE; + } + else + { + LPWSTR nextUrl; + + *pcbUrlArray = bytesNeeded; + pUrlArray->cUrl = 0; + pUrlArray->rgwszUrl = + (LPWSTR *)((BYTE *)pUrlArray + sizeof(CRYPT_URL_ARRAY)); + nextUrl = (LPWSTR)((BYTE *)pUrlArray + sizeof(CRYPT_URL_ARRAY) + + cUrl * sizeof(LPWSTR)); + for (i = 0; i < info->cDistPoint; i++) + if (info->rgDistPoint[i].DistPointName.dwDistPointNameChoice + == CRL_DIST_POINT_FULL_NAME) + { + DWORD j; + CERT_ALT_NAME_INFO *name = + &info->rgDistPoint[i].DistPointName.u.FullName; + + for (j = 0; j < name->cAltEntry; j++) + if (name->rgAltEntry[j].dwAltNameChoice == + CERT_ALT_NAME_URL) + { + if (name->rgAltEntry[j].u.pwszURL) + { + lstrcpyW(nextUrl, + name->rgAltEntry[j].u.pwszURL); + pUrlArray->rgwszUrl[pUrlArray->cUrl++] = + nextUrl; + nextUrl += + (lstrlenW(name->rgAltEntry[j].u.pwszURL) + 1); + } + } + } + } + if (ret) + { + if (pcbUrlInfo) + { + FIXME("url info: stub\n"); + if (!pUrlInfo) + *pcbUrlInfo = sizeof(CRYPT_URL_INFO); + else if (*pcbUrlInfo < sizeof(CRYPT_URL_INFO)) + { + *pcbUrlInfo = sizeof(CRYPT_URL_INFO); + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pcbUrlInfo = sizeof(CRYPT_URL_INFO); + memset(pUrlInfo, 0, sizeof(CRYPT_URL_INFO)); + } + } + } + LocalFree(info); + } + return ret; +} + +static BOOL WINAPI CRYPT_GetUrlFromCertificateCRLDistPoint(LPCSTR pszUrlOid, + LPVOID pvPara, DWORD dwFlags, PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, + PCRYPT_URL_INFO pUrlInfo, DWORD *pcbUrlInfo, LPVOID pvReserved) +{ + PCCERT_CONTEXT cert = pvPara; + PCERT_EXTENSION ext; + BOOL ret = FALSE; + + /* The only applicable flag is CRYPT_GET_URL_FROM_EXTENSION */ + if (dwFlags && !(dwFlags & CRYPT_GET_URL_FROM_EXTENSION)) + { + SetLastError(CRYPT_E_NOT_FOUND); + return FALSE; + } + if ((ext = CertFindExtension(szOID_CRL_DIST_POINTS, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + ret = CRYPT_GetUrlFromCRLDistPointsExt(&ext->Value, pUrlArray, + pcbUrlArray, pUrlInfo, pcbUrlInfo); + else + SetLastError(CRYPT_E_NOT_FOUND); + return ret; +} + /*********************************************************************** * CryptGetObjectUrl (CRYPTNET.@) */ @@ -269,7 +381,7 @@ BOOL WINAPI CryptGetObjectUrl(LPCSTR pszUrlOid, LPVOID pvPara, DWORD dwFlags, TRACE("(%s, %p, %08x, %p, %p, %p, %p, %p)\n", debugstr_a(pszUrlOid), pvPara, dwFlags, pUrlArray, pcbUrlArray, pUrlInfo, pcbUrlInfo, pvReserved); - if (!HIWORD(pszUrlOid)) + if (IS_INTOID(pszUrlOid)) { switch (LOWORD(pszUrlOid)) { @@ -566,7 +678,7 @@ static BOOL CRYPT_DownloadObject(DWORD dwRetrievalFlags, HINTERNET hHttp, } } if (ret) - object.cbData += bytesAvailable; + object.cbData += buffer.dwBufferLength; } else { @@ -1246,20 +1358,24 @@ static BOOL WINAPI CRYPT_CreateAny(LPCSTR pszObjectOid, if (!CertAddCertificateContextToStore(store, context, CERT_STORE_ADD_ALWAYS, NULL)) ret = FALSE; + CertFreeCertificateContext(context); break; case CERT_QUERY_CONTENT_CRL: if (!CertAddCRLContextToStore(store, context, CERT_STORE_ADD_ALWAYS, NULL)) ret = FALSE; + CertFreeCRLContext(context); break; case CERT_QUERY_CONTENT_CTL: if (!CertAddCTLContextToStore(store, context, CERT_STORE_ADD_ALWAYS, NULL)) ret = FALSE; + CertFreeCTLContext(context); break; default: CertAddStoreToCollection(store, contextStore, 0, 0); } + CertCloseStore(contextStore, 0); } else ret = FALSE; @@ -1284,7 +1400,7 @@ static BOOL CRYPT_GetCreateFunction(LPCSTR pszObjectOid, *pFunc = NULL; *phFunc = 0; - if (!HIWORD(pszObjectOid)) + if (IS_INTOID(pszObjectOid)) { switch (LOWORD(pszObjectOid)) { @@ -1354,7 +1470,7 @@ static BOOL CRYPT_GetExpirationFunction(LPCSTR pszObjectOid, { BOOL ret; - if (!HIWORD(pszObjectOid)) + if (IS_INTOID(pszObjectOid)) { switch (LOWORD(pszObjectOid)) { @@ -1437,6 +1553,238 @@ BOOL WINAPI CryptRetrieveObjectByUrlW(LPCWSTR pszURL, LPCSTR pszObjectOid, return ret; } +static DWORD verify_cert_revocation_with_crl(PCCERT_CONTEXT cert, + PCCRL_CONTEXT crl, DWORD index, FILETIME *pTime, + PCERT_REVOCATION_STATUS pRevStatus) +{ + DWORD error; + + if (CertVerifyCRLTimeValidity(pTime, crl->pCrlInfo)) + { + /* The CRL isn't time valid */ + error = CRYPT_E_NO_REVOCATION_CHECK; + } + else + { + PCRL_ENTRY entry = NULL; + + CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + if (entry) + { + error = CRYPT_E_REVOKED; + pRevStatus->dwIndex = index; + } + else + error = ERROR_SUCCESS; + } + return error; +} + +static DWORD verify_cert_revocation_from_dist_points_ext( + const CRYPT_DATA_BLOB *value, PCCERT_CONTEXT cert, DWORD index, + FILETIME *pTime, DWORD dwFlags, PCERT_REVOCATION_PARA pRevPara, + PCERT_REVOCATION_STATUS pRevStatus) +{ + DWORD error = ERROR_SUCCESS, cbUrlArray; + + if (CRYPT_GetUrlFromCRLDistPointsExt(value, NULL, &cbUrlArray, NULL, NULL)) + { + CRYPT_URL_ARRAY *urlArray = CryptMemAlloc(cbUrlArray); + + if (urlArray) + { + DWORD j, retrievalFlags = 0, startTime, endTime, timeout; + BOOL ret; + + ret = CRYPT_GetUrlFromCRLDistPointsExt(value, urlArray, + &cbUrlArray, NULL, NULL); + if (dwFlags & CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION) + retrievalFlags |= CRYPT_CACHE_ONLY_RETRIEVAL; + if (dwFlags & CERT_VERIFY_REV_ACCUMULATIVE_TIMEOUT_FLAG && + pRevPara && pRevPara->cbSize >= offsetof(CERT_REVOCATION_PARA, + dwUrlRetrievalTimeout) + sizeof(DWORD)) + { + startTime = GetTickCount(); + endTime = startTime + pRevPara->dwUrlRetrievalTimeout; + timeout = pRevPara->dwUrlRetrievalTimeout; + } + else + endTime = timeout = 0; + if (!ret) + error = GetLastError(); + for (j = 0; !error && j < urlArray->cUrl; j++) + { + PCCRL_CONTEXT crl; + + ret = CryptRetrieveObjectByUrlW(urlArray->rgwszUrl[j], + CONTEXT_OID_CRL, retrievalFlags, timeout, (void **)&crl, + NULL, NULL, NULL, NULL); + if (ret) + { + error = verify_cert_revocation_with_crl(cert, crl, index, + pTime, pRevStatus); + if (!error && timeout) + { + DWORD time = GetTickCount(); + + if ((int)(endTime - time) <= 0) + { + error = ERROR_TIMEOUT; + pRevStatus->dwIndex = index; + } + else + timeout = endTime - time; + } + CertFreeCRLContext(crl); + } + else + error = CRYPT_E_REVOCATION_OFFLINE; + } + CryptMemFree(urlArray); + } + else + { + error = ERROR_OUTOFMEMORY; + pRevStatus->dwIndex = index; + } + } + else + { + error = GetLastError(); + pRevStatus->dwIndex = index; + } + return error; +} + +static DWORD verify_cert_revocation_from_aia_ext( + const CRYPT_DATA_BLOB *value, PCCERT_CONTEXT cert, DWORD index, + FILETIME *pTime, DWORD dwFlags, PCERT_REVOCATION_PARA pRevPara, + PCERT_REVOCATION_STATUS pRevStatus) +{ + BOOL ret; + DWORD error, size; + CERT_AUTHORITY_INFO_ACCESS *aia; + + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_AUTHORITY_INFO_ACCESS, + value->pbData, value->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &aia, &size); + if (ret) + { + DWORD i; + + for (i = 0; i < aia->cAccDescr; i++) + if (!strcmp(aia->rgAccDescr[i].pszAccessMethod, + szOID_PKIX_OCSP)) + { + if (aia->rgAccDescr[i].AccessLocation.dwAltNameChoice == + CERT_ALT_NAME_URL) + FIXME("OCSP URL = %s\n", + debugstr_w(aia->rgAccDescr[i].AccessLocation.u.pwszURL)); + else + FIXME("unsupported AccessLocation type %d\n", + aia->rgAccDescr[i].AccessLocation.dwAltNameChoice); + } + LocalFree(aia); + /* FIXME: lie and pretend OCSP validated the cert */ + error = ERROR_SUCCESS; + } + else + error = GetLastError(); + return error; +} + +static DWORD verify_cert_revocation(PCCERT_CONTEXT cert, DWORD index, + FILETIME *pTime, DWORD dwFlags, PCERT_REVOCATION_PARA pRevPara, + PCERT_REVOCATION_STATUS pRevStatus) +{ + DWORD error = ERROR_SUCCESS; + PCERT_EXTENSION ext; + + if ((ext = CertFindExtension(szOID_CRL_DIST_POINTS, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + error = verify_cert_revocation_from_dist_points_ext(&ext->Value, cert, + index, pTime, dwFlags, pRevPara, pRevStatus); + else if ((ext = CertFindExtension(szOID_AUTHORITY_INFO_ACCESS, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + error = verify_cert_revocation_from_aia_ext(&ext->Value, cert, + index, pTime, dwFlags, pRevPara, pRevStatus); + else + { + if (pRevPara && pRevPara->hCrlStore && pRevPara->pIssuerCert) + { + PCCRL_CONTEXT crl = NULL; + BOOL canSignCRLs; + + /* If the caller told us about the issuer, make sure the issuer + * can sign CRLs before looking for one. + */ + if ((ext = CertFindExtension(szOID_KEY_USAGE, + pRevPara->pIssuerCert->pCertInfo->cExtension, + pRevPara->pIssuerCert->pCertInfo->rgExtension))) + { + CRYPT_BIT_BLOB usage; + DWORD size = sizeof(usage); + + if (!CryptDecodeObjectEx(cert->dwCertEncodingType, X509_BITS, + ext->Value.pbData, ext->Value.cbData, + CRYPT_DECODE_NOCOPY_FLAG, NULL, &usage, &size)) + canSignCRLs = FALSE; + else if (usage.cbData > 2) + { + /* The key usage extension only defines 9 bits => no more + * than 2 bytes are needed to encode all known usages. + */ + canSignCRLs = FALSE; + } + else + { + BYTE usageBits = usage.pbData[usage.cbData - 1]; + + canSignCRLs = usageBits & CERT_CRL_SIGN_KEY_USAGE; + } + } + else + canSignCRLs = TRUE; + if (canSignCRLs) + { + /* If the caller was helpful enough to tell us where to find a + * CRL for the cert, look for one and check it. + */ + crl = CertFindCRLInStore(pRevPara->hCrlStore, + cert->dwCertEncodingType, + CRL_FIND_ISSUED_BY_SIGNATURE_FLAG | + CRL_FIND_ISSUED_BY_AKI_FLAG, + CRL_FIND_ISSUED_BY, pRevPara->pIssuerCert, NULL); + } + if (crl) + { + error = verify_cert_revocation_with_crl(cert, crl, index, + pTime, pRevStatus); + CertFreeCRLContext(crl); + } + else + { + error = CRYPT_E_NO_REVOCATION_CHECK; + pRevStatus->dwIndex = index; + } + } + else + { + error = CRYPT_E_NO_REVOCATION_CHECK; + pRevStatus->dwIndex = index; + } + } + return error; +} + +typedef struct _CERT_REVOCATION_PARA_NO_EXTRA_FIELDS { + DWORD cbSize; + PCCERT_CONTEXT pIssuerCert; + DWORD cCertStore; + HCERTSTORE *rgCertStore; + HCERTSTORE hCrlStore; + LPFILETIME pftTimeToUse; +} CERT_REVOCATION_PARA_NO_EXTRA_FIELDS, *PCERT_REVOCATION_PARA_NO_EXTRA_FIELDS; + typedef struct _OLD_CERT_REVOCATION_STATUS { DWORD cbSize; DWORD dwIndex; @@ -1452,7 +1800,8 @@ BOOL WINAPI CertDllVerifyRevocation(DWORD dwEncodingType, DWORD dwRevType, PCERT_REVOCATION_PARA pRevPara, PCERT_REVOCATION_STATUS pRevStatus) { DWORD error = 0, i; - BOOL ret; + FILETIME now; + LPFILETIME pTime = NULL; TRACE("(%08x, %d, %d, %p, %08x, %p, %p)\n", dwEncodingType, dwRevType, cContext, rgpvContext, dwFlags, pRevPara, pRevStatus); @@ -1463,106 +1812,33 @@ BOOL WINAPI CertDllVerifyRevocation(DWORD dwEncodingType, DWORD dwRevType, SetLastError(E_INVALIDARG); return FALSE; } + if (!cContext) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + if (pRevPara && pRevPara->cbSize >= + sizeof(CERT_REVOCATION_PARA_NO_EXTRA_FIELDS)) + pTime = pRevPara->pftTimeToUse; + if (!pTime) + { + GetSystemTimeAsFileTime(&now); + pTime = &now; + } memset(&pRevStatus->dwIndex, 0, pRevStatus->cbSize - sizeof(DWORD)); if (dwRevType != CERT_CONTEXT_REVOCATION_TYPE) - { error = CRYPT_E_NO_REVOCATION_CHECK; - ret = FALSE; - } else { - ret = TRUE; - for (i = 0; ret && i < cContext; i++) - { - DWORD cbUrlArray; - - ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT, - rgpvContext[i], 0, NULL, &cbUrlArray, NULL, NULL, NULL); - if (!ret && GetLastError() == CRYPT_E_NOT_FOUND) - { - error = CRYPT_E_NO_REVOCATION_CHECK; - pRevStatus->dwIndex = i; - } - else if (ret) - { - CRYPT_URL_ARRAY *urlArray = CryptMemAlloc(cbUrlArray); - - if (urlArray) - { - DWORD j, retrievalFlags = 0, startTime, endTime, timeout; - - ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT, - rgpvContext[i], 0, urlArray, &cbUrlArray, NULL, NULL, - NULL); - if (dwFlags & CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION) - retrievalFlags |= CRYPT_CACHE_ONLY_RETRIEVAL; - if (dwFlags & CERT_VERIFY_REV_ACCUMULATIVE_TIMEOUT_FLAG && - pRevPara->cbSize >= offsetof(CERT_REVOCATION_PARA, - dwUrlRetrievalTimeout) + sizeof(DWORD)) - { - startTime = GetTickCount(); - endTime = startTime + pRevPara->dwUrlRetrievalTimeout; - timeout = pRevPara->dwUrlRetrievalTimeout; - } - else - endTime = timeout = 0; - for (j = 0; ret && j < urlArray->cUrl; j++) - { - PCCRL_CONTEXT crl; - - ret = CryptRetrieveObjectByUrlW(urlArray->rgwszUrl[j], - CONTEXT_OID_CRL, retrievalFlags, timeout, - (void **)&crl, NULL, NULL, NULL, NULL); - if (ret) - { - PCRL_ENTRY entry = NULL; - - CertFindCertificateInCRL( - rgpvContext[i], crl, 0, NULL, - &entry); - if (entry) - { - error = CRYPT_E_REVOKED; - pRevStatus->dwIndex = i; - ret = FALSE; - } - else if (timeout) - { - DWORD time = GetTickCount(); - - if ((int)(endTime - time) <= 0) - { - error = ERROR_TIMEOUT; - pRevStatus->dwIndex = i; - ret = FALSE; - } - else - timeout = endTime - time; - } - CertFreeCRLContext(crl); - } - else - error = CRYPT_E_REVOCATION_OFFLINE; - } - CryptMemFree(urlArray); - } - else - { - error = ERROR_OUTOFMEMORY; - pRevStatus->dwIndex = i; - ret = FALSE; - } - } - else - pRevStatus->dwIndex = i; - } + for (i = 0; !error && i < cContext; i++) + error = verify_cert_revocation(rgpvContext[i], i, pTime, dwFlags, + pRevPara, pRevStatus); } - - if (!ret) + if (error) { SetLastError(error); pRevStatus->dwError = error; } - TRACE("returning %d (%08x)\n", ret, error); - return ret; + TRACE("returning %d (%08x)\n", !error, error); + return !error; } diff --git a/dll/win32/cryptui/cryptui.rc b/dll/win32/cryptui/cryptui.rc index 5460ca2dec7..6f2a5304dab 100644 --- a/dll/win32/cryptui/cryptui.rc +++ b/dll/win32/cryptui/cryptui.rc @@ -46,10 +46,13 @@ IDB_CERT_WATERMARK BITMAP LOADONCALL DISCARDABLE certwatermark.bmp /* @makedep: certheader.bmp */ IDB_CERT_HEADER BITMAP LOADONCALL DISCARDABLE certheader.bmp -#include "cryptui_De.rc" #include "cryptui_En.rc" -#include "cryptui_Fr.rc" #include "cryptui_Ko.rc" + +/* UTF-8 */ +#include "cryptui_De.rc" +#include "cryptui_Fr.rc" #include "cryptui_Lt.rc" #include "cryptui_Nl.rc" #include "cryptui_Pt.rc" + diff --git a/dll/win32/cryptui/cryptui_De.rc b/dll/win32/cryptui/cryptui_De.rc index d34d88332cc..71740157666 100644 --- a/dll/win32/cryptui/cryptui_De.rc +++ b/dll/win32/cryptui/cryptui_De.rc @@ -119,6 +119,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Sind Sie sicher, dass Sie dieses Zertifikat entfernen möchten?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Sind Sie sicher, dass Sie diese Zertifikate entfernen möchten?" IDS_CERT_MGR "Zertifikate" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Garantiert die Identität eines entfernten Computers" IDS_PURPOSE_CLIENT_AUTH "Beweist Ihre Identität für einen entfernten Computers" IDS_PURPOSE_CODE_SIGNING "Schützt Software vor Manipulation nach der Veröffentlichung" diff --git a/dll/win32/cryptui/cryptui_En.rc b/dll/win32/cryptui/cryptui_En.rc index 5aee197a5f0..527ffa584f7 100644 --- a/dll/win32/cryptui/cryptui_En.rc +++ b/dll/win32/cryptui/cryptui_En.rc @@ -31,7 +31,7 @@ STRINGTABLE DISCARDABLE IDS_CERT_INFO_UNTRUSTED_ROOT "This certificate could not be validated to a trusted root certificate." IDS_CERT_INFO_PARTIAL_CHAIN "This certificate's issuer could not be found." IDS_CERT_INFO_BAD_PURPOSES "All the intended purposes of this certificate could not be verified." - IDS_CERT_INFO_PURPOSES "This cerificate is intended for the following purposes:" + IDS_CERT_INFO_PURPOSES "This certificate is intended for the following purposes:" IDS_SUBJECT_HEADING "Issued to: " IDS_ISSUER_HEADING "Issued by: " IDS_VALID_FROM "Valid from " @@ -117,6 +117,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Are you sure you want to remove this certificate?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Are you sure you want to remove these certificates?" IDS_CERT_MGR "Certificates" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Ensures the identify of a remote computer" IDS_PURPOSE_CLIENT_AUTH "Proves your identity to a remote computer" IDS_PURPOSE_CODE_SIGNING "Ensures software came from software publisher\nProtects software from alteration after publication" diff --git a/dll/win32/cryptui/cryptui_Fr.rc b/dll/win32/cryptui/cryptui_Fr.rc index 16b847fc6e7..5c5ca6891db 100644 --- a/dll/win32/cryptui/cryptui_Fr.rc +++ b/dll/win32/cryptui/cryptui_Fr.rc @@ -120,6 +120,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Voulez-vous réellement supprimer ce certificat ?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Voulez-vous réellement supprimer ces certificats ?" IDS_CERT_MGR "Certificats" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Prouve l'identité d'un ordinateur distant" IDS_PURPOSE_CLIENT_AUTH "Prouve votre identité à un ordinateur distant" IDS_PURPOSE_CODE_SIGNING "Garantit que des logiciels proviennent bien d'un éditeur de logiciels donné\nProtège le logiciel contre toute altération après publication" @@ -464,4 +465,3 @@ BEGIN LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_SINGLESEL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, 115,67,174,100 END -#pragma code_page(default) diff --git a/dll/win32/cryptui/cryptui_Ko.rc b/dll/win32/cryptui/cryptui_Ko.rc index 66064114d7f..eaa6222f160 100644 --- a/dll/win32/cryptui/cryptui_Ko.rc +++ b/dll/win32/cryptui/cryptui_Ko.rc @@ -118,6 +118,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT " Ÿ ϱ⸦ մϱ?" IDS_WARN_REMOVE_PLURAL_DEFAULT " 鸦 ϱ⸦ մϱ?" IDS_CERT_MGR "" + IDS_FRIENDLY_NAME_NONE "<>" IDS_PURPOSE_SERVER_AUTH " ǻ ϼ " IDS_PURPOSE_CLIENT_AUTH " ſ ǻͷ " IDS_PURPOSE_CODE_SIGNING "Ʈ ڷκ Ʈ \n Ʈ κ ȣ" diff --git a/dll/win32/cryptui/cryptui_Lt.rc b/dll/win32/cryptui/cryptui_Lt.rc index d4ba0eb2608..ee02eabf018 100644 --- a/dll/win32/cryptui/cryptui_Lt.rc +++ b/dll/win32/cryptui/cryptui_Lt.rc @@ -120,6 +120,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Ar tikrai norite pašalinti šį liudijimą?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Ar tikrai norite pašalinti šiuos liudijimus?" IDS_CERT_MGR "Liudijimai" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Garantuoja nutolusio kompiuterio tapatumą" IDS_PURPOSE_CLIENT_AUTH "Įrodo jūsų tapatumą nutolusiam kompiuteriui" IDS_PURPOSE_CODE_SIGNING "Garantuoja, kad programinė įranga yra iš šio leidėjo\nApsaugo programinę įrangą nuo pakeitimų po išleidimo" diff --git a/dll/win32/cryptui/cryptui_Nl.rc b/dll/win32/cryptui/cryptui_Nl.rc index faa32108eeb..3a2d2edfb43 100644 --- a/dll/win32/cryptui/cryptui_Nl.rc +++ b/dll/win32/cryptui/cryptui_Nl.rc @@ -119,6 +119,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Weet u zeker dat u dit certificaat wilt verwijderen?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Weet u zeker dat u deze certificaten wilt verwijderen?" IDS_CERT_MGR "Certificaten" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Bewijst de identiteit van een remote computer" IDS_PURPOSE_CLIENT_AUTH "Bewijst uw identiteit aan een remote computer" IDS_PURPOSE_CODE_SIGNING "Bewijst dat de software kwam van de software uitgever\nBeschermt software tegen wijzigingen na publicatie" diff --git a/dll/win32/cryptui/cryptui_Pt.rc b/dll/win32/cryptui/cryptui_Pt.rc index f8795293d9f..4b528b5b1f9 100644 --- a/dll/win32/cryptui/cryptui_Pt.rc +++ b/dll/win32/cryptui/cryptui_Pt.rc @@ -119,6 +119,7 @@ STRINGTABLE DISCARDABLE IDS_WARN_REMOVE_DEFAULT "Tem a certeza que deseja remover este certificado?" IDS_WARN_REMOVE_PLURAL_DEFAULT "Tem a certeza que deseja remover estes certificados?" IDS_CERT_MGR "Certificados" + IDS_FRIENDLY_NAME_NONE "" IDS_PURPOSE_SERVER_AUTH "Assegura a identidade de um computador remoto" IDS_PURPOSE_CLIENT_AUTH "Prova a sua identidade a um computador remoto" IDS_PURPOSE_CODE_SIGNING "Assegura que o software veio de uma editora de software\nProtege o software de alterações após publicação" diff --git a/dll/win32/cryptui/cryptuires.h b/dll/win32/cryptui/cryptuires.h index 716dba5e3a6..df321df4632 100644 --- a/dll/win32/cryptui/cryptuires.h +++ b/dll/win32/cryptui/cryptuires.h @@ -116,6 +116,7 @@ #define IDS_WARN_REMOVE_DEFAULT 1092 #define IDS_WARN_REMOVE_PLURAL_DEFAULT 1093 #define IDS_CERT_MGR 1094 +#define IDS_FRIENDLY_NAME_NONE 1095 #define IDS_PURPOSE_SERVER_AUTH 1100 #define IDS_PURPOSE_CLIENT_AUTH 1101 diff --git a/dll/win32/cryptui/main.c b/dll/win32/cryptui/main.c index 980706434a1..a95a7a487d3 100644 --- a/dll/win32/cryptui/main.c +++ b/dll/win32/cryptui/main.c @@ -104,6 +104,7 @@ static void add_cert_to_view(HWND lv, PCCERT_CONTEXT cert, DWORD *allocatedLen, WCHAR dateFmt[80]; /* sufficient for LOCALE_SSHORTDATE */ WCHAR date[80]; SYSTEMTIME sysTime; + LPWSTR none; item.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT; item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); @@ -155,8 +156,9 @@ static void add_cert_to_view(HWND lv, PCCERT_CONTEXT cert, DWORD *allocatedLen, item.iSubItem = 2; SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); - len = CertGetNameStringW(cert, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, - NULL, 0); + if (!CertGetCertificateContextProperty(cert, CERT_FRIENDLY_NAME_PROP_ID, + NULL, &len)) + len = LoadStringW(hInstance, IDS_FRIENDLY_NAME_NONE, (LPWSTR)&none, 0); if (len > *allocatedLen) { HeapFree(GetProcessHeap(), 0, *str); @@ -166,9 +168,11 @@ static void add_cert_to_view(HWND lv, PCCERT_CONTEXT cert, DWORD *allocatedLen, } if (*str) { - CertGetNameStringW(cert, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, - *str, len); - item.pszText = *str; + if (!CertGetCertificateContextProperty(cert, CERT_FRIENDLY_NAME_PROP_ID, + *str, &len)) + item.pszText = none; + else + item.pszText = *str; item.iSubItem = 3; SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); } @@ -348,6 +352,8 @@ static CERT_ENHKEY_USAGE *create_advanced_filter(void) return advancedUsage; } +static int CALLBACK cert_mgr_sort_by_subject(LPARAM lp1, LPARAM lp2, LPARAM lp); + static void show_store_certs(HWND hwnd, HCERTSTORE store) { HWND lv = GetDlgItem(hwnd, IDC_MGR_CERTS); @@ -443,6 +449,8 @@ static void show_store_certs(HWND hwnd, HCERTSTORE store) HeapFree(GetProcessHeap(), 0, advanced->rgpszUsageIdentifier); HeapFree(GetProcessHeap(), 0, advanced); } + SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv, + (LPARAM)cert_mgr_sort_by_subject); } static const WCHAR my[] = { 'M','y',0 }; @@ -1062,6 +1070,48 @@ static void cert_mgr_do_export(HWND hwnd) } } +static int cert_mgr_sort_by_text(HWND lv, int col, int index1, int index2) +{ + LVITEMW item; + WCHAR buf1[MAX_STRING_LEN]; + WCHAR buf2[MAX_STRING_LEN]; + + item.cchTextMax = sizeof(buf1) / sizeof(buf1[0]); + item.mask = LVIF_TEXT; + item.pszText = buf1; + item.iItem = index1; + item.iSubItem = col; + SendMessageW(lv, LVM_GETITEMW, 0, (LPARAM)&item); + item.pszText = buf2; + item.iItem = index2; + SendMessageW(lv, LVM_GETITEMW, 0, (LPARAM)&item); + return strcmpW(buf1, buf2); +} + +static int CALLBACK cert_mgr_sort_by_subject(LPARAM lp1, LPARAM lp2, LPARAM lp) +{ + return cert_mgr_sort_by_text((HWND)lp, 0, lp1, lp2); +} + +static int CALLBACK cert_mgr_sort_by_issuer(LPARAM lp1, LPARAM lp2, LPARAM lp) +{ + return cert_mgr_sort_by_text((HWND)lp, 1, lp1, lp2); +} + +static int CALLBACK cert_mgr_sort_by_date(LPARAM lp1, LPARAM lp2, LPARAM lp) +{ + PCCERT_CONTEXT cert1 = (PCCERT_CONTEXT)lp1; + PCCERT_CONTEXT cert2 = (PCCERT_CONTEXT)lp2; + return CompareFileTime(&cert1->pCertInfo->NotAfter, + &cert2->pCertInfo->NotAfter); +} + +static int CALLBACK cert_mgr_sort_by_friendly_name(LPARAM lp1, LPARAM lp2, + LPARAM lp) +{ + return cert_mgr_sort_by_text((HWND)lp, 3, lp1, lp2); +} + static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { @@ -1141,6 +1191,35 @@ static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, cert_mgr_do_remove(hwnd); break; } + case LVN_COLUMNCLICK: + { + NMLISTVIEW *nmlv = (NMLISTVIEW *)lp; + HWND lv = GetDlgItem(hwnd, IDC_MGR_CERTS); + + /* FIXME: doesn't support swapping sort order between ascending + * and descending. + */ + switch (nmlv->iSubItem) + { + case 0: + SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv, + (LPARAM)cert_mgr_sort_by_subject); + break; + case 1: + SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv, + (LPARAM)cert_mgr_sort_by_issuer); + break; + case 2: + SendMessageW(lv, LVM_SORTITEMS, 0, + (LPARAM)cert_mgr_sort_by_date); + break; + case 3: + SendMessageW(lv, LVM_SORTITEMSEX, (WPARAM)lv, + (LPARAM)cert_mgr_sort_by_friendly_name); + break; + } + break; + } } break; } @@ -1385,7 +1464,7 @@ static void enumerate_stores(HWND hwnd, CRYPTUI_ENUM_DATA *pEnumData) static void free_store_info(HWND tree) { HTREEITEM next = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_CHILD, - (LPARAM)NULL); + 0); while (next) { @@ -1473,7 +1552,7 @@ static LRESULT CALLBACK select_store_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, { HWND tree = GetDlgItem(hwnd, IDC_STORE_LIST); HTREEITEM selection = (HTREEITEM)SendMessageW(tree, - TVM_GETNEXTITEM, TVGN_CARET, (LPARAM)NULL); + TVM_GETNEXTITEM, TVGN_CARET, 0); selectInfo = (struct SelectStoreInfo *)GetWindowLongPtrW(hwnd, DWLP_USER); @@ -4034,8 +4113,7 @@ static void show_dialog_for_selected_cert(HWND hwnd) memset(&item, 0, sizeof(item)); item.mask = TVIF_HANDLE | TVIF_PARAM; - item.hItem = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_CARET, - (LPARAM)NULL); + item.hItem = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_CARET, 0); SendMessageW(tree, TVM_GETITEMW, 0, (LPARAM)&item); data = get_hierarchy_data_from_tree_item(tree, item.hItem); selection = lparam_to_index(data, item.lParam); @@ -4137,7 +4215,7 @@ static LRESULT CALLBACK hierarchy_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, memset(&item, 0, sizeof(item)); item.mask = TVIF_HANDLE | TVIF_PARAM; item.hItem = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_ROOT, - (LPARAM)NULL); + 0); data = get_hierarchy_data_from_tree_item(tree, item.hItem); /* Delete the contents of the tree */ SendMessageW(tree, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); diff --git a/dll/win32/dwmapi/dwmapi_main.c b/dll/win32/dwmapi/dwmapi_main.c index 60420282966..ee866912a35 100644 --- a/dll/win32/dwmapi/dwmapi_main.c +++ b/dll/win32/dwmapi/dwmapi_main.c @@ -54,7 +54,14 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) */ HRESULT WINAPI DwmIsCompositionEnabled(BOOL *enabled) { - FIXME("%p\n", enabled); + static int once; + if (!once) + { + FIXME("%p\n", enabled); + once = 1; + } + else + TRACE("%p\n", enabled); *enabled = FALSE; return S_OK; diff --git a/dll/win32/fusion/asmname.c b/dll/win32/fusion/asmname.c index 913674aa80e..3c014ea3244 100644 --- a/dll/win32/fusion/asmname.c +++ b/dll/win32/fusion/asmname.c @@ -471,6 +471,11 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam done: HeapFree(GetProcessHeap(), 0, save); + if (FAILED(hr)) + { + HeapFree(GetProcessHeap(), 0, name->displayname); + HeapFree(GetProcessHeap(), 0, name->name); + } return hr; } diff --git a/dll/win32/fusion/fusion_main.c b/dll/win32/fusion/fusion_main.c index 8bc4b1e3349..5c9d77646e0 100644 --- a/dll/win32/fusion/fusion_main.c +++ b/dll/win32/fusion/fusion_main.c @@ -34,6 +34,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) switch (fdwReason) { + case DLL_WINE_PREATTACH: + return FALSE; /* prefer native version */ case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls(hinstDLL); break; diff --git a/dll/win32/gdiplus/brush.c b/dll/win32/gdiplus/brush.c index bfce7d85bb5..2f2143dba58 100644 --- a/dll/win32/gdiplus/brush.c +++ b/dll/win32/gdiplus/brush.c @@ -87,13 +87,11 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone) break; } case BrushTypeHatchFill: - *clone = GdipAlloc(sizeof(GpHatch)); - if (!*clone) return OutOfMemory; + { + GpHatch *hatch = (GpHatch*)brush; - memcpy(*clone, brush, sizeof(GpHatch)); - - (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb); - break; + return GdipCreateHatchBrush(hatch->hatchstyle, hatch->forecol, hatch->backcol, (GpHatch**)clone); + } case BrushTypePathGradient:{ GpPathGradient *src, *dest; INT count; @@ -189,18 +187,29 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone) break; } case BrushTypeTextureFill: - *clone = GdipAlloc(sizeof(GpTexture)); - if(!*clone) return OutOfMemory; + { + GpStatus stat; + GpTexture *texture = (GpTexture*)brush; + GpTexture *new_texture; - memcpy(*clone, brush, sizeof(GpTexture)); + stat = GdipCreateTexture(texture->image, texture->wrap, &new_texture); - (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb); - break; + if (stat == Ok) + { + memcpy(new_texture->transform, texture->transform, sizeof(GpMatrix)); + *clone = (GpBrush*)new_texture; + } + else + *clone = NULL; + + return stat; + } default: ERR("not implemented for brush type %d\n", brush->bt); return NotImplemented; } + TRACE("<-- %p\n", *clone); return Ok; } @@ -317,6 +326,7 @@ GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, AR (*brush)->forecol = forecol; (*brush)->backcol = backcol; (*brush)->hatchstyle = hatchstyle; + TRACE("<-- %p\n", *brush); } else { @@ -336,8 +346,8 @@ GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint, { COLORREF col = ARGB2COLORREF(startcolor); - TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint, - startcolor, endcolor, wrap, line); + TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint), + debugstr_pointf(endpoint), startcolor, endcolor, wrap, line); if(!line || !startpoint || !endpoint || wrap == WrapModeClamp) return InvalidParameter; @@ -397,6 +407,8 @@ GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint, (*line)->pblendpos = NULL; (*line)->pblendcount = 0; + TRACE("<-- %p\n", *line); + return Ok; } @@ -491,20 +503,74 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect, /****************************************************************************** * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@] - * - * FIXME: angle value completely ignored. Don't know how to use it since native - * always set Brush rectangle to rect (independetly of this angle). - * Maybe it's used only on drawing. */ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect, ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap, GpLineGradient **line) { + GpStatus stat; + LinearGradientMode mode; + REAL width, height, exofs, eyofs; + REAL sin_angle, cos_angle, sin_cos_angle; + TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable, wrap, line); - return GdipCreateLineBrushFromRect(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal, - wrap, line); + sin_angle = sinf(deg2rad(angle)); + cos_angle = cosf(deg2rad(angle)); + sin_cos_angle = sin_angle * cos_angle; + + if (isAngleScalable) + { + width = height = 1.0; + } + else + { + width = rect->Width; + height = rect->Height; + } + + if (sin_cos_angle >= 0) + mode = LinearGradientModeForwardDiagonal; + else + mode = LinearGradientModeBackwardDiagonal; + + stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line); + + if (stat == Ok) + { + if (sin_cos_angle >= 0) + { + exofs = width * sin_cos_angle + height * cos_angle * cos_angle; + eyofs = width * sin_angle * sin_angle + height * sin_cos_angle; + } + else + { + exofs = width * sin_angle * sin_angle + height * sin_cos_angle; + eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle; + } + + if (isAngleScalable) + { + exofs = exofs * rect->Width; + eyofs = eyofs * rect->Height; + } + + if (sin_angle >= 0) + { + (*line)->endpoint.X = rect->X + exofs; + (*line)->endpoint.Y = rect->Y + eyofs; + } + else + { + (*line)->endpoint.X = (*line)->startpoint.X; + (*line)->endpoint.Y = (*line)->startpoint.Y; + (*line)->startpoint.X = rect->X + exofs; + (*line)->startpoint.Y = rect->Y + eyofs; + } + } + + return stat; } GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect, @@ -571,6 +637,8 @@ GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points, (*grad)->focus.X = 0.0; (*grad)->focus.Y = 0.0; + TRACE("<-- %p\n", *grad); + return Ok; } @@ -661,6 +729,8 @@ GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path, (*grad)->focus.X = 0.0; (*grad)->focus.Y = 0.0; + TRACE("<-- %p\n", *grad); + return Ok; } @@ -687,6 +757,8 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf) (*sf)->color = color; (*sf)->bmp = ARGB2BMP(color); + TRACE("<-- %p\n", *sf); + return Ok; } @@ -749,14 +821,9 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width, REAL height, GpTexture **texture) { - HDC hdc; - HBITMAP hbm, old = NULL; - BITMAPINFO *pbmi; - BITMAPINFOHEADER *bmih; - INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp; - BOOL bm_is_selected; - BYTE *dibits, *buff, *textbits; + HBITMAP hbm; GpStatus status; + GpImage *new_image=NULL; TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height, texture); @@ -764,124 +831,61 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0) return InvalidParameter; + *texture = NULL; + if(image->type != ImageTypeBitmap){ FIXME("not implemented for image type %d\n", image->type); return NotImplemented; } - n_x = roundr(x); - n_y = roundr(y); - n_width = roundr(width); - n_height = roundr(height); + status = GdipCloneBitmapArea(x, y, width, height, PixelFormatDontCare, (GpBitmap*)image, (GpBitmap**)&new_image); + if (status != Ok) + return status; - if(n_x + n_width > ((GpBitmap*)image)->width || - n_y + n_height > ((GpBitmap*)image)->height) - return InvalidParameter; - - hbm = ((GpBitmap*)image)->hbitmap; - if(!hbm) return GenericError; - hdc = ((GpBitmap*)image)->hdc; - bm_is_selected = (hdc != 0); - - pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); - if (!pbmi) - return OutOfMemory; - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biBitCount = 0; - - if(!bm_is_selected){ - hdc = CreateCompatibleDC(0); - old = SelectObject(hdc, hbm); + hbm = ((GpBitmap*)new_image)->hbitmap; + if(!hbm) + { + status = GenericError; + goto exit; } - /* fill out bmi */ - GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); - - bytespp = pbmi->bmiHeader.biBitCount / 8; - abs_height = abs(pbmi->bmiHeader.biHeight); - - if(n_x > pbmi->bmiHeader.biWidth || n_x + n_width > pbmi->bmiHeader.biWidth || - n_y > abs_height || n_y + n_height > abs_height){ - GdipFree(pbmi); - return InvalidParameter; - } - - dibits = GdipAlloc(pbmi->bmiHeader.biSizeImage); - - if(dibits) /* this is not a good place to error out */ - GetDIBits(hdc, hbm, 0, abs_height, dibits, pbmi, DIB_RGB_COLORS); - - if(!bm_is_selected){ - SelectObject(hdc, old); - DeleteDC(hdc); - } - - if(!dibits){ - GdipFree(pbmi); - return OutOfMemory; - } - - image_stride = (pbmi->bmiHeader.biWidth * bytespp + 3) & ~3; - stride = (n_width * bytespp + 3) & ~3; - buff = GdipAlloc(sizeof(BITMAPINFOHEADER) + stride * n_height); - if(!buff){ - GdipFree(pbmi); - GdipFree(dibits); - return OutOfMemory; - } - - bmih = (BITMAPINFOHEADER*)buff; - textbits = (BYTE*) (bmih + 1); - bmih->biSize = sizeof(BITMAPINFOHEADER); - bmih->biWidth = n_width; - bmih->biHeight = n_height; - bmih->biCompression = BI_RGB; - bmih->biSizeImage = stride * n_height; - bmih->biBitCount = pbmi->bmiHeader.biBitCount; - bmih->biClrUsed = 0; - bmih->biPlanes = 1; - - /* image is flipped */ - if(pbmi->bmiHeader.biHeight > 0){ - dibits += image_stride * (pbmi->bmiHeader.biHeight - 1); - image_stride *= -1; - textbits += stride * (n_height - 1); - stride *= -1; - } - - GdipFree(pbmi); - - for(i = 0; i < n_height; i++) - memcpy(&textbits[i * stride], - &dibits[n_x * bytespp + (n_y + i) * image_stride], - abs(stride)); - *texture = GdipAlloc(sizeof(GpTexture)); if (!*texture){ - GdipFree(dibits); - GdipFree(buff); - return OutOfMemory; + status = OutOfMemory; + goto exit; } if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){ - GdipFree(*texture); - GdipFree(dibits); - GdipFree(buff); - return status; + goto exit; } - (*texture)->brush.lb.lbStyle = BS_DIBPATTERNPT; - (*texture)->brush.lb.lbColor = DIB_RGB_COLORS; - (*texture)->brush.lb.lbHatch = (ULONG_PTR)buff; + (*texture)->brush.lb.lbStyle = BS_PATTERN; + (*texture)->brush.lb.lbColor = 0; + (*texture)->brush.lb.lbHatch = (ULONG_PTR)hbm; (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb); (*texture)->brush.bt = BrushTypeTextureFill; (*texture)->wrap = imageattr->wrap; + (*texture)->image = new_image; - GdipFree(dibits); - GdipFree(buff); +exit: + if (status == Ok) + { + TRACE("<-- %p\n", *texture); + } + else + { + if (*texture) + { + GdipDeleteMatrix((*texture)->transform); + GdipFree(*texture); + *texture = NULL; + } + GdipDisposeImage(new_image); + TRACE("<-- error %u\n", status); + } - return Ok; + return status; } /****************************************************************************** @@ -979,6 +983,7 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush) break; case BrushTypeTextureFill: GdipDeleteMatrix(((GpTexture*)brush)->transform); + GdipDisposeImage(((GpTexture*)brush)->image); break; default: break; @@ -1175,6 +1180,8 @@ GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient { static int calls; + TRACE("(%p,%p,%p)\n", grad, argb, count); + if(!grad || !argb || !count || (*count < grad->pathdata.Count)) return InvalidParameter; @@ -1209,6 +1216,19 @@ GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb) return Ok; } +/****************************************************************************** + * GdipGetTextureImage [GDIPLUS.@] + */ +GpStatus WINGDIPAPI GdipGetTextureImage(GpTexture *brush, GpImage **image) +{ + TRACE("(%p, %p)\n", brush, image); + + if(!brush || !image) + return InvalidParameter; + + return GdipCloneImage(brush->image, image); +} + /****************************************************************************** * GdipGetTextureTransform [GDIPLUS.@] */ @@ -1430,6 +1450,8 @@ GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST RE { static int calls; + TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count); + if(!(calls++)) FIXME("not implemented\n"); @@ -1463,7 +1485,7 @@ GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad, GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad, GpPointF *point) { - TRACE("(%p, %p)\n", grad, point); + TRACE("(%p, %s)\n", grad, debugstr_pointf(point)); if(!grad || !point) return InvalidParameter; @@ -1522,6 +1544,8 @@ GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad, { static int calls; + TRACE("(%p,%0.2f,%0.2f)\n", grad, focus, scale); + if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0) return InvalidParameter; @@ -1536,6 +1560,8 @@ GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient { static int calls; + TRACE("(%p,%p,%p)\n", grad, argb, count); + if(!grad || !argb || !count || (*count <= 0) || (*count > grad->pathdata.Count)) return InvalidParameter; @@ -1749,6 +1775,8 @@ GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush) { static int calls; + TRACE("(%p)\n", brush); + if(!(calls++)) FIXME("not implemented\n"); @@ -1760,6 +1788,8 @@ GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush, { static int calls; + TRACE("(%p,%p)\n", brush, matrix); + if(!(calls++)) FIXME("not implemented\n"); @@ -1771,6 +1801,8 @@ GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL { static int calls; + TRACE("(%p,%0.2f,%0.2f,%u)\n", brush, sx, sy, order); + if(!(calls++)) FIXME("not implemented\n"); @@ -1838,6 +1870,8 @@ GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush, { static int calls; + TRACE("(%p,%0.2f,%u)\n", brush, angle, order); + if(!brush) return InvalidParameter; diff --git a/dll/win32/gdiplus/customlinecap.c b/dll/win32/gdiplus/customlinecap.c index 5658e69c00d..00c228bf3cf 100644 --- a/dll/win32/gdiplus/customlinecap.c +++ b/dll/win32/gdiplus/customlinecap.c @@ -57,6 +57,8 @@ GpStatus WINGDIPAPI GdipCloneCustomLineCap(GpCustomLineCap* from, * sizeof(PointF)); memcpy((*to)->pathdata.Types, from->pathdata.Types, from->pathdata.Count); + TRACE("<-- %p\n", *to); + return Ok; } @@ -105,6 +107,8 @@ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath (*customCap)->join = LineJoinMiter; (*customCap)->scale = 1.0; + TRACE("<-- %p\n", *customCap); + return Ok; } @@ -153,6 +157,8 @@ GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeCaps(GpCustomLineCap* custom, { static int calls; + TRACE("(%p,%u,%u)\n", custom, start, end); + if(!custom) return InvalidParameter; @@ -167,6 +173,8 @@ GpStatus WINGDIPAPI GdipSetCustomLineCapBaseCap(GpCustomLineCap* custom, { static int calls; + TRACE("(%p,%u)\n", custom, base); + if(!(calls++)) FIXME("not implemented\n"); @@ -191,6 +199,8 @@ GpStatus WINGDIPAPI GdipSetCustomLineCapBaseInset(GpCustomLineCap* custom, { static int calls; + TRACE("(%p,%0.2f)\n", custom, inset); + if(!(calls++)) FIXME("not implemented\n"); @@ -216,6 +226,8 @@ GpStatus WINGDIPAPI GdipSetCustomLineCapWidthScale(GpCustomLineCap* custom, { static int calls; + TRACE("(%p,%0.2f)\n", custom, width); + if(!(calls++)) FIXME("not implemented\n"); @@ -239,6 +251,8 @@ GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL f { static int calls; + TRACE("(%0.2f,%0.2f,%i,%p)\n", height, width, fill, cap); + if(!(calls++)) FIXME("not implemented\n"); @@ -249,6 +263,8 @@ GpStatus WINGDIPAPI GdipGetAdjustableArrowCapFillState(GpAdjustableArrowCap* cap { static int calls; + TRACE("(%p,%p)\n", cap, fill); + if(!(calls++)) FIXME("not implemented\n"); @@ -259,6 +275,8 @@ GpStatus WINGDIPAPI GdipGetAdjustableArrowCapHeight(GpAdjustableArrowCap* cap, R { static int calls; + TRACE("(%p,%p)\n", cap, height); + if(!(calls++)) FIXME("not implemented\n"); @@ -269,6 +287,8 @@ GpStatus WINGDIPAPI GdipGetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap* c { static int calls; + TRACE("(%p,%p)\n", cap, middle); + if(!(calls++)) FIXME("not implemented\n"); @@ -279,6 +299,8 @@ GpStatus WINGDIPAPI GdipGetAdjustableArrowCapWidth(GpAdjustableArrowCap* cap, RE { static int calls; + TRACE("(%p,%p)\n", cap, width); + if(!(calls++)) FIXME("not implemented\n"); @@ -289,6 +311,8 @@ GpStatus WINGDIPAPI GdipSetAdjustableArrowCapFillState(GpAdjustableArrowCap* cap { static int calls; + TRACE("(%p,%i)\n", cap, fill); + if(!(calls++)) FIXME("not implemented\n"); @@ -299,6 +323,8 @@ GpStatus WINGDIPAPI GdipSetAdjustableArrowCapHeight(GpAdjustableArrowCap* cap, R { static int calls; + TRACE("(%p,%0.2f)\n", cap, height); + if(!(calls++)) FIXME("not implemented\n"); @@ -309,6 +335,8 @@ GpStatus WINGDIPAPI GdipSetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap* c { static int calls; + TRACE("(%p,%0.2f)\n", cap, middle); + if(!(calls++)) FIXME("not implemented\n"); @@ -319,6 +347,8 @@ GpStatus WINGDIPAPI GdipSetAdjustableArrowCapWidth(GpAdjustableArrowCap* cap, RE { static int calls; + TRACE("(%p,%0.2f)\n", cap, width); + if(!(calls++)) FIXME("not implemented\n"); diff --git a/dll/win32/gdiplus/font.c b/dll/win32/gdiplus/font.c index 89498bce0d0..fda5428a7dd 100644 --- a/dll/win32/gdiplus/font.c +++ b/dll/win32/gdiplus/font.c @@ -158,6 +158,8 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily, (*font)->height = tmw->ntmSizeEM; (*font)->line_spacing = tmw->tmAscent + tmw->tmDescent + tmw->tmExternalLeading; + TRACE("<-- %p\n", *font); + return Ok; } @@ -205,6 +207,8 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc, SelectObject(hdc, oldfont); DeleteObject(hfont); + TRACE("<-- %p\n", *font); + return Ok; } @@ -583,6 +587,8 @@ GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name, *FontFamily = ffamily; + TRACE("<-- %p\n", ffamily); + return Ok; } @@ -611,6 +617,8 @@ GpStatus WINGDIPAPI GdipCloneFontFamily(GpFontFamily* FontFamily, GpFontFamily** (*clonedFontFamily)->tmw = FontFamily->tmw; lstrcpyW((*clonedFontFamily)->FamilyName, FontFamily->FamilyName); + TRACE("<-- %p\n", *clonedFontFamily); + return Ok; } @@ -845,6 +853,9 @@ GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollecti (*fontCollection)->FontFamilies = NULL; (*fontCollection)->count = 0; (*fontCollection)->allocated = 0; + + TRACE("<-- %p\n", *fontCollection); + return Ok; } diff --git a/dll/win32/gdiplus/gdiplus.c b/dll/win32/gdiplus/gdiplus.c index 9fe933280ab..383f53621fb 100644 --- a/dll/win32/gdiplus/gdiplus.c +++ b/dll/win32/gdiplus/gdiplus.c @@ -58,9 +58,6 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) switch(reason) { - case DLL_WINE_PREATTACH: - return FALSE; /* prefer native version */ - case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls( hinst ); break; @@ -444,3 +441,9 @@ const char *debugstr_rectf(CONST RectF* rc) if (!rc) return "(null)"; return wine_dbg_sprintf("(%0.2f,%0.2f,%0.2f,%0.2f)", rc->X, rc->Y, rc->Width, rc->Height); } + +const char *debugstr_pointf(CONST PointF* pt) +{ + if (!pt) return "(null)"; + return wine_dbg_sprintf("(%0.2f,%0.2f)", pt->X, pt->Y); +} diff --git a/dll/win32/gdiplus/gdiplus.spec b/dll/win32/gdiplus/gdiplus.spec index aa64a3cb311..e6cea5ad443 100644 --- a/dll/win32/gdiplus/gdiplus.spec +++ b/dll/win32/gdiplus/gdiplus.spec @@ -290,7 +290,7 @@ @ stdcall GdipGetImageGraphicsContext(ptr ptr) @ stdcall GdipGetImageHeight(ptr ptr) @ stdcall GdipGetImageHorizontalResolution(ptr ptr) -@ stub GdipGetImageItemData +@ stdcall GdipGetImageItemData(ptr ptr) @ stdcall GdipGetImagePalette(ptr ptr long) @ stdcall GdipGetImagePaletteSize(ptr ptr) @ stdcall GdipGetImagePixelFormat(ptr ptr) @@ -381,7 +381,7 @@ @ stdcall GdipGetRegionDataSize(ptr ptr) @ stdcall GdipGetRegionHRgn(ptr ptr ptr) @ stub GdipGetRegionScans -@ stub GdipGetRegionScansCount +@ stdcall GdipGetRegionScansCount(ptr ptr ptr) @ stub GdipGetRegionScansI @ stub GdipGetRenderingOrigin @ stdcall GdipGetSmoothingMode(ptr ptr) @@ -397,7 +397,7 @@ @ stdcall GdipGetStringFormatTrimming(ptr ptr) @ stdcall GdipGetTextContrast(ptr ptr) @ stdcall GdipGetTextRenderingHint(ptr ptr) -@ stub GdipGetTextureImage +@ stdcall GdipGetTextureImage(ptr ptr) @ stdcall GdipGetTextureTransform(ptr ptr) @ stdcall GdipGetTextureWrapMode(ptr ptr) @ stdcall GdipGetVisibleClipBounds(ptr ptr) @@ -424,7 +424,7 @@ @ stdcall GdipIsOutlineVisiblePathPoint(ptr long long ptr ptr ptr) @ stdcall GdipIsOutlineVisiblePathPointI(ptr long long ptr ptr ptr) @ stdcall GdipIsStyleAvailable(ptr long ptr) -@ stub GdipIsVisibleClipEmpty +@ stdcall GdipIsVisibleClipEmpty(ptr ptr) @ stdcall GdipIsVisiblePathPoint(ptr long long ptr ptr) @ stdcall GdipIsVisiblePathPointI(ptr long long ptr ptr) @ stdcall GdipIsVisiblePoint(ptr long long ptr) diff --git a/dll/win32/gdiplus/gdiplus_private.h b/dll/win32/gdiplus/gdiplus_private.h index 0ceeb6e0e8b..ca1cba6175c 100644 --- a/dll/win32/gdiplus/gdiplus_private.h +++ b/dll/win32/gdiplus/gdiplus_private.h @@ -80,9 +80,15 @@ static inline REAL deg2rad(REAL degrees) extern const char *debugstr_rectf(CONST RectF* rc); +extern const char *debugstr_pointf(CONST PointF* pt); + extern void convert_32bppARGB_to_32bppPARGB(UINT width, UINT height, BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride); +extern GpStatus convert_pixels(UINT width, UINT height, + INT dst_stride, BYTE *dst_bits, PixelFormat dst_format, + INT src_stride, const BYTE *src_bits, PixelFormat src_format, ARGB *src_palette); + struct GpPen{ UINT style; GpUnit unit; @@ -174,6 +180,7 @@ struct GpLineGradient{ struct GpTexture{ GpBrush brush; GpMatrix *transform; + GpImage *image; WrapMode wrap; /* not used yet */ }; @@ -217,6 +224,7 @@ struct GpImage{ UINT palette_count; UINT palette_size; ARGB *palette_entries; + REAL xres, yres; }; struct GpMetafile{ @@ -249,9 +257,26 @@ struct color_key{ ARGB high; }; +struct color_matrix{ + BOOL enabled; + ColorMatrixFlags flags; + ColorMatrix colormatrix; + ColorMatrix graymatrix; +}; + +struct color_remap_table{ + BOOL enabled; + INT mapsize; + GDIPCONST ColorMap *colormap; +}; + struct GpImageAttributes{ WrapMode wrap; struct color_key colorkeys[ColorAdjustTypeCount]; + struct color_matrix colormatrices[ColorAdjustTypeCount]; + struct color_remap_table colorremaptables[ColorAdjustTypeCount]; + BOOL gamma_enabled[ColorAdjustTypeCount]; + REAL gamma[ColorAdjustTypeCount]; }; struct GpFont{ @@ -274,6 +299,8 @@ struct GpStringFormat{ INT tabcount; REAL firsttab; REAL *tabs; + CharacterRange *character_ranges; + INT range_count; }; struct GpFontCollection{ diff --git a/dll/win32/gdiplus/graphics.c b/dll/win32/gdiplus/graphics.c index b1092b77621..1fd870e3d42 100644 --- a/dll/win32/gdiplus/graphics.c +++ b/dll/win32/gdiplus/graphics.c @@ -1162,6 +1162,8 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra list_init(&(*graphics)->containers); (*graphics)->contid = 0; + TRACE("<-- %p\n", *graphics); + return Ok; } @@ -1199,6 +1201,8 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, { static int calls; + TRACE("(%p,%i,%p)\n", hemf, delete, metafile); + if(!hemf || !metafile) return InvalidParameter; @@ -1215,7 +1219,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, UINT read; BYTE* copy; HENHMETAFILE hemf; - GpStatus retval = GenericError; + GpStatus retval = Ok; TRACE("(%p, %d, %p, %p)\n", hwmf, delete, placeable, metafile); @@ -1240,6 +1244,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, if(CreateStreamOnHGlobal(copy, TRUE, &stream) != S_OK){ ERR("could not make stream\n"); GdipFree(copy); + retval = GenericError; goto err; } @@ -1251,7 +1256,10 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture, (LPVOID*) &((*metafile)->image.picture)) != S_OK) + { + retval = GenericError; goto err; + } (*metafile)->image.type = ImageTypeMetafile; @@ -1260,8 +1268,10 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, (*metafile)->image.palette_count = 0; (*metafile)->image.palette_size = 0; (*metafile)->image.palette_entries = NULL; + (*metafile)->image.xres = (REAL)placeable->Inch; + (*metafile)->image.yres = (REAL)placeable->Inch; (*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch); - (*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Right) / ((REAL) placeable->Inch); + (*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Top) / ((REAL) placeable->Inch); (*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right - placeable->BoundingBox.Left)) / ((REAL) placeable->Inch); (*metafile)->bounds.Height = ((REAL) (placeable->BoundingBox.Bottom @@ -1271,10 +1281,11 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete, if(delete) DeleteMetaFile(hwmf); - return Ok; + TRACE("<-- %p\n", *metafile); err: - GdipFree(*metafile); + if (retval != Ok) + GdipFree(*metafile); IStream_Release(stream); return retval; } @@ -1872,6 +1883,9 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image if(!graphics || !image || !points || count != 3) return InvalidParameter; + TRACE("%s %s %s\n", debugstr_pointf(&points[0]), debugstr_pointf(&points[1]), + debugstr_pointf(&points[2])); + memcpy(ptf, points, 3 * sizeof(GpPointF)); transform_and_round_points(graphics, pti, ptf, 3); @@ -1912,12 +1926,16 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image else return NotImplemented; - if (bitmap->format == PixelFormat32bppARGB) + if (!(bitmap->format == PixelFormat16bppRGB555 || + bitmap->format == PixelFormat24bppRGB || + bitmap->format == PixelFormat32bppRGB || + bitmap->format == PixelFormat32bppPARGB)) { BITMAPINFOHEADER bih; BYTE *temp_bits; + PixelFormat dst_format; - /* we need a bitmap with premultiplied alpha */ + /* we can't draw a bitmap of this format directly */ hdc = CreateCompatibleDC(0); temp_hdc = 1; temp_bitmap = 1; @@ -1937,8 +1955,14 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&temp_bits, NULL, 0); - convert_32bppARGB_to_32bppPARGB(bitmap->width, bitmap->height, - temp_bits, bitmap->width*4, bitmap->bits, bitmap->stride); + if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha)) + dst_format = PixelFormat32bppPARGB; + else + dst_format = PixelFormat32bppRGB; + + convert_pixels(bitmap->width, bitmap->height, + bitmap->width*4, temp_bits, dst_format, + bitmap->stride, bitmap->bits, bitmap->format, bitmap->image.palette_entries); } else { @@ -1953,7 +1977,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image old_hbm = SelectObject(hdc, hbitmap); } - if (bitmap->format == PixelFormat32bppARGB || bitmap->format == PixelFormat32bppPARGB) + if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha)) { BLENDFUNCTION bf; @@ -3052,6 +3076,8 @@ GpStatus WINGDIPAPI GdipFlush(GpGraphics *graphics, GpFlushIntention intention) { static int calls; + TRACE("(%p,%u)\n", graphics, intention); + if(!graphics) return InvalidParameter; @@ -3147,17 +3173,18 @@ GpStatus WINGDIPAPI GdipGetInterpolationMode(GpGraphics *graphics, return Ok; } +/* FIXME: Need to handle color depths less than 24bpp */ GpStatus WINGDIPAPI GdipGetNearestColor(GpGraphics *graphics, ARGB* argb) { + FIXME("(%p, %p): Passing color unmodified\n", graphics, argb); + if(!graphics || !argb) return InvalidParameter; if(graphics->busy) return ObjectBusy; - FIXME("(%p, %p): stub\n", graphics, argb); - - return NotImplemented; + return Ok; } GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics *graphics, REAL *scale) @@ -3443,12 +3470,12 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics, GDIPCONST RectF* layoutRect, GDIPCONST GpStringFormat *stringFormat, INT regionCount, GpRegion** regions) { - if (!(graphics && string && font && layoutRect && stringFormat && regions)) - return InvalidParameter; - FIXME("stub: %p %s %d %p %p %p %d %p\n", graphics, debugstr_w(string), length, font, layoutRect, stringFormat, regionCount, regions); + if (!(graphics && string && font && layoutRect && stringFormat && regions)) + return InvalidParameter; + return NotImplemented; } @@ -4001,6 +4028,8 @@ GpStatus WINGDIPAPI GdipSetMetafileDownLevelRasterizationLimit(GpMetafile *metaf { static int calls; + TRACE("(%p,%u)\n", metafile, limitDpi); + if(!(calls++)) FIXME("not implemented\n"); @@ -4341,3 +4370,26 @@ GpStatus WINGDIPAPI GdipRecordMetafileI(HDC hdc, EmfType type, GDIPCONST GpRect FIXME("(%p %d %p %d %p %p): stub\n", hdc, type, frameRect, frameUnit, desc, metafile); return NotImplemented; } + +/***************************************************************************** + * GdipIsVisibleClipEmpty [GDIPLUS.@] + */ +GpStatus WINGDIPAPI GdipIsVisibleClipEmpty(GpGraphics *graphics, BOOL *res) +{ + GpStatus stat; + GpRegion* rgn; + + TRACE("(%p, %p)\n", graphics, res); + + if((stat = GdipCreateRegion(&rgn)) != Ok) + return stat; + + if((stat = get_visible_clip_region(graphics, rgn)) != Ok) + goto cleanup; + + stat = GdipIsEmptyRegion(rgn, graphics, res); + +cleanup: + GdipDeleteRegion(rgn); + return stat; +} diff --git a/dll/win32/gdiplus/graphicspath.c b/dll/win32/gdiplus/graphicspath.c index 94e17dda39c..60ddda1d7b5 100644 --- a/dll/win32/gdiplus/graphicspath.c +++ b/dll/win32/gdiplus/graphicspath.c @@ -1380,6 +1380,8 @@ GpStatus WINGDIPAPI GdipIsOutlineVisiblePathPoint(GpPath* path, REAL x, REAL y, { static int calls; + TRACE("(%p,%0.2f,%0.2f,%p,%p,%p)\n", path, x, y, pen, graphics, result); + if(!path || !pen) return InvalidParameter; diff --git a/dll/win32/gdiplus/image.c b/dll/win32/gdiplus/image.c index 3dbe4daf8be..d72d4cfbb8a 100644 --- a/dll/win32/gdiplus/image.c +++ b/dll/win32/gdiplus/image.c @@ -94,6 +94,24 @@ GpStatus WINGDIPAPI GdipBitmapCreateApplyEffect(GpBitmap** inputBitmaps, return NotImplemented; } +static inline void getpixel_1bppIndexed(BYTE *index, const BYTE *row, UINT x) +{ + *index = (row[x/8]>>(7-x%8)) & 1; +} + +static inline void getpixel_4bppIndexed(BYTE *index, const BYTE *row, UINT x) +{ + if (x & 1) + *index = row[x/2]&0xf; + else + *index = row[x/2]>>4; +} + +static inline void getpixel_8bppIndexed(BYTE *index, const BYTE *row, UINT x) +{ + *index = row[x]; +} + static inline void getpixel_16bppGrayScale(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x) { @@ -211,6 +229,7 @@ GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, ARGB *color) { BYTE r, g, b, a; + BYTE index; BYTE *row; TRACE("%p %d %d %p\n", bitmap, x, y, color); @@ -222,6 +241,15 @@ GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, switch (bitmap->format) { + case PixelFormat1bppIndexed: + getpixel_1bppIndexed(&index,row,x); + break; + case PixelFormat4bppIndexed: + getpixel_4bppIndexed(&index,row,x); + break; + case PixelFormat8bppIndexed: + getpixel_8bppIndexed(&index,row,x); + break; case PixelFormat16bppGrayScale: getpixel_16bppGrayScale(&r,&g,&b,&a,row,x); break; @@ -260,7 +288,10 @@ GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, return NotImplemented; } - *color = a<<24|r<<16|g<<8|b; + if (bitmap->format & PixelFormatIndexed) + *color = bitmap->image.palette_entries[index]; + else + *color = a<<24|r<<16|g<<8|b; return Ok; } @@ -411,6 +442,412 @@ GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap* bitmap, INT x, INT y, return Ok; } +GpStatus convert_pixels(UINT width, UINT height, + INT dst_stride, BYTE *dst_bits, PixelFormat dst_format, + INT src_stride, const BYTE *src_bits, PixelFormat src_format, ARGB *src_palette) +{ + UINT x, y; + + if (src_format == dst_format || + (dst_format == PixelFormat32bppRGB && PIXELFORMATBPP(src_format) == 32)) + { + UINT widthbytes = PIXELFORMATBPP(src_format) * width / 8; + for (y=0; ylockmode) + { + WARN("bitmap is already locked and cannot be locked again\n"); return WrongState; + } if (bitmap->bits && bitmap->format == format) { @@ -470,83 +911,77 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect, return Ok; } - hbm = bitmap->hbitmap; - hdc = bitmap->hdc; - bm_is_selected = (hdc != 0); - - pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); - if (!pbmi) - return OutOfMemory; - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biBitCount = 0; - - if(!bm_is_selected){ - hdc = CreateCompatibleDC(0); - old = SelectObject(hdc, hbm); + /* Make sure we can convert to the requested format. */ + stat = convert_pixels(0, 0, 0, NULL, format, 0, NULL, bitmap->format, NULL); + if (stat == NotImplemented) + { + FIXME("cannot read bitmap from %x to %x\n", bitmap->format, format); + return NotImplemented; } - /* fill out bmi */ - GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); + /* If we're opening for writing, make sure we'll be able to write back in + * the original format. */ + if (flags & ImageLockModeWrite) + { + stat = convert_pixels(0, 0, 0, NULL, bitmap->format, 0, NULL, format, NULL); + if (stat == NotImplemented) + { + FIXME("cannot write bitmap from %x to %x\n", format, bitmap->format); + return NotImplemented; + } + } - abs_height = abs(pbmi->bmiHeader.biHeight); - stride = pbmi->bmiHeader.biWidth * bitspp / 8; + abs_height = bitmap->height; + stride = (bitmap->width * bitspp + 7) / 8; stride = (stride + 3) & ~3; buff = GdipAlloc(stride * abs_height); - pbmi->bmiHeader.biBitCount = bitspp; + if (!buff) return OutOfMemory; - if(buff) - GetDIBits(hdc, hbm, 0, abs_height, buff, pbmi, DIB_RGB_COLORS); + stat = convert_pixels(bitmap->width, bitmap->height, + stride, buff, format, + bitmap->stride, bitmap->bits, bitmap->format, bitmap->image.palette_entries); - if(!bm_is_selected){ - SelectObject(hdc, old); - DeleteDC(hdc); - } - - if(!buff){ - GdipFree(pbmi); - return OutOfMemory; + if (stat != Ok) + { + GdipFree(buff); + return stat; } lockeddata->Width = act_rect.Width; lockeddata->Height = act_rect.Height; lockeddata->PixelFormat = format; lockeddata->Reserved = flags; - - if(pbmi->bmiHeader.biHeight > 0){ - lockeddata->Stride = -stride; - lockeddata->Scan0 = buff + (bitspp / 8) * act_rect.X + - stride * (abs_height - 1 - act_rect.Y); - } - else{ - lockeddata->Stride = stride; - lockeddata->Scan0 = buff + (bitspp / 8) * act_rect.X + stride * act_rect.Y; - } + lockeddata->Stride = stride; + lockeddata->Scan0 = buff + (bitspp / 8) * act_rect.X + stride * act_rect.Y; bitmap->lockmode = flags; bitmap->numlocks++; - bitmap->bitmapbits = buff; - GdipFree(pbmi); return Ok; } GpStatus WINGDIPAPI GdipBitmapSetResolution(GpBitmap* bitmap, REAL xdpi, REAL ydpi) { - FIXME("(%p, %.2f, %.2f)\n", bitmap, xdpi, ydpi); + TRACE("(%p, %.2f, %.2f)\n", bitmap, xdpi, ydpi); - return NotImplemented; + if (!bitmap || xdpi == 0.0 || ydpi == 0.0) + return InvalidParameter; + + bitmap->image.xres = xdpi; + bitmap->image.yres = ydpi; + + return Ok; } GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, BitmapData* lockeddata) { - HDC hdc; - HBITMAP hbm, old = NULL; - BOOL bm_is_selected; - BITMAPINFO *pbmi; + GpStatus stat; + + TRACE("(%p,%p)\n", bitmap, lockeddata); if(!bitmap || !lockeddata) return InvalidParameter; @@ -570,38 +1005,25 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, { /* we passed a direct reference; no need to do anything */ bitmap->lockmode = 0; + bitmap->numlocks = 0; return Ok; } - hbm = bitmap->hbitmap; - hdc = bitmap->hdc; - bm_is_selected = (hdc != 0); + stat = convert_pixels(bitmap->width, bitmap->height, + bitmap->stride, bitmap->bits, bitmap->format, + lockeddata->Stride, bitmap->bitmapbits, lockeddata->PixelFormat, NULL); - pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biBitCount = 0; - - if(!bm_is_selected){ - hdc = CreateCompatibleDC(0); - old = SelectObject(hdc, hbm); + if (stat != Ok) + { + ERR("failed to convert pixels; this should never happen\n"); } - GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); - pbmi->bmiHeader.biBitCount = PIXELFORMATBPP(lockeddata->PixelFormat); - SetDIBits(hdc, hbm, 0, abs(pbmi->bmiHeader.biHeight), - bitmap->bitmapbits, pbmi, DIB_RGB_COLORS); - - if(!bm_is_selected){ - SelectObject(hdc, old); - DeleteDC(hdc); - } - - GdipFree(pbmi); GdipFree(bitmap->bitmapbits); bitmap->bitmapbits = NULL; bitmap->lockmode = 0; + bitmap->numlocks = 0; - return Ok; + return stat; } GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height, @@ -613,7 +1035,7 @@ GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height, Rect area; GpStatus stat; - TRACE("(%f,%f,%f,%f,%i,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap); + TRACE("(%f,%f,%f,%f,0x%x,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap); if (!srcBitmap || !dstBitmap || srcBitmap->image.type != ImageTypeBitmap || x < 0 || y < 0 || @@ -671,7 +1093,7 @@ GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height, GpStatus WINGDIPAPI GdipCloneBitmapAreaI(INT x, INT y, INT width, INT height, PixelFormat format, GpBitmap* srcBitmap, GpBitmap** dstBitmap) { - TRACE("(%i,%i,%i,%i,%i,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap); + TRACE("(%i,%i,%i,%i,0x%x,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap); return GdipCloneBitmapArea(x, y, width, height, format, srcBitmap, dstBitmap); } @@ -937,6 +1359,9 @@ GpStatus WINGDIPAPI GdipConvertToEmfPlus(const GpGraphics* ref, { static int calls; + TRACE("(%p,%p,%p,%u,%s,%p)\n", ref, metafile, succ, emfType, + debugstr_w(description), out_metafile); + if(!ref || !metafile || !out_metafile) return InvalidParameter; @@ -1172,17 +1597,33 @@ static void generate_halftone_palette(ARGB *entries, UINT count) } } +static GpStatus get_screen_resolution(REAL *xres, REAL *yres) +{ + HDC screendc = GetDC(0); + + if (!screendc) return GenericError; + + *xres = (REAL)GetDeviceCaps(screendc, LOGPIXELSX); + *yres = (REAL)GetDeviceCaps(screendc, LOGPIXELSY); + + ReleaseDC(0, screendc); + + return Ok; +} + GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE* scan0, GpBitmap** bitmap) { - BITMAPINFOHEADER bmih; + BITMAPINFO* pbmi; HBITMAP hbitmap; INT row_size, dib_stride; HDC hdc; BYTE *bits; int i; + REAL xres, yres; + GpStatus stat; - TRACE("%d %d %d %d %p %p\n", width, height, stride, format, scan0, bitmap); + TRACE("%d %d %d 0x%x %p %p\n", width, height, stride, format, scan0, bitmap); if (!bitmap) return InvalidParameter; @@ -1194,32 +1635,42 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, if(scan0 && !stride) return InvalidParameter; + stat = get_screen_resolution(&xres, &yres); + if (stat != Ok) return stat; + row_size = (width * PIXELFORMATBPP(format)+7) / 8; dib_stride = (row_size + 3) & ~3; if(stride == 0) stride = dib_stride; - bmih.biSize = sizeof(BITMAPINFOHEADER); - bmih.biWidth = width; - bmih.biHeight = -height; - bmih.biPlanes = 1; + pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); + if (!pbmi) + return OutOfMemory; + + pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + pbmi->bmiHeader.biWidth = width; + pbmi->bmiHeader.biHeight = -height; + pbmi->bmiHeader.biPlanes = 1; /* FIXME: use the rest of the data from format */ - bmih.biBitCount = PIXELFORMATBPP(format); - bmih.biCompression = BI_RGB; - bmih.biSizeImage = 0; - bmih.biXPelsPerMeter = 0; - bmih.biYPelsPerMeter = 0; - bmih.biClrUsed = 0; - bmih.biClrImportant = 0; + pbmi->bmiHeader.biBitCount = PIXELFORMATBPP(format); + pbmi->bmiHeader.biCompression = BI_RGB; + pbmi->bmiHeader.biSizeImage = 0; + pbmi->bmiHeader.biXPelsPerMeter = 0; + pbmi->bmiHeader.biYPelsPerMeter = 0; + pbmi->bmiHeader.biClrUsed = 0; + pbmi->bmiHeader.biClrImportant = 0; hdc = CreateCompatibleDC(NULL); - if (!hdc) return GenericError; + if (!hdc) { + GdipFree(pbmi); + return GenericError; + } - hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&bits, - NULL, 0); + hbitmap = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); DeleteDC(hdc); + GdipFree(pbmi); if (!hbitmap) return GenericError; @@ -1243,6 +1694,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, (*bitmap)->image.palette_count = 0; (*bitmap)->image.palette_size = 0; (*bitmap)->image.palette_entries = NULL; + (*bitmap)->image.xres = xres; + (*bitmap)->image.yres = yres; (*bitmap)->width = width; (*bitmap)->height = height; (*bitmap)->format = format; @@ -1282,6 +1735,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, } } + TRACE("<-- %p\n", *bitmap); + return Ok; } @@ -1389,6 +1844,7 @@ GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image) { GdipFree(((GpBitmap*)image)->bitmapbits); DeleteDC(((GpBitmap*)image)->hdc); + DeleteObject(((GpBitmap*)image)->hbitmap); } GdipFree(image->palette_entries); GdipFree(image); @@ -1398,9 +1854,28 @@ GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image) GpStatus WINGDIPAPI GdipFindFirstImageItem(GpImage *image, ImageItemData* item) { + static int calls; + + TRACE("(%p,%p)\n", image, item); + if(!image || !item) return InvalidParameter; + if (!(calls++)) + FIXME("not implemented\n"); + + return NotImplemented; +} + +GpStatus WINGDIPAPI GdipGetImageItemData(GpImage *image, ImageItemData *item) +{ + static int calls; + + TRACE("(%p,%p)\n", image, item); + + if (!(calls++)) + FIXME("not implemented\n"); + return NotImplemented; } @@ -1520,15 +1995,14 @@ GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height) GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res) { - static int calls; - if(!image || !res) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + *res = image->xres; - return NotImplemented; + TRACE("(%p) <-- %0.2f\n", image, *res); + + return Ok; } GpStatus WINGDIPAPI GdipGetImagePaletteSize(GpImage *image, INT *size) @@ -1588,15 +2062,14 @@ GpStatus WINGDIPAPI GdipGetImageType(GpImage *image, ImageType *type) GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res) { - static int calls; - if(!image || !res) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + *res = image->yres; - return NotImplemented; + TRACE("(%p) <-- %0.2f\n", image, *res); + + return Ok; } GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width) @@ -1700,17 +2173,34 @@ GpStatus WINGDIPAPI GdipGetPropertySize(GpImage *image, UINT* size, UINT* num) { static int calls; + TRACE("(%p,%p,%p)\n", image, size, num); + if(!(calls++)) FIXME("not implemented\n"); return InvalidParameter; } +struct image_format_dimension +{ + const GUID *format; + const GUID *dimension; +}; + +struct image_format_dimension image_format_dimensions[] = +{ + {&ImageFormatGIF, &FrameDimensionTime}, + {&ImageFormatIcon, &FrameDimensionResolution}, + {NULL} +}; + GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image, GDIPCONST GUID* dimensionID, UINT* count) { static int calls; + TRACE("(%p,%s,%p)\n", image, debugstr_guid(dimensionID), count); + if(!image || !dimensionID || !count) return InvalidParameter; @@ -1723,26 +2213,40 @@ GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image, GpStatus WINGDIPAPI GdipImageGetFrameDimensionsCount(GpImage *image, UINT* count) { + /* Native gdiplus 1.1 does not yet support multiple frame dimensions. */ + if(!image || !count) return InvalidParameter; *count = 1; - FIXME("stub\n"); - return Ok; } GpStatus WINGDIPAPI GdipImageGetFrameDimensionsList(GpImage* image, GUID* dimensionIDs, UINT count) { - static int calls; + int i; + const GUID *result=NULL; - if(!image || !dimensionIDs) + TRACE("(%p,%p,%u)\n", image, dimensionIDs, count); + + if(!image || !dimensionIDs || count != 1) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + for (i=0; image_format_dimensions[i].format; i++) + { + if (IsEqualGUID(&image->format, image_format_dimensions[i].format)) + { + result = image_format_dimensions[i].dimension; + break; + } + } + + if (!result) + result = &FrameDimensionPage; + + memcpy(dimensionIDs, result, sizeof(GUID)); return Ok; } @@ -1976,6 +2480,8 @@ static GpStatus decode_image_olepicture_metafile(IStream* stream, REFCLSID clsid (*image)->palette_size = 0; (*image)->palette_entries = NULL; + TRACE("<-- %p\n", *image); + return Ok; } @@ -2084,6 +2590,8 @@ GpStatus WINGDIPAPI GdipRemovePropertyItem(GpImage *image, PROPID propId) { static int calls; + TRACE("(%p,%u)\n", image, propId); + if(!image) return InvalidParameter; @@ -2097,6 +2605,8 @@ GpStatus WINGDIPAPI GdipSetPropertyItem(GpImage *image, GDIPCONST PropertyItem* { static int calls; + TRACE("(%p,%p)\n", image, item); + if(!(calls++)) FIXME("not implemented\n"); @@ -2790,6 +3300,8 @@ GpStatus WINGDIPAPI GdipSetEffectParameters(CGpEffect *effect, { static int calls; + TRACE("(%p,%p,%u)\n", effect, params, size); + if(!(calls++)) FIXME("not implemented\n"); diff --git a/dll/win32/gdiplus/imageattributes.c b/dll/win32/gdiplus/imageattributes.c index 8f49c67bd44..1a7118df773 100644 --- a/dll/win32/gdiplus/imageattributes.c +++ b/dll/win32/gdiplus/imageattributes.c @@ -30,26 +30,31 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imageattr, GpImageAttributes **cloneImageattr) { + GpStatus stat; + TRACE("(%p, %p)\n", imageattr, cloneImageattr); if(!imageattr || !cloneImageattr) return InvalidParameter; - **cloneImageattr = *imageattr; + stat = GdipCreateImageAttributes(cloneImageattr); - return Ok; + if (stat == Ok) + **cloneImageattr = *imageattr; + + return stat; } GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr) { - TRACE("(%p)\n", imageattr); - if(!imageattr) return InvalidParameter; *imageattr = GdipAlloc(sizeof(GpImageAttributes)); if(!*imageattr) return OutOfMemory; + TRACE("<-- %p\n", *imageattr); + return Ok; } @@ -84,15 +89,32 @@ GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageat ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix, GDIPCONST ColorMatrix* grayMatrix, ColorMatrixFlags flags) { - static int calls; + TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix, + grayMatrix, flags); - if(!imageattr || !colorMatrix || !grayMatrix) + if(!imageattr || type >= ColorAdjustTypeCount || flags > ColorMatrixFlagsAltGray) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + if (enableFlag) + { + if (!colorMatrix) + return InvalidParameter; - return NotImplemented; + if (flags == ColorMatrixFlagsAltGray) + { + if (!grayMatrix) + return InvalidParameter; + + imageattr->colormatrices[type].graymatrix = *grayMatrix; + } + + imageattr->colormatrices[type].colormatrix = *colorMatrix; + imageattr->colormatrices[type].flags = flags; + } + + imageattr->colormatrices[type].enabled = enableFlag; + + return Ok; } GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr, @@ -100,6 +122,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr, { static int calls; + TRACE("(%p,%u,%08x,%i)\n", imageAttr, wrap, argb, clamp); + if(!imageAttr) return InvalidParameter; @@ -114,6 +138,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *im { static int calls; + TRACE("(%p,%i)\n", imageAttr, enableFlag); + if(!(calls++)) FIXME("not implemented\n"); @@ -123,12 +149,15 @@ GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *im GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr, ColorAdjustType type, BOOL enableFlag, REAL gamma) { - static int calls; + TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma); - if(!(calls++)) - FIXME("not implemented\n"); + if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount) + return InvalidParameter; - return NotImplemented; + imageAttr->gamma_enabled[type] = enableFlag; + imageAttr->gamma[type] = gamma; + + return Ok; } GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr, @@ -136,6 +165,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr, { static int calls; + TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag); + if(!(calls++)) FIXME("not implemented\n"); @@ -147,6 +178,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *image { static int calls; + TRACE("(%p,%u,%i,%x)\n", imageAttr, type, enableFlag, channelFlags); + if(!(calls++)) FIXME("not implemented\n"); @@ -159,6 +192,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannelColorProfile(GpImageAttri { static int calls; + TRACE("(%p,%u,%i,%s)\n", imageAttr, type, enableFlag, debugstr_w(colorProfileFilename)); + if(!(calls++)) FIXME("not implemented\n"); @@ -169,12 +204,23 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt ColorAdjustType type, BOOL enableFlag, UINT mapSize, GDIPCONST ColorMap *map) { - static int calls; + TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map); - if(!(calls++)) - FIXME("not implemented\n"); + if(!imageAttr || type >= ColorAdjustTypeCount) + return InvalidParameter; - return NotImplemented; + if (enableFlag) + { + if(!map || !mapSize) + return InvalidParameter; + + imageAttr->colorremaptables[type].mapsize = mapSize; + imageAttr->colorremaptables[type].colormap = map; + } + + imageAttr->colorremaptables[type].enabled = enableFlag; + + return Ok; } GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr, @@ -182,6 +228,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr { static int calls; + TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, threshold); + if(!(calls++)) FIXME("not implemented\n"); @@ -193,6 +241,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesToIdentity(GpImageAttributes *imageAtt { static int calls; + TRACE("(%p,%u)\n", imageAttr, type); + if(!(calls++)) FIXME("not implemented\n"); diff --git a/dll/win32/gdiplus/pen.c b/dll/win32/gdiplus/pen.c index 4a68a27c541..930317cc826 100644 --- a/dll/win32/gdiplus/pen.c +++ b/dll/win32/gdiplus/pen.c @@ -101,6 +101,8 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen) GdipCloneCustomLineCap(pen->customend, &(*clonepen)->customend); GdipCloneBrush(pen->brush, &(*clonepen)->brush); + TRACE("<-- %p\n", *clonepen); + return Ok; } @@ -154,6 +156,8 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit, *pen = gp_pen; + TRACE("<-- %p\n", *pen); + return Ok; } @@ -389,6 +393,8 @@ GpStatus WINGDIPAPI GdipResetPenTransform(GpPen *pen) { static int calls; + TRACE("(%p)\n", pen); + if(!pen) return InvalidParameter; @@ -402,6 +408,8 @@ GpStatus WINGDIPAPI GdipScalePenTransform(GpPen *pen, REAL sx, REAL sy, GpMatrix { static int calls; + TRACE("(%p,%0.2f,%0.2f,%u)\n", pen, sx, sy, order); + if(!pen) return InvalidParameter; diff --git a/dll/win32/gdiplus/region.c b/dll/win32/gdiplus/region.c index eab9b8fa5db..decaaf9e837 100644 --- a/dll/win32/gdiplus/region.c +++ b/dll/win32/gdiplus/region.c @@ -1306,3 +1306,15 @@ GpStatus WINGDIPAPI GdipTranslateRegionI(GpRegion *region, INT dx, INT dy) return GdipTranslateRegion(region, (REAL)dx, (REAL)dy); } + +GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMatrix *matrix) +{ + static int calls; + + TRACE("(%p, %p, %p)\n", region, count, matrix); + + if (!(calls++)) + FIXME("not implemented\n"); + + return NotImplemented; +} diff --git a/dll/win32/gdiplus/stringformat.c b/dll/win32/gdiplus/stringformat.c index bfe7d34e05e..cf6ea1f392a 100644 --- a/dll/win32/gdiplus/stringformat.c +++ b/dll/win32/gdiplus/stringformat.c @@ -48,11 +48,15 @@ GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang, (*format)->digitlang = LANG_NEUTRAL; (*format)->trimming = StringTrimmingCharacter; (*format)->digitsub = StringDigitSubstituteUser; + (*format)->character_ranges = NULL; + (*format)->range_count = 0; /* tabstops */ (*format)->tabcount = 0; (*format)->firsttab = 0.0; (*format)->tabs = NULL; + TRACE("<-- %p\n", *format); + return Ok; } @@ -61,6 +65,7 @@ GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format) if(!format) return InvalidParameter; + GdipFree(format->character_ranges); GdipFree(format->tabs); GdipFree(format); @@ -141,14 +146,16 @@ GpStatus WINGDIPAPI GdipGetStringFormatLineAlign(GpStringFormat *format, } GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount( - GDIPCONST GpStringFormat* format, INT* count) + GDIPCONST GpStringFormat *format, INT *count) { if (!(format && count)) return InvalidParameter; - FIXME("stub: %p %p\n", format, count); + TRACE("%p %p\n", format, count); - return NotImplemented; + *count = format->range_count; + + return Ok; } GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount(GDIPCONST GpStringFormat *format, @@ -242,15 +249,26 @@ GpStatus WINGDIPAPI GdipSetStringFormatLineAlign(GpStringFormat *format, return Ok; } -GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(GpStringFormat* - format, INT rangeCount, GDIPCONST CharacterRange* ranges) +GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges( + GpStringFormat *format, INT rangeCount, GDIPCONST CharacterRange *ranges) { - if (!(format && rangeCount && ranges)) + CharacterRange *new_ranges; + + if (!(format && ranges)) return InvalidParameter; - FIXME("stub: %p, %d, %p\n", format, rangeCount, ranges); + TRACE("%p, %d, %p\n", format, rangeCount, ranges); - return NotImplemented; + new_ranges = GdipAlloc(rangeCount * sizeof(CharacterRange)); + if (!new_ranges) + return OutOfMemory; + + GdipFree(format->character_ranges); + format->character_ranges = new_ranges; + memcpy(format->character_ranges, ranges, sizeof(CharacterRange) * rangeCount); + format->range_count = rangeCount; + + return Ok; } GpStatus WINGDIPAPI GdipSetStringFormatTabStops(GpStringFormat *format, REAL firsttab, @@ -331,6 +349,19 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt else (*newFormat)->tabs = NULL; + if(format->range_count > 0){ + (*newFormat)->character_ranges = GdipAlloc(sizeof(CharacterRange) * format->range_count); + if(!(*newFormat)->character_ranges){ + GdipFree((*newFormat)->tabs); + GdipFree(*newFormat); + return OutOfMemory; + } + memcpy((*newFormat)->character_ranges, format->character_ranges, + sizeof(CharacterRange) * format->range_count); + } + else + (*newFormat)->character_ranges = NULL; + TRACE("%p %p\n",format,newFormat); return Ok; diff --git a/dll/win32/hhctrl.ocx/Cs.rc b/dll/win32/hhctrl.ocx/Cs.rc index ec564d830d1..b9147627278 100644 --- a/dll/win32/hhctrl.ocx/Cs.rc +++ b/dll/win32/hhctrl.ocx/Cs.rc @@ -21,6 +21,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_CZECH, SUBLANG_DEFAULT /* Czech strings in CP1250 */ diff --git a/dll/win32/hhctrl.ocx/Da.rc b/dll/win32/hhctrl.ocx/Da.rc index e425ef0e567..1832d71c334 100644 --- a/dll/win32/hhctrl.ocx/Da.rc +++ b/dll/win32/hhctrl.ocx/Da.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_DANISH, SUBLANG_DEFAULT STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/De.rc b/dll/win32/hhctrl.ocx/De.rc index ef6e6997bd5..20b20f8c468 100644 --- a/dll/win32/hhctrl.ocx/De.rc +++ b/dll/win32/hhctrl.ocx/De.rc @@ -19,6 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + +#pragma code_page(65001) + LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL STRINGTABLE @@ -33,14 +37,14 @@ STRINGTABLE BEGIN IDTB_EXPAND "Anzeigen" IDTB_CONTRACT "Verstecken" - IDTB_STOP "Stop" + IDTB_STOP "Stopp" IDTB_REFRESH "Aktualisieren" - IDTB_BACK "Zurck" + IDTB_BACK "Zurück" IDTB_HOME "Startseite" IDTB_SYNC "Synchronisieren" IDTB_PRINT "Drucken" IDTB_OPTIONS "Einstellungen" - IDTB_FORWARD "Vorwrts" + IDTB_FORWARD "Vorwärts" IDTB_NOTES "IDTB_NOTES" IDTB_BROWSE_FWD "IDTB_BROWSE_FWD" IDTB_BROWSE_BACK "IDT_BROWSE_BACK" @@ -52,7 +56,7 @@ BEGIN IDTB_JUMP1 "Sprung1" IDTB_JUMP2 "Sprung2" IDTB_CUSTOMIZE "Anpassen" - IDTB_ZOOM "Vergrern" + IDTB_ZOOM "Vergrößern" IDTB_TOC_NEXT "IDTB_TOC_NEXT" IDTB_TOC_PREV "IDTB_TOC_PREV" END diff --git a/dll/win32/hhctrl.ocx/El.rc b/dll/win32/hhctrl.ocx/El.rc index dd81eb68da2..4fa79a2dcd8 100644 --- a/dll/win32/hhctrl.ocx/El.rc +++ b/dll/win32/hhctrl.ocx/El.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_GREEK, SUBLANG_DEFAULT STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/En.rc b/dll/win32/hhctrl.ocx/En.rc index 83917f6e3d6..b69383e1898 100644 --- a/dll/win32/hhctrl.ocx/En.rc +++ b/dll/win32/hhctrl.ocx/En.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE @@ -56,3 +58,13 @@ BEGIN IDTB_TOC_NEXT "IDTB_TOC_NEXT" IDTB_TOC_PREV "IDTB_TOC_PREV" END + +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_CONTENTS "&Contents" + IDS_INDEX "I&ndex" + IDS_SEARCH "&Search" + IDS_FAVORITES "Favour&ites" +END diff --git a/dll/win32/hhctrl.ocx/Es.rc b/dll/win32/hhctrl.ocx/Es.rc new file mode 100644 index 00000000000..d7681aa8ca4 --- /dev/null +++ b/dll/win32/hhctrl.ocx/Es.rc @@ -0,0 +1,63 @@ +/* + * HTML Help resources + * Spanish Language Support + * + * Copyright 2010 José Manuel Ferrer Ortiz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_CONTENTS "&Contenido" + IDS_INDEX "Í&ndice" + IDS_SEARCH "&Buscar" + IDS_FAVORITES "Favor&itos" +END + +STRINGTABLE +BEGIN + IDTB_EXPAND "Mostrar" + IDTB_CONTRACT "Ocultar" + IDTB_STOP "Parar" + IDTB_REFRESH "Recargar" + IDTB_BACK "Atrás" + IDTB_HOME "Inicio" + IDTB_SYNC "Sincronizar" + IDTB_PRINT "Imprimir" + IDTB_OPTIONS "Opciones" + IDTB_FORWARD "Adelante" + IDTB_NOTES "IDTB_NOTES" + IDTB_BROWSE_FWD "IDTB_BROWSE_FWD" + IDTB_BROWSE_BACK "IDT_BROWSE_BACK" + IDTB_CONTENTS "IDTB_CONTENTS" + IDTB_INDEX "IDTB_INDEX" + IDTB_SEARCH "IDTB_SEARCH" + IDTB_HISTORY "IDTB_HISTORY" + IDTB_FAVORITES "IDTB_FAVORITES" + IDTB_JUMP1 "Jump1" + IDTB_JUMP2 "Jump2" + IDTB_CUSTOMIZE "Personalizar" + IDTB_ZOOM "Zoom" + IDTB_TOC_NEXT "IDTB_TOC_NEXT" + IDTB_TOC_PREV "IDTB_TOC_PREV" +END diff --git a/dll/win32/hhctrl.ocx/Fi.rc b/dll/win32/hhctrl.ocx/Fi.rc index 975ce1f49aa..825422e57d6 100644 --- a/dll/win32/hhctrl.ocx/Fi.rc +++ b/dll/win32/hhctrl.ocx/Fi.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/Fr.rc b/dll/win32/hhctrl.ocx/Fr.rc index 0e5dd4f9591..2146a3c7ae1 100644 --- a/dll/win32/hhctrl.ocx/Fr.rc +++ b/dll/win32/hhctrl.ocx/Fr.rc @@ -19,6 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL STRINGTABLE @@ -33,9 +38,9 @@ STRINGTABLE BEGIN IDTB_EXPAND "Afficher" IDTB_CONTRACT "Cacher" - IDTB_STOP "Arrter" + IDTB_STOP "Arrêter" IDTB_REFRESH "A&ctualiser" - IDTB_BACK "Prcdent" + IDTB_BACK "Précédent" IDTB_HOME "Sommaire" IDTB_SYNC "Synchroniser" IDTB_PRINT "Imprimer" @@ -49,8 +54,8 @@ BEGIN IDTB_SEARCH "IDTB_SEARCH" IDTB_HISTORY "IDTB_HISTORY" IDTB_FAVORITES "IDTB_FAVORITES" - IDTB_JUMP1 "Jump1" - IDTB_JUMP2 "Jump2" + IDTB_JUMP1 "Saut1" + IDTB_JUMP2 "Saut2" IDTB_CUSTOMIZE "Personnaliser" IDTB_ZOOM "Zoom" IDTB_TOC_NEXT "IDTB_TOC_NEXT" diff --git a/dll/win32/hhctrl.ocx/Hu.rc b/dll/win32/hhctrl.ocx/Hu.rc index 225c04a82d7..0cab8cdae81 100644 --- a/dll/win32/hhctrl.ocx/Hu.rc +++ b/dll/win32/hhctrl.ocx/Hu.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/Ko.rc b/dll/win32/hhctrl.ocx/Ko.rc index 169eb70e472..37831dfcb7c 100644 --- a/dll/win32/hhctrl.ocx/Ko.rc +++ b/dll/win32/hhctrl.ocx/Ko.rc @@ -20,6 +20,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/Lt.rc b/dll/win32/hhctrl.ocx/Lt.rc index fed6b40e400..8c813ba1ef1 100644 --- a/dll/win32/hhctrl.ocx/Lt.rc +++ b/dll/win32/hhctrl.ocx/Lt.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + /* UTF-8 */ #pragma code_page(65001) @@ -59,5 +61,3 @@ BEGIN IDTB_TOC_NEXT "IDTB_TOC_NEXT" IDTB_TOC_PREV "IDTB_TOC_PREV" END - -#pragma code_page(default) diff --git a/dll/win32/hhctrl.ocx/Nl.rc b/dll/win32/hhctrl.ocx/Nl.rc index 929ac39f6da..99c12faf10d 100644 --- a/dll/win32/hhctrl.ocx/Nl.rc +++ b/dll/win32/hhctrl.ocx/Nl.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/No.rc b/dll/win32/hhctrl.ocx/No.rc index 5ff634d02df..a76ad3147a7 100644 --- a/dll/win32/hhctrl.ocx/No.rc +++ b/dll/win32/hhctrl.ocx/No.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/Pl.rc b/dll/win32/hhctrl.ocx/Pl.rc index 40d3089af84..f3ce6f2c76c 100644 --- a/dll/win32/hhctrl.ocx/Pl.rc +++ b/dll/win32/hhctrl.ocx/Pl.rc @@ -20,6 +20,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_POLISH, SUBLANG_DEFAULT STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/Pt.rc b/dll/win32/hhctrl.ocx/Pt.rc index d196ff499b9..13476ce843f 100644 --- a/dll/win32/hhctrl.ocx/Pt.rc +++ b/dll/win32/hhctrl.ocx/Pt.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/Ru.rc b/dll/win32/hhctrl.ocx/Ru.rc index a530f80b637..0634c39da21 100644 --- a/dll/win32/hhctrl.ocx/Ru.rc +++ b/dll/win32/hhctrl.ocx/Ru.rc @@ -19,40 +19,45 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT STRINGTABLE BEGIN - IDS_CONTENTS "&" - IDS_INDEX "&" - IDS_SEARCH "&" - IDS_FAVORITES "&" + IDS_CONTENTS "&Содержание" + IDS_INDEX "&Оглавление" + IDS_SEARCH "&Поиск" + IDS_FAVORITES "&Избранное" END STRINGTABLE BEGIN - IDTB_EXPAND "" - IDTB_CONTRACT "" - IDTB_STOP "" - IDTB_REFRESH "" - IDTB_BACK "" - IDTB_HOME " " - IDTB_SYNC "" - IDTB_PRINT "" - IDTB_OPTIONS "" - IDTB_FORWARD "" - IDTB_NOTES "" - IDTB_BROWSE_FWD " " - IDTB_BROWSE_BACK " " - IDTB_CONTENTS "" - IDTB_INDEX "" - IDTB_SEARCH "" - IDTB_HISTORY "" - IDTB_FAVORITES "" - IDTB_JUMP1 " 1" - IDTB_JUMP2 " 2" - IDTB_CUSTOMIZE "" - IDTB_ZOOM "" - IDTB_TOC_NEXT " " - IDTB_TOC_PREV " " + IDTB_EXPAND "Показать" + IDTB_CONTRACT "Спрятать" + IDTB_STOP "Остановить" + IDTB_REFRESH "Обновить" + IDTB_BACK "Назад" + IDTB_HOME "В начало" + IDTB_SYNC "Синхронизировать" + IDTB_PRINT "Печать" + IDTB_OPTIONS "Настройки" + IDTB_FORWARD "Вперёд" + IDTB_NOTES "Записки" + IDTB_BROWSE_FWD "Просмотр вперёд" + IDTB_BROWSE_BACK "Просмотр назад" + IDTB_CONTENTS "Содержание" + IDTB_INDEX "Оглавление" + IDTB_SEARCH "Поиск" + IDTB_HISTORY "История" + IDTB_FAVORITES "Избранное" + IDTB_JUMP1 "Переход 1" + IDTB_JUMP2 "Переход 2" + IDTB_CUSTOMIZE "Персонализовать" + IDTB_ZOOM "Масштаб" + IDTB_TOC_NEXT "Следующая глава" + IDTB_TOC_PREV "Предыдущая глава" END diff --git a/dll/win32/hhctrl.ocx/Si.rc b/dll/win32/hhctrl.ocx/Si.rc index c8ea447f5ed..bc8ca1d3705 100644 --- a/dll/win32/hhctrl.ocx/Si.rc +++ b/dll/win32/hhctrl.ocx/Si.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + #pragma code_page(65001) LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT @@ -58,5 +60,3 @@ BEGIN IDTB_TOC_NEXT "IDTB_TOC_NEXT" IDTB_TOC_PREV "IDTB_TOC_PREV" END - -#pragma code_page(default) diff --git a/dll/win32/hhctrl.ocx/Sv.rc b/dll/win32/hhctrl.ocx/Sv.rc index cb3e4e26a5d..b92c63c2bbd 100644 --- a/dll/win32/hhctrl.ocx/Sv.rc +++ b/dll/win32/hhctrl.ocx/Sv.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/Tr.rc b/dll/win32/hhctrl.ocx/Tr.rc index 748899908f7..f1011b1dc48 100644 --- a/dll/win32/hhctrl.ocx/Tr.rc +++ b/dll/win32/hhctrl.ocx/Tr.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT STRINGTABLE diff --git a/dll/win32/hhctrl.ocx/Uk.rc b/dll/win32/hhctrl.ocx/Uk.rc new file mode 100644 index 00000000000..40d96b86a28 --- /dev/null +++ b/dll/win32/hhctrl.ocx/Uk.rc @@ -0,0 +1,75 @@ +/* + * HTML Help resources + * Ukrainian Language Support + * + * Copyright 2005 James Hawkins + * Copyright 2007 Artem Reznikov + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE +BEGIN + IDS_CONTENTS "&Зміст" + IDS_INDEX "&Вказівник" + IDS_SEARCH "&Пошук" + IDS_FAVORITES "&Обране" +END + +STRINGTABLE +BEGIN + IDTB_EXPAND "Показувати" + IDTB_CONTRACT "Приховати" + IDTB_STOP "Зупинити" + IDTB_REFRESH "Оновити" + IDTB_BACK "Назад" + IDTB_HOME "Додому" + IDTB_SYNC "Синхронізувати" + IDTB_PRINT "Друк" + IDTB_OPTIONS "Параметри" + IDTB_FORWARD "Вперед" + IDTB_NOTES "IDTB_NOTES" + IDTB_BROWSE_FWD "IDTB_BROWSE_FWD" + IDTB_BROWSE_BACK "IDT_BROWSE_BACK" + IDTB_CONTENTS "IDTB_CONTENTS" + IDTB_INDEX "IDTB_INDEX" + IDTB_SEARCH "IDTB_SEARCH" + IDTB_HISTORY "IDTB_HISTORY" + IDTB_FAVORITES "IDTB_FAVORITES" + IDTB_JUMP1 "Jump1" + IDTB_JUMP2 "Jump2" + IDTB_CUSTOMIZE "Налаштування" + IDTB_ZOOM "Збільшення" + IDTB_TOC_NEXT "IDTB_TOC_NEXT" + IDTB_TOC_PREV "IDTB_TOC_PREV" +END + +LANGUAGE LANG_UKRAINIAN, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_CONTENTS "&Зміст" + IDS_INDEX "&Вказівник" + IDS_SEARCH "&Пошук" + IDS_FAVORITES "&Обране" +END diff --git a/dll/win32/hhctrl.ocx/Zh.rc b/dll/win32/hhctrl.ocx/Zh.rc index a7ccab0da74..d6295a96d20 100644 --- a/dll/win32/hhctrl.ocx/Zh.rc +++ b/dll/win32/hhctrl.ocx/Zh.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "resource.h" + /* Chinese text is encoded in UTF-8 */ #pragma code_page(65001) @@ -96,5 +98,3 @@ BEGIN IDTB_TOC_NEXT "後一項" IDTB_TOC_PREV "前一項" END - -#pragma code_page(default) diff --git a/dll/win32/hhctrl.ocx/chm.c b/dll/win32/hhctrl.ocx/chm.c index b7df8e72c7d..cf5b8bf2e90 100644 --- a/dll/win32/hhctrl.ocx/chm.c +++ b/dll/win32/hhctrl.ocx/chm.c @@ -38,12 +38,13 @@ static LPCSTR GetChmString(CHMInfo *chm, DWORD offset) return NULL; if(chm->strings_size <= (offset >> BLOCK_BITS)) { + chm->strings_size = (offset >> BLOCK_BITS)+1; if(chm->strings) chm->strings = heap_realloc_zero(chm->strings, - chm->strings_size = ((offset >> BLOCK_BITS)+1)*sizeof(char*)); + chm->strings_size*sizeof(char*)); else chm->strings = heap_alloc_zero( - chm->strings_size = ((offset >> BLOCK_BITS)+1)*sizeof(char*)); + chm->strings_size*sizeof(char*)); } @@ -388,7 +389,6 @@ CHMInfo *OpenCHM(LPCWSTR szFile) WARN("Could not open storage: %08x\n", hres); return CloseCHM(ret); } - hres = IStorage_OpenStream(ret->pStorage, wszSTRINGS, NULL, STGM_READ, 0, &ret->strings_stream); if(FAILED(hres)) { diff --git a/dll/win32/hhctrl.ocx/content.c b/dll/win32/hhctrl.ocx/content.c index 4fc017656c5..bfe25cf9453 100644 --- a/dll/win32/hhctrl.ocx/content.c +++ b/dll/win32/hhctrl.ocx/content.c @@ -20,13 +20,12 @@ #define NONAMELESSSTRUCT #include "hhctrl.h" +#include "stream.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp); -#define BLOCK_SIZE 0x1000 - typedef enum { INSERT_NEXT, INSERT_CHILD @@ -50,134 +49,6 @@ static void free_content_item(ContentItem *item) } } -typedef struct { - char *buf; - int size; - int len; -} strbuf_t; - -static void strbuf_init(strbuf_t *buf) -{ - buf->size = 8; - buf->len = 0; - buf->buf = heap_alloc(buf->size); -} - -static void strbuf_zero(strbuf_t *buf) -{ - buf->len = 0; -} - -static void strbuf_free(strbuf_t *buf) -{ - heap_free(buf->buf); -} - -static void strbuf_append(strbuf_t *buf, const char *data, int len) -{ - if(buf->len+len > buf->size) { - buf->size = buf->len+len; - buf->buf = heap_realloc(buf->buf, buf->size); - } - - memcpy(buf->buf+buf->len, data, len); - buf->len += len; -} - -typedef struct { - IStream *str; - char buf[BLOCK_SIZE]; - ULONG size; - ULONG p; -} stream_t; - -static void stream_init(stream_t *stream, IStream *str) -{ - memset(stream, 0, sizeof(stream_t)); - stream->str = str; -} - -static BOOL stream_chr(stream_t *stream, strbuf_t *buf, char c) -{ - BOOL b = TRUE; - ULONG i; - - while(b) { - for(i=stream->p; isize; i++) { - if(stream->buf[i] == c) { - b = FALSE; - break; - } - } - - if(buf && i > stream->p) - strbuf_append(buf, stream->buf+stream->p, i-stream->p); - stream->p = i; - - if(stream->p == stream->size) { - stream->p = 0; - IStream_Read(stream->str, stream->buf, sizeof(stream->buf), &stream->size); - if(!stream->size) - break; - } - } - - return stream->size != 0; -} - -static void get_node_name(strbuf_t *node, strbuf_t *name) -{ - const char *ptr = node->buf+1; - - strbuf_zero(name); - - while(*ptr != '>' && !isspace(*ptr)) - ptr++; - - strbuf_append(name, node->buf+1, ptr-node->buf-1); - strbuf_append(name, "", 1); -} - -static BOOL next_node(stream_t *stream, strbuf_t *buf) -{ - if(!stream_chr(stream, NULL, '<')) - return FALSE; - - if(!stream_chr(stream, buf, '>')) - return FALSE; - - strbuf_append(buf, ">", 2); - - return TRUE; -} - -static const char *get_attr(const char *node, const char *name, int *len) -{ - const char *ptr, *ptr2; - char name_buf[32]; - int nlen; - - nlen = strlen(name); - memcpy(name_buf, name, nlen); - name_buf[nlen++] = '='; - name_buf[nlen++] = '\"'; - name_buf[nlen] = 0; - - ptr = strstr(node, name_buf); - if(!ptr) { - WARN("name not found\n"); - return NULL; - } - - ptr += nlen; - ptr2 = strchr(ptr, '\"'); - if(!ptr2) - return NULL; - - *len = ptr2-ptr; - return ptr; -} - static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text) { const char *ptr; diff --git a/dll/win32/hhctrl.ocx/help.c b/dll/win32/hhctrl.ocx/help.c index 092e97e8784..30cb008bd27 100644 --- a/dll/win32/hhctrl.ocx/help.c +++ b/dll/win32/hhctrl.ocx/help.c @@ -44,6 +44,7 @@ static LRESULT Help_OnSize(HWND hWnd); #define TAB_TOP_PADDING 8 #define TAB_RIGHT_PADDING 4 #define TAB_MARGIN 8 +#define EDIT_HEIGHT 20 static const WCHAR szEmpty[] = {0}; @@ -320,8 +321,10 @@ static LRESULT Child_OnPaint(HWND hWnd) return 0; } -static void ResizeTabChild(HHInfo *info, HWND hwnd) +static void ResizeTabChild(HHInfo *info, int tab) { + HWND hwnd = info->tabs[tab].hwnd; + INT width, height; RECT rect, tabrc; DWORD cnt; @@ -333,9 +336,47 @@ static void ResizeTabChild(HHInfo *info, HWND hwnd) rect.top = TAB_TOP_PADDING + cnt*(tabrc.bottom-tabrc.top) + TAB_MARGIN; rect.right -= TAB_RIGHT_PADDING + TAB_MARGIN; rect.bottom -= TAB_MARGIN; + width = rect.right-rect.left; + height = rect.bottom-rect.top; - SetWindowPos(hwnd, NULL, rect.left, rect.top, rect.right-rect.left, - rect.bottom-rect.top, SWP_NOZORDER | SWP_NOACTIVATE); + SetWindowPos(hwnd, NULL, rect.left, rect.top, width, height, + SWP_NOZORDER | SWP_NOACTIVATE); + + switch (tab) + { + case TAB_INDEX: { + int scroll_width = GetSystemMetrics(SM_CXVSCROLL); + int border_width = GetSystemMetrics(SM_CXBORDER); + int edge_width = GetSystemMetrics(SM_CXEDGE); + + /* Resize the tab widget column to perfectly fit the tab window and + * leave sufficient space for the scroll widget. + */ + SendMessageW(info->tabs[TAB_INDEX].hwnd, LVM_SETCOLUMNWIDTH, 0, + width-scroll_width-2*border_width-2*edge_width); + + break; + } + case TAB_SEARCH: { + int scroll_width = GetSystemMetrics(SM_CXVSCROLL); + int border_width = GetSystemMetrics(SM_CXBORDER); + int edge_width = GetSystemMetrics(SM_CXEDGE); + int top_pos = 0; + + SetWindowPos(info->search.hwndEdit, NULL, 0, top_pos, width, + EDIT_HEIGHT, SWP_NOZORDER | SWP_NOACTIVATE); + top_pos += EDIT_HEIGHT + TAB_MARGIN; + SetWindowPos(info->search.hwndList, NULL, 0, top_pos, width, + height-top_pos, SWP_NOZORDER | SWP_NOACTIVATE); + /* Resize the tab widget column to perfectly fit the tab window and + * leave sufficient space for the scroll widget. + */ + SendMessageW(info->search.hwndList, LVM_SETCOLUMNWIDTH, 0, + width-scroll_width-2*border_width-2*edge_width); + + break; + } + } } static LRESULT Child_OnSize(HWND hwnd) @@ -351,7 +392,8 @@ static LRESULT Child_OnSize(HWND hwnd) rect.right - TAB_RIGHT_PADDING, rect.bottom - TAB_TOP_PADDING, SWP_NOMOVE); - ResizeTabChild(info, info->tabs[TAB_CONTENTS].hwnd); + ResizeTabChild(info, TAB_CONTENTS); + ResizeTabChild(info, TAB_INDEX); return 0; } @@ -375,29 +417,101 @@ static LRESULT OnTabChange(HWND hwnd) return 0; } -static LRESULT OnTopicChange(HWND hwnd, ContentItem *item) +static LRESULT OnTopicChange(HHInfo *info, void *user_data) { - HHInfo *info = (HHInfo*)GetWindowLongPtrW(hwnd, GWLP_USERDATA); - LPCWSTR chmfile = NULL; - ContentItem *iter = item; + LPCWSTR chmfile = NULL, name = NULL, local = NULL; + ContentItem *citer; + SearchItem *siter; + IndexItem *iiter; - if(!item || !info) + if(!user_data || !info) return 0; - TRACE("name %s loal %s\n", debugstr_w(item->name), debugstr_w(item->local)); - - while(iter) { - if(iter->merge.chm_file) { - chmfile = iter->merge.chm_file; - break; + switch (info->current_tab) + { + case TAB_CONTENTS: + citer = (ContentItem *) user_data; + name = citer->name; + local = citer->local; + while(citer) { + if(citer->merge.chm_file) { + chmfile = citer->merge.chm_file; + break; + } + citer = citer->parent; } - iter = iter->parent; + break; + case TAB_INDEX: + iiter = (IndexItem *) user_data; + if(iiter->nItems == 0) { + FIXME("No entries for this item!\n"); + return 0; + } + if(iiter->nItems > 1) { + int i = 0; + LVITEMW lvi; + + SendMessageW(info->popup.hwndList, LVM_DELETEALLITEMS, 0, 0); + for(i=0;inItems;i++) { + IndexSubItem *item = &iiter->items[i]; + WCHAR *name = iiter->keyword; + + if(item->name) + name = item->name; + memset(&lvi, 0, sizeof(lvi)); + lvi.iItem = i; + lvi.mask = LVIF_TEXT|LVIF_PARAM; + lvi.cchTextMax = strlenW(name)+1; + lvi.pszText = name; + lvi.lParam = (LPARAM) item; + SendMessageW(info->popup.hwndList, LVM_INSERTITEMW, 0, (LPARAM)&lvi); + } + ShowWindow(info->popup.hwndPopup, SW_SHOW); + return 0; + } + name = iiter->items[0].name; + local = iiter->items[0].local; + chmfile = iiter->merge.chm_file; + break; + case TAB_SEARCH: + siter = (SearchItem *) user_data; + name = siter->filename; + local = siter->filename; + chmfile = info->pCHMInfo->szFile; + break; + default: + FIXME("Unhandled operation for this tab!\n"); + return 0; } - NavigateToChm(info, chmfile, item->local); + if(!chmfile) + { + FIXME("No help file found for this item!\n"); + return 0; + } + + TRACE("name %s loal %s\n", debugstr_w(name), debugstr_w(local)); + + NavigateToChm(info, chmfile, local); return 0; } +/* Capture the Enter/Return key and send it up to Child_WndProc as an NM_RETURN message */ +static LRESULT CALLBACK EditChild_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + WNDPROC editWndProc = (WNDPROC)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + + if(message == WM_KEYUP && wParam == VK_RETURN) + { + NMHDR nmhdr; + + nmhdr.hwndFrom = hWnd; + nmhdr.code = NM_RETURN; + SendMessageW(GetParent(GetParent(hWnd)), WM_NOTIFY, wParam, (LPARAM)&nmhdr); + } + return editWndProc(hWnd, message, wParam, lParam); +} + static LRESULT CALLBACK Child_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) @@ -407,12 +521,71 @@ static LRESULT CALLBACK Child_WndProc(HWND hWnd, UINT message, WPARAM wParam, LP case WM_SIZE: return Child_OnSize(hWnd); case WM_NOTIFY: { + HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA); NMHDR *nmhdr = (NMHDR*)lParam; + switch(nmhdr->code) { case TCN_SELCHANGE: return OnTabChange(hWnd); case TVN_SELCHANGEDW: - return OnTopicChange(hWnd, (ContentItem*)((NMTREEVIEWW *)lParam)->itemNew.lParam); + return OnTopicChange(info, (void*)((NMTREEVIEWW *)lParam)->itemNew.lParam); + case NM_DBLCLK: + if(!info) + return 0; + switch(info->current_tab) + { + case TAB_INDEX: + return OnTopicChange(info, (void*)((NMITEMACTIVATE *)lParam)->lParam); + case TAB_SEARCH: + return OnTopicChange(info, (void*)((NMITEMACTIVATE *)lParam)->lParam); + } + break; + case NM_RETURN: + if(!info) + return 0; + switch(info->current_tab) { + case TAB_INDEX: { + HWND hwndList = info->tabs[TAB_INDEX].hwnd; + LVITEMW lvItem; + + lvItem.iItem = (int) SendMessageW(hwndList, LVM_GETSELECTIONMARK, 0, 0); + lvItem.mask = TVIF_PARAM; + SendMessageW(hwndList, LVM_GETITEMW, 0, (LPARAM)&lvItem); + OnTopicChange(info, (void*) lvItem.lParam); + return 0; + } + case TAB_SEARCH: { + if(nmhdr->hwndFrom == info->search.hwndEdit) { + char needle[100]; + DWORD i, len; + + len = GetWindowTextA(info->search.hwndEdit, needle, sizeof(needle)); + if(!len) + { + FIXME("Unable to get search text.\n"); + return 0; + } + /* Convert the requested text for comparison later against the + * lower case version of HTML file contents. + */ + for(i=0;ihwndFrom == info->search.hwndList) { + HWND hwndList = info->search.hwndList; + LVITEMW lvItem; + + lvItem.iItem = (int) SendMessageW(hwndList, LVM_GETSELECTIONMARK, 0, 0); + lvItem.mask = TVIF_PARAM; + SendMessageW(hwndList, LVM_GETITEMW, 0, (LPARAM)&lvItem); + OnTopicChange(info, (void*) lvItem.lParam); + return 0; + } + break; + } + } + break; } break; } @@ -729,6 +902,8 @@ static BOOL HH_AddHTMLPane(HHInfo *pHHInfo) static BOOL AddContentTab(HHInfo *info) { + if(info->tabs[TAB_CONTENTS].id == -1) + return TRUE; /* No "Contents" tab */ info->tabs[TAB_CONTENTS].hwnd = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW, szEmpty, WS_CHILD | WS_BORDER | 0x25, 50, 50, 100, 100, info->WinType.hwndNavigation, NULL, hhctrl_hinstance, NULL); @@ -737,12 +912,293 @@ static BOOL AddContentTab(HHInfo *info) return FALSE; } - ResizeTabChild(info, info->tabs[TAB_CONTENTS].hwnd); + ResizeTabChild(info, TAB_CONTENTS); ShowWindow(info->tabs[TAB_CONTENTS].hwnd, SW_SHOW); return TRUE; } +static BOOL AddIndexTab(HHInfo *info) +{ + char hidden_column[] = "Column"; + LVCOLUMNA lvc; + + if(info->tabs[TAB_INDEX].id == -1) + return TRUE; /* No "Index" tab */ + info->tabs[TAB_INDEX].hwnd = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, + szEmpty, WS_CHILD | WS_BORDER | LVS_SINGLESEL | LVS_REPORT | LVS_NOCOLUMNHEADER, 50, 50, 100, 100, + info->WinType.hwndNavigation, NULL, hhctrl_hinstance, NULL); + if(!info->tabs[TAB_INDEX].hwnd) { + ERR("Could not create ListView control\n"); + return FALSE; + } + memset(&lvc, 0, sizeof(lvc)); + lvc.mask = LVCF_TEXT; + lvc.pszText = hidden_column; + if(SendMessageW(info->tabs[TAB_INDEX].hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM) &lvc) == -1) + { + ERR("Could not create ListView column\n"); + return FALSE; + } + + ResizeTabChild(info, TAB_INDEX); + ShowWindow(info->tabs[TAB_INDEX].hwnd, SW_HIDE); + + return TRUE; +} + +static BOOL AddSearchTab(HHInfo *info) +{ + HWND hwndList, hwndEdit, hwndContainer; + char hidden_column[] = "Column"; + WNDPROC editWndProc; + LVCOLUMNA lvc; + + if(info->tabs[TAB_SEARCH].id == -1) + return TRUE; /* No "Search" tab */ + hwndContainer = CreateWindowExW(WS_EX_CONTROLPARENT, szChildClass, szEmpty, + WS_CHILD, 0, 0, 0, 0, info->WinType.hwndNavigation, + NULL, hhctrl_hinstance, NULL); + if(!hwndContainer) { + ERR("Could not create search window container control.\n"); + return FALSE; + } + hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE, WC_EDITW, szEmpty, WS_CHILD + | WS_VISIBLE | ES_LEFT | SS_NOTIFY, 0, 0, 0, 0, + hwndContainer, NULL, hhctrl_hinstance, NULL); + if(!hwndEdit) { + ERR("Could not create search ListView control.\n"); + return FALSE; + } + if(SendMessageW(hwndEdit, WM_SETFONT, (WPARAM) info->hFont, (LPARAM) FALSE) == -1) + { + ERR("Could not set font for edit control.\n"); + return FALSE; + } + editWndProc = (WNDPROC) SetWindowLongPtrW(hwndEdit, GWLP_WNDPROC, (LONG_PTR)EditChild_WndProc); + if(!editWndProc) { + ERR("Could not redirect messages for edit control.\n"); + return FALSE; + } + SetWindowLongPtrW(hwndEdit, GWLP_USERDATA, (LONG_PTR)editWndProc); + hwndList = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, szEmpty, + WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_SINGLESEL + | LVS_REPORT | LVS_NOCOLUMNHEADER, 0, 0, 0, 0, + hwndContainer, NULL, hhctrl_hinstance, NULL); + if(!hwndList) { + ERR("Could not create search ListView control.\n"); + return FALSE; + } + memset(&lvc, 0, sizeof(lvc)); + lvc.mask = LVCF_TEXT; + lvc.pszText = hidden_column; + if(SendMessageW(hwndList, LVM_INSERTCOLUMNA, 0, (LPARAM) &lvc) == -1) + { + ERR("Could not create ListView column\n"); + return FALSE; + } + + info->search.hwndEdit = hwndEdit; + info->search.hwndList = hwndList; + info->search.hwndContainer = hwndContainer; + info->tabs[TAB_SEARCH].hwnd = hwndContainer; + + SetWindowLongPtrW(hwndContainer, GWLP_USERDATA, (LONG_PTR)info); + + ResizeTabChild(info, TAB_SEARCH); + + return TRUE; +} + +/* The Index tab's sub-topic popup */ + +static void ResizePopupChild(HHInfo *info) +{ + int scroll_width = GetSystemMetrics(SM_CXVSCROLL); + int border_width = GetSystemMetrics(SM_CXBORDER); + int edge_width = GetSystemMetrics(SM_CXEDGE); + INT width, height; + RECT rect; + + if(!info) + return; + + GetClientRect(info->popup.hwndPopup, &rect); + SetWindowPos(info->popup.hwndCallback, HWND_TOP, 0, 0, + rect.right, rect.bottom, SWP_NOMOVE); + + rect.left = TAB_MARGIN; + rect.top = TAB_TOP_PADDING + TAB_MARGIN; + rect.right -= TAB_RIGHT_PADDING + TAB_MARGIN; + rect.bottom -= TAB_MARGIN; + width = rect.right-rect.left; + height = rect.bottom-rect.top; + + SetWindowPos(info->popup.hwndList, NULL, rect.left, rect.top, width, height, + SWP_NOZORDER | SWP_NOACTIVATE); + + SendMessageW(info->popup.hwndList, LVM_SETCOLUMNWIDTH, 0, + width-scroll_width-2*border_width-2*edge_width); +} + +static LRESULT CALLBACK HelpPopup_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + + switch (message) + { + case WM_SIZE: + ResizePopupChild(info); + return 0; + case WM_DESTROY: + DestroyWindow(hWnd); + return 0; + case WM_CLOSE: + ShowWindow(hWnd, SW_HIDE); + return 0; + + default: + return DefWindowProcW(hWnd, message, wParam, lParam); + } + + return 0; +} + +static LRESULT CALLBACK PopupChild_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_NOTIFY: { + NMHDR *nmhdr = (NMHDR*)lParam; + switch(nmhdr->code) + { + case NM_DBLCLK: { + HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + IndexSubItem *iter; + + if(info == 0 || lParam == 0) + return 0; + iter = (IndexSubItem*) ((NMITEMACTIVATE *)lParam)->lParam; + if(iter == 0) + return 0; + NavigateToChm(info, info->index->merge.chm_file, iter->local); + ShowWindow(info->popup.hwndPopup, SW_HIDE); + return 0; + } + case NM_RETURN: { + HHInfo *info = (HHInfo*)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + IndexSubItem *iter; + LVITEMW lvItem; + + if(info == 0) + return 0; + + lvItem.iItem = (int) SendMessageW(info->popup.hwndList, LVM_GETSELECTIONMARK, 0, 0); + lvItem.mask = TVIF_PARAM; + SendMessageW(info->popup.hwndList, LVM_GETITEMW, 0, (LPARAM)&lvItem); + iter = (IndexSubItem*) lvItem.lParam; + NavigateToChm(info, info->index->merge.chm_file, iter->local); + ShowWindow(info->popup.hwndPopup, SW_HIDE); + return 0; + } + } + break; + } + default: + return DefWindowProcW(hWnd, message, wParam, lParam); + } + + return 0; +} + +static BOOL AddIndexPopup(HHInfo *info) +{ + static const WCHAR szPopupChildClass[] = {'H','H',' ','P','o','p','u','p',' ','C','h','i','l','d',0}; + static const WCHAR windowCaptionW[] = {'S','e','l','e','c','t',' ','T','o','p','i','c',':',0}; + static const WCHAR windowClassW[] = {'H','H',' ','P','o','p','u','p',0}; + HWND hwndList, hwndPopup, hwndCallback; + char hidden_column[] = "Column"; + WNDCLASSEXW wcex; + LVCOLUMNA lvc; + + if(info->tabs[TAB_INDEX].id == -1) + return TRUE; /* No "Index" tab */ + + wcex.cbSize = sizeof(WNDCLASSEXW); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = HelpPopup_WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hhctrl_hinstance; + wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); + wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_MENU + 1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = windowClassW; + wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); + RegisterClassExW(&wcex); + + wcex.cbSize = sizeof(WNDCLASSEXW); + wcex.style = 0; + wcex.lpfnWndProc = PopupChild_WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hhctrl_hinstance; + wcex.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); + wcex.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = szPopupChildClass; + wcex.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION); + RegisterClassExW(&wcex); + + hwndPopup = CreateWindowExW(WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_APPWINDOW + | WS_EX_WINDOWEDGE | WS_EX_RIGHTSCROLLBAR, + windowClassW, windowCaptionW, WS_POPUPWINDOW + | WS_OVERLAPPEDWINDOW | WS_VISIBLE + | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, + CW_USEDEFAULT, 300, 200, info->WinType.hwndHelp, + NULL, hhctrl_hinstance, NULL); + if (!hwndPopup) + return FALSE; + + hwndCallback = CreateWindowExW(WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, + szPopupChildClass, szEmpty, WS_CHILDWINDOW | WS_VISIBLE, + 0, 0, 0, 0, + hwndPopup, NULL, hhctrl_hinstance, NULL); + if (!hwndCallback) + return FALSE; + + ShowWindow(hwndPopup, SW_HIDE); + hwndList = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, szEmpty, + WS_CHILD | WS_BORDER | LVS_SINGLESEL | LVS_REPORT + | LVS_NOCOLUMNHEADER, 50, 50, 100, 100, + hwndCallback, NULL, hhctrl_hinstance, NULL); + if(!hwndList) { + ERR("Could not create popup ListView control\n"); + return FALSE; + } + memset(&lvc, 0, sizeof(lvc)); + lvc.mask = LVCF_TEXT; + lvc.pszText = hidden_column; + if(SendMessageW(hwndList, LVM_INSERTCOLUMNA, 0, (LPARAM) &lvc) == -1) + { + ERR("Could not create popup ListView column\n"); + return FALSE; + } + + info->popup.hwndCallback = hwndCallback; + info->popup.hwndPopup = hwndPopup; + info->popup.hwndList = hwndList; + SetWindowLongPtrW(hwndPopup, GWLP_USERDATA, (LONG_PTR)info); + SetWindowLongPtrW(hwndCallback, GWLP_USERDATA, (LONG_PTR)info); + + ResizePopupChild(info); + ShowWindow(hwndList, SW_SHOW); + + return TRUE; +} + /* Viewer Window */ static LRESULT Help_OnSize(HWND hWnd) @@ -918,7 +1374,17 @@ static BOOL CreateViewer(HHInfo *pHHInfo) if (!AddContentTab(pHHInfo)) return FALSE; + if (!AddIndexTab(pHHInfo)) + return FALSE; + + if (!AddIndexPopup(pHHInfo)) + return FALSE; + + if (!AddSearchTab(pHHInfo)) + return FALSE; + InitContent(pHHInfo); + InitIndex(pHHInfo); return TRUE; } @@ -947,6 +1413,8 @@ void ReleaseHelpViewer(HHInfo *info) ReleaseWebBrowser(info); ReleaseContent(info); + ReleaseIndex(info); + ReleaseSearch(info); if(info->WinType.hwndHelp) DestroyWindow(info->WinType.hwndHelp); @@ -958,6 +1426,13 @@ void ReleaseHelpViewer(HHInfo *info) HHInfo *CreateHelpViewer(LPCWSTR filename) { HHInfo *info = heap_alloc_zero(sizeof(HHInfo)); + int i; + + /* Set the invalid tab ID (-1) as the default value for all + * of the tabs, this matches a failed TCM_INSERTITEM call. + */ + for(i=0;itabs)/sizeof(HHTab);i++) + info->tabs[i].id = -1; OleInitialize(NULL); diff --git a/dll/win32/hhctrl.ocx/hhctrl.c b/dll/win32/hhctrl.ocx/hhctrl.c index 8268a21f34b..99f713059e3 100644 --- a/dll/win32/hhctrl.ocx/hhctrl.c +++ b/dll/win32/hhctrl.ocx/hhctrl.c @@ -272,12 +272,41 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine) { MSG msg; - int len, buflen; + int len, buflen, mapid = -1; WCHAR *filename; char *endq = NULL; hh_process = TRUE; + /* Parse command line option of the HTML Help command. + * + * Note: The only currently handled action is "mapid", + * which corresponds to opening a specific page. + */ + while(*szCmdLine == '-') + { + LPSTR space, ptr; + + ptr = szCmdLine + 1; + space = strchr(ptr, ' '); + if(!strncmp(ptr, "mapid", space-ptr)) + { + char idtxt[10]; + + ptr += strlen("mapid")+1; + space = strchr(ptr, ' '); + memcpy(idtxt, ptr, space-ptr); + idtxt[space-ptr] = '\0'; + mapid = atoi(idtxt); + szCmdLine = space+1; + } + else + { + FIXME("Unhandled HTML Help command line parameter! (%.*s)\n", space-szCmdLine, szCmdLine); + return 0; + } + } + /* FIXME: Check szCmdLine for bad arguments */ if (*szCmdLine == '\"') endq = strchr(++szCmdLine, '\"'); @@ -291,7 +320,11 @@ int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine) MultiByteToWideChar(CP_ACP, 0, szCmdLine, len, filename, buflen); filename[buflen-1] = 0; - HtmlHelpW(GetDesktopWindow(), filename, HH_DISPLAY_TOPIC, 0); + /* Open a specific help topic */ + if(mapid != -1) + HtmlHelpW(GetDesktopWindow(), filename, HH_HELP_CONTEXT, mapid); + else + HtmlHelpW(GetDesktopWindow(), filename, HH_DISPLAY_TOPIC, 0); heap_free(filename); diff --git a/dll/win32/hhctrl.ocx/hhctrl.h b/dll/win32/hhctrl.ocx/hhctrl.h index 795bea4d13e..91d3a775ace 100644 --- a/dll/win32/hhctrl.ocx/hhctrl.h +++ b/dll/win32/hhctrl.ocx/hhctrl.h @@ -65,11 +65,37 @@ typedef struct ContentItem { ChmPath merge; } ContentItem; +typedef struct IndexSubItem { + LPWSTR name; + LPWSTR local; +} IndexSubItem; + +typedef struct IndexItem { + struct IndexItem *next; + + HTREEITEM id; + LPWSTR keyword; + ChmPath merge; + + int nItems; + int itemFlags; + int indentLevel; + IndexSubItem *items; +} IndexItem; + +typedef struct SearchItem { + struct SearchItem *next; + + HTREEITEM id; + LPWSTR title; + LPWSTR filename; +} SearchItem; + typedef struct CHMInfo { IITStorage *pITStorage; IStorage *pStorage; - LPCWSTR szFile; + WCHAR *szFile; IStream *strings_stream; char **strings; @@ -90,6 +116,19 @@ typedef struct { DWORD id; } HHTab; +typedef struct { + HWND hwndList; + HWND hwndPopup; + HWND hwndCallback; +} IndexPopup; + +typedef struct { + SearchItem *root; + HWND hwndEdit; + HWND hwndList; + HWND hwndContainer; +} SearchTab; + typedef struct { IOleClientSite *client_site; IWebBrowser2 *web_browser; @@ -111,6 +150,9 @@ typedef struct { CHMInfo *pCHMInfo; ContentItem *content; + IndexItem *index; + IndexPopup popup; + SearchTab search; HWND hwndTabCtrl; HWND hwndSizeBar; HFONT hFont; @@ -127,6 +169,9 @@ void DoPageAction(HHInfo*,DWORD); void InitContent(HHInfo*); void ReleaseContent(HHInfo*); +void InitIndex(HHInfo*); +void ReleaseIndex(HHInfo*); + CHMInfo *OpenCHM(LPCWSTR szFile); BOOL LoadWinTypeFromCHM(HHInfo *info); CHMInfo *CloseCHM(CHMInfo *pCHMInfo); @@ -139,6 +184,9 @@ void ReleaseHelpViewer(HHInfo*); BOOL NavigateToUrl(HHInfo*,LPCWSTR); BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR); +void InitSearch(HHInfo *info, const char *needle); +void ReleaseSearch(HHInfo *info); + /* memory allocation functions */ static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len) diff --git a/dll/win32/hhctrl.ocx/hhctrl.ocx.rbuild b/dll/win32/hhctrl.ocx/hhctrl.ocx.rbuild index cf043e00031..9cd7d4cfdfd 100644 --- a/dll/win32/hhctrl.ocx/hhctrl.ocx.rbuild +++ b/dll/win32/hhctrl.ocx/hhctrl.ocx.rbuild @@ -14,7 +14,10 @@ content.c help.c hhctrl.c + index.c regsvr.c + search.c + stream.c webbrowser.c hhctrl.rc wine diff --git a/dll/win32/hhctrl.ocx/hhctrl.rc b/dll/win32/hhctrl.ocx/hhctrl.rc index 8618819ed12..8e76454218e 100644 --- a/dll/win32/hhctrl.ocx/hhctrl.rc +++ b/dll/win32/hhctrl.ocx/hhctrl.rc @@ -31,20 +31,25 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include "Cs.rc" #include "Da.rc" -#include "De.rc" #include "El.rc" #include "En.rc" -#include "Fr.rc" #include "Fi.rc" #include "Hu.rc" #include "Ko.rc" -#include "Lt.rc" #include "Nl.rc" #include "No.rc" #include "Pl.rc" #include "Pt.rc" -#include "Ru.rc" -#include "Si.rc" #include "Sv.rc" #include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Es.rc" +#include "Fr.rc" +#include "Lt.rc" +#include "Ru.rc" +#include "Si.rc" +#include "Uk.rc" #include "Zh.rc" + diff --git a/dll/win32/hhctrl.ocx/index.c b/dll/win32/hhctrl.ocx/index.c new file mode 100644 index 00000000000..e9385c35429 --- /dev/null +++ b/dll/win32/hhctrl.ocx/index.c @@ -0,0 +1,295 @@ +/* + * Copyright 2007 Jacek Caban for CodeWeavers + * Copyright 2010 Erich Hoover + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT + +#include "hhctrl.h" +#include "stream.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp); + +/* Fill the TreeView object corresponding to the Index items */ +static void fill_index_tree(HWND hwnd, IndexItem *item) +{ + int index = 0; + LVITEMW lvi; + + while(item) { + TRACE("tree debug: %s\n", debugstr_w(item->keyword)); + + if(!item->keyword) + { + FIXME("HTML Help index item has no keyword.\n"); + item = item->next; + continue; + } + memset(&lvi, 0, sizeof(lvi)); + lvi.iItem = index++; + lvi.mask = LVIF_TEXT|LVIF_PARAM|LVIF_INDENT; + lvi.iIndent = item->indentLevel; + lvi.cchTextMax = strlenW(item->keyword)+1; + lvi.pszText = item->keyword; + lvi.lParam = (LPARAM)item; + item->id = (HTREEITEM)SendMessageW(hwnd, LVM_INSERTITEMW, 0, (LPARAM)&lvi); + item = item->next; + } +} + +/* Parse the attributes correspond to a list item, including sub-topics. + * + * Each list item has, at minimum, a param of type "keyword" and two + * parameters corresponding to a "sub-topic." For each sub-topic there + * must be a "name" param and a "local" param, if there is only one + * sub-topic then there isn't really a sub-topic, the index will jump + * directly to the requested item. + */ +static void parse_index_obj_node_param(IndexItem *item, const char *text) +{ + const char *ptr; + LPWSTR *param; + int len, wlen; + + ptr = get_attr(text, "name", &len); + if(!ptr) { + WARN("name attr not found\n"); + return; + } + + /* Allocate a new sub-item, either on the first run or whenever a + * sub-topic has filled out both the "name" and "local" params. + */ + if(item->itemFlags == 0x11 && (!strncasecmp("name", ptr, len) || !strncasecmp("local", ptr, len))) { + item->nItems++; + item->items = heap_realloc(item->items, sizeof(IndexSubItem)*item->nItems); + item->items[item->nItems-1].name = NULL; + item->items[item->nItems-1].local = NULL; + item->itemFlags = 0x00; + } + if(!strncasecmp("keyword", ptr, len)) { + param = &item->keyword; + }else if(!item->keyword && !strncasecmp("name", ptr, len)) { + /* Some HTML Help index files use an additional "name" parameter + * rather than the "keyword" parameter. In this case, the first + * occurance of the "name" parameter is the keyword. + */ + param = &item->keyword; + }else if(!strncasecmp("name", ptr, len)) { + item->itemFlags |= 0x01; + param = &item->items[item->nItems-1].name; + }else if(!strncasecmp("local", ptr, len)) { + item->itemFlags |= 0x10; + param = &item->items[item->nItems-1].local; + }else { + WARN("unhandled param %s\n", debugstr_an(ptr, len)); + return; + } + + ptr = get_attr(text, "value", &len); + if(!ptr) { + WARN("value attr not found\n"); + return; + } + + wlen = MultiByteToWideChar(CP_ACP, 0, ptr, len, NULL, 0); + *param = heap_alloc((wlen+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, ptr, len, *param, wlen); + (*param)[wlen] = 0; +} + +/* Parse the object tag corresponding to a list item. + * + * At this step we look for all of the "param" child tags, using this information + * to build up the information about the list item. When we reach the + * tag we know that we've finished parsing this list item. + */ +static IndexItem *parse_index_sitemap_object(HHInfo *info, stream_t *stream) +{ + strbuf_t node, node_name; + IndexItem *item; + + strbuf_init(&node); + strbuf_init(&node_name); + + item = heap_alloc_zero(sizeof(IndexItem)); + item->nItems = 0; + item->items = heap_alloc_zero(0); + item->itemFlags = 0x11; + + while(next_node(stream, &node)) { + get_node_name(&node, &node_name); + + TRACE("%s\n", node.buf); + + if(!strcasecmp(node_name.buf, "param")) { + parse_index_obj_node_param(item, node.buf); + }else if(!strcasecmp(node_name.buf, "/object")) { + break; + }else { + WARN("Unhandled tag! %s\n", node_name.buf); + } + + strbuf_zero(&node); + } + + strbuf_free(&node); + strbuf_free(&node_name); + + return item; +} + +/* Parse the HTML list item node corresponding to a specific help entry. + * + * At this stage we look for the only child tag we expect to find under + * the list item: the tag. We also only expect to find object + * tags with the "type" attribute set to "text/sitemap". + */ +static IndexItem *parse_li(HHInfo *info, stream_t *stream) +{ + strbuf_t node, node_name; + IndexItem *ret = NULL; + + strbuf_init(&node); + strbuf_init(&node_name); + + while(next_node(stream, &node)) { + get_node_name(&node, &node_name); + + TRACE("%s\n", node.buf); + + if(!strcasecmp(node_name.buf, "object")) { + const char *ptr; + int len; + + static const char sz_text_sitemap[] = "text/sitemap"; + + ptr = get_attr(node.buf, "type", &len); + + if(ptr && len == sizeof(sz_text_sitemap)-1 + && !memcmp(ptr, sz_text_sitemap, len)) { + ret = parse_index_sitemap_object(info, stream); + break; + } + }else { + WARN("Unhandled tag! %s\n", node_name.buf); + } + + strbuf_zero(&node); + } + + strbuf_free(&node); + strbuf_free(&node_name); + + return ret; +} + +/* Parse the HTML Help page corresponding to all of the Index items. + * + * At this high-level stage we locate out each HTML list item tag. + * Since there is no end-tag for the
  • item, we must hope that + * the
  • entry is parsed correctly or tags might get lost. + * + * Within each entry it is also possible to encounter an additional + *
      tag. When this occurs the tag indicates that the topics + * contained within it are related to the parent
    • topic and + * should be inset by an indent. + */ +static void parse_hhindex(HHInfo *info, IStream *str, IndexItem *item) +{ + stream_t stream; + strbuf_t node, node_name; + int indent_level = -1; + + strbuf_init(&node); + strbuf_init(&node_name); + + stream_init(&stream, str); + + while(next_node(&stream, &node)) { + get_node_name(&node, &node_name); + + TRACE("%s\n", node.buf); + + if(!strcasecmp(node_name.buf, "li")) { + item->next = parse_li(info, &stream); + item->next->merge = item->merge; + item = item->next; + item->indentLevel = indent_level; + }else if(!strcasecmp(node_name.buf, "ul")) { + indent_level++; + }else if(!strcasecmp(node_name.buf, "/ul")) { + indent_level--; + }else { + WARN("Unhandled tag! %s\n", node_name.buf); + } + + strbuf_zero(&node); + } + + strbuf_free(&node); + strbuf_free(&node_name); +} + +/* Initialize the HTML Help Index tab */ +void InitIndex(HHInfo *info) +{ + IStream *stream; + + info->index = heap_alloc_zero(sizeof(IndexItem)); + info->index->nItems = 0; + SetChmPath(&info->index->merge, info->pCHMInfo->szFile, info->WinType.pszIndex); + + stream = GetChmStream(info->pCHMInfo, info->pCHMInfo->szFile, &info->index->merge); + if(!stream) { + TRACE("Could not get index stream\n"); + return; + } + + parse_hhindex(info, stream, info->index); + IStream_Release(stream); + + fill_index_tree(info->tabs[TAB_INDEX].hwnd, info->index->next); +} + +/* Free all of the Index items, including all of the "sub-items" that + * correspond to different sub-topics. + */ +void ReleaseIndex(HHInfo *info) +{ + IndexItem *item = info->index, *next; + int i; + + /* Note: item->merge is identical for all items, only free once */ + heap_free(item->merge.chm_file); + heap_free(item->merge.chm_index); + while(item) { + next = item->next; + + heap_free(item->keyword); + for(i=0;inItems;i++) { + heap_free(item->items[i].name); + heap_free(item->items[i].local); + } + heap_free(item->items); + + item = next; + } +} diff --git a/dll/win32/hhctrl.ocx/search.c b/dll/win32/hhctrl.ocx/search.c new file mode 100644 index 00000000000..f81e46cbf79 --- /dev/null +++ b/dll/win32/hhctrl.ocx/search.c @@ -0,0 +1,246 @@ +/* + * Copyright 2010 Erich Hoover + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT + +#include "hhctrl.h" +#include "stream.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp); + +static SearchItem *SearchCHM_Folder(SearchItem *item, IStorage *pStorage, + const WCHAR *folder, const char *needle); + +/* Allocate a ListView entry for a search result. */ +static SearchItem *alloc_search_item(WCHAR *title, const WCHAR *filename) +{ + int filename_len = filename ? (strlenW(filename)+1)*sizeof(WCHAR) : 0; + SearchItem *item; + + item = heap_alloc_zero(sizeof(SearchItem)); + if(filename) + { + item->filename = heap_alloc(filename_len); + memcpy(item->filename, filename, filename_len); + } + item->title = title; /* Already allocated */ + + return item; +} + +/* Fill the ListView object corresponding to the found Search tab items */ +static void fill_search_tree(HWND hwndList, SearchItem *item) +{ + int index = 0; + LVITEMW lvi; + + SendMessageW(hwndList, LVM_DELETEALLITEMS, 0, 0); + while(item) { + TRACE("list debug: %s\n", debugstr_w(item->filename)); + + memset(&lvi, 0, sizeof(lvi)); + lvi.iItem = index++; + lvi.mask = LVIF_TEXT|LVIF_PARAM; + lvi.cchTextMax = strlenW(item->title)+1; + lvi.pszText = item->title; + lvi.lParam = (LPARAM)item; + item->id = (HTREEITEM)SendMessageW(hwndList, LVM_INSERTITEMW, 0, (LPARAM)&lvi); + item = item->next; + } +} + +/* Search the CHM storage stream (an HTML file) for the requested text. + * + * Before searching the HTML file all HTML tags are removed so that only + * the content of the document is scanned. If the search string is found + * then the title of the document is returned. + */ +static WCHAR *SearchCHM_File(IStorage *pStorage, const WCHAR *file, const char *needle) +{ + char *buffer = heap_alloc(BLOCK_SIZE); + strbuf_t content, node, node_name; + IStream *temp_stream = NULL; + DWORD i, buffer_size = 0; + WCHAR *title = NULL; + BOOL found = FALSE; + stream_t stream; + HRESULT hres; + + hres = IStorage_OpenStream(pStorage, file, NULL, STGM_READ, 0, &temp_stream); + if(FAILED(hres)) { + FIXME("Could not open '%s' stream: %08x\n", debugstr_w(file), hres); + goto cleanup; + } + + strbuf_init(&node); + strbuf_init(&content); + strbuf_init(&node_name); + + stream_init(&stream, temp_stream); + + /* Remove all HTML formatting and record the title */ + while(next_node(&stream, &node)) { + get_node_name(&node, &node_name); + + if(next_content(&stream, &content) && content.len > 1) + { + char *text = &content.buf[1]; + int textlen = content.len-1; + + if(!strcasecmp(node_name.buf, "title")) + { + int wlen = MultiByteToWideChar(CP_ACP, 0, text, textlen, NULL, 0); + title = heap_alloc((wlen+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, text, textlen, title, wlen); + title[wlen] = 0; + } + + buffer = heap_realloc(buffer, buffer_size + textlen + 1); + memcpy(&buffer[buffer_size], text, textlen); + buffer[buffer_size + textlen] = '\0'; + buffer_size += textlen; + } + + strbuf_zero(&node); + strbuf_zero(&content); + } + + /* Convert the buffer to lower case for comparison against the + * requested text (already in lower case). + */ + for(i=0;inext = alloc_search_item(title, entries.pwcsName); + item = item->next; + } + } + break; + default: + FIXME("Unhandled IStorage stream element.\n"); + } + } + return item; +} + +/* Open a CHM storage object (folder) by name and find all items with + * the requested text. The last found item is returned. + */ +static SearchItem *SearchCHM_Folder(SearchItem *item, IStorage *pStorage, + const WCHAR *folder, const char *needle) +{ + IStorage *temp_storage = NULL; + HRESULT hres; + + hres = IStorage_OpenStorage(pStorage, folder, NULL, STGM_READ, NULL, 0, &temp_storage); + if(FAILED(hres)) + { + FIXME("Could not open '%s' storage object: %08x\n", debugstr_w(folder), hres); + return NULL; + } + item = SearchCHM_Storage(item, temp_storage, needle); + + IStorage_Release(temp_storage); + return item; +} + +/* Search the entire CHM file for the requested text and add all of + * the found items to a ListView for the user to choose the item + * they want. + */ +void InitSearch(HHInfo *info, const char *needle) +{ + CHMInfo *chm = info->pCHMInfo; + SearchItem *root_item = alloc_search_item(NULL, NULL); + + SearchCHM_Storage(root_item, chm->pStorage, needle); + fill_search_tree(info->search.hwndList, root_item->next); + if(info->search.root) + ReleaseSearch(info); + info->search.root = root_item; +} + +/* Free all of the found Search items. */ +void ReleaseSearch(HHInfo *info) +{ + SearchItem *item = info->search.root; + + info->search.root = NULL; + while(item) { + heap_free(item->filename); + item = item->next; + } +} diff --git a/dll/win32/hhctrl.ocx/stream.c b/dll/win32/hhctrl.ocx/stream.c new file mode 100644 index 00000000000..317eeebabcf --- /dev/null +++ b/dll/win32/hhctrl.ocx/stream.c @@ -0,0 +1,179 @@ +/* + * Copyright 2007 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "hhctrl.h" +#include "stream.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp); + +void strbuf_init(strbuf_t *buf) +{ + buf->size = 8; + buf->len = 0; + buf->buf = heap_alloc(buf->size); +} + +void strbuf_zero(strbuf_t *buf) +{ + buf->len = 0; +} + +void strbuf_free(strbuf_t *buf) +{ + heap_free(buf->buf); +} + +void strbuf_append(strbuf_t *buf, const char *data, int len) +{ + if(buf->len+len > buf->size) { + buf->size = buf->len+len; + buf->buf = heap_realloc(buf->buf, buf->size); + } + + memcpy(buf->buf+buf->len, data, len); + buf->len += len; +} + +void stream_init(stream_t *stream, IStream *str) +{ + memset(stream, 0, sizeof(stream_t)); + stream->str = str; +} + +BOOL stream_chr(stream_t *stream, strbuf_t *buf, char c) +{ + BOOL b = TRUE; + ULONG i; + + while(b) { + for(i=stream->p; isize; i++) { + if(stream->buf[i] == c) { + b = FALSE; + break; + } + } + + if(buf && i > stream->p) + strbuf_append(buf, stream->buf+stream->p, i-stream->p); + stream->p = i; + + if(stream->p == stream->size) { + stream->p = 0; + IStream_Read(stream->str, stream->buf, sizeof(stream->buf), &stream->size); + if(!stream->size) + break; + } + } + + return stream->size != 0; +} + +void get_node_name(strbuf_t *node, strbuf_t *name) +{ + const char *ptr = node->buf+1; + + strbuf_zero(name); + + while(*ptr != '>' && !isspace(*ptr)) + ptr++; + + strbuf_append(name, node->buf+1, ptr-node->buf-1); + strbuf_append(name, "", 1); +} + +/* Return the stream content up to the next HTML tag. + * + * Note: the first returned character is the end of the last tag (>). + */ +BOOL next_content(stream_t *stream, strbuf_t *buf) +{ + if(!stream_chr(stream, buf, '<')) + return FALSE; + + return TRUE; +} + +BOOL next_node(stream_t *stream, strbuf_t *buf) +{ + if(!stream_chr(stream, NULL, '<')) + return FALSE; + + if(!stream_chr(stream, buf, '>')) + return FALSE; + + strbuf_append(buf, ">", 2); + + return TRUE; +} + +/* + * Find the value of a named HTML attribute. + * + * Note: Attribute names are case insensitive, so it is necessary to + * put both the node text and the attribute name in the same case + * before attempting a string search. + */ +const char *get_attr(const char *node, const char *name, int *len) +{ + const char *ptr, *ptr2; + int name_len, node_len; + char name_buf[32]; + char *node_buf; + int i; + + /* Create a lower case copy of the node */ + node_len = strlen(node)+1; + node_buf = heap_alloc(node_len*sizeof(char)); + if(!node_buf) + return NULL; + memcpy(node_buf, node, node_len); + for(i=0;i(%x %p)\n", This, uHLID, ppihl); + + if(uHLID != HLID_CURRENT) { + FIXME("Only HLID_CURRENT implemented, given: %x\n", uHLID); + return E_NOTIMPL; + } + + *ppihl = This->CurrentPage; + IHlink_AddRef(*ppihl); + + return S_OK; } static HRESULT WINAPI IHlinkBC_SetCurrentHlink( IHlinkBrowseContext* iface, diff --git a/dll/win32/hlink/hlink_main.c b/dll/win32/hlink/hlink_main.c index 213506e15f1..d07901aea4a 100644 --- a/dll/win32/hlink/hlink_main.c +++ b/dll/win32/hlink/hlink_main.c @@ -55,7 +55,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) */ HRESULT WINAPI DllCanUnloadNow( void ) { - FIXME("\n"); return S_OK; } @@ -77,14 +76,12 @@ HRESULT WINAPI HlinkCreateFromMoniker( IMoniker *pimkTrgt, LPCWSTR pwzLocation, if (FAILED(r)) return r; - if (pwzLocation) - IHlink_SetStringReference(hl, HLINKSETF_LOCATION, NULL, pwzLocation); + IHlink_SetMonikerReference(hl, HLINKSETF_LOCATION | HLINKSETF_TARGET, pimkTrgt, pwzLocation); + if (pwzFriendlyName) IHlink_SetFriendlyName(hl, pwzFriendlyName); if (pihlsite) IHlink_SetHlinkSite(hl, pihlsite, dwSiteData); - if (pimkTrgt) - IHlink_SetMonikerReference(hl, 0, pimkTrgt, pwzLocation); *ppvObj = hl; @@ -111,43 +108,12 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation, if (FAILED(r)) return r; - if (pwzLocation) - IHlink_SetStringReference(hl, HLINKSETF_LOCATION, NULL, pwzLocation); - - if (pwzTarget) - { - IMoniker *pTgtMk = NULL; - IBindCtx *pbc = NULL; - ULONG eaten; - - CreateBindCtx(0, &pbc); - r = MkParseDisplayName(pbc, pwzTarget, &eaten, &pTgtMk); - IBindCtx_Release(pbc); - - if (FAILED(r)) - { - LPCWSTR p = strchrW(pwzTarget, ':'); - if (p && (p - pwzTarget > 1)) - r = CreateURLMoniker(NULL, pwzTarget, &pTgtMk); - else - r = CreateFileMoniker(pwzTarget,&pTgtMk); - } - - if (FAILED(r)) - { - ERR("couldn't create moniker for %s, failed with error 0x%08x\n", - debugstr_w(pwzTarget), r); - return r; - } - - IHlink_SetMonikerReference(hl, 0, pTgtMk, pwzLocation); - IMoniker_Release(pTgtMk); - - IHlink_SetStringReference(hl, HLINKSETF_TARGET, pwzTarget, NULL); - } + IHlink_SetStringReference(hl, HLINKSETF_TARGET | HLINKSETF_LOCATION, + pwzTarget, pwzLocation); if (pwzFriendlyName) IHlink_SetFriendlyName(hl, pwzFriendlyName); + if (pihlsite) IHlink_SetHlinkSite(hl, pihlsite, dwSiteData); @@ -159,7 +125,7 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation, /*********************************************************************** - * HlinkNavigate (HLINK.@) + * HlinkCreateBrowseContext (HLINK.@) */ HRESULT WINAPI HlinkCreateBrowseContext( IUnknown* piunkOuter, REFIID riid, void** ppvObj) { diff --git a/dll/win32/hlink/link.c b/dll/win32/hlink/link.c index 689317db429..52197ccf6fd 100644 --- a/dll/win32/hlink/link.c +++ b/dll/win32/hlink/link.c @@ -51,7 +51,6 @@ typedef struct LPWSTR FriendlyName; LPWSTR Location; - LPWSTR Target; LPWSTR TargetFrameName; IMoniker *Moniker; IHlinkSite *Site; @@ -155,7 +154,6 @@ static ULONG WINAPI IHlink_fnRelease (IHlink* iface) TRACE("-- destroying IHlink (%p)\n", This); heap_free(This->FriendlyName); - heap_free(This->Target); heap_free(This->TargetFrameName); heap_free(This->Location); if (This->Moniker) @@ -206,24 +204,33 @@ static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface, { HlinkImpl *This = (HlinkImpl*)iface; - FIXME("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget, + TRACE("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget, debugstr_w(pwzLocation)); - if (This->Moniker) - IMoniker_Release(This->Moniker); + if(rfHLSETF == 0) + return E_INVALIDARG; + if(!(rfHLSETF & (HLINKSETF_TARGET | HLINKSETF_LOCATION))) + return rfHLSETF; - This->Moniker = pmkTarget; - if (This->Moniker) - { - LPOLESTR display_name; - IMoniker_AddRef(This->Moniker); - IMoniker_GetDisplayName(This->Moniker, NULL, NULL, &display_name); - This->absolute = display_name && strchrW(display_name, ':'); - CoTaskMemFree(display_name); + if(rfHLSETF & HLINKSETF_TARGET){ + if (This->Moniker) + IMoniker_Release(This->Moniker); + + This->Moniker = pmkTarget; + if (This->Moniker) + { + LPOLESTR display_name; + IMoniker_AddRef(This->Moniker); + IMoniker_GetDisplayName(This->Moniker, NULL, NULL, &display_name); + This->absolute = display_name && strchrW(display_name, ':'); + CoTaskMemFree(display_name); + } } - heap_free(This->Location); - This->Location = hlink_strdupW( pwzLocation ); + if(rfHLSETF & HLINKSETF_LOCATION){ + heap_free(This->Location); + This->Location = hlink_strdupW( pwzLocation ); + } return S_OK; } @@ -236,11 +243,51 @@ static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface, TRACE("(%p)->(%i %s %s)\n", This, grfHLSETF, debugstr_w(pwzTarget), debugstr_w(pwzLocation)); + if(grfHLSETF > (HLINKSETF_TARGET | HLINKSETF_LOCATION) && + grfHLSETF < -(HLINKSETF_TARGET | HLINKSETF_LOCATION)) + return grfHLSETF; + if (grfHLSETF & HLINKSETF_TARGET) { - heap_free(This->Target); - This->Target = hlink_strdupW( pwzTarget ); + if (This->Moniker) + { + IMoniker_Release(This->Moniker); + This->Moniker = NULL; + } + if (pwzTarget && *pwzTarget) + { + IMoniker *pMon; + IBindCtx *pbc = NULL; + ULONG eaten; + HRESULT r; + + r = CreateBindCtx(0, &pbc); + if (FAILED(r)) + return E_OUTOFMEMORY; + + r = MkParseDisplayName(pbc, pwzTarget, &eaten, &pMon); + IBindCtx_Release(pbc); + + if (FAILED(r)) + { + LPCWSTR p = strchrW(pwzTarget, ':'); + if (p && (p - pwzTarget > 1)) + r = CreateURLMoniker(NULL, pwzTarget, &pMon); + else + r = CreateFileMoniker(pwzTarget, &pMon); + if (FAILED(r)) + { + ERR("couldn't create moniker for %s, failed with error 0x%08x\n", + debugstr_w(pwzTarget), r); + return r; + } + } + + IHlink_SetMonikerReference(iface, HLINKSETF_TARGET, pMon, NULL); + IMoniker_Release(pMon); + } } + if (grfHLSETF & HLINKSETF_LOCATION) { heap_free(This->Location); @@ -272,28 +319,36 @@ static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface, { HlinkImpl *This = (HlinkImpl*)iface; - FIXME("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation); + TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation); + + /* note: undocumented behavior with dwWhichRef == -1 */ + if(dwWhichRef != -1 && dwWhichRef & ~(HLINKGETREF_DEFAULT | HLINKGETREF_ABSOLUTE | HLINKGETREF_RELATIVE)) + { + if(ppwzTarget) + *ppwzTarget = NULL; + if(ppwzLocation) + *ppwzLocation = NULL; + return E_INVALIDARG; + } + + if(dwWhichRef != HLINKGETREF_DEFAULT) + FIXME("unhandled flags: 0x%x\n", dwWhichRef); if (ppwzTarget) { - *ppwzTarget = hlink_co_strdupW( This->Target ); - - if (!This->Target) + IMoniker* mon; + __GetMoniker(This, &mon); + if (mon) { - IMoniker* mon; - __GetMoniker(This, &mon); - if (mon) - { - IBindCtx *pbc; + IBindCtx *pbc; - CreateBindCtx( 0, &pbc); - IMoniker_GetDisplayName(mon, pbc, NULL, ppwzTarget); - IBindCtx_Release(pbc); - IMoniker_Release(mon); - } - else - FIXME("Unhandled case, no set Target and no moniker\n"); + CreateBindCtx( 0, &pbc); + IMoniker_GetDisplayName(mon, pbc, NULL, ppwzTarget); + IBindCtx_Release(pbc); + IMoniker_Release(mon); } + else + *ppwzTarget = NULL; } if (ppwzLocation) *ppwzLocation = hlink_co_strdupW( This->Location ); diff --git a/dll/win32/iccvid/iccvid_Da.rc b/dll/win32/iccvid/iccvid_Da.rc index 185b1bb92ab..bbdc03ed4f2 100644 --- a/dll/win32/iccvid/iccvid_Da.rc +++ b/dll/win32/iccvid/iccvid_Da.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_DANISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_De.rc b/dll/win32/iccvid/iccvid_De.rc index c101f3ad714..d1a3cef3131 100644 --- a/dll/win32/iccvid/iccvid_De.rc +++ b/dll/win32/iccvid/iccvid_De.rc @@ -17,6 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + +#pragma code_page(65001) + LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_En.rc b/dll/win32/iccvid/iccvid_En.rc index c71b0a449a0..91d848a0841 100644 --- a/dll/win32/iccvid/iccvid_En.rc +++ b/dll/win32/iccvid/iccvid_En.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_Es.rc b/dll/win32/iccvid/iccvid_Es.rc new file mode 100644 index 00000000000..e86d5250a01 --- /dev/null +++ b/dll/win32/iccvid/iccvid_Es.rc @@ -0,0 +1,30 @@ +/* + * Copyright 2010 José Manuel Ferrer Ortiz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_NAME "Códec de vídeo Cinepak" + IDS_DESCRIPTION "Códec de vídeo Cinepak" +} diff --git a/dll/win32/iccvid/iccvid_Fr.rc b/dll/win32/iccvid/iccvid_Fr.rc index 4d276e68a15..79d9cfd23ce 100644 --- a/dll/win32/iccvid/iccvid_Fr.rc +++ b/dll/win32/iccvid/iccvid_Fr.rc @@ -16,10 +16,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { - IDS_NAME "codec vido Cinepak" - IDS_DESCRIPTION "codec vido Cinepak" + IDS_NAME "Codec vidéo Cinepak" + IDS_DESCRIPTION "Codec vidéo Cinepak" } diff --git a/dll/win32/iccvid/iccvid_Hu.rc b/dll/win32/iccvid/iccvid_Hu.rc index b24cf8eaf25..69faccd6a0d 100644 --- a/dll/win32/iccvid/iccvid_Hu.rc +++ b/dll/win32/iccvid/iccvid_Hu.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_Ja.rc b/dll/win32/iccvid/iccvid_Ja.rc new file mode 100644 index 00000000000..b845af4a1c3 --- /dev/null +++ b/dll/win32/iccvid/iccvid_Ja.rc @@ -0,0 +1,30 @@ +/* + * Copyright 2009 Aric Stewart, CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_NAME "Cinepak ビデオコーデック" + IDS_DESCRIPTION "Cinepak ビデオコーデック" +} diff --git a/dll/win32/iccvid/iccvid_Ko.rc b/dll/win32/iccvid/iccvid_Ko.rc index 0cfbe3ea95d..f47eb8ca89a 100644 --- a/dll/win32/iccvid/iccvid_Ko.rc +++ b/dll/win32/iccvid/iccvid_Ko.rc @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_Lt.rc b/dll/win32/iccvid/iccvid_Lt.rc new file mode 100644 index 00000000000..2e31cd398ed --- /dev/null +++ b/dll/win32/iccvid/iccvid_Lt.rc @@ -0,0 +1,30 @@ +/* + * Copyright 2009 Aurimas Fišeras + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_NAME "Cinepak vaizdo kodekas" + IDS_DESCRIPTION "Cinepak vaizdo kodekas" +} diff --git a/dll/win32/iccvid/iccvid_Nl.rc b/dll/win32/iccvid/iccvid_Nl.rc index 0c58dd16d85..fbc4024bf22 100644 --- a/dll/win32/iccvid/iccvid_Nl.rc +++ b/dll/win32/iccvid/iccvid_Nl.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_No.rc b/dll/win32/iccvid/iccvid_No.rc index dd64108523b..4cefc0013fd 100644 --- a/dll/win32/iccvid/iccvid_No.rc +++ b/dll/win32/iccvid/iccvid_No.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_Pl.rc b/dll/win32/iccvid/iccvid_Pl.rc index e276e8703a1..0a4c0f51678 100644 --- a/dll/win32/iccvid/iccvid_Pl.rc +++ b/dll/win32/iccvid/iccvid_Pl.rc @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_POLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_Pt.rc b/dll/win32/iccvid/iccvid_Pt.rc index 5e4ad5cabd3..659224f8966 100644 --- a/dll/win32/iccvid/iccvid_Pt.rc +++ b/dll/win32/iccvid/iccvid_Pt.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_Ro.rc b/dll/win32/iccvid/iccvid_Ro.rc index 85cb1da2d38..d99a0b2d36b 100644 --- a/dll/win32/iccvid/iccvid_Ro.rc +++ b/dll/win32/iccvid/iccvid_Ro.rc @@ -17,6 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + +#pragma code_page(65001) + LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_Ru.rc b/dll/win32/iccvid/iccvid_Ru.rc index c78ee72ff16..7a77b349eaf 100644 --- a/dll/win32/iccvid/iccvid_Ru.rc +++ b/dll/win32/iccvid/iccvid_Ru.rc @@ -16,10 +16,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { - IDS_NAME " - Cinepak" - IDS_DESCRIPTION " - Cinepak" + IDS_NAME "Видео кодер-декодер Cinepak" + IDS_DESCRIPTION "Видео кодер-декодер Cinepak" } diff --git a/dll/win32/iccvid/iccvid_Si.rc b/dll/win32/iccvid/iccvid_Si.rc index 82bbd05fee4..9635480e091 100644 --- a/dll/win32/iccvid/iccvid_Si.rc +++ b/dll/win32/iccvid/iccvid_Si.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + #pragma code_page(65001) LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT @@ -25,5 +27,3 @@ STRINGTABLE DISCARDABLE IDS_NAME "Cinepak Video kodek" IDS_DESCRIPTION "Cinepak Video kodek" } - -#pragma code_page(default) diff --git a/dll/win32/iccvid/iccvid_Sv.rc b/dll/win32/iccvid/iccvid_Sv.rc index 55eb468125b..34762d69071 100644 --- a/dll/win32/iccvid/iccvid_Sv.rc +++ b/dll/win32/iccvid/iccvid_Sv.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_Tr.rc b/dll/win32/iccvid/iccvid_Tr.rc index 929f44fcbb2..8eabf9f6909 100644 --- a/dll/win32/iccvid/iccvid_Tr.rc +++ b/dll/win32/iccvid/iccvid_Tr.rc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "iccvid_private.h" + LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/iccvid/iccvid_private.h b/dll/win32/iccvid/iccvid_private.h index 8400e775207..56b082d844d 100644 --- a/dll/win32/iccvid/iccvid_private.h +++ b/dll/win32/iccvid/iccvid_private.h @@ -19,6 +19,8 @@ #ifndef __ICCVID_PRIVATE_H #define __ICCVID_PRIVATE_H +#include + #define IDS_NAME 100 #define IDS_DESCRIPTION 101 diff --git a/dll/win32/iccvid/rsrc.rc b/dll/win32/iccvid/rsrc.rc index e7512207c82..ab655d7e199 100644 --- a/dll/win32/iccvid/rsrc.rc +++ b/dll/win32/iccvid/rsrc.rc @@ -20,17 +20,23 @@ #include "iccvid_private.h" #include "iccvid_Da.rc" -#include "iccvid_De.rc" #include "iccvid_En.rc" -#include "iccvid_Fr.rc" #include "iccvid_Hu.rc" #include "iccvid_Ko.rc" #include "iccvid_Nl.rc" #include "iccvid_No.rc" #include "iccvid_Pl.rc" #include "iccvid_Pt.rc" +#include "iccvid_Sv.rc" +#include "iccvid_Tr.rc" + +/* UTF-8 */ +#include "iccvid_De.rc" +#include "iccvid_Es.rc" +#include "iccvid_Fr.rc" +#include "iccvid_Ja.rc" +#include "iccvid_Lt.rc" #include "iccvid_Ro.rc" #include "iccvid_Ru.rc" #include "iccvid_Si.rc" -#include "iccvid_Sv.rc" -#include "iccvid_Tr.rc" + diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index 4ba1d631313..6f9744872b6 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -20,6 +20,7 @@ */ #include +#include #include "windef.h" #include "winbase.h" @@ -35,10 +36,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(imm); -#define FROM_IME 0xcafe1337 - -static void (*pX11DRV_ForceXIMReset)(HWND); - typedef struct tagIMCCInternal { DWORD dwLock; @@ -76,15 +73,12 @@ typedef struct _tagImmHkl{ typedef struct tagInputContextData { - BOOL bInternalState; - BOOL bRead; - BOOL bInComposition; - HFONT textfont; - DWORD dwLock; INPUTCONTEXT IMC; ImmHkl *immKbd; + HWND imeWnd; + UINT lastVK; } InputContextData; typedef struct _tagTRANSMSG { @@ -93,12 +87,12 @@ typedef struct _tagTRANSMSG { LPARAM lParam; } TRANSMSG, *LPTRANSMSG; -static InputContextData *root_context = NULL; -static HWND hwndDefault = NULL; -static HANDLE hImeInst; -static const WCHAR WC_IMECLASSNAME[] = {'I','M','E',0}; -static ATOM atIMEClass = 0; +typedef struct _tagIMMThreadData { + HIMC defaultContext; + HWND hwndDefault; +} IMMThreadData; +static DWORD tlsIndex = 0; static struct list ImmHklList = LIST_INIT(ImmHklList); /* MSIME messages */ @@ -111,15 +105,174 @@ static UINT WM_MSIME_QUERYPOSITION; static UINT WM_MSIME_DOCUMENTFEED; static const WCHAR szwWineIMCProperty[] = {'W','i','n','e','I','m','m','H','I','M','C','P','r','o','p','e','r','t','y',0}; -/* - * prototypes - */ -static LRESULT WINAPI IME_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, - LPARAM lParam); -static void UpdateDataInDefaultIMEWindow(HWND hwnd, BOOL showable); -static void ImmInternalPostIMEMessage(InputContextData*, UINT, WPARAM, LPARAM); -static void ImmInternalSetOpenStatus(BOOL fOpen); -static HIMCC updateResultStr(HIMCC old, LPWSTR resultstr, DWORD len); + +static const WCHAR szImeFileW[] = {'I','m','e',' ','F','i','l','e',0}; +static const WCHAR szLayoutTextW[] = {'L','a','y','o','u','t',' ','T','e','x','t',0}; +static const WCHAR szImeRegFmt[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s','\\','%','0','8','l','x',0}; + + +#define is_himc_ime_unicode(p) (p->immKbd->imeInfo.fdwProperty & IME_PROP_UNICODE) +#define is_kbd_ime_unicode(p) (p->imeInfo.fdwProperty & IME_PROP_UNICODE) + +static BOOL IMM_DestroyContext(HIMC hIMC); + +static inline WCHAR *strdupAtoW( const char *str ) +{ + WCHAR *ret = NULL; + if (str) + { + DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) + MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); + } + return ret; +} + +static inline CHAR *strdupWtoA( const WCHAR *str ) +{ + CHAR *ret = NULL; + if (str) + { + DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); + if ((ret = HeapAlloc( GetProcessHeap(), 0, len ))) + WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); + } + return ret; +} + +static DWORD convert_candidatelist_WtoA( + LPCANDIDATELIST lpSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen) +{ + DWORD ret, i, len; + + ret = FIELD_OFFSET( CANDIDATELIST, dwOffset[lpSrc->dwCount] ); + if ( lpDst && dwBufLen > 0 ) + { + *lpDst = *lpSrc; + lpDst->dwOffset[0] = ret; + } + + for ( i = 0; i < lpSrc->dwCount; i++) + { + LPBYTE src = (LPBYTE)lpSrc + lpSrc->dwOffset[i]; + + if ( lpDst && dwBufLen > 0 ) + { + LPBYTE dest = (LPBYTE)lpDst + lpDst->dwOffset[i]; + + len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, + (LPSTR)dest, dwBufLen, NULL, NULL); + + if ( i + 1 < lpSrc->dwCount ) + lpDst->dwOffset[i+1] = lpDst->dwOffset[i] + len * sizeof(char); + dwBufLen -= len * sizeof(char); + } + else + len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, NULL, 0, NULL, NULL); + + ret += len * sizeof(char); + } + + if ( lpDst ) + lpDst->dwSize = ret; + + return ret; +} + +static DWORD convert_candidatelist_AtoW( + LPCANDIDATELIST lpSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen) +{ + DWORD ret, i, len; + + ret = FIELD_OFFSET( CANDIDATELIST, dwOffset[lpSrc->dwCount] ); + if ( lpDst && dwBufLen > 0 ) + { + *lpDst = *lpSrc; + lpDst->dwOffset[0] = ret; + } + + for ( i = 0; i < lpSrc->dwCount; i++) + { + LPBYTE src = (LPBYTE)lpSrc + lpSrc->dwOffset[i]; + + if ( lpDst && dwBufLen > 0 ) + { + LPBYTE dest = (LPBYTE)lpDst + lpDst->dwOffset[i]; + + len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)src, -1, + (LPWSTR)dest, dwBufLen); + + if ( i + 1 < lpSrc->dwCount ) + lpDst->dwOffset[i+1] = lpDst->dwOffset[i] + len * sizeof(WCHAR); + dwBufLen -= len * sizeof(WCHAR); + } + else + len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)src, -1, NULL, 0); + + ret += len * sizeof(WCHAR); + } + + if ( lpDst ) + lpDst->dwSize = ret; + + return ret; +} + +static IMMThreadData* IMM_GetThreadData(void) +{ + IMMThreadData* data = TlsGetValue(tlsIndex); + if (!data) + { + data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(IMMThreadData)); + TlsSetValue(tlsIndex,data); + TRACE("Thread Data Created\n"); + } + return data; +} + +static void IMM_FreeThreadData(void) +{ + IMMThreadData* data = TlsGetValue(tlsIndex); + if (data) + { + IMM_DestroyContext(data->defaultContext); + DestroyWindow(data->hwndDefault); + HeapFree(GetProcessHeap(),0,data); + TRACE("Thread Data Destroyed\n"); + } +} + +static HMODULE LoadDefaultWineIME(void) +{ + char buffer[MAX_PATH], libname[32], *name, *next; + HMODULE module = 0; + HKEY hkey; + + TRACE("Attempting to fall back to wine default IME\n"); + + strcpy( buffer, "x11" ); /* default value */ + /* @@ Wine registry key: HKCU\Software\Wine\Drivers */ + if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey )) + { + DWORD type, count = sizeof(buffer); + RegQueryValueExA( hkey, "Ime", 0, &type, (LPBYTE) buffer, &count ); + RegCloseKey( hkey ); + } + + name = buffer; + while (name) + { + next = strchr( name, ',' ); + if (next) *next++ = 0; + + snprintf( libname, sizeof(libname), "wine%s.drv", name ); + if ((module = LoadLibraryA( libname )) != 0) break; + name = next; + } + + return module; +} /* ImmHkl loading and freeing */ #define LOAD_FUNCPTR(f) if((ptr->p##f = (LPVOID)GetProcAddress(ptr->hIME, #f)) == NULL){WARN("Can't find function %s in ime\n", #f);} @@ -128,7 +281,7 @@ static ImmHkl *IMM_GetImmHkl(HKL hkl) ImmHkl *ptr; WCHAR filename[MAX_PATH]; - TRACE("Seeking ime for keyboard 0x%x\n",(unsigned)hkl); + TRACE("Seeking ime for keyboard %p\n",hkl); LIST_FOR_EACH_ENTRY(ptr, &ImmHklList, ImmHkl, entry) { @@ -141,32 +294,49 @@ static ImmHkl *IMM_GetImmHkl(HKL hkl) ptr->hkl = hkl; if (ImmGetIMEFileNameW(hkl, filename, MAX_PATH)) ptr->hIME = LoadLibraryW(filename); + if (!ptr->hIME) + ptr->hIME = LoadDefaultWineIME(); if (ptr->hIME) { LOAD_FUNCPTR(ImeInquire); - LOAD_FUNCPTR(ImeDestroy); - LOAD_FUNCPTR(ImeSelect); - if (!ptr->pImeInquire || !ptr->pImeDestroy || !ptr->pImeSelect) + if (!ptr->pImeInquire || !ptr->pImeInquire(&ptr->imeInfo, ptr->imeClassName, NULL)) { FreeLibrary(ptr->hIME); ptr->hIME = NULL; } else { - ptr->pImeInquire(&ptr->imeInfo, ptr->imeClassName, NULL); - LOAD_FUNCPTR(ImeConfigure); - LOAD_FUNCPTR(ImeEscape); - LOAD_FUNCPTR(ImeSetActiveContext); - LOAD_FUNCPTR(ImeToAsciiEx); - LOAD_FUNCPTR(NotifyIME); - LOAD_FUNCPTR(ImeRegisterWord); - LOAD_FUNCPTR(ImeUnregisterWord); - LOAD_FUNCPTR(ImeEnumRegisterWord); - LOAD_FUNCPTR(ImeSetCompositionString); - LOAD_FUNCPTR(ImeConversionList); - LOAD_FUNCPTR(ImeProcessKey); - LOAD_FUNCPTR(ImeGetRegisterWordStyle); - LOAD_FUNCPTR(ImeGetImeMenuItems); + LOAD_FUNCPTR(ImeDestroy); + LOAD_FUNCPTR(ImeSelect); + if (!ptr->pImeSelect || !ptr->pImeDestroy) + { + FreeLibrary(ptr->hIME); + ptr->hIME = NULL; + } + else + { + LOAD_FUNCPTR(ImeConfigure); + LOAD_FUNCPTR(ImeEscape); + LOAD_FUNCPTR(ImeSetActiveContext); + LOAD_FUNCPTR(ImeToAsciiEx); + LOAD_FUNCPTR(NotifyIME); + LOAD_FUNCPTR(ImeRegisterWord); + LOAD_FUNCPTR(ImeUnregisterWord); + LOAD_FUNCPTR(ImeEnumRegisterWord); + LOAD_FUNCPTR(ImeSetCompositionString); + LOAD_FUNCPTR(ImeConversionList); + LOAD_FUNCPTR(ImeProcessKey); + LOAD_FUNCPTR(ImeGetRegisterWordStyle); + LOAD_FUNCPTR(ImeGetImeMenuItems); + /* make sure our classname is WCHAR */ + if (!is_kbd_ime_unicode(ptr)) + { + WCHAR bufW[17]; + MultiByteToWideChar(CP_ACP, 0, (LPSTR)ptr->imeClassName, + -1, bufW, 17); + lstrcpyW(ptr->imeClassName, bufW); + } + } } } list_add_head(&ImmHklList,&ptr->entry); @@ -191,54 +361,6 @@ static void IMM_FreeAllImmHkl(void) } } -static VOID IMM_PostResult(InputContextData *data) -{ - unsigned int i; - LPCOMPOSITIONSTRING compstr; - LPBYTE compdata; - LPWSTR ResultStr; - HIMCC newCompStr; - - TRACE("Posting result as IME_CHAR\n"); - compdata = ImmLockIMCC(root_context->IMC.hCompStr); - compstr = (LPCOMPOSITIONSTRING)compdata; - ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset); - - for (i = 0; i < compstr->dwResultStrLen; i++) - ImmInternalPostIMEMessage (root_context, WM_IME_CHAR, ResultStr[i], 1); - - ImmUnlockIMCC(root_context->IMC.hCompStr); - - /* clear the buffer */ - newCompStr = updateResultStr(root_context->IMC.hCompStr, NULL, 0); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; -} - -static void IMM_Register(void) -{ - WNDCLASSW wndClass; - ZeroMemory(&wndClass, sizeof(WNDCLASSW)); - wndClass.style = CS_GLOBALCLASS | CS_IME | CS_HREDRAW | CS_VREDRAW; - wndClass.lpfnWndProc = (WNDPROC) IME_WindowProc; - wndClass.cbClsExtra = 0; - wndClass.cbWndExtra = 0; - wndClass.hInstance = hImeInst; - wndClass.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW); - wndClass.hIcon = NULL; - wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW +1); - wndClass.lpszMenuName = 0; - wndClass.lpszClassName = WC_IMECLASSNAME; - atIMEClass = RegisterClassW(&wndClass); -} - -static void IMM_Unregister(void) -{ - if (atIMEClass) { - UnregisterClassW(WC_IMECLASSNAME, NULL); - } -} - static void IMM_RegisterMessages(void) { WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService"); @@ -250,29 +372,26 @@ static void IMM_RegisterMessages(void) WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed"); } - BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved) { - HMODULE x11drv; - TRACE("%p, %x, %p\n",hInstDLL,fdwReason,lpReserved); switch (fdwReason) { case DLL_PROCESS_ATTACH: - DisableThreadLibraryCalls(hInstDLL); - hImeInst = hInstDLL; IMM_RegisterMessages(); - x11drv = GetModuleHandleA("winex11.drv"); - if (x11drv) pX11DRV_ForceXIMReset = (void *)GetProcAddress( x11drv, "ForceXIMReset"); + tlsIndex = TlsAlloc(); + if (tlsIndex == TLS_OUT_OF_INDEXES) + return FALSE; + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + IMM_FreeThreadData(); break; case DLL_PROCESS_DETACH: - if (hwndDefault) - { - DestroyWindow(hwndDefault); - hwndDefault = 0; - } - IMM_Unregister(); + IMM_FreeThreadData(); IMM_FreeAllImmHkl(); + TlsFree(tlsIndex); break; } return TRUE; @@ -306,337 +425,25 @@ static HIMCC ImmCreateBlankCompStr(void) HIMCC rc; LPCOMPOSITIONSTRING ptr; rc = ImmCreateIMCC(sizeof(COMPOSITIONSTRING)); - ptr = (LPCOMPOSITIONSTRING)ImmLockIMCC(rc); + ptr = ImmLockIMCC(rc); memset(ptr,0,sizeof(COMPOSITIONSTRING)); ptr->dwSize = sizeof(COMPOSITIONSTRING); ImmUnlockIMCC(rc); return rc; } -static void ImmInternalSetOpenStatus(BOOL fOpen) -{ - TRACE("Setting internal state to %s\n",(fOpen)?"OPEN":"CLOSED"); - - if (root_context->IMC.fOpen && fOpen == FALSE) - { - ShowWindow(hwndDefault,SW_HIDE); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = ImmCreateBlankCompStr(); - } - - root_context->IMC.fOpen = fOpen; - root_context->bInternalState = fOpen; - - ImmInternalSendIMENotify(root_context, IMN_SETOPENSTATUS, 0); -} - -static int updateField(DWORD origLen, DWORD origOffset, DWORD currentOffset, - LPBYTE target, LPBYTE source, DWORD* lenParam, - DWORD* offsetParam, BOOL wchars ) -{ - if (origLen > 0 && origOffset > 0) - { - int truelen = origLen; - if (wchars) - truelen *= sizeof(WCHAR); - - memcpy(&target[currentOffset], &source[origOffset], truelen); - - *lenParam = origLen; - *offsetParam = currentOffset; - currentOffset += truelen; - } - return currentOffset; -} - -static HIMCC updateCompStr(HIMCC old, LPWSTR compstr, DWORD len) -{ - /* we need to make sure the CompStr, CompClaus and CompAttr fields are all - * set and correct */ - int needed_size; - HIMCC rc; - LPBYTE newdata = NULL; - LPBYTE olddata = NULL; - LPCOMPOSITIONSTRING new_one; - LPCOMPOSITIONSTRING lpcs = NULL; - INT current_offset = 0; - - TRACE("%s, %i\n",debugstr_wn(compstr,len),len); - - if (old == NULL && compstr == NULL && len == 0) - return NULL; - - if (old != NULL) - { - olddata = ImmLockIMCC(old); - lpcs = (LPCOMPOSITIONSTRING)olddata; - } - - needed_size = sizeof(COMPOSITIONSTRING) + len * sizeof(WCHAR) + - len + sizeof(DWORD) * 2; - - if (lpcs != NULL) - { - needed_size += lpcs->dwCompReadAttrLen; - needed_size += lpcs->dwCompReadClauseLen; - needed_size += lpcs->dwCompReadStrLen * sizeof(DWORD); - needed_size += lpcs->dwResultReadClauseLen; - needed_size += lpcs->dwResultReadStrLen * sizeof(DWORD); - needed_size += lpcs->dwResultClauseLen; - needed_size += lpcs->dwResultStrLen * sizeof(DWORD); - needed_size += lpcs->dwPrivateSize; - } - rc = ImmCreateIMCC(needed_size); - newdata = ImmLockIMCC(rc); - new_one = (LPCOMPOSITIONSTRING)newdata; - - new_one->dwSize = needed_size; - current_offset = sizeof(COMPOSITIONSTRING); - if (lpcs != NULL) - { - current_offset = updateField(lpcs->dwCompReadAttrLen, - lpcs->dwCompReadAttrOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadAttrLen, - &new_one->dwCompReadAttrOffset, FALSE); - - current_offset = updateField(lpcs->dwCompReadClauseLen, - lpcs->dwCompReadClauseOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadClauseLen, - &new_one->dwCompReadClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwCompReadStrLen, - lpcs->dwCompReadStrOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadStrLen, - &new_one->dwCompReadStrOffset, TRUE); - - /* new CompAttr, CompClause, CompStr, dwCursorPos */ - new_one->dwDeltaStart = 0; - - current_offset = updateField(lpcs->dwResultReadClauseLen, - lpcs->dwResultReadClauseOffset, - current_offset, newdata, olddata, - &new_one->dwResultReadClauseLen, - &new_one->dwResultReadClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwResultReadStrLen, - lpcs->dwResultReadStrOffset, - current_offset, newdata, olddata, - &new_one->dwResultReadStrLen, - &new_one->dwResultReadStrOffset, TRUE); - - current_offset = updateField(lpcs->dwResultClauseLen, - lpcs->dwResultClauseOffset, - current_offset, newdata, olddata, - &new_one->dwResultClauseLen, - &new_one->dwResultClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwResultStrLen, - lpcs->dwResultStrOffset, - current_offset, newdata, olddata, - &new_one->dwResultStrLen, - &new_one->dwResultStrOffset, TRUE); - - current_offset = updateField(lpcs->dwPrivateSize, - lpcs->dwPrivateOffset, - current_offset, newdata, olddata, - &new_one->dwPrivateSize, - &new_one->dwPrivateOffset, FALSE); - } - - /* set new data */ - /* CompAttr */ - new_one->dwCompAttrLen = len; - if (len > 0) - { - new_one->dwCompAttrOffset = current_offset; - memset(&newdata[current_offset],ATTR_INPUT,len); - current_offset += len; - } - - /* CompClause */ - if (len > 0) - { - new_one->dwCompClauseLen = sizeof(DWORD) * 2; - new_one->dwCompClauseOffset = current_offset; - *(DWORD*)(&newdata[current_offset]) = 0; - current_offset += sizeof(DWORD); - *(DWORD*)(&newdata[current_offset]) = len; - current_offset += sizeof(DWORD); - } - - /* CompStr */ - new_one->dwCompStrLen = len; - if (len > 0) - { - new_one->dwCompStrOffset = current_offset; - memcpy(&newdata[current_offset],compstr,len*sizeof(WCHAR)); - } - - /* CursorPos */ - new_one->dwCursorPos = len; - - ImmUnlockIMCC(rc); - if (lpcs) - ImmUnlockIMCC(old); - - return rc; -} - -static HIMCC updateResultStr(HIMCC old, LPWSTR resultstr, DWORD len) -{ - /* we need to make sure the ResultStr and ResultClause fields are all - * set and correct */ - int needed_size; - HIMCC rc; - LPBYTE newdata = NULL; - LPBYTE olddata = NULL; - LPCOMPOSITIONSTRING new_one; - LPCOMPOSITIONSTRING lpcs = NULL; - INT current_offset = 0; - - TRACE("%s, %i\n",debugstr_wn(resultstr,len),len); - - if (old == NULL && resultstr == NULL && len == 0) - return NULL; - - if (old != NULL) - { - olddata = ImmLockIMCC(old); - lpcs = (LPCOMPOSITIONSTRING)olddata; - } - - needed_size = sizeof(COMPOSITIONSTRING) + len * sizeof(WCHAR) + - sizeof(DWORD) * 2; - - if (lpcs != NULL) - { - needed_size += lpcs->dwCompReadAttrLen; - needed_size += lpcs->dwCompReadClauseLen; - needed_size += lpcs->dwCompReadStrLen * sizeof(DWORD); - needed_size += lpcs->dwCompAttrLen; - needed_size += lpcs->dwCompClauseLen; - needed_size += lpcs->dwCompStrLen * sizeof(DWORD); - needed_size += lpcs->dwResultReadClauseLen; - needed_size += lpcs->dwResultReadStrLen * sizeof(DWORD); - needed_size += lpcs->dwPrivateSize; - } - rc = ImmCreateIMCC(needed_size); - newdata = ImmLockIMCC(rc); - new_one = (LPCOMPOSITIONSTRING)newdata; - - new_one->dwSize = needed_size; - current_offset = sizeof(COMPOSITIONSTRING); - if (lpcs != NULL) - { - current_offset = updateField(lpcs->dwCompReadAttrLen, - lpcs->dwCompReadAttrOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadAttrLen, - &new_one->dwCompReadAttrOffset, FALSE); - - current_offset = updateField(lpcs->dwCompReadClauseLen, - lpcs->dwCompReadClauseOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadClauseLen, - &new_one->dwCompReadClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwCompReadStrLen, - lpcs->dwCompReadStrOffset, - current_offset, newdata, olddata, - &new_one->dwCompReadStrLen, - &new_one->dwCompReadStrOffset, TRUE); - - current_offset = updateField(lpcs->dwCompAttrLen, - lpcs->dwCompAttrOffset, - current_offset, newdata, olddata, - &new_one->dwCompAttrLen, - &new_one->dwCompAttrOffset, FALSE); - - current_offset = updateField(lpcs->dwCompClauseLen, - lpcs->dwCompClauseOffset, - current_offset, newdata, olddata, - &new_one->dwCompClauseLen, - &new_one->dwCompClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwCompStrLen, - lpcs->dwCompStrOffset, - current_offset, newdata, olddata, - &new_one->dwCompStrLen, - &new_one->dwCompStrOffset, TRUE); - - new_one->dwCursorPos = lpcs->dwCursorPos; - new_one->dwDeltaStart = 0; - - current_offset = updateField(lpcs->dwResultReadClauseLen, - lpcs->dwResultReadClauseOffset, - current_offset, newdata, olddata, - &new_one->dwResultReadClauseLen, - &new_one->dwResultReadClauseOffset, FALSE); - - current_offset = updateField(lpcs->dwResultReadStrLen, - lpcs->dwResultReadStrOffset, - current_offset, newdata, olddata, - &new_one->dwResultReadStrLen, - &new_one->dwResultReadStrOffset, TRUE); - - /* new ResultClause , ResultStr */ - - current_offset = updateField(lpcs->dwPrivateSize, - lpcs->dwPrivateOffset, - current_offset, newdata, olddata, - &new_one->dwPrivateSize, - &new_one->dwPrivateOffset, FALSE); - } - - /* set new data */ - /* ResultClause */ - if (len > 0) - { - new_one->dwResultClauseLen = sizeof(DWORD) * 2; - new_one->dwResultClauseOffset = current_offset; - *(DWORD*)(&newdata[current_offset]) = 0; - current_offset += sizeof(DWORD); - *(DWORD*)(&newdata[current_offset]) = len; - current_offset += sizeof(DWORD); - } - - /* ResultStr */ - new_one->dwResultStrLen = len; - if (len > 0) - { - new_one->dwResultStrOffset = current_offset; - memcpy(&newdata[current_offset],resultstr,len*sizeof(WCHAR)); - } - ImmUnlockIMCC(rc); - if (lpcs) - ImmUnlockIMCC(old); - - return rc; -} - - - /*********************************************************************** * ImmAssociateContext (IMM32.@) */ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) { HIMC old = NULL; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p):\n", hWnd, hIMC); - /* - * WINE SPECIFIC! MAY CONFLICT - * associate the root context we have an XIM created - */ - if (hWnd == 0x000) - { - root_context = (InputContextData*)hIMC; - } + if (!IMM_GetThreadData()->defaultContext) + IMM_GetThreadData()->defaultContext = ImmCreateContext(); /* * If already associated just return @@ -646,19 +453,26 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) if (hWnd) { - old = (HIMC)RemovePropW(hWnd,szwWineIMCProperty); + old = RemovePropW(hWnd,szwWineIMCProperty); if (old == NULL) - old = (HIMC)root_context; + old = IMM_GetThreadData()->defaultContext; else if (old == (HIMC)-1) old = NULL; - if (hIMC != (HIMC)root_context) + if (hIMC != IMM_GetThreadData()->defaultContext) { if (hIMC == NULL) /* Meaning disable imm for that window*/ SetPropW(hWnd,szwWineIMCProperty,(HANDLE)-1); else - SetPropW(hWnd,szwWineIMCProperty,(HANDLE)hIMC); + SetPropW(hWnd,szwWineIMCProperty,hIMC); + } + + if (old) + { + InputContextData *old_data = old; + if (old_data->IMC.hWnd == hWnd) + old_data->IMC.hWnd = NULL; } } @@ -686,14 +500,48 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) return old; } + +/* + * Helper function for ImmAssociateContextEx + */ +static BOOL CALLBACK _ImmAssociateContextExEnumProc(HWND hwnd, LPARAM lParam) +{ + HIMC hImc = (HIMC)lParam; + ImmAssociateContext(hwnd,hImc); + return TRUE; +} + /*********************************************************************** * ImmAssociateContextEx (IMM32.@) */ BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags) { - FIXME("(%p, %p, %d): stub\n", hWnd, hIMC, dwFlags); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + TRACE("(%p, %p, %d): stub\n", hWnd, hIMC, dwFlags); + + if (!IMM_GetThreadData()->defaultContext) + IMM_GetThreadData()->defaultContext = ImmCreateContext(); + + if (dwFlags == IACE_DEFAULT) + { + ImmAssociateContext(hWnd,IMM_GetThreadData()->defaultContext); + return TRUE; + } + else if (dwFlags == IACE_IGNORENOCONTEXT) + { + if (GetPropW(hWnd,szwWineIMCProperty)) + ImmAssociateContext(hWnd,hIMC); + return TRUE; + } + else if (dwFlags == IACE_CHILDREN) + { + EnumChildWindows(hWnd,_ImmAssociateContextExEnumProc,(LPARAM)hIMC); + return TRUE; + } + else + { + ERR("Unknown dwFlags 0x%x\n",dwFlags); + return FALSE; + } } /*********************************************************************** @@ -702,11 +550,33 @@ BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags) BOOL WINAPI ImmConfigureIMEA( HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData) { - FIXME("(%p, %p, %d, %p): stub\n", - hKL, hWnd, dwMode, lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + + TRACE("(%p, %p, %d, %p):\n", hKL, hWnd, dwMode, lpData); + + if (dwMode == IME_CONFIG_REGISTERWORD && !lpData) + return FALSE; + + if (immHkl->hIME && immHkl->pImeConfigure) + { + if (dwMode != IME_CONFIG_REGISTERWORD || !is_kbd_ime_unicode(immHkl)) + return immHkl->pImeConfigure(hKL,hWnd,dwMode,lpData); + else + { + REGISTERWORDW rww; + REGISTERWORDA *rwa = lpData; + BOOL rc; + + rww.lpReading = strdupAtoW(rwa->lpReading); + rww.lpWord = strdupAtoW(rwa->lpWord); + rc = immHkl->pImeConfigure(hKL,hWnd,dwMode,&rww); + HeapFree(GetProcessHeap(),0,rww.lpReading); + HeapFree(GetProcessHeap(),0,rww.lpWord); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -715,11 +585,33 @@ BOOL WINAPI ImmConfigureIMEA( BOOL WINAPI ImmConfigureIMEW( HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData) { - FIXME("(%p, %p, %d, %p): stub\n", - hKL, hWnd, dwMode, lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + + TRACE("(%p, %p, %d, %p):\n", hKL, hWnd, dwMode, lpData); + + if (dwMode == IME_CONFIG_REGISTERWORD && !lpData) + return FALSE; + + if (immHkl->hIME && immHkl->pImeConfigure) + { + if (dwMode != IME_CONFIG_REGISTERWORD || is_kbd_ime_unicode(immHkl)) + return immHkl->pImeConfigure(hKL,hWnd,dwMode,lpData); + else + { + REGISTERWORDW *rww = lpData; + REGISTERWORDA rwa; + BOOL rc; + + rwa.lpReading = strdupWtoA(rww->lpReading); + rwa.lpWord = strdupWtoA(rww->lpWord); + rc = immHkl->pImeConfigure(hKL,hWnd,dwMode,&rwa); + HeapFree(GetProcessHeap(),0,rwa.lpReading); + HeapFree(GetProcessHeap(),0,rwa.lpWord); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -728,54 +620,67 @@ BOOL WINAPI ImmConfigureIMEW( HIMC WINAPI ImmCreateContext(void) { InputContextData *new_context; + LPGUIDELINE gl; + LPCANDIDATEINFO ci; new_context = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputContextData)); /* Load the IME */ new_context->immKbd = IMM_GetImmHkl(GetKeyboardLayout(0)); - /* - * Once we depend on the IME for all the processing like we should - * these will become hard errors and result in creation failures - */ if (!new_context->immKbd->hIME) + { TRACE("IME dll could not be loaded\n"); + HeapFree(GetProcessHeap(),0,new_context); + return 0; + } - /* hCompStr is never NULL */ + /* the HIMCCs are never NULL */ new_context->IMC.hCompStr = ImmCreateBlankCompStr(); - new_context->IMC.hMsgBuf = ImmCreateIMCC(1); + new_context->IMC.hMsgBuf = ImmCreateIMCC(0); + new_context->IMC.hCandInfo = ImmCreateIMCC(sizeof(CANDIDATEINFO)); + ci = ImmLockIMCC(new_context->IMC.hCandInfo); + memset(ci,0,sizeof(CANDIDATEINFO)); + ci->dwSize = sizeof(CANDIDATEINFO); + ImmUnlockIMCC(new_context->IMC.hCandInfo); + new_context->IMC.hGuideLine = ImmCreateIMCC(sizeof(GUIDELINE)); + gl = ImmLockIMCC(new_context->IMC.hGuideLine); + memset(gl,0,sizeof(GUIDELINE)); + gl->dwSize = sizeof(GUIDELINE); + ImmUnlockIMCC(new_context->IMC.hGuideLine); /* Initialize the IME Private */ new_context->IMC.hPrivate = ImmCreateIMCC(new_context->immKbd->imeInfo.dwPrivateDataSize); - if (new_context->immKbd->hIME && - !new_context->immKbd->pImeSelect(new_context, TRUE)) + if (!new_context->immKbd->pImeSelect(new_context, TRUE)) { TRACE("Selection of IME failed\n"); - ImmDestroyContext(new_context); + IMM_DestroyContext(new_context); return 0; } + SendMessageW(GetFocus(), WM_IME_SELECT, TRUE, (LPARAM)GetKeyboardLayout(0)); new_context->immKbd->uSelected++; - TRACE("Created context 0x%x\n",(UINT)new_context); + TRACE("Created context %p\n",new_context); - return (HIMC)new_context; + return new_context; } -/*********************************************************************** - * ImmDestroyContext (IMM32.@) - */ -BOOL WINAPI ImmDestroyContext(HIMC hIMC) +static BOOL IMM_DestroyContext(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("Destroying %p\n",hIMC); if (hIMC) { data->immKbd->uSelected --; - if (data->immKbd->hIME) - data->immKbd->pImeSelect(hIMC, FALSE); + data->immKbd->pImeSelect(hIMC, FALSE); + SendMessageW(data->IMC.hWnd, WM_IME_SELECT, FALSE, (LPARAM)GetKeyboardLayout(0)); + + if (IMM_GetThreadData()->hwndDefault == data->imeWnd) + IMM_GetThreadData()->hwndDefault = NULL; + DestroyWindow(data->imeWnd); ImmDestroyIMCC(data->IMC.hCompStr); ImmDestroyIMCC(data->IMC.hCandInfo); @@ -783,17 +688,22 @@ BOOL WINAPI ImmDestroyContext(HIMC hIMC) ImmDestroyIMCC(data->IMC.hPrivate); ImmDestroyIMCC(data->IMC.hMsgBuf); - if (data->textfont) - { - DeleteObject(data->textfont); - data->textfont = NULL; - } - HeapFree(GetProcessHeap(),0,data); } return TRUE; } +/*********************************************************************** + * ImmDestroyContext (IMM32.@) + */ +BOOL WINAPI ImmDestroyContext(HIMC hIMC) +{ + if (hIMC != IMM_GetThreadData()->defaultContext) + return IMM_DestroyContext(hIMC); + else + return FALSE; +} + /*********************************************************************** * ImmDisableIME (IMM32.@) */ @@ -811,13 +721,31 @@ UINT WINAPI ImmEnumRegisterWordA( LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszRegister, LPVOID lpData) { - FIXME("(%p, %p, %s, %d, %s, %p): stub\n", - hKL, lpfnEnumProc, - debugstr_a(lpszReading), dwStyle, - debugstr_a(lpszRegister), lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %s, %d, %s, %p):\n", hKL, lpfnEnumProc, + debugstr_a(lpszReading), dwStyle, debugstr_a(lpszRegister), lpData); + if (immHkl->hIME && immHkl->pImeEnumRegisterWord) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeEnumRegisterWord((REGISTERWORDENUMPROCW)lpfnEnumProc, + (LPCWSTR)lpszReading, dwStyle, (LPCWSTR)lpszRegister, lpData); + else + { + LPWSTR lpszwReading = strdupAtoW(lpszReading); + LPWSTR lpszwRegister = strdupAtoW(lpszRegister); + BOOL rc; + + rc = immHkl->pImeEnumRegisterWord((REGISTERWORDENUMPROCW)lpfnEnumProc, + lpszwReading, dwStyle, lpszwRegister, + lpData); + + HeapFree(GetProcessHeap(),0,lpszwReading); + HeapFree(GetProcessHeap(),0,lpszwRegister); + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -828,13 +756,40 @@ UINT WINAPI ImmEnumRegisterWordW( LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszRegister, LPVOID lpData) { - FIXME("(%p, %p, %s, %d, %s, %p): stub\n", - hKL, lpfnEnumProc, - debugstr_w(lpszReading), dwStyle, - debugstr_w(lpszRegister), lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %s, %d, %s, %p):\n", hKL, lpfnEnumProc, + debugstr_w(lpszReading), dwStyle, debugstr_w(lpszRegister), lpData); + if (immHkl->hIME && immHkl->pImeEnumRegisterWord) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeEnumRegisterWord(lpfnEnumProc, lpszReading, dwStyle, + lpszRegister, lpData); + else + { + LPSTR lpszaReading = strdupWtoA(lpszReading); + LPSTR lpszaRegister = strdupWtoA(lpszRegister); + BOOL rc; + + rc = immHkl->pImeEnumRegisterWord(lpfnEnumProc, (LPCWSTR)lpszaReading, + dwStyle, (LPCWSTR)lpszaRegister, lpData); + + HeapFree(GetProcessHeap(),0,lpszaReading); + HeapFree(GetProcessHeap(),0,lpszaRegister); + return rc; + } + } + else + return 0; +} + +static inline BOOL EscapeRequiresWA(UINT uEscape) +{ + if (uEscape == IME_ESC_GET_EUDC_DICTIONARY || + uEscape == IME_ESC_SET_EUDC_DICTIONARY || + uEscape == IME_ESC_IME_NAME || + uEscape == IME_ESC_GETHELPFILENAME) + return TRUE; + return FALSE; } /*********************************************************************** @@ -844,11 +799,32 @@ LRESULT WINAPI ImmEscapeA( HKL hKL, HIMC hIMC, UINT uEscape, LPVOID lpData) { - FIXME("(%p, %p, %d, %p): stub\n", - hKL, hIMC, uEscape, lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %d, %p):\n", hKL, hIMC, uEscape, lpData); + + if (immHkl->hIME && immHkl->pImeEscape) + { + if (!EscapeRequiresWA(uEscape) || !is_kbd_ime_unicode(immHkl)) + return immHkl->pImeEscape(hIMC,uEscape,lpData); + else + { + WCHAR buffer[81]; /* largest required buffer should be 80 */ + LRESULT rc; + if (uEscape == IME_ESC_SET_EUDC_DICTIONARY) + { + MultiByteToWideChar(CP_ACP,0,lpData,-1,buffer,81); + rc = immHkl->pImeEscape(hIMC,uEscape,buffer); + } + else + { + rc = immHkl->pImeEscape(hIMC,uEscape,buffer); + WideCharToMultiByte(CP_ACP,0,buffer,-1,lpData,80, NULL, NULL); + } + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -858,26 +834,72 @@ LRESULT WINAPI ImmEscapeW( HKL hKL, HIMC hIMC, UINT uEscape, LPVOID lpData) { - FIXME("(%p, %p, %d, %p): stub\n", - hKL, hIMC, uEscape, lpData - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %d, %p):\n", hKL, hIMC, uEscape, lpData); + + if (immHkl->hIME && immHkl->pImeEscape) + { + if (!EscapeRequiresWA(uEscape) || is_kbd_ime_unicode(immHkl)) + return immHkl->pImeEscape(hIMC,uEscape,lpData); + else + { + CHAR buffer[81]; /* largest required buffer should be 80 */ + LRESULT rc; + if (uEscape == IME_ESC_SET_EUDC_DICTIONARY) + { + WideCharToMultiByte(CP_ACP,0,lpData,-1,buffer,81, NULL, NULL); + rc = immHkl->pImeEscape(hIMC,uEscape,buffer); + } + else + { + rc = immHkl->pImeEscape(hIMC,uEscape,buffer); + MultiByteToWideChar(CP_ACP,0,buffer,-1,lpData,80); + } + return rc; + } + } + else + return 0; } /*********************************************************************** * ImmGetCandidateListA (IMM32.@) */ DWORD WINAPI ImmGetCandidateListA( - HIMC hIMC, DWORD deIndex, + HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST lpCandList, DWORD dwBufLen) { - FIXME("(%p, %d, %p, %d): stub\n", - hIMC, deIndex, - lpCandList, dwBufLen - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + InputContextData *data = hIMC; + LPCANDIDATEINFO candinfo; + LPCANDIDATELIST candlist; + DWORD ret = 0; + + TRACE("%p, %d, %p, %d\n", hIMC, dwIndex, lpCandList, dwBufLen); + + if (!data || !data->IMC.hCandInfo) + return 0; + + candinfo = ImmLockIMCC(data->IMC.hCandInfo); + if ( dwIndex >= candinfo->dwCount || + dwIndex >= (sizeof(candinfo->dwOffset) / sizeof(DWORD)) ) + goto done; + + candlist = (LPCANDIDATELIST)((LPBYTE)candinfo + candinfo->dwOffset[dwIndex]); + if ( !candlist->dwSize || !candlist->dwCount ) + goto done; + + if ( !is_himc_ime_unicode(data) ) + { + ret = candlist->dwSize; + if ( lpCandList && dwBufLen >= ret ) + memcpy(lpCandList, candlist, ret); + } + else + ret = convert_candidatelist_WtoA( candlist, lpCandList, dwBufLen); + +done: + ImmUnlockIMCC(data->IMC.hCandInfo); + return ret; } /*********************************************************************** @@ -886,9 +908,30 @@ DWORD WINAPI ImmGetCandidateListA( DWORD WINAPI ImmGetCandidateListCountA( HIMC hIMC, LPDWORD lpdwListCount) { - FIXME("(%p, %p): stub\n", hIMC, lpdwListCount); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + InputContextData *data = hIMC; + LPCANDIDATEINFO candinfo; + DWORD ret, count; + + TRACE("%p, %p\n", hIMC, lpdwListCount); + + if (!data || !lpdwListCount || !data->IMC.hCandInfo) + return 0; + + candinfo = ImmLockIMCC(data->IMC.hCandInfo); + + *lpdwListCount = count = candinfo->dwCount; + + if ( !is_himc_ime_unicode(data) ) + ret = candinfo->dwSize; + else + { + ret = sizeof(CANDIDATEINFO); + while ( count-- ) + ret += ImmGetCandidateListA(hIMC, count, NULL, 0); + } + + ImmUnlockIMCC(data->IMC.hCandInfo); + return ret; } /*********************************************************************** @@ -897,35 +940,91 @@ DWORD WINAPI ImmGetCandidateListCountA( DWORD WINAPI ImmGetCandidateListCountW( HIMC hIMC, LPDWORD lpdwListCount) { - FIXME("(%p, %p): stub\n", hIMC, lpdwListCount); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + InputContextData *data = hIMC; + LPCANDIDATEINFO candinfo; + DWORD ret, count; + + TRACE("%p, %p\n", hIMC, lpdwListCount); + + if (!data || !lpdwListCount || !data->IMC.hCandInfo) + return 0; + + candinfo = ImmLockIMCC(data->IMC.hCandInfo); + + *lpdwListCount = count = candinfo->dwCount; + + if ( is_himc_ime_unicode(data) ) + ret = candinfo->dwSize; + else + { + ret = sizeof(CANDIDATEINFO); + while ( count-- ) + ret += ImmGetCandidateListW(hIMC, count, NULL, 0); + } + + ImmUnlockIMCC(data->IMC.hCandInfo); + return ret; } /*********************************************************************** * ImmGetCandidateListW (IMM32.@) */ DWORD WINAPI ImmGetCandidateListW( - HIMC hIMC, DWORD deIndex, + HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST lpCandList, DWORD dwBufLen) { - FIXME("(%p, %d, %p, %d): stub\n", - hIMC, deIndex, - lpCandList, dwBufLen - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + InputContextData *data = hIMC; + LPCANDIDATEINFO candinfo; + LPCANDIDATELIST candlist; + DWORD ret = 0; + + TRACE("%p, %d, %p, %d\n", hIMC, dwIndex, lpCandList, dwBufLen); + + if (!data || !data->IMC.hCandInfo) + return 0; + + candinfo = ImmLockIMCC(data->IMC.hCandInfo); + if ( dwIndex >= candinfo->dwCount || + dwIndex >= (sizeof(candinfo->dwOffset) / sizeof(DWORD)) ) + goto done; + + candlist = (LPCANDIDATELIST)((LPBYTE)candinfo + candinfo->dwOffset[dwIndex]); + if ( !candlist->dwSize || !candlist->dwCount ) + goto done; + + if ( is_himc_ime_unicode(data) ) + { + ret = candlist->dwSize; + if ( lpCandList && dwBufLen >= ret ) + memcpy(lpCandList, candlist, ret); + } + else + ret = convert_candidatelist_AtoW( candlist, lpCandList, dwBufLen); + +done: + ImmUnlockIMCC(data->IMC.hCandInfo); + return ret; } /*********************************************************************** * ImmGetCandidateWindow (IMM32.@) */ BOOL WINAPI ImmGetCandidateWindow( - HIMC hIMC, DWORD dwBufLen, LPCANDIDATEFORM lpCandidate) + HIMC hIMC, DWORD dwIndex, LPCANDIDATEFORM lpCandidate) { - FIXME("(%p, %d, %p): stub\n", hIMC, dwBufLen, lpCandidate); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + InputContextData *data = hIMC; + + TRACE("%p, %d, %p\n", hIMC, dwIndex, lpCandidate); + + if (!data || !lpCandidate) + return FALSE; + + if ( dwIndex >= (sizeof(data->IMC.cfCandForm) / sizeof(CANDIDATEFORM)) ) + return FALSE; + + *lpCandidate = data->IMC.cfCandForm[dwIndex]; + + return TRUE; } /*********************************************************************** @@ -939,13 +1038,13 @@ BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) TRACE("(%p, %p):\n", hIMC, lplf); rc = ImmGetCompositionFontW(hIMC,&lfW); - if (rc) - { - memcpy(lplf,&lfW,sizeof(LOGFONTA)); - WideCharToMultiByte(CP_ACP, 0, lfW.lfFaceName, -1, lplf->lfFaceName, + if (!rc || !lplf) + return FALSE; + + memcpy(lplf,&lfW,sizeof(LOGFONTA)); + WideCharToMultiByte(CP_ACP, 0, lfW.lfFaceName, -1, lplf->lfFaceName, LF_FACESIZE, NULL, NULL); - } - return rc; + return TRUE; } /*********************************************************************** @@ -953,11 +1052,11 @@ BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) */ BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p):\n", hIMC, lplf); - if (!data) + if (!data || !lplf) return FALSE; *lplf = data->IMC.lfFont.W; @@ -965,112 +1064,270 @@ BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) return TRUE; } + +/* Helpers for the GetCompositionString functions */ + +static INT CopyCompStringIMEtoClient(InputContextData *data, LPBYTE source, INT slen, LPBYTE target, INT tlen, + BOOL unicode ) +{ + INT rc; + + if (is_himc_ime_unicode(data) && !unicode) + rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)source, slen, (LPSTR)target, tlen, NULL, NULL); + else if (!is_himc_ime_unicode(data) && unicode) + rc = MultiByteToWideChar(CP_ACP, 0, (LPSTR)source, slen, (LPWSTR)target, tlen) * sizeof(WCHAR); + else + { + int dlen = (unicode)?sizeof(WCHAR):sizeof(CHAR); + memcpy( target, source, min(slen,tlen)*dlen); + rc = slen*dlen; + } + + return rc; +} + +static INT CopyCompAttrIMEtoClient(InputContextData *data, LPBYTE source, INT slen, LPBYTE ssource, INT sslen, + LPBYTE target, INT tlen, BOOL unicode ) +{ + INT rc; + + if (is_himc_ime_unicode(data) && !unicode) + { + rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)ssource, sslen, NULL, 0, NULL, NULL); + if (tlen) + { + const BYTE *src = source; + LPBYTE dst = target; + int i, j = 0, k = 0; + + if (rc < tlen) + tlen = rc; + for (i = 0; i < sslen; ++i) + { + int len; + + len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)ssource + i, 1, + NULL, 0, NULL, NULL); + for (; len > 0; --len) + { + dst[j++] = src[k]; + + if (j >= tlen) + goto end; + } + ++k; + } + end: + rc = j; + } + } + else if (!is_himc_ime_unicode(data) && unicode) + { + rc = MultiByteToWideChar(CP_ACP, 0, (LPSTR)ssource, sslen, NULL, 0); + if (tlen) + { + const BYTE *src = source; + LPBYTE dst = target; + int i, j = 0; + + if (rc < tlen) + tlen = rc; + for (i = 0; i < sslen; ++i) + { + if (IsDBCSLeadByte(((LPSTR)ssource)[i])) + continue; + + dst[j++] = src[i]; + + if (j >= tlen) + break; + } + rc = j; + } + } + else + { + memcpy( target, source, min(slen,tlen)); + rc = slen; + } + + return rc; +} + +static INT CopyCompClauseIMEtoClient(InputContextData *data, LPBYTE source, INT slen, LPBYTE ssource, INT sslen, + LPBYTE target, INT tlen, BOOL unicode ) +{ + INT rc; + + if (is_himc_ime_unicode(data) && !unicode) + { + if (tlen) + { + int i; + + if (slen < tlen) + tlen = slen; + tlen /= sizeof (DWORD); + for (i = 0; i < tlen; ++i) + { + ((DWORD *)target)[i] = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)ssource, + ((DWORD *)source)[i], + NULL, 0, + NULL, NULL); + } + rc = sizeof (DWORD) * i; + } + else + rc = slen; + } + else if (!is_himc_ime_unicode(data) && unicode) + { + if (tlen) + { + int i; + + if (slen < tlen) + tlen = slen; + tlen /= sizeof (DWORD); + for (i = 0; i < tlen; ++i) + { + ((DWORD *)target)[i] = MultiByteToWideChar(CP_ACP, 0, (LPSTR)ssource, + ((DWORD *)source)[i], + NULL, 0); + } + rc = sizeof (DWORD) * i; + } + else + rc = slen; + } + else + { + memcpy( target, source, min(slen,tlen)); + rc = slen; + } + + return rc; +} + +static INT CopyCompOffsetIMEtoClient(InputContextData *data, DWORD offset, LPBYTE ssource, BOOL unicode) +{ + int rc; + + if (is_himc_ime_unicode(data) && !unicode) + { + rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)ssource, offset, NULL, 0, NULL, NULL); + } + else if (!is_himc_ime_unicode(data) && unicode) + { + rc = MultiByteToWideChar(CP_ACP, 0, (LPSTR)ssource, offset, NULL, 0); + } + else + rc = offset; + + return rc; +} + +static LONG ImmGetCompositionStringT( HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, + DWORD dwBufLen, BOOL unicode) +{ + LONG rc = 0; + InputContextData *data = hIMC; + LPCOMPOSITIONSTRING compstr; + LPBYTE compdata; + + TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen); + + if (!data) + return FALSE; + + if (!data->IMC.hCompStr) + return FALSE; + + compdata = ImmLockIMCC(data->IMC.hCompStr); + compstr = (LPCOMPOSITIONSTRING)compdata; + + switch (dwIndex) + { + case GCS_RESULTSTR: + TRACE("GCS_RESULTSTR\n"); + rc = CopyCompStringIMEtoClient(data, compdata + compstr->dwResultStrOffset, compstr->dwResultStrLen, lpBuf, dwBufLen, unicode); + break; + case GCS_COMPSTR: + TRACE("GCS_COMPSTR\n"); + rc = CopyCompStringIMEtoClient(data, compdata + compstr->dwCompStrOffset, compstr->dwCompStrLen, lpBuf, dwBufLen, unicode); + break; + case GCS_COMPATTR: + TRACE("GCS_COMPATTR\n"); + rc = CopyCompAttrIMEtoClient(data, compdata + compstr->dwCompAttrOffset, compstr->dwCompAttrLen, + compdata + compstr->dwCompStrOffset, compstr->dwCompStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_COMPCLAUSE: + TRACE("GCS_COMPCLAUSE\n"); + rc = CopyCompClauseIMEtoClient(data, compdata + compstr->dwCompClauseOffset,compstr->dwCompClauseLen, + compdata + compstr->dwCompStrOffset, compstr->dwCompStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_RESULTCLAUSE: + TRACE("GCS_RESULTCLAUSE\n"); + rc = CopyCompClauseIMEtoClient(data, compdata + compstr->dwResultClauseOffset,compstr->dwResultClauseLen, + compdata + compstr->dwResultStrOffset, compstr->dwResultStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_RESULTREADSTR: + TRACE("GCS_RESULTREADSTR\n"); + rc = CopyCompStringIMEtoClient(data, compdata + compstr->dwResultReadStrOffset, compstr->dwResultReadStrLen, lpBuf, dwBufLen, unicode); + break; + case GCS_RESULTREADCLAUSE: + TRACE("GCS_RESULTREADCLAUSE\n"); + rc = CopyCompClauseIMEtoClient(data, compdata + compstr->dwResultReadClauseOffset,compstr->dwResultReadClauseLen, + compdata + compstr->dwResultStrOffset, compstr->dwResultStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_COMPREADSTR: + TRACE("GCS_COMPREADSTR\n"); + rc = CopyCompStringIMEtoClient(data, compdata + compstr->dwCompReadStrOffset, compstr->dwCompReadStrLen, lpBuf, dwBufLen, unicode); + break; + case GCS_COMPREADATTR: + TRACE("GCS_COMPREADATTR\n"); + rc = CopyCompAttrIMEtoClient(data, compdata + compstr->dwCompReadAttrOffset, compstr->dwCompReadAttrLen, + compdata + compstr->dwCompReadStrOffset, compstr->dwCompReadStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_COMPREADCLAUSE: + TRACE("GCS_COMPREADCLAUSE\n"); + rc = CopyCompClauseIMEtoClient(data, compdata + compstr->dwCompReadClauseOffset,compstr->dwCompReadClauseLen, + compdata + compstr->dwCompStrOffset, compstr->dwCompStrLen, + lpBuf, dwBufLen, unicode); + break; + case GCS_CURSORPOS: + TRACE("GCS_CURSORPOS\n"); + rc = CopyCompOffsetIMEtoClient(data, compstr->dwCursorPos, compdata + compstr->dwCompStrOffset, unicode); + break; + case GCS_DELTASTART: + TRACE("GCS_DELTASTART\n"); + rc = CopyCompOffsetIMEtoClient(data, compstr->dwDeltaStart, compdata + compstr->dwCompStrOffset, unicode); + break; + default: + FIXME("Unhandled index 0x%x\n",dwIndex); + break; + } + + ImmUnlockIMCC(data->IMC.hCompStr); + + return rc; +} + /*********************************************************************** * ImmGetCompositionStringA (IMM32.@) */ LONG WINAPI ImmGetCompositionStringA( HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen) { - CHAR *buf; - LONG rc = 0; - InputContextData *data = (InputContextData*)hIMC; - LPCOMPOSITIONSTRING compstr; - LPBYTE compdata; - - TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen); - - if (!data) - return FALSE; - - if (!data->IMC.hCompStr) - return FALSE; - - compdata = ImmLockIMCC(data->IMC.hCompStr); - compstr = (LPCOMPOSITIONSTRING)compdata; - - if (dwIndex == GCS_RESULTSTR && compstr->dwResultStrLen > 0 && - compstr->dwResultStrOffset > 0) - { - LPWSTR ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset); - - TRACE("GSC_RESULTSTR %p %i\n",ResultStr, - compstr->dwResultStrLen); - - buf = HeapAlloc( GetProcessHeap(), 0, compstr->dwResultStrLen * 3 ); - rc = WideCharToMultiByte(CP_ACP, 0, ResultStr, - compstr->dwResultStrLen , buf, - compstr->dwResultStrLen * 3, NULL, NULL); - if (dwBufLen >= rc) - memcpy(lpBuf,buf,rc); - - data->bRead = TRUE; - HeapFree( GetProcessHeap(), 0, buf ); - } - else if (dwIndex == GCS_COMPSTR && compstr->dwCompStrLen > 0 && - compstr->dwCompStrOffset > 0) - { - LPWSTR CompString = (LPWSTR)(compdata + compstr->dwCompStrOffset); - - TRACE("GSC_COMPSTR %p %i\n", CompString, compstr->dwCompStrLen); - - buf = HeapAlloc( GetProcessHeap(), 0, compstr->dwCompStrLen * 3 ); - rc = WideCharToMultiByte(CP_ACP, 0, CompString, - compstr->dwCompStrLen, buf, - compstr->dwCompStrLen * 3, NULL, NULL); - if (dwBufLen >= rc) - memcpy(lpBuf,buf,rc); - HeapFree( GetProcessHeap(), 0, buf ); - } - else if (dwIndex == GCS_COMPATTR && compstr->dwCompAttrLen > 0 && - compstr->dwCompAttrOffset > 0) - { - LPWSTR Compattr = (LPWSTR)(compdata + compstr->dwCompAttrOffset); - TRACE("GSC_COMPATTR %p %i\n", Compattr , compstr->dwCompAttrLen); - - rc = compstr->dwCompAttrLen; - if (dwBufLen >= rc) - memcpy(lpBuf,Compattr,rc); - } - else if (dwIndex == GCS_COMPCLAUSE && compstr->dwCompClauseLen > 0 && - compstr->dwCompClauseOffset > 0) - { - LPWSTR Compclause = (LPWSTR)(compdata + compstr->dwCompClauseOffset); - TRACE("GSC_COMPCLAUSE %p %i\n", Compclause, compstr->dwCompClauseLen); - - rc = compstr->dwCompClauseLen; - if (dwBufLen >= compstr->dwCompClauseLen) - memcpy(lpBuf,Compclause,rc); - } - else if (dwIndex == GCS_RESULTCLAUSE && compstr->dwResultClauseLen > 0 && - compstr->dwResultClauseOffset > 0) - { - LPWSTR Resultclause = (LPWSTR)(compdata + compstr->dwResultClauseOffset); - TRACE("GSC_RESULTCLAUSE %p %i\n", Resultclause, compstr->dwResultClauseLen); - - rc = compstr->dwResultClauseLen; - if (dwBufLen >= compstr->dwResultClauseLen) - memcpy(lpBuf,Resultclause,rc); - } - else if (dwIndex == GCS_CURSORPOS) - { - TRACE("GSC_CURSORPOS\n"); - rc = compstr->dwCursorPos; - } - else if (dwIndex == GCS_DELTASTART) - { - TRACE("GCS_DELTASTART\n"); - rc = compstr->dwDeltaStart; - } - else - { - FIXME("Unhandled index 0x%x\n",dwIndex); - } - - ImmUnlockIMCC(data->IMC.hCompStr); - - return rc; + return ImmGetCompositionStringT(hIMC, dwIndex, lpBuf, dwBufLen, FALSE); } + /*********************************************************************** * ImmGetCompositionStringW (IMM32.@) */ @@ -1078,96 +1335,7 @@ LONG WINAPI ImmGetCompositionStringW( HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen) { - LONG rc = 0; - InputContextData *data = (InputContextData*)hIMC; - LPCOMPOSITIONSTRING compstr; - LPBYTE compdata; - - TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen); - - if (!data) - return FALSE; - - if (!data->IMC.hCompStr) - return FALSE; - - compdata = ImmLockIMCC(data->IMC.hCompStr); - compstr = (LPCOMPOSITIONSTRING)compdata; - - if (dwIndex == GCS_RESULTSTR && compstr->dwResultStrLen > 0 && - compstr->dwResultStrOffset > 0) - { - LPWSTR ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset); - data->bRead = TRUE; - rc = compstr->dwResultStrLen * sizeof(WCHAR); - - if (dwBufLen >= rc) - memcpy(lpBuf,ResultStr,rc); - } - else if (dwIndex == GCS_RESULTREADSTR && compstr->dwResultReadStrLen > 0 && - compstr->dwResultReadStrOffset > 0) - { - LPWSTR ResultReadString = (LPWSTR)(compdata + compstr->dwResultReadStrOffset); - - rc = compstr->dwResultReadStrLen * sizeof(WCHAR); - if (dwBufLen >= rc) - memcpy(lpBuf,ResultReadString,rc); - } - else if (dwIndex == GCS_COMPSTR && compstr->dwCompStrLen > 0 && - compstr->dwCompStrOffset > 0) - { - LPWSTR CompString = (LPWSTR)(compdata + compstr->dwCompStrOffset); - rc = compstr->dwCompStrLen * sizeof(WCHAR); - if (dwBufLen >= rc) - memcpy(lpBuf,CompString,rc); - } - else if (dwIndex == GCS_COMPATTR && compstr->dwCompAttrLen > 0 && - compstr->dwCompAttrOffset > 0) - { - - LPWSTR Compattr = (LPWSTR)(compdata + compstr->dwCompAttrOffset); - - rc = compstr->dwCompAttrLen; - if (dwBufLen >= rc) - memcpy(lpBuf,Compattr,rc); - } - else if (dwIndex == GCS_COMPCLAUSE && compstr->dwCompClauseLen > 0 && - compstr->dwCompClauseOffset > 0) - { - LPWSTR Compclause = (LPWSTR)(compdata + compstr->dwCompClauseOffset); - - rc = compstr->dwCompClauseLen; - if (dwBufLen >= compstr->dwCompClauseLen) - memcpy(lpBuf,Compclause,rc); - } - else if (dwIndex == GCS_COMPREADSTR && compstr->dwCompReadStrLen > 0 && - compstr->dwCompReadStrOffset > 0) - { - LPWSTR CompReadString = (LPWSTR)(compdata + compstr->dwCompReadStrOffset); - - rc = compstr->dwCompReadStrLen * sizeof(WCHAR); - - if (dwBufLen >= rc) - memcpy(lpBuf,CompReadString,rc); - } - else if (dwIndex == GCS_CURSORPOS) - { - TRACE("GSC_CURSORPOS\n"); - rc = compstr->dwCursorPos; - } - else if (dwIndex == GCS_DELTASTART) - { - TRACE("GCS_DELTASTART\n"); - rc = compstr->dwDeltaStart; - } - else - { - FIXME("Unhandled index 0x%x\n",dwIndex); - } - - ImmUnlockIMCC(data->IMC.hCompStr); - - return rc; + return ImmGetCompositionStringT(hIMC, dwIndex, lpBuf, dwBufLen, TRUE); } /*********************************************************************** @@ -1175,7 +1343,7 @@ LONG WINAPI ImmGetCompositionStringW( */ BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lpCompForm); @@ -1195,16 +1363,18 @@ HIMC WINAPI ImmGetContext(HWND hWnd) HIMC rc = NULL; TRACE("%p\n", hWnd); + if (!IMM_GetThreadData()->defaultContext) + IMM_GetThreadData()->defaultContext = ImmCreateContext(); - rc = (HIMC)GetPropW(hWnd,szwWineIMCProperty); + rc = GetPropW(hWnd,szwWineIMCProperty); if (rc == (HIMC)-1) rc = NULL; else if (rc == NULL) - rc = (HIMC)root_context; + rc = IMM_GetThreadData()->defaultContext; if (rc) { - InputContextData *data = (InputContextData*)rc; + InputContextData *data = rc; data->IMC.hWnd = hWnd; } TRACE("returning %p\n", rc); @@ -1220,11 +1390,34 @@ DWORD WINAPI ImmGetConversionListA( LPCSTR pSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen, UINT uFlag) { - FIXME("(%p, %p, %s, %p, %d, %d): stub\n", - hKL, hIMC, debugstr_a(pSrc), lpDst, dwBufLen, uFlag - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %s, %p, %d, %d):\n", hKL, hIMC, debugstr_a(pSrc), lpDst, + dwBufLen, uFlag); + if (immHkl->hIME && immHkl->pImeConversionList) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeConversionList(hIMC,(LPCWSTR)pSrc,lpDst,dwBufLen,uFlag); + else + { + LPCANDIDATELIST lpwDst; + DWORD ret = 0, len; + LPWSTR pwSrc = strdupAtoW(pSrc); + + len = immHkl->pImeConversionList(hIMC, pwSrc, NULL, 0, uFlag); + lpwDst = HeapAlloc(GetProcessHeap(), 0, len); + if ( lpwDst ) + { + immHkl->pImeConversionList(hIMC, pwSrc, lpwDst, len, uFlag); + ret = convert_candidatelist_WtoA( lpwDst, lpDst, dwBufLen); + HeapFree(GetProcessHeap(), 0, lpwDst); + } + HeapFree(GetProcessHeap(), 0, pwSrc); + + return ret; + } + } + else + return 0; } /*********************************************************************** @@ -1235,11 +1428,34 @@ DWORD WINAPI ImmGetConversionListW( LPCWSTR pSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen, UINT uFlag) { - FIXME("(%p, %p, %s, %p, %d, %d): stub\n", - hKL, hIMC, debugstr_w(pSrc), lpDst, dwBufLen, uFlag - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %p, %s, %p, %d, %d):\n", hKL, hIMC, debugstr_w(pSrc), lpDst, + dwBufLen, uFlag); + if (immHkl->hIME && immHkl->pImeConversionList) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeConversionList(hIMC,pSrc,lpDst,dwBufLen,uFlag); + else + { + LPCANDIDATELIST lpaDst; + DWORD ret = 0, len; + LPSTR paSrc = strdupWtoA(pSrc); + + len = immHkl->pImeConversionList(hIMC, (LPCWSTR)paSrc, NULL, 0, uFlag); + lpaDst = HeapAlloc(GetProcessHeap(), 0, len); + if ( lpaDst ) + { + immHkl->pImeConversionList(hIMC, (LPCWSTR)paSrc, lpaDst, len, uFlag); + ret = convert_candidatelist_AtoW( lpaDst, lpDst, dwBufLen); + HeapFree(GetProcessHeap(), 0, lpaDst); + } + HeapFree(GetProcessHeap(), 0, paSrc); + + return ret; + } + } + else + return 0; } /*********************************************************************** @@ -1248,11 +1464,18 @@ DWORD WINAPI ImmGetConversionListW( BOOL WINAPI ImmGetConversionStatus( HIMC hIMC, LPDWORD lpfdwConversion, LPDWORD lpfdwSentence) { - TRACE("(%p, %p, %p): best guess\n", hIMC, lpfdwConversion, lpfdwSentence); + InputContextData *data = hIMC; + + TRACE("%p %p %p\n", hIMC, lpfdwConversion, lpfdwSentence); + + if (!data) + return FALSE; + if (lpfdwConversion) - *lpfdwConversion = IME_CMODE_NATIVE; + *lpfdwConversion = data->IMC.fdwConversion; if (lpfdwSentence) - *lpfdwSentence = IME_SMODE_NONE; + *lpfdwSentence = data->IMC.fdwSentence; + return TRUE; } @@ -1261,26 +1484,8 @@ BOOL WINAPI ImmGetConversionStatus( */ HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd) { - static int shown = 0; - - if (!shown) { - FIXME("(%p - %p %p ): semi-stub\n", hWnd,hwndDefault, root_context); - shown = 1; - } - - if (hwndDefault == NULL) - { - static const WCHAR the_name[] = {'I','M','E','\0'}; - - IMM_Register(); - hwndDefault = CreateWindowExW( WS_EX_TOOLWINDOW, WC_IMECLASSNAME, - the_name, WS_POPUP, 0, 0, 1, 1, 0, 0, - hImeInst, 0); - - TRACE("Default created (%p)\n",hwndDefault); - } - - return hwndDefault; + TRACE("Default is %p\n",IMM_GetThreadData()->hwndDefault); + return IMM_GetThreadData()->hwndDefault; } /*********************************************************************** @@ -1391,15 +1596,12 @@ UINT WINAPI ImmGetIMEFileNameA( HKL hKL, LPSTR lpszFileName, UINT uBufLen) */ UINT WINAPI ImmGetIMEFileNameW(HKL hKL, LPWSTR lpszFileName, UINT uBufLen) { - static const WCHAR szImeFileW[] = {'I','m','e',' ','F','i','l','e',0}; - static const WCHAR fmt[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s','\\','%','0','8','x',0}; - HKEY hkey; DWORD length; DWORD rc; - WCHAR regKey[sizeof(fmt)/sizeof(WCHAR)+8]; + WCHAR regKey[sizeof(szImeRegFmt)/sizeof(WCHAR)+8]; - wsprintfW( regKey, fmt, (unsigned)hKL ); + wsprintfW( regKey, szImeRegFmt, (ULONG_PTR)hKL ); rc = RegOpenKeyW( HKEY_LOCAL_MACHINE, regKey, &hkey); if (rc != ERROR_SUCCESS) { @@ -1440,7 +1642,7 @@ UINT WINAPI ImmGetIMEFileNameW(HKL hKL, LPWSTR lpszFileName, UINT uBufLen) */ BOOL WINAPI ImmGetOpenStatus(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; if (!data) return FALSE; @@ -1455,40 +1657,24 @@ BOOL WINAPI ImmGetOpenStatus(HIMC hIMC) DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex) { DWORD rc = 0; - TRACE("(%p, %d)\n", hKL, fdwIndex); + ImmHkl *kbd; - switch (fdwIndex) + TRACE("(%p, %d)\n", hKL, fdwIndex); + kbd = IMM_GetImmHkl(hKL); + + if (kbd && kbd->hIME) { - case IGP_PROPERTY: - TRACE("(%s)\n", "IGP_PROPERTY"); - rc = IME_PROP_UNICODE | IME_PROP_AT_CARET; - break; - case IGP_CONVERSION: - FIXME("(%s)\n", "IGP_CONVERSION"); - rc = IME_CMODE_NATIVE; - break; - case IGP_SENTENCE: - FIXME("%s)\n", "IGP_SENTENCE"); - rc = IME_SMODE_AUTOMATIC; - break; - case IGP_SETCOMPSTR: - TRACE("(%s)\n", "IGP_SETCOMPSTR"); - rc = 0; - break; - case IGP_SELECT: - TRACE("(%s)\n", "IGP_SELECT"); - rc = SELECT_CAP_CONVERSION | SELECT_CAP_SENTENCE; - break; - case IGP_GETIMEVERSION: - TRACE("(%s)\n", "IGP_GETIMEVERSION"); - rc = IMEVER_0400; - break; - case IGP_UI: - TRACE("(%s)\n", "IGP_UI"); - rc = 0; - break; - default: - rc = 0; + switch (fdwIndex) + { + case IGP_PROPERTY: rc = kbd->imeInfo.fdwProperty; break; + case IGP_CONVERSION: rc = kbd->imeInfo.fdwConversionCaps; break; + case IGP_SENTENCE: rc = kbd->imeInfo.fdwSentenceCaps; break; + case IGP_SETCOMPSTR: rc = kbd->imeInfo.fdwSCSCaps; break; + case IGP_SELECT: rc = kbd->imeInfo.fdwSelectCaps; break; + case IGP_GETIMEVERSION: rc = IMEVER_0400; break; + case IGP_UI: rc = 0; break; + default: rc = 0; + } } return rc; } @@ -1499,9 +1685,26 @@ DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex) UINT WINAPI ImmGetRegisterWordStyleA( HKL hKL, UINT nItem, LPSTYLEBUFA lpStyleBuf) { - FIXME("(%p, %d, %p): stub\n", hKL, nItem, lpStyleBuf); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %d, %p):\n", hKL, nItem, lpStyleBuf); + if (immHkl->hIME && immHkl->pImeGetRegisterWordStyle) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeGetRegisterWordStyle(nItem,(LPSTYLEBUFW)lpStyleBuf); + else + { + STYLEBUFW sbw; + UINT rc; + + rc = immHkl->pImeGetRegisterWordStyle(nItem,&sbw); + WideCharToMultiByte(CP_ACP, 0, sbw.szDescription, -1, + lpStyleBuf->szDescription, 32, NULL, NULL); + lpStyleBuf->dwStyle = sbw.dwStyle; + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -1510,9 +1713,26 @@ UINT WINAPI ImmGetRegisterWordStyleA( UINT WINAPI ImmGetRegisterWordStyleW( HKL hKL, UINT nItem, LPSTYLEBUFW lpStyleBuf) { - FIXME("(%p, %d, %p): stub\n", hKL, nItem, lpStyleBuf); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %d, %p):\n", hKL, nItem, lpStyleBuf); + if (immHkl->hIME && immHkl->pImeGetRegisterWordStyle) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeGetRegisterWordStyle(nItem,lpStyleBuf); + else + { + STYLEBUFA sba; + UINT rc; + + rc = immHkl->pImeGetRegisterWordStyle(nItem,(LPSTYLEBUFW)&sba); + MultiByteToWideChar(CP_ACP, 0, sba.szDescription, -1, + lpStyleBuf->szDescription, 32); + lpStyleBuf->dwStyle = sba.dwStyle; + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -1520,9 +1740,16 @@ UINT WINAPI ImmGetRegisterWordStyleW( */ BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) { - FIXME("(%p, %p): stub\n", hIMC, lpptPos); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + InputContextData *data = hIMC; + + TRACE("(%p, %p)\n", hIMC, lpptPos); + + if (!data || !lpptPos) + return FALSE; + + *lpptPos = data->IMC.ptStatusWndPos; + + return TRUE; } /*********************************************************************** @@ -1531,7 +1758,12 @@ BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) UINT WINAPI ImmGetVirtualKey(HWND hWnd) { OSVERSIONINFOA version; - FIXME("(%p): stub\n", hWnd); + InputContextData *data = ImmGetContext( hWnd ); + TRACE("%p\n", hWnd); + + if ( data ) + return data->lastVK; + GetVersionExA( &version ); switch(version.dwPlatformId) { @@ -1551,11 +1783,21 @@ UINT WINAPI ImmGetVirtualKey(HWND hWnd) HKL WINAPI ImmInstallIMEA( LPCSTR lpszIMEFileName, LPCSTR lpszLayoutText) { - FIXME("(%s, %s): stub\n", - debugstr_a(lpszIMEFileName), debugstr_a(lpszLayoutText) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return NULL; + LPWSTR lpszwIMEFileName; + LPWSTR lpszwLayoutText; + HKL hkl; + + TRACE ("(%s, %s)\n", debugstr_a(lpszIMEFileName), + debugstr_a(lpszLayoutText)); + + lpszwIMEFileName = strdupAtoW(lpszIMEFileName); + lpszwLayoutText = strdupAtoW(lpszLayoutText); + + hkl = ImmInstallIMEW(lpszwIMEFileName, lpszwLayoutText); + + HeapFree(GetProcessHeap(),0,lpszwIMEFileName); + HeapFree(GetProcessHeap(),0,lpszwLayoutText); + return hkl; } /*********************************************************************** @@ -1564,11 +1806,56 @@ HKL WINAPI ImmInstallIMEA( HKL WINAPI ImmInstallIMEW( LPCWSTR lpszIMEFileName, LPCWSTR lpszLayoutText) { - FIXME("(%s, %s): stub\n", - debugstr_w(lpszIMEFileName), debugstr_w(lpszLayoutText) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return NULL; + INT lcid = GetUserDefaultLCID(); + INT count; + HKL hkl; + DWORD rc; + HKEY hkey; + WCHAR regKey[sizeof(szImeRegFmt)/sizeof(WCHAR)+8]; + + TRACE ("(%s, %s):\n", debugstr_w(lpszIMEFileName), + debugstr_w(lpszLayoutText)); + + /* Start with 2. e001 will be blank and so default to the wine internal IME */ + count = 2; + + while (count < 0xfff) + { + DWORD disposition = 0; + + hkl = (HKL)MAKELPARAM( lcid, 0xe000 | count ); + wsprintfW( regKey, szImeRegFmt, (ULONG_PTR)hkl); + + rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, regKey, 0, NULL, 0, KEY_WRITE, NULL, &hkey, &disposition); + if (rc == ERROR_SUCCESS && disposition == REG_CREATED_NEW_KEY) + break; + else if (rc == ERROR_SUCCESS) + RegCloseKey(hkey); + + count++; + } + + if (count == 0xfff) + { + WARN("Unable to find slot to install IME\n"); + return 0; + } + + if (rc == ERROR_SUCCESS) + { + rc = RegSetValueExW(hkey, szImeFileW, 0, REG_SZ, (LPBYTE)lpszIMEFileName, + (lstrlenW(lpszIMEFileName) + 1) * sizeof(WCHAR)); + if (rc == ERROR_SUCCESS) + rc = RegSetValueExW(hkey, szLayoutTextW, 0, REG_SZ, (LPBYTE)lpszLayoutText, + (lstrlenW(lpszLayoutText) + 1) * sizeof(WCHAR)); + RegCloseKey(hkey); + return hkl; + } + else + { + WARN("Unable to set IME registry values\n"); + return 0; + } } /*********************************************************************** @@ -1576,12 +1863,10 @@ HKL WINAPI ImmInstallIMEW( */ BOOL WINAPI ImmIsIME(HKL hKL) { - TRACE("(%p): semi-stub\n", hKL); - /* - * FIXME: Dead key locales will return TRUE here when they should not - * There is probably a more proper way to check this. - */ - return (root_context != NULL); + ImmHkl *ptr; + TRACE("(%p):\n", hKL); + ptr = IMM_GetImmHkl(hKL); + return (ptr && ptr->hIME); } /*********************************************************************** @@ -1604,11 +1889,11 @@ BOOL WINAPI ImmIsUIMessageA( (msg == WM_MSIME_DOCUMENTFEED)) { - if (!hwndDefault) + if (!IMM_GetThreadData()->hwndDefault) ImmGetDefaultIMEWnd(NULL); if (hWndIME == NULL) - PostMessageA(hwndDefault, msg, wParam, lParam); + PostMessageA(IMM_GetThreadData()->hwndDefault, msg, wParam, lParam); rc = TRUE; } @@ -1622,7 +1907,7 @@ BOOL WINAPI ImmIsUIMessageW( HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam) { BOOL rc = FALSE; - TRACE("(%p, %d, %ld, %ld): stub\n", hWndIME, msg, wParam, lParam); + TRACE("(%p, %d, %ld, %ld):\n", hWndIME, msg, wParam, lParam); if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) || (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) || (msg == WM_MSIME_SERVICE) || @@ -1642,126 +1927,15 @@ BOOL WINAPI ImmIsUIMessageW( BOOL WINAPI ImmNotifyIME( HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue) { - BOOL rc = FALSE; + InputContextData *data = hIMC; TRACE("(%p, %d, %d, %d)\n", hIMC, dwAction, dwIndex, dwValue); - if (!root_context) - return rc; + if (!data || ! data->immKbd->pNotifyIME) + return FALSE; - switch(dwAction) - { - case NI_CHANGECANDIDATELIST: - FIXME("%s\n","NI_CHANGECANDIDATELIST"); - break; - case NI_CLOSECANDIDATE: - FIXME("%s\n","NI_CLOSECANDIDATE"); - break; - case NI_COMPOSITIONSTR: - switch (dwIndex) - { - case CPS_CANCEL: - TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_CANCEL"); - { - BOOL send; - LPCOMPOSITIONSTRING lpCompStr; - - if (pX11DRV_ForceXIMReset) - pX11DRV_ForceXIMReset(root_context->IMC.hWnd); - - lpCompStr = ImmLockIMCC(root_context->IMC.hCompStr); - send = (lpCompStr->dwCompStrLen != 0); - ImmUnlockIMCC(root_context->IMC.hCompStr); - - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = ImmCreateBlankCompStr(); - - if (send) - ImmInternalPostIMEMessage(root_context, WM_IME_COMPOSITION, 0, - GCS_COMPSTR); - rc = TRUE; - } - break; - case CPS_COMPLETE: - TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_COMPLETE"); - if (hIMC != (HIMC)FROM_IME && pX11DRV_ForceXIMReset) - pX11DRV_ForceXIMReset(root_context->IMC.hWnd); - { - HIMCC newCompStr; - DWORD cplen = 0; - LPWSTR cpstr; - LPCOMPOSITIONSTRING cs = NULL; - LPBYTE cdata = NULL; - - /* clear existing result */ - newCompStr = updateResultStr(root_context->IMC.hCompStr, NULL, 0); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - - if (root_context->IMC.hCompStr) - { - cdata = ImmLockIMCC(root_context->IMC.hCompStr); - cs = (LPCOMPOSITIONSTRING)cdata; - cplen = cs->dwCompStrLen; - cpstr = (LPWSTR)&(cdata[cs->dwCompStrOffset]); - ImmUnlockIMCC(root_context->IMC.hCompStr); - } - if (cplen > 0) - { - WCHAR param = cpstr[0]; - newCompStr = updateResultStr(root_context->IMC.hCompStr, cpstr, cplen); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - newCompStr = updateCompStr(root_context->IMC.hCompStr, NULL, 0); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - - root_context->bRead = FALSE; - - ImmInternalPostIMEMessage(root_context, WM_IME_COMPOSITION, 0, - GCS_COMPSTR); - - ImmInternalPostIMEMessage(root_context, WM_IME_COMPOSITION, - param, - GCS_RESULTSTR|GCS_RESULTCLAUSE); - } - - ImmInternalPostIMEMessage(root_context, WM_IME_ENDCOMPOSITION, 0, 0); - root_context->bInComposition = FALSE; - } - break; - case CPS_CONVERT: - FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_CONVERT"); - break; - case CPS_REVERT: - FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_REVERT"); - break; - default: - ERR("%s - %s (%i)\n","NI_COMPOSITIONSTR","UNKNOWN",dwIndex); - break; - } - break; - case NI_IMEMENUSELECTED: - FIXME("%s\n", "NI_IMEMENUSELECTED"); - break; - case NI_OPENCANDIDATE: - FIXME("%s\n", "NI_OPENCANDIDATE"); - break; - case NI_SELECTCANDIDATESTR: - FIXME("%s\n", "NI_SELECTCANDIDATESTR"); - break; - case NI_SETCANDIDATE_PAGESIZE: - FIXME("%s\n", "NI_SETCANDIDATE_PAGESIZE"); - break; - case NI_SETCANDIDATE_PAGESTART: - FIXME("%s\n", "NI_SETCANDIDATE_PAGESTART"); - break; - default: - ERR("Unknown\n"); - } - - return rc; + return data->immKbd->pNotifyIME(hIMC,dwAction,dwIndex,dwValue); } /*********************************************************************** @@ -1770,11 +1944,28 @@ BOOL WINAPI ImmNotifyIME( BOOL WINAPI ImmRegisterWordA( HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszRegister) { - FIXME("(%p, %s, %d, %s): stub\n", - hKL, debugstr_a(lpszReading), dwStyle, debugstr_a(lpszRegister) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_a(lpszReading), dwStyle, + debugstr_a(lpszRegister)); + if (immHkl->hIME && immHkl->pImeRegisterWord) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeRegisterWord((LPCWSTR)lpszReading,dwStyle, + (LPCWSTR)lpszRegister); + else + { + LPWSTR lpszwReading = strdupAtoW(lpszReading); + LPWSTR lpszwRegister = strdupAtoW(lpszRegister); + BOOL rc; + + rc = immHkl->pImeRegisterWord(lpszwReading,dwStyle,lpszwRegister); + HeapFree(GetProcessHeap(),0,lpszwReading); + HeapFree(GetProcessHeap(),0,lpszwRegister); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -1783,11 +1974,28 @@ BOOL WINAPI ImmRegisterWordA( BOOL WINAPI ImmRegisterWordW( HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszRegister) { - FIXME("(%p, %s, %d, %s): stub\n", - hKL, debugstr_w(lpszReading), dwStyle, debugstr_w(lpszRegister) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_w(lpszReading), dwStyle, + debugstr_w(lpszRegister)); + if (immHkl->hIME && immHkl->pImeRegisterWord) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeRegisterWord(lpszReading,dwStyle,lpszRegister); + else + { + LPSTR lpszaReading = strdupWtoA(lpszReading); + LPSTR lpszaRegister = strdupWtoA(lpszRegister); + BOOL rc; + + rc = immHkl->pImeRegisterWord((LPCWSTR)lpszaReading,dwStyle, + (LPCWSTR)lpszaRegister); + HeapFree(GetProcessHeap(),0,lpszaReading); + HeapFree(GetProcessHeap(),0,lpszaRegister); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -1804,15 +2012,63 @@ BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC) return TRUE; } +/*********************************************************************** +* ImmRequestMessageA(IMM32.@) +*/ +LRESULT WINAPI ImmRequestMessageA(HIMC hIMC, WPARAM wParam, LPARAM lParam) +{ + InputContextData *data = hIMC; + + TRACE("%p %ld %ld\n", hIMC, wParam, wParam); + + if (data && IsWindow(data->IMC.hWnd)) + return SendMessageA(data->IMC.hWnd, WM_IME_REQUEST, wParam, lParam); + + return 0; +} + +/*********************************************************************** +* ImmRequestMessageW(IMM32.@) +*/ +LRESULT WINAPI ImmRequestMessageW(HIMC hIMC, WPARAM wParam, LPARAM lParam) +{ + InputContextData *data = hIMC; + + TRACE("%p %ld %ld\n", hIMC, wParam, wParam); + + if (data && IsWindow(data->IMC.hWnd)) + return SendMessageW(data->IMC.hWnd, WM_IME_REQUEST, wParam, lParam); + + return 0; +} + /*********************************************************************** * ImmSetCandidateWindow (IMM32.@) */ BOOL WINAPI ImmSetCandidateWindow( HIMC hIMC, LPCANDIDATEFORM lpCandidate) { - FIXME("(%p, %p): stub\n", hIMC, lpCandidate); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + InputContextData *data = hIMC; + + TRACE("(%p, %p)\n", hIMC, lpCandidate); + + if (!data || !lpCandidate) + return FALSE; + + TRACE("\t%x, %x, (%i,%i), (%i,%i - %i,%i)\n", + lpCandidate->dwIndex, lpCandidate->dwStyle, + lpCandidate->ptCurrentPos.x, lpCandidate->ptCurrentPos.y, + lpCandidate->rcArea.top, lpCandidate->rcArea.left, + lpCandidate->rcArea.bottom, lpCandidate->rcArea.right); + + if ( lpCandidate->dwIndex >= (sizeof(data->IMC.cfCandForm) / sizeof(CANDIDATEFORM)) ) + return FALSE; + + data->IMC.cfCandForm[lpCandidate->dwIndex] = *lpCandidate; + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, 0, IMC_SETCANDIDATEPOS); + ImmInternalSendIMENotify(data, IMN_SETCANDIDATEPOS, 1 << lpCandidate->dwIndex); + + return TRUE; } /*********************************************************************** @@ -1820,25 +2076,18 @@ BOOL WINAPI ImmSetCandidateWindow( */ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lplf); - if (!data) + if (!data || !lplf) return FALSE; memcpy(&data->IMC.lfFont.W,lplf,sizeof(LOGFONTA)); MultiByteToWideChar(CP_ACP, 0, lplf->lfFaceName, -1, data->IMC.lfFont.W.lfFaceName, LF_FACESIZE); - + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, 0, IMC_SETCOMPOSITIONFONT); ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONFONT, 0); - if (data->textfont) - { - DeleteObject(data->textfont); - data->textfont = NULL; - } - - data->textfont = CreateFontIndirectW(&data->IMC.lfFont.W); return TRUE; } @@ -1847,21 +2096,16 @@ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) */ BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lplf); - if (!data) + if (!data || !lplf) return FALSE; data->IMC.lfFont.W = *lplf; + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, 0, IMC_SETCOMPOSITIONFONT); ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONFONT, 0); - if (data->textfont) - { - DeleteObject(data->textfont); - data->textfont = NULL; - } - data->textfont = CreateFontIndirectW(&data->IMC.lfFont.W); return TRUE; } @@ -1878,10 +2122,25 @@ BOOL WINAPI ImmSetCompositionStringA( WCHAR *CompBuffer = NULL; WCHAR *ReadBuffer = NULL; BOOL rc; + InputContextData *data = hIMC; - TRACE("(%p, %d, %p, %d, %p, %d): stub\n", + TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen); + if (!data) + return FALSE; + + if (!(dwIndex == SCS_SETSTR || + dwIndex == SCS_CHANGEATTR || + dwIndex == SCS_CHANGECLAUSE || + dwIndex == SCS_SETRECONVERTSTRING || + dwIndex == SCS_QUERYRECONVERTSTRING)) + return FALSE; + + if (!is_himc_ime_unicode(data)) + return data->immKbd->pImeSetCompositionString(hIMC, dwIndex, lpComp, + dwCompLen, lpRead, dwReadLen); + comp_len = MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, NULL, 0); if (comp_len) { @@ -1913,64 +2172,55 @@ BOOL WINAPI ImmSetCompositionStringW( LPCVOID lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen) { - DWORD flags = 0; - WCHAR wParam = 0; + DWORD comp_len; + DWORD read_len; + CHAR *CompBuffer = NULL; + CHAR *ReadBuffer = NULL; + BOOL rc; + InputContextData *data = hIMC; - TRACE("(%p, %d, %p, %d, %p, %d): stub\n", - hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen); + TRACE("(%p, %d, %p, %d, %p, %d):\n", + hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen); + if (!data) + return FALSE; - if (hIMC != (HIMC)FROM_IME) - FIXME("PROBLEM: This only sets the wine level string\n"); + if (!(dwIndex == SCS_SETSTR || + dwIndex == SCS_CHANGEATTR || + dwIndex == SCS_CHANGECLAUSE || + dwIndex == SCS_SETRECONVERTSTRING || + dwIndex == SCS_QUERYRECONVERTSTRING)) + return FALSE; - /* - * Explanation: - * this sets the composition string in the imm32.dll level - * of the composition buffer. we cannot manipulate the xim level - * buffer, which means that once the xim level buffer changes again - * any call to this function from the application will be lost - */ + if (is_himc_ime_unicode(data)) + return data->immKbd->pImeSetCompositionString(hIMC, dwIndex, lpComp, + dwCompLen, lpRead, dwReadLen); - if (lpRead && dwReadLen) - FIXME("Reading string unimplemented\n"); - - /* - * app operating this api to also receive the message from xim - */ - - if (dwIndex == SCS_SETSTR) + comp_len = WideCharToMultiByte(CP_ACP, 0, lpComp, dwCompLen, NULL, 0, NULL, + NULL); + if (comp_len) { - HIMCC newCompStr; - if (!root_context->bInComposition) - { - ImmInternalPostIMEMessage(root_context, WM_IME_STARTCOMPOSITION, 0, 0); - root_context->bInComposition = TRUE; - } - - flags = GCS_COMPSTR; - - if (dwCompLen && lpComp) - { - newCompStr = updateCompStr(root_context->IMC.hCompStr, (LPWSTR)lpComp, dwCompLen / sizeof(WCHAR)); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - - wParam = ((const WCHAR*)lpComp)[0]; - flags |= GCS_COMPCLAUSE | GCS_COMPATTR | GCS_DELTASTART; - } - else - { - newCompStr = updateCompStr(root_context->IMC.hCompStr, NULL, 0); - ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = newCompStr; - } + CompBuffer = HeapAlloc(GetProcessHeap(),0,comp_len); + WideCharToMultiByte(CP_ACP, 0, lpComp, dwCompLen, CompBuffer, comp_len, + NULL, NULL); } - UpdateDataInDefaultIMEWindow(hwndDefault,FALSE); + read_len = WideCharToMultiByte(CP_ACP, 0, lpRead, dwReadLen, NULL, 0, NULL, + NULL); + if (read_len) + { + ReadBuffer = HeapAlloc(GetProcessHeap(),0,read_len); + WideCharToMultiByte(CP_ACP, 0, lpRead, dwReadLen, ReadBuffer, read_len, + NULL, NULL); + } - ImmInternalPostIMEMessage(root_context, WM_IME_COMPOSITION, wParam, flags); + rc = ImmSetCompositionStringA(hIMC, dwIndex, CompBuffer, comp_len, + ReadBuffer, read_len); - return TRUE; + HeapFree(GetProcessHeap(), 0, CompBuffer); + HeapFree(GetProcessHeap(), 0, ReadBuffer); + + return rc; } /*********************************************************************** @@ -1980,7 +2230,7 @@ BOOL WINAPI ImmSetCompositionWindow( HIMC hIMC, LPCOMPOSITIONFORM lpCompForm) { BOOL reshow = FALSE; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lpCompForm); TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm->dwStyle, @@ -1992,16 +2242,16 @@ BOOL WINAPI ImmSetCompositionWindow( data->IMC.cfCompForm = *lpCompForm; - if (IsWindowVisible(hwndDefault)) + if (IsWindowVisible(IMM_GetThreadData()->hwndDefault)) { reshow = TRUE; - ShowWindow(hwndDefault,SW_HIDE); + ShowWindow(IMM_GetThreadData()->hwndDefault,SW_HIDE); } /* FIXME: this is a partial stub */ if (reshow) - ShowWindow(hwndDefault,SW_SHOWNOACTIVATE); + ShowWindow(IMM_GetThreadData()->hwndDefault,SW_SHOWNOACTIVATE); ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONWINDOW, 0); return TRUE; @@ -2013,16 +2263,30 @@ BOOL WINAPI ImmSetCompositionWindow( BOOL WINAPI ImmSetConversionStatus( HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence) { - static int shown = 0; + DWORD oldConversion, oldSentence; + InputContextData *data = hIMC; - if (!shown) { - FIXME("(%p, %d, %d): stub\n", - hIMC, fdwConversion, fdwSentence - ); - shown = 1; - } - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + TRACE("%p %d %d\n", hIMC, fdwConversion, fdwSentence); + + if (!data) + return FALSE; + + if ( fdwConversion != data->IMC.fdwConversion ) + { + oldConversion = data->IMC.fdwConversion; + data->IMC.fdwConversion = fdwConversion; + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, oldConversion, IMC_SETCONVERSIONMODE); + ImmInternalSendIMENotify(data, IMN_SETCONVERSIONMODE, 0); + } + if ( fdwSentence != data->IMC.fdwSentence ) + { + oldSentence = data->IMC.fdwSentence; + data->IMC.fdwSentence = fdwSentence; + ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, oldSentence, IMC_SETSENTENCEMODE); + ImmInternalSendIMENotify(data, IMN_SETSENTENCEMODE, 0); + } + + return TRUE; } /*********************************************************************** @@ -2030,40 +2294,30 @@ BOOL WINAPI ImmSetConversionStatus( */ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%p %d\n", hIMC, fOpen); - if (hIMC == (HIMC)FROM_IME) - { - ImmInternalSetOpenStatus(fOpen); - ImmInternalSendIMENotify(root_context, IMN_SETOPENSTATUS, 0); - return TRUE; - } - if (!data) return FALSE; - if (fOpen != data->bInternalState) + if (data->imeWnd == NULL) { - if (fOpen == FALSE && pX11DRV_ForceXIMReset) - pX11DRV_ForceXIMReset(data->IMC.hWnd); - - if (fOpen == FALSE) - ImmInternalPostIMEMessage(data, WM_IME_ENDCOMPOSITION,0,0); - else - ImmInternalPostIMEMessage(data, WM_IME_STARTCOMPOSITION,0,0); - - ImmInternalSetOpenStatus(fOpen); - ImmInternalSetOpenStatus(!fOpen); - - if (data->IMC.fOpen == FALSE) - ImmInternalPostIMEMessage(data, WM_IME_ENDCOMPOSITION,0,0); - else - ImmInternalPostIMEMessage(data, WM_IME_STARTCOMPOSITION,0,0); - - return FALSE; + /* create the ime window */ + data->imeWnd = CreateWindowExW( WS_EX_TOOLWINDOW, + data->immKbd->imeClassName, NULL, WS_POPUP, 0, 0, 1, 1, 0, + 0, data->immKbd->hIME, 0); + SetWindowLongPtrW(data->imeWnd, IMMGWL_IMC, (LONG_PTR)data); + IMM_GetThreadData()->hwndDefault = data->imeWnd; } + + if (!fOpen != !data->IMC.fOpen) + { + data->IMC.fOpen = fOpen; + ImmNotifyIME( hIMC, NI_CONTEXTUPDATED, 0, IMC_SETOPENSTATUS); + ImmInternalSendIMENotify(data, IMN_SETOPENSTATUS, 0); + } + return TRUE; } @@ -2072,9 +2326,50 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) */ BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) { - FIXME("(%p, %p): stub\n", hIMC, lpptPos); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + InputContextData *data = hIMC; + + TRACE("(%p, %p)\n", hIMC, lpptPos); + + if (!data || !lpptPos) + return FALSE; + + TRACE("\t(%i,%i)\n", lpptPos->x, lpptPos->y); + + data->IMC.ptStatusWndPos = *lpptPos; + ImmNotifyIME( hIMC, NI_CONTEXTUPDATED, 0, IMC_SETSTATUSWINDOWPOS); + ImmInternalSendIMENotify(data, IMN_SETSTATUSWINDOWPOS, 0); + + return TRUE; +} + +/*********************************************************************** + * ImmCreateSoftKeyboard(IMM32.@) + */ +HWND WINAPI ImmCreateSoftKeyboard(UINT uType, UINT hOwner, int x, int y) +{ + FIXME("(%d, %d, %d, %d): stub\n", uType, hOwner, x, y); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/*********************************************************************** + * ImmDestroySoftKeyboard(IMM32.@) + */ +BOOL WINAPI ImmDestroySoftKeyboard(HWND hSoftWnd) +{ + FIXME("(%p): stub\n", hSoftWnd); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/*********************************************************************** + * ImmShowSoftKeyboard(IMM32.@) + */ +BOOL WINAPI ImmShowSoftKeyboard(HWND hSoftWnd, int nCmdShow) +{ + FIXME("(%p, %d): stub\n", hSoftWnd, nCmdShow); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /*********************************************************************** @@ -2093,11 +2388,28 @@ BOOL WINAPI ImmSimulateHotKey(HWND hWnd, DWORD dwHotKeyID) BOOL WINAPI ImmUnregisterWordA( HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszUnregister) { - FIXME("(%p, %s, %d, %s): stub\n", - hKL, debugstr_a(lpszReading), dwStyle, debugstr_a(lpszUnregister) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_a(lpszReading), dwStyle, + debugstr_a(lpszUnregister)); + if (immHkl->hIME && immHkl->pImeUnregisterWord) + { + if (!is_kbd_ime_unicode(immHkl)) + return immHkl->pImeUnregisterWord((LPCWSTR)lpszReading,dwStyle, + (LPCWSTR)lpszUnregister); + else + { + LPWSTR lpszwReading = strdupAtoW(lpszReading); + LPWSTR lpszwUnregister = strdupAtoW(lpszUnregister); + BOOL rc; + + rc = immHkl->pImeUnregisterWord(lpszwReading,dwStyle,lpszwUnregister); + HeapFree(GetProcessHeap(),0,lpszwReading); + HeapFree(GetProcessHeap(),0,lpszwUnregister); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -2106,11 +2418,28 @@ BOOL WINAPI ImmUnregisterWordA( BOOL WINAPI ImmUnregisterWordW( HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszUnregister) { - FIXME("(%p, %s, %d, %s): stub\n", - hKL, debugstr_w(lpszReading), dwStyle, debugstr_w(lpszUnregister) - ); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + ImmHkl *immHkl = IMM_GetImmHkl(hKL); + TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_w(lpszReading), dwStyle, + debugstr_w(lpszUnregister)); + if (immHkl->hIME && immHkl->pImeUnregisterWord) + { + if (is_kbd_ime_unicode(immHkl)) + return immHkl->pImeUnregisterWord(lpszReading,dwStyle,lpszUnregister); + else + { + LPSTR lpszaReading = strdupWtoA(lpszReading); + LPSTR lpszaUnregister = strdupWtoA(lpszUnregister); + BOOL rc; + + rc = immHkl->pImeUnregisterWord((LPCWSTR)lpszaReading,dwStyle, + (LPCWSTR)lpszaUnregister); + HeapFree(GetProcessHeap(),0,lpszaReading); + HeapFree(GetProcessHeap(),0,lpszaUnregister); + return rc; + } + } + else + return FALSE; } /*********************************************************************** @@ -2120,9 +2449,61 @@ DWORD WINAPI ImmGetImeMenuItemsA( HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOA lpImeParentMenu, LPIMEMENUITEMINFOA lpImeMenu, DWORD dwSize) { - FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC, dwFlags, dwType, - lpImeParentMenu, lpImeMenu, dwSize); - return 0; + InputContextData *data = hIMC; + TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType, + lpImeParentMenu, lpImeMenu, dwSize); + if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems) + { + if (!is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu)) + return data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, + (IMEMENUITEMINFOW*)lpImeParentMenu, + (IMEMENUITEMINFOW*)lpImeMenu, dwSize); + else + { + IMEMENUITEMINFOW lpImeParentMenuW; + IMEMENUITEMINFOW *lpImeMenuW, *parent = NULL; + DWORD rc; + + if (lpImeParentMenu) + parent = &lpImeParentMenuW; + if (lpImeMenu) + { + int count = dwSize / sizeof(LPIMEMENUITEMINFOA); + dwSize = count * sizeof(IMEMENUITEMINFOW); + lpImeMenuW = HeapAlloc(GetProcessHeap(), 0, dwSize); + } + else + lpImeMenuW = NULL; + + rc = data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, + parent, lpImeMenuW, dwSize); + + if (lpImeParentMenu) + { + memcpy(lpImeParentMenu,&lpImeParentMenuW,sizeof(IMEMENUITEMINFOA)); + lpImeParentMenu->hbmpItem = lpImeParentMenuW.hbmpItem; + WideCharToMultiByte(CP_ACP, 0, lpImeParentMenuW.szString, + -1, lpImeParentMenu->szString, IMEMENUITEM_STRING_SIZE, + NULL, NULL); + } + if (lpImeMenu && rc) + { + unsigned int i; + for (i = 0; i < rc; i++) + { + memcpy(&lpImeMenu[i],&lpImeMenuW[1],sizeof(IMEMENUITEMINFOA)); + lpImeMenu[i].hbmpItem = lpImeMenuW[i].hbmpItem; + WideCharToMultiByte(CP_ACP, 0, lpImeMenuW[i].szString, + -1, lpImeMenu[i].szString, IMEMENUITEM_STRING_SIZE, + NULL, NULL); + } + } + HeapFree(GetProcessHeap(),0,lpImeMenuW); + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -2132,9 +2513,59 @@ DWORD WINAPI ImmGetImeMenuItemsW( HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize) { - FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC, dwFlags, dwType, - lpImeParentMenu, lpImeMenu, dwSize); - return 0; + InputContextData *data = hIMC; + TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType, + lpImeParentMenu, lpImeMenu, dwSize); + if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems) + { + if (is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu)) + return data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, + lpImeParentMenu, lpImeMenu, dwSize); + else + { + IMEMENUITEMINFOA lpImeParentMenuA; + IMEMENUITEMINFOA *lpImeMenuA, *parent = NULL; + DWORD rc; + + if (lpImeParentMenu) + parent = &lpImeParentMenuA; + if (lpImeMenu) + { + int count = dwSize / sizeof(LPIMEMENUITEMINFOW); + dwSize = count * sizeof(IMEMENUITEMINFOA); + lpImeMenuA = HeapAlloc(GetProcessHeap(), 0, dwSize); + } + else + lpImeMenuA = NULL; + + rc = data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, + (IMEMENUITEMINFOW*)parent, + (IMEMENUITEMINFOW*)lpImeMenuA, dwSize); + + if (lpImeParentMenu) + { + memcpy(lpImeParentMenu,&lpImeParentMenuA,sizeof(IMEMENUITEMINFOA)); + lpImeParentMenu->hbmpItem = lpImeParentMenuA.hbmpItem; + MultiByteToWideChar(CP_ACP, 0, lpImeParentMenuA.szString, + -1, lpImeParentMenu->szString, IMEMENUITEM_STRING_SIZE); + } + if (lpImeMenu && rc) + { + unsigned int i; + for (i = 0; i < rc; i++) + { + memcpy(&lpImeMenu[i],&lpImeMenuA[1],sizeof(IMEMENUITEMINFOA)); + lpImeMenu[i].hbmpItem = lpImeMenuA[i].hbmpItem; + MultiByteToWideChar(CP_ACP, 0, lpImeMenuA[i].szString, + -1, lpImeMenu[i].szString, IMEMENUITEM_STRING_SIZE); + } + } + HeapFree(GetProcessHeap(),0,lpImeMenuA); + return rc; + } + } + else + return 0; } /*********************************************************************** @@ -2142,7 +2573,7 @@ DWORD WINAPI ImmGetImeMenuItemsW( HIMC hIMC, DWORD dwFlags, DWORD dwType, */ LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; if (!data) return NULL; @@ -2155,7 +2586,7 @@ LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC) */ BOOL WINAPI ImmUnlockIMC(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; data->dwLock--; return (data->dwLock!=0); } @@ -2165,7 +2596,7 @@ BOOL WINAPI ImmUnlockIMC(HIMC hIMC) */ DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; return data->dwLock; } @@ -2182,7 +2613,7 @@ HIMCC WINAPI ImmCreateIMCC(DWORD size) return NULL; internal->dwSize = size; - return (HIMCC)internal; + return internal; } /*********************************************************************** @@ -2200,7 +2631,7 @@ HIMCC WINAPI ImmDestroyIMCC(HIMCC block) LPVOID WINAPI ImmLockIMCC(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; internal->dwLock ++; return internal + 1; @@ -2212,7 +2643,7 @@ LPVOID WINAPI ImmLockIMCC(HIMCC imcc) BOOL WINAPI ImmUnlockIMCC(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; internal->dwLock --; return (internal->dwLock!=0); @@ -2224,7 +2655,7 @@ BOOL WINAPI ImmUnlockIMCC(HIMCC imcc) DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; return internal->dwLock; } @@ -2237,7 +2668,7 @@ HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size) IMCCInternal *internal,*newone; int real_size = size + sizeof(IMCCInternal); - internal = (IMCCInternal*) imcc; + internal = imcc; newone = HeapReAlloc(GetProcessHeap(), 0, internal, real_size); newone->dwSize = size; @@ -2251,7 +2682,7 @@ HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size) DWORD WINAPI ImmGetIMCCSize(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; return internal->dwSize; } @@ -2261,15 +2692,15 @@ DWORD WINAPI ImmGetIMCCSize(HIMCC imcc) */ BOOL WINAPI ImmGenerateMessage(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%i messages queued\n",data->IMC.dwNumMsgBuf); if (data->IMC.dwNumMsgBuf > 0) { LPTRANSMSG lpTransMsg; - INT i; + DWORD i; - lpTransMsg = (LPTRANSMSG)ImmLockIMCC(data->IMC.hMsgBuf); + lpTransMsg = ImmLockIMCC(data->IMC.hMsgBuf); for (i = 0; i < data->IMC.dwNumMsgBuf; i++) ImmInternalPostIMEMessage(data, lpTransMsg[i].message, lpTransMsg[i].wParam, lpTransMsg[i].lParam); @@ -2281,252 +2712,106 @@ BOOL WINAPI ImmGenerateMessage(HIMC hIMC) return TRUE; } -/***** - * Internal functions to help with IME window management - */ -static void PaintDefaultIMEWnd(HWND hwnd) +/*********************************************************************** +* ImmTranslateMessage(IMM32.@) +* ( Undocumented, call internally and from user32.dll ) +*/ +BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lKeyData) { - PAINTSTRUCT ps; - RECT rect; - HDC hdc = BeginPaint(hwnd,&ps); - LPCOMPOSITIONSTRING compstr; - LPBYTE compdata = NULL; - HMONITOR monitor; - MONITORINFO mon_info; - INT offX=0, offY=0; + InputContextData *data; + HIMC imc = ImmGetContext(hwnd); + BYTE state[256]; + UINT scancode; + LPVOID list = 0; + UINT msg_count; + UINT uVirtKey; + static const DWORD list_count = 10; - GetClientRect(hwnd,&rect); - FillRect(hdc, &rect, (HBRUSH)(COLOR_WINDOW + 1)); + TRACE("%p %x %x %x\n",hwnd, msg, (UINT)wParam, (UINT)lKeyData); - compdata = ImmLockIMCC(root_context->IMC.hCompStr); - compstr = (LPCOMPOSITIONSTRING)compdata; - - if (compstr->dwCompStrLen && compstr->dwCompStrOffset) - { - SIZE size; - POINT pt; - HFONT oldfont = NULL; - LPWSTR CompString; - - CompString = (LPWSTR)(compdata + compstr->dwCompStrOffset); - if (root_context->textfont) - oldfont = SelectObject(hdc,root_context->textfont); - - - GetTextExtentPoint32W(hdc, CompString, compstr->dwCompStrLen, &size); - pt.x = size.cx; - pt.y = size.cy; - LPtoDP(hdc,&pt,1); - - /* - * How this works based on tests on windows: - * CFS_POINT: then we start our window at the point and grow it as large - * as it needs to be for the string. - * CFS_RECT: we still use the ptCurrentPos as a starting point and our - * window is only as large as we need for the string, but we do not - * grow such that our window exceeds the given rect. Wrapping if - * needed and possible. If our ptCurrentPos is outside of our rect - * then no window is displayed. - * CFS_FORCE_POSITION: appears to behave just like CFS_POINT - * maybe becase the default MSIME does not do any IME adjusting. - */ - if (root_context->IMC.cfCompForm.dwStyle != CFS_DEFAULT) - { - POINT cpt = root_context->IMC.cfCompForm.ptCurrentPos; - ClientToScreen(root_context->IMC.hWnd,&cpt); - rect.left = cpt.x; - rect.top = cpt.y; - rect.right = rect.left + pt.x; - rect.bottom = rect.top + pt.y; - monitor = MonitorFromPoint(cpt, MONITOR_DEFAULTTOPRIMARY); - } - else /* CFS_DEFAULT */ - { - /* Windows places the default IME window in the bottom left */ - HWND target = root_context->IMC.hWnd; - if (!target) target = GetFocus(); - - GetWindowRect(target,&rect); - rect.top = rect.bottom; - rect.right = rect.left + pt.x + 20; - rect.bottom = rect.top + pt.y + 20; - offX=offY=10; - monitor = MonitorFromWindow(target, MONITOR_DEFAULTTOPRIMARY); - } - - if (root_context->IMC.cfCompForm.dwStyle == CFS_RECT) - { - RECT client; - client =root_context->IMC.cfCompForm.rcArea; - MapWindowPoints( root_context->IMC.hWnd, 0, (POINT *)&client, 2 ); - IntersectRect(&rect,&rect,&client); - /* TODO: Wrap the input if needed */ - } - - if (root_context->IMC.cfCompForm.dwStyle == CFS_DEFAULT) - { - /* make sure we are on the desktop */ - mon_info.cbSize = sizeof(mon_info); - GetMonitorInfoW(monitor, &mon_info); - - if (rect.bottom > mon_info.rcWork.bottom) - { - int shift = rect.bottom - mon_info.rcWork.bottom; - rect.top -= shift; - rect.bottom -= shift; - } - if (rect.left < 0) - { - rect.right -= rect.left; - rect.left = 0; - } - if (rect.right > mon_info.rcWork.right) - { - int shift = rect.right - mon_info.rcWork.right; - rect.left -= shift; - rect.right -= shift; - } - } - - SetWindowPos(hwnd, HWND_TOPMOST, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE); - - TextOutW(hdc, offX,offY, CompString, compstr->dwCompStrLen); - - if (oldfont) - SelectObject(hdc,oldfont); - } - - ImmUnlockIMCC(root_context->IMC.hCompStr); - - EndPaint(hwnd,&ps); -} - -static void UpdateDataInDefaultIMEWindow(HWND hwnd, BOOL showable) -{ - LPCOMPOSITIONSTRING compstr; - - if (root_context->IMC.hCompStr) - compstr = ImmLockIMCC(root_context->IMC.hCompStr); + if (imc) + data = imc; else - compstr = NULL; + return FALSE; - if (compstr == NULL || compstr->dwCompStrLen == 0) - ShowWindow(hwndDefault,SW_HIDE); - else if (showable) - ShowWindow(hwndDefault,SW_SHOWNOACTIVATE); + if (!data->immKbd->hIME || !data->immKbd->pImeToAsciiEx) + return FALSE; - RedrawWindow(hwnd,NULL,NULL,RDW_ERASENOW|RDW_INVALIDATE); + GetKeyboardState(state); + scancode = lKeyData >> 0x10 & 0xff; - if (compstr != NULL) - ImmUnlockIMCC(root_context->IMC.hCompStr); + list = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, list_count * sizeof(TRANSMSG) + sizeof(DWORD)); + ((DWORD*)list)[0] = list_count; + + if (data->immKbd->imeInfo.fdwProperty & IME_PROP_KBD_CHAR_FIRST) + { + WCHAR chr; + + if (!is_himc_ime_unicode(data)) + ToAscii(data->lastVK, scancode, state, &chr, 0); + else + ToUnicodeEx(data->lastVK, scancode, state, &chr, 1, 0, GetKeyboardLayout(0)); + uVirtKey = MAKELONG(data->lastVK,chr); + } + else + uVirtKey = data->lastVK; + + msg_count = data->immKbd->pImeToAsciiEx(uVirtKey, scancode, state, list, 0, imc); + TRACE("%i messages generated\n",msg_count); + if (msg_count && msg_count <= list_count) + { + UINT i; + LPTRANSMSG msgs = (LPTRANSMSG)((LPBYTE)list + sizeof(DWORD)); + + for (i = 0; i < msg_count; i++) + ImmInternalPostIMEMessage(data, msgs[i].message, msgs[i].wParam, msgs[i].lParam); + } + else if (msg_count > list_count) + ImmGenerateMessage(imc); + + HeapFree(GetProcessHeap(),0,list); + + data->lastVK = VK_PROCESSKEY; + + return (msg_count > 0); } -/* - * The window proc for the default IME window - */ -static LRESULT WINAPI IME_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) +/*********************************************************************** +* ImmProcessKey(IMM32.@) +* ( Undocumented, called from user32.dll ) +*/ +BOOL WINAPI ImmProcessKey(HWND hwnd, HKL hKL, UINT vKey, LPARAM lKeyData, DWORD unknown) { - LRESULT rc = 0; + InputContextData *data; + HIMC imc = ImmGetContext(hwnd); + BYTE state[256]; - TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", msg, (UINT)wParam, - (UINT)lParam); + TRACE("%p %p %x %x %x\n",hwnd, hKL, vKey, (UINT)lKeyData, unknown); - switch(msg) - { - case WM_PAINT: - PaintDefaultIMEWnd(hwnd); - return FALSE; + if (imc) + data = imc; + else + return FALSE; - case WM_NCCREATE: - return TRUE; + if (!data->immKbd->hIME || !data->immKbd->pImeProcessKey) + return FALSE; - case WM_CREATE: - SetWindowTextA(hwnd,"Wine Ime Active"); - return TRUE; + GetKeyboardState(state); + if (data->immKbd->pImeProcessKey(imc, vKey, lKeyData, state)) + { + data->lastVK = vKey; + return TRUE; + } - case WM_SETFOCUS: - if (wParam) - SetFocus((HWND)wParam); - else - FIXME("Received focus, should never have focus\n"); - break; - case WM_IME_COMPOSITION: - TRACE("IME message %s, 0x%x, 0x%x (%i)\n", - "WM_IME_COMPOSITION", (UINT)wParam, (UINT)lParam, - root_context->bRead); - if (lParam & GCS_RESULTSTR) - IMM_PostResult(root_context); - else - UpdateDataInDefaultIMEWindow(hwnd,TRUE); - break; - case WM_IME_STARTCOMPOSITION: - TRACE("IME message %s, 0x%x, 0x%x\n", - "WM_IME_STARTCOMPOSITION", (UINT)wParam, (UINT)lParam); - root_context->IMC.hWnd = GetFocus(); - ShowWindow(hwndDefault,SW_SHOWNOACTIVATE); - break; - case WM_IME_ENDCOMPOSITION: - TRACE("IME message %s, 0x%x, 0x%x\n", - "WM_IME_ENDCOMPOSITION", (UINT)wParam, (UINT)lParam); - ShowWindow(hwndDefault,SW_HIDE); - break; - case WM_IME_SELECT: - TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_SELECT", - (UINT)wParam, (UINT)lParam); - break; - case WM_IME_CONTROL: - TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_CONTROL", - (UINT)wParam, (UINT)lParam); - rc = 1; - break; - case WM_IME_NOTIFY: - TRACE("!! IME NOTIFY\n"); - break; - default: - TRACE("Non-standard message 0x%x\n",msg); - } - /* check the MSIME messages */ - if (msg == WM_MSIME_SERVICE) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_SERVICE", - (UINT)wParam, (UINT)lParam); - rc = FALSE; - } - else if (msg == WM_MSIME_RECONVERTOPTIONS) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTOPTIONS", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_MOUSE) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_MOUSE", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_RECONVERTREQUEST) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTREQUEST", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_RECONVERT) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERT", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_QUERYPOSITION) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_QUERYPOSITION", - (UINT)wParam, (UINT)lParam); - } - else if (msg == WM_MSIME_DOCUMENTFEED) - { - TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_DOCUMENTFEED", - (UINT)wParam, (UINT)lParam); - } - /* DefWndProc if not an IME message */ - else if (!rc && !((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) || - (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP))) - rc = DefWindowProcW(hwnd,msg,wParam,lParam); - - return rc; + data->lastVK = VK_PROCESSKEY; + return FALSE; +} + +/*********************************************************************** +* ImmDisableTextFrameService(IMM32.@) +*/ +BOOL WINAPI ImmDisableTextFrameService(DWORD idThread) +{ + FIXME("Stub\n"); + return FALSE; } diff --git a/dll/win32/imm32/imm32.spec b/dll/win32/imm32/imm32.spec index 0ecd1f93fa8..0d053627d50 100644 --- a/dll/win32/imm32/imm32.spec +++ b/dll/win32/imm32/imm32.spec @@ -5,12 +5,13 @@ @ stdcall ImmConfigureIMEW(long long long ptr) @ stdcall ImmCreateContext() @ stdcall ImmCreateIMCC(long) -@ stub ImmCreateSoftKeyboard +@ stdcall ImmCreateSoftKeyboard(long long long long) @ stdcall ImmDestroyContext(long) @ stdcall ImmDestroyIMCC(long) -@ stub ImmDestroySoftKeyboard +@ stdcall ImmDestroySoftKeyboard(long) @ stdcall ImmDisableIME(long) @ stdcall ImmDisableIme(long) ImmDisableIME +@ stdcall ImmDisableTextFrameService(long) @ stub ImmEnumInputContext @ stdcall ImmEnumRegisterWordA(long ptr str long str ptr) @ stdcall ImmEnumRegisterWordW(long ptr wstr long wstr ptr) @@ -72,15 +73,15 @@ @ stub ImmLockImeDpi @ stdcall ImmNotifyIME(long long long long) @ stub ImmPenAuxInput -@ stub ImmProcessKey +@ stdcall ImmProcessKey(long long long long long) @ stub ImmPutImeMenuItemsIntoMappedFile @ stdcall ImmReSizeIMCC(long long) @ stub ImmRegisterClient @ stdcall ImmRegisterWordA(long str long str) @ stdcall ImmRegisterWordW(long wstr long wstr) @ stdcall ImmReleaseContext(long long) -@ stub ImmRequestMessageA -@ stub ImmRequestMessageW +@ stdcall ImmRequestMessageA(ptr long long) +@ stdcall ImmRequestMessageW(ptr long long) @ stub ImmSendIMEMessageExA @ stub ImmSendIMEMessageExW @ stub ImmSendMessageToActiveDefImeWndW @@ -96,10 +97,10 @@ #@ stdcall ImmSetHotKey(long long long ptr) user32.CliImmSetHotKey @ stdcall ImmSetOpenStatus(long long) @ stdcall ImmSetStatusWindowPos(long ptr) -@ stub ImmShowSoftKeyboard +@ stdcall ImmShowSoftKeyboard(long long) @ stdcall ImmSimulateHotKey(long long) @ stub ImmSystemHandler -@ stub ImmTranslateMessage +@ stdcall ImmTranslateMessage(long long long long) @ stub ImmUnlockClientImc @ stdcall ImmUnlockIMC(long) @ stdcall ImmUnlockIMCC(long) diff --git a/dll/win32/inetcomm/inetcomm_main.c b/dll/win32/inetcomm/inetcomm_main.c index 22f19197488..dac1a5c069d 100644 --- a/dll/win32/inetcomm/inetcomm_main.c +++ b/dll/win32/inetcomm/inetcomm_main.c @@ -197,6 +197,5 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) */ HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("\n"); return S_FALSE; } diff --git a/dll/win32/inetmib1/main.c b/dll/win32/inetmib1/main.c index b0ff812dd7c..9aef4d5c5dc 100644 --- a/dll/win32/inetmib1/main.c +++ b/dll/win32/inetmib1/main.c @@ -32,10 +32,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(inetmib1); /** * Utility functions */ -static void copyInt(AsnAny *value, void *src) +static DWORD copyInt(AsnAny *value, void *src) { value->asnType = ASN_INTEGER; value->asnValue.number = *(DWORD *)src; + return SNMP_ERRORSTATUS_NOERROR; } static void setStringValue(AsnAny *value, BYTE type, DWORD len, BYTE *str) @@ -45,18 +46,11 @@ static void setStringValue(AsnAny *value, BYTE type, DWORD len, BYTE *str) strValue.asnType = type; strValue.asnValue.string.stream = str; strValue.asnValue.string.length = len; - strValue.asnValue.string.dynamic = TRUE; + strValue.asnValue.string.dynamic = FALSE; SnmpUtilAsnAnyCpy(value, &strValue); } -static void copyLengthPrecededString(AsnAny *value, void *src) -{ - DWORD len = *(DWORD *)src; - - setStringValue(value, ASN_OCTETSTRING, len, (BYTE *)src + sizeof(DWORD)); -} - -typedef void (*copyValueFunc)(AsnAny *value, void *src); +typedef DWORD (*copyValueFunc)(AsnAny *value, void *src); struct structToAsnValue { @@ -75,13 +69,13 @@ static AsnInteger32 mapStructEntryToValue(struct structToAsnValue *map, return SNMP_ERRORSTATUS_NOSUCHNAME; if (!map[id].copy) return SNMP_ERRORSTATUS_NOSUCHNAME; - map[id].copy(&pVarBind->value, (BYTE *)record + map[id].offset); - return SNMP_ERRORSTATUS_NOERROR; + return map[id].copy(&pVarBind->value, (BYTE *)record + map[id].offset); } -static void copyIpAddr(AsnAny *value, void *src) +static DWORD copyIpAddr(AsnAny *value, void *src) { setStringValue(value, ASN_IPADDRESS, sizeof(DWORD), src); + return SNMP_ERRORSTATUS_NOERROR; } static UINT mib2[] = { 1,3,6,1,2,1 }; @@ -168,7 +162,7 @@ static BOOL mib2IfNumberQuery(BYTE bPduType, SnmpVarBind *pVarBind, return ret; } -static void copyOperStatus(AsnAny *value, void *src) +static DWORD copyOperStatus(AsnAny *value, void *src) { value->asnType = ASN_INTEGER; /* The IPHlpApi definition of operational status differs from the MIB2 one, @@ -186,6 +180,7 @@ static void copyOperStatus(AsnAny *value, void *src) default: value->asnValue.number = MIB_IF_ADMIN_STATUS_DOWN; }; + return SNMP_ERRORSTATUS_NOERROR; } /* Given an OID and a base OID that it must begin with, finds the item and @@ -393,7 +388,7 @@ static UINT findNextOidInTable(AsnObjectIdentifier *oid, * an infinite loop. */ for (++index; index <= table->numEntries && compare(key, - &table->entries[tableEntrySize * index]) == 0; ++index) + &table->entries[tableEntrySize * (index - 1)]) == 0; ++index) ; } HeapFree(GetProcessHeap(), 0, key); @@ -550,13 +545,46 @@ static INT setOidWithItemAndInteger(AsnObjectIdentifier *dst, return ret; } +static DWORD copyIfRowDescr(AsnAny *value, void *src) +{ + PMIB_IFROW row = (PMIB_IFROW)((BYTE *)src - + FIELD_OFFSET(MIB_IFROW, dwDescrLen)); + DWORD ret; + + if (row->dwDescrLen) + { + setStringValue(value, ASN_OCTETSTRING, row->dwDescrLen, row->bDescr); + ret = SNMP_ERRORSTATUS_NOERROR; + } + else + ret = SNMP_ERRORSTATUS_NOSUCHNAME; + return ret; +} + +static DWORD copyIfRowPhysAddr(AsnAny *value, void *src) +{ + PMIB_IFROW row = (PMIB_IFROW)((BYTE *)src - + FIELD_OFFSET(MIB_IFROW, dwPhysAddrLen)); + DWORD ret; + + if (row->dwPhysAddrLen) + { + setStringValue(value, ASN_OCTETSTRING, row->dwPhysAddrLen, + row->bPhysAddr); + ret = SNMP_ERRORSTATUS_NOERROR; + } + else + ret = SNMP_ERRORSTATUS_NOSUCHNAME; + return ret; +} + static struct structToAsnValue mib2IfEntryMap[] = { { FIELD_OFFSET(MIB_IFROW, dwIndex), copyInt }, - { FIELD_OFFSET(MIB_IFROW, dwDescrLen), copyLengthPrecededString }, + { FIELD_OFFSET(MIB_IFROW, dwDescrLen), copyIfRowDescr }, { FIELD_OFFSET(MIB_IFROW, dwType), copyInt }, { FIELD_OFFSET(MIB_IFROW, dwMtu), copyInt }, { FIELD_OFFSET(MIB_IFROW, dwSpeed), copyInt }, - { FIELD_OFFSET(MIB_IFROW, dwPhysAddrLen), copyLengthPrecededString }, + { FIELD_OFFSET(MIB_IFROW, dwPhysAddrLen), copyIfRowPhysAddr }, { FIELD_OFFSET(MIB_IFROW, dwAdminStatus), copyInt }, { FIELD_OFFSET(MIB_IFROW, dwOperStatus), copyOperStatus }, { FIELD_OFFSET(MIB_IFROW, dwLastChange), copyInt }, @@ -883,9 +911,18 @@ static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind, static UINT mib2IpNet[] = { 1,3,6,1,2,1,4,22,1 }; static PMIB_IPNETTABLE ipNetTable; +static DWORD copyIpNetPhysAddr(AsnAny *value, void *src) +{ + PMIB_IPNETROW row = (PMIB_IPNETROW)((BYTE *)src - FIELD_OFFSET(MIB_IPNETROW, + dwPhysAddrLen)); + + setStringValue(value, ASN_OCTETSTRING, row->dwPhysAddrLen, row->bPhysAddr); + return SNMP_ERRORSTATUS_NOERROR; +} + static struct structToAsnValue mib2IpNetMap[] = { { FIELD_OFFSET(MIB_IPNETROW, dwIndex), copyInt }, - { FIELD_OFFSET(MIB_IPNETROW, dwPhysAddrLen), copyLengthPrecededString }, + { FIELD_OFFSET(MIB_IPNETROW, dwPhysAddrLen), copyIpNetPhysAddr }, { FIELD_OFFSET(MIB_IPNETROW, dwAddr), copyIpAddr }, { FIELD_OFFSET(MIB_IPNETROW, dwType), copyInt }, }; diff --git a/dll/win32/iphlpapi/iphlpapi.spec b/dll/win32/iphlpapi/iphlpapi.spec index 788666a6948..f65673b601f 100644 --- a/dll/win32/iphlpapi/iphlpapi.spec +++ b/dll/win32/iphlpapi/iphlpapi.spec @@ -32,7 +32,7 @@ @ stub GetBestInterfaceFromStack @ stdcall GetBestRoute( long long long ) @ stub GetBestRouteFromStack -@ stub GetExtendedTcpTable +@ stdcall GetExtendedTcpTable( ptr ptr long long long long ) @ stub GetExtendedUdpTable @ stdcall GetFriendlyIfIndex( long ) @ stdcall GetIcmpStatistics( ptr ) @@ -61,7 +61,7 @@ @ stdcall GetNetworkParams( ptr ptr ) @ stdcall GetNumberOfInterfaces( ptr ) @ stub GetOwnerModuleFromTcp6Entry -@ stub GetOwnerModuleFromTcpEntry +@ stdcall GetOwnerModuleFromTcpEntry ( ptr long ptr ptr ) @ stub GetOwnerModuleFromUdp6Entry @ stub GetOwnerModuleFromUdpEntry @ stdcall GetPerAdapterInfo( long ptr ptr ) diff --git a/dll/win32/iphlpapi/iphlpapi_main.c b/dll/win32/iphlpapi/iphlpapi_main.c index 6d27ce66e80..0bc146b6616 100644 --- a/dll/win32/iphlpapi/iphlpapi_main.c +++ b/dll/win32/iphlpapi/iphlpapi_main.c @@ -789,6 +789,32 @@ DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDRO return ret; } +/****************************************************************** + * GetExtendedTcpTable (IPHLPAPI.@) + * + * Get the table of TCP endpoints available to the application. + * + * PARAMS + * pTcpTable [Out] table struct with the filtered TCP endpoints available to application + * pdwSize [In/Out] estimated size of the structure returned in pTcpTable, in bytes + * bOrder [In] whether to order the table + * ulAf [in] version of IP used by the TCP endpoints + * TableClass [in] type of the TCP table structure from TCP_TABLE_CLASS + * Reserved [in] reserved - this value must be zero + * + * RETURNS + * Success: NO_ERROR + * Failure: either ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER + * + * NOTES + */ +DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved) +{ + DWORD ret = NO_ERROR; + UNIMPLEMENTED; + return ret; +} + /****************************************************************** * GetFriendlyIfIndex (IPHLPAPI.@) @@ -1479,6 +1505,33 @@ DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf) } +/****************************************************************** + * GetOwnerModuleFromTcpEntry (IPHLPAPI.@) + * + * Get data about the module that issued the context bind for a specific IPv4 TCP endpoint in a MIB table row + * + * PARAMS + * pTcpEntry [in] pointer to a MIB_TCPROW_OWNER_MODULE structure + * Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value + * Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data. + * pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes + * + * RETURNS + * Success: NO_ERROR + * Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY + * ERROR_NOT_FOUND or ERROR_PARTIAL_COPY + * + * NOTES + * The type of data returned in Buffer is indicated by the value of the Class parameter. + */ +DWORD WINAPI GetOwnerModuleFromTcpEntry( PMIB_TCPROW_OWNER_MODULE pTcpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize) +{ + DWORD ret = NO_ERROR; + UNIMPLEMENTED; + return ret; +} + + /****************************************************************** * GetPerAdapterInfo (IPHLPAPI.@) * diff --git a/dll/win32/itircl/itircl_main.c b/dll/win32/itircl/itircl_main.c index b8d57517a35..e2f1ed35035 100644 --- a/dll/win32/itircl/itircl_main.c +++ b/dll/win32/itircl/itircl_main.c @@ -71,6 +71,5 @@ HRESULT WINAPI DllUnregisterServer(void) */ HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("stub\n"); return S_FALSE; } diff --git a/dll/win32/itss/chm_lib.c b/dll/win32/itss/chm_lib.c index a98c8ac6cac..ada9be118a8 100644 --- a/dll/win32/itss/chm_lib.c +++ b/dll/win32/itss/chm_lib.c @@ -829,6 +829,38 @@ struct chmFile *chm_openW(const WCHAR *filename) return newHandle; } +/* Duplicate an ITS archive handle */ +struct chmFile *chm_dup(struct chmFile *oldHandle) +{ + struct chmFile *newHandle=NULL; + + newHandle = HeapAlloc(GetProcessHeap(), 0, sizeof(struct chmFile)); + memcpy(newHandle, oldHandle, sizeof(struct chmFile)); + + /* duplicate fd handle */ + DuplicateHandle(GetCurrentProcess(), oldHandle->fd, + GetCurrentProcess(), &(newHandle->fd), + 0, FALSE, DUPLICATE_SAME_ACCESS); + newHandle->lzx_state = NULL; + newHandle->cache_blocks = NULL; + newHandle->cache_block_indices = NULL; + newHandle->cache_num_blocks = 0; + + /* initialize mutexes, if needed */ + InitializeCriticalSection(&newHandle->mutex); + newHandle->mutex.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": chmFile.mutex"); + InitializeCriticalSection(&newHandle->lzx_mutex); + newHandle->lzx_mutex.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": chmFile.lzx_mutex"); + InitializeCriticalSection(&newHandle->cache_mutex); + newHandle->cache_mutex.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": chmFile.cache_mutex"); + + /* initialize cache */ + chm_set_param(newHandle, CHM_PARAM_MAX_BLOCKS_CACHED, + CHM_MAX_BLOCKS_CACHED); + + return newHandle; +} + /* close an ITS archive */ void chm_close(struct chmFile *h) { diff --git a/dll/win32/itss/chm_lib.h b/dll/win32/itss/chm_lib.h index 564df5a1cc5..7a064172adf 100644 --- a/dll/win32/itss/chm_lib.h +++ b/dll/win32/itss/chm_lib.h @@ -73,6 +73,7 @@ struct chmUnitInfo }; struct chmFile* chm_openW(const WCHAR *filename); +struct chmFile *chm_dup(struct chmFile *oldHandle); /* close an ITS archive */ void chm_close(struct chmFile *h); diff --git a/dll/win32/itss/itss.inf b/dll/win32/itss/itss.inf index eeefbbb93bc..fcad4d1ae2f 100644 --- a/dll/win32/itss/itss.inf +++ b/dll/win32/itss/itss.inf @@ -16,7 +16,7 @@ DelReg=Classes.Reg, Misc.Reg HKCR,"CLSID\%CLSID_ITStorage%",,,"Microsoft InfoTech IStorage System" HKCR,"CLSID\%CLSID_ITStorage%\InProcServer32",,,"itss.dll" HKCR,"CLSID\%CLSID_ITStorage%\InProcServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_ITStorage%\NotInsertable",,,"" +HKCR,"CLSID\%CLSID_ITStorage%\NotInsertable",,16 HKCR,"CLSID\%CLSID_ITStorage%\ProgID",,,"MSITFS1.0" HKCR,"CLSID\%CLSID_ITStorage%\VersionIndependentProgID",,,"MSITFS" @@ -28,7 +28,7 @@ HKCR,"MSITFS\CurVer",,,"MSITFS1.0" HKCR,"CLSID\%CLSID_MSITStore%",,,"Microsoft InfoTech Protocol for IE 3.0" HKCR,"CLSID\%CLSID_MSITStore%\InProcServer32",,,"itss.dll" HKCR,"CLSID\%CLSID_MSITStore%\InProcServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_MSITStore%\NotInsertable",,,"" +HKCR,"CLSID\%CLSID_MSITStore%\NotInsertable",,16 HKCR,"CLSID\%CLSID_MSITStore%\ProgID",,,"MSITFS1.0" HKCR,"CLSID\%CLSID_MSITStore%\VersionIndependentProgID",,,"MSITFS" @@ -41,9 +41,9 @@ HKCR,"MSITStore\CurVer",,,"MSITStore1.0" HKCR,"CLSID\%CLSID_ITSProtocol%",,,"Microsoft InfoTech Protocol for IE 4.0" HKCR,"CLSID\%CLSID_ITSProtocol%\InProcServer32",,,"itss.dll" HKCR,"CLSID\%CLSID_ITSProtocol%\InProcServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_ITSProtocol%\NotInsertable",,,"" +HKCR,"CLSID\%CLSID_ITSProtocol%\NotInsertable",,16 HKCR,"CLSID\%CLSID_ITSProtocol%\ProgID",,,"MSITFS1.0" -HKCR,"CLSID\%CLSID_ITSProtocol%%\VersionIndependentProgID",,,"MSITFS" +HKCR,"CLSID\%CLSID_ITSProtocol%\VersionIndependentProgID",,,"MSITFS" HKCR,"ITSProtocol","Microsoft InfoTech Protocols for IE 4.0" HKCR,"ITSProtocol\CLSID",,,"%CLSID_ITSProtocol%" @@ -54,7 +54,7 @@ HKCR,"ITSProtocol\CurVer",,,"ITSProtocol1.0" HKCR,"CLSID\%CLSID_MSFSStore%",,,"Microsoft InfoTech IStorage for Win32 Files" HKCR,"CLSID\%CLSID_MSFSStore%\InProcServer32",,,"itss.dll" HKCR,"CLSID\%CLSID_MSFSStore%\InProcServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_MSFSStore%\NotInsertable",,,"" +HKCR,"CLSID\%CLSID_MSFSStore%\NotInsertable",,16 HKCR,"CLSID\%CLSID_MSFSStore%\ProgID",,,"MSITFS1.0" HKCR,"CLSID\%CLSID_MSFSStore%\VersionIndependentProgID",,,"MSITFS" diff --git a/dll/win32/itss/storage.c b/dll/win32/itss/storage.c index de0acfaee3e..79c863a4bc2 100644 --- a/dll/win32/itss/storage.c +++ b/dll/win32/itss/storage.c @@ -391,10 +391,43 @@ static HRESULT WINAPI ITSS_IStorageImpl_OpenStorage( IStorage** ppstg) { ITSS_IStorageImpl *This = (ITSS_IStorageImpl *)iface; + static const WCHAR szRoot[] = { '/', 0 }; + struct chmFile *chmfile; + WCHAR *path, *p; + DWORD len; - FIXME("%p %s %p %u %p %u %p\n", This, debugstr_w(pwcsName), + TRACE("%p %s %p %u %p %u %p\n", This, debugstr_w(pwcsName), pstgPriority, grfMode, snbExclude, reserved, ppstg); - return E_NOTIMPL; + + chmfile = chm_dup( This->chmfile ); + if( !chmfile ) + return E_FAIL; + + len = strlenW( This->dir ) + strlenW( pwcsName ) + 1; + path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + strcpyW( path, This->dir ); + + if( pwcsName[0] == '/' || pwcsName[0] == '\\' ) + { + p = &path[strlenW( path ) - 1]; + while( ( path <= p ) && ( *p == '/' ) ) + *p-- = 0; + } + strcatW( path, pwcsName ); + + for(p=path; *p; p++) { + if(*p == '\\') + *p = '/'; + } + + if(*--p == '/') + *p = 0; + + strcatW( path, szRoot ); + + TRACE("Resolving %s\n", debugstr_w(path)); + + return ITSS_create_chm_storage(chmfile, path, ppstg); } static HRESULT WINAPI ITSS_IStorageImpl_CopyTo( diff --git a/dll/win32/jscript/activex.c b/dll/win32/jscript/activex.c index cb94d4e5f34..947e4cfd289 100644 --- a/dll/win32/jscript/activex.c +++ b/dll/win32/jscript/activex.c @@ -86,7 +86,7 @@ static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid) if(FAILED(hres) || policy != URLPOLICY_ALLOW) return NULL; - hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, NULL, &IID_IClassFactory, (void**)&cf); + hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void**)&cf); if(FAILED(hres)) return NULL; @@ -192,7 +192,8 @@ HRESULT create_activex_constr(script_ctx_t *ctx, DispatchEx **ret) if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, ActiveXObject_value, ActiveXObjectW, NULL, PROPF_CONSTR, prototype, ret); + hres = create_builtin_function(ctx, ActiveXObject_value, ActiveXObjectW, NULL, + PROPF_CONSTR|1, prototype, ret); jsdisp_release(prototype); return hres; diff --git a/dll/win32/jscript/array.c b/dll/win32/jscript/array.c index 941e414567b..1268d59638b 100644 --- a/dll/win32/jscript/array.c +++ b/dll/win32/jscript/array.c @@ -166,7 +166,7 @@ static HRESULT concat_array(DispatchEx *array, ArrayInstance *obj, DWORD *len, HRESULT hres; for(i=0; i < obj->length; i++) { - hres = jsdisp_propget_idx(&obj->dispex, i, &var, ei, caller); + hres = jsdisp_get_idx(&obj->dispex, i, &var, ei, caller); if(hres == DISP_E_UNKNOWNNAME) continue; if(FAILED(hres)) @@ -267,8 +267,11 @@ static HRESULT array_join(script_ctx_t *ctx, DispatchEx *array, DWORD length, co return E_OUTOFMEMORY; for(i=0; i < length; i++) { - hres = jsdisp_propget_idx(array, i, &var, ei, caller); - if(FAILED(hres)) + hres = jsdisp_get_idx(array, i, &var, ei, caller); + if(hres == DISP_E_UNKNOWNNAME) { + hres = S_OK; + continue; + } else if(FAILED(hres)) break; if(V_VT(&var) != VT_EMPTY && V_VT(&var) != VT_NULL) @@ -342,20 +345,18 @@ static HRESULT array_join(script_ctx_t *ctx, DispatchEx *array, DWORD length, co } /* ECMA-262 3rd Edition 15.4.4.5 */ -static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, +static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { + DispatchEx *jsthis; DWORD length; HRESULT hres; TRACE("\n"); - if(is_vclass(jsthis, JSCLASS_ARRAY)) { - length = array_from_vdisp(jsthis)->length; - }else { - FIXME("dispid is not Array\n"); - return E_NOTIMPL; - } + hres = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres)) + return hres; if(arg_cnt(dp)) { BSTR sep; @@ -364,62 +365,52 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA if(FAILED(hres)) return hres; - hres = array_join(ctx, jsthis->u.jsdisp, length, sep, retv, ei, caller); + hres = array_join(ctx, jsthis, length, sep, retv, ei, caller); SysFreeString(sep); }else { - hres = array_join(ctx, jsthis->u.jsdisp, length, default_separatorW, retv, ei, caller); + hres = array_join(ctx, jsthis, length, default_separatorW, retv, ei, caller); } return hres; } -static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, +static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { + DispatchEx *jsthis; VARIANT val; DWORD length; - WCHAR buf[14]; - DISPID id; HRESULT hres; - static const WCHAR formatW[] = {'%','d',0}; - TRACE("\n"); - if(is_vclass(jsthis, JSCLASS_ARRAY)) { - ArrayInstance *array = array_from_vdisp(jsthis); - length = array->length; - }else { - FIXME("not Array this\n"); - return E_NOTIMPL; - } + hres = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres)) + return hres; if(!length) { + hres = set_length(jsthis, ei, 0); + if(FAILED(hres)) + return hres; + if(retv) V_VT(retv) = VT_EMPTY; return S_OK; } - sprintfW(buf, formatW, --length); - hres = jsdisp_get_id(jsthis->u.jsdisp, buf, 0, &id); + length--; + hres = jsdisp_get_idx(jsthis, length, &val, ei, caller); if(SUCCEEDED(hres)) { - hres = jsdisp_propget(jsthis->u.jsdisp, id, &val, ei, caller); - if(FAILED(hres)) - return hres; - - hres = IDispatchEx_DeleteMemberByDispID(jsthis->u.dispex, id); - }else if(hres == DISP_E_UNKNOWNNAME) { + hres = jsdisp_delete_idx(jsthis, length); + } else if(hres == DISP_E_UNKNOWNNAME) { V_VT(&val) = VT_EMPTY; hres = S_OK; - }else { + } else return hres; - } - if(SUCCEEDED(hres)) { - ArrayInstance *array = array_from_vdisp(jsthis); - array->length = length; - } + if(SUCCEEDED(hres)) + hres = set_length(jsthis, ei, length); if(FAILED(hres)) { VariantClear(&val); @@ -430,6 +421,7 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR *retv = val; else VariantClear(&val); + return S_OK; } @@ -469,8 +461,59 @@ static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + DispatchEx *jsthis; + DWORD length, k, l; + VARIANT v1, v2; + HRESULT hres1, hres2; + + TRACE("\n"); + + hres1 = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres1)) + return hres1; + + for(k=0; klength; - }else { - FIXME("unsupported this not array\n"); - return E_NOTIMPL; - } + hres = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres)) + return hres; if(arg_cnt(dp) > 1) { WARN("invalid arg_cnt %d\n", arg_cnt(dp)); @@ -707,8 +749,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA jsdisp_release(cmp_func); if(retv) { V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = jsthis->u.disp; - IDispatch_AddRef(jsthis->u.disp); + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(jsthis); + IDispatch_AddRef(V_DISPATCH(retv)); } return S_OK; } @@ -716,8 +758,11 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA vtab = heap_alloc_zero(length * sizeof(VARIANT)); if(vtab) { for(i=0; iu.jsdisp, i, vtab+i, ei, caller); - if(FAILED(hres) && hres != DISP_E_UNKNOWNNAME) { + hres = jsdisp_get_idx(jsthis, i, vtab+i, ei, caller); + if(hres == DISP_E_UNKNOWNNAME) { + V_VT(vtab+i) = VT_EMPTY; + hres = S_OK; + } else if(FAILED(hres)) { WARN("Could not get elem %d: %08x\n", i, hres); break; } @@ -793,7 +838,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA } for(i=0; SUCCEEDED(hres) && i < length; i++) - hres = jsdisp_propput_idx(jsthis->u.jsdisp, i, sorttab[i], ei, caller); + hres = jsdisp_propput_idx(jsthis, i, sorttab[i], ei, caller); } if(vtab) { @@ -810,8 +855,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA if(retv) { V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = jsthis->u.disp; - IDispatch_AddRef(jsthis->u.disp); + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(jsthis); + IDispatch_AddRef(V_DISPATCH(retv)); } return S_OK; @@ -869,7 +914,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP return hres; for(i=0; SUCCEEDED(hres) && i < delete_cnt; i++) { - hres = jsdisp_propget_idx(jsthis, start+i, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, start+i, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = S_OK; else if(SUCCEEDED(hres)) @@ -886,7 +931,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP if(add_args < delete_cnt) { for(i = start; SUCCEEDED(hres) && i < length-delete_cnt; i++) { - hres = jsdisp_propget_idx(jsthis, i+delete_cnt, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, i+delete_cnt, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = jsdisp_delete_idx(jsthis, i+add_args); else if(SUCCEEDED(hres)) @@ -897,7 +942,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP hres = jsdisp_delete_idx(jsthis, i-1); }else if(add_args > delete_cnt) { for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) { - hres = jsdisp_propget_idx(jsthis, i+delete_cnt-1, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, i+delete_cnt-1, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = jsdisp_delete_idx(jsthis, i+add_args-1); else if(SUCCEEDED(hres)) @@ -967,29 +1012,25 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP return hres; argc = arg_cnt(dp); - if(!argc) { - if(retv) - V_VT(retv) = VT_EMPTY; - return S_OK; - } + if(argc) { + buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; + *buf_end-- = 0; + i = length; - buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; - *buf_end-- = 0; - i = length; + while(i--) { + str = idx_to_str(i, buf_end); - while(i--) { - str = idx_to_str(i, buf_end); + hres = jsdisp_get_id(jsthis, str, 0, &id); + if(SUCCEEDED(hres)) { + hres = jsdisp_propget(jsthis, id, &var, ei, caller); + if(FAILED(hres)) + return hres; - hres = jsdisp_get_id(jsthis, str, 0, &id); - if(SUCCEEDED(hres)) { - hres = jsdisp_propget(jsthis, id, &var, ei, caller); - if(FAILED(hres)) - return hres; - - hres = jsdisp_propput_idx(jsthis, i+argc, &var, ei, caller); - VariantClear(&var); - }else if(hres == DISP_E_UNKNOWNNAME) { - hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id); + hres = jsdisp_propput_idx(jsthis, i+argc, &var, ei, caller); + VariantClear(&var); + }else if(hres == DISP_E_UNKNOWNNAME) { + hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id); + } } if(FAILED(hres)) @@ -1002,12 +1043,21 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP return hres; } - hres = set_length(jsthis, ei, length+argc); - if(FAILED(hres)) - return hres; + if(argc) { + length += argc; + hres = set_length(jsthis, ei, length); + if(FAILED(hres)) + return hres; + } - if(retv) - V_VT(retv) = VT_EMPTY; + if(retv) { + if(ctx->version < 2) { + V_VT(retv) = VT_EMPTY; + }else { + V_VT(retv) = VT_I4; + V_I4(retv) = length; + } + } return S_OK; } @@ -1166,7 +1216,7 @@ HRESULT create_array_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Dis if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, ArrayConstr_value, ArrayW, NULL, PROPF_CONSTR, &array->dispex, ret); + hres = create_builtin_function(ctx, ArrayConstr_value, ArrayW, NULL, PROPF_CONSTR|1, &array->dispex, ret); jsdisp_release(&array->dispex); return hres; diff --git a/dll/win32/jscript/bool.c b/dll/win32/jscript/bool.c index 1fca406c184..4f23678a2e3 100644 --- a/dll/win32/jscript/bool.c +++ b/dll/win32/jscript/bool.c @@ -191,7 +191,8 @@ HRESULT create_bool_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Disp if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, BoolConstr_value, BooleanW, NULL, PROPF_CONSTR, &bool->dispex, ret); + hres = create_builtin_function(ctx, BoolConstr_value, BooleanW, NULL, + PROPF_CONSTR|1, &bool->dispex, ret); jsdisp_release(&bool->dispex); return hres; diff --git a/dll/win32/jscript/date.c b/dll/win32/jscript/date.c index f8d3522939b..71d37519fd7 100644 --- a/dll/win32/jscript/date.c +++ b/dll/win32/jscript/date.c @@ -2624,7 +2624,8 @@ HRESULT create_date_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Disp if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, DateConstr_value, DateW, &DateConstr_info, PROPF_CONSTR, date, ret); + hres = create_builtin_function(ctx, DateConstr_value, DateW, &DateConstr_info, + PROPF_CONSTR|7, date, ret); jsdisp_release(date); return hres; diff --git a/dll/win32/jscript/dispex.c b/dll/win32/jscript/dispex.c index 307efd97a22..6894eae0515 100644 --- a/dll/win32/jscript/dispex.c +++ b/dll/win32/jscript/dispex.c @@ -30,6 +30,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); static const IID IID_IDispatchJS = {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa6}}; +#define FDEX_VERSION_MASK 0xf0000000 + typedef enum { PROP_VARIANT, PROP_BUILTIN, @@ -158,7 +160,7 @@ static HRESULT find_prop_name(DispatchEx *This, const WCHAR *name, dispex_prop_t return S_OK; } -static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, BOOL alloc, dispex_prop_t **ret) +static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, dispex_prop_t **ret) { dispex_prop_t *prop; HRESULT hres; @@ -172,7 +174,7 @@ static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, BOOL all } if(This->prototype) { - hres = find_prop_name_prot(This->prototype, name, FALSE, &prop); + hres = find_prop_name_prot(This->prototype, name, &prop); if(FAILED(hres)) return hres; if(prop) { @@ -184,17 +186,30 @@ static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, BOOL all } } - if(alloc) { + *ret = prop; + return S_OK; +} + +static HRESULT ensure_prop_name(DispatchEx *This, const WCHAR *name, BOOL search_prot, DWORD create_flags, dispex_prop_t **ret) +{ + dispex_prop_t *prop; + HRESULT hres; + + if(search_prot) + hres = find_prop_name_prot(This, name, &prop); + else + hres = find_prop_name(This, name, &prop); + if(SUCCEEDED(hres) && !prop) { TRACE("creating prop %s\n", debugstr_w(name)); - prop = alloc_prop(This, name, PROP_VARIANT, PROPF_ENUM); + prop = alloc_prop(This, name, PROP_VARIANT, create_flags); if(!prop) return E_OUTOFMEMORY; VariantInit(&prop->u.var); } *ret = prop; - return S_OK; + return hres; } static HRESULT set_this(DISPPARAMS *dp, DISPPARAMS *olddp, IDispatch *jsthis) @@ -338,19 +353,19 @@ static HRESULT prop_get(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp, return hres; } -static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp, +static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) { - DWORD i; HRESULT hres; switch(prop->type) { case PROP_BUILTIN: if(!(prop->flags & PROPF_METHOD)) { + DISPPARAMS dp = {val, NULL, 1, 0}; vdisp_t vthis; set_jsdisp(&vthis, This); - hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, dp, NULL, ei, caller); + hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, &dp, NULL, ei, caller); vdisp_release(&vthis); return hres; } @@ -367,24 +382,14 @@ static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp, return E_FAIL; } - for(i=0; i < dp->cNamedArgs; i++) { - if(dp->rgdispidNamedArgs[i] == DISPID_PROPERTYPUT) - break; - } - - if(i == dp->cNamedArgs) { - TRACE("no value to set\n"); - return DISP_E_PARAMNOTOPTIONAL; - } - - hres = VariantCopy(&prop->u.var, dp->rgvarg+i); + hres = VariantCopy(&prop->u.var, val); if(FAILED(hres)) return hres; if(This->builtin_info->on_put) This->builtin_info->on_put(This, prop->name); - TRACE("%s = %s\n", debugstr_w(prop->name), debugstr_variant(dp->rgvarg+i)); + TRACE("%s = %s\n", debugstr_w(prop->name), debugstr_variant(val)); return S_OK; } @@ -471,6 +476,8 @@ static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface) } heap_free(This->props); script_release(This->ctx); + if(This->prototype) + jsdisp_release(This->prototype); if(This->builtin_info->destructor) This->builtin_info->destructor(This); @@ -538,7 +545,7 @@ static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DW TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid); - if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit)) { + if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit|FDEX_VERSION_MASK)) { FIXME("Unsupported grfdex %x\n", grfdex); return E_NOTIMPL; } @@ -575,9 +582,22 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc case DISPATCH_PROPERTYGET: hres = prop_get(This, prop, pdp, pvarRes, &jsexcept, pspCaller); break; - case DISPATCH_PROPERTYPUT: - hres = prop_put(This, prop, pdp, &jsexcept, pspCaller); + case DISPATCH_PROPERTYPUT: { + DWORD i; + + for(i=0; i < pdp->cNamedArgs; i++) { + if(pdp->rgdispidNamedArgs[i] == DISPID_PROPERTYPUT) + break; + } + + if(i == pdp->cNamedArgs) { + TRACE("no value to set\n"); + return DISP_E_PARAMNOTOPTIONAL; + } + + hres = prop_put(This, prop, pdp->rgvarg+i, &jsexcept, pspCaller); break; + } default: FIXME("Unimplemented flags %x\n", wFlags); return E_INVALIDARG; @@ -606,7 +626,7 @@ static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bst TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex); - if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit)) + if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit|FDEX_VERSION_MASK)) FIXME("Unsupported grfdex %x\n", grfdex); hres = find_prop_name(This, bstrName, &prop); @@ -783,9 +803,10 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui dispex_prop_t *prop; HRESULT hres; + static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r'}; static const WCHAR prototypeW[] = {'p','r','o','t','o','t','y','p','e',0}; - hres = find_prop_name_prot(constr, prototypeW, FALSE, &prop); + hres = find_prop_name_prot(constr, prototypeW, &prop); if(SUCCEEDED(hres) && prop) { jsexcept_t jsexcept; VARIANT var; @@ -807,6 +828,22 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui if(prot) jsdisp_release(prot); + if(FAILED(hres)) + return hres; + + hres = ensure_prop_name(dispex, constructorW, FALSE, 0, &prop); + if(SUCCEEDED(hres)) { + jsexcept_t jsexcept; + VARIANT var; + + V_VT(&var) = VT_DISPATCH; + V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(constr); + memset(&jsexcept, 0, sizeof(jsexcept)); + hres = prop_put(dispex, prop, &var, &jsexcept, NULL/*FIXME*/); + } + if(FAILED(hres)) + jsdisp_release(dispex); + return hres; } @@ -827,7 +864,10 @@ HRESULT jsdisp_get_id(DispatchEx *jsdisp, const WCHAR *name, DWORD flags, DISPID dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(jsdisp, name, (flags&fdexNameEnsure) != 0, &prop); + if(flags & fdexNameEnsure) + hres = ensure_prop_name(jsdisp, name, TRUE, PROPF_ENUM, &prop); + else + hres = find_prop_name_prot(jsdisp, name, &prop); if(FAILED(hres)) return hres; @@ -874,7 +914,7 @@ HRESULT jsdisp_call_name(DispatchEx *disp, const WCHAR *name, WORD flags, DISPPA dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(disp, name, TRUE, &prop); + hres = find_prop_name_prot(disp, name, &prop); if(FAILED(hres)) return hres; @@ -924,16 +964,14 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, DIS HRESULT jsdisp_propput_name(DispatchEx *obj, const WCHAR *name, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) { - DISPID named_arg = DISPID_PROPERTYPUT; - DISPPARAMS dp = {val, &named_arg, 1, 1}; dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(obj, name, TRUE, &prop); + hres = ensure_prop_name(obj, name, FALSE, PROPF_ENUM, &prop); if(FAILED(hres)) return hres; - return prop_put(obj, prop, &dp, ei, caller); + return prop_put(obj, prop, val, ei, caller); } HRESULT jsdisp_propput_idx(DispatchEx *obj, DWORD idx, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) @@ -948,9 +986,6 @@ HRESULT jsdisp_propput_idx(DispatchEx *obj, DWORD idx, VARIANT *val, jsexcept_t HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) { - DISPID dispid = DISPID_PROPERTYPUT; - DISPPARAMS dp = {val, &dispid, 1, 1}; - IDispatchEx *dispex; DispatchEx *jsdisp; HRESULT hres; @@ -960,25 +995,28 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val prop = get_prop(jsdisp, id); if(prop) - hres = prop_put(jsdisp, prop, &dp, ei, caller); + hres = prop_put(jsdisp, prop, val, ei, caller); else hres = DISP_E_MEMBERNOTFOUND; jsdisp_release(jsdisp); - return hres; + }else { + DISPID dispid = DISPID_PROPERTYPUT; + DISPPARAMS dp = {val, &dispid, 1, 1}; + IDispatchEx *dispex; + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + if(SUCCEEDED(hres)) { + hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, caller); + IDispatchEx_Release(dispex); + }else { + ULONG err = 0; + + TRACE("using IDispatch\n"); + hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, &err); + } } - hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); - if(FAILED(hres)) { - ULONG err = 0; - - TRACE("using IDispatch\n"); - return IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, &err); - } - - hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, caller); - - IDispatchEx_Release(dispex); return hres; } @@ -988,7 +1026,7 @@ HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, VARIANT *var, js dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(obj, name, FALSE, &prop); + hres = find_prop_name_prot(obj, name, &prop); if(FAILED(hres)) return hres; @@ -999,14 +1037,26 @@ HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, VARIANT *var, js return prop_get(obj, prop, &dp, var, ei, caller); } -HRESULT jsdisp_propget_idx(DispatchEx *obj, DWORD idx, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller) +HRESULT jsdisp_get_idx(DispatchEx *obj, DWORD idx, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller) { - WCHAR buf[12]; + WCHAR name[12]; + DISPPARAMS dp = {NULL, NULL, 0, 0}; + dispex_prop_t *prop; + HRESULT hres; static const WCHAR formatW[] = {'%','d',0}; - sprintfW(buf, formatW, idx); - return jsdisp_propget_name(obj, buf, var, ei, caller); + sprintfW(name, formatW, idx); + + hres = find_prop_name_prot(obj, name, &prop); + if(FAILED(hres)) + return hres; + + V_VT(var) = VT_EMPTY; + if(!prop) + return DISP_E_UNKNOWNNAME; + + return prop_get(obj, prop, &dp, var, ei, caller); } HRESULT jsdisp_propget(DispatchEx *jsdisp, DISPID id, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) diff --git a/dll/win32/jscript/engine.c b/dll/win32/jscript/engine.c index cecfd62b606..b40a88eb591 100644 --- a/dll/win32/jscript/engine.c +++ b/dll/win32/jscript/engine.c @@ -223,7 +223,7 @@ void exec_release(exec_ctx_t *ctx) heap_free(ctx); } -static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id) +static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, BSTR name, DWORD flags, DISPID *id) { IDispatchEx *dispex; HRESULT hres; @@ -237,7 +237,7 @@ static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id) } *id = 0; - hres = IDispatchEx_GetDispID(dispex, name, flags|fdexNameCaseSensitive, id); + hres = IDispatchEx_GetDispID(dispex, name, make_grfdex(ctx, flags|fdexNameCaseSensitive), id); IDispatchEx_Release(dispex); return hres; } @@ -347,33 +347,45 @@ static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret) return S_OK; } -static HRESULT literal_to_var(literal_t *literal, VARIANT *v) +static HRESULT literal_to_var(script_ctx_t *ctx, literal_t *literal, VARIANT *v) { - V_VT(v) = literal->vt; - - switch(V_VT(v)) { - case VT_EMPTY: - case VT_NULL: + switch(literal->type) { + case LT_NULL: + V_VT(v) = VT_NULL; break; - case VT_I4: + case LT_INT: + V_VT(v) = VT_I4; V_I4(v) = literal->u.lval; break; - case VT_R8: + case LT_DOUBLE: + V_VT(v) = VT_R8; V_R8(v) = literal->u.dval; break; - case VT_BSTR: - V_BSTR(v) = SysAllocString(literal->u.wstr); + case LT_STRING: { + BSTR str = SysAllocString(literal->u.wstr); + if(!str) + return E_OUTOFMEMORY; + + V_VT(v) = VT_BSTR; + V_BSTR(v) = str; break; - case VT_BOOL: + } + case LT_BOOL: + V_VT(v) = VT_BOOL; V_BOOL(v) = literal->u.bval; break; - case VT_DISPATCH: - IDispatch_AddRef(literal->u.disp); - V_DISPATCH(v) = literal->u.disp; - break; - default: - ERR("wrong type %d\n", V_VT(v)); - return E_NOTIMPL; + case LT_REGEXP: { + DispatchEx *regexp; + HRESULT hres; + + hres = create_regexp(ctx, literal->u.regexp.str, literal->u.regexp.str_len, + literal->u.regexp.flags, ®exp); + if(FAILED(hres)) + return hres; + + V_VT(v) = VT_DISPATCH; + V_DISPATCH(v) = (IDispatch*)_IDispatchEx_(regexp); + } } return S_OK; @@ -387,7 +399,7 @@ static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t for(item = ctx->named_items; item; item = item->next) { if(item->flags & SCRIPTITEM_GLOBALMEMBERS) { - hres = disp_get_id(item->disp, identifier, 0, &id); + hres = disp_get_id(ctx, item->disp, identifier, 0, &id); if(SUCCEEDED(hres)) { if(ret) exprval_set_idref(ret, item->disp, id); @@ -399,7 +411,8 @@ static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t return FALSE; } -HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv) +HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, exec_type_t exec_type, + jsexcept_t *ei, VARIANT *retv) { script_ctx_t *script = parser->script; function_declaration_t *func; @@ -478,10 +491,14 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so return hres; } - if(retv) + if(retv && (exec_type == EXECT_EVAL || rt.type == RT_RETURN)) *retv = val; - else + else { + if (retv) { + VariantInit(retv); + } VariantClear(&val); + } return S_OK; } @@ -1380,7 +1397,7 @@ HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, TRACE("\n"); - hres = expr_eval(ctx, expr->member_expr, EXPR_NEWREF, ei, &exprval); + hres = expr_eval(ctx, expr->member_expr, 0, ei, &exprval); if(FAILED(hres)) return hres; @@ -1395,11 +1412,15 @@ HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, exprval_release(&exprval); } - if(SUCCEEDED(hres)) + if(SUCCEEDED(hres)) { hres = to_object(ctx->parser->script, &member, &obj); + if(FAILED(hres)) + VariantClear(&val); + } VariantClear(&member); if(SUCCEEDED(hres)) { hres = to_string(ctx->parser->script, &val, ei, &str); + VariantClear(&val); if(SUCCEEDED(hres)) { if(flags & EXPR_STRREF) { ret->type = EXPRVAL_NAMEREF; @@ -1408,7 +1429,8 @@ HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return S_OK; } - hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + hres = disp_get_id(ctx->parser->script, obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + SysFreeString(str); } if(SUCCEEDED(hres)) { @@ -1459,7 +1481,7 @@ HRESULT member_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags return S_OK; } - hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + hres = disp_get_id(ctx->parser->script, obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); SysFreeString(str); if(SUCCEEDED(hres)) { exprval_set_idref(ret, obj, id); @@ -1552,6 +1574,7 @@ HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, j hres = disp_call(ctx->parser->script, V_DISPATCH(&constr), DISPID_VALUE, DISPATCH_CONSTRUCT, &dp, &var, ei, NULL/*FIXME*/); IDispatch_Release(V_DISPATCH(&constr)); + free_dp(&dp); if(FAILED(hres)) return hres; @@ -1654,7 +1677,7 @@ HRESULT literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flag TRACE("\n"); - hres = literal_to_var(expr->literal, &var); + hres = literal_to_var(ctx->parser->script, expr->literal, &var); if(FAILED(hres)) return hres; @@ -1733,7 +1756,7 @@ HRESULT property_value_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWO return hres; for(iter = expr->property_list; iter; iter = iter->next) { - hres = literal_to_var(iter->name, &tmp); + hres = literal_to_var(ctx->parser->script, iter->name, &tmp); if(FAILED(hres)) break; @@ -2053,7 +2076,7 @@ static HRESULT in_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *obj, jsexcept_t if(FAILED(hres)) return hres; - hres = disp_get_id(V_DISPATCH(obj), str, 0, &id); + hres = disp_get_id(ctx->parser->script, V_DISPATCH(obj), str, 0, &id); SysFreeString(str); if(SUCCEEDED(hres)) ret = VARIANT_TRUE; @@ -2293,7 +2316,8 @@ HRESULT delete_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex); if(SUCCEEDED(hres)) { - hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, fdexNameCaseSensitive); + hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, + make_grfdex(ctx->parser->script, fdexNameCaseSensitive)); b = VARIANT_TRUE; IDispatchEx_Release(dispex); } @@ -2472,6 +2496,7 @@ HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return hres; hres = to_number(ctx->parser->script, &val, ei, &num); + VariantClear(&val); if(FAILED(hres)) return hres; @@ -2731,6 +2756,8 @@ HRESULT equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return hres; hres = equal_values(ctx, &rval, &lval, ei, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -2752,6 +2779,8 @@ HRESULT equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags return hres; hres = equal2_values(&rval, &lval, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -2773,6 +2802,8 @@ HRESULT not_equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD fl return hres; hres = equal_values(ctx, &lval, &rval, ei, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -2794,6 +2825,8 @@ HRESULT not_equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD f return hres; hres = equal2_values(&lval, &rval, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -3096,8 +3129,11 @@ HRESULT assign_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags exprval_release(&exprvalr); } - if(SUCCEEDED(hres)) + if(SUCCEEDED(hres)) { hres = put_value(ctx->parser->script, &exprval, &rval, ei); + if(FAILED(hres)) + VariantClear(&rval); + } exprval_release(&exprval); if(FAILED(hres)) diff --git a/dll/win32/jscript/engine.h b/dll/win32/jscript/engine.h index 386f38b51fd..0bcabf614d2 100644 --- a/dll/win32/jscript/engine.h +++ b/dll/win32/jscript/engine.h @@ -19,11 +19,6 @@ typedef struct _source_elements_t source_elements_t; typedef struct _function_expression_t function_expression_t; -typedef struct _obj_literal_t { - DispatchEx *obj; - struct _obj_literal_t *next; -} obj_literal_t; - typedef struct _function_declaration_t { function_expression_t *expr; @@ -48,9 +43,9 @@ typedef struct _func_stack { typedef struct _parser_ctx_t { LONG ref; - const WCHAR *ptr; - const WCHAR *begin; + WCHAR *begin; const WCHAR *end; + const WCHAR *ptr; script_ctx_t *script; source_elements_t *source; @@ -61,7 +56,6 @@ typedef struct _parser_ctx_t { jsheap_t heap; - obj_literal_t *obj_literals; func_stack_t *func_stack; struct _parser_ctx_t *next; @@ -115,9 +109,15 @@ static inline void exec_addref(exec_ctx_t *ctx) ctx->ref++; } +typedef enum { + EXECT_PROGRAM, + EXECT_FUNCTION, + EXECT_EVAL +} exec_type_t; + void exec_release(exec_ctx_t*); HRESULT create_exec_ctx(script_ctx_t*,IDispatch*,DispatchEx*,scope_chain_t*,exec_ctx_t**); -HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,jsexcept_t*,VARIANT*); +HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,exec_type_t,jsexcept_t*,VARIANT*); typedef struct _statement_t statement_t; typedef struct _expression_t expression_t; @@ -126,14 +126,28 @@ typedef struct _parameter_t parameter_t; HRESULT create_source_function(parser_ctx_t*,parameter_t*,source_elements_t*,scope_chain_t*, const WCHAR*,DWORD,DispatchEx**); +typedef enum { + LT_INT, + LT_DOUBLE, + LT_STRING, + LT_BOOL, + LT_NULL, + LT_REGEXP +}literal_type_t; + typedef struct { - VARTYPE vt; + literal_type_t type; union { LONG lval; double dval; const WCHAR *wstr; VARIANT_BOOL bval; IDispatch *disp; + struct { + const WCHAR *str; + DWORD str_len; + DWORD flags; + } regexp; } u; } literal_t; diff --git a/dll/win32/jscript/error.c b/dll/win32/jscript/error.c index 9530a4ce52a..e3cfce634ee 100644 --- a/dll/win32/jscript/error.c +++ b/dll/win32/jscript/error.c @@ -36,6 +36,7 @@ typedef struct { static const WCHAR descriptionW[] = {'d','e','s','c','r','i','p','t','i','o','n',0}; static const WCHAR messageW[] = {'m','e','s','s','a','g','e',0}; +static const WCHAR nameW[] = {'n','a','m','e',0}; static const WCHAR numberW[] = {'n','u','m','b','e','r',0}; static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}; @@ -44,6 +45,11 @@ static inline ErrorInstance *error_from_vdisp(vdisp_t *vdisp) return (ErrorInstance*)vdisp->u.jsdisp; } +static inline ErrorInstance *error_this(vdisp_t *jsthis) +{ + return is_vclass(jsthis, JSCLASS_ERROR) ? error_from_vdisp(jsthis) : NULL; +} + static HRESULT Error_number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { @@ -101,17 +107,77 @@ static HRESULT Error_message(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, /* ECMA-262 3rd Edition 15.11.4.4 */ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, - DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) + DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { + ErrorInstance *error; + BSTR name, msg = NULL, ret = NULL; + VARIANT v; + HRESULT hres; + static const WCHAR str[] = {'[','o','b','j','e','c','t',' ','E','r','r','o','r',']',0}; TRACE("\n"); + error = error_this(jsthis); + if(ctx->version < 2 || !error) { + if(retv) { + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = SysAllocString(str); + if(!V_BSTR(retv)) + return E_OUTOFMEMORY; + } + return S_OK; + } + + hres = jsdisp_propget_name(&error->dispex, nameW, &v, ei, caller); + if(FAILED(hres)) + return hres; + + hres = to_string(ctx, &v, ei, &name); + VariantClear(&v); + if(FAILED(hres)) + return hres; + + if(V_VT(&error->message) != VT_EMPTY) { + hres = to_string(ctx, &error->message, ei, &msg); + if(SUCCEEDED(hres) && !*msg) { + SysFreeString(msg); + msg = NULL; + } + } + + if(SUCCEEDED(hres)) { + if(msg) { + DWORD name_len, msg_len; + + name_len = SysStringLen(name); + msg_len = SysStringLen(msg); + + ret = SysAllocStringLen(NULL, name_len + msg_len + 2); + if(ret) { + memcpy(ret, name, name_len*sizeof(WCHAR)); + ret[name_len] = ':'; + ret[name_len+1] = ' '; + memcpy(ret+name_len+2, msg, msg_len*sizeof(WCHAR)); + } + }else { + ret = name; + name = NULL; + } + } + + SysFreeString(msg); + SysFreeString(name); + if(FAILED(hres)) + return hres; + if(!ret) + return E_OUTOFMEMORY; + if(retv) { V_VT(retv) = VT_BSTR; - V_BSTR(retv) = SysAllocString(str); - if(!V_BSTR(retv)) - return E_OUTOFMEMORY; + V_BSTR(retv) = ret; + }else { + SysFreeString(ret); } return S_OK; @@ -264,6 +330,7 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, DISPPARAMS *dp, hres = create_error(ctx, constr, NULL, msg, &err); else hres = create_error(ctx, constr, &num, msg, &err); + SysFreeString(msg); if(FAILED(hres)) return hres; @@ -341,7 +408,6 @@ static HRESULT URIErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla HRESULT init_error_constr(script_ctx_t *ctx, DispatchEx *object_prototype) { - static const WCHAR nameW[] = {'n','a','m','e',0}; static const WCHAR ErrorW[] = {'E','r','r','o','r',0}; static const WCHAR EvalErrorW[] = {'E','v','a','l','E','r','r','o','r',0}; static const WCHAR RangeErrorW[] = {'R','a','n','g','e','E','r','r','o','r',0}; @@ -381,7 +447,7 @@ HRESULT init_error_constr(script_ctx_t *ctx, DispatchEx *object_prototype) if(SUCCEEDED(hres)) hres = create_builtin_function(ctx, constr_val[i], names[i], NULL, - PROPF_CONSTR, &err->dispex, constr_addr[i]); + PROPF_CONSTR|1, &err->dispex, constr_addr[i]); jsdisp_release(&err->dispex); VariantClear(&v); @@ -424,11 +490,6 @@ static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCH return id; } -HRESULT throw_eval_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCHAR *str) -{ - return throw_error(ctx, ei, id, str, ctx->eval_error_constr); -} - HRESULT throw_generic_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCHAR *str) { return throw_error(ctx, ei, id, str, ctx->error_constr); diff --git a/dll/win32/jscript/function.c b/dll/win32/jscript/function.c index b0fb79d711d..c7494cfce6c 100644 --- a/dll/win32/jscript/function.c +++ b/dll/win32/jscript/function.c @@ -213,10 +213,11 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis hres = create_exec_ctx(ctx, this_obj, var_disp, scope, &exec_ctx); scope_release(scope); } + jsdisp_release(var_disp); if(FAILED(hres)) return hres; - hres = exec_source(exec_ctx, function->parser, function->source, ei, retv); + hres = exec_source(exec_ctx, function->parser, function->source, EXECT_FUNCTION, ei, retv); exec_release(exec_ctx); return hres; @@ -226,20 +227,27 @@ static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { DispatchEx *this_obj; + VARIANT var; HRESULT hres; hres = create_object(ctx, &function->dispex, &this_obj); if(FAILED(hres)) return hres; - hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, retv, ei, caller); + hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, &var, ei, caller); if(FAILED(hres)) { jsdisp_release(this_obj); return hres; } V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj); + if(V_VT(&var) == VT_DISPATCH) { + jsdisp_release(this_obj); + V_DISPATCH(retv) = V_DISPATCH(&var); + }else { + VariantClear(&var); + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj); + } return S_OK; } @@ -366,8 +374,10 @@ static HRESULT array_to_args(script_ctx_t *ctx, DispatchEx *arg_array, jsexcept_ return E_OUTOFMEMORY; for(i=0; i= 2) { @@ -406,8 +420,8 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI if(V_VT(get_arg(dp,1)) == VT_DISPATCH) { arg_array = iface_to_jsdisp((IUnknown*)V_DISPATCH(get_arg(dp,1))); - if(arg_array && ( - !is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) { + if(arg_array && + (!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) { jsdisp_release(arg_array); arg_array = NULL; } @@ -448,9 +462,14 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS argc = arg_cnt(dp); if(argc) { - hres = to_object(ctx, get_arg(dp,0), &this_obj); - if(FAILED(hres)) - return hres; + VARIANT *v = get_arg(dp,0); + + if(V_VT(v) != VT_EMPTY && V_VT(v) != VT_NULL) { + hres = to_object(ctx, v, &this_obj); + if(FAILED(hres)) + return hres; + } + args.cArgs = argc-1; } @@ -539,20 +558,6 @@ static const builtin_info_t Function_info = { NULL }; -static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, - VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) -{ - FIXME("\n"); - return E_NOTIMPL; -} - -static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, - VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) -{ - FIXME("\n"); - return E_NOTIMPL; -} - static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, DWORD flags, BOOL funcprot, DispatchEx *prototype, FunctionInstance **ret) { @@ -659,6 +664,131 @@ HRESULT create_source_function(parser_ctx_t *ctx, parameter_t *parameters, sourc return S_OK; } +static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t *ei, IDispatch **ret) +{ + function_expression_t *expr; + WCHAR *str = NULL, *ptr; + DWORD argc, len = 0, l; + parser_ctx_t *parser; + DispatchEx *function; + BSTR *params = NULL; + int i=0, j=0; + HRESULT hres = S_OK; + + static const WCHAR function_anonymousW[] = {'f','u','n','c','t','i','o','n',' ','a','n','o','n','y','m','o','u','s','('}; + static const WCHAR function_beginW[] = {')',' ','{','\n'}; + static const WCHAR function_endW[] = {'\n','}',0}; + + argc = arg_cnt(dp); + if(argc) { + params = heap_alloc(argc*sizeof(BSTR)); + if(!params) + return E_OUTOFMEMORY; + + if(argc > 2) + len = (argc-2)*2; /* separating commas */ + for(i=0; i < argc; i++) { + hres = to_string(ctx, get_arg(dp,i), ei, params+i); + if(FAILED(hres)) + break; + len += SysStringLen(params[i]); + } + } + + if(SUCCEEDED(hres)) { + len += (sizeof(function_anonymousW) + sizeof(function_beginW) + sizeof(function_endW)) / sizeof(WCHAR); + str = heap_alloc(len*sizeof(WCHAR)); + if(str) { + memcpy(str, function_anonymousW, sizeof(function_anonymousW)); + ptr = str + sizeof(function_anonymousW)/sizeof(WCHAR); + if(argc > 1) { + while(1) { + l = SysStringLen(params[j]); + memcpy(ptr, params[j], l*sizeof(WCHAR)); + ptr += l; + if(++j == argc-1) + break; + *ptr++ = ','; + *ptr++ = ' '; + } + } + memcpy(ptr, function_beginW, sizeof(function_beginW)); + ptr += sizeof(function_beginW)/sizeof(WCHAR); + if(argc) { + l = SysStringLen(params[argc-1]); + memcpy(ptr, params[argc-1], l*sizeof(WCHAR)); + ptr += l; + } + memcpy(ptr, function_endW, sizeof(function_endW)); + + TRACE("%s\n", debugstr_w(str)); + }else { + hres = E_OUTOFMEMORY; + } + } + + while(--i >= 0) + SysFreeString(params[i]); + heap_free(params); + if(FAILED(hres)) + return hres; + + hres = script_parse(ctx, str, NULL, &parser); + heap_free(str); + if(FAILED(hres)) + return hres; + + if(!parser->source || !parser->source->functions || parser->source->functions->next || parser->source->variables) { + ERR("Invalid parser result!\n"); + parser_release(parser); + return E_UNEXPECTED; + } + expr = parser->source->functions->expr; + + hres = create_source_function(parser, expr->parameter_list, expr->source_elements, NULL, expr->src_str, + expr->src_len, &function); + parser_release(parser); + if(FAILED(hres)) + return hres; + + *ret = (IDispatch*)_IDispatchEx_(function); + return S_OK; +} + +static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, + VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) +{ + HRESULT hres; + + TRACE("\n"); + + switch(flags) { + case DISPATCH_CONSTRUCT: { + IDispatch *ret; + + hres = construct_function(ctx, dp, ei, &ret); + if(FAILED(hres)) + return hres; + + V_VT(retv) = VT_DISPATCH; + V_DISPATCH(retv) = ret; + break; + } + default: + FIXME("unimplemented flags %x\n", flags); + return E_NOTIMPL; + } + + return S_OK; +} + +static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, + VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) +{ + FIXME("\n"); + return E_NOTIMPL; +} + HRESULT init_function_constr(script_ctx_t *ctx, DispatchEx *object_prototype) { FunctionInstance *prot, *constr; @@ -673,7 +803,7 @@ HRESULT init_function_constr(script_ctx_t *ctx, DispatchEx *object_prototype) prot->value_proc = FunctionProt_value; prot->name = prototypeW; - hres = create_function(ctx, NULL, PROPF_CONSTR, TRUE, &prot->dispex, &constr); + hres = create_function(ctx, NULL, PROPF_CONSTR|1, TRUE, &prot->dispex, &constr); if(SUCCEEDED(hres)) { constr->value_proc = FunctionConstr_value; constr->name = FunctionW; diff --git a/dll/win32/jscript/global.c b/dll/win32/jscript/global.c index ef86f2663d4..af142ed4db3 100644 --- a/dll/win32/jscript/global.c +++ b/dll/win32/jscript/global.c @@ -334,8 +334,10 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D } ret = SysAllocStringLen(NULL, len); - if(!ret) + if(!ret) { + SysFreeString(str); return E_OUTOFMEMORY; + } len = 0; for(ptr=str; *ptr; ptr++) { @@ -357,6 +359,8 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D } } + SysFreeString(str); + if(retv) { V_VT(retv) = VT_BSTR; V_BSTR(retv) = ret; @@ -404,7 +408,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS return throw_syntax_error(ctx, ei, hres, NULL); } - hres = exec_source(ctx->exec_ctx, parser_ctx, parser_ctx->source, ei, retv); + hres = exec_source(ctx->exec_ctx, parser_ctx, parser_ctx->source, EXECT_EVAL, ei, retv); parser_release(parser_ctx); return hres; @@ -690,8 +694,10 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } ret = SysAllocStringLen(NULL, len); - if(!ret) + if(!ret) { + SysFreeString(str); return E_OUTOFMEMORY; + } len = 0; for(ptr=str; *ptr; ptr++) { @@ -715,6 +721,8 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, len++; } + SysFreeString(str); + if(retv) { V_VT(retv) = VT_BSTR; V_BSTR(retv) = ret; @@ -802,8 +810,8 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags }else { i = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL)*3; if(!i) { - FIXME("throw URIError\n"); - return E_FAIL; + SysFreeString(str); + return throw_uri_error(ctx, ei, IDS_URI_INVALID_CHAR, NULL); } len += i; @@ -811,8 +819,10 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } rptr = ret = SysAllocStringLen(NULL, len); - if(!ret) + if(!ret) { + SysFreeString(str); return E_OUTOFMEMORY; + } for(ptr = str; *ptr; ptr++) { if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') { @@ -827,6 +837,8 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } } + SysFreeString(str); + TRACE("%s -> %s\n", debugstr_w(str), debugstr_w(ret)); if(retv) { V_VT(retv) = VT_BSTR; @@ -847,56 +859,239 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + BSTR str, ret; + char buf[4]; + const WCHAR *ptr; + DWORD len = 0, size, i; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) { + ret = SysAllocString(undefinedW); + if(!ret) + return E_OUTOFMEMORY; + + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + } + + return S_OK; + } + + hres = to_string(ctx, get_arg(dp, 0), ei, &str); + if(FAILED(hres)) + return hres; + + for(ptr=str; *ptr; ptr++) { + if(is_uri_unescaped(*ptr)) + len++; + else { + size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL); + if(!size) { + SysFreeString(str); + FIXME("throw Error\n"); + return E_FAIL; + } + len += size*3; + } + } + + ret = SysAllocStringLen(NULL, len); + if(!ret) { + SysFreeString(str); + return E_OUTOFMEMORY; + } + + len = 0; + for(ptr=str; *ptr; ptr++) { + if(is_uri_unescaped(*ptr)) + ret[len++] = *ptr; + else { + size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL); + for(i=0; i> 4); + ret[len++] = int_to_char(buf[i] & 0x0f); + } + } + } + + SysFreeString(str); + + if(retv) { + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + } else { + SysFreeString(ret); + } + + return S_OK; } +/* ECMA-262 3rd Edition 15.1.3.2 */ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + BSTR str, ret; + const WCHAR *ptr; + WCHAR *out_ptr; + DWORD len = 0; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) { + ret = SysAllocString(undefinedW); + if(!ret) + return E_OUTOFMEMORY; + + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + } + + return S_OK; + } + + hres = to_string(ctx, get_arg(dp, 0), ei, &str); + if(FAILED(hres)) + return hres; + + ptr = str; + while(*ptr) { + if(*ptr == '%') { + char octets[4]; + unsigned char mask = 0x80; + int i, size, num_bytes = 0; + if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) { + FIXME("Throw URIError: Invalid hex sequence\n"); + SysFreeString(str); + return E_FAIL; + } + octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + while(octets[0] & mask) { + mask = mask >> 1; + ++num_bytes; + } + if(num_bytes == 1 || num_bytes > 4) { + FIXME("Throw URIError: Invalid initial UTF character\n"); + SysFreeString(str); + return E_FAIL; + } + for(i = 1; i < num_bytes; ++i) { + if(*ptr != '%'){ + FIXME("Throw URIError: Incomplete UTF sequence\n"); + SysFreeString(str); + return E_FAIL; + } + if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) { + FIXME("Throw URIError: Invalid hex sequence\n"); + SysFreeString(str); + return E_FAIL; + } + octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + } + size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, octets, + num_bytes ? num_bytes : 1, NULL, 0); + if(size == 0) { + FIXME("Throw URIError: Invalid UTF sequence\n"); + SysFreeString(str); + return E_FAIL; + } + len += size; + }else { + ++ptr; + ++len; + } + } + + out_ptr = ret = SysAllocStringLen(NULL, len); + if(!ret) { + SysFreeString(str); + return E_OUTOFMEMORY; + } + + ptr = str; + while(*ptr) { + if(*ptr == '%') { + char octets[4]; + unsigned char mask = 0x80; + int i, size, num_bytes = 0; + octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + while(octets[0] & mask) { + mask = mask >> 1; + ++num_bytes; + } + for(i = 1; i < num_bytes; ++i) { + octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + } + size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, octets, + num_bytes ? num_bytes : 1, out_ptr, len); + len -= size; + out_ptr += size; + }else { + *out_ptr++ = *ptr++; + --len; + } + } + + SysFreeString(str); + + if(retv) { + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + }else { + SysFreeString(ret); + } + + return S_OK; } static const builtin_prop_t JSGlobal_props[] = { - {ActiveXObjectW, JSGlobal_ActiveXObject, PROPF_CONSTR}, - {ArrayW, JSGlobal_Array, PROPF_CONSTR}, - {BooleanW, JSGlobal_Boolean, PROPF_CONSTR}, + {ActiveXObjectW, JSGlobal_ActiveXObject, PROPF_CONSTR|1}, + {ArrayW, JSGlobal_Array, PROPF_CONSTR|1}, + {BooleanW, JSGlobal_Boolean, PROPF_CONSTR|1}, {CollectGarbageW, JSGlobal_CollectGarbage, PROPF_METHOD}, - {DateW, JSGlobal_Date, PROPF_CONSTR}, - {EnumeratorW, JSGlobal_Enumerator, PROPF_METHOD}, - {ErrorW, JSGlobal_Error, PROPF_CONSTR}, - {EvalErrorW, JSGlobal_EvalError, PROPF_CONSTR}, - {FunctionW, JSGlobal_Function, PROPF_CONSTR}, - {_GetObjectW, JSGlobal_GetObject, PROPF_METHOD}, + {DateW, JSGlobal_Date, PROPF_CONSTR|7}, + {EnumeratorW, JSGlobal_Enumerator, PROPF_METHOD|7}, + {ErrorW, JSGlobal_Error, PROPF_CONSTR|1}, + {EvalErrorW, JSGlobal_EvalError, PROPF_CONSTR|1}, + {FunctionW, JSGlobal_Function, PROPF_CONSTR|1}, + {_GetObjectW, JSGlobal_GetObject, PROPF_METHOD|2}, {InfinityW, JSGlobal_Infinity, 0}, /* {MathW, JSGlobal_Math, 0}, */ {NaNW, JSGlobal_NaN, 0}, - {NumberW, JSGlobal_Number, PROPF_CONSTR}, - {ObjectW, JSGlobal_Object, PROPF_CONSTR}, - {RangeErrorW, JSGlobal_RangeError, PROPF_CONSTR}, - {ReferenceErrorW, JSGlobal_ReferenceError, PROPF_CONSTR}, - {RegExpW, JSGlobal_RegExp, PROPF_CONSTR}, + {NumberW, JSGlobal_Number, PROPF_CONSTR|1}, + {ObjectW, JSGlobal_Object, PROPF_CONSTR|1}, + {RangeErrorW, JSGlobal_RangeError, PROPF_CONSTR|1}, + {ReferenceErrorW, JSGlobal_ReferenceError, PROPF_CONSTR|1}, + {RegExpW, JSGlobal_RegExp, PROPF_CONSTR|2}, {ScriptEngineW, JSGlobal_ScriptEngine, PROPF_METHOD}, {ScriptEngineBuildVersionW, JSGlobal_ScriptEngineBuildVersion, PROPF_METHOD}, {ScriptEngineMajorVersionW, JSGlobal_ScriptEngineMajorVersion, PROPF_METHOD}, {ScriptEngineMinorVersionW, JSGlobal_ScriptEngineMinorVersion, PROPF_METHOD}, - {StringW, JSGlobal_String, PROPF_CONSTR}, - {SyntaxErrorW, JSGlobal_SyntaxError, PROPF_CONSTR}, - {TypeErrorW, JSGlobal_TypeError, PROPF_CONSTR}, - {URIErrorW, JSGlobal_URIError, PROPF_CONSTR}, - {VBArrayW, JSGlobal_VBArray, PROPF_METHOD}, - {decodeURIW, JSGlobal_decodeURI, PROPF_METHOD}, - {decodeURIComponentW, JSGlobal_decodeURIComponent, PROPF_METHOD}, - {encodeURIW, JSGlobal_encodeURI, PROPF_METHOD}, - {encodeURIComponentW, JSGlobal_encodeURIComponent, PROPF_METHOD}, - {escapeW, JSGlobal_escape, PROPF_METHOD}, + {StringW, JSGlobal_String, PROPF_CONSTR|1}, + {SyntaxErrorW, JSGlobal_SyntaxError, PROPF_CONSTR|1}, + {TypeErrorW, JSGlobal_TypeError, PROPF_CONSTR|1}, + {URIErrorW, JSGlobal_URIError, PROPF_CONSTR|1}, + {VBArrayW, JSGlobal_VBArray, PROPF_METHOD|1}, + {decodeURIW, JSGlobal_decodeURI, PROPF_METHOD|1}, + {decodeURIComponentW, JSGlobal_decodeURIComponent, PROPF_METHOD|1}, + {encodeURIW, JSGlobal_encodeURI, PROPF_METHOD|1}, + {encodeURIComponentW, JSGlobal_encodeURIComponent, PROPF_METHOD|1}, + {escapeW, JSGlobal_escape, PROPF_METHOD|1}, {evalW, JSGlobal_eval, PROPF_METHOD|1}, - {isFiniteW, JSGlobal_isFinite, PROPF_METHOD}, - {isNaNW, JSGlobal_isNaN, PROPF_METHOD}, - {parseFloatW, JSGlobal_parseFloat, PROPF_METHOD}, + {isFiniteW, JSGlobal_isFinite, PROPF_METHOD|1}, + {isNaNW, JSGlobal_isNaN, PROPF_METHOD|1}, + {parseFloatW, JSGlobal_parseFloat, PROPF_METHOD|1}, {parseIntW, JSGlobal_parseInt, PROPF_METHOD|2}, - {unescapeW, JSGlobal_unescape, PROPF_METHOD} + {unescapeW, JSGlobal_unescape, PROPF_METHOD|1} }; static const builtin_info_t JSGlobal_info = { @@ -981,6 +1176,11 @@ HRESULT init_global(script_ctx_t *ctx) if(FAILED(hres)) return hres; + V_VT(&var) = VT_EMPTY; + hres = jsdisp_propput_name(ctx->global, undefinedW, &var, NULL/*FIXME*/, NULL/*FIXME*/); + if(FAILED(hres)) + return hres; + V_VT(&var) = VT_DISPATCH; V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(math); hres = jsdisp_propput_name(ctx->global, MathW, &var, NULL/*FIXME*/, NULL/*FIXME*/); diff --git a/dll/win32/jscript/jscript.c b/dll/win32/jscript/jscript.c index eb4183526be..9a516aa5d71 100644 --- a/dll/win32/jscript/jscript.c +++ b/dll/win32/jscript/jscript.c @@ -51,6 +51,7 @@ typedef struct { script_ctx_t *ctx; LONG thread_id; LCID lcid; + DWORD version; IActiveScriptSite *site; @@ -93,7 +94,6 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx) { exec_ctx_t *exec_ctx; jsexcept_t jsexcept; - VARIANT var; HRESULT hres; hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, &exec_ctx); @@ -103,14 +103,11 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx) IActiveScriptSite_OnEnterScript(This->site); memset(&jsexcept, 0, sizeof(jsexcept)); - hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, &jsexcept, &var); + hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, EXECT_PROGRAM, &jsexcept, NULL); VariantClear(&jsexcept.var); exec_release(exec_ctx); - if(SUCCEEDED(hres)) - VariantClear(&var); IActiveScriptSite_OnLeaveScript(This->site); - return hres; } @@ -659,6 +656,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface) ctx->ref = 1; ctx->state = SCRIPTSTATE_UNINITIALIZED; ctx->safeopt = This->safeopt; + ctx->version = This->version; jsheap_init(&ctx->tmp_heap); ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL); @@ -822,8 +820,27 @@ static HRESULT WINAPI JScriptProperty_SetProperty(IActiveScriptProperty *iface, VARIANT *pvarIndex, VARIANT *pvarValue) { JScript *This = ACTSCPPROP_THIS(iface); - FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue); - return E_NOTIMPL; + + TRACE("(%p)->(%x %s %s)\n", This, dwProperty, debugstr_variant(pvarIndex), debugstr_variant(pvarValue)); + + if(pvarIndex) + FIXME("unsupported pvarIndex\n"); + + switch(dwProperty) { + case SCRIPTPROP_INVOKEVERSIONING: + if(V_VT(pvarValue) != VT_I4 || V_I4(pvarValue) < 0 || V_I4(pvarValue) > 15) { + WARN("invalid value %s\n", debugstr_variant(pvarValue)); + return E_INVALIDARG; + } + + This->version = V_I4(pvarValue); + break; + default: + FIXME("Unimplemented property %x\n", dwProperty); + return E_NOTIMPL; + } + + return S_OK; } #undef ACTSCPPROP_THIS diff --git a/dll/win32/jscript/jscript.h b/dll/win32/jscript/jscript.h index cde1e1bf67c..00688273de8 100644 --- a/dll/win32/jscript/jscript.h +++ b/dll/win32/jscript/jscript.h @@ -205,7 +205,7 @@ HRESULT jsdisp_propget(DispatchEx*,DISPID,VARIANT*,jsexcept_t*,IServiceProvider* HRESULT jsdisp_propput_name(DispatchEx*,const WCHAR*,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propput_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propget_name(DispatchEx*,LPCWSTR,VARIANT*,jsexcept_t*,IServiceProvider*); -HRESULT jsdisp_propget_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*); +HRESULT jsdisp_get_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_get_id(DispatchEx*,const WCHAR*,DWORD,DISPID*); HRESULT jsdisp_delete_idx(DispatchEx*,DWORD); @@ -225,7 +225,8 @@ HRESULT throw_uri_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*); HRESULT create_object(script_ctx_t*,DispatchEx*,DispatchEx**); HRESULT create_math(script_ctx_t*,DispatchEx**); HRESULT create_array(script_ctx_t*,DWORD,DispatchEx**); -HRESULT create_regexp_str(script_ctx_t*,const WCHAR*,DWORD,const WCHAR*,DWORD,DispatchEx**); +HRESULT create_regexp(script_ctx_t*,const WCHAR *,int,DWORD,DispatchEx**); +HRESULT create_regexp_var(script_ctx_t*,VARIANT*,VARIANT*,DispatchEx**); HRESULT create_string(script_ctx_t*,const WCHAR*,DWORD,DispatchEx**); HRESULT create_bool(script_ctx_t*,VARIANT_BOOL,DispatchEx**); HRESULT create_number(script_ctx_t*,VARIANT*,DispatchEx**); @@ -262,6 +263,7 @@ struct _script_ctx_t { IActiveScriptSite *site; IInternetHostSecurityManager *secmgr; DWORD safeopt; + DWORD version; LCID lcid; jsheap_t tmp_heap; @@ -316,9 +318,12 @@ typedef struct { DWORD len; } match_result_t; -HRESULT regexp_match_next(script_ctx_t*,DispatchEx*,BOOL,const WCHAR*,DWORD,const WCHAR**,match_result_t**, +#define REM_CHECK_GLOBAL 0x0001 +#define REM_RESET_INDEX 0x0002 +HRESULT regexp_match_next(script_ctx_t*,DispatchEx*,DWORD,const WCHAR*,DWORD,const WCHAR**,match_result_t**, DWORD*,DWORD*,match_result_t*); HRESULT regexp_match(script_ctx_t*,DispatchEx*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*); +HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*); static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i) { @@ -390,6 +395,11 @@ static inline void num_set_inf(VARIANT *v, BOOL positive) #endif } +static inline DWORD make_grfdex(script_ctx_t *ctx, DWORD flags) +{ + return (ctx->version << 28) | flags; +} + const char *debugstr_variant(const VARIANT*); HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**); diff --git a/dll/win32/jscript/jscript.inf b/dll/win32/jscript/jscript.inf index bdec721c040..9f683ed78e1 100644 --- a/dll/win32/jscript/jscript.inf +++ b/dll/win32/jscript/jscript.inf @@ -12,27 +12,27 @@ DelReg=Classes.Reg [Classes.Reg] HKCR,"CLSID\%CLSID_JScript%",,,"JScript Language" -HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScript%",,, -HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScriptParse%",,, +HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScript%",,16 +HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScriptParse%",,16 HKCR,"CLSID\%CLSID_JScript%\InprocServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_JScript%\InprocServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_JScript%\OLEScript",,, +HKCR,"CLSID\%CLSID_JScript%\OLEScript",,16 HKCR,"CLSID\%CLSID_JScript%\ProgID",,,"JScript" HKCR,"CLSID\%CLSID_JScriptAuthor%",,,"JScript Language Authoring" -HKCR,"CLSID\%CLSID_JScriptAuthor%\Implemented Categories\%CATID_ActiveScriptAuthor%",,, +HKCR,"CLSID\%CLSID_JScriptAuthor%\Implemented Categories\%CATID_ActiveScriptAuthor%",,16 HKCR,"CLSID\%CLSID_JScriptAuthor%\InprocServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_JScriptAuthor%\InprocServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_JScriptAuthor%\OLEScript",,, +HKCR,"CLSID\%CLSID_JScriptAuthor%\OLEScript",,16 HKCR,"CLSID\%CLSID_JScriptAuthor%\ProgID",,,"JScript Author" HKCR,"CLSID\%CLSID_JScriptEncode%",,,"JScript Language Encoding" -HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScript%",,, -HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptParse%",,, -HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptEncode%",,, +HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScript%",,16 +HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptParse%",,16 +HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptEncode%",,16 HKCR,"CLSID\%CLSID_JScriptEncode%\InprocServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_JScriptEncode%\InprocServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_JScriptEncode%\OLEScript",,, +HKCR,"CLSID\%CLSID_JScriptEncode%\OLEScript",,16 HKCR,"CLSID\%CLSID_JScriptEncode%\ProgID",,,"JScript.Encode" HKCR,"Component Categories\%CATID_ActiveScriptAuthor%","409",,"Active Scripting Engine with Authoring" @@ -42,55 +42,55 @@ HKCR,"Component Categories\%CATID_ActiveScriptEncode%","409",,"Active Scripting HKCR,"ECMAScript",,,"JScript Language" HKCR,"ECMAScript\CLSID",,,"%CLSID_JScript%" -HKCR,"ECMAScript\OLEScript",,, +HKCR,"ECMAScript\OLEScript",,16 HKCR,"JavaScript",,,"JScript Language" HKCR,"JavaScript\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript\OLEScript",,, +HKCR,"JavaScript\OLEScript",,16 HKCR,"JavaScript Author",,,"JScript Language Authoring" HKCR,"JavaScript Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JavaScript Author\OLEScript",,, +HKCR,"JavaScript Author\OLEScript",,16 HKCR,"JavaScript1.1",,,"JScript Language" HKCR,"JavaScript1.1\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript1.1\OLEScript",,, +HKCR,"JavaScript1.1\OLEScript",,16 HKCR,"JavaScript1.1 Author",,,"JScript Language Authoring" HKCR,"JavaScript1.1 Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JavaScript1.1 Author\OLEScript",,, +HKCR,"JavaScript1.1 Author\OLEScript",,16 HKCR,"JavaScript1.2",,,"JScript Language" HKCR,"JavaScript1.2\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript1.2\OLEScript",,, +HKCR,"JavaScript1.2\OLEScript",,16 HKCR,"JavaScript1.2 Author",,,"JScript Language Authoring" HKCR,"JavaScript1.2 Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JavaScript1.2 Author\OLEScript",,, +HKCR,"JavaScript1.2 Author\OLEScript",,16 HKCR,"JavaScript1.3",,,"JScript Language" HKCR,"JavaScript1.3\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript1.3\OLEScript",,, +HKCR,"JavaScript1.3\OLEScript",,16 HKCR,"JScript",,,"JScript Language" HKCR,"JScript\CLSID",,,"%CLSID_JScript%" -HKCR,"JScript\OLEScript",,, +HKCR,"JScript\OLEScript",,16 HKCR,"JScript Author",,,"JScript Language Authoring" HKCR,"JScript Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JScript Author\OLEScript",,, +HKCR,"JScript Author\OLEScript",,16 HKCR,"JScript.Encode",,,"JScript Language Encoding" HKCR,"JScript.Encode\CLSID",,,"%CLSID_JScriptEncode%" -HKCR,"JScript.Encode\OLEScript",,, +HKCR,"JScript.Encode\OLEScript",,16 HKCR,"LiveScript",,,"JScript Language" HKCR,"LiveScript\CLSID",,,"%CLSID_JScript%" -HKCR,"LiveScript\OLEScript",,, +HKCR,"LiveScript\OLEScript",,16 HKCR,"LiveScript Author",,,"JScript Language Authoring" HKCR,"LiveScript Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"LiveScript Author\OLEScript",,, +HKCR,"LiveScript Author\OLEScript",,16 [Strings] diff --git a/dll/win32/jscript/jscript_De.rc b/dll/win32/jscript/jscript_De.rc index 02b52f38dbf..7e4e9a13050 100644 --- a/dll/win32/jscript/jscript_De.rc +++ b/dll/win32/jscript/jscript_De.rc @@ -43,6 +43,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Boolisches Objekt erwartet" IDS_JSCRIPT_EXPECTED "JScript Objekt erwartet" IDS_REGEXP_SYNTAX_ERROR "Syntax Fehler in regulärem Ausdruck" + IDS_URI_INVALID_CHAR "Zu verschlüsselnde URI enthält ungültige Zeichen" IDS_INVALID_LENGTH "Array-Größe muss eine endliche, positive Ganzzahl sein" IDS_ARRAY_EXPECTED "Array Objekt erwartet" } diff --git a/dll/win32/jscript/jscript_En.rc b/dll/win32/jscript/jscript_En.rc index 14be9bddbde..bd3c09d2a5d 100644 --- a/dll/win32/jscript/jscript_En.rc +++ b/dll/win32/jscript/jscript_En.rc @@ -41,6 +41,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Boolean object expected" IDS_JSCRIPT_EXPECTED "JScript object expected" IDS_REGEXP_SYNTAX_ERROR "Syntax error in regular expression" + IDS_URI_INVALID_CHAR "URI to be encoded contains invalid characters" IDS_INVALID_LENGTH "Array length must be a finite positive integer" IDS_ARRAY_EXPECTED "Array object expected" } diff --git a/dll/win32/jscript/jscript_Fr.rc b/dll/win32/jscript/jscript_Fr.rc index 8c23e412c40..f70029db13f 100644 --- a/dll/win32/jscript/jscript_Fr.rc +++ b/dll/win32/jscript/jscript_Fr.rc @@ -46,6 +46,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Objet booléen attendu" IDS_JSCRIPT_EXPECTED "Objet JScript attendu" IDS_REGEXP_SYNTAX_ERROR "Erreur de syntaxe dans l'expression rationnelle" + IDS_URI_INVALID_CHAR "L'URI à coder contient des caractères invalides" IDS_INVALID_LENGTH "La longueur d'un tableau doit être un entier positif" IDS_ARRAY_EXPECTED "Objet tableau attendu" } diff --git a/dll/win32/jscript/jscript_Ko.rc b/dll/win32/jscript/jscript_Ko.rc new file mode 100644 index 00000000000..164d6beb128 --- /dev/null +++ b/dll/win32/jscript/jscript_Ko.rc @@ -0,0 +1,51 @@ +/* + * Copyright 2009 Piotr Caban + * Copyright 2010 YunSong Hwang + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_TO_PRIMITIVE "객페를 기본 형식으로 변환하는 중에 에러 발생" + IDS_INVALID_CALL_ARG "올바르지 않은 프로시져 호출이나 인수" + IDS_CREATE_OBJ_ERROR "자동화 서버가 객체를 만들 수 없습니다" + IDS_NO_PROPERTY "객체는 이 속성이나 메소드를 지원하지 않습니다" + IDS_ARG_NOT_OPT "인수는 옵션이 아닙니다" + IDS_SYNTAX_ERROR "문법 에러" + IDS_SEMICOLON "';' 가 필요합니다" + IDS_LBRACKET "'(' 가 필요합니다" + IDS_RBRACKET "')' 가 필요합니다" + IDS_UNTERMINATED_STR "띁나지 않은 문자열 상수" + IDS_NOT_FUNC "함수가 필요합니다" + IDS_NOT_DATE "'[객체]' 는 날짜 객체가 아닙니다" + IDS_NOT_NUM "숫자가 필요합니다" + IDS_OBJECT_EXPECTED "객체가 필요합니다" + IDS_ILLEGAL_ASSIGN "잘못된 할당" + IDS_UNDEFINED "'|' 는 정의되지 않았습니다" + IDS_NOT_BOOL "볼린 객제가 필요합니다" + IDS_JSCRIPT_EXPECTED "JScript 객체가 필요합니다" + IDS_REGEXP_SYNTAX_ERROR "정규 표현식에 문법에러가 있습니다" + IDS_URI_INVALID_CHAR "URI 는 올바르지 않은 문자를 포함해서 인코딩되었습니다" + IDS_INVALID_LENGTH "배열 길이는 반드시 한정된 양의 정수이어야 합니다" + IDS_ARRAY_EXPECTED "배열 객체가 필요합니다" +} diff --git a/dll/win32/jscript/jscript_Lt.rc b/dll/win32/jscript/jscript_Lt.rc index 4d3989574fd..a7b451eb8c9 100644 --- a/dll/win32/jscript/jscript_Lt.rc +++ b/dll/win32/jscript/jscript_Lt.rc @@ -44,6 +44,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Tikėtasi loginio objekto" IDS_JSCRIPT_EXPECTED "Tikėtasi JScript objekto" IDS_REGEXP_SYNTAX_ERROR "Sintaksės klaida reguliariajame reiškinyje" + IDS_URI_INVALID_CHAR "Koduotiname URI yra netinkamų simbolių" IDS_INVALID_LENGTH "Masyvo dydis turi būti teigiamas sveikasis skaičius" IDS_ARRAY_EXPECTED "Tikėtasi masyvo objekto" } diff --git a/dll/win32/jscript/jscript_Ru.rc b/dll/win32/jscript/jscript_Ru.rc new file mode 100644 index 00000000000..9632d3f3693 --- /dev/null +++ b/dll/win32/jscript/jscript_Ru.rc @@ -0,0 +1,50 @@ +/* + * Copyright 2009 Vladimir Pankratov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_TO_PRIMITIVE "Ошибка конвертирования объекта в примитивный тип" + IDS_INVALID_CALL_ARG "Неверный вызов процедуры или аргумент" + IDS_CREATE_OBJ_ERROR "Сервер автоматизации не может создать объект" + IDS_NO_PROPERTY "Объект не поддерживает это свойство или метод" + IDS_ARG_NOT_OPT "Отсутствует обязательный аргумент" + IDS_SYNTAX_ERROR "Синтаксическая ошибка" + IDS_SEMICOLON "Ожидается ';'" + IDS_LBRACKET "Ожидается '('" + IDS_RBRACKET "Ожидается ')'" + IDS_UNTERMINATED_STR "Незавершённая строковая константа" + IDS_NOT_FUNC "Ожидается функция" + IDS_NOT_DATE "'[object]' не объект типа 'date'" + IDS_NOT_NUM "Ожидается число" + IDS_OBJECT_EXPECTED "Ожидается объект" + IDS_ILLEGAL_ASSIGN "Неверное присваивание" + IDS_UNDEFINED "'|' не определён" + IDS_NOT_BOOL "Ожидается объект типа 'bool'" + IDS_JSCRIPT_EXPECTED "Ожидается объект типа 'JScript'" + IDS_REGEXP_SYNTAX_ERROR "Синтаксическая ошибка в регулярном выражении" + IDS_URI_INVALID_CHAR "URI содержит неверные символы" + IDS_INVALID_LENGTH "Длиной массива должно быть конечное положительное число" + IDS_ARRAY_EXPECTED "Ожидается объект типа 'Array'" +} diff --git a/dll/win32/jscript/jsutils.c b/dll/win32/jscript/jsutils.c index 80cce597481..9e49cc7b8a3 100644 --- a/dll/win32/jscript/jsutils.c +++ b/dll/win32/jscript/jsutils.c @@ -449,10 +449,14 @@ HRESULT to_integer(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret) if(FAILED(hres)) return hres; - if(V_VT(&num) == VT_I4) + if(V_VT(&num) == VT_I4) { *ret = num; - else + }else if(isnan(V_R8(&num))) { + V_VT(ret) = VT_I4; + V_I4(ret) = 0; + }else { num_set_val(ret, V_R8(&num) >= 0.0 ? floor(V_R8(&num)) : -floor(-V_R8(&num))); + } return S_OK; } @@ -467,7 +471,10 @@ HRESULT to_int32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, INT *ret) if(FAILED(hres)) return hres; - *ret = V_VT(&num) == VT_I4 ? V_I4(&num) : (INT)V_R8(&num); + if(V_VT(&num) == VT_I4) + *ret = V_I4(&num); + else + *ret = isnan(V_R8(&num)) || isinf(V_R8(&num)) ? 0 : (INT)V_R8(&num); return S_OK; } @@ -481,7 +488,10 @@ HRESULT to_uint32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, DWORD *ret) if(FAILED(hres)) return hres; - *ret = V_VT(&num) == VT_I4 ? V_I4(&num) : (DWORD)V_R8(&num); + if(V_VT(&num) == VT_I4) + *ret = V_I4(&num); + else + *ret = isnan(V_R8(&num)) || isinf(V_R8(&num)) ? 0 : (DWORD)V_R8(&num); return S_OK; } diff --git a/dll/win32/jscript/lex.c b/dll/win32/jscript/lex.c index 43089d3e210..2e79db9878a 100644 --- a/dll/win32/jscript/lex.c +++ b/dll/win32/jscript/lex.c @@ -91,7 +91,6 @@ static const struct { {trueW, kTRUE}, {tryW, kTRY}, {typeofW, kTYPEOF}, - {undefinedW, kUNDEFINED}, {varW, kVAR}, {voidW, kVOID}, {whileW, kWHILE}, @@ -369,7 +368,7 @@ static literal_t *alloc_int_literal(parser_ctx_t *ctx, LONG l) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_I4; + ret->type = LT_INT; ret->u.lval = l; return ret; @@ -447,7 +446,7 @@ static int parse_double_literal(parser_ctx_t *ctx, LONG int_part, literal_t **li } *literal = parser_alloc(ctx, sizeof(literal_t)); - (*literal)->vt = VT_R8; + (*literal)->type = LT_DOUBLE; (*literal)->u.dval = (double)d*pow(10, exp); return tNumericLiteral; @@ -755,21 +754,11 @@ int parser_lex(void *lval, parser_ctx_t *ctx) return 0; } -static void add_object_literal(parser_ctx_t *ctx, DispatchEx *obj) -{ - obj_literal_t *literal = parser_alloc(ctx, sizeof(obj_literal_t)); - - literal->obj = obj; - literal->next = ctx->obj_literals; - ctx->obj_literals = literal; -} - literal_t *parse_regexp(parser_ctx_t *ctx) { - const WCHAR *re, *flags; - DispatchEx *regexp; + const WCHAR *re, *flags_ptr; + DWORD re_len, flags; literal_t *ret; - DWORD re_len; HRESULT hres; TRACE("\n"); @@ -790,18 +779,18 @@ literal_t *parse_regexp(parser_ctx_t *ctx) re_len = ctx->ptr-re; - flags = ++ctx->ptr; + flags_ptr = ++ctx->ptr; while(ctx->ptr < ctx->end && isalnumW(*ctx->ptr)) ctx->ptr++; - hres = create_regexp_str(ctx->script, re, re_len, flags, ctx->ptr-flags, ®exp); + hres = parse_regexp_flags(flags_ptr, ctx->ptr-flags_ptr, &flags); if(FAILED(hres)) return NULL; - add_object_literal(ctx, regexp); - ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_DISPATCH; - ret->u.disp = (IDispatch*)_IDispatchEx_(regexp); + ret->type = LT_REGEXP; + ret->u.regexp.str = re; + ret->u.regexp.str_len = re_len; + ret->u.regexp.flags = flags; return ret; } diff --git a/dll/win32/jscript/number.c b/dll/win32/jscript/number.c index 757316cee86..00de9abba85 100644 --- a/dll/win32/jscript/number.c +++ b/dll/win32/jscript/number.c @@ -346,7 +346,8 @@ HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Di return hres; V_VT(&number->num) = VT_I4; - hres = create_builtin_function(ctx, NumberConstr_value, NumberW, NULL, PROPF_CONSTR, &number->dispex, ret); + hres = create_builtin_function(ctx, NumberConstr_value, NumberW, NULL, + PROPF_CONSTR|1, &number->dispex, ret); jsdisp_release(&number->dispex); return hres; diff --git a/dll/win32/jscript/parser.tab.c b/dll/win32/jscript/parser.tab.c index 3262aa07a8d..e3307bdbec6 100644 --- a/dll/win32/jscript/parser.tab.c +++ b/dll/win32/jscript/parser.tab.c @@ -99,7 +99,6 @@ typedef struct _statement_list_t { static literal_t *new_string_literal(parser_ctx_t*,const WCHAR*); static literal_t *new_null_literal(parser_ctx_t*); -static literal_t *new_undefined_literal(parser_ctx_t*); static literal_t *new_boolean_literal(parser_ctx_t*,VARIANT_BOOL); typedef struct _property_list_t { @@ -207,7 +206,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state /* Line 189 of yacc.c */ -#line 211 "parser.tab.c" +#line 210 "parser.tab.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -249,34 +248,33 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state kINSTANCEOF = 270, kNEW = 271, kNULL = 272, - kUNDEFINED = 273, - kRETURN = 274, - kSWITCH = 275, - kTHIS = 276, - kTHROW = 277, - kTRUE = 278, - kFALSE = 279, - kTRY = 280, - kTYPEOF = 281, - kVAR = 282, - kVOID = 283, - kWHILE = 284, - kWITH = 285, - tANDAND = 286, - tOROR = 287, - tINC = 288, - tDEC = 289, - tHTMLCOMMENT = 290, - kDIVEQ = 291, - kFUNCTION = 292, - tIdentifier = 293, - tAssignOper = 294, - tEqOper = 295, - tShiftOper = 296, - tRelOper = 297, - tNumericLiteral = 298, - tStringLiteral = 299, - LOWER_THAN_ELSE = 300 + kRETURN = 273, + kSWITCH = 274, + kTHIS = 275, + kTHROW = 276, + kTRUE = 277, + kFALSE = 278, + kTRY = 279, + kTYPEOF = 280, + kVAR = 281, + kVOID = 282, + kWHILE = 283, + kWITH = 284, + tANDAND = 285, + tOROR = 286, + tINC = 287, + tDEC = 288, + tHTMLCOMMENT = 289, + kDIVEQ = 290, + kFUNCTION = 291, + tIdentifier = 292, + tAssignOper = 293, + tEqOper = 294, + tShiftOper = 295, + tRelOper = 296, + tNumericLiteral = 297, + tStringLiteral = 298, + LOWER_THAN_ELSE = 299 }; #endif @@ -287,7 +285,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c */ -#line 151 "parser.y" +#line 150 "parser.y" int ival; const WCHAR *srcptr; @@ -311,7 +309,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 315 "parser.tab.c" +#line 313 "parser.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -323,7 +321,7 @@ typedef union YYSTYPE /* Line 264 of yacc.c */ -#line 327 "parser.tab.c" +#line 325 "parser.tab.c" #ifdef short # undef short @@ -538,20 +536,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1042 +#define YYLAST 1030 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 68 +#define YYNTOKENS 67 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 95 /* YYNRULES -- Number of rules. */ -#define YYNRULES 215 +#define YYNRULES 214 /* YYNRULES -- Number of states. */ -#define YYNSTATES 374 +#define YYNSTATES 373 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 300 +#define YYMAXUTOK 299 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -562,16 +560,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 62, 2, 2, 2, 60, 55, 2, - 66, 67, 58, 56, 48, 57, 65, 59, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 51, 50, - 2, 49, 2, 52, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 61, 2, 2, 2, 59, 54, 2, + 65, 66, 57, 55, 47, 56, 64, 58, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 50, 49, + 2, 48, 2, 51, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 63, 2, 64, 54, 2, 2, 2, 2, 2, + 2, 62, 2, 63, 53, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 47, 53, 38, 61, 2, 2, 2, + 2, 2, 2, 46, 52, 37, 60, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -588,8 +586,7 @@ static const yytype_uint8 yytranslate[] = 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, - 46 + 35, 36, 38, 39, 40, 41, 42, 43, 44, 45 }; #if YYDEBUG @@ -618,105 +615,105 @@ static const yytype_uint16 yyprhs[] = 567, 570, 574, 578, 584, 587, 592, 594, 597, 598, 600, 603, 607, 611, 617, 619, 621, 623, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, - 648, 650, 652, 654, 656, 658 + 648, 650, 652, 654, 656 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 69, 0, -1, 71, 70, -1, 35, -1, -1, -1, - 71, 77, -1, 73, 156, 160, 76, 161, 47, 74, - 38, -1, 37, -1, 71, -1, 39, -1, 75, 48, - 39, -1, -1, 75, -1, 80, -1, 81, -1, 90, - -1, 72, -1, 91, -1, 92, -1, 93, -1, 98, - -1, 99, -1, 100, -1, 101, -1, 102, -1, 103, - -1, 109, -1, 110, -1, 77, -1, 78, 77, -1, - -1, 78, -1, 47, 78, 38, -1, 47, 38, -1, - 27, 82, 159, -1, 84, -1, 82, 48, 84, -1, - 85, -1, 83, 48, 85, -1, 39, 86, -1, 39, - 88, -1, -1, 87, -1, 49, 119, -1, -1, 89, - -1, 49, 120, -1, 50, -1, 115, 159, -1, 11, - 160, 114, 161, 77, 10, 77, -1, 11, 160, 114, - 161, 77, -1, 9, 77, 29, 160, 114, 161, 159, - -1, 29, 160, 114, 161, 77, -1, -1, -1, 13, - 160, 116, 94, 162, 113, 95, 162, 113, 161, 77, - -1, -1, -1, 13, 160, 27, 83, 96, 162, 113, - 97, 162, 113, 161, 77, -1, 13, 160, 142, 14, - 114, 161, 77, -1, 13, 160, 27, 85, 14, 114, - 161, 77, -1, 6, 156, 159, -1, 3, 156, 159, - -1, 19, 113, 159, -1, 30, 160, 115, 161, 77, - -1, 39, 51, 77, -1, 20, 160, 115, 161, 104, - -1, 47, 105, 38, -1, 47, 105, 108, 105, 38, - -1, -1, 106, -1, 107, -1, 106, 107, -1, 4, - 115, 51, 79, -1, 7, 51, 79, -1, 22, 115, - 159, -1, 25, 80, 111, -1, 25, 80, 112, -1, - 25, 80, 111, 112, -1, 5, 160, 39, 161, 80, - -1, 12, 80, -1, -1, 115, -1, 115, -1, 1, - -1, 119, -1, 115, 48, 119, -1, -1, 117, -1, - 120, -1, 117, 48, 120, -1, 40, -1, 36, -1, - 121, -1, 142, 49, 119, -1, 142, 118, 119, -1, - 122, -1, 142, 49, 120, -1, 142, 118, 120, -1, - 123, -1, 123, 52, 119, 51, 119, -1, 124, -1, - 124, 52, 120, 51, 120, -1, 125, -1, 123, 32, - 125, -1, 126, -1, 124, 32, 126, -1, 127, -1, - 125, 31, 127, -1, 128, -1, 126, 31, 128, -1, - 129, -1, 127, 53, 129, -1, 130, -1, 128, 53, - 130, -1, 131, -1, 129, 54, 131, -1, 132, -1, - 130, 54, 132, -1, 133, -1, 131, 55, 133, -1, - 134, -1, 132, 55, 134, -1, 135, -1, 133, 41, - 135, -1, 136, -1, 134, 41, 136, -1, 137, -1, - 135, 43, 137, -1, 135, 15, 137, -1, 135, 14, - 137, -1, 137, -1, 136, 43, 137, -1, 136, 15, - 137, -1, 138, -1, 137, 42, 138, -1, 139, -1, - 138, 56, 139, -1, 138, 57, 139, -1, 140, -1, - 139, 58, 140, -1, 139, 59, 140, -1, 139, 60, - 140, -1, 141, -1, 8, 140, -1, 28, 140, -1, - 26, 140, -1, 33, 140, -1, 34, 140, -1, 56, - 140, -1, 57, 140, -1, 61, 140, -1, 62, 140, - -1, 142, -1, 142, 33, -1, 142, 34, -1, 143, - -1, 145, -1, 144, -1, 16, 143, -1, 148, -1, - 72, -1, 144, 63, 115, 64, -1, 144, 65, 39, - -1, 16, 144, 146, -1, 144, 146, -1, 145, 146, - -1, 145, 63, 115, 64, -1, 145, 65, 39, -1, - 66, 67, -1, 66, 147, 67, -1, 119, -1, 147, - 48, 119, -1, 21, -1, 39, -1, 157, -1, 149, - -1, 153, -1, 66, 115, 67, -1, 63, 64, -1, - 63, 151, 64, -1, 63, 150, 64, -1, 63, 150, - 48, 152, 64, -1, 152, 119, -1, 150, 48, 152, - 119, -1, 48, -1, 151, 48, -1, -1, 151, -1, - 47, 38, -1, 47, 154, 38, -1, 155, 51, 119, - -1, 154, 48, 155, 51, 119, -1, 39, -1, 45, - -1, 44, -1, -1, 39, -1, 17, -1, 18, -1, - 158, -1, 44, -1, 45, -1, 59, -1, 36, -1, - 23, -1, 24, -1, 50, -1, 1, -1, 66, -1, - 1, -1, 67, -1, 1, -1, 50, -1, 1, -1 + 68, 0, -1, 70, 69, -1, 34, -1, -1, -1, + 70, 76, -1, 72, 155, 159, 75, 160, 46, 73, + 37, -1, 36, -1, 70, -1, 38, -1, 74, 47, + 38, -1, -1, 74, -1, 79, -1, 80, -1, 89, + -1, 71, -1, 90, -1, 91, -1, 92, -1, 97, + -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, + -1, 108, -1, 109, -1, 76, -1, 77, 76, -1, + -1, 77, -1, 46, 77, 37, -1, 46, 37, -1, + 26, 81, 158, -1, 83, -1, 81, 47, 83, -1, + 84, -1, 82, 47, 84, -1, 38, 85, -1, 38, + 87, -1, -1, 86, -1, 48, 118, -1, -1, 88, + -1, 48, 119, -1, 49, -1, 114, 158, -1, 11, + 159, 113, 160, 76, 10, 76, -1, 11, 159, 113, + 160, 76, -1, 9, 76, 28, 159, 113, 160, 158, + -1, 28, 159, 113, 160, 76, -1, -1, -1, 13, + 159, 115, 93, 161, 112, 94, 161, 112, 160, 76, + -1, -1, -1, 13, 159, 26, 82, 95, 161, 112, + 96, 161, 112, 160, 76, -1, 13, 159, 141, 14, + 113, 160, 76, -1, 13, 159, 26, 84, 14, 113, + 160, 76, -1, 6, 155, 158, -1, 3, 155, 158, + -1, 18, 112, 158, -1, 29, 159, 114, 160, 76, + -1, 38, 50, 76, -1, 19, 159, 114, 160, 103, + -1, 46, 104, 37, -1, 46, 104, 107, 104, 37, + -1, -1, 105, -1, 106, -1, 105, 106, -1, 4, + 114, 50, 78, -1, 7, 50, 78, -1, 21, 114, + 158, -1, 24, 79, 110, -1, 24, 79, 111, -1, + 24, 79, 110, 111, -1, 5, 159, 38, 160, 79, + -1, 12, 79, -1, -1, 114, -1, 114, -1, 1, + -1, 118, -1, 114, 47, 118, -1, -1, 116, -1, + 119, -1, 116, 47, 119, -1, 39, -1, 35, -1, + 120, -1, 141, 48, 118, -1, 141, 117, 118, -1, + 121, -1, 141, 48, 119, -1, 141, 117, 119, -1, + 122, -1, 122, 51, 118, 50, 118, -1, 123, -1, + 123, 51, 119, 50, 119, -1, 124, -1, 122, 31, + 124, -1, 125, -1, 123, 31, 125, -1, 126, -1, + 124, 30, 126, -1, 127, -1, 125, 30, 127, -1, + 128, -1, 126, 52, 128, -1, 129, -1, 127, 52, + 129, -1, 130, -1, 128, 53, 130, -1, 131, -1, + 129, 53, 131, -1, 132, -1, 130, 54, 132, -1, + 133, -1, 131, 54, 133, -1, 134, -1, 132, 40, + 134, -1, 135, -1, 133, 40, 135, -1, 136, -1, + 134, 42, 136, -1, 134, 15, 136, -1, 134, 14, + 136, -1, 136, -1, 135, 42, 136, -1, 135, 15, + 136, -1, 137, -1, 136, 41, 137, -1, 138, -1, + 137, 55, 138, -1, 137, 56, 138, -1, 139, -1, + 138, 57, 139, -1, 138, 58, 139, -1, 138, 59, + 139, -1, 140, -1, 8, 139, -1, 27, 139, -1, + 25, 139, -1, 32, 139, -1, 33, 139, -1, 55, + 139, -1, 56, 139, -1, 60, 139, -1, 61, 139, + -1, 141, -1, 141, 32, -1, 141, 33, -1, 142, + -1, 144, -1, 143, -1, 16, 142, -1, 147, -1, + 71, -1, 143, 62, 114, 63, -1, 143, 64, 38, + -1, 16, 143, 145, -1, 143, 145, -1, 144, 145, + -1, 144, 62, 114, 63, -1, 144, 64, 38, -1, + 65, 66, -1, 65, 146, 66, -1, 118, -1, 146, + 47, 118, -1, 20, -1, 38, -1, 156, -1, 148, + -1, 152, -1, 65, 114, 66, -1, 62, 63, -1, + 62, 150, 63, -1, 62, 149, 63, -1, 62, 149, + 47, 151, 63, -1, 151, 118, -1, 149, 47, 151, + 118, -1, 47, -1, 150, 47, -1, -1, 150, -1, + 46, 37, -1, 46, 153, 37, -1, 154, 50, 118, + -1, 153, 47, 154, 50, 118, -1, 38, -1, 44, + -1, 43, -1, -1, 38, -1, 17, -1, 157, -1, + 43, -1, 44, -1, 58, -1, 35, -1, 22, -1, + 23, -1, 49, -1, 1, -1, 65, -1, 1, -1, + 66, -1, 1, -1, 49, -1, 1, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 257, 257, 261, 262, 266, 267, 272, 276, 280, - 284, 285, 290, 291, 295, 296, 297, 298, 299, 300, - 301, 302, 303, 304, 305, 306, 307, 308, 309, 313, - 314, 319, 320, 324, 325, 329, 334, 335, 340, 342, - 347, 352, 357, 358, 362, 367, 368, 372, 377, 381, - 386, 388, 393, 395, 398, 400, 397, 404, 406, 403, - 409, 411, 416, 421, 426, 431, 436, 441, 446, 448, - 453, 454, 458, 459, 464, 469, 474, 479, 480, 481, - 486, 491, 495, 496, 499, 500, 504, 505, 510, 511, - 515, 517, 521, 522, 526, 527, 529, 534, 536, 538, - 543, 544, 549, 551, 556, 557, 562, 564, 569, 570, - 575, 577, 582, 583, 588, 590, 595, 596, 601, 603, - 608, 609, 614, 616, 621, 622, 627, 628, 633, 634, - 636, 638, 643, 644, 646, 651, 652, 657, 659, 661, - 666, 667, 669, 671, 676, 677, 679, 680, 682, 683, - 684, 685, 686, 687, 691, 693, 695, 701, 702, 706, - 707, 711, 712, 713, 715, 717, 722, 724, 726, 728, - 733, 734, 738, 739, 744, 745, 746, 747, 748, 749, - 753, 754, 755, 756, 761, 763, 768, 769, 773, 774, - 778, 779, 784, 786, 791, 792, 793, 797, 798, 802, - 803, 804, 805, 806, 807, 809, 814, 815, 818, 819, - 822, 823, 826, 827, 830, 831 + 0, 256, 256, 260, 261, 265, 266, 271, 275, 279, + 283, 284, 289, 290, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 312, + 313, 318, 319, 323, 324, 328, 333, 334, 339, 341, + 346, 351, 356, 357, 361, 366, 367, 371, 376, 380, + 385, 387, 392, 394, 397, 399, 396, 403, 405, 402, + 408, 410, 415, 420, 425, 430, 435, 440, 445, 447, + 452, 453, 457, 458, 463, 468, 473, 478, 479, 480, + 485, 490, 494, 495, 498, 499, 503, 504, 509, 510, + 514, 516, 520, 521, 525, 526, 528, 533, 535, 537, + 542, 543, 548, 550, 555, 556, 561, 563, 568, 569, + 574, 576, 581, 582, 587, 589, 594, 595, 600, 602, + 607, 608, 613, 615, 620, 621, 626, 627, 632, 633, + 635, 637, 642, 643, 645, 650, 651, 656, 658, 660, + 665, 666, 668, 670, 675, 676, 678, 679, 681, 682, + 683, 684, 685, 686, 690, 692, 694, 700, 701, 705, + 706, 710, 711, 712, 714, 716, 721, 723, 725, 727, + 732, 733, 737, 738, 743, 744, 745, 746, 747, 748, + 752, 753, 754, 755, 760, 762, 767, 768, 772, 773, + 777, 778, 783, 785, 790, 791, 792, 796, 797, 801, + 802, 803, 804, 805, 807, 812, 813, 816, 817, 820, + 821, 824, 825, 828, 829 }; #endif @@ -727,10 +724,10 @@ static const char *const yytname[] = { "$end", "error", "$undefined", "kBREAK", "kCASE", "kCATCH", "kCONTINUE", "kDEFAULT", "kDELETE", "kDO", "kELSE", "kIF", "kFINALLY", "kFOR", "kIN", - "kINSTANCEOF", "kNEW", "kNULL", "kUNDEFINED", "kRETURN", "kSWITCH", - "kTHIS", "kTHROW", "kTRUE", "kFALSE", "kTRY", "kTYPEOF", "kVAR", "kVOID", - "kWHILE", "kWITH", "tANDAND", "tOROR", "tINC", "tDEC", "tHTMLCOMMENT", - "kDIVEQ", "kFUNCTION", "'}'", "tIdentifier", "tAssignOper", "tEqOper", + "kINSTANCEOF", "kNEW", "kNULL", "kRETURN", "kSWITCH", "kTHIS", "kTHROW", + "kTRUE", "kFALSE", "kTRY", "kTYPEOF", "kVAR", "kVOID", "kWHILE", "kWITH", + "tANDAND", "tOROR", "tINC", "tDEC", "tHTMLCOMMENT", "kDIVEQ", + "kFUNCTION", "'}'", "tIdentifier", "tAssignOper", "tEqOper", "tShiftOper", "tRelOper", "tNumericLiteral", "tStringLiteral", "LOWER_THAN_ELSE", "'{'", "','", "'='", "';'", "':'", "'?'", "'|'", "'^'", "'&'", "'+'", "'-'", "'*'", "'/'", "'%'", "'~'", "'!'", "'['", @@ -775,38 +772,38 @@ static const yytype_uint16 yytoknum[] = 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 125, 293, - 294, 295, 296, 297, 298, 299, 300, 123, 44, 61, - 59, 58, 63, 124, 94, 38, 43, 45, 42, 47, - 37, 126, 33, 91, 93, 46, 40, 41 + 285, 286, 287, 288, 289, 290, 291, 125, 292, 293, + 294, 295, 296, 297, 298, 299, 123, 44, 61, 59, + 58, 63, 124, 94, 38, 43, 45, 42, 47, 37, + 126, 33, 91, 93, 46, 40, 41 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 68, 69, 70, 70, 71, 71, 72, 73, 74, - 75, 75, 76, 76, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 78, - 78, 79, 79, 80, 80, 81, 82, 82, 83, 83, - 84, 85, 86, 86, 87, 88, 88, 89, 90, 91, - 92, 92, 93, 93, 94, 95, 93, 96, 97, 93, - 93, 93, 98, 99, 100, 101, 102, 103, 104, 104, - 105, 105, 106, 106, 107, 108, 109, 110, 110, 110, - 111, 112, 113, 113, 114, 114, 115, 115, 116, 116, - 117, 117, 118, 118, 119, 119, 119, 120, 120, 120, - 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, - 126, 126, 127, 127, 128, 128, 129, 129, 130, 130, - 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, - 135, 135, 136, 136, 136, 137, 137, 138, 138, 138, - 139, 139, 139, 139, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 141, 141, 141, 142, 142, 143, - 143, 144, 144, 144, 144, 144, 145, 145, 145, 145, - 146, 146, 147, 147, 148, 148, 148, 148, 148, 148, - 149, 149, 149, 149, 150, 150, 151, 151, 152, 152, - 153, 153, 154, 154, 155, 155, 155, 156, 156, 157, - 157, 157, 157, 157, 157, 157, 158, 158, 159, 159, - 160, 160, 161, 161, 162, 162 + 0, 67, 68, 69, 69, 70, 70, 71, 72, 73, + 74, 74, 75, 75, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 77, + 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, + 83, 84, 85, 85, 86, 87, 87, 88, 89, 90, + 91, 91, 92, 92, 93, 94, 92, 95, 96, 92, + 92, 92, 97, 98, 99, 100, 101, 102, 103, 103, + 104, 104, 105, 105, 106, 107, 108, 109, 109, 109, + 110, 111, 112, 112, 113, 113, 114, 114, 115, 115, + 116, 116, 117, 117, 118, 118, 118, 119, 119, 119, + 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, + 125, 125, 126, 126, 127, 127, 128, 128, 129, 129, + 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, + 134, 134, 135, 135, 135, 136, 136, 137, 137, 137, + 138, 138, 138, 138, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 140, 140, 140, 141, 141, 142, + 142, 143, 143, 143, 143, 143, 144, 144, 144, 144, + 145, 145, 146, 146, 147, 147, 147, 147, 147, 147, + 148, 148, 148, 148, 149, 149, 150, 150, 151, 151, + 152, 152, 153, 153, 154, 154, 154, 155, 155, 156, + 156, 156, 156, 156, 156, 157, 157, 158, 158, 159, + 159, 160, 160, 161, 161 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -833,7 +830,7 @@ static const yytype_uint8 yyr2[] = 2, 3, 3, 5, 2, 4, 1, 2, 0, 1, 2, 3, 3, 5, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -842,118 +839,118 @@ static const yytype_uint8 yyr2[] = static const yytype_uint8 yydefact[] = { 5, 0, 4, 1, 197, 197, 0, 0, 0, 0, - 0, 199, 200, 82, 0, 174, 0, 206, 207, 0, - 0, 0, 0, 0, 0, 0, 0, 3, 205, 8, - 175, 202, 203, 0, 48, 0, 0, 204, 0, 0, - 188, 0, 2, 17, 197, 6, 14, 15, 16, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 0, 86, 94, 100, 104, 108, 112, 116, 120, 124, - 128, 135, 137, 140, 144, 154, 157, 159, 158, 161, - 177, 178, 176, 201, 198, 0, 0, 175, 0, 162, - 145, 154, 0, 211, 210, 0, 88, 160, 159, 0, - 83, 0, 0, 0, 0, 147, 42, 0, 36, 146, - 0, 0, 148, 149, 0, 34, 175, 202, 203, 29, - 0, 0, 0, 150, 151, 152, 153, 186, 180, 0, - 189, 0, 0, 0, 209, 0, 208, 49, 0, 0, + 0, 199, 82, 0, 174, 0, 205, 206, 0, 0, + 0, 0, 0, 0, 0, 0, 3, 204, 8, 175, + 201, 202, 0, 48, 0, 0, 203, 0, 0, 188, + 0, 2, 17, 197, 6, 14, 15, 16, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, + 86, 94, 100, 104, 108, 112, 116, 120, 124, 128, + 135, 137, 140, 144, 154, 157, 159, 158, 161, 177, + 178, 176, 200, 198, 0, 0, 175, 0, 162, 145, + 154, 0, 210, 209, 0, 88, 160, 159, 0, 83, + 0, 0, 0, 0, 147, 42, 0, 36, 146, 0, + 0, 148, 149, 0, 34, 175, 201, 202, 29, 0, + 0, 0, 150, 151, 152, 153, 186, 180, 0, 189, + 0, 0, 0, 208, 0, 207, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 155, 156, 93, 92, 0, 0, - 0, 0, 0, 166, 0, 0, 167, 63, 62, 190, - 194, 196, 195, 0, 85, 0, 84, 0, 54, 89, - 90, 97, 102, 106, 110, 114, 118, 122, 126, 132, - 154, 165, 64, 0, 76, 34, 0, 0, 77, 78, - 0, 40, 43, 0, 35, 0, 0, 66, 33, 30, - 191, 0, 0, 188, 182, 187, 181, 184, 179, 12, - 87, 105, 0, 109, 113, 117, 121, 125, 131, 130, - 129, 136, 138, 139, 141, 142, 143, 95, 96, 0, - 164, 170, 172, 0, 0, 169, 0, 213, 212, 0, - 45, 57, 38, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, - 79, 44, 37, 0, 0, 0, 192, 189, 0, 10, - 13, 0, 0, 163, 0, 171, 168, 0, 51, 0, - 41, 46, 0, 0, 0, 215, 214, 82, 91, 154, - 107, 0, 111, 115, 119, 123, 127, 134, 133, 0, - 98, 99, 70, 67, 0, 53, 65, 0, 183, 185, - 0, 0, 101, 173, 0, 0, 47, 39, 82, 0, - 55, 0, 0, 0, 0, 71, 72, 0, 193, 11, - 5, 52, 50, 58, 0, 0, 103, 60, 0, 0, - 68, 70, 73, 80, 9, 0, 0, 61, 82, 31, - 31, 0, 7, 82, 0, 32, 74, 75, 69, 0, - 0, 0, 56, 59 + 0, 0, 0, 155, 156, 93, 92, 0, 0, 0, + 0, 0, 166, 0, 0, 167, 63, 62, 190, 194, + 196, 195, 0, 85, 0, 84, 0, 54, 89, 90, + 97, 102, 106, 110, 114, 118, 122, 126, 132, 154, + 165, 64, 0, 76, 34, 0, 0, 77, 78, 0, + 40, 43, 0, 35, 0, 0, 66, 33, 30, 191, + 0, 0, 188, 182, 187, 181, 184, 179, 12, 87, + 105, 0, 109, 113, 117, 121, 125, 131, 130, 129, + 136, 138, 139, 141, 142, 143, 95, 96, 0, 164, + 170, 172, 0, 0, 169, 0, 212, 211, 0, 45, + 57, 38, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 81, 79, + 44, 37, 0, 0, 0, 192, 189, 0, 10, 13, + 0, 0, 163, 0, 171, 168, 0, 51, 0, 41, + 46, 0, 0, 0, 214, 213, 82, 91, 154, 107, + 0, 111, 115, 119, 123, 127, 134, 133, 0, 98, + 99, 70, 67, 0, 53, 65, 0, 183, 185, 0, + 0, 101, 173, 0, 0, 47, 39, 82, 0, 55, + 0, 0, 0, 0, 71, 72, 0, 193, 11, 5, + 52, 50, 58, 0, 0, 103, 60, 0, 0, 68, + 70, 73, 80, 9, 0, 0, 61, 82, 31, 31, + 0, 7, 82, 0, 32, 74, 75, 69, 0, 0, + 0, 56, 59 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 42, 2, 89, 44, 355, 280, 281, 119, - 120, 366, 46, 47, 107, 251, 108, 252, 201, 202, - 290, 291, 48, 49, 50, 51, 253, 345, 293, 356, - 52, 53, 54, 55, 56, 57, 313, 334, 335, 336, - 351, 58, 59, 198, 199, 99, 175, 60, 178, 179, - 266, 61, 180, 62, 181, 63, 182, 64, 183, 65, - 184, 66, 185, 67, 186, 68, 187, 69, 188, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 163, 243, - 79, 80, 129, 130, 131, 81, 121, 122, 85, 82, - 83, 137, 95, 249, 297 + -1, 1, 41, 2, 88, 43, 354, 279, 280, 118, + 119, 365, 45, 46, 106, 250, 107, 251, 200, 201, + 289, 290, 47, 48, 49, 50, 252, 344, 292, 355, + 51, 52, 53, 54, 55, 56, 312, 333, 334, 335, + 350, 57, 58, 197, 198, 98, 174, 59, 177, 178, + 265, 60, 179, 61, 180, 62, 181, 63, 182, 64, + 183, 65, 184, 66, 185, 67, 186, 68, 187, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 162, 242, + 78, 79, 128, 129, 130, 80, 120, 121, 84, 81, + 82, 136, 94, 248, 296 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -273 +#define YYPACT_NINF -287 static const yytype_int16 yypact[] = { - -273, 19, 524, -273, -7, -7, 976, 768, 12, 12, - 192, -273, -273, 976, 12, -273, 976, -273, -273, 57, - 976, 24, 976, 12, 12, 976, 976, -273, -273, -273, - -3, -273, -273, 585, -273, 976, 976, -273, 976, 976, - 22, 976, -273, 416, -7, -273, -273, -273, -273, -273, - -273, -273, -273, -273, -273, -273, -273, -273, -273, -273, - 40, -273, -273, 8, 30, 49, 54, 61, 84, 21, - 96, 155, 83, -273, -273, 88, -273, 99, 140, -273, - -273, -273, -273, -273, -273, 17, 17, -273, 115, -273, - -273, 184, 118, -273, -273, 379, 872, -273, 99, 17, - 107, 976, 40, 646, 134, -273, 109, 55, -273, -273, - 379, 976, -273, -273, 768, 471, -3, 119, 121, -273, - 707, 58, 153, -273, -273, -273, -273, -273, -273, 45, - 59, 976, -45, 12, -273, 976, -273, -273, 976, 976, - 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - 976, 976, 976, 976, -273, -273, -273, -273, 976, 976, - 976, 127, 820, -273, 976, 168, -273, -273, -273, -273, - -273, -273, -273, 12, -273, 7, 107, 175, -273, 171, - -273, -273, 14, 194, 174, 176, 177, 197, 34, 96, - 77, -273, -273, 9, -273, -273, 12, 57, 221, -273, - 976, -273, -273, 24, -273, 7, 9, -273, -273, -273, - -273, 112, 976, 187, -273, -273, -273, -273, -273, 203, - -273, 30, 193, 49, 54, 61, 84, 21, 96, 96, - 96, 155, 83, 83, -273, -273, -273, -273, -273, 67, - -273, -273, -273, 27, 71, -273, 379, -273, -273, 768, - 196, 195, 232, 37, 976, 976, 976, 976, 976, 976, - 976, 976, 976, 976, 379, 976, 976, 207, 217, -273, - -273, -273, -273, 768, 768, 206, -273, 211, 924, -273, - 212, 7, 976, -273, 976, -273, -273, 7, 251, 976, - -273, -273, 175, 37, 379, -273, -273, 976, -273, 100, - 194, 213, 174, 176, 177, 197, 34, 96, 96, 7, - -273, -273, 258, -273, 7, -273, -273, 976, -273, -273, - 224, 219, -273, -273, 17, 768, -273, -273, 976, 7, - -273, 976, 768, 976, 16, 258, -273, 57, -273, -273, - -273, -273, -273, -273, 768, 37, -273, -273, 79, 216, - -273, 258, -273, -273, 768, 231, 37, -273, 976, 768, - 768, 237, -273, 976, 7, 768, -273, -273, -273, 7, - 768, 768, -273, -273 + -287, 29, 490, -287, -18, -18, 934, 730, 21, 21, + 965, -287, 934, 21, -287, 934, -287, -287, 36, 934, + 89, 934, 21, 21, 934, 934, -287, -287, -287, 105, + -287, -287, 550, -287, 934, 934, -287, 934, 934, 61, + 934, -287, 403, -18, -287, -287, -287, -287, -287, -287, + -287, -287, -287, -287, -287, -287, -287, -287, -287, 15, + -287, -287, 41, 106, 117, 129, 142, 158, 76, 162, + 131, 47, -287, -287, 141, -287, 113, 148, -287, -287, + -287, -287, -287, -287, 5, 5, -287, 147, -287, -287, + 169, 177, -287, -287, 370, 832, -287, 113, 5, 164, + 934, 15, 610, 123, -287, 159, 16, -287, -287, 370, + 934, -287, -287, 730, 438, 105, 175, 176, -287, 670, + 86, 178, -287, -287, -287, -287, -287, -287, 62, 63, + 934, 28, 21, -287, 934, -287, -287, 934, 934, 934, + 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, -287, -287, -287, -287, 934, 934, 934, + 181, 781, -287, 934, 189, -287, -287, -287, -287, -287, + -287, -287, 21, -287, 8, 164, 191, -287, 183, -287, + -287, 56, 201, 180, 182, 179, 194, 53, 162, 10, + -287, -287, 12, -287, -287, 21, 36, 225, -287, 934, + -287, -287, 89, -287, 8, 12, -287, -287, -287, -287, + 94, 934, 193, -287, -287, -287, -287, -287, 200, -287, + 106, 192, 117, 129, 142, 158, 76, 162, 162, 162, + 131, 47, 47, -287, -287, -287, -287, -287, 68, -287, + -287, -287, 46, 109, -287, 370, -287, -287, 730, 195, + 197, 227, 18, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, 370, 934, 934, 199, 209, -287, -287, + -287, -287, 730, 730, 202, -287, 204, 883, -287, 206, + 8, 934, -287, 934, -287, -287, 8, 239, 934, -287, + -287, 191, 18, 370, -287, -287, 934, -287, 160, 201, + 218, 180, 182, 179, 194, 53, 162, 162, 8, -287, + -287, 250, -287, 8, -287, -287, 934, -287, -287, 231, + 228, -287, -287, 5, 730, -287, -287, 934, 8, -287, + 934, 730, 934, 66, 250, -287, 36, -287, -287, -287, + -287, -287, -287, 730, 18, -287, -287, -32, 226, -287, + 250, -287, -287, 730, 238, 18, -287, 934, 730, 730, + 240, -287, 934, 8, 730, -287, -287, -287, 8, 730, + 730, -287, -287 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -273, -273, -273, -70, -2, -273, -273, -273, -273, 0, - -138, -84, -10, -273, -273, -273, 74, -14, -273, -273, - -273, -273, -273, -273, -273, -273, -273, -273, -273, -273, - -273, -273, -273, -273, -273, -273, -273, -72, -273, -55, - -273, -273, -273, -273, 85, -263, -96, -12, -273, -273, - 209, -115, -239, -273, -273, -273, -273, 143, 31, 157, - 43, 160, 44, 162, 46, 163, 47, 165, 50, -66, - 164, 91, 353, -273, 33, 300, 303, -273, -16, -273, - -273, -273, -273, 101, 102, -273, -273, 106, 1, -273, - -273, -74, 28, -61, -272 + -287, -287, -287, -61, -2, -287, -287, -287, -287, 0, + -141, -80, -15, -287, -287, -287, 78, -10, -287, -287, + -287, -287, -287, -287, -287, -287, -287, -287, -287, -287, + -287, -287, -287, -287, -287, -287, -287, -68, -287, -50, + -287, -287, -287, -287, 88, -286, -105, 20, -287, -287, + 212, -77, -209, -287, -287, -287, -287, 150, 34, 152, + 33, 153, 35, 154, 38, 156, 40, 151, 42, -94, + 157, 75, 64, -287, 2, 290, 291, -287, 19, -287, + -287, -287, -287, 93, 95, -287, -287, 96, 26, -287, + -287, -73, 25, 17, -278 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -963,264 +960,262 @@ static const yytype_int16 yypgoto[] = #define YYTABLE_NINF -197 static const yytype_int16 yytable[] = { - 43, 100, 45, 135, 102, 43, 86, 92, 247, 104, - 247, 167, 168, 93, 205, 298, 217, 301, 134, 3, - 220, 328, 218, 349, 222, 192, 310, 311, 194, 132, - 189, 43, 84, 204, 330, 145, 146, 96, 295, 91, - 138, 134, 101, 237, 238, 133, 255, 242, 114, 262, - 326, 110, 111, 91, 350, 91, 134, 135, 91, 91, - 139, 140, 166, 106, 147, 343, 256, 136, 91, 91, - 127, 91, 91, 358, 248, 284, 248, 263, 94, 228, - 229, 230, 191, 176, 363, 271, 128, 296, 135, 193, - 136, 264, 346, 213, 285, 364, 210, 276, 176, 206, - 369, 43, 141, 203, 103, 136, 211, 215, 142, 214, - 154, 155, 43, 156, 207, 135, 143, 157, 43, 135, - 209, 154, 155, 216, 156, 144, 265, 135, 157, 190, - 359, 283, 267, 154, 155, 286, 156, 158, 148, 196, - 157, 151, 152, 153, 273, 274, 197, 173, 239, 265, - 287, 170, 244, 169, 170, 135, 171, 172, 200, 171, - 172, 219, 160, 319, 161, 162, 240, 322, 309, 323, - -196, 91, -195, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 269, 189, 189, - 189, 189, 189, 189, 189, 189, 307, 308, 329, 189, - 189, 246, 338, 164, 212, 165, 162, 245, 10, 11, - 12, 149, 150, 15, 250, 17, 18, 154, 155, 254, - 321, 365, 365, 189, 268, 257, 324, 258, 28, 29, - 259, 87, 260, 197, 176, 127, 31, 32, 261, 88, - 232, 233, 279, 292, 282, 289, 294, 43, 332, 288, - 341, 37, 176, 337, 312, 40, 314, 317, 41, 215, - 320, 325, 333, 339, 331, 189, 340, 360, 344, 362, - 354, 43, 43, 315, 316, 368, 367, 272, 327, 361, - 352, 221, 176, 270, 159, 100, 300, 299, 91, 299, - 91, 91, 91, 91, 91, 91, 91, 223, 299, 299, - 302, 224, 303, 370, 225, 304, 226, 305, 371, 227, - 97, 306, 231, 98, 277, 278, 100, 275, 0, 0, - 0, 348, 299, 43, 0, 342, 0, 353, 0, 0, - 43, 0, 347, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 43, 0, 357, 0, 100, 0, 0, 0, - 0, 100, 43, 0, 45, 0, 0, 43, 43, 90, - 0, 0, 0, 43, 299, 209, 0, 0, 43, 43, - 372, 373, 0, 105, 0, 109, 0, 0, 112, 113, - 174, 0, 0, 0, 0, 0, 0, 6, 123, 124, - 0, 125, 126, 0, 0, 10, 11, 12, 0, 0, - 15, 0, 17, 18, 0, 20, 0, 22, 0, 0, - 0, 0, 25, 26, 0, 28, 29, -162, 87, 0, - 0, 0, 0, 31, 32, 0, 88, 0, 0, 0, - -162, -162, 0, 0, 0, 35, 36, 0, 37, 0, - 38, 39, 40, 0, 0, 41, 0, -162, -162, 0, - 0, 0, 0, 0, 0, 0, -162, -162, -162, -162, - 0, 0, 0, 0, -162, -162, 0, 0, -162, -162, - -162, -162, -190, 0, -162, 0, -162, 0, 0, 0, - 0, -162, 0, 0, 0, -190, -190, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -190, -190, 234, 235, 236, 0, 0, 0, - 0, -190, -190, -190, -190, 0, 0, 0, 0, -190, - -190, 0, 0, -190, -190, -190, -190, 4, 0, -190, - 5, -190, 6, 7, 0, 8, -190, 9, 0, 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 0, 0, 25, 26, 27, - 28, 29, 0, 30, 0, 0, 0, 0, 31, 32, - 0, 33, 0, 0, 34, 0, 0, 0, 0, 0, - 35, 36, 0, 37, 0, 38, 39, 40, 4, 0, - 41, 5, 0, 6, 7, 0, 8, 0, 9, 0, - 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 0, 0, 25, 26, - 0, 28, 29, 115, 116, 0, 0, 0, 0, 117, - 118, 0, 33, 0, 0, 34, 0, 0, 0, 0, - 0, 35, 36, 0, 37, 0, 38, 39, 40, 4, - 0, 41, 5, 0, 6, 7, 0, 8, 0, 9, - 0, 0, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 0, 0, 25, - 26, 0, 28, 29, 195, 30, 0, 0, 0, 0, - 31, 32, 0, 33, 0, 0, 34, 0, 0, 0, - 0, 0, 35, 36, 0, 37, 0, 38, 39, 40, - 4, 0, 41, 5, 0, 6, 7, 0, 8, 0, - 9, 0, 0, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 0, 0, - 25, 26, 0, 28, 29, 208, 30, 0, 0, 0, - 0, 31, 32, 0, 33, 0, 0, 34, 0, 0, - 0, 0, 0, 35, 36, 0, 37, 0, 38, 39, - 40, 4, 0, 41, 5, 0, 6, 7, 0, 8, - 0, 9, 0, 0, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, - 0, 25, 26, 0, 28, 29, 0, 30, 0, 0, - 0, 0, 31, 32, 0, 33, 0, 0, 34, 0, - 0, 0, 0, 0, 35, 36, 0, 37, 6, 38, - 39, 40, 0, 0, 41, 0, 10, 11, 12, 0, - 0, 15, 0, 17, 18, 0, 20, 0, 22, 0, - 0, 0, 0, 25, 26, 0, 28, 29, 0, 87, - 0, 0, 0, 0, 31, 32, 0, 88, 0, 0, - 0, 0, 0, 0, 0, 0, 35, 36, 0, 37, - 6, 38, 39, 40, 0, 0, 41, 241, 10, 11, - 12, 0, 0, 15, 0, 17, 18, 0, 20, 177, - 22, 0, 0, 0, 0, 25, 26, 0, 28, 29, - 0, 87, 0, 0, 0, 0, 31, 32, 0, 88, - 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, - 0, 37, 6, 38, 39, 40, 0, 0, 41, 0, - 10, 11, 12, 0, 0, 15, 0, 17, 18, 0, - 20, 0, 22, 0, 0, 0, 0, 25, 26, 0, - 28, 29, 0, 87, 0, 0, 0, 0, 31, 32, - 0, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 35, 36, 0, 37, 6, 38, 39, 40, 318, 0, - 41, 0, 10, 11, 12, 0, 0, 15, 0, 17, - 18, 0, 20, 0, 22, 0, 0, 0, 0, 25, - 26, 0, 28, 29, 0, 87, 0, 0, 0, 0, - 31, 32, 0, 88, 0, 0, 0, 0, 0, 0, - 0, 0, 35, 36, 0, 37, 0, 38, 39, 40, - 0, 0, 41 + 42, 188, 44, 103, 204, 42, 133, 91, 90, 246, + 329, 166, 167, 246, 327, 134, 133, 133, 358, 294, + 83, 90, 92, 90, 263, 191, 90, 90, 193, 3, + 42, 85, 99, 203, 95, 101, 90, 90, 100, 90, + 90, 342, 153, 154, 297, 155, 300, 109, 110, 156, + 227, 228, 229, 216, 135, 309, 310, 219, 264, 134, + 131, 221, 134, 202, 135, 135, 357, 295, 261, 132, + 89, 363, 137, 348, 247, 134, 368, 362, 247, 325, + 236, 237, 102, 104, 241, 108, 93, 254, 111, 112, + 144, 145, 138, 283, 217, 262, 165, 189, 122, 123, + 42, 124, 125, 349, 150, 151, 152, 255, 126, 212, + 214, 42, 284, 206, 175, 134, 190, 42, 146, 208, + 192, 345, 270, 209, 127, 213, 215, 105, 195, 175, + 205, 282, 169, 210, 275, 196, 139, 170, 171, 90, + 286, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 113, 134, 218, 308, 188, + 188, 188, 188, 188, 188, 188, 188, 306, 307, 140, + 188, 188, 285, 153, 154, 159, 155, 160, 161, 238, + 156, 268, 141, 243, 168, 169, 148, 149, 328, 157, + 170, 171, 153, 154, 188, 155, 142, 245, 143, 156, + 318, 153, 154, 147, 321, 172, 322, 199, 264, 266, + 163, 134, 164, 161, 233, 234, 235, 364, 364, 239, + 267, 272, 273, 231, 232, -196, -195, 244, 211, 249, + 253, 256, 257, 259, 260, 258, 188, 196, 278, 337, + 126, 293, 281, 288, 291, 311, 42, 313, 287, 324, + 340, 214, 316, 319, 332, 298, 90, 298, 90, 90, + 90, 90, 90, 90, 90, 175, 298, 298, 330, 338, + 42, 42, 314, 315, 339, 361, 359, 367, 353, 366, + 271, 326, 360, 175, 351, 269, 158, 220, 299, 301, + 298, 222, 302, 223, 226, 224, 303, 320, 225, 304, + 96, 97, 305, 323, 230, 276, 274, 277, 0, 0, + 0, 0, 0, 175, 0, 0, 99, 0, 0, 0, + 0, 352, 42, 0, 341, 331, 0, 0, 0, 42, + 336, 346, 298, 0, 0, 0, 0, 0, 0, 0, + 0, 42, 0, 356, 0, 343, 0, 99, 0, 0, + 0, 42, 347, 44, 0, 0, 42, 42, 0, 0, + 0, 0, 42, 0, 208, 0, 0, 42, 42, 371, + 372, 173, 0, 0, 0, 0, 0, 99, 6, 0, + 369, 0, 99, 0, 0, 370, 10, 11, 0, 0, + 14, 0, 16, 17, 0, 19, 0, 21, 0, 0, + 0, 0, 24, 25, -162, 27, 28, 0, 86, 0, + 0, 0, 0, 30, 31, 0, 87, -162, -162, 0, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, -162, -162, 40, 0, 0, 0, -190, + 0, 0, -162, -162, -162, -162, 0, 0, 0, 0, + -162, -162, -190, -190, -162, -162, -162, -162, 0, 0, + -162, 0, -162, 0, 0, 0, 0, -162, -190, -190, + 0, 0, 0, 0, 0, 0, 0, -190, -190, -190, + -190, 0, 0, 0, 0, -190, -190, 0, 0, -190, + -190, -190, -190, 4, 0, -190, 5, -190, 6, 7, + 0, 8, -190, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 26, 27, 28, 0, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 114, 115, 0, + 0, 0, 0, 116, 117, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 194, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 207, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 0, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 6, + 37, 38, 39, 0, 0, 40, 0, 10, 11, 0, + 0, 14, 0, 16, 17, 0, 19, 0, 21, 0, + 0, 0, 0, 24, 25, 0, 27, 28, 0, 86, + 0, 0, 0, 0, 30, 31, 0, 87, 0, 0, + 0, 0, 0, 0, 0, 0, 34, 35, 0, 36, + 6, 37, 38, 39, 0, 0, 40, 240, 10, 11, + 0, 0, 14, 0, 16, 17, 0, 19, 176, 21, + 0, 0, 0, 0, 24, 25, 0, 27, 28, 0, + 86, 0, 0, 0, 0, 30, 31, 0, 87, 0, + 0, 0, 0, 0, 0, 0, 0, 34, 35, 0, + 36, 6, 37, 38, 39, 0, 0, 40, 0, 10, + 11, 0, 0, 14, 0, 16, 17, 0, 19, 0, + 21, 0, 0, 0, 0, 24, 25, 0, 27, 28, + 0, 86, 0, 0, 0, 0, 30, 31, 0, 87, + 0, 0, 0, 0, 0, 0, 0, 0, 34, 35, + 0, 36, 6, 37, 38, 39, 317, 0, 40, 0, + 10, 11, 0, 0, 14, 0, 16, 17, 0, 19, + 0, 21, 0, 0, 0, 0, 24, 25, 0, 27, + 28, 0, 86, 0, 0, 0, 0, 30, 31, 0, + 87, 10, 11, 0, 0, 14, 0, 16, 17, 34, + 35, 0, 36, 0, 37, 38, 39, 0, 0, 40, + 27, 28, 0, 86, 0, 0, 0, 0, 30, 31, + 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 36, 0, 0, 0, 39, 0, 0, + 40 }; static const yytype_int16 yycheck[] = { - 2, 13, 2, 48, 16, 7, 5, 7, 1, 19, - 1, 85, 86, 1, 110, 254, 131, 256, 1, 0, - 135, 293, 67, 7, 139, 99, 265, 266, 102, 41, - 96, 33, 39, 107, 297, 14, 15, 9, 1, 6, - 32, 1, 14, 158, 159, 44, 32, 162, 51, 15, - 289, 23, 24, 20, 38, 22, 1, 48, 25, 26, - 52, 31, 78, 39, 43, 328, 52, 50, 35, 36, - 48, 38, 39, 345, 67, 48, 67, 43, 66, 145, - 146, 147, 98, 95, 356, 200, 64, 50, 48, 101, - 50, 14, 331, 48, 67, 358, 38, 212, 110, 111, - 363, 103, 53, 48, 47, 50, 48, 48, 54, 64, - 33, 34, 114, 36, 114, 48, 55, 40, 120, 48, - 120, 33, 34, 64, 36, 41, 49, 48, 40, 96, - 51, 64, 193, 33, 34, 64, 36, 49, 42, 5, - 40, 58, 59, 60, 205, 206, 12, 29, 160, 49, - 246, 39, 164, 38, 39, 48, 44, 45, 49, 44, - 45, 133, 63, 278, 65, 66, 39, 282, 264, 284, - 51, 138, 51, 140, 141, 142, 143, 144, 145, 146, - 147, 148, 149, 150, 151, 152, 153, 197, 254, 255, - 256, 257, 258, 259, 260, 261, 262, 263, 294, 265, - 266, 173, 317, 63, 51, 65, 66, 39, 16, 17, - 18, 56, 57, 21, 39, 23, 24, 33, 34, 48, - 281, 359, 360, 289, 196, 31, 287, 53, 36, 37, - 54, 39, 55, 12, 246, 48, 44, 45, 41, 47, - 149, 150, 39, 48, 51, 49, 14, 249, 309, 249, - 324, 59, 264, 314, 47, 63, 39, 51, 66, 48, - 48, 10, 4, 39, 51, 331, 47, 51, 329, 38, - 340, 273, 274, 273, 274, 38, 360, 203, 292, 351, - 335, 138, 294, 198, 75, 297, 255, 254, 255, 256, - 257, 258, 259, 260, 261, 262, 263, 140, 265, 266, - 257, 141, 258, 364, 142, 259, 143, 260, 369, 144, - 10, 261, 148, 10, 213, 213, 328, 211, -1, -1, - -1, 333, 289, 325, -1, 325, -1, 337, -1, -1, - 332, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 344, -1, 344, -1, 358, -1, -1, -1, - -1, 363, 354, -1, 354, -1, -1, 359, 360, 6, - -1, -1, -1, 365, 331, 365, -1, -1, 370, 371, - 370, 371, -1, 20, -1, 22, -1, -1, 25, 26, - 1, -1, -1, -1, -1, -1, -1, 8, 35, 36, - -1, 38, 39, -1, -1, 16, 17, 18, -1, -1, - 21, -1, 23, 24, -1, 26, -1, 28, -1, -1, - -1, -1, 33, 34, -1, 36, 37, 1, 39, -1, - -1, -1, -1, 44, 45, -1, 47, -1, -1, -1, - 14, 15, -1, -1, -1, 56, 57, -1, 59, -1, - 61, 62, 63, -1, -1, 66, -1, 31, 32, -1, - -1, -1, -1, -1, -1, -1, 40, 41, 42, 43, - -1, -1, -1, -1, 48, 49, -1, -1, 52, 53, - 54, 55, 1, -1, 58, -1, 60, -1, -1, -1, - -1, 65, -1, -1, -1, 14, 15, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 31, 32, 151, 152, 153, -1, -1, -1, - -1, 40, 41, 42, 43, -1, -1, -1, -1, 48, - 49, -1, -1, 52, 53, 54, 55, 3, -1, 58, - 6, 60, 8, 9, -1, 11, 65, 13, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, -1, -1, 33, 34, 35, - 36, 37, -1, 39, -1, -1, -1, -1, 44, 45, - -1, 47, -1, -1, 50, -1, -1, -1, -1, -1, - 56, 57, -1, 59, -1, 61, 62, 63, 3, -1, - 66, 6, -1, 8, 9, -1, 11, -1, 13, -1, - -1, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, -1, -1, 33, 34, - -1, 36, 37, 38, 39, -1, -1, -1, -1, 44, - 45, -1, 47, -1, -1, 50, -1, -1, -1, -1, - -1, 56, 57, -1, 59, -1, 61, 62, 63, 3, - -1, 66, 6, -1, 8, 9, -1, 11, -1, 13, - -1, -1, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, -1, -1, 33, - 34, -1, 36, 37, 38, 39, -1, -1, -1, -1, - 44, 45, -1, 47, -1, -1, 50, -1, -1, -1, - -1, -1, 56, 57, -1, 59, -1, 61, 62, 63, - 3, -1, 66, 6, -1, 8, 9, -1, 11, -1, - 13, -1, -1, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, -1, -1, - 33, 34, -1, 36, 37, 38, 39, -1, -1, -1, - -1, 44, 45, -1, 47, -1, -1, 50, -1, -1, - -1, -1, -1, 56, 57, -1, 59, -1, 61, 62, - 63, 3, -1, 66, 6, -1, 8, 9, -1, 11, - -1, 13, -1, -1, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, -1, - -1, 33, 34, -1, 36, 37, -1, 39, -1, -1, - -1, -1, 44, 45, -1, 47, -1, -1, 50, -1, - -1, -1, -1, -1, 56, 57, -1, 59, 8, 61, - 62, 63, -1, -1, 66, -1, 16, 17, 18, -1, - -1, 21, -1, 23, 24, -1, 26, -1, 28, -1, - -1, -1, -1, 33, 34, -1, 36, 37, -1, 39, - -1, -1, -1, -1, 44, 45, -1, 47, -1, -1, - -1, -1, -1, -1, -1, -1, 56, 57, -1, 59, - 8, 61, 62, 63, -1, -1, 66, 67, 16, 17, - 18, -1, -1, 21, -1, 23, 24, -1, 26, 27, - 28, -1, -1, -1, -1, 33, 34, -1, 36, 37, - -1, 39, -1, -1, -1, -1, 44, 45, -1, 47, - -1, -1, -1, -1, -1, -1, -1, -1, 56, 57, - -1, 59, 8, 61, 62, 63, -1, -1, 66, -1, - 16, 17, 18, -1, -1, 21, -1, 23, 24, -1, - 26, -1, 28, -1, -1, -1, -1, 33, 34, -1, - 36, 37, -1, 39, -1, -1, -1, -1, 44, 45, - -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, - 56, 57, -1, 59, 8, 61, 62, 63, 64, -1, - 66, -1, 16, 17, 18, -1, -1, 21, -1, 23, - 24, -1, 26, -1, 28, -1, -1, -1, -1, 33, - 34, -1, 36, 37, -1, 39, -1, -1, -1, -1, - 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, - -1, -1, 56, 57, -1, 59, -1, 61, 62, 63, - -1, -1, 66 + 2, 95, 2, 18, 109, 7, 1, 7, 6, 1, + 296, 84, 85, 1, 292, 47, 1, 1, 50, 1, + 38, 19, 1, 21, 14, 98, 24, 25, 101, 0, + 32, 5, 12, 106, 9, 15, 34, 35, 13, 37, + 38, 327, 32, 33, 253, 35, 255, 22, 23, 39, + 144, 145, 146, 130, 49, 264, 265, 134, 48, 47, + 40, 138, 47, 47, 49, 49, 344, 49, 15, 43, + 6, 357, 31, 7, 66, 47, 362, 355, 66, 288, + 157, 158, 46, 19, 161, 21, 65, 31, 24, 25, + 14, 15, 51, 47, 66, 42, 77, 95, 34, 35, + 102, 37, 38, 37, 57, 58, 59, 51, 47, 47, + 47, 113, 66, 113, 94, 47, 97, 119, 42, 119, + 100, 330, 199, 37, 63, 63, 63, 38, 5, 109, + 110, 63, 38, 47, 211, 12, 30, 43, 44, 137, + 245, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 152, 50, 47, 132, 263, 253, + 254, 255, 256, 257, 258, 259, 260, 261, 262, 52, + 264, 265, 63, 32, 33, 62, 35, 64, 65, 159, + 39, 196, 53, 163, 37, 38, 55, 56, 293, 48, + 43, 44, 32, 33, 288, 35, 54, 172, 40, 39, + 277, 32, 33, 41, 281, 28, 283, 48, 48, 192, + 62, 47, 64, 65, 150, 151, 152, 358, 359, 38, + 195, 204, 205, 148, 149, 50, 50, 38, 50, 38, + 47, 30, 52, 54, 40, 53, 330, 12, 38, 316, + 47, 14, 50, 48, 47, 46, 248, 38, 248, 10, + 323, 47, 50, 47, 4, 253, 254, 255, 256, 257, + 258, 259, 260, 261, 262, 245, 264, 265, 50, 38, + 272, 273, 272, 273, 46, 37, 50, 37, 339, 359, + 202, 291, 350, 263, 334, 197, 74, 137, 254, 256, + 288, 139, 257, 140, 143, 141, 258, 280, 142, 259, + 10, 10, 260, 286, 147, 212, 210, 212, -1, -1, + -1, -1, -1, 293, -1, -1, 296, -1, -1, -1, + -1, 336, 324, -1, 324, 308, -1, -1, -1, 331, + 313, 331, 330, -1, -1, -1, -1, -1, -1, -1, + -1, 343, -1, 343, -1, 328, -1, 327, -1, -1, + -1, 353, 332, 353, -1, -1, 358, 359, -1, -1, + -1, -1, 364, -1, 364, -1, -1, 369, 370, 369, + 370, 1, -1, -1, -1, -1, -1, 357, 8, -1, + 363, -1, 362, -1, -1, 368, 16, 17, -1, -1, + 20, -1, 22, 23, -1, 25, -1, 27, -1, -1, + -1, -1, 32, 33, 1, 35, 36, -1, 38, -1, + -1, -1, -1, 43, 44, -1, 46, 14, 15, -1, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 30, 31, 65, -1, -1, -1, 1, + -1, -1, 39, 40, 41, 42, -1, -1, -1, -1, + 47, 48, 14, 15, 51, 52, 53, 54, -1, -1, + 57, -1, 59, -1, -1, -1, -1, 64, 30, 31, + -1, -1, -1, -1, -1, -1, -1, 39, 40, 41, + 42, -1, -1, -1, -1, 47, 48, -1, -1, 51, + 52, 53, 54, 3, -1, 57, 6, 59, 8, 9, + -1, 11, 64, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, 34, 35, 36, -1, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, 37, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, 37, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, 37, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, -1, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, 8, + 60, 61, 62, -1, -1, 65, -1, 16, 17, -1, + -1, 20, -1, 22, 23, -1, 25, -1, 27, -1, + -1, -1, -1, 32, 33, -1, 35, 36, -1, 38, + -1, -1, -1, -1, 43, 44, -1, 46, -1, -1, + -1, -1, -1, -1, -1, -1, 55, 56, -1, 58, + 8, 60, 61, 62, -1, -1, 65, 66, 16, 17, + -1, -1, 20, -1, 22, 23, -1, 25, 26, 27, + -1, -1, -1, -1, 32, 33, -1, 35, 36, -1, + 38, -1, -1, -1, -1, 43, 44, -1, 46, -1, + -1, -1, -1, -1, -1, -1, -1, 55, 56, -1, + 58, 8, 60, 61, 62, -1, -1, 65, -1, 16, + 17, -1, -1, 20, -1, 22, 23, -1, 25, -1, + 27, -1, -1, -1, -1, 32, 33, -1, 35, 36, + -1, 38, -1, -1, -1, -1, 43, 44, -1, 46, + -1, -1, -1, -1, -1, -1, -1, -1, 55, 56, + -1, 58, 8, 60, 61, 62, 63, -1, 65, -1, + 16, 17, -1, -1, 20, -1, 22, 23, -1, 25, + -1, 27, -1, -1, -1, -1, 32, 33, -1, 35, + 36, -1, 38, -1, -1, -1, -1, 43, 44, -1, + 46, 16, 17, -1, -1, 20, -1, 22, 23, 55, + 56, -1, 58, -1, 60, 61, 62, -1, -1, 65, + 35, 36, -1, 38, -1, -1, -1, -1, 43, 44, + -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 58, -1, -1, -1, 62, -1, -1, + 65 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 69, 71, 0, 3, 6, 8, 9, 11, 13, + 0, 68, 70, 0, 3, 6, 8, 9, 11, 13, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 33, 34, 35, 36, 37, - 39, 44, 45, 47, 50, 56, 57, 59, 61, 62, - 63, 66, 70, 72, 73, 77, 80, 81, 90, 91, - 92, 93, 98, 99, 100, 101, 102, 103, 109, 110, - 115, 119, 121, 123, 125, 127, 129, 131, 133, 135, - 137, 138, 139, 140, 141, 142, 143, 144, 145, 148, - 149, 153, 157, 158, 39, 156, 156, 39, 47, 72, - 140, 142, 77, 1, 66, 160, 160, 143, 144, 113, - 115, 160, 115, 47, 80, 140, 39, 82, 84, 140, - 160, 160, 140, 140, 51, 38, 39, 44, 45, 77, - 78, 154, 155, 140, 140, 140, 140, 48, 64, 150, - 151, 152, 115, 156, 1, 48, 50, 159, 32, 52, - 31, 53, 54, 55, 41, 14, 15, 43, 42, 56, - 57, 58, 59, 60, 33, 34, 36, 40, 49, 118, - 63, 65, 66, 146, 63, 65, 146, 159, 159, 38, - 39, 44, 45, 29, 1, 114, 115, 27, 116, 117, - 120, 122, 124, 126, 128, 130, 132, 134, 136, 137, - 142, 146, 159, 115, 159, 38, 5, 12, 111, 112, - 49, 86, 87, 48, 159, 114, 115, 77, 38, 77, - 38, 48, 51, 48, 64, 48, 64, 119, 67, 160, - 119, 125, 119, 127, 129, 131, 133, 135, 137, 137, - 137, 138, 139, 139, 140, 140, 140, 119, 119, 115, - 39, 67, 119, 147, 115, 39, 160, 1, 67, 161, - 39, 83, 85, 94, 48, 32, 52, 31, 53, 54, - 55, 41, 15, 43, 14, 49, 118, 161, 160, 80, - 112, 119, 84, 161, 161, 155, 119, 151, 152, 39, - 75, 76, 51, 64, 48, 67, 64, 114, 77, 49, - 88, 89, 48, 96, 14, 1, 50, 162, 120, 142, - 126, 120, 128, 130, 132, 134, 136, 137, 137, 114, - 120, 120, 47, 104, 39, 77, 77, 51, 64, 119, - 48, 161, 119, 119, 161, 10, 120, 85, 162, 114, - 113, 51, 161, 4, 105, 106, 107, 161, 119, 39, - 47, 159, 77, 113, 161, 95, 120, 77, 115, 7, - 38, 108, 107, 80, 71, 74, 97, 77, 162, 51, - 51, 105, 38, 162, 113, 78, 79, 79, 38, 113, - 161, 161, 77, 77 + 26, 27, 28, 29, 32, 33, 34, 35, 36, 38, + 43, 44, 46, 49, 55, 56, 58, 60, 61, 62, + 65, 69, 71, 72, 76, 79, 80, 89, 90, 91, + 92, 97, 98, 99, 100, 101, 102, 108, 109, 114, + 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, + 137, 138, 139, 140, 141, 142, 143, 144, 147, 148, + 152, 156, 157, 38, 155, 155, 38, 46, 71, 139, + 141, 76, 1, 65, 159, 159, 142, 143, 112, 114, + 159, 114, 46, 79, 139, 38, 81, 83, 139, 159, + 159, 139, 139, 50, 37, 38, 43, 44, 76, 77, + 153, 154, 139, 139, 139, 139, 47, 63, 149, 150, + 151, 114, 155, 1, 47, 49, 158, 31, 51, 30, + 52, 53, 54, 40, 14, 15, 42, 41, 55, 56, + 57, 58, 59, 32, 33, 35, 39, 48, 117, 62, + 64, 65, 145, 62, 64, 145, 158, 158, 37, 38, + 43, 44, 28, 1, 113, 114, 26, 115, 116, 119, + 121, 123, 125, 127, 129, 131, 133, 135, 136, 141, + 145, 158, 114, 158, 37, 5, 12, 110, 111, 48, + 85, 86, 47, 158, 113, 114, 76, 37, 76, 37, + 47, 50, 47, 63, 47, 63, 118, 66, 159, 118, + 124, 118, 126, 128, 130, 132, 134, 136, 136, 136, + 137, 138, 138, 139, 139, 139, 118, 118, 114, 38, + 66, 118, 146, 114, 38, 159, 1, 66, 160, 38, + 82, 84, 93, 47, 31, 51, 30, 52, 53, 54, + 40, 15, 42, 14, 48, 117, 160, 159, 79, 111, + 118, 83, 160, 160, 154, 118, 150, 151, 38, 74, + 75, 50, 63, 47, 66, 63, 113, 76, 48, 87, + 88, 47, 95, 14, 1, 49, 161, 119, 141, 125, + 119, 127, 129, 131, 133, 135, 136, 136, 113, 119, + 119, 46, 103, 38, 76, 76, 50, 63, 118, 47, + 160, 118, 118, 160, 10, 119, 84, 161, 113, 112, + 50, 160, 4, 104, 105, 106, 160, 118, 38, 46, + 158, 76, 112, 160, 94, 119, 76, 114, 7, 37, + 107, 106, 79, 70, 73, 96, 76, 161, 50, 50, + 104, 37, 161, 112, 77, 78, 78, 37, 112, 160, + 160, 76, 76 }; #define yyerrok (yyerrstatus = 0) @@ -2033,1415 +2028,1416 @@ yyreduce: case 2: /* Line 1455 of yacc.c */ -#line 258 "parser.y" +#line 257 "parser.y" { program_parsed(ctx, (yyvsp[(1) - (2)].source_elements)); ;} break; case 3: /* Line 1455 of yacc.c */ -#line 261 "parser.y" +#line 260 "parser.y" {;} break; case 4: /* Line 1455 of yacc.c */ -#line 262 "parser.y" +#line 261 "parser.y" {;} break; case 5: /* Line 1455 of yacc.c */ -#line 266 "parser.y" +#line 265 "parser.y" { (yyval.source_elements) = new_source_elements(ctx); ;} break; case 6: /* Line 1455 of yacc.c */ -#line 268 "parser.y" +#line 267 "parser.y" { (yyval.source_elements) = source_elements_add_statement((yyvsp[(1) - (2)].source_elements), (yyvsp[(2) - (2)].statement)); ;} break; case 7: /* Line 1455 of yacc.c */ -#line 273 "parser.y" +#line 272 "parser.y" { (yyval.expr) = new_function_expression(ctx, (yyvsp[(2) - (8)].identifier), (yyvsp[(4) - (8)].parameter_list), (yyvsp[(7) - (8)].source_elements), (yyvsp[(1) - (8)].srcptr), (yyvsp[(8) - (8)].srcptr)-(yyvsp[(1) - (8)].srcptr)+1); ;} break; case 8: /* Line 1455 of yacc.c */ -#line 276 "parser.y" +#line 275 "parser.y" { push_func(ctx); (yyval.srcptr) = (yyvsp[(1) - (1)].srcptr); ;} break; case 9: /* Line 1455 of yacc.c */ -#line 280 "parser.y" +#line 279 "parser.y" { (yyval.source_elements) = function_body_parsed(ctx, (yyvsp[(1) - (1)].source_elements)); ;} break; case 10: /* Line 1455 of yacc.c */ -#line 284 "parser.y" +#line 283 "parser.y" { (yyval.parameter_list) = new_parameter_list(ctx, (yyvsp[(1) - (1)].identifier)); ;} break; case 11: /* Line 1455 of yacc.c */ -#line 286 "parser.y" +#line 285 "parser.y" { (yyval.parameter_list) = parameter_list_add(ctx, (yyvsp[(1) - (3)].parameter_list), (yyvsp[(3) - (3)].identifier)); ;} break; case 12: /* Line 1455 of yacc.c */ -#line 290 "parser.y" +#line 289 "parser.y" { (yyval.parameter_list) = NULL; ;} break; case 13: /* Line 1455 of yacc.c */ -#line 291 "parser.y" +#line 290 "parser.y" { (yyval.parameter_list) = (yyvsp[(1) - (1)].parameter_list); ;} break; case 14: /* Line 1455 of yacc.c */ -#line 295 "parser.y" +#line 294 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 15: /* Line 1455 of yacc.c */ -#line 296 "parser.y" +#line 295 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 16: /* Line 1455 of yacc.c */ -#line 297 "parser.y" +#line 296 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 17: /* Line 1455 of yacc.c */ -#line 298 "parser.y" +#line 297 "parser.y" { (yyval.statement) = new_empty_statement(ctx); ;} break; case 18: /* Line 1455 of yacc.c */ -#line 299 "parser.y" +#line 298 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 19: /* Line 1455 of yacc.c */ -#line 300 "parser.y" +#line 299 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 20: /* Line 1455 of yacc.c */ -#line 301 "parser.y" +#line 300 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 21: /* Line 1455 of yacc.c */ -#line 302 "parser.y" +#line 301 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 22: /* Line 1455 of yacc.c */ -#line 303 "parser.y" +#line 302 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 23: /* Line 1455 of yacc.c */ -#line 304 "parser.y" +#line 303 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 24: /* Line 1455 of yacc.c */ -#line 305 "parser.y" +#line 304 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 25: /* Line 1455 of yacc.c */ -#line 306 "parser.y" +#line 305 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 26: /* Line 1455 of yacc.c */ -#line 307 "parser.y" +#line 306 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 27: /* Line 1455 of yacc.c */ -#line 308 "parser.y" +#line 307 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 28: /* Line 1455 of yacc.c */ -#line 309 "parser.y" +#line 308 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 29: /* Line 1455 of yacc.c */ -#line 313 "parser.y" +#line 312 "parser.y" { (yyval.statement_list) = new_statement_list(ctx, (yyvsp[(1) - (1)].statement)); ;} break; case 30: /* Line 1455 of yacc.c */ -#line 315 "parser.y" +#line 314 "parser.y" { (yyval.statement_list) = statement_list_add((yyvsp[(1) - (2)].statement_list), (yyvsp[(2) - (2)].statement)); ;} break; case 31: /* Line 1455 of yacc.c */ -#line 319 "parser.y" +#line 318 "parser.y" { (yyval.statement_list) = NULL; ;} break; case 32: /* Line 1455 of yacc.c */ -#line 320 "parser.y" +#line 319 "parser.y" { (yyval.statement_list) = (yyvsp[(1) - (1)].statement_list); ;} break; case 33: /* Line 1455 of yacc.c */ -#line 324 "parser.y" +#line 323 "parser.y" { (yyval.statement) = new_block_statement(ctx, (yyvsp[(2) - (3)].statement_list)); ;} break; case 34: /* Line 1455 of yacc.c */ -#line 325 "parser.y" +#line 324 "parser.y" { (yyval.statement) = new_block_statement(ctx, NULL); ;} break; case 35: /* Line 1455 of yacc.c */ -#line 330 "parser.y" +#line 329 "parser.y" { (yyval.statement) = new_var_statement(ctx, (yyvsp[(2) - (3)].variable_list)); ;} break; case 36: /* Line 1455 of yacc.c */ -#line 334 "parser.y" +#line 333 "parser.y" { (yyval.variable_list) = new_variable_list(ctx, (yyvsp[(1) - (1)].variable_declaration)); ;} break; case 37: /* Line 1455 of yacc.c */ -#line 336 "parser.y" +#line 335 "parser.y" { (yyval.variable_list) = variable_list_add(ctx, (yyvsp[(1) - (3)].variable_list), (yyvsp[(3) - (3)].variable_declaration)); ;} break; case 38: /* Line 1455 of yacc.c */ -#line 341 "parser.y" +#line 340 "parser.y" { (yyval.variable_list) = new_variable_list(ctx, (yyvsp[(1) - (1)].variable_declaration)); ;} break; case 39: /* Line 1455 of yacc.c */ -#line 343 "parser.y" +#line 342 "parser.y" { (yyval.variable_list) = variable_list_add(ctx, (yyvsp[(1) - (3)].variable_list), (yyvsp[(3) - (3)].variable_declaration)); ;} break; case 40: /* Line 1455 of yacc.c */ -#line 348 "parser.y" +#line 347 "parser.y" { (yyval.variable_declaration) = new_variable_declaration(ctx, (yyvsp[(1) - (2)].identifier), (yyvsp[(2) - (2)].expr)); ;} break; case 41: /* Line 1455 of yacc.c */ -#line 353 "parser.y" +#line 352 "parser.y" { (yyval.variable_declaration) = new_variable_declaration(ctx, (yyvsp[(1) - (2)].identifier), (yyvsp[(2) - (2)].expr)); ;} break; case 42: /* Line 1455 of yacc.c */ -#line 357 "parser.y" +#line 356 "parser.y" { (yyval.expr) = NULL; ;} break; case 43: /* Line 1455 of yacc.c */ -#line 358 "parser.y" +#line 357 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 44: /* Line 1455 of yacc.c */ -#line 363 "parser.y" +#line 362 "parser.y" { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} break; case 45: /* Line 1455 of yacc.c */ -#line 367 "parser.y" +#line 366 "parser.y" { (yyval.expr) = NULL; ;} break; case 46: /* Line 1455 of yacc.c */ -#line 368 "parser.y" +#line 367 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 47: /* Line 1455 of yacc.c */ -#line 373 "parser.y" +#line 372 "parser.y" { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} break; case 48: /* Line 1455 of yacc.c */ -#line 377 "parser.y" +#line 376 "parser.y" { (yyval.statement) = new_empty_statement(ctx); ;} break; case 49: /* Line 1455 of yacc.c */ -#line 382 "parser.y" +#line 381 "parser.y" { (yyval.statement) = new_expression_statement(ctx, (yyvsp[(1) - (2)].expr)); ;} break; case 50: /* Line 1455 of yacc.c */ -#line 387 "parser.y" +#line 386 "parser.y" { (yyval.statement) = new_if_statement(ctx, (yyvsp[(3) - (7)].expr), (yyvsp[(5) - (7)].statement), (yyvsp[(7) - (7)].statement)); ;} break; case 51: /* Line 1455 of yacc.c */ -#line 389 "parser.y" +#line 388 "parser.y" { (yyval.statement) = new_if_statement(ctx, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].statement), NULL); ;} break; case 52: /* Line 1455 of yacc.c */ -#line 394 "parser.y" +#line 393 "parser.y" { (yyval.statement) = new_while_statement(ctx, TRUE, (yyvsp[(5) - (7)].expr), (yyvsp[(2) - (7)].statement)); ;} break; case 53: /* Line 1455 of yacc.c */ -#line 396 "parser.y" +#line 395 "parser.y" { (yyval.statement) = new_while_statement(ctx, FALSE, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].statement)); ;} break; case 54: /* Line 1455 of yacc.c */ -#line 398 "parser.y" +#line 397 "parser.y" { if(!explicit_error(ctx, (yyvsp[(3) - (3)].expr), ';')) YYABORT; ;} break; case 55: /* Line 1455 of yacc.c */ -#line 400 "parser.y" +#line 399 "parser.y" { if(!explicit_error(ctx, (yyvsp[(6) - (6)].expr), ';')) YYABORT; ;} break; case 56: /* Line 1455 of yacc.c */ -#line 402 "parser.y" +#line 401 "parser.y" { (yyval.statement) = new_for_statement(ctx, NULL, (yyvsp[(3) - (11)].expr), (yyvsp[(6) - (11)].expr), (yyvsp[(9) - (11)].expr), (yyvsp[(11) - (11)].statement)); ;} break; case 57: /* Line 1455 of yacc.c */ -#line 404 "parser.y" +#line 403 "parser.y" { if(!explicit_error(ctx, (yyvsp[(4) - (4)].variable_list), ';')) YYABORT; ;} break; case 58: /* Line 1455 of yacc.c */ -#line 406 "parser.y" +#line 405 "parser.y" { if(!explicit_error(ctx, (yyvsp[(7) - (7)].expr), ';')) YYABORT; ;} break; case 59: /* Line 1455 of yacc.c */ -#line 408 "parser.y" +#line 407 "parser.y" { (yyval.statement) = new_for_statement(ctx, (yyvsp[(4) - (12)].variable_list), NULL, (yyvsp[(7) - (12)].expr), (yyvsp[(10) - (12)].expr), (yyvsp[(12) - (12)].statement)); ;} break; case 60: /* Line 1455 of yacc.c */ -#line 410 "parser.y" +#line 409 "parser.y" { (yyval.statement) = new_forin_statement(ctx, NULL, (yyvsp[(3) - (7)].expr), (yyvsp[(5) - (7)].expr), (yyvsp[(7) - (7)].statement)); ;} break; case 61: /* Line 1455 of yacc.c */ -#line 412 "parser.y" +#line 411 "parser.y" { (yyval.statement) = new_forin_statement(ctx, (yyvsp[(4) - (8)].variable_declaration), NULL, (yyvsp[(6) - (8)].expr), (yyvsp[(8) - (8)].statement)); ;} break; case 62: /* Line 1455 of yacc.c */ -#line 417 "parser.y" +#line 416 "parser.y" { (yyval.statement) = new_continue_statement(ctx, (yyvsp[(2) - (3)].identifier)); ;} break; case 63: /* Line 1455 of yacc.c */ -#line 422 "parser.y" +#line 421 "parser.y" { (yyval.statement) = new_break_statement(ctx, (yyvsp[(2) - (3)].identifier)); ;} break; case 64: /* Line 1455 of yacc.c */ -#line 427 "parser.y" +#line 426 "parser.y" { (yyval.statement) = new_return_statement(ctx, (yyvsp[(2) - (3)].expr)); ;} break; case 65: /* Line 1455 of yacc.c */ -#line 432 "parser.y" +#line 431 "parser.y" { (yyval.statement) = new_with_statement(ctx, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].statement)); ;} break; case 66: /* Line 1455 of yacc.c */ -#line 437 "parser.y" +#line 436 "parser.y" { (yyval.statement) = new_labelled_statement(ctx, (yyvsp[(1) - (3)].identifier), (yyvsp[(3) - (3)].statement)); ;} break; case 67: /* Line 1455 of yacc.c */ -#line 442 "parser.y" +#line 441 "parser.y" { (yyval.statement) = new_switch_statement(ctx, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].case_clausule)); ;} break; case 68: /* Line 1455 of yacc.c */ -#line 447 "parser.y" +#line 446 "parser.y" { (yyval.case_clausule) = new_case_block(ctx, (yyvsp[(2) - (3)].case_list), NULL, NULL); ;} break; case 69: /* Line 1455 of yacc.c */ -#line 449 "parser.y" +#line 448 "parser.y" { (yyval.case_clausule) = new_case_block(ctx, (yyvsp[(2) - (5)].case_list), (yyvsp[(3) - (5)].case_clausule), (yyvsp[(4) - (5)].case_list)); ;} break; case 70: /* Line 1455 of yacc.c */ -#line 453 "parser.y" +#line 452 "parser.y" { (yyval.case_list) = NULL; ;} break; case 71: /* Line 1455 of yacc.c */ -#line 454 "parser.y" +#line 453 "parser.y" { (yyval.case_list) = (yyvsp[(1) - (1)].case_list); ;} break; case 72: /* Line 1455 of yacc.c */ -#line 458 "parser.y" +#line 457 "parser.y" { (yyval.case_list) = new_case_list(ctx, (yyvsp[(1) - (1)].case_clausule)); ;} break; case 73: /* Line 1455 of yacc.c */ -#line 460 "parser.y" +#line 459 "parser.y" { (yyval.case_list) = case_list_add(ctx, (yyvsp[(1) - (2)].case_list), (yyvsp[(2) - (2)].case_clausule)); ;} break; case 74: /* Line 1455 of yacc.c */ -#line 465 "parser.y" +#line 464 "parser.y" { (yyval.case_clausule) = new_case_clausule(ctx, (yyvsp[(2) - (4)].expr), (yyvsp[(4) - (4)].statement_list)); ;} break; case 75: /* Line 1455 of yacc.c */ -#line 470 "parser.y" +#line 469 "parser.y" { (yyval.case_clausule) = new_case_clausule(ctx, NULL, (yyvsp[(3) - (3)].statement_list)); ;} break; case 76: /* Line 1455 of yacc.c */ -#line 475 "parser.y" +#line 474 "parser.y" { (yyval.statement) = new_throw_statement(ctx, (yyvsp[(2) - (3)].expr)); ;} break; case 77: /* Line 1455 of yacc.c */ -#line 479 "parser.y" +#line 478 "parser.y" { (yyval.statement) = new_try_statement(ctx, (yyvsp[(2) - (3)].statement), (yyvsp[(3) - (3)].catch_block), NULL); ;} break; case 78: /* Line 1455 of yacc.c */ -#line 480 "parser.y" +#line 479 "parser.y" { (yyval.statement) = new_try_statement(ctx, (yyvsp[(2) - (3)].statement), NULL, (yyvsp[(3) - (3)].statement)); ;} break; case 79: /* Line 1455 of yacc.c */ -#line 482 "parser.y" +#line 481 "parser.y" { (yyval.statement) = new_try_statement(ctx, (yyvsp[(2) - (4)].statement), (yyvsp[(3) - (4)].catch_block), (yyvsp[(4) - (4)].statement)); ;} break; case 80: /* Line 1455 of yacc.c */ -#line 487 "parser.y" +#line 486 "parser.y" { (yyval.catch_block) = new_catch_block(ctx, (yyvsp[(3) - (5)].identifier), (yyvsp[(5) - (5)].statement)); ;} break; case 81: /* Line 1455 of yacc.c */ -#line 491 "parser.y" +#line 490 "parser.y" { (yyval.statement) = (yyvsp[(2) - (2)].statement); ;} break; case 82: /* Line 1455 of yacc.c */ -#line 495 "parser.y" +#line 494 "parser.y" { (yyval.expr) = NULL; ;} break; case 83: /* Line 1455 of yacc.c */ -#line 496 "parser.y" +#line 495 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 84: /* Line 1455 of yacc.c */ -#line 499 "parser.y" +#line 498 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 85: /* Line 1455 of yacc.c */ -#line 500 "parser.y" +#line 499 "parser.y" { set_error(ctx, IDS_SYNTAX_ERROR); YYABORT; ;} break; case 86: /* Line 1455 of yacc.c */ -#line 504 "parser.y" +#line 503 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 87: /* Line 1455 of yacc.c */ -#line 506 "parser.y" +#line 505 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_COMMA, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 88: /* Line 1455 of yacc.c */ -#line 510 "parser.y" +#line 509 "parser.y" { (yyval.expr) = NULL; ;} break; case 89: /* Line 1455 of yacc.c */ -#line 511 "parser.y" +#line 510 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 90: /* Line 1455 of yacc.c */ -#line 516 "parser.y" +#line 515 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 91: /* Line 1455 of yacc.c */ -#line 518 "parser.y" +#line 517 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_COMMA, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 92: /* Line 1455 of yacc.c */ -#line 521 "parser.y" +#line 520 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} break; case 93: /* Line 1455 of yacc.c */ -#line 522 "parser.y" +#line 521 "parser.y" { (yyval.ival) = EXPR_ASSIGNDIV; ;} break; case 94: /* Line 1455 of yacc.c */ -#line 526 "parser.y" +#line 525 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 95: /* Line 1455 of yacc.c */ -#line 528 "parser.y" +#line 527 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_ASSIGN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 96: /* Line 1455 of yacc.c */ -#line 530 "parser.y" +#line 529 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 97: /* Line 1455 of yacc.c */ -#line 535 "parser.y" +#line 534 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 98: /* Line 1455 of yacc.c */ -#line 537 "parser.y" +#line 536 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_ASSIGN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 99: /* Line 1455 of yacc.c */ -#line 539 "parser.y" +#line 538 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 100: /* Line 1455 of yacc.c */ -#line 543 "parser.y" +#line 542 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 101: /* Line 1455 of yacc.c */ -#line 545 "parser.y" +#line 544 "parser.y" { (yyval.expr) = new_conditional_expression(ctx, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} break; case 102: /* Line 1455 of yacc.c */ -#line 550 "parser.y" +#line 549 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 103: /* Line 1455 of yacc.c */ -#line 552 "parser.y" +#line 551 "parser.y" { (yyval.expr) = new_conditional_expression(ctx, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} break; case 104: /* Line 1455 of yacc.c */ -#line 556 "parser.y" +#line 555 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 105: /* Line 1455 of yacc.c */ -#line 558 "parser.y" +#line 557 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 106: /* Line 1455 of yacc.c */ -#line 563 "parser.y" +#line 562 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 107: /* Line 1455 of yacc.c */ -#line 565 "parser.y" +#line 564 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 108: /* Line 1455 of yacc.c */ -#line 569 "parser.y" +#line 568 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 109: /* Line 1455 of yacc.c */ -#line 571 "parser.y" +#line 570 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 110: /* Line 1455 of yacc.c */ -#line 576 "parser.y" +#line 575 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 111: /* Line 1455 of yacc.c */ -#line 578 "parser.y" +#line 577 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 112: /* Line 1455 of yacc.c */ -#line 582 "parser.y" +#line 581 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 113: /* Line 1455 of yacc.c */ -#line 584 "parser.y" +#line 583 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 114: /* Line 1455 of yacc.c */ -#line 589 "parser.y" +#line 588 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 115: /* Line 1455 of yacc.c */ -#line 591 "parser.y" +#line 590 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 116: /* Line 1455 of yacc.c */ -#line 595 "parser.y" +#line 594 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 117: /* Line 1455 of yacc.c */ -#line 597 "parser.y" +#line 596 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BXOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 118: /* Line 1455 of yacc.c */ -#line 602 "parser.y" +#line 601 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 119: /* Line 1455 of yacc.c */ -#line 604 "parser.y" +#line 603 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BXOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 120: /* Line 1455 of yacc.c */ -#line 608 "parser.y" +#line 607 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 121: /* Line 1455 of yacc.c */ -#line 610 "parser.y" +#line 609 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 122: /* Line 1455 of yacc.c */ -#line 615 "parser.y" +#line 614 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 123: /* Line 1455 of yacc.c */ -#line 617 "parser.y" +#line 616 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 124: /* Line 1455 of yacc.c */ -#line 621 "parser.y" +#line 620 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 125: /* Line 1455 of yacc.c */ -#line 623 "parser.y" +#line 622 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 126: /* Line 1455 of yacc.c */ -#line 627 "parser.y" +#line 626 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 127: /* Line 1455 of yacc.c */ -#line 629 "parser.y" +#line 628 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 128: /* Line 1455 of yacc.c */ -#line 633 "parser.y" +#line 632 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 129: /* Line 1455 of yacc.c */ -#line 635 "parser.y" +#line 634 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 130: /* Line 1455 of yacc.c */ -#line 637 "parser.y" +#line 636 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_INSTANCEOF, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 131: /* Line 1455 of yacc.c */ -#line 639 "parser.y" +#line 638 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_IN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 132: /* Line 1455 of yacc.c */ -#line 643 "parser.y" +#line 642 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 133: /* Line 1455 of yacc.c */ -#line 645 "parser.y" +#line 644 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 134: /* Line 1455 of yacc.c */ -#line 647 "parser.y" +#line 646 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_INSTANCEOF, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 135: /* Line 1455 of yacc.c */ -#line 651 "parser.y" +#line 650 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 136: /* Line 1455 of yacc.c */ -#line 653 "parser.y" +#line 652 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 137: /* Line 1455 of yacc.c */ -#line 658 "parser.y" +#line 657 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 138: /* Line 1455 of yacc.c */ -#line 660 "parser.y" +#line 659 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_ADD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 139: /* Line 1455 of yacc.c */ -#line 662 "parser.y" +#line 661 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_SUB, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 140: /* Line 1455 of yacc.c */ -#line 666 "parser.y" +#line 665 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 141: /* Line 1455 of yacc.c */ -#line 668 "parser.y" +#line 667 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_MUL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 142: /* Line 1455 of yacc.c */ -#line 670 "parser.y" +#line 669 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_DIV, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 143: /* Line 1455 of yacc.c */ -#line 672 "parser.y" +#line 671 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_MOD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 144: /* Line 1455 of yacc.c */ -#line 676 "parser.y" +#line 675 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 145: /* Line 1455 of yacc.c */ -#line 678 "parser.y" +#line 677 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_DELETE, (yyvsp[(2) - (2)].expr)); ;} break; case 146: /* Line 1455 of yacc.c */ -#line 679 "parser.y" +#line 678 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_VOID, (yyvsp[(2) - (2)].expr)); ;} break; case 147: /* Line 1455 of yacc.c */ -#line 681 "parser.y" +#line 680 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_TYPEOF, (yyvsp[(2) - (2)].expr)); ;} break; case 148: /* Line 1455 of yacc.c */ -#line 682 "parser.y" +#line 681 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_PREINC, (yyvsp[(2) - (2)].expr)); ;} break; case 149: /* Line 1455 of yacc.c */ -#line 683 "parser.y" +#line 682 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_PREDEC, (yyvsp[(2) - (2)].expr)); ;} break; case 150: /* Line 1455 of yacc.c */ -#line 684 "parser.y" +#line 683 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_PLUS, (yyvsp[(2) - (2)].expr)); ;} break; case 151: /* Line 1455 of yacc.c */ -#line 685 "parser.y" +#line 684 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_MINUS, (yyvsp[(2) - (2)].expr)); ;} break; case 152: /* Line 1455 of yacc.c */ -#line 686 "parser.y" +#line 685 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_BITNEG, (yyvsp[(2) - (2)].expr)); ;} break; case 153: /* Line 1455 of yacc.c */ -#line 687 "parser.y" +#line 686 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_LOGNEG, (yyvsp[(2) - (2)].expr)); ;} break; case 154: /* Line 1455 of yacc.c */ -#line 692 "parser.y" +#line 691 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 155: /* Line 1455 of yacc.c */ -#line 694 "parser.y" +#line 693 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_POSTINC, (yyvsp[(1) - (2)].expr)); ;} break; case 156: /* Line 1455 of yacc.c */ -#line 696 "parser.y" +#line 695 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_POSTDEC, (yyvsp[(1) - (2)].expr)); ;} break; case 157: /* Line 1455 of yacc.c */ -#line 701 "parser.y" +#line 700 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 158: /* Line 1455 of yacc.c */ -#line 702 "parser.y" +#line 701 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 159: /* Line 1455 of yacc.c */ -#line 706 "parser.y" +#line 705 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 160: /* Line 1455 of yacc.c */ -#line 707 "parser.y" +#line 706 "parser.y" { (yyval.expr) = new_new_expression(ctx, (yyvsp[(2) - (2)].expr), NULL); ;} break; case 161: /* Line 1455 of yacc.c */ -#line 711 "parser.y" +#line 710 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 162: /* Line 1455 of yacc.c */ -#line 712 "parser.y" +#line 711 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 163: /* Line 1455 of yacc.c */ -#line 714 "parser.y" +#line 713 "parser.y" { (yyval.expr) = new_array_expression(ctx, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} break; case 164: /* Line 1455 of yacc.c */ -#line 716 "parser.y" +#line 715 "parser.y" { (yyval.expr) = new_member_expression(ctx, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].identifier)); ;} break; case 165: /* Line 1455 of yacc.c */ -#line 718 "parser.y" +#line 717 "parser.y" { (yyval.expr) = new_new_expression(ctx, (yyvsp[(2) - (3)].expr), (yyvsp[(3) - (3)].argument_list)); ;} break; case 166: /* Line 1455 of yacc.c */ -#line 723 "parser.y" +#line 722 "parser.y" { (yyval.expr) = new_call_expression(ctx, (yyvsp[(1) - (2)].expr), (yyvsp[(2) - (2)].argument_list)); ;} break; case 167: /* Line 1455 of yacc.c */ -#line 725 "parser.y" +#line 724 "parser.y" { (yyval.expr) = new_call_expression(ctx, (yyvsp[(1) - (2)].expr), (yyvsp[(2) - (2)].argument_list)); ;} break; case 168: /* Line 1455 of yacc.c */ -#line 727 "parser.y" +#line 726 "parser.y" { (yyval.expr) = new_array_expression(ctx, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} break; case 169: /* Line 1455 of yacc.c */ -#line 729 "parser.y" +#line 728 "parser.y" { (yyval.expr) = new_member_expression(ctx, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].identifier)); ;} break; case 170: /* Line 1455 of yacc.c */ -#line 733 "parser.y" +#line 732 "parser.y" { (yyval.argument_list) = NULL; ;} break; case 171: /* Line 1455 of yacc.c */ -#line 734 "parser.y" +#line 733 "parser.y" { (yyval.argument_list) = (yyvsp[(2) - (3)].argument_list); ;} break; case 172: /* Line 1455 of yacc.c */ -#line 738 "parser.y" +#line 737 "parser.y" { (yyval.argument_list) = new_argument_list(ctx, (yyvsp[(1) - (1)].expr)); ;} break; case 173: /* Line 1455 of yacc.c */ -#line 740 "parser.y" +#line 739 "parser.y" { (yyval.argument_list) = argument_list_add(ctx, (yyvsp[(1) - (3)].argument_list), (yyvsp[(3) - (3)].expr)); ;} break; case 174: /* Line 1455 of yacc.c */ -#line 744 "parser.y" +#line 743 "parser.y" { (yyval.expr) = new_this_expression(ctx); ;} break; case 175: /* Line 1455 of yacc.c */ -#line 745 "parser.y" +#line 744 "parser.y" { (yyval.expr) = new_identifier_expression(ctx, (yyvsp[(1) - (1)].identifier)); ;} break; case 176: /* Line 1455 of yacc.c */ -#line 746 "parser.y" +#line 745 "parser.y" { (yyval.expr) = new_literal_expression(ctx, (yyvsp[(1) - (1)].literal)); ;} break; case 177: /* Line 1455 of yacc.c */ -#line 747 "parser.y" +#line 746 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 178: /* Line 1455 of yacc.c */ -#line 748 "parser.y" +#line 747 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 179: /* Line 1455 of yacc.c */ -#line 749 "parser.y" +#line 748 "parser.y" { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} break; case 180: /* Line 1455 of yacc.c */ -#line 753 "parser.y" +#line 752 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, NULL, 0); ;} break; case 181: /* Line 1455 of yacc.c */ -#line 754 "parser.y" +#line 753 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, NULL, (yyvsp[(2) - (3)].ival)+1); ;} break; case 182: /* Line 1455 of yacc.c */ -#line 755 "parser.y" +#line 754 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, (yyvsp[(2) - (3)].element_list), 0); ;} break; case 183: /* Line 1455 of yacc.c */ -#line 757 "parser.y" +#line 756 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, (yyvsp[(2) - (5)].element_list), (yyvsp[(4) - (5)].ival)+1); ;} break; case 184: /* Line 1455 of yacc.c */ -#line 762 "parser.y" +#line 761 "parser.y" { (yyval.element_list) = new_element_list(ctx, (yyvsp[(1) - (2)].ival), (yyvsp[(2) - (2)].expr)); ;} break; case 185: /* Line 1455 of yacc.c */ -#line 764 "parser.y" +#line 763 "parser.y" { (yyval.element_list) = element_list_add(ctx, (yyvsp[(1) - (4)].element_list), (yyvsp[(3) - (4)].ival), (yyvsp[(4) - (4)].expr)); ;} break; case 186: /* Line 1455 of yacc.c */ -#line 768 "parser.y" +#line 767 "parser.y" { (yyval.ival) = 1; ;} break; case 187: /* Line 1455 of yacc.c */ -#line 769 "parser.y" +#line 768 "parser.y" { (yyval.ival) = (yyvsp[(1) - (2)].ival) + 1; ;} break; case 188: /* Line 1455 of yacc.c */ -#line 773 "parser.y" +#line 772 "parser.y" { (yyval.ival) = 0; ;} break; case 189: /* Line 1455 of yacc.c */ -#line 774 "parser.y" +#line 773 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} break; case 190: /* Line 1455 of yacc.c */ -#line 778 "parser.y" +#line 777 "parser.y" { (yyval.expr) = new_prop_and_value_expression(ctx, NULL); ;} break; case 191: /* Line 1455 of yacc.c */ -#line 780 "parser.y" +#line 779 "parser.y" { (yyval.expr) = new_prop_and_value_expression(ctx, (yyvsp[(2) - (3)].property_list)); ;} break; case 192: /* Line 1455 of yacc.c */ -#line 785 "parser.y" +#line 784 "parser.y" { (yyval.property_list) = new_property_list(ctx, (yyvsp[(1) - (3)].literal), (yyvsp[(3) - (3)].expr)); ;} break; case 193: /* Line 1455 of yacc.c */ -#line 787 "parser.y" +#line 786 "parser.y" { (yyval.property_list) = property_list_add(ctx, (yyvsp[(1) - (5)].property_list), (yyvsp[(3) - (5)].literal), (yyvsp[(5) - (5)].expr)); ;} break; case 194: /* Line 1455 of yacc.c */ -#line 791 "parser.y" +#line 790 "parser.y" { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].identifier)); ;} break; case 195: /* Line 1455 of yacc.c */ -#line 792 "parser.y" +#line 791 "parser.y" { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].wstr)); ;} break; case 196: /* Line 1455 of yacc.c */ -#line 793 "parser.y" +#line 792 "parser.y" { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} break; case 197: /* Line 1455 of yacc.c */ -#line 797 "parser.y" +#line 796 "parser.y" { (yyval.identifier) = NULL; ;} break; case 198: /* Line 1455 of yacc.c */ -#line 798 "parser.y" +#line 797 "parser.y" { (yyval.identifier) = (yyvsp[(1) - (1)].identifier); ;} break; case 199: /* Line 1455 of yacc.c */ -#line 802 "parser.y" +#line 801 "parser.y" { (yyval.literal) = new_null_literal(ctx); ;} break; case 200: /* Line 1455 of yacc.c */ -#line 803 "parser.y" - { (yyval.literal) = new_undefined_literal(ctx); ;} +#line 802 "parser.y" + { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} break; case 201: /* Line 1455 of yacc.c */ -#line 804 "parser.y" +#line 803 "parser.y" { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} break; case 202: /* Line 1455 of yacc.c */ -#line 805 "parser.y" - { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} +#line 804 "parser.y" + { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].wstr)); ;} break; case 203: /* Line 1455 of yacc.c */ -#line 806 "parser.y" - { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].wstr)); ;} +#line 805 "parser.y" + { (yyval.literal) = parse_regexp(ctx); + if(!(yyval.literal)) YYABORT; ;} break; case 204: @@ -3455,57 +3451,49 @@ yyreduce: case 205: /* Line 1455 of yacc.c */ -#line 809 "parser.y" - { (yyval.literal) = parse_regexp(ctx); - if(!(yyval.literal)) YYABORT; ;} +#line 812 "parser.y" + { (yyval.literal) = new_boolean_literal(ctx, VARIANT_TRUE); ;} break; case 206: /* Line 1455 of yacc.c */ -#line 814 "parser.y" - { (yyval.literal) = new_boolean_literal(ctx, VARIANT_TRUE); ;} - break; - - case 207: - -/* Line 1455 of yacc.c */ -#line 815 "parser.y" +#line 813 "parser.y" { (yyval.literal) = new_boolean_literal(ctx, VARIANT_FALSE); ;} break; - case 209: + case 208: /* Line 1455 of yacc.c */ -#line 819 "parser.y" +#line 817 "parser.y" { if(!allow_auto_semicolon(ctx)) {YYABORT;} ;} break; - case 211: + case 210: /* Line 1455 of yacc.c */ -#line 823 "parser.y" +#line 821 "parser.y" { set_error(ctx, IDS_LBRACKET); YYABORT; ;} break; - case 213: + case 212: /* Line 1455 of yacc.c */ -#line 827 "parser.y" +#line 825 "parser.y" { set_error(ctx, IDS_RBRACKET); YYABORT; ;} break; - case 215: + case 214: /* Line 1455 of yacc.c */ -#line 831 "parser.y" +#line 829 "parser.y" { set_error(ctx, IDS_SEMICOLON); YYABORT; ;} break; /* Line 1455 of yacc.c */ -#line 3509 "parser.tab.c" +#line 3497 "parser.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -3717,7 +3705,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 833 "parser.y" +#line 831 "parser.y" static BOOL allow_auto_semicolon(parser_ctx_t *ctx) @@ -3729,7 +3717,7 @@ static literal_t *new_string_literal(parser_ctx_t *ctx, const WCHAR *str) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BSTR; + ret->type = LT_STRING; ret->u.wstr = str; return ret; @@ -3739,16 +3727,7 @@ static literal_t *new_null_literal(parser_ctx_t *ctx) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_NULL; - - return ret; -} - -static literal_t *new_undefined_literal(parser_ctx_t *ctx) -{ - literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - - ret->vt = VT_EMPTY; + ret->type = LT_NULL; return ret; } @@ -3757,7 +3736,7 @@ static literal_t *new_boolean_literal(parser_ctx_t *ctx, VARIANT_BOOL bval) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BOOL; + ret->type = LT_BOOL; ret->u.bval = bval; return ret; @@ -4479,14 +4458,11 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source) void parser_release(parser_ctx_t *ctx) { - obj_literal_t *iter; - if(--ctx->ref) return; - for(iter = ctx->obj_literals; iter; iter = iter->next) - jsdisp_release(iter->obj); - + script_release(ctx->script); + heap_free(ctx->begin); jsheap_free(&ctx->heap); heap_free(ctx); } @@ -4508,8 +4484,14 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite parser_ctx->hres = JSCRIPT_ERROR|IDS_SYNTAX_ERROR; parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW); - parser_ctx->begin = parser_ctx->ptr = code; - parser_ctx->end = code + strlenW(code); + parser_ctx->begin = heap_strdupW(code); + if(!parser_ctx->begin) { + heap_free(parser_ctx); + return E_OUTOFMEMORY; + } + + parser_ctx->ptr = parser_ctx->begin; + parser_ctx->end = parser_ctx->begin + strlenW(parser_ctx->begin); script_addref(ctx); parser_ctx->script = ctx; diff --git a/dll/win32/jscript/parser.tab.h b/dll/win32/jscript/parser.tab.h index deed458a2f6..cdc4c1c2851 100644 --- a/dll/win32/jscript/parser.tab.h +++ b/dll/win32/jscript/parser.tab.h @@ -54,34 +54,33 @@ kINSTANCEOF = 270, kNEW = 271, kNULL = 272, - kUNDEFINED = 273, - kRETURN = 274, - kSWITCH = 275, - kTHIS = 276, - kTHROW = 277, - kTRUE = 278, - kFALSE = 279, - kTRY = 280, - kTYPEOF = 281, - kVAR = 282, - kVOID = 283, - kWHILE = 284, - kWITH = 285, - tANDAND = 286, - tOROR = 287, - tINC = 288, - tDEC = 289, - tHTMLCOMMENT = 290, - kDIVEQ = 291, - kFUNCTION = 292, - tIdentifier = 293, - tAssignOper = 294, - tEqOper = 295, - tShiftOper = 296, - tRelOper = 297, - tNumericLiteral = 298, - tStringLiteral = 299, - LOWER_THAN_ELSE = 300 + kRETURN = 273, + kSWITCH = 274, + kTHIS = 275, + kTHROW = 276, + kTRUE = 277, + kFALSE = 278, + kTRY = 279, + kTYPEOF = 280, + kVAR = 281, + kVOID = 282, + kWHILE = 283, + kWITH = 284, + tANDAND = 285, + tOROR = 286, + tINC = 287, + tDEC = 288, + tHTMLCOMMENT = 289, + kDIVEQ = 290, + kFUNCTION = 291, + tIdentifier = 292, + tAssignOper = 293, + tEqOper = 294, + tShiftOper = 295, + tRelOper = 296, + tNumericLiteral = 297, + tStringLiteral = 298, + LOWER_THAN_ELSE = 299 }; #endif @@ -92,7 +91,7 @@ typedef union YYSTYPE { /* Line 1676 of yacc.c */ -#line 151 "parser.y" +#line 150 "parser.y" int ival; const WCHAR *srcptr; @@ -116,7 +115,7 @@ typedef union YYSTYPE /* Line 1676 of yacc.c */ -#line 120 "parser.tab.h" +#line 119 "parser.tab.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/dll/win32/jscript/parser.y b/dll/win32/jscript/parser.y index d4b49089424..f062cd0117d 100644 --- a/dll/win32/jscript/parser.y +++ b/dll/win32/jscript/parser.y @@ -38,7 +38,6 @@ typedef struct _statement_list_t { static literal_t *new_string_literal(parser_ctx_t*,const WCHAR*); static literal_t *new_null_literal(parser_ctx_t*); -static literal_t *new_undefined_literal(parser_ctx_t*); static literal_t *new_boolean_literal(parser_ctx_t*,VARIANT_BOOL); typedef struct _property_list_t { @@ -171,7 +170,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state /* keywords */ %token kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kIF kFINALLY kFOR kIN -%token kINSTANCEOF kNEW kNULL kUNDEFINED kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH +%token kINSTANCEOF kNEW kNULL kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH %token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ %token kFUNCTION '}' @@ -800,7 +799,6 @@ Identifier_opt /* ECMA-262 3rd Edition 7.8 */ Literal : kNULL { $$ = new_null_literal(ctx); } - | kUNDEFINED { $$ = new_undefined_literal(ctx); } | BooleanLiteral { $$ = $1; } | tNumericLiteral { $$ = $1; } | tStringLiteral { $$ = new_string_literal(ctx, $1); } @@ -841,7 +839,7 @@ static literal_t *new_string_literal(parser_ctx_t *ctx, const WCHAR *str) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BSTR; + ret->type = LT_STRING; ret->u.wstr = str; return ret; @@ -851,16 +849,7 @@ static literal_t *new_null_literal(parser_ctx_t *ctx) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_NULL; - - return ret; -} - -static literal_t *new_undefined_literal(parser_ctx_t *ctx) -{ - literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - - ret->vt = VT_EMPTY; + ret->type = LT_NULL; return ret; } @@ -869,7 +858,7 @@ static literal_t *new_boolean_literal(parser_ctx_t *ctx, VARIANT_BOOL bval) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BOOL; + ret->type = LT_BOOL; ret->u.bval = bval; return ret; @@ -1591,14 +1580,11 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source) void parser_release(parser_ctx_t *ctx) { - obj_literal_t *iter; - if(--ctx->ref) return; - for(iter = ctx->obj_literals; iter; iter = iter->next) - jsdisp_release(iter->obj); - + script_release(ctx->script); + heap_free(ctx->begin); jsheap_free(&ctx->heap); heap_free(ctx); } @@ -1620,8 +1606,14 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite parser_ctx->hres = JSCRIPT_ERROR|IDS_SYNTAX_ERROR; parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW); - parser_ctx->begin = parser_ctx->ptr = code; - parser_ctx->end = code + strlenW(code); + parser_ctx->begin = heap_strdupW(code); + if(!parser_ctx->begin) { + heap_free(parser_ctx); + return E_OUTOFMEMORY; + } + + parser_ctx->ptr = parser_ctx->begin; + parser_ctx->end = parser_ctx->begin + strlenW(parser_ctx->begin); script_addref(ctx); parser_ctx->script = ctx; diff --git a/dll/win32/jscript/regexp.c b/dll/win32/jscript/regexp.c index e911d0f5fdf..04575458105 100644 --- a/dll/win32/jscript/regexp.c +++ b/dll/win32/jscript/regexp.c @@ -32,6 +32,7 @@ */ #include +#include #include "jscript.h" @@ -82,7 +83,8 @@ typedef struct { JSRegExp *jsregexp; BSTR str; - DWORD last_index; + INT last_index; + VARIANT last_index_var; } RegExpInstance; static const WCHAR sourceW[] = {'s','o','u','r','c','e',0}; @@ -3299,8 +3301,16 @@ static inline RegExpInstance *regexp_from_vdisp(vdisp_t *vdisp) return (RegExpInstance*)vdisp->u.jsdisp; } -static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, const WCHAR *str, DWORD len, - const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, match_result_t *ret) +static void set_last_index(RegExpInstance *This, DWORD last_index) +{ + This->last_index = last_index; + VariantClear(&This->last_index_var); + num_set_val(&This->last_index_var, last_index); +} + +static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, DWORD rem_flags, + const WCHAR *str, DWORD len, const WCHAR **cp, match_result_t **parens, DWORD *parens_size, + DWORD *parens_cnt, match_result_t *ret) { REMatchState *x, *result; REGlobalData gData; @@ -3325,8 +3335,11 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c return E_FAIL; } - if(!result) + if(!result) { + if(rem_flags & REM_RESET_INDEX) + set_last_index(regexp, 0); return S_FALSE; + } if(parens) { DWORD i; @@ -3347,8 +3360,13 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c *parens_cnt = regexp->jsregexp->parenCount; for(i=0; i < regexp->jsregexp->parenCount; i++) { - (*parens)[i].str = *cp + result->parens[i].index; - (*parens)[i].len = result->parens[i].length; + if(result->parens[i].index == -1) { + (*parens)[i].str = NULL; + (*parens)[i].len = 0; + }else { + (*parens)[i].str = *cp + result->parens[i].index; + (*parens)[i].len = result->parens[i].length; + } } } @@ -3356,23 +3374,25 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c *cp = result->cp; ret->str = result->cp-matchlen; ret->len = matchlen; + set_last_index(regexp, result->cp-str); return S_OK; } -HRESULT regexp_match_next(script_ctx_t *ctx, DispatchEx *dispex, BOOL gcheck, const WCHAR *str, DWORD len, - const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, match_result_t *ret) +HRESULT regexp_match_next(script_ctx_t *ctx, DispatchEx *dispex, DWORD rem_flags, const WCHAR *str, + DWORD len, const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, + match_result_t *ret) { RegExpInstance *regexp = (RegExpInstance*)dispex; jsheap_t *mark; HRESULT hres; - if(gcheck && !(regexp->jsregexp->flags & JSREG_GLOB)) + if((rem_flags & REM_CHECK_GLOBAL) && !(regexp->jsregexp->flags & JSREG_GLOB)) return S_FALSE; mark = jsheap_mark(&ctx->tmp_heap); - hres = do_regexp_match_next(ctx, regexp, str, len, cp, parens, parens_size, parens_cnt, ret); + hres = do_regexp_match_next(ctx, regexp, rem_flags, str, len, cp, parens, parens_size, parens_cnt, ret); jsheap_clear(mark); return hres; @@ -3391,7 +3411,7 @@ HRESULT regexp_match(script_ctx_t *ctx, DispatchEx *dispex, const WCHAR *str, DW mark = jsheap_mark(&ctx->tmp_heap); while(1) { - hres = do_regexp_match_next(ctx, This, str, len, &cp, NULL, NULL, NULL, &cres); + hres = do_regexp_match_next(ctx, This, 0, str, len, &cp, NULL, NULL, NULL, &cres); if(hres == S_FALSE) { hres = S_OK; break; @@ -3474,6 +3494,27 @@ static HRESULT RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return E_NOTIMPL; } +static INT index_from_var(script_ctx_t *ctx, VARIANT *v) +{ + jsexcept_t ei; + VARIANT num; + HRESULT hres; + + memset(&ei, 0, sizeof(ei)); + hres = to_number(ctx, v, &ei, &num); + if(FAILED(hres)) { /* FIXME: Move ignoring exceptions to to_promitive */ + VariantClear(&ei.var); + return 0; + } + + if(V_VT(&num) == VT_R8) { + DOUBLE d = floor(V_R8(&num)); + return (DOUBLE)(INT)d == d ? d : 0; + } + + return V_I4(&num); +} + static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { @@ -3482,8 +3523,21 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, switch(flags) { case DISPATCH_PROPERTYGET: { RegExpInstance *regexp = regexp_from_vdisp(jsthis); - V_VT(retv) = VT_I4; - V_I4(retv) = regexp->last_index; + + V_VT(retv) = VT_EMPTY; + return VariantCopy(retv, ®exp->last_index_var); + } + case DISPATCH_PROPERTYPUT: { + RegExpInstance *regexp = regexp_from_vdisp(jsthis); + VARIANT *arg; + HRESULT hres; + + arg = get_arg(dp,0); + hres = VariantCopy(®exp->last_index_var, arg); + if(FAILED(hres)) + return hres; + + regexp->last_index = index_from_var(ctx, arg); break; } default: @@ -3589,28 +3643,34 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce return E_OUTOFMEMORY; } + if(regexp->last_index < 0) { + SysFreeString(string); + set_last_index(regexp, 0); + *ret = VARIANT_FALSE; + if(input) { + *input = NULL; + } + return S_OK; + } + length = SysStringLen(string); if(regexp->jsregexp->flags & JSREG_GLOB) last_index = regexp->last_index; cp = string + last_index; - hres = regexp_match_next(ctx, ®exp->dispex, FALSE, string, length, &cp, parens, parens ? &parens_size : NULL, - parens_cnt, match); + hres = regexp_match_next(ctx, ®exp->dispex, REM_RESET_INDEX, string, length, &cp, parens, + parens ? &parens_size : NULL, parens_cnt, match); if(FAILED(hres)) { SysFreeString(string); return hres; } - if(hres == S_OK) { - regexp->last_index = cp-string; - *ret = VARIANT_TRUE; - }else { - regexp->last_index = 0; - *ret = VARIANT_FALSE; - } - - if(input) + *ret = hres == S_OK ? VARIANT_TRUE : VARIANT_FALSE; + if(input) { *input = string; + }else { + SysFreeString(string); + } return S_OK; } @@ -3690,6 +3750,7 @@ static void RegExp_destructor(DispatchEx *dispex) if(This->jsregexp) js_DestroyRegExp(This->jsregexp); + VariantClear(&This->last_index_var); SysFreeString(This->str); heap_free(This); } @@ -3737,7 +3798,7 @@ static HRESULT alloc_regexp(script_ctx_t *ctx, DispatchEx *object_prototype, Reg return S_OK; } -static HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags, DispatchEx **ret) +HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags, DispatchEx **ret) { RegExpInstance *regexp; HRESULT hres; @@ -3764,73 +3825,57 @@ static HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD return E_FAIL; } + V_VT(®exp->last_index_var) = VT_I4; + V_I4(®exp->last_index_var) = 0; + *ret = ®exp->dispex; return S_OK; } -static HRESULT regexp_constructor(script_ctx_t *ctx, DISPPARAMS *dp, VARIANT *retv) +HRESULT create_regexp_var(script_ctx_t *ctx, VARIANT *src_arg, VARIANT *flags_arg, DispatchEx **ret) { const WCHAR *opt = emptyW, *src; - DispatchEx *ret; - VARIANT *arg; + DWORD flags; HRESULT hres; - if(!arg_cnt(dp)) { - FIXME("no args\n"); - return E_NOTIMPL; - } - - arg = get_arg(dp,0); - if(V_VT(arg) == VT_DISPATCH) { + if(V_VT(src_arg) == VT_DISPATCH) { DispatchEx *obj; - obj = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); + obj = iface_to_jsdisp((IUnknown*)V_DISPATCH(src_arg)); if(obj) { if(is_class(obj, JSCLASS_REGEXP)) { RegExpInstance *regexp = (RegExpInstance*)obj; - hres = create_regexp(ctx, regexp->str, -1, regexp->jsregexp->flags, &ret); + hres = create_regexp(ctx, regexp->str, -1, regexp->jsregexp->flags, ret); jsdisp_release(obj); - if(FAILED(hres)) - return hres; - - V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(ret); - return S_OK; + return hres; } jsdisp_release(obj); } } - if(V_VT(arg) != VT_BSTR) { - FIXME("vt arg0 = %d\n", V_VT(arg)); + if(V_VT(src_arg) != VT_BSTR) { + FIXME("flags_arg = %s\n", debugstr_variant(flags_arg)); return E_NOTIMPL; } - src = V_BSTR(arg); + src = V_BSTR(src_arg); - if(arg_cnt(dp) >= 2) { - arg = get_arg(dp,1); - if(V_VT(arg) != VT_BSTR) { - FIXME("unimplemented for vt %d\n", V_VT(arg)); + if(flags_arg) { + if(V_VT(flags_arg) != VT_BSTR) { + FIXME("unimplemented for vt %d\n", V_VT(flags_arg)); return E_NOTIMPL; } - opt = V_BSTR(arg); + opt = V_BSTR(flags_arg); } - hres = create_regexp_str(ctx, src, -1, opt, strlenW(opt), &ret); + hres = parse_regexp_flags(opt, strlenW(opt), &flags); if(FAILED(hres)) return hres; - if(retv) { - V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(ret); - }else { - jsdisp_release(ret); - } - return S_OK; + return create_regexp(ctx, src, -1, flags, ret); } static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, @@ -3864,8 +3909,27 @@ static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } } /* fall through */ - case DISPATCH_CONSTRUCT: - return regexp_constructor(ctx, dp, retv); + case DISPATCH_CONSTRUCT: { + DispatchEx *ret; + HRESULT hres; + + if(!arg_cnt(dp)) { + FIXME("no args\n"); + return E_NOTIMPL; + } + + hres = create_regexp_var(ctx, get_arg(dp,0), arg_cnt(dp) > 1 ? get_arg(dp,1) : NULL, &ret); + if(FAILED(hres)) + return hres; + + if(retv) { + V_VT(retv) = VT_DISPATCH; + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(ret); + }else { + jsdisp_release(ret); + } + return S_OK; + } default: FIXME("unimplemented flags: %x\n", flags); return E_NOTIMPL; @@ -3885,39 +3949,38 @@ HRESULT create_regexp_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Di if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, RegExpConstr_value, RegExpW, NULL, PROPF_CONSTR, ®exp->dispex, ret); + hres = create_builtin_function(ctx, RegExpConstr_value, RegExpW, NULL, + PROPF_CONSTR|2, ®exp->dispex, ret); jsdisp_release(®exp->dispex); return hres; } -HRESULT create_regexp_str(script_ctx_t *ctx, const WCHAR *exp, DWORD exp_len, const WCHAR *opt, - DWORD opt_len, DispatchEx **ret) +HRESULT parse_regexp_flags(const WCHAR *str, DWORD str_len, DWORD *ret) { const WCHAR *p; DWORD flags = 0; - if(opt) { - for (p = opt; p < opt+opt_len; p++) { - switch (*p) { - case 'g': - flags |= JSREG_GLOB; - break; - case 'i': - flags |= JSREG_FOLD; - break; - case 'm': - flags |= JSREG_MULTILINE; - break; - case 'y': - flags |= JSREG_STICKY; - break; - default: - WARN("wrong flag %c\n", *p); - return E_FAIL; - } + for (p = str; p < str+str_len; p++) { + switch (*p) { + case 'g': + flags |= JSREG_GLOB; + break; + case 'i': + flags |= JSREG_FOLD; + break; + case 'm': + flags |= JSREG_MULTILINE; + break; + case 'y': + flags |= JSREG_STICKY; + break; + default: + WARN("wrong flag %c\n", *p); + return E_FAIL; } } - return create_regexp(ctx, exp, exp_len, flags, ret); + *ret = flags; + return S_OK; } diff --git a/dll/win32/jscript/resource.h b/dll/win32/jscript/resource.h index 17c0df09f6d..b88621fb58c 100644 --- a/dll/win32/jscript/resource.h +++ b/dll/win32/jscript/resource.h @@ -37,5 +37,6 @@ #define IDS_NOT_BOOL 0x1392 #define IDS_JSCRIPT_EXPECTED 0x1396 #define IDS_REGEXP_SYNTAX_ERROR 0x1399 +#define IDS_URI_INVALID_CHAR 0x13A0 #define IDS_INVALID_LENGTH 0x13A5 #define IDS_ARRAY_EXPECTED 0x13A7 diff --git a/dll/win32/jscript/rsrc.rc b/dll/win32/jscript/rsrc.rc index d57f83c09dc..d23ea33a2f3 100644 --- a/dll/win32/jscript/rsrc.rc +++ b/dll/win32/jscript/rsrc.rc @@ -25,6 +25,8 @@ REGINST REGINST jscript.inf #include "jscript_De.rc" #include "jscript_En.rc" #include "jscript_Fr.rc" +#include "jscript_Ko.rc" #include "jscript_Lt.rc" #include "jscript_Nl.rc" #include "jscript_Pt.rc" +#include "jscript_Ru.rc" diff --git a/dll/win32/jscript/string.c b/dll/win32/jscript/string.c index 55b6b858fb6..df43fee27ed 100644 --- a/dll/win32/jscript/string.c +++ b/dll/win32/jscript/string.c @@ -656,7 +656,7 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP if(FAILED(hres)) return hres; - hres = create_regexp_str(ctx, match_str, SysStringLen(match_str), NULL, 0, ®exp); + hres = create_regexp(ctx, match_str, SysStringLen(match_str), 0, ®exp); SysFreeString(match_str); if(FAILED(hres)) return hres; @@ -703,6 +703,7 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP break; } + heap_free(match_result); SysFreeString(val_str); if(SUCCEEDED(hres) && retv) { @@ -795,7 +796,7 @@ static HRESULT rep_call(script_ctx_t *ctx, DispatchEx *func, const WCHAR *str, m if(SUCCEEDED(hres)) hres = jsdisp_call_value(func, DISPATCH_METHOD, &dp, &var, ei, caller); - for(i=0; i < parens_cnt+1; i++) { + for(i=0; i < parens_cnt+3; i++) { if(i != parens_cnt+1) SysFreeString(V_BSTR(get_arg(&dp,i))); } @@ -819,7 +820,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI DispatchEx *rep_func = NULL, *regexp = NULL; match_result_t *parens = NULL, match, **parens_ptr = &parens; strbuf_t ret = {NULL,0,0}; - BOOL gcheck = FALSE; + DWORD re_flags = 0; VARIANT *arg_var; HRESULT hres = S_OK; @@ -896,9 +897,9 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI while(1) { if(regexp) { - hres = regexp_match_next(ctx, regexp, gcheck, str, length, &cp, parens_ptr, + hres = regexp_match_next(ctx, regexp, re_flags, str, length, &cp, parens_ptr, &parens_size, &parens_cnt, &match); - gcheck = TRUE; + re_flags = REM_CHECK_GLOBAL; if(hres == S_FALSE) { hres = S_OK; @@ -965,7 +966,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI } idx = ptr2[1] - '0'; - if(isdigitW(ptr[3]) && idx*10 + (ptr[2]-'0') <= parens_cnt) { + if(isdigitW(ptr2[2]) && idx*10 + (ptr2[2]-'0') <= parens_cnt) { idx = idx*10 + (ptr[2]-'0'); ptr = ptr2+3; }else if(idx && idx <= parens_cnt) { @@ -1031,8 +1032,58 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + DispatchEx *regexp = NULL; + const WCHAR *str, *cp; + match_result_t match; + VARIANT *arg; + DWORD length; + BSTR val_str; + HRESULT hres; + + TRACE("\n"); + + hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); + if(FAILED(hres)) + return hres; + + if(!arg_cnt(dp)) { + if(retv) + V_VT(retv) = VT_NULL; + SysFreeString(val_str); + return S_OK; + } + + arg = get_arg(dp,0); + if(V_VT(arg) == VT_DISPATCH) { + regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); + if(regexp) { + if(!is_class(regexp, JSCLASS_REGEXP)) { + jsdisp_release(regexp); + regexp = NULL; + } + } + } + + if(!regexp) { + hres = create_regexp_var(ctx, arg, NULL, ®exp); + if(FAILED(hres)) { + SysFreeString(val_str); + return hres; + } + } + + cp = str; + hres = regexp_match_next(ctx, regexp, REM_RESET_INDEX, str, length, &cp, NULL, NULL, NULL, &match); + SysFreeString(val_str); + jsdisp_release(regexp); + if(FAILED(hres)) + return hres; + + if(retv) { + V_VT(retv) = VT_I4; + V_I4(retv) = hres == S_OK ? match.str-str : -1; + } + return S_OK; } /* ECMA-262 3rd Edition 15.5.4.13 */ @@ -1129,6 +1180,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP match_result_t *match_result = NULL; DWORD length, match_cnt, i, match_len = 0; const WCHAR *str, *ptr, *ptr2; + BOOL use_regexp = FALSE; VARIANT *arg, var; DispatchEx *array; BSTR val_str, match_str = NULL; @@ -1153,6 +1205,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); if(regexp) { if(is_class(regexp, JSCLASS_REGEXP)) { + use_regexp = TRUE; hres = regexp_match(ctx, regexp, str, length, TRUE, &match_result, &match_cnt); jsdisp_release(regexp); if(FAILED(hres)) { @@ -1183,7 +1236,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP if(SUCCEEDED(hres)) { ptr = str; for(i=0;; i++) { - if(match_result) { + if(use_regexp) { if(i == match_cnt) break; ptr2 = match_result[i].str; @@ -1209,7 +1262,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP if(FAILED(hres)) break; - if(match_result) + if(use_regexp) ptr = match_result[i].str + match_result[i].len; else if(match_str) ptr = ptr2 + match_len; @@ -1218,7 +1271,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP } } - if(SUCCEEDED(hres) && (match_str || match_result)) { + if(SUCCEEDED(hres) && (match_str || use_regexp)) { DWORD len = (str+length) - ptr; if(len || match_str) { @@ -1705,7 +1758,7 @@ HRESULT create_string_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Di return hres; hres = create_builtin_function(ctx, StringConstr_value, StringW, &StringConstr_info, - PROPF_CONSTR, &string->dispex, ret); + PROPF_CONSTR|1, &string->dispex, ret); jsdisp_release(&string->dispex); return hres; diff --git a/dll/win32/kernel32/except/except.c b/dll/win32/kernel32/except/except.c index 75e935679ee..a0e322167ce 100644 --- a/dll/win32/kernel32/except/except.c +++ b/dll/win32/kernel32/except/except.c @@ -204,6 +204,68 @@ BasepCheckForReadOnlyResource(IN PVOID Ptr) return Ret; } +static VOID +PrintStackTrace(struct _EXCEPTION_POINTERS *ExceptionInfo) +{ + PVOID StartAddr; + CHAR szMod[128] = ""; + PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord; + PCONTEXT ContextRecord = ExceptionInfo->ContextRecord; + + /* Print a stack trace. */ + DbgPrint("Unhandled exception\n"); + DbgPrint("ExceptionCode: %8x\n", ExceptionRecord->ExceptionCode); + + if ((NTSTATUS)ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && + ExceptionRecord->NumberParameters == 2) + { + DbgPrint("Faulting Address: %8x\n", ExceptionRecord->ExceptionInformation[1]); + } + + _dump_context (ContextRecord); + _module_name_from_addr(ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod)); + DbgPrint("Address:\n %8x+%-8x %s\n", + (PVOID)StartAddr, + (ULONG_PTR)ExceptionRecord->ExceptionAddress - (ULONG_PTR)StartAddr, + szMod); +#ifdef _M_IX86 + DbgPrint("Frames:\n"); + + _SEH2_TRY + { + UINT i; + PULONG Frame = (PULONG)ContextRecord->Ebp; + + for (i = 0; Frame[1] != 0 && Frame[1] != 0xdeadbeef && i < 128; i++) + { + if (IsBadReadPtr((PVOID)Frame[1], 4)) + { + DbgPrint(" %8x%9s %s\n", Frame[1], ""," "); + } + else + { + _module_name_from_addr((const void*)Frame[1], &StartAddr, + szMod, sizeof(szMod)); + DbgPrint(" %8x+%-8x %s\n", + (PVOID)StartAddr, + (ULONG_PTR)Frame[1] - (ULONG_PTR)StartAddr, + szMod); + } + + if (IsBadReadPtr((PVOID)Frame[0], sizeof(*Frame) * 2)) + break; + + Frame = (PULONG)Frame[0]; + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + DbgPrint("\n", _SEH2_GetExceptionCode()); + } + _SEH2_END; +#endif +} + /* * @implemented */ @@ -215,17 +277,18 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo) NTSTATUS ErrCode; ULONG ErrorParameters[4]; ULONG ErrorResponse; + PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord; - if ((NTSTATUS)ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && - ExceptionInfo->ExceptionRecord->NumberParameters >= 2) + if ((NTSTATUS)ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && + ExceptionRecord->NumberParameters >= 2) { - switch(ExceptionInfo->ExceptionRecord->ExceptionInformation[0]) + switch(ExceptionRecord->ExceptionInformation[0]) { case EXCEPTION_WRITE_FAULT: /* Change the protection on some write attempts, some InstallShield setups have this bug */ RetValue = BasepCheckForReadOnlyResource( - (PVOID)ExceptionInfo->ExceptionRecord->ExceptionInformation[1]); + (PVOID)ExceptionRecord->ExceptionInformation[1]); if (RetValue == EXCEPTION_CONTINUE_EXECUTION) return EXCEPTION_CONTINUE_EXECUTION; break; @@ -253,79 +316,30 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo) if (GlobalTopLevelExceptionFilter) { - LONG ret = GlobalTopLevelExceptionFilter( ExceptionInfo ); + LONG ret = GlobalTopLevelExceptionFilter(ExceptionInfo); if (ret != EXCEPTION_CONTINUE_SEARCH) return ret; } if ((GetErrorMode() & SEM_NOGPFAULTERRORBOX) == 0) - { -#ifdef _X86_ - PULONG Frame; -#endif - PVOID StartAddr; - CHAR szMod[128] = ""; - - /* Print a stack trace. */ - DbgPrint("Unhandled exception\n"); - DbgPrint("ExceptionCode: %8x\n", ExceptionInfo->ExceptionRecord->ExceptionCode); - if ((NTSTATUS)ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION && - ExceptionInfo->ExceptionRecord->NumberParameters == 2) - { - DbgPrint("Faulting Address: %8x\n", ExceptionInfo->ExceptionRecord->ExceptionInformation[1]); - } - _dump_context ( ExceptionInfo->ContextRecord ); - _module_name_from_addr(ExceptionInfo->ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod)); - DbgPrint("Address:\n %8x+%-8x %s\n", - (PVOID)StartAddr, (ULONG_PTR)ExceptionInfo->ExceptionRecord->ExceptionAddress - - (ULONG_PTR)StartAddr, szMod); - -#ifdef _X86_ - DbgPrint("Frames:\n"); - _SEH2_TRY - { - Frame = (PULONG)ExceptionInfo->ContextRecord->Ebp; - while (Frame[1] != 0 && Frame[1] != 0xdeadbeef) - { - if (IsBadReadPtr((PVOID)Frame[1], 4)) { - DbgPrint(" %8x%9s %s\n", Frame[1], ""," "); - } else { - _module_name_from_addr((const void*)Frame[1], &StartAddr, - szMod, sizeof(szMod)); - DbgPrint(" %8x+%-8x %s\n", - (PVOID)StartAddr, - (ULONG_PTR)Frame[1] - (ULONG_PTR)StartAddr, szMod); - } - if (IsBadReadPtr((PVOID)Frame[0], sizeof(*Frame) * 2)) { - break; - } - Frame = (PULONG)Frame[0]; - } - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - DbgPrint("\n", _SEH2_GetExceptionCode()); - } - _SEH2_END; -#endif - } + PrintStackTrace(ExceptionInfo); /* Save exception code and address */ - ErrorParameters[0] = (ULONG)ExceptionInfo->ExceptionRecord->ExceptionCode; - ErrorParameters[1] = (ULONG)ExceptionInfo->ExceptionRecord->ExceptionAddress; + ErrorParameters[0] = (ULONG)ExceptionRecord->ExceptionCode; + ErrorParameters[1] = (ULONG)ExceptionRecord->ExceptionAddress; - if ((NTSTATUS)ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION) + if ((NTSTATUS)ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION) { /* get the type of operation that caused the access violation */ - ErrorParameters[2] = ExceptionInfo->ExceptionRecord->ExceptionInformation[0]; + ErrorParameters[2] = ExceptionRecord->ExceptionInformation[0]; } else { - ErrorParameters[2] = ExceptionInfo->ExceptionRecord->ExceptionInformation[2]; + ErrorParameters[2] = ExceptionRecord->ExceptionInformation[2]; } /* Save faulting address */ - ErrorParameters[3] = ExceptionInfo->ExceptionRecord->ExceptionInformation[1]; + ErrorParameters[3] = ExceptionRecord->ExceptionInformation[1]; /* Raise the harderror */ ErrCode = NtRaiseHardError(STATUS_UNHANDLED_EXCEPTION | 0x10000000, diff --git a/dll/win32/mapi32/De.rc b/dll/win32/mapi32/De.rc new file mode 100644 index 00000000000..2c811d15a0c --- /dev/null +++ b/dll/win32/mapi32/De.rc @@ -0,0 +1,30 @@ +/* +* MAPI32 German resources +* +* Copyright 2009 André Hentschel +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "Das senden der E-Mails scheiterte, da Sie keinen MAPI E-Mail Programm installiert haben." + IDS_SEND_MAIL, "E-Mail senden" +} diff --git a/dll/win32/mapi32/En.rc b/dll/win32/mapi32/En.rc new file mode 100644 index 00000000000..9a6bf77998f --- /dev/null +++ b/dll/win32/mapi32/En.rc @@ -0,0 +1,30 @@ +/* +* MAPI32 English resources +* +* Copyright 2009 Owen Rudge for CodeWeavers +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "Mail sending failed as you do not have a MAPI mail client installed." + IDS_SEND_MAIL, "Send Mail" +} diff --git a/dll/win32/mapi32/Es.rc b/dll/win32/mapi32/Es.rc new file mode 100644 index 00000000000..534f4d4dbc9 --- /dev/null +++ b/dll/win32/mapi32/Es.rc @@ -0,0 +1,33 @@ +/* +* MAPI32 Spanish resources +* +* Copyright 2010 José Manuel Ferrer Ortiz +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "El envío de correo ha fallado debido a que no tiene instalado un cliente de correo MAPI." + IDS_SEND_MAIL, "Enviar correo" +} diff --git a/dll/win32/mapi32/Fr.rc b/dll/win32/mapi32/Fr.rc new file mode 100644 index 00000000000..ab14e4ad377 --- /dev/null +++ b/dll/win32/mapi32/Fr.rc @@ -0,0 +1,33 @@ +/* +* MAPI32 French resources +* +* Copyright 2009 Frédéric Delanoy +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "L'envoi de courriel a échoué car aucun client mail MAPI n'est installé." + IDS_SEND_MAIL, "Envoyer un courriel" +} diff --git a/dll/win32/mapi32/Lt.rc b/dll/win32/mapi32/Lt.rc new file mode 100644 index 00000000000..b66bf3da010 --- /dev/null +++ b/dll/win32/mapi32/Lt.rc @@ -0,0 +1,33 @@ +/* +* MAPI32 Lithuanian resources +* + * Copyright 2009 Aurimas Fišeras +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "Nepavyko išsiųsti laiškų, nes neturite įdiegto MAPI pašto kliento." + IDS_SEND_MAIL, "Laiškų siuntimas" +} diff --git a/dll/win32/mapi32/Ru.rc b/dll/win32/mapi32/Ru.rc new file mode 100644 index 00000000000..66626da23a2 --- /dev/null +++ b/dll/win32/mapi32/Ru.rc @@ -0,0 +1,33 @@ +/* +* MAPI32 Russian resources +* +* Copyright 2009 Vladimir Pankratov +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include "res.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT + +STRINGTABLE +{ + IDS_NO_MAPI_CLIENT, "Невозможно отправить почту: не установлен почтовый клиент MAPI." + IDS_SEND_MAIL, "Отправка почты" +} diff --git a/dll/win32/mapi32/mapi32.rbuild b/dll/win32/mapi32/mapi32.rbuild index 93a8d539875..4832457070b 100644 --- a/dll/win32/mapi32/mapi32.rbuild +++ b/dll/win32/mapi32/mapi32.rbuild @@ -15,6 +15,7 @@ wine shlwapi shell32 + user32 advapi32 uuid ntdll diff --git a/dll/win32/mapi32/mapi32.spec b/dll/win32/mapi32/mapi32.spec index 04be363d2bc..8037c9b54d8 100644 --- a/dll/win32/mapi32/mapi32.spec +++ b/dll/win32/mapi32/mapi32.spec @@ -145,17 +145,17 @@ 205 stub FDecodeID@12 206 stub CchOfEncoding@4 207 stdcall CbOfEncoded@4(ptr) CbOfEncoded -208 stdcall MAPISendDocuments(ptr ptr ptr ptr long) -209 stdcall MAPILogon(long ptr ptr long long ptr) -210 stdcall MAPILogoff(long long long long) -211 stdcall MAPISendMail(long long ptr long long) -212 stdcall MAPISaveMail(ptr ptr ptr long long ptr) -213 stdcall MAPIReadMail(ptr ptr ptr long long ptr) -214 stdcall MAPIFindNext(ptr ptr ptr ptr long long ptr) -215 stdcall MAPIDeleteMail(ptr ptr ptr long long) -217 stdcall MAPIAddress(ptr ptr ptr long ptr long long ptr long ptr ptr) +208 stdcall MAPISendDocuments(ptr str str str long) +209 stdcall MAPILogon(ptr str str long long ptr) +210 stdcall MAPILogoff(ptr ptr long long) +211 stdcall MAPISendMail(ptr ptr ptr long long) +212 stdcall MAPISaveMail(ptr ptr ptr long long str) +213 stdcall MAPIReadMail(ptr ptr str long long ptr) +214 stdcall MAPIFindNext(ptr ptr str str long long ptr) +215 stdcall MAPIDeleteMail(ptr ptr str long long) +217 stdcall MAPIAddress(ptr ptr str long str long ptr long long ptr ptr) 218 stdcall MAPIDetails(ptr ptr ptr long long) -219 stdcall MAPIResolveName(ptr ptr ptr long long ptr) +219 stdcall MAPIResolveName(ptr ptr str long long ptr) 220 stub BMAPISendMail 221 stub BMAPISaveMail 222 stub BMAPIReadMail diff --git a/dll/win32/mapi32/mapi32_main.c b/dll/win32/mapi32/mapi32_main.c index 906c22e2c9f..6c35563a448 100644 --- a/dll/win32/mapi32/mapi32_main.c +++ b/dll/win32/mapi32/mapi32_main.c @@ -34,6 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mapi); LONG MAPI_ObjectCount = 0; +HINSTANCE hInstMAPI32; /*********************************************************************** * DllMain (MAPI32.init) @@ -45,6 +46,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) switch (fdwReason) { case DLL_PROCESS_ATTACH: + hInstMAPI32 = hinstDLL; DisableThreadLibraryCalls(hinstDLL); load_mapi_providers(); break; diff --git a/dll/win32/mapi32/prop.c b/dll/win32/mapi32/prop.c index 1a157da352f..5a7e8db0565 100644 --- a/dll/win32/mapi32/prop.c +++ b/dll/win32/mapi32/prop.c @@ -1835,7 +1835,7 @@ IMAPIProp_fnSetProps(LPMAPIPROP iface, ULONG ulValues, else { /* Add new value */ - if (!(item = IMAPIPROP_AddValue(This, &lpProps[i]))) + if (!IMAPIPROP_AddValue(This, &lpProps[i])) hRet = MAPI_E_NOT_ENOUGH_MEMORY; } } diff --git a/dll/win32/mapi32/res.h b/dll/win32/mapi32/res.h new file mode 100644 index 00000000000..658f8f609b0 --- /dev/null +++ b/dll/win32/mapi32/res.h @@ -0,0 +1,26 @@ +/* +* MAPI32 resources +* +* Copyright 2009 Owen Rudge for CodeWeavers +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +* +*/ + +#include + +/* Strings */ +#define IDS_NO_MAPI_CLIENT 1 +#define IDS_SEND_MAIL 2 diff --git a/dll/win32/mapi32/sendmail.c b/dll/win32/mapi32/sendmail.c index cbbff9847e9..e1156498cd1 100644 --- a/dll/win32/mapi32/sendmail.c +++ b/dll/win32/mapi32/sendmail.c @@ -30,6 +30,7 @@ #include "windef.h" #include "winbase.h" #include "winerror.h" +#include "winuser.h" #include "objbase.h" #include "objidl.h" #include "mapi.h" @@ -41,6 +42,7 @@ #include "shlwapi.h" #include "wine/debug.h" #include "util.h" +#include "res.h" WINE_DEFAULT_DEBUG_CHANNEL(mapi); @@ -383,27 +385,11 @@ cleanup: ; * Success: SUCCESS_SUCCESS * Failure: MAPI_E_FAILURE * - * NOTES - * The fallback procedure is a temporary hack. */ ULONG WINAPI MAPISendMail( LHANDLE session, ULONG_PTR uiparam, lpMapiMessage message, FLAGS flags, ULONG reserved ) { - ULONG ret = MAPI_E_FAILURE; - unsigned int i, to_count = 0, cc_count = 0, bcc_count = 0; - unsigned int to_size = 0, cc_size = 0, bcc_size = 0, subj_size, body_size; - - char *to = NULL, *cc = NULL, *bcc = NULL; - const char *address, *subject, *body; - static const char format[] = - "mailto:\"%s\"?subject=\"%s\"&cc=\"%s\"&bcc=\"%s\"&body=\"%s\""; - char *mailto = NULL, *escape = NULL; - char empty_string[] = ""; - HRESULT res; - DWORD size; - - TRACE( "(0x%08x 0x%08lx %p 0x%08x 0x%08x)\n", session, uiparam, - message, flags, reserved ); + WCHAR msg_title[READ_BUF_SIZE], error_msg[READ_BUF_SIZE]; /* Check to see if we have a Simple MAPI provider loaded */ if (mapiFunctions.MAPISendMail) @@ -413,133 +399,13 @@ ULONG WINAPI MAPISendMail( LHANDLE session, ULONG_PTR uiparam, if (MAPIInitialize(NULL) == S_OK) return sendmail_extended_mapi(session, uiparam, message, flags, reserved); - /* Fall back on our own implementation */ - if (!message) return MAPI_E_FAILURE; + /* Display an error message since we apparently have no mail clients */ + LoadStringW(hInstMAPI32, IDS_NO_MAPI_CLIENT, error_msg, sizeof(error_msg) / sizeof(WCHAR)); + LoadStringW(hInstMAPI32, IDS_SEND_MAIL, msg_title, sizeof(msg_title) / sizeof(WCHAR)); - for (i = 0; i < message->nRecipCount; i++) - { - if (!message->lpRecips) - { - WARN("No recipients found\n"); - return MAPI_E_FAILURE; - } + MessageBoxW((HWND) uiparam, error_msg, msg_title, MB_ICONEXCLAMATION); - address = message->lpRecips[i].lpszAddress; - if (address) - { - switch (message->lpRecips[i].ulRecipClass) - { - case MAPI_ORIG: - TRACE( "From: %s\n", debugstr_a(address) ); - break; - case MAPI_TO: - TRACE( "To: %s\n", debugstr_a(address) ); - to_size += lstrlenA( address ) + 1; - break; - case MAPI_CC: - TRACE( "Cc: %s\n", debugstr_a(address) ); - cc_size += lstrlenA( address ) + 1; - break; - case MAPI_BCC: - TRACE( "Bcc: %s\n", debugstr_a(address) ); - bcc_size += lstrlenA( address ) + 1; - break; - default: - TRACE( "Unknown recipient class: %d\n", - message->lpRecips[i].ulRecipClass ); - } - } - else - FIXME("Name resolution and entry identifiers not supported\n"); - } - if (message->nFileCount) FIXME("Ignoring attachments\n"); - - subject = message->lpszSubject ? message->lpszSubject : ""; - body = message->lpszNoteText ? message->lpszNoteText : ""; - - TRACE( "Subject: %s\n", debugstr_a(subject) ); - TRACE( "Body: %s\n", debugstr_a(body) ); - - subj_size = lstrlenA( subject ); - body_size = lstrlenA( body ); - - ret = MAPI_E_INSUFFICIENT_MEMORY; - if (to_size) - { - to = HeapAlloc( GetProcessHeap(), 0, to_size ); - if (!to) goto exit; - to[0] = 0; - } - if (cc_size) - { - cc = HeapAlloc( GetProcessHeap(), 0, cc_size ); - if (!cc) goto exit; - cc[0] = 0; - } - if (bcc_size) - { - bcc = HeapAlloc( GetProcessHeap(), 0, bcc_size ); - if (!bcc) goto exit; - bcc[0] = 0; - } - - if (message->lpOriginator) - TRACE( "From: %s\n", debugstr_a(message->lpOriginator->lpszAddress) ); - - for (i = 0; i < message->nRecipCount; i++) - { - address = message->lpRecips[i].lpszAddress; - if (address) - { - switch (message->lpRecips[i].ulRecipClass) - { - case MAPI_TO: - if (to_count) lstrcatA( to, "," ); - lstrcatA( to, address ); - to_count++; - break; - case MAPI_CC: - if (cc_count) lstrcatA( cc, "," ); - lstrcatA( cc, address ); - cc_count++; - break; - case MAPI_BCC: - if (bcc_count) lstrcatA( bcc, "," ); - lstrcatA( bcc, address ); - bcc_count++; - break; - } - } - } - ret = MAPI_E_FAILURE; - size = sizeof(format) + to_size + cc_size + bcc_size + subj_size + body_size; - - mailto = HeapAlloc( GetProcessHeap(), 0, size ); - if (!mailto) goto exit; - - sprintf( mailto, format, to ? to : "", subject, cc ? cc : "", bcc ? bcc : "", body ); - - size = 1; - res = UrlEscapeA( mailto, empty_string, &size, URL_ESCAPE_SPACES_ONLY ); - if (res != E_POINTER) goto exit; - - escape = HeapAlloc( GetProcessHeap(), 0, size ); - if (!escape) goto exit; - - res = UrlEscapeA( mailto, escape, &size, URL_ESCAPE_SPACES_ONLY ); - if (res != S_OK) goto exit; - - if ((UINT_PTR)ShellExecuteA( NULL, "open", escape, NULL, NULL, 0 ) > 32) - ret = SUCCESS_SUCCESS; - -exit: - HeapFree( GetProcessHeap(), 0, to ); - HeapFree( GetProcessHeap(), 0, cc ); - HeapFree( GetProcessHeap(), 0, bcc ); - HeapFree( GetProcessHeap(), 0, mailto ); - HeapFree( GetProcessHeap(), 0, escape ); - - return ret; + return MAPI_E_NOT_SUPPORTED; } ULONG WINAPI MAPISendDocuments(ULONG_PTR uiparam, LPSTR delim, LPSTR paths, diff --git a/dll/win32/mapi32/util.c b/dll/win32/mapi32/util.c index 71a5e1aec59..90cfa6ecd67 100644 --- a/dll/win32/mapi32/util.c +++ b/dll/win32/mapi32/util.c @@ -1037,7 +1037,7 @@ void load_mapi_providers(void) TRACE("appName: %s\n", debugstr_w(appName)); appKey = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (lstrlenW(regkey_mail) + - lstrlenW(regkey_backslash) + lstrlenW(appName))); + lstrlenW(regkey_backslash) + lstrlenW(appName) + 1)); if (!appKey) goto cleanUp; diff --git a/dll/win32/mapi32/util.h b/dll/win32/mapi32/util.h index fd813ca5892..df03d6e5f9a 100644 --- a/dll/win32/mapi32/util.h +++ b/dll/win32/mapi32/util.h @@ -61,5 +61,6 @@ typedef struct MAPI_FUNCTIONS { } MAPI_FUNCTIONS; extern MAPI_FUNCTIONS mapiFunctions; +extern HINSTANCE hInstMAPI32; #endif diff --git a/dll/win32/mapi32/version.rc b/dll/win32/mapi32/version.rc index d3a620bd8fb..e7c3d5926fb 100644 --- a/dll/win32/mapi32/version.rc +++ b/dll/win32/mapi32/version.rc @@ -24,3 +24,10 @@ #define WINE_PRODUCTVERSION_STR "1.0.0.0" #include "wine/wine_common_ver.rc" + +#include "De.rc" +#include "En.rc" +#include "Es.rc" +#include "Fr.rc" +#include "Lt.rc" +#include "Ru.rc" diff --git a/dll/win32/mciwave/mciwave.c b/dll/win32/mciwave/mciwave.c index c533e857797..24e75ee9dac 100644 --- a/dll/win32/mciwave/mciwave.c +++ b/dll/win32/mciwave/mciwave.c @@ -1,9 +1,10 @@ /* - * Sample Wine Driver for MCI wave forms + * Wine Driver for MCI wave forms * * Copyright 1994 Martin Ayotte * 1999,2000,2005 Eric Pouech * 2000 Francois Jacques + * 2009 Jörg Höhle * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,6 +21,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include "windef.h" @@ -38,11 +40,12 @@ typedef struct { UINT wDevID; HANDLE hWave; int nUseCount; /* Incremented for each shared open */ - BOOL fShareable; /* TRUE if first open was shareable */ HMMIO hFile; /* mmio file handle open as Element */ - MCI_WAVE_OPEN_PARMSW openParms; + MCIDEVICEID wNotifyDeviceID; /* MCI device ID with a pending notification */ + HANDLE hCallback; /* Callback handle for pending notification */ + LPWSTR lpFileName; /* Name of file (if any) */ WAVEFORMATEX wfxRef; - LPWAVEFORMATEX lpWaveFormat; + LPWAVEFORMATEX lpWaveFormat; /* Points to wfxRef until set by OPEN or RECORD */ BOOL fInput; /* FALSE = Output, TRUE = Input */ volatile WORD dwStatus; /* one from MCI_MODE_xxxx */ DWORD dwMciTimeFormat;/* One of the supported MCI_FORMAT_xxxx */ @@ -62,9 +65,12 @@ typedef struct { * =================================================================== * =================================================================== */ +typedef DWORD (*async_cmd)(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, HANDLE evt); + struct SCA { + async_cmd cmd; + HANDLE evt; UINT wDevID; - UINT wMsg; DWORD_PTR dwParam1; DWORD_PTR dwParam2; }; @@ -77,32 +83,29 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg) struct SCA* sca = (struct SCA*)arg; DWORD ret; - TRACE("In thread before async command (%08x,%u,%08lx,%08lx)\n", - sca->wDevID, sca->wMsg, sca->dwParam1, sca->dwParam2); - ret = mciSendCommandA(sca->wDevID, sca->wMsg, sca->dwParam1 | MCI_WAIT, sca->dwParam2); - TRACE("In thread after async command (%08x,%u,%08lx,%08lx)\n", - sca->wDevID, sca->wMsg, sca->dwParam1, sca->dwParam2); + TRACE("In thread before async command (%08x,%08lx,%08lx)\n", + sca->wDevID, sca->dwParam1, sca->dwParam2); + ret = sca->cmd(sca->wDevID, sca->dwParam1 | MCI_WAIT, sca->dwParam2, sca->evt); + TRACE("In thread after async command (%08x,%08lx,%08lx)\n", + sca->wDevID, sca->dwParam1, sca->dwParam2); HeapFree(GetProcessHeap(), 0, sca); - ExitThread(ret); - WARN("Should not happen ? what's wrong\n"); - /* should not go after this point */ return ret; } /************************************************************************** * MCI_SendCommandAsync [internal] */ -static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD_PTR dwParam1, +static DWORD MCI_SendCommandAsync(UINT wDevID, async_cmd cmd, DWORD_PTR dwParam1, DWORD_PTR dwParam2, UINT size) { - HANDLE handle; + HANDLE handles[2]; struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size); if (sca == 0) return MCIERR_OUT_OF_MEMORY; sca->wDevID = wDevID; - sca->wMsg = wMsg; + sca->cmd = cmd; sca->dwParam1 = dwParam1; if (size && dwParam2) { @@ -115,12 +118,22 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD_PTR dwParam1, sca->dwParam2 = dwParam2; } - if ((handle = CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL)) == 0) { + if ((sca->evt = handles[1] = CreateEventW(NULL, FALSE, FALSE, NULL)) == NULL || + (handles[0] = CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL)) == 0) { WARN("Couldn't allocate thread for async command handling, sending synchronously\n"); + if (handles[1]) CloseHandle(handles[1]); + sca->evt = NULL; return MCI_SCAStarter(&sca); } - SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); - CloseHandle(handle); + + SetThreadPriority(handles[0], THREAD_PRIORITY_TIME_CRITICAL); + /* wait until either: + * - the thread has finished (handles[0], likely an error) + * - init phase of async command is done (handles[1]) + */ + WaitForMultipleObjects(2, handles, FALSE, INFINITE); + CloseHandle(handles[0]); + CloseHandle(handles[1]); return 0; } @@ -189,6 +202,24 @@ static WINE_MCIWAVE *WAVE_mciGetOpenDev(MCIDEVICEID wDevID) return wmw; } +/************************************************************************** + * WAVE_mciNotify [internal] + * + * Notifications in MCI work like a 1-element queue. + * Each new notification request supersedes the previous one. + * This affects Play and Record; other commands are immediate. + */ +static void WAVE_mciNotify(DWORD_PTR hWndCallBack, WINE_MCIWAVE* wmw, UINT wStatus) +{ + /* We simply save one parameter by not passing the wDevID local + * to the command. They are the same (via mciGetDriverData). + */ + MCIDEVICEID wDevID = wmw->wNotifyDeviceID; + HANDLE old = InterlockedExchangePointer(&wmw->hCallback, NULL); + if (old) mciDriverNotify(old, wDevID, MCI_NOTIFY_SUPERSEDED); + mciDriverNotify(HWND_32(LOWORD(hWndCallBack)), wDevID, wStatus); +} + /************************************************************************** * WAVE_ConvertByteToTimeFormat [internal] */ @@ -203,8 +234,8 @@ static DWORD WAVE_ConvertByteToTimeFormat(WINE_MCIWAVE* wmw, DWORD val, LPDWORD case MCI_FORMAT_BYTES: ret = val; break; - case MCI_FORMAT_SAMPLES: /* FIXME: is this correct ? */ - ret = (val * 8) / (wmw->lpWaveFormat->wBitsPerSample ? wmw->lpWaveFormat->wBitsPerSample : 1); + case MCI_FORMAT_SAMPLES: + ret = MulDiv(val,wmw->lpWaveFormat->nSamplesPerSec,wmw->lpWaveFormat->nAvgBytesPerSec); break; default: WARN("Bad time format %u!\n", wmw->dwMciTimeFormat); @@ -223,13 +254,13 @@ static DWORD WAVE_ConvertTimeFormatToByte(WINE_MCIWAVE* wmw, DWORD val) switch (wmw->dwMciTimeFormat) { case MCI_FORMAT_MILLISECONDS: - ret = (val * wmw->lpWaveFormat->nAvgBytesPerSec) / 1000; + ret = MulDiv(val,wmw->lpWaveFormat->nAvgBytesPerSec,1000); break; case MCI_FORMAT_BYTES: ret = val; break; - case MCI_FORMAT_SAMPLES: /* FIXME: is this correct ? */ - ret = (val * wmw->lpWaveFormat->wBitsPerSample) / 8; + case MCI_FORMAT_SAMPLES: + ret = MulDiv(val,wmw->lpWaveFormat->nAvgBytesPerSec,wmw->lpWaveFormat->nSamplesPerSec); break; default: WARN("Bad time format %u!\n", wmw->dwMciTimeFormat); @@ -245,6 +276,7 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF) { MMCKINFO mmckInfo; long r; + LPWAVEFORMATEX pwfx; mmckInfo.ckid = mmioFOURCC('f', 'm', 't', ' '); if (mmioDescend(wmw->hFile, &mmckInfo, pckMainRIFF, MMIO_FINDCHUNK) != 0) @@ -252,20 +284,28 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF) TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08X\n", (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize); - wmw->lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); - if (!wmw->lpWaveFormat) return MMSYSERR_NOMEM; - r = mmioRead(wmw->hFile, (HPSTR)wmw->lpWaveFormat, mmckInfo.cksize); - if (r < sizeof(WAVEFORMAT)) - return MCIERR_INVALID_FILE; + pwfx = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); + if (!pwfx) return MCIERR_OUT_OF_MEMORY; - TRACE("wFormatTag=%04X !\n", wmw->lpWaveFormat->wFormatTag); - TRACE("nChannels=%d\n", wmw->lpWaveFormat->nChannels); - TRACE("nSamplesPerSec=%d\n", wmw->lpWaveFormat->nSamplesPerSec); - TRACE("nAvgBytesPerSec=%d\n", wmw->lpWaveFormat->nAvgBytesPerSec); - TRACE("nBlockAlign=%d\n", wmw->lpWaveFormat->nBlockAlign); - TRACE("wBitsPerSample=%u !\n", wmw->lpWaveFormat->wBitsPerSample); + r = mmioRead(wmw->hFile, (HPSTR)pwfx, mmckInfo.cksize); + if (r < sizeof(PCMWAVEFORMAT)) { + HeapFree(GetProcessHeap(), 0, pwfx); + return MCIERR_INVALID_FILE; + } + TRACE("wFormatTag=%04X !\n", pwfx->wFormatTag); + TRACE("nChannels=%d\n", pwfx->nChannels); + TRACE("nSamplesPerSec=%d\n", pwfx->nSamplesPerSec); + TRACE("nAvgBytesPerSec=%d\n", pwfx->nAvgBytesPerSec); + TRACE("nBlockAlign=%d\n", pwfx->nBlockAlign); + TRACE("wBitsPerSample=%u !\n", pwfx->wBitsPerSample); if (r >= (long)sizeof(WAVEFORMATEX)) - TRACE("cbSize=%u !\n", wmw->lpWaveFormat->cbSize); + TRACE("cbSize=%u !\n", pwfx->cbSize); + if ((pwfx->wFormatTag != WAVE_FORMAT_PCM) + && (r < sizeof(WAVEFORMATEX) || (r < sizeof(WAVEFORMATEX) + pwfx->cbSize))) { + HeapFree(GetProcessHeap(), 0, pwfx); + return MCIERR_INVALID_FILE; + } + wmw->lpWaveFormat = pwfx; mmioAscend(wmw->hFile, &mmckInfo, 0); wmw->ckWaveData.ckid = mmioFOURCC('d', 'a', 't', 'a'); @@ -275,28 +315,26 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF) } TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08X\n", (LPSTR)&wmw->ckWaveData.ckid, (LPSTR)&wmw->ckWaveData.fccType, wmw->ckWaveData.cksize); - TRACE("nChannels=%d nSamplesPerSec=%d\n", - wmw->lpWaveFormat->nChannels, wmw->lpWaveFormat->nSamplesPerSec); - return 0; } /************************************************************************** - * WAVE_mciDefaultFmt [internal] + * WAVE_mciDefaultFmt [internal] + * + * wmw->lpWaveFormat points to the default wave format at wmw->wfxRef + * until either Open File or Record. It becomes immutable afterwards, + * i.e. Set wave format or channels etc. is subsequently refused. */ -static DWORD WAVE_mciDefaultFmt(WINE_MCIWAVE* wmw) +static void WAVE_mciDefaultFmt(WINE_MCIWAVE* wmw) { - wmw->lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, sizeof(*wmw->lpWaveFormat)); - if (!wmw->lpWaveFormat) return MMSYSERR_NOMEM; - + wmw->lpWaveFormat = &wmw->wfxRef; wmw->lpWaveFormat->wFormatTag = WAVE_FORMAT_PCM; wmw->lpWaveFormat->nChannels = 1; - wmw->lpWaveFormat->nSamplesPerSec = 44000; - wmw->lpWaveFormat->nAvgBytesPerSec = 44000; + wmw->lpWaveFormat->nSamplesPerSec = 11025; + wmw->lpWaveFormat->nAvgBytesPerSec = 11025; wmw->lpWaveFormat->nBlockAlign = 1; wmw->lpWaveFormat->wBitsPerSample = 8; - - return 0; + wmw->lpWaveFormat->cbSize = 0; } /************************************************************************** @@ -319,24 +357,41 @@ static DWORD WAVE_mciCreateRIFFSkeleton(WINE_MCIWAVE* wmw) ckWaveFormat.ckid = mmioFOURCC('f', 'm', 't', ' '); ckWaveFormat.cksize = sizeof(PCMWAVEFORMAT); - if (!wmw->lpWaveFormat) - { - wmw->lpWaveFormat = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wmw->lpWaveFormat)); - if (!wmw->lpWaveFormat) return MMSYSERR_NOMEM; - *wmw->lpWaveFormat = wmw->wfxRef; + /* Set wave format accepts PCM only, however open an + * existing ADPCM file, record into it and the MCI will + * happily save back in that format. */ + if (wmw->lpWaveFormat->wFormatTag == WAVE_FORMAT_PCM) { + if (wmw->lpWaveFormat->nBlockAlign != + wmw->lpWaveFormat->nChannels * wmw->lpWaveFormat->wBitsPerSample/8) { + WORD size = wmw->lpWaveFormat->nChannels * + wmw->lpWaveFormat->wBitsPerSample/8; + WARN("Incorrect nBlockAlign (%d), setting it to %d\n", + wmw->lpWaveFormat->nBlockAlign, size); + wmw->lpWaveFormat->nBlockAlign = size; + } + if (wmw->lpWaveFormat->nAvgBytesPerSec != + wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) { + DWORD speed = wmw->lpWaveFormat->nSamplesPerSec * + wmw->lpWaveFormat->nBlockAlign; + WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n", + wmw->lpWaveFormat->nAvgBytesPerSec, speed); + wmw->lpWaveFormat->nAvgBytesPerSec = speed; + } + } + if (wmw->lpWaveFormat == &wmw->wfxRef) { + LPWAVEFORMATEX pwfx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WAVEFORMATEX)); + if (!pwfx) return MCIERR_OUT_OF_MEMORY; + /* Set wave format accepts PCM only so the size is known. */ + assert(wmw->wfxRef.wFormatTag == WAVE_FORMAT_PCM); + *pwfx = wmw->wfxRef; + wmw->lpWaveFormat = pwfx; } - - /* we can only record PCM files... there is no way in the MCI API to specify - * the necessary data to initialize the extra bytes of the WAVEFORMATEX - * structure - */ - if (wmw->lpWaveFormat->wFormatTag != WAVE_FORMAT_PCM) - goto err; if (MMSYSERR_NOERROR != mmioCreateChunk(wmw->hFile, &ckWaveFormat, 0)) goto err; - if (-1 == mmioWrite(wmw->hFile, (HPCSTR)wmw->lpWaveFormat, sizeof(PCMWAVEFORMAT))) + if (-1 == mmioWrite(wmw->hFile, (HPCSTR)wmw->lpWaveFormat, (WAVE_FORMAT_PCM==wmw->lpWaveFormat->wFormatTag) + ? sizeof(PCMWAVEFORMAT) : sizeof(WAVEFORMATEX)+wmw->lpWaveFormat->cbSize)) goto err; if (MMSYSERR_NOERROR != mmioAscend(wmw->hFile, &ckWaveFormat, 0)) @@ -353,8 +408,7 @@ static DWORD WAVE_mciCreateRIFFSkeleton(WINE_MCIWAVE* wmw) return 0; err: - HeapFree(GetProcessHeap(), 0, wmw->lpWaveFormat); - wmw->lpWaveFormat = NULL; + /* mciClose takes care of wmw->lpWaveFormat. */ return MCIERR_INVALID_FILE; } @@ -371,6 +425,7 @@ static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName) if (!GetTempPathW(sizeof(szTmpPath)/sizeof(szTmpPath[0]), szTmpPath)) { WARN("can't retrieve temp path!\n"); + *pszTmpFileName = NULL; return MCIERR_FILE_NOT_FOUND; } @@ -400,16 +455,16 @@ static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName) return dwRet; } -static LRESULT WAVE_mciOpenFile(WINE_MCIWAVE* wmw, const WCHAR* filename) +static LRESULT WAVE_mciOpenFile(WINE_MCIWAVE* wmw, LPCWSTR filename) { LRESULT dwRet = MMSYSERR_NOERROR; - WCHAR* fn; + LPWSTR fn; fn = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1) * sizeof(WCHAR)); if (!fn) return MCIERR_OUT_OF_MEMORY; strcpyW(fn, filename); - HeapFree(GetProcessHeap(), 0, (void*)wmw->openParms.lpstrElementName); - wmw->openParms.lpstrElementName = fn; + HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName); + wmw->lpFileName = fn; if (strlenW(filename) > 0) { /* FIXME : what should be done if wmw->hFile is already != 0, or the driver is playin' */ @@ -463,7 +518,7 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; if (dwFlags & MCI_OPEN_SHAREABLE) - return MCIERR_HARDWARE; + return MCIERR_UNSUPPORTED_FUNCTION; if (wmw->nUseCount > 0) { /* The driver is already opened on this channel @@ -478,11 +533,13 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P wmw->hWave = 0; wmw->dwStatus = MCI_MODE_NOT_READY; wmw->hFile = 0; - memcpy(&wmw->openParms, lpOpenParms, sizeof(MCI_WAVE_OPEN_PARMSA)); - /* will be set by WAVE_mciOpenFile */ - wmw->openParms.lpstrElementName = NULL; + wmw->lpFileName = NULL; /* will be set by WAVE_mciOpenFile */ + wmw->hCallback = NULL; + WAVE_mciDefaultFmt(wmw); TRACE("wDevID=%04X (lpParams->wDeviceID=%08X)\n", wDevID, lpOpenParms->wDeviceID); + /* Logs show the native winmm calls us with 0 still in lpOpenParms.wDeviceID */ + wmw->wNotifyDeviceID = wDevID; if (dwFlags & MCI_OPEN_ELEMENT) { if (dwFlags & MCI_OPEN_ELEMENT_ID) { @@ -494,32 +551,15 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P dwRet = WAVE_mciOpenFile(wmw, lpOpenParms->lpstrElementName); } } - TRACE("hFile=%p\n", wmw->hFile); - if (dwRet == 0 && !wmw->lpWaveFormat) - dwRet = WAVE_mciDefaultFmt(wmw); - if (dwRet == 0) { - if (wmw->lpWaveFormat) { - switch (wmw->lpWaveFormat->wFormatTag) { - case WAVE_FORMAT_PCM: - if (wmw->lpWaveFormat->nAvgBytesPerSec != - wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) { - WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n", - wmw->lpWaveFormat->nAvgBytesPerSec, - wmw->lpWaveFormat->nSamplesPerSec * - wmw->lpWaveFormat->nBlockAlign); - wmw->lpWaveFormat->nAvgBytesPerSec = - wmw->lpWaveFormat->nSamplesPerSec * - wmw->lpWaveFormat->nBlockAlign; - } - break; - } - } wmw->dwPosition = 0; wmw->dwStatus = MCI_MODE_STOP; + + if (dwFlags & MCI_NOTIFY) + WAVE_mciNotify(lpOpenParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); } else { wmw->nUseCount--; if (wmw->hFile != 0) @@ -532,46 +572,38 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P /************************************************************************** * WAVE_mciCue [internal] */ -static DWORD WAVE_mciCue(MCIDEVICEID wDevID, LPARAM dwParam, LPMCI_GENERIC_PARMS lpParms) +static DWORD WAVE_mciCue(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { - /* - FIXME - - This routine is far from complete. At the moment only a check is done on the - MCI_WAVE_INPUT flag. No explicit check on MCI_WAVE_OUTPUT is done since that - is the default. - - The flags MCI_NOTIFY (and the callback parameter in lpParms) and MCI_WAIT - are ignored - */ - - DWORD dwRet; WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); - FIXME("(%u, %08lX, %p); likely to fail\n", wDevID, dwParam, lpParms); + TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); - if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; + /* Tests on systems without sound drivers show that Cue, like + * Record and Play, opens winmm, returning MCIERR_WAVE_xyPUTSUNSUITABLE. + * The first Cue Notify does not immediately return the + * notification, as if a player or recorder thread is started. + * PAUSE mode is reported when successful, but this mode is + * different from the normal Pause, because a) Pause then returns + * NONAPPLICABLE_FUNCTION instead of 0 and b) Set Channels etc. is + * still accepted, returning the original notification as ABORTED. + * I.e. Cue allows subsequent format changes, unlike Record or + * Open file, closes winmm if the format changes and stops this + * thread. + * Wine creates one player or recorder thread per async. Play or + * Record command. Notification behaviour suggests that MS-W* + * reuses a single thread to improve response times. Having Cue + * start this thread early helps to improve Play/Record's initial + * response time. In effect, Cue is a performance hint, which + * justifies our almost no-op implementation. + */ - /* FIXME */ - /* always close elements ? */ - if (wmw->hFile != 0) { - mmioClose(wmw->hFile, 0); - wmw->hFile = 0; - } + if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; + if (wmw->dwStatus != MCI_MODE_STOP) return MCIERR_NONAPPLICABLE_FUNCTION; - dwRet = MMSYSERR_NOERROR; /* assume success */ + if ((dwFlags & MCI_NOTIFY) && lpParms) + WAVE_mciNotify(lpParms->dwCallback,wmw,MCI_NOTIFY_SUCCESSFUL); - if ((dwParam & MCI_WAVE_INPUT) && !wmw->fInput) { - dwRet = waveOutClose(wmw->hWave); - if (dwRet != MMSYSERR_NOERROR) return MCIERR_INTERNAL; - wmw->fInput = TRUE; - } else if (wmw->fInput) { - dwRet = waveInClose(wmw->hWave); - if (dwRet != MMSYSERR_NOERROR) return MCIERR_INTERNAL; - wmw->fInput = FALSE; - } - wmw->hWave = 0; - return (dwRet == MMSYSERR_NOERROR) ? 0 : MCIERR_INTERNAL; + return MMSYSERR_NOERROR; } /************************************************************************** @@ -586,6 +618,11 @@ static DWORD WAVE_mciStop(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; + if (wmw->dwStatus != MCI_MODE_STOP) { + HANDLE old = InterlockedExchangePointer(&wmw->hCallback, NULL); + if (old) mciDriverNotify(old, wDevID, MCI_NOTIFY_ABORTED); + } + /* wait for playback thread (if any) to exit before processing further */ switch (wmw->dwStatus) { case MCI_MODE_PAUSE: @@ -602,15 +639,11 @@ static DWORD WAVE_mciStop(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS break; } - wmw->dwPosition = 0; - /* sanity resets */ wmw->dwStatus = MCI_MODE_STOP; - if ((dwFlags & MCI_NOTIFY) && lpParms) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, MCI_NOTIFY_SUCCESSFUL); - } + if ((dwFlags & MCI_NOTIFY) && lpParms && MMSYSERR_NOERROR==dwRet) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return dwRet; } @@ -628,6 +661,7 @@ static DWORD WAVE_mciClose(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; if (wmw->dwStatus != MCI_MODE_STOP) { + /* mciStop handles MCI_NOTIFY_ABORTED */ dwRet = WAVE_mciStop(wDevID, MCI_WAIT, lpParms); } @@ -640,15 +674,15 @@ static DWORD WAVE_mciClose(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM } } - HeapFree(GetProcessHeap(), 0, wmw->lpWaveFormat); - wmw->lpWaveFormat = NULL; - HeapFree(GetProcessHeap(), 0, (void*)wmw->openParms.lpstrElementName); - wmw->openParms.lpstrElementName = NULL; + if (wmw->lpWaveFormat != &wmw->wfxRef) + HeapFree(GetProcessHeap(), 0, wmw->lpWaveFormat); + wmw->lpWaveFormat = &wmw->wfxRef; + HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName); + wmw->lpFileName = NULL; if ((dwFlags & MCI_NOTIFY) && lpParms) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, - (dwRet == 0) ? MCI_NOTIFY_SUCCESSFUL : MCI_NOTIFY_FAILURE); + WAVE_mciNotify(lpParms->dwCallback, wmw, + (dwRet == 0) ? MCI_NOTIFY_SUCCESSFUL : MCI_NOTIFY_FAILURE); } return 0; @@ -678,9 +712,7 @@ static void CALLBACK WAVE_mciPlayCallback(HWAVEOUT hwo, UINT uMsg, } /****************************************************************** - * WAVE_mciPlayWaitDone - * - * + * WAVE_mciPlayWaitDone [internal] */ static void WAVE_mciPlayWaitDone(WINE_MCIWAVE* wmw) { @@ -698,28 +730,28 @@ static void WAVE_mciPlayWaitDone(WINE_MCIWAVE* wmw) /************************************************************************** * WAVE_mciPlay [internal] */ -static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) +static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, HANDLE hEvent) { + LPMCI_PLAY_PARMS lpParms = (void*)pmt; DWORD end; LONG bufsize, count, left; - DWORD dwRet = 0; + DWORD dwRet; LPWAVEHDR waveHdr = NULL; WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); + HANDLE oldcb; int whidx; - TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); + TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms); if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; - wmw->fInput = FALSE; - if (wmw->hFile == 0) { - WARN("Can't play: no file=%s!\n", debugstr_w(wmw->openParms.lpstrElementName)); + WARN("Can't play: no file=%s!\n", debugstr_w(wmw->lpFileName)); return MCIERR_FILE_NOT_FOUND; } - if (wmw->dwStatus == MCI_MODE_PAUSE) { + if (wmw->dwStatus == MCI_MODE_PAUSE && !wmw->fInput) { /* FIXME: parameters (start/end) in lpParams may not be used */ return WAVE_mciResume(wDevID, dwFlags, (LPMCI_GENERIC_PARMS)lpParms); } @@ -732,56 +764,65 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp return MCIERR_INTERNAL; } + if (wmw->lpWaveFormat->wFormatTag == WAVE_FORMAT_PCM) { + if (wmw->lpWaveFormat->nBlockAlign != + wmw->lpWaveFormat->nChannels * wmw->lpWaveFormat->wBitsPerSample/8) { + WARN("Incorrect nBlockAlign (%d), setting it to %d\n", + wmw->lpWaveFormat->nBlockAlign, + wmw->lpWaveFormat->nChannels * + wmw->lpWaveFormat->wBitsPerSample/8); + wmw->lpWaveFormat->nBlockAlign = + wmw->lpWaveFormat->nChannels * + wmw->lpWaveFormat->wBitsPerSample/8; + } + if (wmw->lpWaveFormat->nAvgBytesPerSec != + wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) { + WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n", + wmw->lpWaveFormat->nAvgBytesPerSec, + wmw->lpWaveFormat->nSamplesPerSec * + wmw->lpWaveFormat->nBlockAlign); + wmw->lpWaveFormat->nAvgBytesPerSec = + wmw->lpWaveFormat->nSamplesPerSec * + wmw->lpWaveFormat->nBlockAlign; + } + } + + end = wmw->ckWaveData.cksize; + if (lpParms && (dwFlags & MCI_TO)) { + DWORD position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); + if (position > end) return MCIERR_OUTOFRANGE; + end = position; + } + if (lpParms && (dwFlags & MCI_FROM)) { + DWORD position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom); + if (position > end) return MCIERR_OUTOFRANGE; + /* Seek rounds down, so do we. */ + position /= wmw->lpWaveFormat->nBlockAlign; + position *= wmw->lpWaveFormat->nBlockAlign; + wmw->dwPosition = position; + } + if (end < wmw->dwPosition) return MCIERR_OUTOFRANGE; + left = end - wmw->dwPosition; + if (0==left) return MMSYSERR_NOERROR; /* FIXME: NOTIFY */ + + wmw->fInput = FALSE; /* FIXME: waveInOpen may have been called. */ wmw->dwStatus = MCI_MODE_PLAY; if (!(dwFlags & MCI_WAIT)) { - return MCI_SendCommandAsync(wmw->openParms.wDeviceID, MCI_PLAY, dwFlags, + return MCI_SendCommandAsync(wDevID, WAVE_mciPlay, dwFlags, (DWORD_PTR)lpParms, sizeof(MCI_PLAY_PARMS)); } - end = 0xFFFFFFFF; - if (lpParms && (dwFlags & MCI_FROM)) { - wmw->dwPosition = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom); - } - if (lpParms && (dwFlags & MCI_TO)) { - end = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); - } - TRACE("Playing from byte=%u to byte=%u\n", wmw->dwPosition, end); - if (end <= wmw->dwPosition) - return TRUE; - + oldcb = InterlockedExchangePointer(&wmw->hCallback, + (dwFlags & MCI_NOTIFY) ? HWND_32(LOWORD(lpParms->dwCallback)) : NULL); + if (oldcb) mciDriverNotify(oldcb, wDevID, MCI_NOTIFY_ABORTED); + oldcb = NULL; #define WAVE_ALIGN_ON_BLOCK(wmw,v) \ ((((v) + (wmw)->lpWaveFormat->nBlockAlign - 1) / (wmw)->lpWaveFormat->nBlockAlign) * (wmw)->lpWaveFormat->nBlockAlign) - wmw->dwPosition = WAVE_ALIGN_ON_BLOCK(wmw, wmw->dwPosition); - wmw->ckWaveData.cksize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->ckWaveData.cksize); - - if (dwRet == 0) { - if (wmw->lpWaveFormat) { - switch (wmw->lpWaveFormat->wFormatTag) { - case WAVE_FORMAT_PCM: - if (wmw->lpWaveFormat->nAvgBytesPerSec != - wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) { - WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n", - wmw->lpWaveFormat->nAvgBytesPerSec, - wmw->lpWaveFormat->nSamplesPerSec * - wmw->lpWaveFormat->nBlockAlign); - wmw->lpWaveFormat->nAvgBytesPerSec = - wmw->lpWaveFormat->nSamplesPerSec * - wmw->lpWaveFormat->nBlockAlign; - } - break; - } - } - } else { - TRACE("can't retrieve wave format %d\n", dwRet); - goto cleanUp; - } - - /* go back to beginning of chunk plus the requested position */ /* FIXME: I'm not sure this is correct, notably because some data linked to * the decompression state machine will not be correctly initialized. @@ -790,9 +831,6 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp */ mmioSeek(wmw->hFile, wmw->ckWaveData.dwDataOffset + wmw->dwPosition, SEEK_SET); /* >= 0 */ - /* By default the device will be opened for output, the MCI_CUE function is there to - * change from output to input and back - */ /* FIXME: how to choose between several output channels ? here mapper is forced */ dwRet = waveOutOpen((HWAVEOUT *)&wmw->hWave, WAVE_MAPPER, wmw->lpWaveFormat, (DWORD_PTR)WAVE_mciPlayCallback, (DWORD_PTR)wmw, CALLBACK_FUNCTION); @@ -821,11 +859,11 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp } whidx = 0; - left = min(wmw->ckWaveData.cksize, end - wmw->dwPosition); wmw->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wmw->dwEventCount = 1L; /* for first buffer */ TRACE("Playing (normalized) from byte=%u for %u bytes\n", wmw->dwPosition, left); + if (hEvent) SetEvent(hEvent); /* FIXME: this doesn't work if wmw->dwPosition != 0 */ while (left > 0 && wmw->dwStatus != MCI_MODE_STOP && wmw->dwStatus != MCI_MODE_NOT_READY) { @@ -838,14 +876,18 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp */ waveHdr[whidx].dwBufferLength = count; waveHdr[whidx].dwFlags &= ~WHDR_DONE; - TRACE("before WODM_WRITE lpWaveHdr=%p dwBufferLength=%u dwBytesRecorded=%u\n", - &waveHdr[whidx], waveHdr[whidx].dwBufferLength, - waveHdr[whidx].dwBytesRecorded); + TRACE("before WODM_WRITE lpWaveHdr=%p dwBufferLength=%u\n", + &waveHdr[whidx], waveHdr[whidx].dwBufferLength); dwRet = waveOutWrite(wmw->hWave, &waveHdr[whidx], sizeof(WAVEHDR)); + if (dwRet) { + ERR("Aborting play loop, WODM_WRITE error %d\n", dwRet); + dwRet = MCIERR_HARDWARE; + break; + } left -= count; wmw->dwPosition += count; TRACE("after WODM_WRITE dwPosition=%u\n", wmw->dwPosition); - + /* InterlockedDecrement if and only if waveOutWrite is successful */ WAVE_mciPlayWaitDone(wmw); whidx ^= 1; } @@ -858,9 +900,10 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lp waveOutUnprepareHeader(wmw->hWave, &waveHdr[0], sizeof(WAVEHDR)); waveOutUnprepareHeader(wmw->hWave, &waveHdr[1], sizeof(WAVEHDR)); - dwRet = 0; - cleanUp: + if (dwFlags & MCI_NOTIFY) + oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL); + HeapFree(GetProcessHeap(), 0, waveHdr); if (wmw->hWave) { @@ -869,19 +912,17 @@ cleanUp: } CloseHandle(wmw->hEvent); - if (lpParms && (dwFlags & MCI_NOTIFY)) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, - dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL); - } - wmw->dwStatus = MCI_MODE_STOP; + /* Let the potentically asynchronous commands support FAILURE notification. */ + if (oldcb) mciDriverNotify(oldcb, wDevID, + dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL); + return dwRet; } /************************************************************************** - * WAVE_mciPlayCallback [internal] + * WAVE_mciRecordCallback [internal] */ static void CALLBACK WAVE_mciRecordCallback(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, @@ -924,8 +965,7 @@ static void CALLBACK WAVE_mciRecordCallback(HWAVEOUT hwo, UINT uMsg, } /****************************************************************** - * bWAVE_mciRecordWaitDone - * + * WAVE_mciRecordWaitDone [internal] */ static void WAVE_mciRecordWaitDone(WINE_MCIWAVE* wmw) { @@ -943,41 +983,39 @@ static void WAVE_mciRecordWaitDone(WINE_MCIWAVE* wmw) /************************************************************************** * WAVE_mciRecord [internal] */ -static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_RECORD_PARMS lpParms) +static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, HANDLE hEvent) { + LPMCI_RECORD_PARMS lpParms = (void*)pmt; DWORD end; DWORD dwRet = MMSYSERR_NOERROR; LONG bufsize; LPWAVEHDR waveHdr = NULL; WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); + HANDLE oldcb; - TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); + TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms); if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; - /* FIXME : since there is no way to determine in which mode the device is - * open (recording/playback) automatically switch from a mode to another - */ - wmw->fInput = TRUE; - - if (wmw->dwStatus == MCI_MODE_PAUSE) { + if (wmw->dwStatus == MCI_MODE_PAUSE && wmw->fInput) { /* FIXME: parameters (start/end) in lpParams may not be used */ return WAVE_mciResume(wDevID, dwFlags, (LPMCI_GENERIC_PARMS)lpParms); } /** This function will be called again by a thread when async is used. - * We have to set MCI_MODE_PLAY before we do this so that the app can spin + * We have to set MCI_MODE_RECORD before we do this so that the app can spin * on MCI_STATUS, so we have to allow it here if we're not going to start this thread. */ if ((wmw->dwStatus != MCI_MODE_STOP) && ((wmw->dwStatus != MCI_MODE_RECORD) && (dwFlags & MCI_WAIT))) { return MCIERR_INTERNAL; } + wmw->fInput = TRUE; /* FIXME: waveOutOpen may have been called. */ wmw->dwStatus = MCI_MODE_RECORD; if (!(dwFlags & MCI_WAIT)) { - return MCI_SendCommandAsync(wmw->openParms.wDeviceID, MCI_RECORD, dwFlags, + return MCI_SendCommandAsync(wDevID, WAVE_mciRecord, dwFlags, (DWORD_PTR)lpParms, sizeof(MCI_RECORD_PARMS)); } @@ -985,34 +1023,37 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_RECORD_PARM * we don't modify the wave part of an existing file (ie. we always erase an * existing content, we don't overwrite) */ - HeapFree(GetProcessHeap(), 0, (void*)wmw->openParms.lpstrElementName); - dwRet = create_tmp_file(&wmw->hFile, (WCHAR**)&wmw->openParms.lpstrElementName); + HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName); + dwRet = create_tmp_file(&wmw->hFile, (WCHAR**)&wmw->lpFileName); if (dwRet != 0) return dwRet; - /* new RIFF file */ + /* new RIFF file, lpWaveFormat now valid */ dwRet = WAVE_mciCreateRIFFSkeleton(wmw); - if (dwRet != 0) return dwRet; /* FIXME: we leak resources */ - - end = 0xFFFFFFFF; - if (lpParms && (dwFlags & MCI_FROM)) { - wmw->dwPosition = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom); - } + if (dwRet != 0) return dwRet; if (lpParms && (dwFlags & MCI_TO)) { end = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); + } else end = 0xFFFFFFFF; + if (lpParms && (dwFlags & MCI_FROM)) { + DWORD position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom); + if (wmw->ckWaveData.cksize < position) return MCIERR_OUTOFRANGE; + /* Seek rounds down, so do we. */ + position /= wmw->lpWaveFormat->nBlockAlign; + position *= wmw->lpWaveFormat->nBlockAlign; + wmw->dwPosition = position; } + if (end==wmw->dwPosition) return MMSYSERR_NOERROR; /* FIXME: NOTIFY */ TRACE("Recording from byte=%u to byte=%u\n", wmw->dwPosition, end); - if (end <= wmw->dwPosition) - { - return TRUE; - } + oldcb = InterlockedExchangePointer(&wmw->hCallback, + (dwFlags & MCI_NOTIFY) ? HWND_32(LOWORD(lpParms->dwCallback)) : NULL); + if (oldcb) mciDriverNotify(oldcb, wDevID, MCI_NOTIFY_ABORTED); + oldcb = NULL; #define WAVE_ALIGN_ON_BLOCK(wmw,v) \ ((((v) + (wmw)->lpWaveFormat->nBlockAlign - 1) / (wmw)->lpWaveFormat->nBlockAlign) * (wmw)->lpWaveFormat->nBlockAlign) - wmw->dwPosition = WAVE_ALIGN_ON_BLOCK(wmw, wmw->dwPosition); wmw->ckWaveData.cksize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->ckWaveData.cksize); /* Go back to the beginning of the chunk plus the requested position */ @@ -1067,10 +1108,16 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_RECORD_PARM dwRet = waveInStart(wmw->hWave); + if (hEvent) SetEvent(hEvent); + while (wmw->dwPosition < end && wmw->dwStatus != MCI_MODE_STOP && wmw->dwStatus != MCI_MODE_NOT_READY) { WAVE_mciRecordWaitDone(wmw); } - + /* Grab callback before another thread kicks in after we change dwStatus. */ + if (dwFlags & MCI_NOTIFY) { + oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL); + dwFlags &= ~MCI_NOTIFY; + } /* needed so that the callback above won't add again the buffers returned by the reset */ wmw->dwStatus = MCI_MODE_STOP; @@ -1082,6 +1129,9 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_RECORD_PARM dwRet = 0; cleanUp: + if (dwFlags & MCI_NOTIFY) + oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL); + HeapFree(GetProcessHeap(), 0, waveHdr); if (wmw->hWave) { @@ -1090,14 +1140,11 @@ cleanUp: } CloseHandle(wmw->hEvent); - if (lpParms && (dwFlags & MCI_NOTIFY)) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, - dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL); - } - wmw->dwStatus = MCI_MODE_STOP; + if (oldcb) mciDriverNotify(oldcb, wDevID, + dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL); + return dwRet; } @@ -1112,17 +1159,34 @@ static DWORD WAVE_mciPause(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); - if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; - if (wmw->dwStatus == MCI_MODE_PLAY) { - wmw->dwStatus = MCI_MODE_PAUSE; + switch (wmw->dwStatus) { + case MCI_MODE_PLAY: + dwRet = waveOutPause(wmw->hWave); + if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_PAUSE; + else { /* When playthread was not started yet, winmm not opened, error 5 MMSYSERR_INVALHANDLE */ + ERR("waveOutPause error %d\n",dwRet); + dwRet = MCIERR_INTERNAL; + } + break; + case MCI_MODE_RECORD: + dwRet = waveInStop(wmw->hWave); + if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_PAUSE; + else { + ERR("waveInStop error %d\n",dwRet); + dwRet = MCIERR_INTERNAL; + } + break; + case MCI_MODE_PAUSE: + dwRet = MMSYSERR_NOERROR; + break; + default: + dwRet = MCIERR_NONAPPLICABLE_FUNCTION; } - - if (wmw->fInput) dwRet = waveInStop(wmw->hWave); - else dwRet = waveOutPause(wmw->hWave); - - return (dwRet == MMSYSERR_NOERROR) ? 0 : MCIERR_INTERNAL; + if (MMSYSERR_NOERROR==dwRet && (dwFlags & MCI_NOTIFY) && lpParms) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); + return dwRet; } /************************************************************************** @@ -1131,19 +1195,41 @@ static DWORD WAVE_mciPause(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM static DWORD WAVE_mciResume(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); - DWORD dwRet = 0; + DWORD dwRet; TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; - if (wmw->dwStatus == MCI_MODE_PAUSE) { - wmw->dwStatus = MCI_MODE_PLAY; + switch (wmw->dwStatus) { + case MCI_MODE_PAUSE: + /* Only update dwStatus if wave* succeeds and will exchange buffers buffers. */ + if (wmw->fInput) { + dwRet = waveInStart(wmw->hWave); + if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_RECORD; + else { + ERR("waveInStart error %d\n",dwRet); + dwRet = MCIERR_INTERNAL; + } + } else { + dwRet = waveOutRestart(wmw->hWave); + if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_PLAY; + else { + ERR("waveOutRestart error %d\n",dwRet); + dwRet = MCIERR_INTERNAL; + } + } + break; + case MCI_MODE_PLAY: + case MCI_MODE_RECORD: + dwRet = MMSYSERR_NOERROR; + break; + default: + dwRet = MCIERR_NONAPPLICABLE_FUNCTION; } - - if (wmw->fInput) dwRet = waveInStart(wmw->hWave); - else dwRet = waveOutRestart(wmw->hWave); - return (dwRet == MMSYSERR_NOERROR) ? 0 : MCIERR_INTERNAL; + if (MMSYSERR_NOERROR==dwRet && (dwFlags & MCI_NOTIFY) && lpParms) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); + return dwRet; } /************************************************************************** @@ -1151,37 +1237,43 @@ static DWORD WAVE_mciResume(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PAR */ static DWORD WAVE_mciSeek(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms) { - DWORD ret = 0; WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); + DWORD position, dwRet; TRACE("(%04X, %08X, %p);\n", wDevID, dwFlags, lpParms); - if (lpParms == NULL) { - ret = MCIERR_NULL_PARAMETER_BLOCK; - } else if (wmw == NULL) { - ret = MCIERR_INVALID_DEVICE_ID; + if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; + if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID; + + position = dwFlags & (MCI_SEEK_TO_START|MCI_SEEK_TO_END|MCI_TO); + if (!position) return MCIERR_MISSING_PARAMETER; + if (position&(position-1)) return MCIERR_FLAGS_NOT_COMPATIBLE; + + /* Stop sends MCI_NOTIFY_ABORTED when needed */ + dwRet = WAVE_mciStop(wDevID, MCI_WAIT, 0); + if (dwRet != MMSYSERR_NOERROR) return dwRet; + + if (dwFlags & MCI_TO) { + position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); + if (position > wmw->ckWaveData.cksize) + return MCIERR_OUTOFRANGE; + } else if (dwFlags & MCI_SEEK_TO_START) { + position = 0; } else { - WAVE_mciStop(wDevID, MCI_WAIT, 0); - - if (dwFlags & MCI_SEEK_TO_START) { - wmw->dwPosition = 0; - } else if (dwFlags & MCI_SEEK_TO_END) { - wmw->dwPosition = wmw->ckWaveData.cksize; - } else if (dwFlags & MCI_TO) { - wmw->dwPosition = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo); - } else { - WARN("dwFlag doesn't tell where to seek to...\n"); - return MCIERR_MISSING_PARAMETER; - } - - TRACE("Seeking to position=%u bytes\n", wmw->dwPosition); - - if (dwFlags & MCI_NOTIFY) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, MCI_NOTIFY_SUCCESSFUL); - } + position = wmw->ckWaveData.cksize; } - return ret; + /* Seek rounds down, unless at end */ + if (position != wmw->ckWaveData.cksize) { + position /= wmw->lpWaveFormat->nBlockAlign; + position *= wmw->lpWaveFormat->nBlockAlign; + } + wmw->dwPosition = position; + TRACE("Seeking to position=%u bytes\n", position); + + if (dwFlags & MCI_NOTIFY) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); + + return MMSYSERR_NOERROR; } /************************************************************************** @@ -1253,30 +1345,40 @@ static DWORD WAVE_mciSet(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpPa TRACE("MCI_WAVE_SET_ANYINPUT !\n"); if (dwFlags & MCI_WAVE_SET_ANYOUTPUT) TRACE("MCI_WAVE_SET_ANYOUTPUT !\n"); + /* Set wave format parameters is refused after Open or Record.*/ + if (dwFlags & MCI_WAVE_SET_FORMATTAG) { + TRACE("MCI_WAVE_SET_FORMATTAG = %d\n", ((LPMCI_WAVE_SET_PARMS)lpParms)->wFormatTag); + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; + if (((LPMCI_WAVE_SET_PARMS)lpParms)->wFormatTag != WAVE_FORMAT_PCM) + return MCIERR_OUTOFRANGE; + } if (dwFlags & MCI_WAVE_SET_AVGBYTESPERSEC) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.nAvgBytesPerSec = ((LPMCI_WAVE_SET_PARMS)lpParms)->nAvgBytesPerSec; TRACE("MCI_WAVE_SET_AVGBYTESPERSEC = %d\n", wmw->wfxRef.nAvgBytesPerSec); } if (dwFlags & MCI_WAVE_SET_BITSPERSAMPLE) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.wBitsPerSample = ((LPMCI_WAVE_SET_PARMS)lpParms)->wBitsPerSample; TRACE("MCI_WAVE_SET_BITSPERSAMPLE = %d\n", wmw->wfxRef.wBitsPerSample); } if (dwFlags & MCI_WAVE_SET_BLOCKALIGN) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.nBlockAlign = ((LPMCI_WAVE_SET_PARMS)lpParms)->nBlockAlign; TRACE("MCI_WAVE_SET_BLOCKALIGN = %d\n", wmw->wfxRef.nBlockAlign); } if (dwFlags & MCI_WAVE_SET_CHANNELS) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.nChannels = ((LPMCI_WAVE_SET_PARMS)lpParms)->nChannels; TRACE("MCI_WAVE_SET_CHANNELS = %d\n", wmw->wfxRef.nChannels); } - if (dwFlags & MCI_WAVE_SET_FORMATTAG) { - wmw->wfxRef.wFormatTag = ((LPMCI_WAVE_SET_PARMS)lpParms)->wFormatTag; - TRACE("MCI_WAVE_SET_FORMATTAG = %d\n", wmw->wfxRef.wFormatTag); - } if (dwFlags & MCI_WAVE_SET_SAMPLESPERSEC) { + if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION; wmw->wfxRef.nSamplesPerSec = ((LPMCI_WAVE_SET_PARMS)lpParms)->nSamplesPerSec; TRACE("MCI_WAVE_SET_SAMPLESPERSEC = %d\n", wmw->wfxRef.nSamplesPerSec); } + if (dwFlags & MCI_NOTIFY) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return 0; } @@ -1287,7 +1389,6 @@ static DWORD WAVE_mciSave(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SAVE_PARMSW l { WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID); DWORD ret = MCIERR_FILE_NOT_SAVED, tmpRet; - WPARAM wparam = MCI_NOTIFY_FAILURE; TRACE("%d, %08X, %p);\n", wDevID, dwFlags, lpParms); if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; @@ -1318,16 +1419,14 @@ static DWORD WAVE_mciSave(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SAVE_PARMSW l DeleteFileW (lpParms->lpfilename); SetLastError(tmpRet); - if (0 == mmioRenameW(wmw->openParms.lpstrElementName, lpParms->lpfilename, 0, 0 )) { + /* FIXME: Open file.wav; Save; must not rename the original file. + * Nor must Save a.wav; Save b.wav rename a. */ + if (0 == mmioRenameW(wmw->lpFileName, lpParms->lpfilename, 0, 0 )) { ret = MMSYSERR_NOERROR; } - if (dwFlags & MCI_NOTIFY) { - if (ret == MMSYSERR_NOERROR) wparam = MCI_NOTIFY_SUCCESSFUL; - - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, wparam); - } + if (MMSYSERR_NOERROR==ret && (dwFlags & MCI_NOTIFY)) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); if (ret == MMSYSERR_NOERROR) ret = WAVE_mciOpenFile(wmw, lpParms->lpfilename); @@ -1413,71 +1512,47 @@ static DWORD WAVE_mciStatus(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_STATUS_PARM lpParms->dwReturn = id; } else { lpParms->dwReturn = 0; - ret = MCIERR_WAVE_INPUTUNSPECIFIED; + ret = MCIERR_WAVE_OUTPUTUNSPECIFIED; } } break; + /* It is always ok to query wave format parameters, + * except on auto-open yield MCIERR_UNSUPPORTED_FUNCTION. */ case MCI_WAVE_STATUS_AVGBYTESPERSEC: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->nAvgBytesPerSec; - TRACE("MCI_WAVE_STATUS_AVGBYTESPERSEC => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_STATUS_AVGBYTESPERSEC => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_BITSPERSAMPLE: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->wBitsPerSample; - TRACE("MCI_WAVE_STATUS_BITSPERSAMPLE => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_STATUS_BITSPERSAMPLE => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_BLOCKALIGN: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->nBlockAlign; - TRACE("MCI_WAVE_STATUS_BLOCKALIGN => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_STATUS_BLOCKALIGN => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_CHANNELS: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->nChannels; - TRACE("MCI_WAVE_STATUS_CHANNELS => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_STATUS_CHANNELS => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_FORMATTAG: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } lpParms->dwReturn = wmw->lpWaveFormat->wFormatTag; - TRACE("MCI_WAVE_FORMATTAG => %lu\n", lpParms->dwReturn); + TRACE("MCI_WAVE_FORMATTAG => %lu\n", lpParms->dwReturn); + break; + case MCI_WAVE_STATUS_SAMPLESPERSEC: + lpParms->dwReturn = wmw->lpWaveFormat->nSamplesPerSec; + TRACE("MCI_WAVE_STATUS_SAMPLESPERSEC => %lu\n", lpParms->dwReturn); break; case MCI_WAVE_STATUS_LEVEL: TRACE("MCI_WAVE_STATUS_LEVEL !\n"); lpParms->dwReturn = 0xAAAA5555; break; - case MCI_WAVE_STATUS_SAMPLESPERSEC: - if (!wmw->hFile) { - lpParms->dwReturn = 0; - return MCIERR_UNSUPPORTED_FUNCTION; - } - lpParms->dwReturn = wmw->lpWaveFormat->nSamplesPerSec; - TRACE("MCI_WAVE_STATUS_SAMPLESPERSEC => %lu\n", lpParms->dwReturn); - break; default: WARN("unknown command %08X !\n", lpParms->dwItem); return MCIERR_UNRECOGNIZED_COMMAND; } } - if (dwFlags & MCI_NOTIFY) { - mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), - wmw->openParms.wDeviceID, MCI_NOTIFY_SUCCESSFUL); - } + if ((dwFlags & MCI_NOTIFY) && HRESULT_CODE(ret)==0) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return ret; } @@ -1534,10 +1609,10 @@ static DWORD WAVE_mciGetDevCaps(MCIDEVICEID wDevID, DWORD dwFlags, ret = MCI_RESOURCE_RETURNED; break; case MCI_WAVE_GETDEVCAPS_INPUTS: - lpParms->dwReturn = 1; + lpParms->dwReturn = waveInGetNumDevs(); break; case MCI_WAVE_GETDEVCAPS_OUTPUTS: - lpParms->dwReturn = 1; + lpParms->dwReturn = waveOutGetNumDevs(); break; default: FIXME("Unknown capability (%08x) !\n", lpParms->dwItem); @@ -1547,6 +1622,8 @@ static DWORD WAVE_mciGetDevCaps(MCIDEVICEID wDevID, DWORD dwFlags, WARN("No GetDevCaps-Item !\n"); return MCIERR_UNRECOGNIZED_COMMAND; } + if ((dwFlags & MCI_NOTIFY) && HRESULT_CODE(ret)==0) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return ret; } @@ -1561,9 +1638,10 @@ static DWORD WAVE_mciInfo(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_INFO_PARMSW l TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms); - if (lpParms == NULL || lpParms->lpstrReturn == NULL) { - ret = MCIERR_NULL_PARAMETER_BLOCK; - } else if (wmw == NULL) { + if (!lpParms || !lpParms->lpstrReturn) + return MCIERR_NULL_PARAMETER_BLOCK; + + if (wmw == NULL) { ret = MCIERR_INVALID_DEVICE_ID; } else { static const WCHAR wszAudio [] = {'W','i','n','e','\'','s',' ','a','u','d','i','o',' ','p','l','a','y','e','r',0}; @@ -1574,7 +1652,7 @@ static DWORD WAVE_mciInfo(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_INFO_PARMSW l switch (dwFlags & ~(MCI_WAIT|MCI_NOTIFY)) { case MCI_INFO_PRODUCT: str = wszAudio; break; - case MCI_INFO_FILE: str = wmw->openParms.lpstrElementName; break; + case MCI_INFO_FILE: str = wmw->lpFileName; break; case MCI_WAVE_INPUT: str = wszWaveIn; break; case MCI_WAVE_OUTPUT: str = wszWaveOut; break; default: @@ -1591,7 +1669,8 @@ static DWORD WAVE_mciInfo(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_INFO_PARMSW l } else { lpParms->lpstrReturn[0] = 0; } - + if (MMSYSERR_NOERROR==ret && (dwFlags & MCI_NOTIFY)) + WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL); return ret; } @@ -1612,7 +1691,7 @@ LRESULT CALLBACK MCIWAVE_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, case DRV_ENABLE: return 1; case DRV_DISABLE: return 1; case DRV_QUERYCONFIGURE: return 1; - case DRV_CONFIGURE: MessageBoxA(0, "Sample MultiMedia Driver !", "OSS Driver", MB_OK); return 1; + case DRV_CONFIGURE: MessageBoxA(0, "MCI waveaudio Driver !", "Wine Driver", MB_OK); return 1; case DRV_INSTALL: return DRVCNF_RESTART; case DRV_REMOVE: return DRVCNF_RESTART; } @@ -1623,8 +1702,8 @@ LRESULT CALLBACK MCIWAVE_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, case MCI_OPEN_DRIVER: return WAVE_mciOpen (dwDevID, dwParam1, (LPMCI_WAVE_OPEN_PARMSW) dwParam2); case MCI_CLOSE_DRIVER: return WAVE_mciClose (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2); case MCI_CUE: return WAVE_mciCue (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2); - case MCI_PLAY: return WAVE_mciPlay (dwDevID, dwParam1, (LPMCI_PLAY_PARMS) dwParam2); - case MCI_RECORD: return WAVE_mciRecord (dwDevID, dwParam1, (LPMCI_RECORD_PARMS) dwParam2); + case MCI_PLAY: return WAVE_mciPlay (dwDevID, dwParam1, dwParam2, NULL); + case MCI_RECORD: return WAVE_mciRecord (dwDevID, dwParam1, dwParam2, NULL); case MCI_STOP: return WAVE_mciStop (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2); case MCI_SET: return WAVE_mciSet (dwDevID, dwParam1, (LPMCI_SET_PARMS) dwParam2); case MCI_PAUSE: return WAVE_mciPause (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2); diff --git a/dll/win32/mpr/mpr.rc b/dll/win32/mpr/mpr.rc index b1e4704b976..05c1020a04a 100644 --- a/dll/win32/mpr/mpr.rc +++ b/dll/win32/mpr/mpr.rc @@ -27,23 +27,27 @@ #include "mpr_Bg.rc" #include "mpr_Cs.rc" #include "mpr_Da.rc" -#include "mpr_De.rc" #include "mpr_En.rc" #include "mpr_Eo.rc" #include "mpr_Es.rc" -#include "mpr_Fr.rc" #include "mpr_Hu.rc" #include "mpr_It.rc" -#include "mpr_Ja.rc" #include "mpr_Ko.rc" #include "mpr_Nl.rc" #include "mpr_No.rc" #include "mpr_Pl.rc" +#include "mpr_Sv.rc" +#include "mpr_Tr.rc" + +/* UTF-8 */ +#include "mpr_De.rc" +#include "mpr_Fr.rc" +#include "mpr_Ja.rc" +#include "mpr_Lt.rc" #include "mpr_Pt.rc" #include "mpr_Ro.rc" #include "mpr_Ru.rc" #include "mpr_Si.rc" -#include "mpr_Sv.rc" -#include "mpr_Tr.rc" -#include "mpr_Zh.rc" #include "mpr_Uk.rc" +#include "mpr_Zh.rc" + diff --git a/dll/win32/mpr/mpr_Bg.rc b/dll/win32/mpr/mpr_Bg.rc index a37f7961be1..52353d2a066 100644 --- a/dll/win32/mpr/mpr_Bg.rc +++ b/dll/win32/mpr/mpr_Bg.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Cs.rc b/dll/win32/mpr/mpr_Cs.rc index 6085e7160c6..8e32de4747e 100644 --- a/dll/win32/mpr/mpr_Cs.rc +++ b/dll/win32/mpr/mpr_Cs.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_CZECH, SUBLANG_DEFAULT /* Czech strings in CP1250 */ diff --git a/dll/win32/mpr/mpr_Da.rc b/dll/win32/mpr/mpr_Da.rc index 5b6f99fbd04..52dc635d19a 100644 --- a/dll/win32/mpr/mpr_Da.rc +++ b/dll/win32/mpr/mpr_Da.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_DANISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_De.rc b/dll/win32/mpr/mpr_De.rc index 41429be5501..d8b1298ac41 100644 --- a/dll/win32/mpr/mpr_De.rc +++ b/dll/win32/mpr/mpr_De.rc @@ -18,6 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + +#pragma code_page(65001) + LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_En.rc b/dll/win32/mpr/mpr_En.rc index c71840423f4..c6fdf727785 100644 --- a/dll/win32/mpr/mpr_En.rc +++ b/dll/win32/mpr/mpr_En.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Eo.rc b/dll/win32/mpr/mpr_Eo.rc index 0ed9f470d40..2701f759507 100644 --- a/dll/win32/mpr/mpr_Eo.rc +++ b/dll/win32/mpr/mpr_Eo.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_ESPERANTO, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Es.rc b/dll/win32/mpr/mpr_Es.rc index d82758cbeae..630a9fe9141 100644 --- a/dll/win32/mpr/mpr_Es.rc +++ b/dll/win32/mpr/mpr_Es.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Fr.rc b/dll/win32/mpr/mpr_Fr.rc index ba43eefa077..4481639ad35 100644 --- a/dll/win32/mpr/mpr_Fr.rc +++ b/dll/win32/mpr/mpr_Fr.rc @@ -19,29 +19,34 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { - IDS_ENTIRENETWORK "Le rseau entier" + IDS_ENTIRENETWORK "Le réseau entier" } -IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 +IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 210, 146 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Entrez le mot de passe rseau" +CAPTION "Entrez le mot de passe réseau" FONT 8, "MS Shell Dlg" { - LTEXT "Veuillez saisir votre nom d'utilisateur et votre mot de passe:", IDC_EXPLAIN, 40, 6, 150, 15 - LTEXT "Proxy", -1, 40, 26, 50, 10 + LTEXT "Veuillez saisir votre nom d'utilisateur et votre mot de passe :", IDC_EXPLAIN, 10, 6, 150, 17 + LTEXT "Proxy", -1, 10, 31, 50, 10 /* LTEXT "Realm", -1, 40, 46, 50, 10 */ - LTEXT "Utilisateur", -1, 40, 66, 50, 10 - LTEXT "Mot de passe", -1, 40, 86, 50, 10 - LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 - LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 - EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP - EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD - CHECKBOX "&Enregistrer ce mot de passe (risqu)", IDC_SAVEPASSWORD, - 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP - PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON - PUSHBUTTON "Annuler", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP + LTEXT "Utilisateur", -1, 10, 68, 45, 10 + LTEXT "Mot de passe", -1, 10, 88, 45, 10 + LTEXT "" IDC_PROXY, 56, 32, 144, 14, 0 + LTEXT "" IDC_REALM, 56, 46, 144, 14, 0 + EDITTEXT IDC_USERNAME, 56, 66, 144, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP + EDITTEXT IDC_PASSWORD, 56, 86, 144, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD + CHECKBOX "&Enregistrer ce mot de passe (risqué)", IDC_SAVEPASSWORD, + 56, 106, 144, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 68, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON + PUSHBUTTON "Annuler", IDCANCEL, 128, 126, 56, 14, WS_GROUP | WS_TABSTOP } diff --git a/dll/win32/mpr/mpr_Hu.rc b/dll/win32/mpr/mpr_Hu.rc index d3561cb3fe6..32c32dd6da6 100644 --- a/dll/win32/mpr/mpr_Hu.rc +++ b/dll/win32/mpr/mpr_Hu.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_It.rc b/dll/win32/mpr/mpr_It.rc index 501644d0978..7067ee37d96 100644 --- a/dll/win32/mpr/mpr_It.rc +++ b/dll/win32/mpr/mpr_It.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Ja.rc b/dll/win32/mpr/mpr_Ja.rc index ad1a45685b3..a662ce7223d 100644 --- a/dll/win32/mpr/mpr_Ja.rc +++ b/dll/win32/mpr/mpr_Ja.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + /* UTF-8 */ #pragma code_page(65001) @@ -28,4 +30,22 @@ STRINGTABLE DISCARDABLE IDS_ENTIRENETWORK "ネットワーク全体" } -#pragma code_page(default) +IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "ネットワーク用パスワードを入力" +FONT 8, "MS Shell Dlg" +{ + LTEXT "ユーザー名とパスワードを入力してください:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "プロキシ", -1, 40, 26, 50, 10 +/* LTEXT "Realm", -1, 40, 46, 50, 10 */ + LTEXT "ユーザー名", -1, 40, 66, 50, 10 + LTEXT "パスワード", -1, 40, 86, 50, 10 + LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 + LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 + EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP + EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD + CHECKBOX "パスワードを保存する(&S)(セキュアではありません)", IDC_SAVEPASSWORD, + 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON + PUSHBUTTON "キャンセル", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP +} diff --git a/dll/win32/mpr/mpr_Ko.rc b/dll/win32/mpr/mpr_Ko.rc index 75688cda4e8..4ebbd8f3575 100644 --- a/dll/win32/mpr/mpr_Ko.rc +++ b/dll/win32/mpr/mpr_Ko.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Lt.rc b/dll/win32/mpr/mpr_Lt.rc new file mode 100644 index 00000000000..d086d94c3b7 --- /dev/null +++ b/dll/win32/mpr/mpr_Lt.rc @@ -0,0 +1,51 @@ +/* + * MPR dll resources + * + * Copyright 2009 Aurimas Fišeras + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "mprres.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_ENTIRENETWORK "Visas tinklas" +} + +IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Įveskite tinklo slaptažodį" +FONT 8, "MS Shell Dlg" +{ + LTEXT "Įveskite savo naudotojo vardą ir slaptažodį:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "Įgaliot. serv.", -1, 40, 26, 50, 10 +/* LTEXT "Sritis", -1, 40, 46, 50, 10 */ + LTEXT "Naudotojas", -1, 40, 66, 50, 10 + LTEXT "Slaptažodis", -1, 40, 86, 50, 10 + LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 + LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 + EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP + EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD + CHECKBOX "Į&rašyti šį slaptažodį (nesaugu)", IDC_SAVEPASSWORD, + 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Gerai", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON + PUSHBUTTON "Atsisakyti", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP +} diff --git a/dll/win32/mpr/mpr_Nl.rc b/dll/win32/mpr/mpr_Nl.rc index 430ac6aa8c8..b1c67819799 100644 --- a/dll/win32/mpr/mpr_Nl.rc +++ b/dll/win32/mpr/mpr_Nl.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_No.rc b/dll/win32/mpr/mpr_No.rc index 32833542db9..150ee509edb 100644 --- a/dll/win32/mpr/mpr_No.rc +++ b/dll/win32/mpr/mpr_No.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Pl.rc b/dll/win32/mpr/mpr_Pl.rc index a6f2446f3ea..afdd3ba6343 100644 --- a/dll/win32/mpr/mpr_Pl.rc +++ b/dll/win32/mpr/mpr_Pl.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_POLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Pt.rc b/dll/win32/mpr/mpr_Pt.rc index f79a96dcab8..b0191939094 100644 --- a/dll/win32/mpr/mpr_Pt.rc +++ b/dll/win32/mpr/mpr_Pt.rc @@ -2,7 +2,7 @@ * MPR dll resources * * Copyright (C) 2004 Marcelo Duarte - * Copyright (C) 2006 Amrico Jos Melo + * Copyright (C) 2006 Américo José Melo * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,7 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN +#include "mprres.h" + +#pragma code_page(65001) + +LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { @@ -34,10 +38,10 @@ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Entre a senha da rede" FONT 8, "MS Shell Dlg" { - LTEXT "Por favor, entre como o nome de usurio e a senha:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "Por favor, entre como o nome de usuário e a senha:", IDC_EXPLAIN, 40, 6, 150, 15 LTEXT "Proxy", -1, 40, 26, 50, 10 /* LTEXT "Realm", -1, 40, 46, 50, 10 */ - LTEXT "Usurio", -1, 40, 66, 50, 10 + LTEXT "Usuário", -1, 40, 66, 50, 10 LTEXT "Senha", -1, 40, 86, 50, 10 LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 diff --git a/dll/win32/mpr/mpr_Ro.rc b/dll/win32/mpr/mpr_Ro.rc index ce06328ef80..ab7d137e2b2 100644 --- a/dll/win32/mpr/mpr_Ro.rc +++ b/dll/win32/mpr/mpr_Ro.rc @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL #pragma code_page(65001) @@ -44,5 +46,3 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON PUSHBUTTON "Renunță", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } - -#pragma code_page(default) diff --git a/dll/win32/mpr/mpr_Ru.rc b/dll/win32/mpr/mpr_Ru.rc index d093c0612bb..3d17a0a93a5 100644 --- a/dll/win32/mpr/mpr_Ru.rc +++ b/dll/win32/mpr/mpr_Ru.rc @@ -18,29 +18,34 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { - IDS_ENTIRENETWORK " " + IDS_ENTIRENETWORK "Вся сеть" } IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION " " +CAPTION "Введите сетевой пароль" FONT 8, "MS Shell Dlg" { - LTEXT " :", IDC_EXPLAIN, 40, 6, 150, 15 - LTEXT "", -1, 40, 26, 50, 10 + LTEXT "Введите ваши имя и пароль пользователя:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "Прокси", -1, 40, 26, 50, 10 /* LTEXT "Realm", -1, 40, 46, 50, 10 */ - LTEXT "", -1, 40, 66, 50, 10 - LTEXT "", -1, 40, 86, 50, 10 + LTEXT "Имя", -1, 40, 66, 50, 10 + LTEXT "Пароль", -1, 40, 86, 50, 10 LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD - CHECKBOX "& (!)", IDC_SAVEPASSWORD, + CHECKBOX "&Сохранить этот пароль (небезопасно!)", IDC_SAVEPASSWORD, 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON - PUSHBUTTON "", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP + PUSHBUTTON "Отмена", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } diff --git a/dll/win32/mpr/mpr_Si.rc b/dll/win32/mpr/mpr_Si.rc index 064bf525978..8f4022e402f 100644 --- a/dll/win32/mpr/mpr_Si.rc +++ b/dll/win32/mpr/mpr_Si.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + #pragma code_page(65001) LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT @@ -46,5 +48,3 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "V redu", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON PUSHBUTTON "Prekliči", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } - -#pragma code_page(default) diff --git a/dll/win32/mpr/mpr_Sv.rc b/dll/win32/mpr/mpr_Sv.rc index ef6a685c44d..86d0db6602a 100644 --- a/dll/win32/mpr/mpr_Sv.rc +++ b/dll/win32/mpr/mpr_Sv.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Tr.rc b/dll/win32/mpr/mpr_Tr.rc index b9f3af1fa03..0f48a156a31 100644 --- a/dll/win32/mpr/mpr_Tr.rc +++ b/dll/win32/mpr/mpr_Tr.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/mpr/mpr_Uk.rc b/dll/win32/mpr/mpr_Uk.rc index c5181f11208..67b781d82ad 100644 --- a/dll/win32/mpr/mpr_Uk.rc +++ b/dll/win32/mpr/mpr_Uk.rc @@ -1,7 +1,8 @@ /* - * MPR dll resources (Ukrainian) + * MPR dll Ukrainian resources * - * Copyright 2006 Artem Reznikov + * Copyright (C) 2004 Juan Lang + * Copyright (C) 2007 Artem Reznikov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -15,32 +16,37 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { - IDS_ENTIRENETWORK " " + IDS_ENTIRENETWORK "Вся Мережа" } IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION " " +CAPTION "Введіть Мережний Пароль" FONT 8, "MS Shell Dlg" { - LTEXT " , ' :", IDC_EXPLAIN, 40, 6, 150, 15 - LTEXT "", -1, 40, 26, 50, 10 + LTEXT "Будь ласка, введіть Ваші ім'я та пароль:", IDC_EXPLAIN, 40, 6, 150, 15 + LTEXT "Проксі", -1, 40, 26, 50, 10 /* LTEXT "Realm", -1, 40, 46, 50, 10 */ - LTEXT "", -1, 40, 66, 50, 10 - LTEXT "", -1, 40, 86, 50, 10 + LTEXT "Користувач", -1, 40, 66, 50, 10 + LTEXT "Пароль", -1, 40, 86, 50, 10 LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD - CHECKBOX "& ()", IDC_SAVEPASSWORD, + CHECKBOX "&Зберегти цей пароль (небезпечно)", IDC_SAVEPASSWORD, 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON - PUSHBUTTON "", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP + PUSHBUTTON "Скасувати", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } diff --git a/dll/win32/mpr/mpr_Zh.rc b/dll/win32/mpr/mpr_Zh.rc index 47eb629131b..661e6b4afcd 100644 --- a/dll/win32/mpr/mpr_Zh.rc +++ b/dll/win32/mpr/mpr_Zh.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "mprres.h" + /* Chinese text is encoded in UTF-8 */ #pragma code_page(65001) @@ -74,5 +76,3 @@ FONT 9, "MS Shell Dlg" PUSHBUTTON "確定", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON PUSHBUTTON "取消", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } - -#pragma code_page(default) diff --git a/dll/win32/mpr/mpr_main.c b/dll/win32/mpr/mpr_main.c index 3f9ea4a3c21..5ec6b2209d0 100644 --- a/dll/win32/mpr/mpr_main.c +++ b/dll/win32/mpr/mpr_main.c @@ -78,7 +78,6 @@ BOOL WINAPI _MPR_25( LPBYTE lpMem, INT len ) */ HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("Stub\n"); return S_OK; } diff --git a/dll/win32/mpr/mpr_ros.diff b/dll/win32/mpr/mpr_ros.diff deleted file mode 100644 index d8337d176b1..00000000000 --- a/dll/win32/mpr/mpr_ros.diff +++ /dev/null @@ -1,114 +0,0 @@ -Index: mpr.rc -=================================================================== ---- mpr.rc (revision 23782) -+++ mpr.rc (working copy) -@@ -39,5 +39,7 @@ - #include "mpr_No.rc" - #include "mpr_Pl.rc" - #include "mpr_Pt.rc" -+#include "mpr_Ru.rc" - #include "mpr_Sv.rc" - #include "mpr_Tr.rc" -+#include "mpr_Uk.rc" -Index: mpr_Ru.rc -=================================================================== ---- mpr_Ru.rc (revision 23782) -+++ mpr_Ru.rc (working copy) -@@ -0,0 +1,46 @@ -+/* -+ * MPR dll resources -+ * -+ * Copyright (C) 2005 Mikhail Y. Zvyozdochkin -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -+ -+STRINGTABLE DISCARDABLE -+{ -+ IDS_ENTIRENETWORK " " -+} -+ -+IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 -+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -+CAPTION " " -+FONT 8, "MS Shell Dlg" -+{ -+ LTEXT ", :", IDC_EXPLAIN, 40, 6, 150, 15 -+ LTEXT "-", -1, 40, 26, 50, 10 -+/* LTEXT "Realm", -1, 40, 46, 50, 10 */ -+ LTEXT " ", -1, 40, 66, 50, 10 -+ LTEXT "", -1, 40, 86, 50, 10 -+ LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 -+ LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 -+ EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP -+ EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD -+ CHECKBOX "& ()", IDC_SAVEPASSWORD, -+ 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP -+ PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON -+ PUSHBUTTON "", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP -+} -Index: mpr_Uk.rc -=================================================================== ---- mpr_Uk.rc (revision 23782) -+++ mpr_Uk.rc (working copy) -@@ -0,0 +1,46 @@ -+/* -+ * MPR dll resources (Ukrainian) -+ * -+ * Copyright 2006 Artem Reznikov -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT -+ -+STRINGTABLE DISCARDABLE -+{ -+ IDS_ENTIRENETWORK " " -+} -+ -+IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 -+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -+CAPTION " " -+FONT 8, "MS Shell Dlg" -+{ -+ LTEXT " , ' :", IDC_EXPLAIN, 40, 6, 150, 15 -+ LTEXT "", -1, 40, 26, 50, 10 -+/* LTEXT "Realm", -1, 40, 46, 50, 10 */ -+ LTEXT "", -1, 40, 66, 50, 10 -+ LTEXT "", -1, 40, 86, 50, 10 -+ LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 -+ LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 -+ EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP -+ EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD -+ CHECKBOX "& ()", IDC_SAVEPASSWORD, -+ 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP -+ PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON -+ PUSHBUTTON "", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP -+} diff --git a/dll/win32/mpr/mprres.h b/dll/win32/mpr/mprres.h index 292b4765260..5c42e565477 100644 --- a/dll/win32/mpr/mprres.h +++ b/dll/win32/mpr/mprres.h @@ -18,6 +18,9 @@ #ifndef __WINE_MPRRES_H__ #define __WINE_MPRRES_H__ +#include +#include + #define IDS_ENTIRENETWORK 1 #define IDD_PROXYDLG 0x400 diff --git a/dll/win32/mpr/wnet.c b/dll/win32/mpr/wnet.c index c199cb3aa7e..f5b0bc940c8 100644 --- a/dll/win32/mpr/wnet.c +++ b/dll/win32/mpr/wnet.c @@ -24,6 +24,7 @@ #include "windef.h" #include "winbase.h" #include "winnls.h" +#include "winioctl.h" #include "winnetwk.h" #include "npapi.h" #include "winreg.h" @@ -634,7 +635,10 @@ DWORD WINAPI WNetOpenEnumA( DWORD dwScope, DWORD dwType, DWORD dwUsage, if (!lphEnum) ret = WN_BAD_POINTER; else if (!providerTable || providerTable->numProviders == 0) + { + lphEnum = NULL; ret = WN_NO_NETWORK; + } else { if (lpNet) @@ -723,7 +727,10 @@ DWORD WINAPI WNetOpenEnumW( DWORD dwScope, DWORD dwType, DWORD dwUsage, if (!lphEnum) ret = WN_BAD_POINTER; else if (!providerTable || providerTable->numProviders == 0) + { + lphEnum = NULL; ret = WN_NO_NETWORK; + } else { switch (dwScope) @@ -1923,7 +1930,7 @@ DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR lpLocalPath, DWORD dwInfoLevel, break; } - SetLastError(err); + if (err != WN_NO_ERROR) SetLastError(err); return err; } diff --git a/dll/win32/mscoree/mscoree.spec b/dll/win32/mscoree/mscoree.spec index 04b5e1cda9c..9365f189b51 100644 --- a/dll/win32/mscoree/mscoree.spec +++ b/dll/win32/mscoree/mscoree.spec @@ -31,8 +31,8 @@ @ stub CreateDebuggingInterfaceFromVersion @ stdcall -private DllCanUnloadNow() @ stdcall -private DllGetClassObject(ptr ptr ptr) -@ stub DllRegisterServer -@ stub DllUnregisterServer +@ stdcall -private DllRegisterServer() +@ stdcall -private DllUnregisterServer() @ stub EEDllGetClassObjectFromClass @ stub EEDllRegisterServer @ stub EEDllUnregisterServer diff --git a/dll/win32/mscoree/mscoree_main.c b/dll/win32/mscoree/mscoree_main.c index 5b45adbe29a..dcdc91a5cc1 100644 --- a/dll/win32/mscoree/mscoree_main.c +++ b/dll/win32/mscoree/mscoree_main.c @@ -345,9 +345,20 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) return E_NOTIMPL; } +HRESULT WINAPI DllRegisterServer(void) +{ + FIXME("\n"); + return S_OK; +} + +HRESULT WINAPI DllUnregisterServer(void) +{ + FIXME("\n"); + return S_OK; +} + HRESULT WINAPI DllCanUnloadNow(VOID) { - FIXME("stub\n"); return S_OK; } diff --git a/dll/win32/msctf/langbarmgr.c b/dll/win32/msctf/langbarmgr.c new file mode 100644 index 00000000000..272a8168727 --- /dev/null +++ b/dll/win32/msctf/langbarmgr.c @@ -0,0 +1,193 @@ +/* + * ITfLangBarMgr implementation + * + * Copyright 2010 Justin Chevrier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS + +#include "wine/debug.h" +#include "winbase.h" +#include "winreg.h" +#include "shlwapi.h" + +#include "msctf.h" +#include "msctf_internal.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msctf); + +typedef struct tagLangBarMgr { + const ITfLangBarMgrVtbl *LangBarMgrVtbl; + + LONG refCount; + +} LangBarMgr; + +static void LangBarMgr_Destructor(LangBarMgr *This) +{ + TRACE("destroying %p\n", This); + + HeapFree(GetProcessHeap(),0,This); +} + +static HRESULT WINAPI LangBarMgr_QueryInterface(ITfLangBarMgr *iface, REFIID iid, LPVOID *ppvOut) +{ + LangBarMgr *This = (LangBarMgr *)iface; + *ppvOut = NULL; + + if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfLangBarMgr)) + { + *ppvOut = This; + } + + if (*ppvOut) + { + IUnknown_AddRef(iface); + return S_OK; + } + + WARN("unsupported interface: %s\n", debugstr_guid(iid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI LangBarMgr_AddRef(ITfLangBarMgr *iface) +{ + LangBarMgr *This = (LangBarMgr *)iface; + return InterlockedIncrement(&This->refCount); +} + +static ULONG WINAPI LangBarMgr_Release(ITfLangBarMgr *iface) +{ + LangBarMgr *This = (LangBarMgr *)iface; + ULONG ret; + + ret = InterlockedDecrement(&This->refCount); + if (ret == 0) + LangBarMgr_Destructor(This); + return ret; +} + +/***************************************************** + * ITfLangBarMgr functions + *****************************************************/ + +static HRESULT WINAPI LangBarMgr_AdviseEventSink( ITfLangBarMgr* iface, ITfLangBarEventSink *pSink, HWND hwnd, DWORD dwflags, DWORD *pdwCookie) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_UnAdviseEventSink( ITfLangBarMgr* iface, DWORD dwCookie) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_GetThreadMarshalInterface( ITfLangBarMgr* iface, DWORD dwThreadId, DWORD dwType, REFIID riid, IUnknown **ppunk) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_GetThreadLangBarItemMgr( ITfLangBarMgr* iface, DWORD dwThreadId, ITfLangBarItemMgr **pplbi, DWORD *pdwThreadid) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_GetInputProcessorProfiles( ITfLangBarMgr* iface, DWORD dwThreadId, ITfInputProcessorProfiles **ppaip, DWORD *pdwThreadid) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_RestoreLastFocus( ITfLangBarMgr* iface, DWORD *dwThreadId, BOOL fPrev) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_SetModalInput( ITfLangBarMgr* iface, ITfLangBarEventSink *pSink, DWORD dwThreadId, DWORD dwFlags) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_ShowFloating( ITfLangBarMgr* iface, DWORD dwFlags) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static HRESULT WINAPI LangBarMgr_GetShowFloatingStatus( ITfLangBarMgr* iface, DWORD *pdwFlags) +{ + LangBarMgr *This = (LangBarMgr *)iface; + + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static const ITfLangBarMgrVtbl LangBarMgr_LangBarMgrVtbl = +{ + LangBarMgr_QueryInterface, + LangBarMgr_AddRef, + LangBarMgr_Release, + + LangBarMgr_AdviseEventSink, + LangBarMgr_UnAdviseEventSink, + LangBarMgr_GetThreadMarshalInterface, + LangBarMgr_GetThreadLangBarItemMgr, + LangBarMgr_GetInputProcessorProfiles, + LangBarMgr_RestoreLastFocus, + LangBarMgr_SetModalInput, + LangBarMgr_ShowFloating, + LangBarMgr_GetShowFloatingStatus +}; + +HRESULT LangBarMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) +{ + LangBarMgr *This; + if (pUnkOuter) + return CLASS_E_NOAGGREGATION; + + This = HeapAlloc(GetProcessHeap(),0,sizeof(LangBarMgr)); + if (This == NULL) + return E_OUTOFMEMORY; + + This->LangBarMgrVtbl= &LangBarMgr_LangBarMgrVtbl; + This->refCount = 1; + + TRACE("returning %p\n", This); + *ppOut = (IUnknown *)This; + return S_OK; +} diff --git a/dll/win32/msctf/msctf.c b/dll/win32/msctf/msctf.c index 82772787e41..62d1ff2abd8 100644 --- a/dll/win32/msctf/msctf.c +++ b/dll/win32/msctf/msctf.c @@ -87,6 +87,7 @@ static const struct { {&CLSID_TF_ThreadMgr, ThreadMgr_Constructor}, {&CLSID_TF_InputProcessorProfiles, InputProcessorProfiles_Constructor}, {&CLSID_TF_CategoryMgr, CategoryMgr_Constructor}, + {&CLSID_TF_LangBarMgr, LangBarMgr_Constructor}, {NULL, NULL} }; @@ -351,7 +352,7 @@ HRESULT add_active_textservice(TF_LANGUAGEPROFILE *lp) ActivatedTextService *actsvr; ITfCategoryMgr *catmgr; AtsEntry *entry; - ITfThreadMgr *tm = (ITfThreadMgr*)TlsGetValue(tlsIndex); + ITfThreadMgr *tm = TlsGetValue(tlsIndex); ITfClientId *clientid; if (!tm) return E_UNEXPECTED; @@ -608,3 +609,21 @@ HRESULT WINAPI TF_CreateInputProcessorProfiles( { return InputProcessorProfiles_Constructor(NULL,(IUnknown**)ppipr); } + +/*********************************************************************** + * TF_InvalidAssemblyListCacheIfExist(MSCTF.@) + */ +HRESULT WINAPI TF_InvalidAssemblyListCacheIfExist(void) +{ + FIXME("Stub\n"); + return S_OK; +} + +/*********************************************************************** + * TF_CreateLangBarMgr (MSCTF.@) + */ +HRESULT WINAPI TF_CreateLangBarMgr(ITfLangBarMgr **pppbm) +{ + TRACE("\n"); + return LangBarMgr_Constructor(NULL,(IUnknown**)pppbm); +} diff --git a/dll/win32/msctf/msctf.rbuild b/dll/win32/msctf/msctf.rbuild index d6c531ecbb1..de8f52bf64d 100644 --- a/dll/win32/msctf/msctf.rbuild +++ b/dll/win32/msctf/msctf.rbuild @@ -13,6 +13,7 @@ context.c documentmgr.c inputprocessor.c + langbarmgr.c msctf.c range.c regsvr.c @@ -24,14 +25,6 @@ oleaut32 user32 advapi32 - msctf_local_interface - textstor_local_interface ntdll - - msctf_local.idl - - - textstor_local.idl - diff --git a/dll/win32/msctf/msctf.spec b/dll/win32/msctf/msctf.spec index f7c35a3a64a..387af570021 100644 --- a/dll/win32/msctf/msctf.spec +++ b/dll/win32/msctf/msctf.spec @@ -13,7 +13,7 @@ @ stub TF_CreateDisplayAttributeMgr @ stdcall TF_CreateInputProcessorProfiles(ptr) @ stub TF_CreateLangBarItemMgr -@ stub TF_CreateLangBarMgr +@ stdcall TF_CreateLangBarMgr(ptr) @ stdcall TF_CreateThreadMgr(ptr) @ stub TF_DllDetachInOther @ stub TF_GetGlobalCompartment @@ -27,7 +27,7 @@ @ stub TF_InitMlngInfo @ stub TF_InitSystem @ stub TF_InvalidAssemblyListCache -@ stub TF_InvalidAssemblyListCacheIfExist +@ stdcall TF_InvalidAssemblyListCacheIfExist() @ stub TF_IsCtfmonRunning @ stub TF_IsInMarshaling @ stub TF_MlngInfoCount diff --git a/dll/win32/msctf/msctf_internal.h b/dll/win32/msctf/msctf_internal.h index 3bb0baa6ee7..57423e996fc 100644 --- a/dll/win32/msctf/msctf_internal.h +++ b/dll/win32/msctf/msctf_internal.h @@ -40,6 +40,7 @@ extern HRESULT CategoryMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut); extern HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD lockType, DWORD anchorStart, DWORD anchorEnd, ITfRange **ppOut); extern HRESULT CompartmentMgr_Constructor(IUnknown *pUnkOuter, REFIID riid, IUnknown **ppOut); extern HRESULT CompartmentMgr_Destructor(ITfCompartmentMgr *This); +extern HRESULT LangBarMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut); extern HRESULT Context_Initialize(ITfContext *cxt, ITfDocumentMgr *manager); extern HRESULT Context_Uninitialize(ITfContext *cxt); diff --git a/dll/win32/msctf/msctf_local.idl b/dll/win32/msctf/msctf_local.idl deleted file mode 100644 index cc8b7e65af5..00000000000 --- a/dll/win32/msctf/msctf_local.idl +++ /dev/null @@ -1,2 +0,0 @@ - -#include "msctf.idl" diff --git a/dll/win32/msctf/regsvr.c b/dll/win32/msctf/regsvr.c index a47d984296f..2af1f241154 100644 --- a/dll/win32/msctf/regsvr.c +++ b/dll/win32/msctf/regsvr.c @@ -462,6 +462,13 @@ static struct regsvr_coclass const coclass_list[] = { "msctf.dll", "Apartment" }, + { + &CLSID_TF_LangBarMgr, + "TF_LangBarMgr", + NULL, + "msctf.dll", + "Apartment" + }, { NULL } /* list terminator */ }; @@ -474,7 +481,7 @@ static struct regsvr_interface const interface_list[] = { }; /*********************************************************************** - * DllRegisterServer (HHCTRL.@) + * DllRegisterServer (MSCTF.@) */ HRESULT WINAPI DllRegisterServer(void) { @@ -489,7 +496,7 @@ HRESULT WINAPI DllRegisterServer(void) } /*********************************************************************** - * DllUnregisterServer (HHCTRL.@) + * DllUnregisterServer (MSCTF.@) */ HRESULT WINAPI DllUnregisterServer(void) { diff --git a/dll/win32/msctf/textstor_local.idl b/dll/win32/msctf/textstor_local.idl deleted file mode 100644 index a665b253969..00000000000 --- a/dll/win32/msctf/textstor_local.idl +++ /dev/null @@ -1,2 +0,0 @@ - -#include "textstor.idl" diff --git a/dll/win32/msctf/threadmgr.c b/dll/win32/msctf/threadmgr.c index b77e0f2c0b7..5f3a90abb5a 100644 --- a/dll/win32/msctf/threadmgr.c +++ b/dll/win32/msctf/threadmgr.c @@ -88,7 +88,7 @@ typedef struct tagACLMulti { /* const ITfConfigureSystemKeystrokeFeedVtbl *ConfigureSystemKeystrokeFeedVtbl; */ /* const ITfLangBarItemMgrVtbl *LangBarItemMgrVtbl; */ /* const ITfUIElementMgrVtbl *UIElementMgrVtbl; */ - /* const ITfSourceSingleVtbl *SourceSingleVtbl; */ + const ITfSourceSingleVtbl *SourceSingleVtbl; LONG refCount; /* Aggregation */ @@ -126,7 +126,6 @@ typedef struct tagEnumTfDocumentMgr { } EnumTfDocumentMgr; static HRESULT EnumTfDocumentMgr_Constructor(struct list* head, IEnumTfDocumentMgrs **ppOut); -LRESULT CALLBACK ThreadFocusHookProc(int nCode, WPARAM wParam, LPARAM lParam); static inline ThreadMgr *impl_from_ITfSourceVtbl(ITfSource *iface) { @@ -153,20 +152,10 @@ static inline ThreadMgr *impl_from_ITfThreadMgrEventSink(ITfThreadMgrEventSink * return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,ThreadMgrEventSinkVtbl)); } -static HRESULT SetupWindowsHook(ThreadMgr *This) +static inline ThreadMgr *impl_from_ITfSourceSingleVtbl(ITfSourceSingle* iface) + { - if (!This->focusHook) - { - This->focusHook = SetWindowsHookExW(WH_CBT, ThreadFocusHookProc, 0, - GetCurrentThreadId()); - if (!This->focusHook) - { - ERR("Unable to set focus hook\n"); - return E_FAIL; - } - return S_OK; - } - return S_FALSE; + return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,SourceSingleVtbl)); } static void free_sink(ThreadMgrSink *sink) @@ -283,6 +272,10 @@ static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid, { *ppvOut = This->CompartmentMgr; } + else if (IsEqualIID(iid, &IID_ITfSourceSingle)) + { + *ppvOut = &This->SourceSingleVtbl; + } if (*ppvOut) { @@ -441,6 +434,58 @@ static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *p return S_OK; } +static LRESULT CALLBACK ThreadFocusHookProc(int nCode, WPARAM wParam, LPARAM lParam) +{ + ThreadMgr *This; + + This = TlsGetValue(tlsIndex); + if (!This) + { + ERR("Hook proc but no ThreadMgr for this thread. Serious Error\n"); + return 0; + } + if (!This->focusHook) + { + ERR("Hook proc but no ThreadMgr focus Hook. Serious Error\n"); + return 0; + } + + if (nCode == HCBT_SETFOCUS) /* focus change within our thread */ + { + struct list *cursor; + + LIST_FOR_EACH(cursor, &This->AssociatedFocusWindows) + { + AssociatedWindow *wnd = LIST_ENTRY(cursor,AssociatedWindow,entry); + if (wnd->hwnd == (HWND)wParam) + { + TRACE("Triggering Associated window focus\n"); + if (This->focus != wnd->docmgr) + ThreadMgr_SetFocus((ITfThreadMgr*)This, wnd->docmgr); + break; + } + } + } + + return CallNextHookEx(This->focusHook, nCode, wParam, lParam); +} + +static HRESULT SetupWindowsHook(ThreadMgr *This) +{ + if (!This->focusHook) + { + This->focusHook = SetWindowsHookExW(WH_CBT, ThreadFocusHookProc, 0, + GetCurrentThreadId()); + if (!This->focusHook) + { + ERR("Unable to set focus hook\n"); + return E_FAIL; + } + return S_OK; + } + return S_FALSE; +} + static HRESULT WINAPI ThreadMgr_AssociateFocus( ITfThreadMgr* iface, HWND hwnd, ITfDocumentMgr *pdimNew, ITfDocumentMgr **ppdimPrev) { @@ -838,6 +883,7 @@ static HRESULT WINAPI KeystrokeMgr_PreserveKey(ITfKeystrokeMgr *iface, newkey->guid = *rguid; newkey->prekey = *prekey; newkey->tid = tid; + newkey->description = NULL; if (cchDesc) { newkey->description = HeapAlloc(GetProcessHeap(),0,cchDesc * sizeof(WCHAR)); @@ -1172,6 +1218,53 @@ static const ITfThreadMgrEventSinkVtbl ThreadMgr_ThreadMgrEventSinkVtbl = ThreadMgrEventSink_OnPopContext }; +/***************************************************** + * ITfSourceSingle functions + *****************************************************/ +static HRESULT WINAPI ThreadMgrSourceSingle_QueryInterface(ITfSourceSingle *iface, REFIID iid, LPVOID *ppvOut) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut); +} + +static ULONG WINAPI ThreadMgrSourceSingle_AddRef(ITfSourceSingle *iface) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + return ThreadMgr_AddRef((ITfThreadMgr *)This); +} + +static ULONG WINAPI ThreadMgrSourceSingle_Release(ITfSourceSingle *iface) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + return ThreadMgr_Release((ITfThreadMgr *)This); +} + +static HRESULT WINAPI ThreadMgrSourceSingle_AdviseSingleSink( ITfSourceSingle *iface, + TfClientId tid, REFIID riid, IUnknown *punk) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + FIXME("STUB:(%p) %i %s %p\n",This, tid, debugstr_guid(riid),punk); + return E_NOTIMPL; +} + +static HRESULT WINAPI ThreadMgrSourceSingle_UnadviseSingleSink( ITfSourceSingle *iface, + TfClientId tid, REFIID riid) +{ + ThreadMgr *This = impl_from_ITfSourceSingleVtbl(iface); + FIXME("STUB:(%p) %i %s\n",This, tid, debugstr_guid(riid)); + return E_NOTIMPL; +} + +static const ITfSourceSingleVtbl ThreadMgr_SourceSingleVtbl = +{ + ThreadMgrSourceSingle_QueryInterface, + ThreadMgrSourceSingle_AddRef, + ThreadMgrSourceSingle_Release, + + ThreadMgrSourceSingle_AdviseSingleSink, + ThreadMgrSourceSingle_UnadviseSingleSink, +}; + HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) { ThreadMgr *This; @@ -1197,6 +1290,7 @@ HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) This->MessagePumpVtbl= &ThreadMgr_MessagePumpVtbl; This->ClientIdVtbl = &ThreadMgr_ClientIdVtbl; This->ThreadMgrEventSinkVtbl = &ThreadMgr_ThreadMgrEventSinkVtbl; + This->SourceSingleVtbl = &ThreadMgr_SourceSingleVtbl; This->refCount = 1; TlsSetValue(tlsIndex,This); @@ -1378,39 +1472,3 @@ void ThreadMgr_OnDocumentMgrDestruction(ITfThreadMgr *tm, ITfDocumentMgr *mgr) } FIXME("ITfDocumenMgr %p not found in this thread\n",mgr); } - -LRESULT CALLBACK ThreadFocusHookProc(int nCode, WPARAM wParam, LPARAM lParam) -{ - ThreadMgr *This; - - This = TlsGetValue(tlsIndex); - if (!This) - { - ERR("Hook proc but no ThreadMgr for this thread. Serious Error\n"); - return 0; - } - if (!This->focusHook) - { - ERR("Hook proc but no ThreadMgr focus Hook. Serious Error\n"); - return 0; - } - - if (nCode == HCBT_SETFOCUS) /* focus change within our thread */ - { - struct list *cursor; - - LIST_FOR_EACH(cursor, &This->AssociatedFocusWindows) - { - AssociatedWindow *wnd = LIST_ENTRY(cursor,AssociatedWindow,entry); - if (wnd->hwnd == (HWND)wParam) - { - TRACE("Triggering Associated window focus\n"); - if (This->focus != wnd->docmgr) - ThreadMgr_SetFocus((ITfThreadMgr*)This, wnd->docmgr); - break; - } - } - } - - return CallNextHookEx(This->focusHook, nCode, wParam, lParam); -} diff --git a/dll/win32/mshtml/De.rc b/dll/win32/mshtml/De.rc index 219549c8b7a..43e0cfe85a5 100644 --- a/dll/win32/mshtml/De.rc +++ b/dll/win32/mshtml/De.rc @@ -72,4 +72,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "Abbrechen", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } - +#pragma code_page(default) diff --git a/dll/win32/mshtml/Fr.rc b/dll/win32/mshtml/Fr.rc index 0d14f452e8b..84ee453128f 100644 --- a/dll/win32/mshtml/Fr.rc +++ b/dll/win32/mshtml/Fr.rc @@ -72,3 +72,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "Annuler", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/dll/win32/mshtml/It.rc b/dll/win32/mshtml/It.rc new file mode 100644 index 00000000000..4b262c56e3a --- /dev/null +++ b/dll/win32/mshtml/It.rc @@ -0,0 +1,72 @@ +/* + * Copyright 2010 Luca Bennati + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/*UTF-8*/ +#pragma code_page(65001) + +LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_HTMLDISABLED "Il rendering HTML è correntemente disattivato." + IDS_HTMLDOCUMENT "Documento HTML" + IDS_DOWNLOADING "Scaricando..." + IDS_INSTALLING "Installando..." +} + +ID_DWL_DIALOG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 260, 95 +STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Installer di Wine Gecko" +FONT 8, "MS Shell Dlg" +{ + LTEXT "Wine non ha trovato un pacchetto Gecko che è necessario per applicazioni che incorporano HTML " \ + "per funzionare correttamente. Wine può automaticamente scaricarlo ed installarlo per te.\n\n" \ + "Nota: è raccomandato usare i pacchetti delle distribuzioni. Leggi http://wiki.winehq.org/Gecko per i dettagli.", + ID_DWL_STATUS, 10, 10, 240, 50, SS_LEFT + CONTROL "Avanzamento", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 40, 240, 12 + DEFPUSHBUTTON "&Installa", ID_DWL_INSTALL, 200, 70, 50, 15, WS_GROUP | WS_TABSTOP + PUSHBUTTON "&Annulla", IDCANCEL, 140, 70, 50, 15, WS_GROUP | WS_TABSTOP +} + +IDD_HYPERLINK DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 250, 65 +STYLE DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Hyperlink" +FONT 8, "MS Shell Dlg" +{ + GROUPBOX "Informazioni sull'hyperlink", -1, 5, 5, 190, 55 + LTEXT "&Tipo:", -1, 10, 22, 20, 10 + COMBOBOX IDC_TYPE, 35, 20, 45, 100, WS_TABSTOP | WS_GROUP | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS + LTEXT "&URL:", -1, 10, 42, 20, 10 + EDITTEXT IDC_URL, 35, 40, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 200, 10, 45, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Annulla", IDCANCEL, 200, 28, 45, 14, WS_GROUP | WS_TABSTOP +} + +ID_PROMPT_DIALOG DIALOG 0, 0, 200, 90 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "" +FONT 8, "MS Shell Dlg" +{ + LTEXT "", ID_PROMPT_PROMPT, 10, 10, 180, 30 + EDITTEXT ID_PROMPT_EDIT, 10, 45, 180, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Annulla", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP +} +#pragma code_page(default) diff --git a/dll/win32/mshtml/Ja.rc b/dll/win32/mshtml/Ja.rc index 04fc32e785b..40db7b5f867 100644 --- a/dll/win32/mshtml/Ja.rc +++ b/dll/win32/mshtml/Ja.rc @@ -69,3 +69,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "キャンセル", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/dll/win32/mshtml/Lt.rc b/dll/win32/mshtml/Lt.rc index 8f7e772a3a7..560cc08dd16 100644 --- a/dll/win32/mshtml/Lt.rc +++ b/dll/win32/mshtml/Lt.rc @@ -69,3 +69,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "Gerai", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "Atsisakyti", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/dll/win32/mshtml/No.rc b/dll/win32/mshtml/No.rc index 4592599edf3..3a3b45d7a42 100644 --- a/dll/win32/mshtml/No.rc +++ b/dll/win32/mshtml/No.rc @@ -70,3 +70,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "Avbryt", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/dll/win32/mshtml/Si.rc b/dll/win32/mshtml/Si.rc index 6881addcd5b..500081bc790 100644 --- a/dll/win32/mshtml/Si.rc +++ b/dll/win32/mshtml/Si.rc @@ -68,3 +68,4 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "V redu", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP PUSHBUTTON "Prekliči", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP } +#pragma code_page(default) diff --git a/dll/win32/mshtml/Uk.rc b/dll/win32/mshtml/Uk.rc new file mode 100644 index 00000000000..5e11b4dccfb --- /dev/null +++ b/dll/win32/mshtml/Uk.rc @@ -0,0 +1,72 @@ +/* + * Copyright 2005-2006 Jacek Caban + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_HTMLDISABLED "HTML rendering is currently disabled." + IDS_HTMLDOCUMENT "Документ HTML" + IDS_DOWNLOADING "Завантаження..." + IDS_INSTALLING "Встановлення..." +} + +ID_DWL_DIALOG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 260, 95 +STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Wine Gecko Installer" +FONT 8, "MS Shell Dlg" +{ + LTEXT "Wine не може знайти пакунок Gecko, який потрібний для додатків embedding HTML " \ + "для коректної роботи. Wine може автоматично завантажити та встановити його для Вас.\n\n" \ + "Зауважте: Рекомендується використати пакет з вашого дистрибутиву. Детальніше читайте http://wiki.winehq.org/Gecko.", + ID_DWL_STATUS, 10, 10, 240, 50, SS_LEFT + CONTROL "Прогрес", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 40, 240, 12 + DEFPUSHBUTTON "&Встановити", ID_DWL_INSTALL, 200, 70, 50, 15, WS_GROUP | WS_TABSTOP + PUSHBUTTON "&Скасувати", IDCANCEL, 140, 70, 50, 15, WS_GROUP | WS_TABSTOP +} + +IDD_HYPERLINK DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 250, 65 +STYLE DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Гіперпосилання" +FONT 8, "MS Shell Dlg" +{ + GROUPBOX "Дані про Гіперпосилання", -1, 5, 5, 190, 55 + LTEXT "&Тип:", -1, 10, 22, 20, 10 + COMBOBOX IDC_TYPE, 35, 20, 45, 100, WS_TABSTOP | WS_GROUP | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS + LTEXT "&URL:", -1, 10, 42, 20, 10 + EDITTEXT IDC_URL, 35, 40, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 200, 10, 45, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Скасувати", IDCANCEL, 200, 28, 45, 14, WS_GROUP | WS_TABSTOP +} + +ID_PROMPT_DIALOG DIALOG 0, 0, 200, 90 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "" +FONT 8, "MS Shell Dlg" +{ + LTEXT "", ID_PROMPT_PROMPT, 10, 10, 180, 30 + EDITTEXT ID_PROMPT_EDIT, 10, 45, 180, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Скасувати", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP +} diff --git a/dll/win32/mshtml/dispex.c b/dll/win32/mshtml/dispex.c index c77ebb92218..4b1bd882e5e 100644 --- a/dll/win32/mshtml/dispex.c +++ b/dll/win32/mshtml/dispex.c @@ -92,6 +92,7 @@ static REFIID tid_ids[] = { &DIID_DispHTMLElementCollection, &DIID_DispHTMLFormElement, &DIID_DispHTMLGenericElement, + &DIID_DispHTMLFrameElement, &DIID_DispHTMLIFrame, &DIID_DispHTMLImg, &DIID_DispHTMLInputElement, @@ -99,10 +100,12 @@ static REFIID tid_ids[] = { &DIID_DispHTMLNavigator, &DIID_DispHTMLOptionElement, &DIID_DispHTMLScreen, + &DIID_DispHTMLScriptElement, &DIID_DispHTMLSelectElement, &DIID_DispHTMLStyle, &DIID_DispHTMLTable, &DIID_DispHTMLTableRow, + &DIID_DispHTMLTextAreaElement, &DIID_DispHTMLUnknownElement, &DIID_DispHTMLWindow2, &DIID_HTMLDocumentEvents, @@ -133,12 +136,15 @@ static REFIID tid_ids[] = { &IID_IHTMLFrameBase, &IID_IHTMLFrameBase2, &IID_IHTMLGenericElement, + &IID_IHTMLFrameElement3, + &IID_IHTMLIFrameElement, &IID_IHTMLImageElementFactory, &IID_IHTMLImgElement, &IID_IHTMLInputElement, &IID_IHTMLLocation, &IID_IHTMLOptionElement, &IID_IHTMLScreen, + &IID_IHTMLScriptElement, &IID_IHTMLSelectElement, &IID_IHTMLStyle, &IID_IHTMLStyle2, @@ -146,6 +152,7 @@ static REFIID tid_ids[] = { &IID_IHTMLStyle4, &IID_IHTMLTable, &IID_IHTMLTableRow, + &IID_IHTMLTextAreaElement, &IID_IHTMLTextContainer, &IID_IHTMLUniqueName, &IID_IHTMLWindow2, @@ -397,18 +404,19 @@ HRESULT call_disp_func(IDispatch *disp, DISPPARAMS *dp) VARIANT res; HRESULT hres; - hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); - if(FAILED(hres)) { - FIXME("Could not get IDispatchEx interface: %08x\n", hres); - return hres; - } - VariantInit(&res); memset(&ei, 0, sizeof(ei)); - hres = IDispatchEx_InvokeEx(dispex, 0, GetUserDefaultLCID(), DISPATCH_METHOD, dp, &res, &ei, NULL); + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + if(SUCCEEDED(hres)) { + hres = IDispatchEx_InvokeEx(dispex, 0, GetUserDefaultLCID(), DISPATCH_METHOD, dp, &res, &ei, NULL); + IDispatchEx_Release(dispex); + }else { + TRACE("Could not get IDispatchEx interface: %08x\n", hres); + hres = IDispatch_Invoke(disp, 0, &IID_NULL, GetUserDefaultLCID(), DISPATCH_METHOD, + dp, &res, &ei, NULL); + } - IDispatchEx_Release(dispex); VariantClear(&res); return hres; } @@ -975,7 +983,10 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex) { DispatchEx *This = DISPATCHEX_THIS(iface); - FIXME("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex); + + TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex); + + /* Not implemented by IE */ return E_NOTIMPL; } diff --git a/dll/win32/mshtml/editor.c b/dll/win32/mshtml/editor.c index 568e127220f..961bb916370 100644 --- a/dll/win32/mshtml/editor.c +++ b/dll/win32/mshtml/editor.c @@ -298,7 +298,7 @@ static void get_font_size(HTMLDocument *This, WCHAR *ret) TRACE("found font tag %p\n", elem); - nsAString_Init(&size_str, sizeW); + nsAString_InitDepend(&size_str, sizeW); nsAString_Init(&val_str, NULL); nsIDOMElement_GetAttribute(elem, &size_str, &val_str); @@ -360,10 +360,11 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size) create_nselem(This->doc_node, fontW, &elem); - nsAString_Init(&size_str, sizeW); - nsAString_Init(&val_str, size); + nsAString_InitDepend(&size_str, sizeW); + nsAString_InitDepend(&val_str, size); nsIDOMElement_SetAttribute(elem, &size_str, &val_str); + nsAString_Finish(&val_str); nsISelection_GetRangeAt(nsselection, 0, &range); nsISelection_GetIsCollapsed(nsselection, &collapsed); @@ -384,7 +385,6 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size) nsIDOMElement_Release(elem); nsAString_Finish(&size_str); - nsAString_Finish(&val_str); set_dirty(This, VARIANT_TRUE); } @@ -1167,8 +1167,8 @@ static HRESULT exec_hyperlink(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, /* create an element for the link */ create_nselem(This->doc_node, aW, &anchor_elem); - nsAString_Init(&href_str, hrefW); - nsAString_Init(&ns_url, url); + nsAString_InitDepend(&href_str, hrefW); + nsAString_InitDepend(&ns_url, url); nsIDOMElement_SetAttribute(anchor_elem, &href_str, &ns_url); nsAString_Finish(&href_str); diff --git a/dll/win32/mshtml/htmlanchor.c b/dll/win32/mshtml/htmlanchor.c index 6bbaf26dfae..ae269ee252b 100644 --- a/dll/win32/mshtml/htmlanchor.c +++ b/dll/win32/mshtml/htmlanchor.c @@ -520,12 +520,7 @@ static const NodeImplVtbl HTMLAnchorElementImplVtbl = { static const tid_t HTMLAnchorElement_iface_tids[] = { IHTMLAnchorElement_tid, - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, - IHTMLElement4_tid, + HTMLELEMENT_TIDS, IHTMLTextContainer_tid, IHTMLUniqueName_tid, 0 diff --git a/dll/win32/mshtml/htmlbody.c b/dll/win32/mshtml/htmlbody.c index 7f22a4e06a6..5c66e65a44a 100644 --- a/dll/win32/mshtml/htmlbody.c +++ b/dll/win32/mshtml/htmlbody.c @@ -252,23 +252,18 @@ static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dis static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v) { HTMLBodyElement *This = HTMLBODY_THIS(iface); - HRESULT hr = S_OK; nsAString nsstr; nsresult nsres; TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&nsstr, v); - + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLBodyElement_SetBackground(This->nsbody, &nsstr); - if(!NS_SUCCEEDED(nsres)) - { - hr = E_FAIL; - } - nsAString_Finish(&nsstr); + if(NS_FAILED(nsres)) + return E_FAIL; - return hr; + return S_OK; } static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p) @@ -799,12 +794,7 @@ static const NodeImplVtbl HTMLBodyElementImplVtbl = { static const tid_t HTMLBodyElement_iface_tids[] = { IHTMLBodyElement_tid, IHTMLBodyElement2_tid, - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, - IHTMLElement4_tid, + HTMLELEMENT_TIDS, IHTMLTextContainer_tid, IHTMLUniqueName_tid, 0 diff --git a/dll/win32/mshtml/htmlcomment.c b/dll/win32/mshtml/htmlcomment.c index e38432c4a67..7040d184077 100644 --- a/dll/win32/mshtml/htmlcomment.c +++ b/dll/win32/mshtml/htmlcomment.c @@ -103,8 +103,10 @@ static HRESULT WINAPI HTMLCommentElement_put_text(IHTMLCommentElement *iface, BS static HRESULT WINAPI HTMLCommentElement_get_text(IHTMLCommentElement *iface, BSTR *p) { HTMLCommentElement *This = HTMLCOMMENT_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return IHTMLElement_get_outerHTML(HTMLELEM(&This->element), p); } static HRESULT WINAPI HTMLCommentElement_put_atomic(IHTMLCommentElement *iface, LONG v) @@ -171,11 +173,7 @@ static const NodeImplVtbl HTMLCommentElementImplVtbl = { }; static const tid_t HTMLCommentElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLCommentElement_tid, 0 }; diff --git a/dll/win32/mshtml/htmldoc.c b/dll/win32/mshtml/htmldoc.c index ac67a84cc60..8adfdb14b43 100644 --- a/dll/win32/mshtml/htmldoc.c +++ b/dll/win32/mshtml/htmldoc.c @@ -348,7 +348,7 @@ static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v) return E_UNEXPECTED; } - nsAString_Init(&nsstr, v); + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) @@ -776,6 +776,9 @@ static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln) return E_UNEXPECTED; } + if (!psarray) + return S_OK; + if(psarray->cDims != 1) { FIXME("cDims=%d\n", psarray->cDims); return E_INVALIDARG; @@ -1770,6 +1773,12 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv) }else if(IsEqualGUID(&IID_IMarshal, riid)) { TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv); *ppv = NULL; + }else if(IsEqualGUID(&IID_IExternalConnection, riid)) { + TRACE("(%p)->(IID_IExternalConnection %p) returning NULL\n", This, ppv); + *ppv = NULL; + }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) { + TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv); + *ppv = NULL; }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) { TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv); *ppv = OBJSITE(This); @@ -1989,6 +1998,8 @@ static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface) if(This->basedoc.advise_holder) IOleAdviseHolder_Release(This->basedoc.advise_holder); + if(This->view_sink) + IAdviseSink_Release(This->view_sink); if(This->client) IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL); if(This->in_place_active) diff --git a/dll/win32/mshtml/htmldoc3.c b/dll/win32/mshtml/htmldoc3.c index de32302c935..9079bbc79c7 100644 --- a/dll/win32/mshtml/htmldoc3.c +++ b/dll/win32/mshtml/htmldoc3.c @@ -116,7 +116,7 @@ static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR t return E_UNEXPECTED; } - nsAString_Init(&text_str, text); + nsAString_InitDepend(&text_str, text); nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { @@ -443,7 +443,7 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v return E_UNEXPECTED; } - nsAString_Init(&id_str, v); + nsAString_InitDepend(&id_str, v); /* get element by id attribute */ nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &id_str, &nselem); if(FAILED(nsres)) { @@ -455,9 +455,9 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v /* get first element by name attribute */ nsres = nsIDOMHTMLDocument_GetElementsByName(This->doc_node->nsdoc, &id_str, &nsnode_list); + nsAString_Finish(&id_str); if(FAILED(nsres)) { ERR("getElementsByName failed: %08x\n", nsres); - nsAString_Finish(&id_str); if(nsnode_by_id) nsIDOMNode_Release(nsnode_by_id); return E_FAIL; @@ -465,7 +465,6 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v nsIDOMNodeList_Item(nsnode_list, 0, &nsnode_by_name); nsIDOMNodeList_Release(nsnode_list); - nsAString_Finish(&id_str); if(nsnode_by_name && nsnode_by_id) { nsIDOM3Node *node3; @@ -528,8 +527,8 @@ static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, return E_UNEXPECTED; } - nsAString_Init(&id_str, v); - nsAString_Init(&ns_str, str); + nsAString_InitDepend(&id_str, v); + nsAString_InitDepend(&ns_str, str); nsres = nsIDOMHTMLDocument_GetElementsByTagNameNS(This->doc_node->nsdoc, &ns_str, &id_str, &nslist); nsAString_Finish(&id_str); nsAString_Finish(&ns_str); diff --git a/dll/win32/mshtml/htmldoc5.c b/dll/win32/mshtml/htmldoc5.c index e3b14231e69..12742f64126 100644 --- a/dll/win32/mshtml/htmldoc5.c +++ b/dll/win32/mshtml/htmldoc5.c @@ -136,7 +136,7 @@ static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bs return E_UNEXPECTED; } - nsAString_Init(&str, bstrdata); + nsAString_InitDepend(&str, bstrdata); nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment); nsAString_Finish(&str); if(NS_FAILED(nsres)) { diff --git a/dll/win32/mshtml/htmlelem.c b/dll/win32/mshtml/htmlelem.c index a65ed20065e..e77c1dc4c42 100644 --- a/dll/win32/mshtml/htmlelem.c +++ b/dll/win32/mshtml/htmlelem.c @@ -65,7 +65,7 @@ HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement return E_UNEXPECTED; } - nsAString_Init(&tag_str, tag); + nsAString_InitDepend(&tag_str, tag); nsres = nsIDOMDocument_CreateElement(doc->nsdoc, &tag_str, &nselem); nsAString_Finish(&tag_str); if(NS_FAILED(nsres)) { @@ -215,7 +215,7 @@ static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v) return E_NOTIMPL; } - nsAString_Init(&classname_str, v); + nsAString_InitDepend(&classname_str, v); nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str); nsAString_Finish(&classname_str); if(NS_FAILED(nsres)) @@ -269,7 +269,7 @@ static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v) return S_OK; } - nsAString_Init(&id_str, v); + nsAString_InitDepend(&id_str, v); nsres = nsIDOMHTMLElement_SetId(This->nselem, &id_str); nsAString_Finish(&id_str); if(NS_FAILED(nsres)) @@ -593,6 +593,8 @@ static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch ** return S_OK; } +static const WCHAR titleW[] = {'t','i','t','l','e',0}; + static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v) { HTMLElement *This = HTMLELEM_THIS(iface); @@ -601,7 +603,21 @@ static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&title_str, v); + if(!This->nselem) { + VARIANT *var; + HRESULT hres; + + hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var); + if(FAILED(hres)) + return hres; + + VariantClear(var); + V_VT(var) = VT_BSTR; + V_BSTR(var) = v ? SysAllocString(v) : NULL; + return S_OK; + } + + nsAString_InitDepend(&title_str, v); nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str); nsAString_Finish(&title_str); if(NS_FAILED(nsres)) @@ -618,6 +634,23 @@ static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p) TRACE("(%p)->(%p)\n", This, p); + if(!This->nselem) { + VARIANT *var; + HRESULT hres; + + hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var); + if(hres == DISP_E_UNKNOWNNAME) { + *p = NULL; + }else if(V_VT(var) != VT_BSTR) { + FIXME("title = %s\n", debugstr_variant(var)); + return E_FAIL; + }else { + *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL; + } + + return S_OK; + } + nsAString_Init(&title_str, NULL); nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str); if(NS_SUCCEEDED(nsres)) { @@ -820,7 +853,7 @@ static HRESULT WINAPI HTMLElement_put_innerHTML(IHTMLElement *iface, BSTR v) return E_FAIL; } - nsAString_Init(&html_str, v); + nsAString_InitDepend(&html_str, v); nsres = nsIDOMNSHTMLElement_SetInnerHTML(nselem, &html_str); nsAString_Finish(&html_str); @@ -896,7 +929,7 @@ static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v) nsIDOMNode_Release(tmp); } - nsAString_Init(&text_str, v); + nsAString_InitDepend(&text_str, v); nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { @@ -955,7 +988,7 @@ static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v) return E_FAIL; } - nsAString_Init(&html_str, v); + nsAString_InitDepend(&html_str, v); nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment); nsIDOMNSRange_Release(nsrange); nsAString_Finish(&html_str); @@ -1131,7 +1164,7 @@ static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR w return E_FAIL; } - nsAString_Init(&ns_html, html); + nsAString_InitDepend(&ns_html, html); nsres = nsIDOMNSRange_CreateContextualFragment(nsrange, &ns_html, (nsIDOMDocumentFragment **)&nsnode); nsIDOMNSRange_Release(nsrange); @@ -1166,7 +1199,7 @@ static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR w } - nsAString_Init(&ns_text, text); + nsAString_InitDepend(&ns_text, text); nsres = nsIDOMDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode); nsAString_Finish(&ns_text); @@ -1572,11 +1605,7 @@ static const NodeImplVtbl HTMLElementImplVtbl = { }; static const tid_t HTMLElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, 0 }; @@ -1675,7 +1704,7 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL if(!ret) { ret = heap_alloc_zero(sizeof(HTMLElement)); - HTMLElement_Init(ret, doc, nselem, NULL); + HTMLElement_Init(ret, doc, nselem, &HTMLElement_dispex); ret->node.vtbl = &HTMLElementImplVtbl; } diff --git a/dll/win32/mshtml/htmlelem2.c b/dll/win32/mshtml/htmlelem2.c index cd9b6764857..cd877ceaf30 100644 --- a/dll/win32/mshtml/htmlelem2.c +++ b/dll/win32/mshtml/htmlelem2.c @@ -655,8 +655,10 @@ static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event, static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp) { HTMLElement *This = HTMLELEM2_THIS(iface); - FIXME("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp); - return E_NOTIMPL; + + TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp); + + return detach_event(*get_node_event_target(&This->node), &This->node.doc->basedoc, event, pDisp); } static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p) @@ -1087,7 +1089,7 @@ static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BS TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl); - nsAString_Init(&tag_str, v); + nsAString_InitDepend(&tag_str, v); nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nslist); nsAString_Finish(&tag_str); if(NS_FAILED(nsres)) { diff --git a/dll/win32/mshtml/htmlelemcol.c b/dll/win32/mshtml/htmlelemcol.c index c9737077382..9c0fedde8d0 100644 --- a/dll/win32/mshtml/htmlelemcol.c +++ b/dll/win32/mshtml/htmlelemcol.c @@ -245,7 +245,7 @@ static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name) return TRUE; } - nsAString_Init(&nsname, nameW); + nsAString_InitDepend(&nsname, nameW); nsres = nsIDOMHTMLElement_GetAttribute(elem->nselem, &nsname, &nsstr); nsAString_Finish(&nsname); if(NS_SUCCEEDED(nsres)) { diff --git a/dll/win32/mshtml/htmlevent.c b/dll/win32/mshtml/htmlevent.c index d04b2e66370..54429c34a20 100644 --- a/dll/win32/mshtml/htmlevent.c +++ b/dll/win32/mshtml/htmlevent.c @@ -743,7 +743,7 @@ static IHTMLEventObj *create_event(HTMLDOMNode *target, eventid_t eid, nsIDOMEve if(NS_SUCCEEDED(nsres)) { nsAString type_str; - nsAString_Init(&type_str, event_types[event_info[eid].type]); + nsAString_InitDepend(&type_str, event_types[event_info[eid].type]); nsres = nsIDOMDocumentEvent_CreateEvent(doc_event, &type_str, &ret->nsevent); nsAString_Finish(&type_str); nsIDOMDocumentEvent_Release(doc_event); @@ -816,7 +816,7 @@ static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj, ConnectionPointContainer *cp_container, eventid_t eid, IDispatch *this_obj) { handler_vector_t *handler_vector = NULL; - DWORD i; + int i; HRESULT hres; if(event_target) @@ -845,7 +845,8 @@ static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj, V_VT(&arg) = VT_DISPATCH; V_DISPATCH(&arg) = (IDispatch*)event_obj; - for(i=0; i < handler_vector->handler_cnt; i++) { + i = handler_vector->handler_cnt; + while(i--) { if(handler_vector->handlers[i]) { TRACE("%s [%d] >>>\n", debugstr_w(event_info[eid].name), i); hres = call_disp_func(handler_vector->handlers[i], &dp); @@ -866,6 +867,9 @@ static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj, for(cp = cp_container->cp_list; cp; cp = cp->next) { if(cp->sinks_size && is_cp_event(cp->data, event_info[eid].dispid)) { for(i=0; i < cp->sinks_size; i++) { + if(!cp->sinks[i].disp) + continue; + TRACE("cp %s [%d] >>>\n", debugstr_w(event_info[eid].name), i); hres = call_cp_func(cp->sinks[i].disp, event_info[eid].dispid); if(hres == S_OK) @@ -1124,6 +1128,34 @@ HRESULT attach_event(event_target_t **event_target_ptr, HTMLDocument *doc, BSTR event_target->event_table[eid]->handlers[i] = disp; *res = VARIANT_TRUE; + return ensure_nsevent_handler(doc->doc_node, eid); +} + +HRESULT detach_event(event_target_t *event_target, HTMLDocument *doc, BSTR name, IDispatch *disp) +{ + eventid_t eid; + DWORD i = 0; + + if(!event_target) + return S_OK; + + eid = attr_to_eid(name); + if(eid == EVENTID_LAST) { + WARN("Unknown event\n"); + return S_OK; + } + + if(!event_target->event_table[eid]) + return S_OK; + + while(i < event_target->event_table[eid]->handler_cnt) { + if(event_target->event_table[eid]->handlers[i] == disp) { + IDispatch_Release(event_target->event_table[eid]->handlers[i]); + event_target->event_table[eid]->handlers[i] = NULL; + } + i++; + } + return S_OK; } diff --git a/dll/win32/mshtml/htmlevent.h b/dll/win32/mshtml/htmlevent.h index 1a8572f951e..96ff4cdab5b 100644 --- a/dll/win32/mshtml/htmlevent.h +++ b/dll/win32/mshtml/htmlevent.h @@ -46,6 +46,7 @@ void fire_event(HTMLDocumentNode*,eventid_t,nsIDOMNode*,nsIDOMEvent*); HRESULT set_event_handler(event_target_t**,HTMLDocumentNode*,eventid_t,VARIANT*); HRESULT get_event_handler(event_target_t**,eventid_t,VARIANT*); HRESULT attach_event(event_target_t**,HTMLDocument*,BSTR,IDispatch*,VARIANT_BOOL*); +HRESULT detach_event(event_target_t*,HTMLDocument*,BSTR,IDispatch*); HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*); HRESULT call_event(HTMLDOMNode*,eventid_t); void update_cp_events(HTMLWindow*,cp_static_data_t*); diff --git a/dll/win32/mshtml/htmlform.c b/dll/win32/mshtml/htmlform.c index 1db965a8d77..68860560148 100644 --- a/dll/win32/mshtml/htmlform.c +++ b/dll/win32/mshtml/htmlform.c @@ -343,10 +343,12 @@ static HRESULT HTMLFormElement_get_dispid(HTMLDOMNode *iface, { HTMLFormElement *This = HTMLFORM_NODE_THIS(iface); nsIDOMHTMLCollection *elements; + nsAString nsname, nsstr; PRUint32 len, i; - static const PRUnichar nameW[] = {'n','a','m','e',0}; - nsAString nsname; nsresult nsres; + HRESULT hres = DISP_E_UNKNOWNNAME; + + static const PRUnichar nameW[] = {'n','a','m','e',0}; TRACE("(%p)->(%s %x %p)\n", This, wine_dbgstr_w(name), grfdex, pid); @@ -363,72 +365,62 @@ static HRESULT HTMLFormElement_get_dispid(HTMLDOMNode *iface, return E_FAIL; } - nsAString_Init(&nsname, nameW); + nsAString_InitDepend(&nsname, nameW); + nsAString_Init(&nsstr, NULL); for(i = 0; i < len; ++i) { nsIDOMNode *nsitem; nsIDOMHTMLElement *nshtml_elem; - nsAString nsstr; const PRUnichar *str; nsres = nsIDOMHTMLCollection_Item(elements, i, &nsitem); if(NS_FAILED(nsres)) { FIXME("Item failed: 0x%08x\n", nsres); - nsAString_Finish(&nsname); - nsIDOMHTMLCollection_Release(elements); - return E_FAIL; + hres = E_FAIL; + break; } nsres = nsIDOMNode_QueryInterface(nsitem, &IID_nsIDOMHTMLElement, (void**)&nshtml_elem); nsIDOMNode_Release(nsitem); if(NS_FAILED(nsres)) { FIXME("Failed to get nsIDOMHTMLNode interface: 0x%08x\n", nsres); - nsAString_Finish(&nsname); - nsIDOMHTMLCollection_Release(elements); - return E_FAIL; + hres = E_FAIL; + break; } /* compare by id attr */ - nsAString_Init(&nsstr, NULL); nsres = nsIDOMHTMLElement_GetId(nshtml_elem, &nsstr); if(NS_FAILED(nsres)) { FIXME("GetId failed: 0x%08x\n", nsres); - nsAString_Finish(&nsname); nsIDOMHTMLElement_Release(nshtml_elem); - nsIDOMHTMLCollection_Release(elements); - return E_FAIL; + hres = E_FAIL; + break; } nsAString_GetData(&nsstr, &str); if(!strcmpiW(str, name)) { + nsIDOMHTMLElement_Release(nshtml_elem); /* FIXME: using index for dispid */ *pid = MSHTML_DISPID_CUSTOM_MIN + i; - nsAString_Finish(&nsname); - nsAString_Finish(&nsstr); - nsIDOMHTMLElement_Release(nshtml_elem); - nsIDOMHTMLCollection_Release(elements); - return S_OK; + hres = S_OK; + break; } /* compare by name attr */ nsres = nsIDOMHTMLElement_GetAttribute(nshtml_elem, &nsname, &nsstr); + nsIDOMHTMLElement_Release(nshtml_elem); nsAString_GetData(&nsstr, &str); if(!strcmpiW(str, name)) { /* FIXME: using index for dispid */ *pid = MSHTML_DISPID_CUSTOM_MIN + i; - nsAString_Finish(&nsname); - nsAString_Finish(&nsstr); - nsIDOMHTMLElement_Release(nshtml_elem); - nsIDOMHTMLCollection_Release(elements); - return S_OK; + hres = S_OK; + break; } - nsAString_Finish(&nsstr); - - nsIDOMHTMLElement_Release(nshtml_elem); } nsAString_Finish(&nsname); + nsAString_Finish(&nsstr); nsIDOMHTMLCollection_Release(elements); - return DISP_E_UNKNOWNNAME; + return hres; } static HRESULT HTMLFormElement_invoke(HTMLDOMNode *iface, @@ -483,11 +475,7 @@ static const NodeImplVtbl HTMLFormElementImplVtbl = { }; static const tid_t HTMLFormElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLFormElement_tid, 0 }; diff --git a/dll/win32/mshtml/htmlframe.c b/dll/win32/mshtml/htmlframe.c new file mode 100644 index 00000000000..8d458f7a774 --- /dev/null +++ b/dll/win32/mshtml/htmlframe.c @@ -0,0 +1,299 @@ +/* + * Copyright 2010 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" + +#include "mshtml_private.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +typedef struct { + HTMLFrameBase framebase; + const IHTMLFrameElement3Vtbl *lpIHTMLFrameElement3Vtbl; +} HTMLFrameElement; + +#define HTMLFRAMEELEM3(x) ((IHTMLFrameElement3*) &(x)->lpIHTMLFrameElement3Vtbl) + +#define HTMLFRAME3_THIS(iface) DEFINE_THIS(HTMLFrameElement, IHTMLFrameElement3, iface) + +static HRESULT WINAPI HTMLFrameElement3_QueryInterface(IHTMLFrameElement3 *iface, + REFIID riid, void **ppv) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + + return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->framebase.element.node), riid, ppv); +} + +static ULONG WINAPI HTMLFrameElement3_AddRef(IHTMLFrameElement3 *iface) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + + return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->framebase.element.node)); +} + +static ULONG WINAPI HTMLFrameElement3_Release(IHTMLFrameElement3 *iface) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + + return IHTMLDOMNode_Release(HTMLDOMNODE(&This->framebase.element.node)); +} + +static HRESULT WINAPI HTMLFrameElement3_GetTypeInfoCount(IHTMLFrameElement3 *iface, UINT *pctinfo) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->framebase.element.node.dispex), pctinfo); +} + +static HRESULT WINAPI HTMLFrameElement3_GetTypeInfo(IHTMLFrameElement3 *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->framebase.element.node.dispex), iTInfo, lcid, ppTInfo); +} + +static HRESULT WINAPI HTMLFrameElement3_GetIDsOfNames(IHTMLFrameElement3 *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->framebase.element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId); +} + +static HRESULT WINAPI HTMLFrameElement3_Invoke(IHTMLFrameElement3 *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + return IDispatchEx_Invoke(DISPATCHEX(&This->framebase.element.node.dispex), dispIdMember, riid, + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLFrameElement3_get_contentDocument(IHTMLFrameElement3 *iface, IDispatch **p) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + IHTMLDocument2 *doc; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); + + if(!This->framebase.content_window) { + FIXME("NULL window\n"); + return E_FAIL; + } + + hres = IHTMLWindow2_get_document(HTMLWINDOW2(This->framebase.content_window), &doc); + if(FAILED(hres)) + return hres; + + *p = doc ? (IDispatch*)doc : NULL; + return S_OK; +} + +static HRESULT WINAPI HTMLFrameElement3_put_src(IHTMLFrameElement3 *iface, BSTR v) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_get_src(IHTMLFrameElement3 *iface, BSTR *p) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_put_longDesc(IHTMLFrameElement3 *iface, BSTR v) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_get_longDesc(IHTMLFrameElement3 *iface, BSTR *p) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_put_frameBorder(IHTMLFrameElement3 *iface, BSTR v) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFrameElement3_get_frameBorder(IHTMLFrameElement3 *iface, BSTR *p) +{ + HTMLFrameElement *This = HTMLFRAME3_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +#undef HTMLFRAME3_THIS + +static const IHTMLFrameElement3Vtbl HTMLFrameElement3Vtbl = { + HTMLFrameElement3_QueryInterface, + HTMLFrameElement3_AddRef, + HTMLFrameElement3_Release, + HTMLFrameElement3_GetTypeInfoCount, + HTMLFrameElement3_GetTypeInfo, + HTMLFrameElement3_GetIDsOfNames, + HTMLFrameElement3_Invoke, + HTMLFrameElement3_get_contentDocument, + HTMLFrameElement3_put_src, + HTMLFrameElement3_get_src, + HTMLFrameElement3_put_longDesc, + HTMLFrameElement3_get_longDesc, + HTMLFrameElement3_put_frameBorder, + HTMLFrameElement3_get_frameBorder +}; + +#define HTMLFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLFrameElement, framebase.element.node, iface) + +static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + if(IsEqualGUID(&IID_IHTMLFrameElement3, riid)) { + TRACE("(%p)->(IID_IHTMLFrameElement3 %p)\n", This, ppv); + *ppv = HTMLFRAMEELEM3(This); + }else { + return HTMLFrameBase_QI(&This->framebase, riid, ppv); + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static void HTMLFrameElement_destructor(HTMLDOMNode *iface) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + HTMLFrameBase_destructor(&This->framebase); +} + +static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + if(!This->framebase.content_window || !This->framebase.content_window->doc) { + *p = NULL; + return S_OK; + } + + *p = (IDispatch*)HTMLDOC(&This->framebase.content_window->doc->basedoc); + IDispatch_AddRef(*p); + return S_OK; +} + +static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name, + DWORD grfdex, DISPID *pid) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + if(!This->framebase.content_window) + return DISP_E_UNKNOWNNAME; + + return search_window_props(This->framebase.content_window, name, grfdex, pid); +} + +static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid, + WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + + if(!This->framebase.content_window) { + ERR("no content window to invoke on\n"); + return E_FAIL; + } + + return IDispatchEx_InvokeEx(DISPATCHEX(This->framebase.content_window), id, lcid, flags, params, res, ei, caller); +} + +static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface) +{ + HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); + nsIDOMDocument *nsdoc; + nsresult nsres; + HRESULT hres; + + nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc); + if(NS_FAILED(nsres) || !nsdoc) { + ERR("GetContentDocument failed: %08x\n", nsres); + return E_FAIL; + } + + hres = set_frame_doc(&This->framebase, nsdoc); + nsIDOMDocument_Release(nsdoc); + return hres; +} + +#undef HTMLFRAME_NODE_THIS + +static const NodeImplVtbl HTMLFrameElementImplVtbl = { + HTMLFrameElement_QI, + HTMLFrameElement_destructor, + NULL, + NULL, + NULL, + NULL, + HTMLFrameElement_get_document, + NULL, + HTMLFrameElement_get_dispid, + HTMLFrameElement_invoke, + HTMLFrameElement_bind_to_tree +}; + +static const tid_t HTMLFrameElement_iface_tids[] = { + HTMLELEMENT_TIDS, + IHTMLFrameBase_tid, + IHTMLFrameBase2_tid, + IHTMLFrameElement3_tid, + 0 +}; + +static dispex_static_data_t HTMLFrameElement_dispex = { + NULL, + DispHTMLFrameElement_tid, + NULL, + HTMLFrameElement_iface_tids +}; + +HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) +{ + HTMLFrameElement *ret; + + ret = heap_alloc_zero(sizeof(HTMLFrameElement)); + + ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl; + ret->lpIHTMLFrameElement3Vtbl = &HTMLFrameElement3Vtbl; + + HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLFrameElement_dispex); + + return &ret->framebase.element; +} diff --git a/dll/win32/mshtml/htmlframebase.c b/dll/win32/mshtml/htmlframebase.c index e94c8010f9e..56c1023be8c 100644 --- a/dll/win32/mshtml/htmlframebase.c +++ b/dll/win32/mshtml/htmlframebase.c @@ -283,10 +283,10 @@ static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v) return E_INVALIDARG; if(This->nsframe) { - nsAString_Init(&nsstr, v); + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr); }else if(This->nsiframe) { - nsAString_Init(&nsstr, v); + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr); }else { ERR("No attached ns frame object\n"); @@ -562,108 +562,3 @@ void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLEl }else This->nsiframe = NULL; } - -typedef struct { - HTMLFrameBase framebase; -} HTMLFrameElement; - -#define HTMLFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLFrameElement, framebase.element.node, iface) - -static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - return HTMLFrameBase_QI(&This->framebase, riid, ppv); -} - -static void HTMLFrameElement_destructor(HTMLDOMNode *iface) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - HTMLFrameBase_destructor(&This->framebase); -} - -static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - if(!This->framebase.content_window || !This->framebase.content_window->doc) { - *p = NULL; - return S_OK; - } - - *p = (IDispatch*)HTMLDOC(&This->framebase.content_window->doc->basedoc); - IDispatch_AddRef(*p); - return S_OK; -} - -static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name, - DWORD grfdex, DISPID *pid) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - if(!This->framebase.content_window) - return DISP_E_UNKNOWNNAME; - - return search_window_props(This->framebase.content_window, name, grfdex, pid); -} - -static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid, - WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - - if(!This->framebase.content_window) { - ERR("no content window to invoke on\n"); - return E_FAIL; - } - - return IDispatchEx_InvokeEx(DISPATCHEX(This->framebase.content_window), id, lcid, flags, params, res, ei, caller); -} - -static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface) -{ - HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface); - nsIDOMDocument *nsdoc; - nsresult nsres; - HRESULT hres; - - nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc); - if(NS_FAILED(nsres) || !nsdoc) { - ERR("GetContentDocument failed: %08x\n", nsres); - return E_FAIL; - } - - hres = set_frame_doc(&This->framebase, nsdoc); - nsIDOMDocument_Release(nsdoc); - return hres; -} - -#undef HTMLFRAME_NODE_THIS - -static const NodeImplVtbl HTMLFrameElementImplVtbl = { - HTMLFrameElement_QI, - HTMLFrameElement_destructor, - NULL, - NULL, - NULL, - NULL, - HTMLFrameElement_get_document, - NULL, - HTMLFrameElement_get_dispid, - HTMLFrameElement_invoke, - HTMLFrameElement_bind_to_tree -}; - -HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) -{ - HTMLFrameElement *ret; - - ret = heap_alloc_zero(sizeof(HTMLFrameElement)); - - ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl; - - HTMLFrameBase_Init(&ret->framebase, doc, nselem, NULL); - - return &ret->framebase.element; -} diff --git a/dll/win32/mshtml/htmlgeneric.c b/dll/win32/mshtml/htmlgeneric.c index 8b753164f00..82075b8d325 100644 --- a/dll/win32/mshtml/htmlgeneric.c +++ b/dll/win32/mshtml/htmlgeneric.c @@ -153,11 +153,7 @@ static const NodeImplVtbl HTMLGenericElementImplVtbl = { }; static const tid_t HTMLGenericElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLGenericElement_tid, 0 }; diff --git a/dll/win32/mshtml/htmliframe.c b/dll/win32/mshtml/htmliframe.c index ddb32c80ab2..12cd4275174 100644 --- a/dll/win32/mshtml/htmliframe.c +++ b/dll/win32/mshtml/htmliframe.c @@ -33,15 +33,139 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); typedef struct { HTMLFrameBase framebase; + const IHTMLIFrameElementVtbl *lpIHTMLIFrameElementVtbl; } HTMLIFrame; +#define HTMLIFRAMEELEM(x) ((IHTMLIFrameElement*) &(x)->lpIHTMLIFrameElementVtbl) + +#define HTMLIFRAME_THIS(iface) DEFINE_THIS(HTMLIFrame, IHTMLIFrameElement, iface) + +static HRESULT WINAPI HTMLIFrameElement_QueryInterface(IHTMLIFrameElement *iface, + REFIID riid, void **ppv) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + + return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->framebase.element.node), riid, ppv); +} + +static ULONG WINAPI HTMLIFrameElement_AddRef(IHTMLIFrameElement *iface) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + + return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->framebase.element.node)); +} + +static ULONG WINAPI HTMLIFrameElement_Release(IHTMLIFrameElement *iface) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + + return IHTMLDOMNode_Release(HTMLDOMNODE(&This->framebase.element.node)); +} + +static HRESULT WINAPI HTMLIFrameElement_GetTypeInfoCount(IHTMLIFrameElement *iface, UINT *pctinfo) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->framebase.element.node.dispex), pctinfo); +} + +static HRESULT WINAPI HTMLIFrameElement_GetTypeInfo(IHTMLIFrameElement *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->framebase.element.node.dispex), iTInfo, lcid, ppTInfo); +} + +static HRESULT WINAPI HTMLIFrameElement_GetIDsOfNames(IHTMLIFrameElement *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->framebase.element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId); +} + +static HRESULT WINAPI HTMLIFrameElement_Invoke(IHTMLIFrameElement *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + return IDispatchEx_Invoke(DISPATCHEX(&This->framebase.element.node.dispex), dispIdMember, riid, + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLIFrameElement_put_vspace(IHTMLIFrameElement *iface, LONG v) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%d)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_get_vspace(IHTMLIFrameElement *iface, LONG *p) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_put_hspace(IHTMLIFrameElement *iface, LONG v) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%d)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_get_hspace(IHTMLIFrameElement *iface, LONG *p) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_put_align(IHTMLIFrameElement *iface, BSTR v) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLIFrameElement_get_align(IHTMLIFrameElement *iface, BSTR *p) +{ + HTMLIFrame *This = HTMLIFRAME_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +#undef HTMLIFRAME_THIS + +static const IHTMLIFrameElementVtbl HTMLIFrameElementVtbl = { + HTMLIFrameElement_QueryInterface, + HTMLIFrameElement_AddRef, + HTMLIFrameElement_Release, + HTMLIFrameElement_GetTypeInfoCount, + HTMLIFrameElement_GetTypeInfo, + HTMLIFrameElement_GetIDsOfNames, + HTMLIFrameElement_Invoke, + HTMLIFrameElement_put_vspace, + HTMLIFrameElement_get_vspace, + HTMLIFrameElement_put_hspace, + HTMLIFrameElement_get_hspace, + HTMLIFrameElement_put_align, + HTMLIFrameElement_get_align +}; + #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface) static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) { HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface); - return HTMLFrameBase_QI(&This->framebase, riid, ppv); + if(IsEqualGUID(&IID_IHTMLIFrameElement, riid)) { + TRACE("(%p)->(IID_IHTMLIFrameElement %p)\n", This, ppv); + *ppv = HTMLIFRAMEELEM(This); + }else { + return HTMLFrameBase_QI(&This->framebase, riid, ppv); + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; } static void HTMLIFrame_destructor(HTMLDOMNode *iface) @@ -131,13 +255,10 @@ static const NodeImplVtbl HTMLIFrameImplVtbl = { }; static const tid_t HTMLIFrame_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLFrameBase_tid, IHTMLFrameBase2_tid, + IHTMLIFrameElement_tid, 0 }; @@ -154,6 +275,7 @@ HTMLElement *HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) ret = heap_alloc_zero(sizeof(HTMLIFrame)); + ret->lpIHTMLIFrameElementVtbl = &HTMLIFrameElementVtbl; ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl; HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex); diff --git a/dll/win32/mshtml/htmlimg.c b/dll/win32/mshtml/htmlimg.c index 87fe498b9da..17b6cceac95 100644 --- a/dll/win32/mshtml/htmlimg.c +++ b/dll/win32/mshtml/htmlimg.c @@ -228,7 +228,7 @@ static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&alt_str, v); + nsAString_InitDepend(&alt_str, v); nsres = nsIDOMHTMLImageElement_SetAlt(This->nsimg, &alt_str); nsAString_Finish(&alt_str); if(NS_FAILED(nsres)) @@ -268,7 +268,7 @@ static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&src_str, v); + nsAString_InitDepend(&src_str, v); nsres = nsIDOMHTMLImageElement_SetSrc(This->nsimg, &src_str); nsAString_Finish(&src_str); if(NS_FAILED(nsres)) @@ -460,29 +460,69 @@ static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p) static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v) { HTMLImgElement *This = HTMLIMG_THIS(iface); - FIXME("(%p)->(%d)\n", This, v); - return E_NOTIMPL; + nsresult nsres; + + TRACE("(%p)->(%d)\n", This, v); + + nsres = nsIDOMHTMLImageElement_SetWidth(This->nsimg, v); + if(NS_FAILED(nsres)) { + ERR("SetWidth failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, LONG *p) { HTMLImgElement *This = HTMLIMG_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + PRInt32 width; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsres = nsIDOMHTMLImageElement_GetWidth(This->nsimg, &width); + if(NS_FAILED(nsres)) { + ERR("GetWidth failed: %08x\n", nsres); + return E_FAIL; + } + + *p = width; + return S_OK; } static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, LONG v) { HTMLImgElement *This = HTMLIMG_THIS(iface); - FIXME("(%p)->(%d)\n", This, v); - return E_NOTIMPL; + nsresult nsres; + + TRACE("(%p)->(%d)\n", This, v); + + nsres = nsIDOMHTMLImageElement_SetHeight(This->nsimg, v); + if(NS_FAILED(nsres)) { + ERR("SetHeight failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, LONG *p) { HTMLImgElement *This = HTMLIMG_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + PRInt32 height; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsres = nsIDOMHTMLImageElement_GetHeight(This->nsimg, &height); + if(NS_FAILED(nsres)) { + ERR("GetHeight failed: %08x\n", nsres); + return E_FAIL; + } + + *p = height; + return S_OK; } static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v) @@ -609,11 +649,7 @@ static const NodeImplVtbl HTMLImgElementImplVtbl = { }; static const tid_t HTMLImgElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLImgElement_tid, 0 }; @@ -728,12 +764,38 @@ static HRESULT WINAPI HTMLImageElementFactory_Invoke(IHTMLImageElementFactory *i return E_NOTIMPL; } +static LONG var_to_size(const VARIANT *v) +{ + switch(V_VT(v)) { + case VT_EMPTY: + return 0; + case VT_I4: + return V_I4(v); + case VT_BSTR: { + LONG ret; + HRESULT hres; + + hres = VarI4FromStr(V_BSTR(v), 0, 0, &ret); + if(FAILED(hres)) { + FIXME("VarI4FromStr failed: %08x\n", hres); + return 0; + } + return ret; + } + default: + FIXME("unsupported size %s\n", debugstr_variant(v)); + } + return 0; +} + static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface, VARIANT width, VARIANT height, IHTMLImgElement **img_elem) { HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface); + IHTMLImgElement *img; HTMLElement *elem; nsIDOMHTMLElement *nselem; + LONG l; HRESULT hres; static const PRUnichar imgW[] = {'I','M','G',0}; @@ -758,7 +820,7 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i return E_FAIL; } - hres = IHTMLElement_QueryInterface(HTMLELEM(elem), &IID_IHTMLImgElement, (void**)img_elem); + hres = IHTMLElement_QueryInterface(HTMLELEM(elem), &IID_IHTMLImgElement, (void**)&img); if(FAILED(hres)) { ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres); return hres; @@ -766,9 +828,14 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i nsIDOMHTMLElement_Release(nselem); - if(V_VT(&width) != VT_EMPTY || V_VT(&height) != VT_EMPTY) - FIXME("Not setting image dimensions\n"); + l = var_to_size(&width); + if(l) + IHTMLImgElement_put_width(img, l); + l = var_to_size(&height); + if(l) + IHTMLImgElement_put_height(img, l); + *img_elem = img; return S_OK; } diff --git a/dll/win32/mshtml/htmlinput.c b/dll/win32/mshtml/htmlinput.c index ae7994a291b..1b8d1c5413f 100644 --- a/dll/win32/mshtml/htmlinput.c +++ b/dll/win32/mshtml/htmlinput.c @@ -143,7 +143,7 @@ static HRESULT WINAPI HTMLInputElement_put_value(IHTMLInputElement *iface, BSTR TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&val_str, v); + nsAString_InitDepend(&val_str, v); nsres = nsIDOMHTMLInputElement_SetValue(This->nsinput, &val_str); nsAString_Finish(&val_str); if(NS_FAILED(nsres)) @@ -512,7 +512,7 @@ static HRESULT WINAPI HTMLInputElement_put_src(IHTMLInputElement *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&nsstr, v); + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLInputElement_SetSrc(This->nsinput, &nsstr); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) @@ -1173,11 +1173,7 @@ static const NodeImplVtbl HTMLInputElementImplVtbl = { }; static const tid_t HTMLInputElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLInputElement_tid, 0 }; diff --git a/dll/win32/mshtml/htmlnode.c b/dll/win32/mshtml/htmlnode.c index b8cecf0629e..a5ea3f4dd00 100644 --- a/dll/win32/mshtml/htmlnode.c +++ b/dll/win32/mshtml/htmlnode.c @@ -645,7 +645,7 @@ static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v) TRACE("bstr %s\n", debugstr_w(V_BSTR(&v))); - nsAString_Init(&val_str, V_BSTR(&v)); + nsAString_InitDepend(&val_str, V_BSTR(&v)); nsIDOMNode_SetNodeValue(This->nsnode, &val_str); nsAString_Finish(&val_str); diff --git a/dll/win32/mshtml/htmloption.c b/dll/win32/mshtml/htmloption.c index 4701c577de5..3e037627bf1 100644 --- a/dll/win32/mshtml/htmloption.c +++ b/dll/win32/mshtml/htmloption.c @@ -117,7 +117,7 @@ static HRESULT WINAPI HTMLOptionElement_put_value(IHTMLOptionElement *iface, BST TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&value_str, v); + nsAString_InitDepend(&value_str, v); nsres = nsIDOMHTMLOptionElement_SetValue(This->nsoption, &value_str); nsAString_Finish(&value_str); if(NS_FAILED(nsres)) @@ -209,7 +209,7 @@ static HRESULT WINAPI HTMLOptionElement_put_text(IHTMLOptionElement *iface, BSTR } } - nsAString_Init(&text_str, v); + nsAString_InitDepend(&text_str, v); nsres = nsIDOMHTMLDocument_CreateTextNode(This->element.node.doc->nsdoc, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { @@ -324,11 +324,7 @@ static const NodeImplVtbl HTMLOptionElementImplVtbl = { }; static const tid_t HTMLOptionElement_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLOptionElement_tid, 0 }; diff --git a/dll/win32/mshtml/htmlscript.c b/dll/win32/mshtml/htmlscript.c index d86f3988932..f39e3061c5d 100644 --- a/dll/win32/mshtml/htmlscript.c +++ b/dll/win32/mshtml/htmlscript.c @@ -214,8 +214,18 @@ static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, V static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v) { HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + nsAString nstype_str; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + nsAString_Init(&nstype_str, v); + nsres = nsIDOMHTMLScriptElement_SetType(This->nsscript, &nstype_str); + if (NS_FAILED(nsres)) + ERR("SetType failed: %08x\n", nsres); + nsAString_Finish (&nstype_str); + + return S_OK; } static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p) @@ -319,6 +329,19 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = { HTMLScriptElement_get_readystate }; +static const tid_t HTMLScriptElement_iface_tids[] = { + HTMLELEMENT_TIDS, + IHTMLScriptElement_tid, + 0 +}; + +static dispex_static_data_t HTMLScriptElement_dispex = { + NULL, + DispHTMLScriptElement_tid, + NULL, + HTMLScriptElement_iface_tids +}; + HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) { HTMLScriptElement *ret = heap_alloc_zero(sizeof(HTMLScriptElement)); @@ -327,7 +350,7 @@ HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement * ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl; ret->element.node.vtbl = &HTMLScriptElementImplVtbl; - HTMLElement_Init(&ret->element, doc, nselem, NULL); + HTMLElement_Init(&ret->element, doc, nselem, &HTMLScriptElement_dispex); nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript); if(NS_FAILED(nsres)) diff --git a/dll/win32/mshtml/htmlselect.c b/dll/win32/mshtml/htmlselect.c index f9b71826600..6698606a4c4 100644 --- a/dll/win32/mshtml/htmlselect.c +++ b/dll/win32/mshtml/htmlselect.c @@ -253,7 +253,7 @@ static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BST TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&value_str, v); + nsAString_InitDepend(&value_str, v); nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str); nsAString_Finish(&value_str); if(NS_FAILED(nsres)) @@ -332,8 +332,26 @@ static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElem VARIANT before) { HTMLSelectElement *This = HTMLSELECT_THIS(iface); - FIXME("(%p)->(%p v)\n", This, element); - return E_NOTIMPL; + IHTMLDOMNode *node, *tmp; + HRESULT hres; + + FIXME("(%p)->(%p %s): semi-stub\n", This, element, debugstr_variant(&before)); + + if(V_VT(&before) != VT_EMPTY) { + FIXME("unhandled before %s\n", debugstr_variant(&before)); + return E_NOTIMPL; + } + + hres = IHTMLElement_QueryInterface(element, &IID_IHTMLDOMNode, (void**)&node); + if(FAILED(hres)) + return hres; + + hres = IHTMLDOMNode_appendChild(HTMLDOMNODE(&This->element.node), node, &tmp); + IHTMLDOMNode_Release(node); + if(SUCCEEDED(hres) && tmp) + IHTMLDOMNode_Release(tmp); + + return hres; } static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, LONG index) @@ -487,11 +505,7 @@ static const NodeImplVtbl HTMLSelectElementImplVtbl = { }; static const tid_t HTMLSelectElement_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLSelectElement_tid, 0 }; diff --git a/dll/win32/mshtml/htmlstyle.c b/dll/win32/mshtml/htmlstyle.c index 467464ac919..cb86b79b437 100644 --- a/dll/win32/mshtml/htmlstyle.c +++ b/dll/win32/mshtml/htmlstyle.c @@ -315,9 +315,9 @@ HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCW if(flags & ATTR_FIX_URL) val = fix_url_value(value); - nsAString_Init(&str_name, style_tbl[sid].name); - nsAString_Init(&str_value, val ? val : value); - nsAString_Init(&str_empty, wszEmpty); + nsAString_InitDepend(&str_name, style_tbl[sid].name); + nsAString_InitDepend(&str_value, val ? val : value); + nsAString_InitDepend(&str_empty, wszEmpty); heap_free(val); nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty); @@ -345,10 +345,12 @@ HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, case VT_I4: { WCHAR str[14]; - static const WCHAR format[] = {'%','d',0}; - wsprintfW(str, format, V_I4(value)); - return set_nsstyle_attr(nsstyle, sid, str, flags); + static const WCHAR format[] = {'%','d',0}; + static const WCHAR px_format[] = {'%','d','p','x',0}; + + wsprintfW(str, flags&ATTR_FIX_PX ? px_format : format, V_I4(value)); + return set_nsstyle_attr(nsstyle, sid, str, flags & ~ATTR_FIX_PX); } default: FIXME("not implemented vt %d\n", V_VT(value)); @@ -369,7 +371,7 @@ static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, stylei nsAString str_name; nsresult nsres; - nsAString_Init(&str_name, style_tbl[sid].name); + nsAString_InitDepend(&str_name, style_tbl[sid].name); nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value); if(NS_FAILED(nsres)) { @@ -1531,8 +1533,10 @@ static HRESULT WINAPI HTMLStyle_put_borderTopColor(IHTMLStyle *iface, VARIANT v) static HRESULT WINAPI HTMLStyle_get_borderTopColor(IHTMLStyle *iface, VARIANT *p) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_TOP_COLOR, p, 0); } static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT v) @@ -1545,8 +1549,10 @@ static HRESULT WINAPI HTMLStyle_put_borderRightColor(IHTMLStyle *iface, VARIANT static HRESULT WINAPI HTMLStyle_get_borderRightColor(IHTMLStyle *iface, VARIANT *p) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_RIGHT_COLOR, p, 0); } static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT v) @@ -1559,8 +1565,10 @@ static HRESULT WINAPI HTMLStyle_put_borderBottomColor(IHTMLStyle *iface, VARIANT static HRESULT WINAPI HTMLStyle_get_borderBottomColor(IHTMLStyle *iface, VARIANT *p) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_BOTTOM_COLOR, p, 0); } static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v) @@ -1573,8 +1581,10 @@ static HRESULT WINAPI HTMLStyle_put_borderLeftColor(IHTMLStyle *iface, VARIANT v static HRESULT WINAPI HTMLStyle_get_borderLeftColor(IHTMLStyle *iface, VARIANT *p) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + return get_nsstyle_attr_var(This->nsstyle, STYLEID_BORDER_LEFT_COLOR, p, 0); } static HRESULT WINAPI HTMLStyle_put_borderWidth(IHTMLStyle *iface, BSTR v) @@ -1779,15 +1789,7 @@ static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v) TRACE("(%p)->(v%d)\n", This, V_VT(&v)); - switch(V_VT(&v)) { - case VT_BSTR: - TRACE("%s\n", debugstr_w(V_BSTR(&v))); - return set_style_attr(This, STYLEID_WIDTH, V_BSTR(&v), 0); - default: - FIXME("unsupported vt %d\n", V_VT(&v)); - } - - return E_NOTIMPL; + return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX); } static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p) @@ -2129,7 +2131,7 @@ static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&text_str, v); + nsAString_InitDepend(&text_str, v); nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { diff --git a/dll/win32/mshtml/htmltable.c b/dll/win32/mshtml/htmltable.c index 6357f77e4ba..12869523dbc 100644 --- a/dll/win32/mshtml/htmltable.c +++ b/dll/win32/mshtml/htmltable.c @@ -558,11 +558,7 @@ static const NodeImplVtbl HTMLTableImplVtbl = { }; static const tid_t HTMLTable_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLTable_tid, 0 }; diff --git a/dll/win32/mshtml/htmltablerow.c b/dll/win32/mshtml/htmltablerow.c index 862ed75318c..950535af253 100644 --- a/dll/win32/mshtml/htmltablerow.c +++ b/dll/win32/mshtml/htmltablerow.c @@ -301,11 +301,7 @@ static const NodeImplVtbl HTMLTableRowImplVtbl = { }; static const tid_t HTMLTableRow_iface_tids[] = { - IHTMLDOMNode_tid, - IHTMLDOMNode2_tid, - IHTMLElement_tid, - IHTMLElement2_tid, - IHTMLElement3_tid, + HTMLELEMENT_TIDS, IHTMLTableRow_tid, 0 }; diff --git a/dll/win32/mshtml/htmltextarea.c b/dll/win32/mshtml/htmltextarea.c index 0a07379871b..9ded8ac6e12 100644 --- a/dll/win32/mshtml/htmltextarea.c +++ b/dll/win32/mshtml/htmltextarea.c @@ -411,6 +411,19 @@ static const NodeImplVtbl HTMLTextAreaElementImplVtbl = { HTMLTextAreaElementImpl_get_disabled }; +static const tid_t HTMLTextAreaElement_iface_tids[] = { + HTMLELEMENT_TIDS, + IHTMLTextAreaElement_tid, + 0 +}; + +static dispex_static_data_t HTMLTextAreaElement_dispex = { + NULL, + DispHTMLTextAreaElement_tid, + NULL, + HTMLTextAreaElement_iface_tids +}; + HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) { HTMLTextAreaElement *ret = heap_alloc_zero(sizeof(HTMLTextAreaElement)); @@ -419,7 +432,7 @@ HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement ret->lpHTMLTextAreaElementVtbl = &HTMLTextAreaElementVtbl; ret->element.node.vtbl = &HTMLTextAreaElementImplVtbl; - HTMLElement_Init(&ret->element, doc, nselem, NULL); + HTMLElement_Init(&ret->element, doc, nselem, &HTMLTextAreaElement_dispex); nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTextAreaElement, (void**)&ret->nstextarea); diff --git a/dll/win32/mshtml/htmlwindow.c b/dll/win32/mshtml/htmlwindow.c index 4a2babee06d..491625ed241 100644 --- a/dll/win32/mshtml/htmlwindow.c +++ b/dll/win32/mshtml/htmlwindow.c @@ -1,5 +1,5 @@ /* - * Copyright 2006 Jacek Caban for CodeWeavers + * Copyright 2006-2010 Jacek Caban for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,9 +25,9 @@ #include "winuser.h" #include "ole2.h" #include "mshtmdid.h" +#include "shlguid.h" #include "wine/debug.h" -#include "wine/unicode.h" #include "mshtml_private.h" #include "htmlevent.h" @@ -35,6 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); +#define HTMLPRIVWINDOW(x) ((IHTMLPrivateWindow*) &(x)->lpIHTMLPrivateWindowVtbl) + static struct list window_list = LIST_INIT(window_list); static void window_set_docnode(HTMLWindow *window, HTMLDocumentNode *doc_node) @@ -166,6 +168,9 @@ static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID rii }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) { TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv); *ppv = HTMLWINDOW4(This); + }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) { + TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv); + *ppv = HTMLPRIVWINDOW(This); }else if(dispex_query_interface(&This->dispex, riid, ppv)) { return *ppv ? S_OK : E_NOINTERFACE; } @@ -694,7 +699,7 @@ static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&name_str, v); + nsAString_InitDepend(&name_str, v); nsres = nsIDOMWindow_SetName(This->nswindow, &name_str); nsAString_Finish(&name_str); if(NS_FAILED(nsres)) @@ -1641,6 +1646,162 @@ static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = { HTMLWindow4_get_frameElement }; +#define HTMLPRIVWINDOW_THIS(iface) DEFINE_THIS(HTMLWindow, IHTMLPrivateWindow, iface) + +static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + + return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv); +} + +static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + + return IHTMLWindow2_AddRef(HTMLWINDOW2(This)); +} + +static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + + return IHTMLWindow2_Release(HTMLWINDOW2(This)); +} + +static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3, + BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + DWORD post_data_size = 0; + BYTE *post_data = NULL; + WCHAR *headers = NULL; + nsChannelBSC *bsc; + IMoniker *mon; + BSTR new_url; + HRESULT hres; + + TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4), + debugstr_variant(post_data_var), debugstr_variant(headers_var), flags); + + new_url = url; + if(This->doc_obj->hostui) { + OLECHAR *translated_url = NULL; + + hres = IDocHostUIHandler_TranslateUrl(This->doc_obj->hostui, 0, url, &translated_url); + if(hres == S_OK && translated_url) { + new_url = SysAllocString(translated_url); + CoTaskMemFree(translated_url); + } + } + + if(This->doc_obj->client) { + IOleCommandTarget *cmdtrg; + + hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget, (void**)&cmdtrg); + if(SUCCEEDED(hres)) { + VARIANT in, out; + + V_VT(&in) = VT_BSTR; + V_BSTR(&in) = new_url; + V_VT(&out) = VT_BOOL; + V_BOOL(&out) = VARIANT_TRUE; + hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &in, &out); + IOleCommandTarget_Release(cmdtrg); + if(SUCCEEDED(hres)) + VariantClear(&out); + } + } + + /* FIXME: Why not set_ready_state? */ + This->readystate = READYSTATE_UNINITIALIZED; + + hres = CreateURLMoniker(NULL, new_url, &mon); + if(new_url != url) + SysFreeString(new_url); + if(FAILED(hres)) + return hres; + + if(post_data_var) { + if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) { + SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data); + post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements; + } + } + + if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) { + if(V_VT(headers_var) != VT_BSTR) + return E_INVALIDARG; + + headers = V_BSTR(headers_var); + } + + hres = create_channelbsc(mon, headers, post_data, post_data_size, &bsc); + if(post_data) + SafeArrayUnaccessData(V_ARRAY(post_data_var)); + if(FAILED(hres)) { + IMoniker_Release(mon); + return hres; + } + + hres = set_moniker(&This->doc_obj->basedoc, mon, NULL, bsc, TRUE); + if(SUCCEEDED(hres)) + hres = async_start_doc_binding(This, bsc); + + IUnknown_Release((IUnknown*)bsc); + IMoniker_Release(mon); + return hres; +} + +static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%p)\n", This, url); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%p)\n", This, cmdtrg); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%x)\n", This, arg); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLPrivateWindow_GetAddressBar(IHTMLPrivateWindow *iface, BSTR *url) +{ + HTMLWindow *This = HTMLPRIVWINDOW_THIS(iface); + FIXME("(%p)->(%p)\n", This, url); + return E_NOTIMPL; +} + +#undef HTMLPRIVWINDOW_THIS + +static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = { + HTMLPrivateWindow_QueryInterface, + HTMLPrivateWindow_AddRef, + HTMLPrivateWindow_Release, + HTMLPrivateWindow_SuperNavigate, + HTMLPrivateWindow_GetPendingUrl, + HTMLPrivateWindow_SetPICSTarget, + HTMLPrivateWindow_PICSComplete, + HTMLPrivateWindow_FindWindowByName, + HTMLPrivateWindow_GetAddressBar +}; + #define DISPEX_THIS(iface) DEFINE_THIS(HTMLWindow, IDispatchEx, iface) static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) @@ -1688,13 +1849,20 @@ static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid LCID lcid, DISPID *rgDispId) { HTMLWindow *This = DISPEX_THIS(iface); + UINT i; + HRESULT hres; - TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, + WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); - /* FIXME: Use script dispatch */ + for(i=0; i < cNames; i++) { + /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */ + hres = IDispatchEx_GetDispID(DISPATCHEX(This), rgszNames[i], 0, rgDispId+i); + if(FAILED(hres)) + return hres; + } - return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId); + return S_OK; } static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember, @@ -1947,6 +2115,7 @@ HRESULT HTMLWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTML window->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl; window->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl; window->lpHTMLWindow4Vtbl = &HTMLWindow4Vtbl; + window->lpIHTMLPrivateWindowVtbl = &HTMLPrivateWindowVtbl; window->lpIDispatchExVtbl = &WindowDispExVtbl; window->ref = 1; window->doc_obj = doc_obj; diff --git a/dll/win32/mshtml/main.c b/dll/win32/mshtml/main.c index 1e300661b1b..f54c6e3ed32 100644 --- a/dll/win32/mshtml/main.c +++ b/dll/win32/mshtml/main.c @@ -439,11 +439,14 @@ HRESULT WINAPI DllUnregisterServer(void) const char *debugstr_variant(const VARIANT *v) { + if(!v) + return "(null)"; + switch(V_VT(v)) { case VT_EMPTY: - return wine_dbg_sprintf("{VT_EMPTY}"); + return "{VT_EMPTY}"; case VT_NULL: - return wine_dbg_sprintf("{VT_NULL}"); + return "{VT_NULL}"; case VT_I4: return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v)); case VT_R8: diff --git a/dll/win32/mshtml/mshtml.inf b/dll/win32/mshtml/mshtml.inf index f493a3b5df9..dccd7366a84 100644 --- a/dll/win32/mshtml/mshtml.inf +++ b/dll/win32/mshtml/mshtml.inf @@ -90,7 +90,7 @@ HKCR,"CLSID\%CLSID_CRecalcEngine%\InProcServer32","ThreadingModel",,"Apartment" ;; CrSource HKCR,"CLSID\%CLSID_CrSource%",,,"Microsoft CrSource 4.0" -HKCR,"CLSID\%CLSID_CrSource%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_CrSource%\BrowseInPlace",,16 ;; HKCR,"CLSID\%CLSID_CrSource%\DefaultIcon",,0x00020000,"%IEXPLORE%,1" HKCR,"CLSID\%CLSID_CrSource%\EnablePlugin\.css",,,"PointPlus plugin" HKCR,"CLSID\%CLSID_CrSource%\InProcServer32",,,"mshtml.dll" @@ -113,7 +113,7 @@ HKCR,"ScriptBridge.ScriptBridge.1\CLSID",,,"%CLSID_Scriptlet%" ;; HTADocument HKCR,"CLSID\%CLSID_HTADocument%",,,"Microsoft HTA Document 6.0" -HKCR,"CLSID\%CLSID_HTADocument%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_HTADocument%\BrowseInPlace",,16 HKCR,"CLSID\%CLSID_HTADocument%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_HTADocument%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_HTADocument%\MiscStatus",,,"2228625" @@ -121,7 +121,7 @@ HKCR,"CLSID\%CLSID_HTADocument%\Version",,,"6.0" ;; HTMLDocument HKCR,"CLSID\%CLSID_HTMLDocument%",,,"HTML Document" -HKCR,"CLSID\%CLSID_HTMLDocument%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_HTMLDocument%\BrowseInPlace",,16 ;; HKCR,"CLSID\%CLSID_HTMLDocument%\DefaultIcon",,0x00020000,"%IEXPLORE%,1" HKCR,"CLSID\%CLSID_HTMLDocument%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_HTMLDocument%\InProcServer32","ThreadingModel",,"Apartment" @@ -132,7 +132,7 @@ HKCR,"CLSID\%CLSID_HTMLDocument%\EnablePlugin\.css",,,"PointPlus plugin" ;; HTMLPluginDocument HKCR,"CLSID\%CLSID_HTMLPluginDocument%",,,"Microsoft HTML Document 6.0" -HKCR,"CLSID\%CLSID_HTMLPluginDocument%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_HTMLPluginDocument%\BrowseInPlace",,16 HKCR,"CLSID\%CLSID_HTMLPluginDocument%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_HTMLPluginDocument%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_HTMLPluginDocument%\MiscStatus",,,"0" @@ -159,7 +159,7 @@ HKCR,"CLSID\%CLSID_HTMLWindowProxy%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_HTMLWindowProxy%\InProcServer32","ThreadingModel",,"Apartment" ;; IImageDecodeFilter -HKCR,"CLSID\%CLSID_IImageDecodeFilter%",,,"" +HKCR,"CLSID\%CLSID_IImageDecodeFilter%",,,"CoICOFilter Class" HKCR,"CLSID\%CLSID_IImageDecodeFilter%\InProcServer32",,,%_MOD_PATH% HKCR,"CLSID\%CLSID_IImageDecodeFilter%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"MIME\Database\Content Type\image/x-wmf","Image Filter CLSID",,"%CLSID_IImageDecodeFilter%" @@ -214,7 +214,7 @@ HKCR,"CLSID\%CLSID_MailtoProtocol%\InProcServer32","ThreadingModel",,"Apartment" ;; MHTMLDocument HKCR,"CLSID\%CLSID_MHTMLDocument%",,,"MHTML Document" -HKCR,"CLSID\%CLSID_MHTMLDocument%\BrowseInPlace",,,"" +HKCR,"CLSID\%CLSID_MHTMLDocument%\BrowseInPlace",,16 ;; HKCR,"CLSID\%CLSID_MHTMLDocument%\DefaultIcon",,0x00020000,"%IEXPLORE%,1" HKCR,"CLSID\%CLSID_MHTMLDocument%\InProcServer32",,,"mshtml.dll" HKCR,"CLSID\%CLSID_MHTMLDocument%\InProcServer32","ThreadingModel",,"Apartment" @@ -229,13 +229,13 @@ HKCR,"CLSID\%CLSID_ResProtocol%\InProcServer32","ThreadingModel",,"Apartment" ;; Scriptlet HKCR,"CLSID\%CLSID_Scriptlet%",,,"Microsoft Scriptlet Component" -HKCR,"CLSID\%CLSID_Scriptlet%\Control" +HKCR,"CLSID\%CLSID_Scriptlet%\Control",,16 HKCR,"CLSID\%CLSID_Scriptlet%\InProcServer32",,,"%_MOD_PATH%" HKCR,"CLSID\%CLSID_Scriptlet%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_Scriptlet%\MiscStatus",,,"0" HKCR,"CLSID\%CLSID_Scriptlet%\MiscStatus\1",,,"131473" HKCR,"CLSID\%CLSID_Scriptlet%\ProgID",,,"ScriptBridge.ScriptBridge.1" -HKCR,"CLSID\%CLSID_Scriptlet%\Programmable" +HKCR,"CLSID\%CLSID_Scriptlet%\Programmable",,16 ;; HKCR,"CLSID\%CLSID_Scriptlet%\ToolboxBitmap32",,,"%IEXPLORE%,1" HKCR,"CLSID\%CLSID_Scriptlet%\TypeLib",,,"%LIBID_MSHTML%" HKCR,"CLSID\%CLSID_Scriptlet%\Version",,,"4.0" @@ -337,11 +337,11 @@ HKCR,"InternetShortcut\shell\printto\command",,,"rundll32.exe mshtml.dll,PrintHT HKCR,"htmlfile\shell\print\command",,,"rundll32.exe mshtml.dll,PrintHTML ""%%1""" HKCR,"htmlfile\shell\printto\command",,,"rundll32.exe mshtml.dll,PrintHTML ""%%1"" ""%%2"" ""%%3"" ""%%4""" HKCR,"htmlfile",,,"HTML Document" -HKCR,"htmlfile\BrowseInPlace",,,"" +HKCR,"htmlfile\BrowseInPlace",,16 HKCR,"htmlfile\CLSID",,,"%CLSID_HTMLDocument%" ;; HKCR,"htmlfile\DefaultIcon",,0x00020000,"%IEXPLORE%,1" HKCR,"htmlfile_FullWindowEmbed",,,"HTML Plugin Document" -HKCR,"htmlfile_FullWindowEmbed\BrowseInPlace",,,"" +HKCR,"htmlfile_FullWindowEmbed\BrowseInPlace",,16 HKCR,"htmlfile_FullWindowEmbed\CLSID",,,"%CLSID_HTMLPluginDocument%" HKCR,".htm",,,"htmlfile" HKCR,".htm","Content Type",,"text/html" @@ -398,7 +398,7 @@ HKCR,".mhtml","Content Type",,"message/rfc822" HKCR,".mht",,2,"mhtmlfile" HKCR,".mht","Content Type",,"message/rfc822" HKCR,"mhtmlfile",,,"MHTML Document" -HKCR,"mhtmlfile\BrowseInPlace",,,"" +HKCR,"mhtmlfile\BrowseInPlace",,16 HKCR,"mhtmlfile\CLSID",,,"%CLSID_MHTMLDocument%" ;; MPEG diff --git a/dll/win32/mshtml/mshtml.rbuild b/dll/win32/mshtml/mshtml.rbuild index 562a68aac01..c3f56cd19d2 100644 --- a/dll/win32/mshtml/mshtml.rbuild +++ b/dll/win32/mshtml/mshtml.rbuild @@ -30,6 +30,7 @@ htmlelemcol.c htmlevent.c htmlform.c + htmlframe.c htmlframebase.c htmlgeneric.c htmliframe.c diff --git a/dll/win32/mshtml/mshtml_private.h b/dll/win32/mshtml/mshtml_private.h index 68b3393d868..5a409b3cae5 100644 --- a/dll/win32/mshtml/mshtml_private.h +++ b/dll/win32/mshtml/mshtml_private.h @@ -68,6 +68,7 @@ typedef enum { DispHTMLElementCollection_tid, DispHTMLFormElement_tid, DispHTMLGenericElement_tid, + DispHTMLFrameElement_tid, DispHTMLIFrame_tid, DispHTMLImg_tid, DispHTMLInputElement_tid, @@ -75,10 +76,12 @@ typedef enum { DispHTMLNavigator_tid, DispHTMLOptionElement_tid, DispHTMLScreen_tid, + DispHTMLScriptElement_tid, DispHTMLSelectElement_tid, DispHTMLStyle_tid, DispHTMLTable_tid, DispHTMLTableRow_tid, + DispHTMLTextAreaElement_tid, DispHTMLUnknownElement_tid, DispHTMLWindow2_tid, HTMLDocumentEvents_tid, @@ -108,13 +111,16 @@ typedef enum { IHTMLFormElement_tid, IHTMLFrameBase_tid, IHTMLFrameBase2_tid, + IHTMLFrameElement3_tid, IHTMLGenericElement_tid, + IHTMLIFrameElement_tid, IHTMLImageElementFactory_tid, IHTMLImgElement_tid, IHTMLInputElement_tid, IHTMLLocation_tid, IHTMLOptionElement_tid, IHTMLScreen_tid, + IHTMLScriptElement_tid, IHTMLSelectElement_tid, IHTMLStyle_tid, IHTMLStyle2_tid, @@ -122,6 +128,7 @@ typedef enum { IHTMLStyle4_tid, IHTMLTable_tid, IHTMLTableRow_tid, + IHTMLTextAreaElement_tid, IHTMLTextContainer_tid, IHTMLUniqueName_tid, IHTMLWindow2_tid, @@ -165,9 +172,11 @@ BOOL dispex_query_interface(DispatchEx*,REFIID,void**); HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**); HRESULT get_dispids(tid_t,DWORD*,DISPID**); +typedef struct HTMLWindow HTMLWindow; typedef struct HTMLDocumentNode HTMLDocumentNode; typedef struct HTMLDocumentObj HTMLDocumentObj; typedef struct HTMLFrameBase HTMLFrameBase; +typedef struct NSContainer NSContainer; typedef enum { SCRIPTMODE_GECKO, @@ -219,11 +228,14 @@ typedef struct { LONG ref; } windowref_t; +typedef struct nsChannelBSC nsChannelBSC; + struct HTMLWindow { DispatchEx dispex; const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl; const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl; const IHTMLWindow4Vtbl *lpHTMLWindow4Vtbl; + const IHTMLPrivateWindowVtbl *lpIHTMLPrivateWindowVtbl; const IDispatchExVtbl *lpIDispatchExVtbl; LONG ref; @@ -373,6 +385,7 @@ struct HTMLDocumentObj { IOleInPlaceSite *ipsite; IOleInPlaceFrame *frame; IOleInPlaceUIWindow *ip_window; + IAdviseSink *view_sink; DOCHOSTUIINFO hostinfo; @@ -385,7 +398,7 @@ struct HTMLDocumentObj { BOOL in_place_active; BOOL ui_active; BOOL window_active; - BOOL has_key_path; + BOOL hostui_setup; BOOL container_locked; BOOL focus; INT download_state; @@ -426,6 +439,11 @@ struct NSContainer { HWND reset_focus; /* hack */ }; +typedef struct nsWineURI nsWineURI; + +HRESULT set_wine_url(nsWineURI*,LPCWSTR); +nsresult on_start_uri_open(NSContainer*,nsIURI*,PRBool*); + typedef struct { const nsIHttpChannelVtbl *lpHttpChannelVtbl; const nsIUploadChannelVtbl *lpUploadChannelVtbl; @@ -433,7 +451,7 @@ typedef struct { LONG ref; - nsIWineURI *uri; + nsWineURI *uri; nsIInputStream *post_data_stream; nsILoadGroup *load_group; nsIInterfaceRequestor *notif_callback; @@ -487,6 +505,14 @@ typedef struct { nsIDOMHTMLElement *nselem; } HTMLElement; +#define HTMLELEMENT_TIDS \ + IHTMLDOMNode_tid, \ + IHTMLDOMNode2_tid, \ + IHTMLElement_tid, \ + IHTMLElement2_tid, \ + IHTMLElement3_tid, \ + IHTMLElement4_tid + typedef struct { HTMLElement element; @@ -680,12 +706,13 @@ void release_nsio(void); BOOL install_wine_gecko(BOOL); HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*); -HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsIWineURI**); +HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**); +HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD); -HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD); +HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD,BOOL*); HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*); HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*); -HRESULT load_nsuri(HTMLWindow*,nsIWineURI*,DWORD); +HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL); void call_property_onchanged(ConnectionPoint*,DISPID); HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*); @@ -696,7 +723,8 @@ void nsfree(void*); void nsACString_SetData(nsACString*,const char*); PRUint32 nsACString_GetData(const nsACString*,const char**); -void nsAString_Init(nsAString*,const PRUnichar*); +BOOL nsAString_Init(nsAString*,const PRUnichar*); +void nsAString_InitDepend(nsAString*,const PRUnichar*); void nsAString_SetData(nsAString*,const PRUnichar*); PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**); void nsAString_Finish(nsAString*); @@ -713,11 +741,12 @@ void add_nsevent_listener(HTMLDocumentNode*,LPCWSTR); void set_window_bscallback(HTMLWindow*,nsChannelBSC*); void set_current_mon(HTMLWindow*,IMoniker*); HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*); +HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*); void abort_document_bindings(HTMLDocumentNode*); HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*); -nsChannelBSC *create_channelbsc(IMoniker*); +HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**); HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*); void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*); IMoniker *get_channelbsc_mon(nsChannelBSC*); diff --git a/dll/win32/mshtml/mutation.c b/dll/win32/mshtml/mutation.c index 372c467bf53..61ceca83525 100644 --- a/dll/win32/mshtml/mutation.c +++ b/dll/win32/mshtml/mutation.c @@ -168,12 +168,12 @@ static BOOL handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *commen memcpy(buf, ptr, (end-ptr)*sizeof(WCHAR)); buf[end-ptr] = 0; - nsAString_Init(&nsstr, buf); - heap_free(buf); + nsAString_InitDepend(&nsstr, buf); /* FIXME: Find better way to insert HTML to document. */ nsres = nsIDOMHTMLDocument_Write(doc->nsdoc, &nsstr); nsAString_Finish(&nsstr); + heap_free(buf); if(NS_FAILED(nsres)) { ERR("Write failed: %08x\n", nsres); return FALSE; @@ -322,6 +322,8 @@ static void parse_complete_proc(task_t *task) init_editor(&doc->basedoc); call_explorer_69(doc); + if(doc->view_sink) + IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1); call_property_onchanged(&doc->basedoc.cp_propnotif, 1005); call_explorer_69(doc); @@ -396,7 +398,7 @@ static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface) static const PRUnichar remove_comment_magicW[] = {'#','!','w','i','n','e', 'r','e','m','o','v','e','!','#',0}; - nsAString_Init(&magic_str, remove_comment_magicW); + nsAString_InitDepend(&magic_str, remove_comment_magicW); nsres = nsIDOMComment_SetData(nscomment, &magic_str); nsAString_Finish(&magic_str); if(NS_FAILED(nsres)) diff --git a/dll/win32/mshtml/navigate.c b/dll/win32/mshtml/navigate.c index b85de92e33d..a09ea7f64d6 100644 --- a/dll/win32/mshtml/navigate.c +++ b/dll/win32/mshtml/navigate.c @@ -717,8 +717,11 @@ HRESULT start_binding(HTMLWindow *window, HTMLDocumentNode *doc, BSCallback *bsc /* NOTE: IE7 calls IsSystemMoniker here*/ - if(window) + if(window) { + if(bscallback->mon != window->mon) + set_current_mon(window, bscallback->mon); call_docview_84(window->doc_obj); + } if(bctx) { RegisterBindStatusCallback(bctx, STATUSCLB(bscallback), NULL, 0); @@ -1087,7 +1090,7 @@ static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCW TRACE("redirect to %s\n", debugstr_w(status_text)); /* FIXME: We should find a better way to handle this */ - nsIWineURI_SetWineURL(This->nschannel->uri, status_text); + set_wine_url(This->nschannel->uri, status_text); } return S_OK; @@ -1113,13 +1116,38 @@ static const BSCallbackVtbl nsChannelBSCVtbl = { nsChannelBSC_on_response }; -nsChannelBSC *create_channelbsc(IMoniker *mon) +HRESULT create_channelbsc(IMoniker *mon, WCHAR *headers, BYTE *post_data, DWORD post_data_size, nsChannelBSC **retval) { - nsChannelBSC *ret = heap_alloc_zero(sizeof(*ret)); + nsChannelBSC *ret; + + ret = heap_alloc_zero(sizeof(*ret)); + if(!ret) + return E_OUTOFMEMORY; init_bscallback(&ret->bsc, &nsChannelBSCVtbl, mon, BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA); - return ret; + if(headers) { + ret->bsc.headers = heap_strdupW(headers); + if(!ret->bsc.headers) { + IBindStatusCallback_Release(STATUSCLB(&ret->bsc)); + return E_OUTOFMEMORY; + } + } + + if(post_data) { + ret->bsc.post_data = GlobalAlloc(0, post_data_size); + if(!ret->bsc.post_data) { + heap_free(ret->bsc.headers); + IBindStatusCallback_Release(STATUSCLB(&ret->bsc)); + return E_OUTOFMEMORY; + } + + memcpy(ret->bsc.post_data, post_data, post_data_size); + ret->bsc.post_data_len = post_data_size; + } + + *retval = ret; + return S_OK; } IMoniker *get_channelbsc_mon(nsChannelBSC *This) @@ -1148,6 +1176,36 @@ void set_window_bscallback(HTMLWindow *window, nsChannelBSC *callback) } } +typedef struct { + task_t header; + HTMLWindow *window; + nsChannelBSC *bscallback; +} start_doc_binding_task_t; + +static void start_doc_binding_proc(task_t *_task) +{ + start_doc_binding_task_t *task = (start_doc_binding_task_t*)_task; + + start_binding(task->window, NULL, (BSCallback*)task->bscallback, NULL); + IBindStatusCallback_Release(STATUSCLB(&task->bscallback->bsc)); +} + +HRESULT async_start_doc_binding(HTMLWindow *window, nsChannelBSC *bscallback) +{ + start_doc_binding_task_t *task; + + task = heap_alloc(sizeof(start_doc_binding_task_t)); + if(!task) + return E_OUTOFMEMORY; + + task->window = window; + task->bscallback = bscallback; + IBindStatusCallback_AddRef(STATUSCLB(&bscallback->bsc)); + + push_task(&task->header, start_doc_binding_proc, window->task_magic); + return S_OK; +} + void abort_document_bindings(HTMLDocumentNode *doc) { BSCallback *iter; @@ -1196,37 +1254,43 @@ void channelbsc_set_channel(nsChannelBSC *This, nsChannel *channel, nsIStreamLis } HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, - nsIInputStream *post_data_stream, DWORD hlnf) + nsIInputStream *post_data_stream, DWORD hlnf, BOOL *cancel) { IHlinkFrame *hlink_frame; + nsChannelBSC *callback; IServiceProvider *sp; - BSCallback *callback; IBindCtx *bindctx; IMoniker *mon; IHlink *hlink; HRESULT hres; + *cancel = FALSE; + hres = IOleClientSite_QueryInterface(doc->doc_obj->client, &IID_IServiceProvider, (void**)&sp); if(FAILED(hres)) - return hres; + return S_OK; hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hlink_frame); IServiceProvider_Release(sp); if(FAILED(hres)) + return S_OK; + + hres = create_channelbsc(NULL, NULL, NULL, 0, &callback); + if(FAILED(hres)) { + IHlinkFrame_Release(hlink_frame); return hres; - - callback = &create_channelbsc(NULL)->bsc; - - if(post_data_stream) { - parse_post_data(post_data_stream, &callback->headers, &callback->post_data, - &callback->post_data_len); - TRACE("headers = %s post_data = %s\n", debugstr_w(callback->headers), - debugstr_an(callback->post_data, callback->post_data_len)); } - hres = CreateAsyncBindCtx(0, STATUSCLB(callback), NULL, &bindctx); + if(post_data_stream) { + parse_post_data(post_data_stream, &callback->bsc.headers, &callback->bsc.post_data, + &callback->bsc.post_data_len); + TRACE("headers = %s post_data = %s\n", debugstr_w(callback->bsc.headers), + debugstr_an(callback->bsc.post_data, callback->bsc.post_data_len)); + } + + hres = CreateAsyncBindCtx(0, STATUSCLB(&callback->bsc), NULL, &bindctx); if(SUCCEEDED(hres)) hres = CoCreateInstance(&CLSID_StdHlink, NULL, CLSCTX_INPROC_SERVER, &IID_IHlink, (LPVOID*)&hlink); @@ -1242,50 +1306,22 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, IHlink_SetTargetFrameName(hlink, wszBlank); /* FIXME */ } - hres = IHlinkFrame_Navigate(hlink_frame, hlnf, bindctx, STATUSCLB(callback), hlink); - + hres = IHlinkFrame_Navigate(hlink_frame, hlnf, bindctx, STATUSCLB(&callback->bsc), hlink); IMoniker_Release(mon); + *cancel = hres == S_OK; + hres = S_OK; } IHlinkFrame_Release(hlink_frame); IBindCtx_Release(bindctx); - IBindStatusCallback_Release(STATUSCLB(callback)); + IBindStatusCallback_Release(STATUSCLB(&callback->bsc)); return hres; } -HRESULT load_nsuri(HTMLWindow *window, nsIWineURI *uri, DWORD flags) -{ - nsIWebNavigation *web_navigation; - nsIDocShell *doc_shell; - nsresult nsres; - - nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation); - if(NS_FAILED(nsres)) { - ERR("Could not get nsIWebNavigation interface: %08x\n", nsres); - return E_FAIL; - } - - nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell); - nsIWebNavigation_Release(web_navigation); - if(NS_FAILED(nsres)) { - ERR("Could not get nsIDocShell: %08x\n", nsres); - return E_FAIL; - } - - nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)uri, NULL, flags, FALSE); - nsIDocShell_Release(doc_shell); - if(NS_FAILED(nsres)) { - WARN("LoadURI failed: %08x\n", nsres); - return E_FAIL; - } - - return S_OK; -} - HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base_url) { WCHAR url[INTERNET_MAX_URL_LENGTH]; - nsIWineURI *uri; + nsWineURI *uri; HRESULT hres; if(!new_url) { @@ -1307,23 +1343,30 @@ HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base hres = IDocHostUIHandler_TranslateUrl(window->doc_obj->hostui, 0, url, &translated_url); if(hres == S_OK) { + TRACE("%08x %s -> %s\n", hres, debugstr_w(url), debugstr_w(translated_url)); strcpyW(url, translated_url); CoTaskMemFree(translated_url); } } if(window->doc_obj && window == window->doc_obj->basedoc.window) { - hres = hlink_frame_navigate(&window->doc->basedoc, url, NULL, 0); - if(SUCCEEDED(hres)) + BOOL cancel; + + hres = hlink_frame_navigate(&window->doc->basedoc, url, NULL, 0, &cancel); + if(FAILED(hres)) + return hres; + + if(cancel) { + TRACE("Navigation handled by hlink frame\n"); return S_OK; - TRACE("hlink_frame_navigate failed: %08x\n", hres); + } } hres = create_doc_uri(window, url, &uri); if(FAILED(hres)) return hres; - hres = load_nsuri(window, uri, LOAD_FLAGS_NONE); - nsIWineURI_Release(uri); + hres = load_nsuri(window, uri, NULL, LOAD_FLAGS_NONE); + nsISupports_Release((nsISupports*)uri); return hres; } diff --git a/dll/win32/mshtml/nsembed.c b/dll/win32/mshtml/nsembed.c index 68588977697..fa8aa41fedf 100644 --- a/dll/win32/mshtml/nsembed.c +++ b/dll/win32/mshtml/nsembed.c @@ -52,13 +52,15 @@ struct nsCStringContainer { void *v; void *d1; PRUint32 d2; - void *d3; + PRUint32 d3; }; +#define NS_STRING_CONTAINER_INIT_DEPEND 0x0002 + static nsresult (*NS_InitXPCOM2)(nsIServiceManager**,void*,void*); static nsresult (*NS_ShutdownXPCOM)(nsIServiceManager*); static nsresult (*NS_GetComponentRegistrar)(nsIComponentRegistrar**); -static nsresult (*NS_StringContainerInit)(nsStringContainer*); +static nsresult (*NS_StringContainerInit2)(nsStringContainer*,const PRUnichar*,PRUint32,PRUint32); static nsresult (*NS_CStringContainerInit)(nsCStringContainer*); static nsresult (*NS_StringContainerFinish)(nsStringContainer*); static nsresult (*NS_CStringContainerFinish)(nsCStringContainer*); @@ -194,7 +196,7 @@ static BOOL load_xpcom(const PRUnichar *gre_path) NS_DLSYM(NS_InitXPCOM2); NS_DLSYM(NS_ShutdownXPCOM); NS_DLSYM(NS_GetComponentRegistrar); - NS_DLSYM(NS_StringContainerInit); + NS_DLSYM(NS_StringContainerInit2); NS_DLSYM(NS_CStringContainerInit); NS_DLSYM(NS_StringContainerFinish); NS_DLSYM(NS_CStringContainerFinish); @@ -424,7 +426,7 @@ static BOOL init_xpcom(const PRUnichar *gre_path) nsAString path; nsIFile *gre_dir; - nsAString_Init(&path, gre_path); + nsAString_InitDepend(&path, gre_path); nsres = NS_NewLocalFile(&path, FALSE, &gre_dir); nsAString_Finish(&path); if(NS_FAILED(nsres)) { @@ -555,11 +557,18 @@ static void nsACString_Finish(nsACString *str) NS_CStringContainerFinish(str); } -void nsAString_Init(nsAString *str, const PRUnichar *data) +BOOL nsAString_Init(nsAString *str, const PRUnichar *data) { - NS_StringContainerInit(str); - if(data) - nsAString_SetData(str, data); + return NS_SUCCEEDED(NS_StringContainerInit2(str, data, PR_UINT32_MAX, 0)); +} + +/* + * Initializes nsAString with data owned by caller. + * Caller must ensure that data is valid during lifetime of string object. + */ +void nsAString_InitDepend(nsAString *str, const PRUnichar *data) +{ + NS_StringContainerInit2(str, data, PR_UINT32_MAX, NS_STRING_CONTAINER_INIT_DEPEND); } void nsAString_SetData(nsAString *str, const PRUnichar *data) @@ -1115,41 +1124,12 @@ static nsrefcnt NSAPI nsURIContentListener_Release(nsIURIContentListener *iface) return nsIWebBrowserChrome_Release(NSWBCHROME(This)); } -static BOOL translate_url(HTMLDocumentObj *doc, nsIWineURI *nsuri) -{ - OLECHAR *new_url = NULL, *url; - BOOL ret = FALSE; - LPCWSTR wine_url; - HRESULT hres; - - if(!doc->hostui) - return FALSE; - - nsIWineURI_GetWineURL(nsuri, &wine_url); - - url = heap_strdupW(wine_url); - hres = IDocHostUIHandler_TranslateUrl(doc->hostui, 0, url, &new_url); - heap_free(url); - if(hres != S_OK || !new_url) - return FALSE; - - if(strcmpW(url, new_url)) { - FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url), debugstr_w(new_url)); - ret = TRUE; - } - - CoTaskMemFree(new_url); - return ret; -} - static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener *iface, nsIURI *aURI, PRBool *_retval) { NSContainer *This = NSURICL_THIS(iface); - nsIWineURI *wine_uri; nsACString spec_str; const char *spec; - BOOL is_doc_uri; nsresult nsres; nsACString_Init(&spec_str, NULL); @@ -1160,22 +1140,9 @@ static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener nsACString_Finish(&spec_str); - nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri); - if(NS_FAILED(nsres)) { - WARN("Could not get nsIWineURI interface: %08x\n", nsres); - return NS_ERROR_NOT_IMPLEMENTED; - } - - nsIWineURI_GetIsDocumentURI(wine_uri, &is_doc_uri); - - if(!is_doc_uri) { - nsIWineURI_SetNSContainer(wine_uri, This); - nsIWineURI_SetIsDocumentURI(wine_uri, TRUE); - - *_retval = translate_url(This->doc->basedoc.doc_obj, wine_uri); - } - - nsIWineURI_Release(wine_uri); + nsres = on_start_uri_open(This, aURI, _retval); + if(NS_FAILED(nsres)) + return nsres; return !*_retval && This->content_listener ? nsIURIContentListener_OnStartURIOpen(This->content_listener, aURI, _retval) diff --git a/dll/win32/mshtml/nsevents.c b/dll/win32/mshtml/nsevents.c index 46f057f079a..65bcae05c31 100644 --- a/dll/win32/mshtml/nsevents.c +++ b/dll/win32/mshtml/nsevents.c @@ -236,6 +236,9 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event set_ready_state(doc->basedoc.window, READYSTATE_COMPLETE); if(doc == doc_obj->basedoc.doc_node) { + if(doc_obj->view_sink) + IAdviseSink_OnViewChange(doc_obj->view_sink, DVASPECT_CONTENT, -1); + if(doc_obj->frame) { static const WCHAR wszDone[] = {'D','o','n','e',0}; IOleInPlaceFrame_SetStatusText(doc_obj->frame, wszDone); @@ -316,7 +319,7 @@ static void init_event(nsIDOMEventTarget *target, const PRUnichar *type, nsAString type_str; nsresult nsres; - nsAString_Init(&type_str, type); + nsAString_InitDepend(&type_str, type); nsres = nsIDOMEventTarget_AddEventListener(target, &type_str, listener, capture); nsAString_Finish(&type_str); if(NS_FAILED(nsres)) diff --git a/dll/win32/mshtml/nsiface.idl b/dll/win32/mshtml/nsiface.idl index af117622001..66ab8e6a49b 100644 --- a/dll/win32/mshtml/nsiface.idl +++ b/dll/win32/mshtml/nsiface.idl @@ -2820,32 +2820,3 @@ interface nsIDocumentObserver : nsIMutationObserver void BindToDocument(nsIDocument *aDocument, nsIContent *aContent); void DoneAddingChildren(nsIContent *aContent, PRBool aHaveNotified); } - -/* - * NOTE: - * This is a private Wine interface that is implemented by our implementation - * of nsIURI to store its owner. - */ -[ - object, - uuid(5088272e-900b-11da-c687-000fea57f21a), - local - /* INTERNAL */ -] -interface nsIWineURI : nsIURL -{ - typedef struct NSContainer NSContainer; - typedef struct HTMLWindow HTMLWindow; - typedef struct nsChannelBSC nsChannelBSC; - - nsresult GetNSContainer(NSContainer **aNSContainer); - nsresult SetNSContainer(NSContainer *aNSContainer); - nsresult GetWindow(HTMLWindow **aHTMLWindow); - nsresult SetWindow(HTMLWindow *aHTMLWindow); - nsresult GetChannelBSC(nsChannelBSC **aChannelBSC); - nsresult SetChannelBSC(nsChannelBSC *aChannelBSC); - nsresult GetIsDocumentURI(PRBool *aIsDocumentURI); - nsresult SetIsDocumentURI(PRBool aIsDocumentURI); - nsresult GetWineURL(LPCWSTR *aURL); - nsresult SetWineURL(LPCWSTR aURL); -} diff --git a/dll/win32/mshtml/nsio.c b/dll/win32/mshtml/nsio.c index 46fdcbc320c..f4e6f4bcb56 100644 --- a/dll/win32/mshtml/nsio.c +++ b/dll/win32/mshtml/nsio.c @@ -43,14 +43,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); static const IID NS_IOSERVICE_CID = {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}}; +static const IID IID_nsWineURI = + {0x5088272e, 0x900b, 0x11da, {0xc6,0x87, 0x00,0x0f,0xea,0x57,0xf2,0x1a}}; static nsIIOService *nsio = NULL; static nsINetUtil *net_util; static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; -typedef struct { - const nsIWineURIVtbl *lpWineURIVtbl; +struct nsWineURI { + const nsIURLVtbl *lpIURLVtbl; LONG ref; @@ -60,14 +62,14 @@ typedef struct { windowref_t *window_ref; nsChannelBSC *channel_bsc; LPWSTR wine_url; - PRBool is_doc_uri; + BOOL is_doc_uri; BOOL use_wine_url; -} nsURI; +}; -#define NSURI(x) ((nsIURI*) &(x)->lpWineURIVtbl) -#define NSWINEURI(x) ((nsIWineURI*) &(x)->lpWineURIVtbl) +#define NSURI(x) ((nsIURI*) &(x)->lpIURLVtbl) +#define NSURL(x) ((nsIURL*) &(x)->lpIURLVtbl) -static nsresult create_uri(nsIURI*,HTMLWindow*,NSContainer*,nsIWineURI**); +static nsresult create_uri(nsIURI*,HTMLWindow*,NSContainer*,nsWineURI**); static const char *debugstr_nsacstr(const nsACString *nsstr) { @@ -129,15 +131,9 @@ static BOOL before_async_open(nsChannel *channel, NSContainer *container) { HTMLDocumentObj *doc = container->doc; DWORD hlnf = 0; - LPCWSTR uri; + BOOL cancel; HRESULT hres; - nsIWineURI_GetWineURL(channel->uri, &uri); - if(!uri) { - ERR("GetWineURL returned NULL\n"); - return TRUE; - } - if(!doc) { NSContainer *container_iter = container; @@ -150,11 +146,163 @@ static BOOL before_async_open(nsChannel *channel, NSContainer *container) if(!doc->client) return TRUE; - if(!hlnf && !exec_shldocvw_67(doc, uri)) + if(!hlnf && !exec_shldocvw_67(doc, channel->uri->wine_url)) return FALSE; - hres = hlink_frame_navigate(&doc->basedoc, uri, channel->post_data_stream, hlnf); - return hres != S_OK; + hres = hlink_frame_navigate(&doc->basedoc, channel->uri->wine_url, channel->post_data_stream, hlnf, &cancel); + return FAILED(hres) || cancel; +} + +HRESULT load_nsuri(HTMLWindow *window, nsWineURI *uri, nsChannelBSC *channelbsc, DWORD flags) +{ + nsIWebNavigation *web_navigation; + nsIDocShell *doc_shell; + nsresult nsres; + + nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIWebNavigation interface: %08x\n", nsres); + return E_FAIL; + } + + nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell); + nsIWebNavigation_Release(web_navigation); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIDocShell: %08x\n", nsres); + return E_FAIL; + } + + + uri->channel_bsc = channelbsc; + nsres = nsIDocShell_LoadURI(doc_shell, NSURI(uri), NULL, flags, FALSE); + uri->channel_bsc = NULL; + nsIDocShell_Release(doc_shell); + if(NS_FAILED(nsres)) { + WARN("LoadURI failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; +} + +static BOOL translate_url(HTMLDocumentObj *doc, nsWineURI *uri) +{ + OLECHAR *new_url = NULL, *url; + BOOL ret = FALSE; + HRESULT hres; + + if(!doc->hostui) + return FALSE; + + url = heap_strdupW(uri->wine_url); + hres = IDocHostUIHandler_TranslateUrl(doc->hostui, 0, url, &new_url); + heap_free(url); + if(hres != S_OK || !new_url) + return FALSE; + + if(strcmpW(url, new_url)) { + FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url), debugstr_w(new_url)); + ret = TRUE; + } + + CoTaskMemFree(new_url); + return ret; +} + +nsresult on_start_uri_open(NSContainer *nscontainer, nsIURI *uri, PRBool *_retval) +{ + nsWineURI *wine_uri; + nsresult nsres; + + *_retval = FALSE; + + nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri); + if(NS_FAILED(nsres)) { + WARN("Could not get nsWineURI: %08x\n", nsres); + return NS_ERROR_NOT_IMPLEMENTED; + } + + if(!wine_uri->is_doc_uri) { + if(!wine_uri->container) { + nsIWebBrowserChrome_AddRef(NSWBCHROME(nscontainer)); + wine_uri->container = nscontainer; + } + + wine_uri->is_doc_uri = TRUE; + *_retval = translate_url(nscontainer->doc->basedoc.doc_obj, wine_uri); + } + + nsIURI_Release(NSURI(wine_uri)); + return NS_OK; +} + +HRESULT set_wine_url(nsWineURI *This, LPCWSTR url) +{ + static const WCHAR wszFtp[] = {'f','t','p',':'}; + static const WCHAR wszHttp[] = {'h','t','t','p',':'}; + static const WCHAR wszHttps[] = {'h','t','t','p','s',':'}; + + TRACE("(%p)->(%s)\n", This, debugstr_w(url)); + + if(url) { + WCHAR *new_url; + + new_url = heap_strdupW(url); + if(!new_url) + return E_OUTOFMEMORY; + heap_free(This->wine_url); + This->wine_url = new_url; + + if(This->uri) { + /* FIXME: Always use wine url */ + This->use_wine_url = + strncmpW(url, wszFtp, sizeof(wszFtp)/sizeof(WCHAR)) + && strncmpW(url, wszHttp, sizeof(wszHttp)/sizeof(WCHAR)) + && strncmpW(url, wszHttps, sizeof(wszHttps)/sizeof(WCHAR)); + }else { + This->use_wine_url = TRUE; + } + }else { + heap_free(This->wine_url); + This->wine_url = NULL; + This->use_wine_url = FALSE; + } + + return S_OK; +} + +static void set_uri_nscontainer(nsWineURI *This, NSContainer *nscontainer) +{ + if(This->container) { + if(This->container == nscontainer) + return; + TRACE("Changing %p -> %p\n", This->container, nscontainer); + nsIWebBrowserChrome_Release(NSWBCHROME(This->container)); + } + + if(nscontainer) + nsIWebBrowserChrome_AddRef(NSWBCHROME(nscontainer)); + This->container = nscontainer; +} + +static void set_uri_window(nsWineURI *This, HTMLWindow *window) +{ + if(This->window_ref) { + if(This->window_ref->window == window) + return; + TRACE("Changing %p -> %p\n", This->window_ref->window, window); + windowref_release(This->window_ref); + } + + if(window) { + windowref_addref(window->window_ref); + This->window_ref = window->window_ref; + + if(window->doc_obj) + set_uri_nscontainer(This, window->doc_obj->nscontainer); + }else { + This->window_ref = NULL; + } } static inline BOOL is_http_channel(nsChannel *This) @@ -215,7 +363,7 @@ static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface) LONG ref = InterlockedDecrement(&This->ref); if(!ref) { - nsIWineURI_Release(This->uri); + nsIURI_Release(NSURI(This->uri)); if(This->owner) nsISupports_Release(This->owner); if(This->post_data_stream) @@ -369,7 +517,7 @@ static nsresult NSAPI nsChannel_GetURI(nsIHttpChannel *iface, nsIURI **aURI) TRACE("(%p)->(%p)\n", This, aURI); - nsIWineURI_AddRef(This->uri); + nsIURI_AddRef(NSURI(This->uri)); *aURI = (nsIURI*)This->uri; return NS_OK; @@ -438,7 +586,7 @@ static nsresult NSAPI nsChannel_GetSecurityInfo(nsIHttpChannel *iface, nsISuppor { nsChannel *This = NSCHANNEL_THIS(iface); - FIXME("(%p)->(%p)\n", This, aSecurityInfo); + TRACE("(%p)->(%p)\n", This, aSecurityInfo); return NS_ERROR_NOT_IMPLEMENTED; } @@ -531,8 +679,7 @@ static nsresult NSAPI nsChannel_Open(nsIHttpChannel *iface, nsIInputStream **_re static HRESULT create_mon_for_nschannel(nsChannel *channel, IMoniker **mon) { - nsIWineURI *wine_uri; - LPCWSTR wine_url; + nsWineURI *wine_uri; nsresult nsres; HRESULT hres; @@ -541,22 +688,22 @@ static HRESULT create_mon_for_nschannel(nsChannel *channel, IMoniker **mon) return E_FAIL; } - nsres = nsIURI_QueryInterface(channel->original_uri, &IID_nsIWineURI, (void**)&wine_uri); + nsres = nsIURI_QueryInterface(channel->original_uri, &IID_nsWineURI, (void**)&wine_uri); if(NS_FAILED(nsres)) { - ERR("Could not get nsIWineURI: %08x\n", nsres); + ERR("Could not get nsWineURI: %08x\n", nsres); return E_FAIL; } - nsIWineURI_GetWineURL(wine_uri, &wine_url); - nsIWineURI_Release(wine_uri); - if(!wine_url) { + if(wine_uri->wine_url) { + hres = CreateURLMoniker(NULL, wine_uri->wine_url, mon); + if(FAILED(hres)) + WARN("CreateURLMoniker failed: %08x\n", hres); + }else { TRACE("wine_url == NULL\n"); - return E_FAIL; + hres = E_FAIL; } - hres = CreateURLMoniker(NULL, wine_url, mon); - if(FAILED(hres)) - WARN("CreateURLMoniker failed: %08x\n", hres); + nsIURI_Release(NSURI(wine_uri)); return hres; } @@ -566,7 +713,7 @@ static HTMLWindow *get_window_from_load_group(nsChannel *This) HTMLWindow *window; nsIChannel *channel; nsIRequest *req; - nsIWineURI *wine_uri; + nsWineURI *wine_uri; nsIURI *uri; nsresult nsres; @@ -593,15 +740,17 @@ static HTMLWindow *get_window_from_load_group(nsChannel *This) return NULL; } - nsres = nsIURI_QueryInterface(uri, &IID_nsIWineURI, (void**)&wine_uri); + nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri); nsIURI_Release(uri); if(NS_FAILED(nsres)) { - TRACE("Could not get nsIWineURI: %08x\n", nsres); + TRACE("Could not get nsWineURI: %08x\n", nsres); return NULL; } - nsIWineURI_GetWindow(wine_uri, &window); - nsIWineURI_Release(wine_uri); + window = wine_uri->window_ref ? wine_uri->window_ref->window : NULL; + if(window) + IHTMLWindow2_AddRef(HTMLWINDOW2(window)); + nsIURI_Release(NSURI(wine_uri)); return window; } @@ -660,19 +809,7 @@ static void start_binding_proc(task_t *_task) start_binding_task_t *task = (start_binding_task_t*)_task; start_binding(NULL, task->doc, (BSCallback*)task->bscallback, NULL); -} -typedef struct { - task_t header; - HTMLWindow *window; - nsChannelBSC *bscallback; -} start_doc_binding_task_t; - -static void start_doc_binding_proc(task_t *_task) -{ - start_doc_binding_task_t *task = (start_doc_binding_task_t*)_task; - - start_binding(task->window, NULL, (BSCallback*)task->bscallback, NULL); IUnknown_Release((IUnknown*)task->bscallback); } @@ -690,20 +827,17 @@ static nsresult async_open(nsChannel *This, HTMLWindow *window, BOOL is_doc_chan if(is_doc_channel) set_current_mon(window, mon); - bscallback = create_channelbsc(mon); + hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback); IMoniker_Release(mon); + if(FAILED(hres)) + return NS_ERROR_UNEXPECTED; channelbsc_set_channel(bscallback, This, listener, context); if(is_doc_channel) { - start_doc_binding_task_t *task; - set_window_bscallback(window, bscallback); - - task = heap_alloc(sizeof(start_doc_binding_task_t)); - task->window = window; - task->bscallback = bscallback; - push_task(&task->header, start_doc_binding_proc, window->task_magic); + async_start_doc_binding(window, bscallback); + IUnknown_Release((IUnknown*)bscallback); }else { start_binding_task_t *task = heap_alloc(sizeof(start_binding_task_t)); @@ -720,51 +854,37 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen { nsChannel *This = NSCHANNEL_THIS(iface); HTMLWindow *window = NULL; - PRBool is_doc_uri; BOOL open = TRUE; nsresult nsres = NS_OK; - TRACE("(%p)->(%p %p)\n", This, aListener, aContext); + TRACE("(%p)->(%p %p) opening %s\n", This, aListener, aContext, debugstr_w(This->uri->wine_url)); - if(TRACE_ON(mshtml)) { - LPCWSTR url; - - nsIWineURI_GetWineURL(This->uri, &url); - TRACE("opening %s\n", debugstr_w(url)); - } - - nsIWineURI_GetIsDocumentURI(This->uri, &is_doc_uri); - if(is_doc_uri) { + if(This->uri->is_doc_uri) { window = get_channel_window(This); if(window) { - nsIWineURI_SetWindow(This->uri, window); - }else { - NSContainer *nscontainer; + set_uri_window(This->uri, window); + }else if(This->uri->container) { + BOOL b; - nsIWineURI_GetNSContainer(This->uri, &nscontainer); - if(nscontainer) { - BOOL b; + /* nscontainer->doc should be NULL which means navigation to a new window */ + if(This->uri->container->doc) + FIXME("nscontainer->doc = %p\n", This->uri->container->doc); - /* nscontainer->doc should be NULL which means navigation to a new window */ - if(nscontainer->doc) - FIXME("nscontainer->doc = %p\n", nscontainer->doc); - - b = before_async_open(This, nscontainer); - nsIWebBrowserChrome_Release(NSWBCHROME(nscontainer)); - if(b) - FIXME("Navigation not cancelled\n"); - return NS_ERROR_UNEXPECTED; - } + b = before_async_open(This, This->uri->container); + if(b) + FIXME("Navigation not cancelled\n"); + return NS_ERROR_UNEXPECTED; } } if(!window) { - nsIWineURI_GetWindow(This->uri, &window); - - if(!window && This->load_group) { + if(This->uri->window_ref && This->uri->window_ref->window) { + window = This->uri->window_ref->window; + IHTMLWindow2_AddRef(HTMLWINDOW2(window)); + }else if(This->load_group) { window = get_window_from_load_group(This); if(window) - nsIWineURI_SetWindow(This->uri, window); + set_uri_window(This->uri, window); } } @@ -773,13 +893,9 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen return NS_ERROR_UNEXPECTED; } - if(is_doc_uri && window == window->doc_obj->basedoc.window) { - nsChannelBSC *channel_bsc; - - nsIWineURI_GetChannelBSC(This->uri, &channel_bsc); - if(channel_bsc) { - channelbsc_set_channel(channel_bsc, This, aListener, aContext); - IUnknown_Release((IUnknown*)channel_bsc); + if(This->uri->is_doc_uri && window == window->doc_obj->basedoc.window) { + if(This->uri->channel_bsc) { + channelbsc_set_channel(This->uri->channel_bsc, This, aListener, aContext); if(window->doc_obj->mime) { heap_free(This->content_type); @@ -797,7 +913,7 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen } if(open) - nsres = async_open(This, window, is_doc_uri, aListener, aContext); + nsres = async_open(This, window, This->uri->is_doc_uri, aListener, aContext); IHTMLWindow2_Release(HTMLWINDOW2(window)); return nsres; @@ -1225,11 +1341,11 @@ static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl = { nsHttpChannelInternal_SetForceAllowThirdPartyCookie }; -#define NSURI_THIS(iface) DEFINE_THIS(nsURI, WineURI, iface) +#define NSURI_THIS(iface) DEFINE_THIS(nsWineURI, IURL, iface) -static nsresult NSAPI nsURI_QueryInterface(nsIWineURI *iface, nsIIDRef riid, nsQIResult result) +static nsresult NSAPI nsURI_QueryInterface(nsIURL *iface, nsIIDRef riid, nsQIResult result) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); *result = NULL; @@ -1241,10 +1357,10 @@ static nsresult NSAPI nsURI_QueryInterface(nsIWineURI *iface, nsIIDRef riid, nsQ *result = NSURI(This); }else if(IsEqualGUID(&IID_nsIURL, riid)) { TRACE("(%p)->(IID_nsIURL %p)\n", This, result); - *result = NSURI(This); - }else if(IsEqualGUID(&IID_nsIWineURI, riid)) { - TRACE("(%p)->(IID_nsIWineURI %p)\n", This, result); - *result = NSURI(This); + *result = NSURL(This); + }else if(IsEqualGUID(&IID_nsWineURI, riid)) { + TRACE("(%p)->(IID_nsWineURI %p)\n", This, result); + *result = This; } if(*result) { @@ -1256,9 +1372,9 @@ static nsresult NSAPI nsURI_QueryInterface(nsIWineURI *iface, nsIIDRef riid, nsQ return This->uri ? nsIURI_QueryInterface(This->uri, riid, result) : NS_NOINTERFACE; } -static nsrefcnt NSAPI nsURI_AddRef(nsIWineURI *iface) +static nsrefcnt NSAPI nsURI_AddRef(nsIURL *iface) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); LONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -1266,9 +1382,9 @@ static nsrefcnt NSAPI nsURI_AddRef(nsIWineURI *iface) return ref; } -static nsrefcnt NSAPI nsURI_Release(nsIWineURI *iface) +static nsrefcnt NSAPI nsURI_Release(nsIURL *iface) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); @@ -1289,9 +1405,9 @@ static nsrefcnt NSAPI nsURI_Release(nsIWineURI *iface) return ref; } -static nsresult NSAPI nsURI_GetSpec(nsIWineURI *iface, nsACString *aSpec) +static nsresult NSAPI nsURI_GetSpec(nsIURL *iface, nsACString *aSpec) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aSpec); @@ -1311,9 +1427,9 @@ static nsresult NSAPI nsURI_GetSpec(nsIWineURI *iface, nsACString *aSpec) } -static nsresult NSAPI nsURI_SetSpec(nsIWineURI *iface, const nsACString *aSpec) +static nsresult NSAPI nsURI_SetSpec(nsIURL *iface, const nsACString *aSpec) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aSpec); @@ -1324,9 +1440,9 @@ static nsresult NSAPI nsURI_SetSpec(nsIWineURI *iface, const nsACString *aSpec) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetPrePath(nsIWineURI *iface, nsACString *aPrePath) +static nsresult NSAPI nsURI_GetPrePath(nsIURL *iface, nsACString *aPrePath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPrePath); @@ -1337,9 +1453,9 @@ static nsresult NSAPI nsURI_GetPrePath(nsIWineURI *iface, nsACString *aPrePath) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetScheme(nsIWineURI *iface, nsACString *aScheme) +static nsresult NSAPI nsURI_GetScheme(nsIURL *iface, nsACString *aScheme) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aScheme); @@ -1359,9 +1475,9 @@ static nsresult NSAPI nsURI_GetScheme(nsIWineURI *iface, nsACString *aScheme) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetScheme(nsIWineURI *iface, const nsACString *aScheme) +static nsresult NSAPI nsURI_SetScheme(nsIURL *iface, const nsACString *aScheme) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aScheme); @@ -1372,9 +1488,9 @@ static nsresult NSAPI nsURI_SetScheme(nsIWineURI *iface, const nsACString *aSche return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetUserPass(nsIWineURI *iface, nsACString *aUserPass) +static nsresult NSAPI nsURI_GetUserPass(nsIURL *iface, nsACString *aUserPass) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aUserPass); @@ -1385,9 +1501,9 @@ static nsresult NSAPI nsURI_GetUserPass(nsIWineURI *iface, nsACString *aUserPass return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetUserPass(nsIWineURI *iface, const nsACString *aUserPass) +static nsresult NSAPI nsURI_SetUserPass(nsIURL *iface, const nsACString *aUserPass) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aUserPass); @@ -1398,9 +1514,9 @@ static nsresult NSAPI nsURI_SetUserPass(nsIWineURI *iface, const nsACString *aUs return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetUsername(nsIWineURI *iface, nsACString *aUsername) +static nsresult NSAPI nsURI_GetUsername(nsIURL *iface, nsACString *aUsername) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aUsername); @@ -1411,9 +1527,9 @@ static nsresult NSAPI nsURI_GetUsername(nsIWineURI *iface, nsACString *aUsername return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetUsername(nsIWineURI *iface, const nsACString *aUsername) +static nsresult NSAPI nsURI_SetUsername(nsIURL *iface, const nsACString *aUsername) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aUsername); @@ -1424,9 +1540,9 @@ static nsresult NSAPI nsURI_SetUsername(nsIWineURI *iface, const nsACString *aUs return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetPassword(nsIWineURI *iface, nsACString *aPassword) +static nsresult NSAPI nsURI_GetPassword(nsIURL *iface, nsACString *aPassword) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPassword); @@ -1437,9 +1553,9 @@ static nsresult NSAPI nsURI_GetPassword(nsIWineURI *iface, nsACString *aPassword return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetPassword(nsIWineURI *iface, const nsACString *aPassword) +static nsresult NSAPI nsURI_SetPassword(nsIURL *iface, const nsACString *aPassword) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPassword); @@ -1450,9 +1566,9 @@ static nsresult NSAPI nsURI_SetPassword(nsIWineURI *iface, const nsACString *aPa return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetHostPort(nsIWineURI *iface, nsACString *aHostPort) +static nsresult NSAPI nsURI_GetHostPort(nsIURL *iface, nsACString *aHostPort) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aHostPort); @@ -1463,9 +1579,9 @@ static nsresult NSAPI nsURI_GetHostPort(nsIWineURI *iface, nsACString *aHostPort return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetHostPort(nsIWineURI *iface, const nsACString *aHostPort) +static nsresult NSAPI nsURI_SetHostPort(nsIURL *iface, const nsACString *aHostPort) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aHostPort); @@ -1476,9 +1592,9 @@ static nsresult NSAPI nsURI_SetHostPort(nsIWineURI *iface, const nsACString *aHo return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetHost(nsIWineURI *iface, nsACString *aHost) +static nsresult NSAPI nsURI_GetHost(nsIURL *iface, nsACString *aHost) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aHost); @@ -1489,9 +1605,9 @@ static nsresult NSAPI nsURI_GetHost(nsIWineURI *iface, nsACString *aHost) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetHost(nsIWineURI *iface, const nsACString *aHost) +static nsresult NSAPI nsURI_SetHost(nsIURL *iface, const nsACString *aHost) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aHost); @@ -1502,9 +1618,9 @@ static nsresult NSAPI nsURI_SetHost(nsIWineURI *iface, const nsACString *aHost) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetPort(nsIWineURI *iface, PRInt32 *aPort) +static nsresult NSAPI nsURI_GetPort(nsIURL *iface, PRInt32 *aPort) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPort); @@ -1515,9 +1631,9 @@ static nsresult NSAPI nsURI_GetPort(nsIWineURI *iface, PRInt32 *aPort) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetPort(nsIWineURI *iface, PRInt32 aPort) +static nsresult NSAPI nsURI_SetPort(nsIURL *iface, PRInt32 aPort) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%d)\n", This, aPort); @@ -1528,9 +1644,9 @@ static nsresult NSAPI nsURI_SetPort(nsIWineURI *iface, PRInt32 aPort) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetPath(nsIWineURI *iface, nsACString *aPath) +static nsresult NSAPI nsURI_GetPath(nsIURL *iface, nsACString *aPath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aPath); @@ -1541,9 +1657,9 @@ static nsresult NSAPI nsURI_GetPath(nsIWineURI *iface, nsACString *aPath) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_SetPath(nsIWineURI *iface, const nsACString *aPath) +static nsresult NSAPI nsURI_SetPath(nsIURL *iface, const nsACString *aPath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); const char *path; nsACString_GetData(aPath, &path); @@ -1560,7 +1676,7 @@ static nsresult NSAPI nsURI_SetPath(nsIWineURI *iface, const nsACString *aPath) hres = UrlCombineW(This->wine_url, pathw, new_url, &size, 0); heap_free(pathw); if(SUCCEEDED(hres)) - nsIWineURI_SetWineURL(NSWINEURI(This), new_url); + set_wine_url(This, new_url); else WARN("UrlCombine failed: %08x\n", hres); } @@ -1571,11 +1687,10 @@ static nsresult NSAPI nsURI_SetPath(nsIWineURI *iface, const nsACString *aPath) return nsIURI_SetPath(This->uri, aPath); } -static nsresult NSAPI nsURI_Equals(nsIWineURI *iface, nsIURI *other, PRBool *_retval) +static nsresult NSAPI nsURI_Equals(nsIURL *iface, nsIURI *other, PRBool *_retval) { - nsURI *This = NSURI_THIS(iface); - nsIWineURI *wine_uri; - LPCWSTR other_url = NULL; + nsWineURI *This = NSURI_THIS(iface); + nsWineURI *wine_uri; nsresult nsres; TRACE("(%p)->(%p %p)\n", This, other, _retval); @@ -1583,23 +1698,22 @@ static nsresult NSAPI nsURI_Equals(nsIWineURI *iface, nsIURI *other, PRBool *_re if(This->uri) return nsIURI_Equals(This->uri, other, _retval); - nsres = nsIURI_QueryInterface(other, &IID_nsIWineURI, (void**)&wine_uri); + nsres = nsIURI_QueryInterface(other, &IID_nsWineURI, (void**)&wine_uri); if(NS_FAILED(nsres)) { - TRACE("Could not get nsIWineURI interface\n"); + TRACE("Could not get nsWineURI interface\n"); *_retval = FALSE; return NS_OK; } - nsIWineURI_GetWineURL(wine_uri, &other_url); - *_retval = other_url && !UrlCompareW(This->wine_url, other_url, TRUE); - nsIWineURI_Release(wine_uri); + *_retval = wine_uri->wine_url && !UrlCompareW(This->wine_url, wine_uri->wine_url, TRUE); + nsIURI_Release(NSURI(wine_uri)); return NS_OK; } -static nsresult NSAPI nsURI_SchemeIs(nsIWineURI *iface, const char *scheme, PRBool *_retval) +static nsresult NSAPI nsURI_SchemeIs(nsIURL *iface, const char *scheme, PRBool *_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s %p)\n", This, debugstr_a(scheme), _retval); @@ -1620,11 +1734,11 @@ static nsresult NSAPI nsURI_SchemeIs(nsIWineURI *iface, const char *scheme, PRBo return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_Clone(nsIWineURI *iface, nsIURI **_retval) +static nsresult NSAPI nsURI_Clone(nsIURL *iface, nsIURI **_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); nsIURI *nsuri = NULL; - nsIWineURI *wine_uri; + nsWineURI *wine_uri; nsresult nsres; TRACE("(%p)->(%p)\n", This, _retval); @@ -1643,14 +1757,16 @@ static nsresult NSAPI nsURI_Clone(nsIWineURI *iface, nsIURI **_retval) return nsres; } - *_retval = (nsIURI*)wine_uri; - return nsIWineURI_SetWineURL(wine_uri, This->wine_url); + set_wine_url(wine_uri, This->wine_url); + + *_retval = NSURI(wine_uri); + return NS_OK; } -static nsresult NSAPI nsURI_Resolve(nsIWineURI *iface, const nsACString *arelativePath, +static nsresult NSAPI nsURI_Resolve(nsIURL *iface, const nsACString *arelativePath, nsACString *_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p %p)\n", This, arelativePath, _retval); @@ -1661,9 +1777,9 @@ static nsresult NSAPI nsURI_Resolve(nsIWineURI *iface, const nsACString *arelati return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetAsciiSpec(nsIWineURI *iface, nsACString *aAsciiSpec) +static nsresult NSAPI nsURI_GetAsciiSpec(nsIURL *iface, nsACString *aAsciiSpec) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aAsciiSpec); @@ -1677,9 +1793,9 @@ static nsresult NSAPI nsURI_GetAsciiSpec(nsIWineURI *iface, nsACString *aAsciiSp return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetAsciiHost(nsIWineURI *iface, nsACString *aAsciiHost) +static nsresult NSAPI nsURI_GetAsciiHost(nsIURL *iface, nsACString *aAsciiHost) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aAsciiHost); @@ -1690,9 +1806,9 @@ static nsresult NSAPI nsURI_GetAsciiHost(nsIWineURI *iface, nsACString *aAsciiHo return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetOriginCharset(nsIWineURI *iface, nsACString *aOriginCharset) +static nsresult NSAPI nsURI_GetOriginCharset(nsIURL *iface, nsACString *aOriginCharset) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aOriginCharset); @@ -1703,9 +1819,9 @@ static nsresult NSAPI nsURI_GetOriginCharset(nsIWineURI *iface, nsACString *aOri return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetFilePath(nsIWineURI *iface, nsACString *aFilePath) +static nsresult NSAPI nsURL_GetFilePath(nsIURL *iface, nsACString *aFilePath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aFilePath); @@ -1716,9 +1832,9 @@ static nsresult NSAPI nsURL_GetFilePath(nsIWineURI *iface, nsACString *aFilePath return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetFilePath(nsIWineURI *iface, const nsACString *aFilePath) +static nsresult NSAPI nsURL_SetFilePath(nsIURL *iface, const nsACString *aFilePath) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFilePath)); @@ -1729,9 +1845,9 @@ static nsresult NSAPI nsURL_SetFilePath(nsIWineURI *iface, const nsACString *aFi return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetParam(nsIWineURI *iface, nsACString *aParam) +static nsresult NSAPI nsURL_GetParam(nsIURL *iface, nsACString *aParam) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aParam); @@ -1742,9 +1858,9 @@ static nsresult NSAPI nsURL_GetParam(nsIWineURI *iface, nsACString *aParam) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetParam(nsIWineURI *iface, const nsACString *aParam) +static nsresult NSAPI nsURL_SetParam(nsIURL *iface, const nsACString *aParam) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aParam)); @@ -1755,9 +1871,9 @@ static nsresult NSAPI nsURL_SetParam(nsIWineURI *iface, const nsACString *aParam return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetQuery(nsIWineURI *iface, nsACString *aQuery) +static nsresult NSAPI nsURL_GetQuery(nsIURL *iface, nsACString *aQuery) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aQuery); @@ -1768,9 +1884,9 @@ static nsresult NSAPI nsURL_GetQuery(nsIWineURI *iface, nsACString *aQuery) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetQuery(nsIWineURI *iface, const nsACString *aQuery) +static nsresult NSAPI nsURL_SetQuery(nsIURL *iface, const nsACString *aQuery) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); const WCHAR *ptr1, *ptr2; const char *query; WCHAR *new_url, *ptr; @@ -1821,9 +1937,9 @@ static nsresult NSAPI nsURL_SetQuery(nsIWineURI *iface, const nsACString *aQuery return NS_OK; } -static nsresult NSAPI nsURL_GetRef(nsIWineURI *iface, nsACString *aRef) +static nsresult NSAPI nsURL_GetRef(nsIURL *iface, nsACString *aRef) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aRef); @@ -1834,9 +1950,9 @@ static nsresult NSAPI nsURL_GetRef(nsIWineURI *iface, nsACString *aRef) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetRef(nsIWineURI *iface, const nsACString *aRef) +static nsresult NSAPI nsURL_SetRef(nsIURL *iface, const nsACString *aRef) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); const char *refa; TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aRef)); @@ -1852,9 +1968,9 @@ static nsresult NSAPI nsURL_SetRef(nsIWineURI *iface, const nsACString *aRef) return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetDirectory(nsIWineURI *iface, nsACString *aDirectory) +static nsresult NSAPI nsURL_GetDirectory(nsIURL *iface, nsACString *aDirectory) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aDirectory); @@ -1865,9 +1981,9 @@ static nsresult NSAPI nsURL_GetDirectory(nsIWineURI *iface, nsACString *aDirecto return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetDirectory(nsIWineURI *iface, const nsACString *aDirectory) +static nsresult NSAPI nsURL_SetDirectory(nsIURL *iface, const nsACString *aDirectory) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aDirectory)); @@ -1878,9 +1994,9 @@ static nsresult NSAPI nsURL_SetDirectory(nsIWineURI *iface, const nsACString *aD return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetFileName(nsIWineURI *iface, nsACString *aFileName) +static nsresult NSAPI nsURL_GetFileName(nsIURL *iface, nsACString *aFileName) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aFileName); @@ -1891,9 +2007,9 @@ static nsresult NSAPI nsURL_GetFileName(nsIWineURI *iface, nsACString *aFileName return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetFileName(nsIWineURI *iface, const nsACString *aFileName) +static nsresult NSAPI nsURL_SetFileName(nsIURL *iface, const nsACString *aFileName) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileName)); @@ -1904,9 +2020,9 @@ static nsresult NSAPI nsURL_SetFileName(nsIWineURI *iface, const nsACString *aFi return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetFileBaseName(nsIWineURI *iface, nsACString *aFileBaseName) +static nsresult NSAPI nsURL_GetFileBaseName(nsIURL *iface, nsACString *aFileBaseName) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aFileBaseName); @@ -1917,9 +2033,9 @@ static nsresult NSAPI nsURL_GetFileBaseName(nsIWineURI *iface, nsACString *aFile return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetFileBaseName(nsIWineURI *iface, const nsACString *aFileBaseName) +static nsresult NSAPI nsURL_SetFileBaseName(nsIURL *iface, const nsACString *aFileBaseName) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileBaseName)); @@ -1930,9 +2046,9 @@ static nsresult NSAPI nsURL_SetFileBaseName(nsIWineURI *iface, const nsACString return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetFileExtension(nsIWineURI *iface, nsACString *aFileExtension) +static nsresult NSAPI nsURL_GetFileExtension(nsIURL *iface, nsACString *aFileExtension) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p)\n", This, aFileExtension); @@ -1943,9 +2059,9 @@ static nsresult NSAPI nsURL_GetFileExtension(nsIWineURI *iface, nsACString *aFil return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_SetFileExtension(nsIWineURI *iface, const nsACString *aFileExtension) +static nsresult NSAPI nsURL_SetFileExtension(nsIURL *iface, const nsACString *aFileExtension) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileExtension)); @@ -1956,9 +2072,9 @@ static nsresult NSAPI nsURL_SetFileExtension(nsIWineURI *iface, const nsACString return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIWineURI *iface, nsIURI *aURIToCompare, nsACString *_retval) +static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIURL *iface, nsIURI *aURIToCompare, nsACString *_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p %p)\n", This, aURIToCompare, _retval); @@ -1969,9 +2085,9 @@ static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIWineURI *iface, nsIURI *aURIToC return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURL_GetRelativeSpec(nsIWineURI *iface, nsIURI *aURIToCompare, nsACString *_retval) +static nsresult NSAPI nsURL_GetRelativeSpec(nsIURL *iface, nsIURI *aURIToCompare, nsACString *_retval) { - nsURI *This = NSURI_THIS(iface); + nsWineURI *This = NSURI_THIS(iface); TRACE("(%p)->(%p %p)\n", This, aURIToCompare, _retval); @@ -1982,174 +2098,9 @@ static nsresult NSAPI nsURL_GetRelativeSpec(nsIWineURI *iface, nsIURI *aURIToCom return NS_ERROR_NOT_IMPLEMENTED; } -static nsresult NSAPI nsURI_GetNSContainer(nsIWineURI *iface, NSContainer **aContainer) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aContainer); - - if(This->container) - nsIWebBrowserChrome_AddRef(NSWBCHROME(This->container)); - *aContainer = This->container; - - return NS_OK; -} - -static nsresult NSAPI nsURI_SetNSContainer(nsIWineURI *iface, NSContainer *aContainer) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aContainer); - - if(This->container) { - if(This->container == aContainer) - return NS_OK; - TRACE("Changing %p -> %p\n", This->container, aContainer); - nsIWebBrowserChrome_Release(NSWBCHROME(This->container)); - } - - if(aContainer) - nsIWebBrowserChrome_AddRef(NSWBCHROME(aContainer)); - This->container = aContainer; - - return NS_OK; -} - -static nsresult NSAPI nsURI_GetWindow(nsIWineURI *iface, HTMLWindow **aHTMLWindow) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aHTMLWindow); - - if(This->window_ref && This->window_ref->window) { - IHTMLWindow2_AddRef(HTMLWINDOW2(This->window_ref->window)); - *aHTMLWindow = This->window_ref->window; - }else { - *aHTMLWindow = NULL; - } - - return NS_OK; -} - -static nsresult NSAPI nsURI_SetWindow(nsIWineURI *iface, HTMLWindow *aHTMLWindow) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aHTMLWindow); - - if(This->window_ref) { - if(This->window_ref->window == aHTMLWindow) - return NS_OK; - TRACE("Changing %p -> %p\n", This->window_ref->window, aHTMLWindow); - windowref_release(This->window_ref); - } - - if(aHTMLWindow) { - windowref_addref(aHTMLWindow->window_ref); - This->window_ref = aHTMLWindow->window_ref; - - if(aHTMLWindow->doc_obj) - nsIWineURI_SetNSContainer(NSWINEURI(This), aHTMLWindow->doc_obj->nscontainer); - }else { - This->window_ref = NULL; - } - - return NS_OK; -} - -static nsresult NSAPI nsURI_GetChannelBSC(nsIWineURI *iface, nsChannelBSC **aChannelBSC) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aChannelBSC); - - if(This->channel_bsc) - IUnknown_AddRef((IUnknown*)This->channel_bsc); - *aChannelBSC = This->channel_bsc; - return NS_OK; -} - -static nsresult NSAPI nsURI_SetChannelBSC(nsIWineURI *iface, nsChannelBSC *aChannelBSC) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aChannelBSC); - - if(This->channel_bsc) - IUnknown_Release((IUnknown*)This->channel_bsc); - if(aChannelBSC) - IUnknown_AddRef((IUnknown*)aChannelBSC); - This->channel_bsc = aChannelBSC; - return NS_OK; -} - -static nsresult NSAPI nsURI_GetIsDocumentURI(nsIWineURI *iface, PRBool *aIsDocumentURI) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aIsDocumentURI); - - *aIsDocumentURI = This->is_doc_uri; - return NS_OK; -} - -static nsresult NSAPI nsURI_SetIsDocumentURI(nsIWineURI *iface, PRBool aIsDocumentURI) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%x)\n", This, aIsDocumentURI); - - This->is_doc_uri = aIsDocumentURI; - return NS_OK; -} - -static nsresult NSAPI nsURI_GetWineURL(nsIWineURI *iface, LPCWSTR *aURL) -{ - nsURI *This = NSURI_THIS(iface); - - TRACE("(%p)->(%p)\n", This, aURL); - - *aURL = This->wine_url; - return NS_OK; -} - -static nsresult NSAPI nsURI_SetWineURL(nsIWineURI *iface, LPCWSTR aURL) -{ - nsURI *This = NSURI_THIS(iface); - - static const WCHAR wszFtp[] = {'f','t','p',':'}; - static const WCHAR wszHttp[] = {'h','t','t','p',':'}; - static const WCHAR wszHttps[] = {'h','t','t','p','s',':'}; - - TRACE("(%p)->(%s)\n", This, debugstr_w(aURL)); - - heap_free(This->wine_url); - - if(aURL) { - int len = strlenW(aURL)+1; - This->wine_url = heap_alloc(len*sizeof(WCHAR)); - memcpy(This->wine_url, aURL, len*sizeof(WCHAR)); - - if(This->uri) { - /* FIXME: Always use wine url */ - This->use_wine_url = - strncmpW(aURL, wszFtp, sizeof(wszFtp)/sizeof(WCHAR)) - && strncmpW(aURL, wszHttp, sizeof(wszHttp)/sizeof(WCHAR)) - && strncmpW(aURL, wszHttps, sizeof(wszHttps)/sizeof(WCHAR)); - }else { - This->use_wine_url = TRUE; - } - }else { - This->wine_url = NULL; - This->use_wine_url = FALSE; - } - - return NS_OK; -} - #undef NSURI_THIS -static const nsIWineURIVtbl nsWineURIVtbl = { +static const nsIURLVtbl nsURLVtbl = { nsURI_QueryInterface, nsURI_AddRef, nsURI_Release, @@ -2196,51 +2147,39 @@ static const nsIWineURIVtbl nsWineURIVtbl = { nsURL_GetFileExtension, nsURL_SetFileExtension, nsURL_GetCommonBaseSpec, - nsURL_GetRelativeSpec, - nsURI_GetNSContainer, - nsURI_SetNSContainer, - nsURI_GetWindow, - nsURI_SetWindow, - nsURI_GetChannelBSC, - nsURI_SetChannelBSC, - nsURI_GetIsDocumentURI, - nsURI_SetIsDocumentURI, - nsURI_GetWineURL, - nsURI_SetWineURL + nsURL_GetRelativeSpec }; -static nsresult create_uri(nsIURI *uri, HTMLWindow *window, NSContainer *container, nsIWineURI **_retval) +static nsresult create_uri(nsIURI *uri, HTMLWindow *window, NSContainer *container, nsWineURI **_retval) { - nsURI *ret = heap_alloc_zero(sizeof(nsURI)); + nsWineURI *ret = heap_alloc_zero(sizeof(nsWineURI)); - ret->lpWineURIVtbl = &nsWineURIVtbl; + ret->lpIURLVtbl = &nsURLVtbl; ret->ref = 1; ret->uri = uri; - nsIWineURI_SetNSContainer(NSWINEURI(ret), container); - nsIWineURI_SetWindow(NSWINEURI(ret), window); + set_uri_nscontainer(ret, container); + set_uri_window(ret, window); if(uri) nsIURI_QueryInterface(uri, &IID_nsIURL, (void**)&ret->nsurl); - else - ret->nsurl = NULL; TRACE("retval=%p\n", ret); - *_retval = NSWINEURI(ret); + *_retval = ret; return NS_OK; } -HRESULT create_doc_uri(HTMLWindow *window, WCHAR *url, nsIWineURI **ret) +HRESULT create_doc_uri(HTMLWindow *window, WCHAR *url, nsWineURI **ret) { - nsIWineURI *uri; + nsWineURI *uri; nsresult nsres; nsres = create_uri(NULL, window, window->doc_obj->nscontainer, &uri); if(NS_FAILED(nsres)) return E_FAIL; - nsIWineURI_SetWineURL(uri, url); - nsIWineURI_SetIsDocumentURI(uri, TRUE); + set_wine_url(uri, url); + uri->is_doc_uri = TRUE; *ret = uri; return S_OK; @@ -2470,11 +2409,11 @@ static BOOL is_gecko_special_uri(const char *spec) static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString *aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) { + nsWineURI *wine_uri, *base_wine_uri = NULL; const char *spec = NULL; HTMLWindow *window = NULL; nsIURI *uri = NULL; LPCWSTR base_wine_url = NULL; - nsIWineURI *base_wine_uri = NULL, *wine_uri; BOOL is_wine_uri = FALSE; nsresult nsres; @@ -2494,16 +2433,19 @@ static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString * if(aBaseURI) { PARSEDURLA parsed_url = {sizeof(PARSEDURLA)}; - nsres = nsIURI_QueryInterface(aBaseURI, &IID_nsIWineURI, (void**)&base_wine_uri); + nsres = nsIURI_QueryInterface(aBaseURI, &IID_nsWineURI, (void**)&base_wine_uri); if(NS_SUCCEEDED(nsres)) { - nsIWineURI_GetWineURL(base_wine_uri, &base_wine_url); - nsIWineURI_GetWindow(base_wine_uri, &window); + base_wine_url = base_wine_uri->wine_url; + if(base_wine_uri->window_ref && base_wine_uri->window_ref->window) { + window = base_wine_uri->window_ref->window; + IHTMLWindow2_AddRef(HTMLWINDOW2(window)); + } TRACE("base url: %s window: %p\n", debugstr_w(base_wine_url), window); }else if(FAILED(ParseURLA(spec, &parsed_url))) { TRACE("not wraping\n"); return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval); }else { - WARN("Could not get base nsIWineURI: %08x\n", nsres); + WARN("Could not get base nsWineURI: %08x\n", nsres); } } @@ -2528,18 +2470,18 @@ static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString * URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, url, sizeof(url)/sizeof(WCHAR), &len, 0); if(SUCCEEDED(hres)) - nsIWineURI_SetWineURL(wine_uri, url); + set_wine_url(wine_uri, url); else WARN("CoCombineUrl failed: %08x\n", hres); }else if(is_wine_uri) { WCHAR url[INTERNET_MAX_URL_LENGTH]; MultiByteToWideChar(CP_ACP, 0, spec, -1, url, sizeof(url)/sizeof(WCHAR)); - nsIWineURI_SetWineURL(wine_uri, url); + set_wine_url(wine_uri, url); } if(base_wine_uri) - nsIWineURI_Release(base_wine_uri); + nsIURI_Release(NSURI(base_wine_uri)); return nsres; } @@ -2556,15 +2498,14 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI { PARSEDURLW parsed_url = {sizeof(PARSEDURLW)}; nsChannel *ret; - nsIWineURI *wine_uri; - const WCHAR *url; + nsWineURI *wine_uri; nsresult nsres; TRACE("(%p %p)\n", aURI, _retval); - nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri); + nsres = nsIURI_QueryInterface(aURI, &IID_nsWineURI, (void**)&wine_uri); if(NS_FAILED(nsres)) { - TRACE("Could not get nsIWineURI: %08x\n", nsres); + TRACE("Could not get nsWineURI: %08x\n", nsres); return nsIIOService_NewChannelFromURI(nsio, aURI, _retval); } @@ -2578,9 +2519,8 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI nsIURI_AddRef(aURI); ret->original_uri = aURI; - - nsIWineURI_GetWineURL(wine_uri, &url); - ret->url_scheme = url && SUCCEEDED(ParseURLW(url, &parsed_url)) ? parsed_url.nScheme : URL_SCHEME_UNKNOWN; + ret->url_scheme = wine_uri->wine_url && SUCCEEDED(ParseURLW(wine_uri->wine_url, &parsed_url)) + ? parsed_url.nScheme : URL_SCHEME_UNKNOWN; *_retval = NSCHANNEL(ret); return NS_OK; diff --git a/dll/win32/mshtml/oleobj.c b/dll/win32/mshtml/oleobj.c index 3dec3dc62dd..a33f4793ed8 100644 --- a/dll/win32/mshtml/oleobj.c +++ b/dll/win32/mshtml/oleobj.c @@ -34,9 +34,13 @@ #include "wine/debug.h" #include "mshtml_private.h" +#include "initguid.h" WINE_DEFAULT_DEBUG_CHANNEL(mshtml); +DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0); +#define DOCHOST_DOCCANNAVIGATE 0 + /********************************************************** * IOleObject implementation */ @@ -92,6 +96,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite HTMLDocument *This = OLEOBJ_THIS(iface); IDocHostUIHandler *pDocHostUIHandler = NULL; IOleCommandTarget *cmdtrg = NULL; + BOOL hostui_setup; VARIANT silent; HRESULT hres; @@ -116,6 +121,8 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite if(!pClientSite) return S_OK; + hostui_setup = This->doc_obj->hostui_setup; + hres = IOleObject_QueryInterface(pClientSite, &IID_IDocHostUIHandler, (void**)&pDocHostUIHandler); if(SUCCEEDED(hres)) { DOCHOSTUIINFO hostinfo; @@ -133,7 +140,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite This->doc_obj->hostinfo = hostinfo; } - if(!This->doc_obj->has_key_path) { + if(!hostui_setup) { hres = IDocHostUIHandler_GetOptionKeyPath(pDocHostUIHandler, &key_path, 0); if(hres == S_OK && key_path) { if(key_path[0]) { @@ -157,7 +164,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite IDocHostUIHandler2_Release(pDocHostUIHandler2); } - This->doc_obj->has_key_path = TRUE; + This->doc_obj->hostui_setup = TRUE; } } @@ -179,6 +186,12 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite VARIANT var; OLECMD cmd = {OLECMDID_SETPROGRESSTEXT, 0}; + if(!hostui_setup) { + V_VT(&var) = VT_UNKNOWN; + V_UNKNOWN(&var) = (IUnknown*)HTMLWINDOW2(This->window); + IOleCommandTarget_Exec(cmdtrg, &CGID_DocHostCmdPriv, DOCHOST_DOCCANNAVIGATE, 0, &var, NULL); + } + IOleCommandTarget_QueryStatus(cmdtrg, NULL, 1, &cmd, NULL); V_VT(&var) = VT_I4; diff --git a/dll/win32/mshtml/persist.c b/dll/win32/mshtml/persist.c index d3014b8d330..720a58edbf8 100644 --- a/dll/win32/mshtml/persist.c +++ b/dll/win32/mshtml/persist.c @@ -155,6 +155,9 @@ static void set_downloading_proc(task_t *_task) doc->download_state = 1; } + if(doc->view_sink) + IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1); + if(doc->hostui) { IDropTarget *drop_target = NULL; @@ -166,50 +169,15 @@ static void set_downloading_proc(task_t *_task) } } -static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BOOL set_download) +HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download) { nsChannelBSC *bscallback; - LPOLESTR url = NULL; docobj_task_t *task; download_proc_task_t *download_task; - nsIWineURI *nsuri; + nsWineURI *nsuri; + LPOLESTR url; HRESULT hres; - if(pibc) { - IUnknown *unk = NULL; - - /* FIXME: - * Use params: - * "__PrecreatedObject" - * "BIND_CONTEXT_PARAM" - * "__HTMLLOADOPTIONS" - * "__DWNBINDINFO" - * "URL Context" - * "CBinding Context" - * "_ITransData_Object_" - * "_EnumFORMATETC_" - */ - - IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk); - if(unk) { - IOleClientSite *client = NULL; - - hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client); - if(SUCCEEDED(hres)) { - TRACE("Got client site %p\n", client); - IOleObject_SetClientSite(OLEOBJ(This), client); - IOleClientSite_Release(client); - } - - IUnknown_Release(unk); - } - } - - set_ready_state(This->window, READYSTATE_LOADING); - update_doc(This, UPDATE_TITLE); - - HTMLDocument_LockContainer(This->doc_obj, TRUE); - hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url); if(FAILED(hres)) { WARN("GetDiaplayName failed: %08x\n", hres); @@ -218,11 +186,8 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO TRACE("got url: %s\n", debugstr_w(url)); - set_current_mon(This->window, mon); - if(This->doc_obj->client) { VARIANT silent, offline; - IOleCommandTarget *cmdtrg = NULL; hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent); if(SUCCEEDED(hres)) { @@ -240,15 +205,37 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO else if(V_BOOL(&silent)) FIXME("offline == true\n"); } + } + + if(This->window->mon) { + update_doc(This, UPDATE_TITLE|UPDATE_UI); + }else { + update_doc(This, UPDATE_TITLE); + set_current_mon(This->window, mon); + } + + set_ready_state(This->window, READYSTATE_LOADING); + + if(This->doc_obj->client) { + IOleCommandTarget *cmdtrg = NULL; hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget, (void**)&cmdtrg); if(SUCCEEDED(hres)) { - VARIANT var; + VARIANT var, out; - V_VT(&var) = VT_I4; - V_I4(&var) = 0; - IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL); + if(!async_bsc) { + V_VT(&var) = VT_I4; + V_I4(&var) = 0; + IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL); + }else { + V_VT(&var) = VT_UNKNOWN; + V_UNKNOWN(&var) = (IUnknown*)HTMLWINDOW2(This->window); + V_VT(&out) = VT_EMPTY; + hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 63, 0, &var, &out); + if(SUCCEEDED(hres)) + VariantClear(&out); + } IOleCommandTarget_Release(cmdtrg); } @@ -259,17 +246,25 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO if(FAILED(hres)) return hres; - bscallback = create_channelbsc(mon); + if(async_bsc) { + bscallback = async_bsc; + }else { + hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback); + if(FAILED(hres)) + return hres; + } - nsIWineURI_SetChannelBSC(nsuri, bscallback); - hres = load_nsuri(This->window, nsuri, LOAD_INITIAL_DOCUMENT_URI); - nsIWineURI_SetChannelBSC(nsuri, NULL); + hres = load_nsuri(This->window, nsuri, bscallback, LOAD_INITIAL_DOCUMENT_URI); + nsISupports_Release((nsISupports*)nsuri); /* FIXME */ if(SUCCEEDED(hres)) set_window_bscallback(This->window, bscallback); - IUnknown_Release((IUnknown*)bscallback); + if(bscallback != async_bsc) + IUnknown_Release((IUnknown*)bscallback); if(FAILED(hres)) return hres; + HTMLDocument_LockContainer(This->doc_obj, TRUE); + if(This->doc_obj->frame) { task = heap_alloc(sizeof(docobj_task_t)); task->doc = This->doc_obj; @@ -375,7 +370,36 @@ static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAva TRACE("(%p)->(%x %p %p %08x)\n", This, fFullyAvailable, pimkName, pibc, grfMode); - hres = set_moniker(This, pimkName, pibc, TRUE); + if(pibc) { + IUnknown *unk = NULL; + + /* FIXME: + * Use params: + * "__PrecreatedObject" + * "BIND_CONTEXT_PARAM" + * "__HTMLLOADOPTIONS" + * "__DWNBINDINFO" + * "URL Context" + * "_ITransData_Object_" + * "_EnumFORMATETC_" + */ + + IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk); + if(unk) { + IOleClientSite *client = NULL; + + hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client); + if(SUCCEEDED(hres)) { + TRACE("Got client site %p\n", client); + IOleObject_SetClientSite(OLEOBJ(This), client); + IOleClientSite_Release(client); + } + + IUnknown_Release(unk); + } + } + + hres = set_moniker(This, pimkName, pibc, NULL, TRUE); if(FAILED(hres)) return hres; @@ -636,7 +660,7 @@ static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM return hres; } - hres = set_moniker(This, mon, NULL, TRUE); + hres = set_moniker(This, mon, NULL, NULL, TRUE); IMoniker_Release(mon); if(FAILED(hres)) return hres; @@ -682,44 +706,24 @@ static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface) { HTMLDocument *This = PERSTRINIT_THIS(iface); IMoniker *mon; - HGLOBAL body; - LPSTREAM stream; HRESULT hres; static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; - static const WCHAR html_bodyW[] = {'<','H','T','M','L','>','<','/','H','T','M','L','>',0}; TRACE("(%p)\n", This); - body = GlobalAlloc(0, sizeof(html_bodyW)); - if(!body) - return E_OUTOFMEMORY; - memcpy(body, html_bodyW, sizeof(html_bodyW)); - hres = CreateURLMoniker(NULL, about_blankW, &mon); if(FAILED(hres)) { WARN("CreateURLMoniker failed: %08x\n", hres); - GlobalFree(body); return hres; } - hres = set_moniker(This, mon, NULL, FALSE); + hres = set_moniker(This, mon, NULL, NULL, FALSE); IMoniker_Release(mon); - if(FAILED(hres)) { - GlobalFree(body); + if(FAILED(hres)) return hres; - } - hres = CreateStreamOnHGlobal(body, TRUE, &stream); - if(FAILED(hres)) { - GlobalFree(body); - return hres; - } - - hres = channelbsc_load_stream(This->window->bscallback, stream); - - IStream_Release(stream); - return hres; + return start_binding(This->window, NULL, (BSCallback*)This->window->bscallback, NULL); } #undef PERSTRINIT_THIS diff --git a/dll/win32/mshtml/rsrc.rc b/dll/win32/mshtml/rsrc.rc index 5e669de70ef..40cc041225c 100644 --- a/dll/win32/mshtml/rsrc.rc +++ b/dll/win32/mshtml/rsrc.rc @@ -16,6 +16,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "windef.h" +#include "winuser.h" +#include "commctrl.h" +#include "mshtmcid.h" + +#include "resource.h" + #define WINE_OLESELFREGISTER #define WINE_FILEDESCRIPTION_STR "Wine HTML Viewer" #define WINE_FILENAME_STR "mshtml.dll" @@ -26,6 +33,35 @@ #include "wine/wine_common_ver.rc" +#include "Bg.rc" +#include "Da.rc" +#include "En.rc" +#include "Es.rc" +#include "Fi.rc" +#include "Hu.rc" +#include "Ko.rc" +#include "Nl.rc" +#include "Pl.rc" +#include "Sv.rc" +#include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "It.rc" +#include "Ja.rc" +#include "Lt.rc" +#include "No.rc" +#include "Pt.rc" +#include "Ro.rc" +#include "Ru.rc" +#include "Si.rc" +#include "Uk.rc" +#include "Zh.rc" + + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + /* @makedep: mshtml.inf */ REGINST REGINST mshtml.inf diff --git a/dll/win32/mshtml/script.c b/dll/win32/mshtml/script.c index efd2605de39..1d21da9a07e 100644 --- a/dll/win32/mshtml/script.c +++ b/dll/win32/mshtml/script.c @@ -758,9 +758,9 @@ static BOOL get_script_guid(nsIDOMHTMLScriptElement *nsscript, GUID *guid) ERR("GetType failed: %08x\n", nsres); } - nsAString_Init(&attr_str, languageW); - + nsAString_InitDepend(&attr_str, languageW); nsres = nsIDOMHTMLScriptElement_GetAttribute(nsscript, &attr_str, &val_str); + nsAString_Finish(&attr_str); if(NS_SUCCEEDED(nsres)) { const PRUnichar *language; @@ -776,7 +776,6 @@ static BOOL get_script_guid(nsIDOMHTMLScriptElement *nsscript, GUID *guid) ERR("GetAttribute(language) failed: %08x\n", nsres); } - nsAString_Finish(&attr_str); nsAString_Finish(&val_str); return ret; diff --git a/dll/win32/mshtml/txtrange.c b/dll/win32/mshtml/txtrange.c index 0ece6ecb969..9b2bb94aec4 100644 --- a/dll/win32/mshtml/txtrange.c +++ b/dll/win32/mshtml/txtrange.c @@ -1141,7 +1141,7 @@ static HRESULT WINAPI HTMLTxtRange_put_text(IHTMLTxtRange *iface, BSTR v) if(!This->doc) return MSHTML_E_NODOC; - nsAString_Init(&text_str, v); + nsAString_InitDepend(&text_str, v); nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc->nsdoc, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { diff --git a/dll/win32/mshtml/view.c b/dll/win32/mshtml/view.c index f4c62a03d63..261e959b0ad 100644 --- a/dll/win32/mshtml/view.c +++ b/dll/win32/mshtml/view.c @@ -807,8 +807,19 @@ static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze) static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink) { HTMLDocument *This = VIEWOBJ_THIS(iface); - FIXME("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink); - return E_NOTIMPL; + + TRACE("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink); + + if(aspects != DVASPECT_CONTENT || advf != ADVF_PRIMEFIRST) + FIXME("unsuported arguments\n"); + + if(This->doc_obj->view_sink) + IAdviseSink_Release(This->doc_obj->view_sink); + if(pAdvSink) + IAdviseSink_AddRef(pAdvSink); + + This->doc_obj->view_sink = pAdvSink; + return S_OK; } static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink) diff --git a/dll/win32/msi/action.c b/dll/win32/msi/action.c index d94d842cae1..81dcba43ae9 100644 --- a/dll/win32/msi/action.c +++ b/dll/win32/msi/action.c @@ -92,8 +92,6 @@ static const WCHAR szForceReboot[] = {'F','o','r','c','e','R','e','b','o','o','t',0}; static const WCHAR szResolveSource[] = {'R','e','s','o','l','v','e','S','o','u','r','c','e',0}; -static const WCHAR szAppSearch[] = - {'A','p','p','S','e','a','r','c','h',0}; static const WCHAR szAllocateRegistrySpace[] = {'A','l','l','o','c','a','t','e','R','e','g','i','s','t','r','y','S','p','a','c','e',0}; static const WCHAR szBindImage[] = @@ -114,8 +112,6 @@ static const WCHAR szIsolateComponents[] = {'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t','s',0}; static const WCHAR szMigrateFeatureStates[] = {'M','i','g','r','a','t','e','F','e','a','t','u','r','e','S','t','a','t','e','s',0}; -static const WCHAR szMoveFiles[] = - {'M','o','v','e','F','i','l','e','s',0}; static const WCHAR szMsiPublishAssemblies[] = {'M','s','i','P','u','b','l','i','s','h','A','s','s','e','m','b','l','i','e','s',0}; static const WCHAR szMsiUnpublishAssemblies[] = @@ -134,8 +130,6 @@ static const WCHAR szRegisterFonts[] = {'R','e','g','i','s','t','e','r','F','o','n','t','s',0}; static const WCHAR szRegisterUser[] = {'R','e','g','i','s','t','e','r','U','s','e','r',0}; -static const WCHAR szRemoveDuplicateFiles[] = - {'R','e','m','o','v','e','D','u','p','l','i','c','a','t','e','F','i','l','e','s',0}; static const WCHAR szRemoveEnvironmentStrings[] = {'R','e','m','o','v','e','E','n','v','i','r','o','n','m','e','n','t','S','t','r','i','n','g','s',0}; static const WCHAR szRemoveExistingProducts[] = @@ -886,10 +880,24 @@ static BOOL ACTION_HandleCustomAction( MSIPACKAGE* package, LPCWSTR action, static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - LPCWSTR dir; + LPCWSTR dir, component; LPWSTR full_path; MSIRECORD *uirow; MSIFOLDER *folder; + MSICOMPONENT *comp; + + component = MSI_RecordGetString(row, 2); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; dir = MSI_RecordGetString(row,1); if (!dir) @@ -898,6 +906,11 @@ static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param) return ERROR_SUCCESS; } + uirow = MSI_CreateRecord(1); + MSI_RecordSetStringW(uirow, 1, dir); + ui_actiondata(package, szCreateFolders, uirow); + msiobj_release(&uirow->hdr); + full_path = resolve_folder(package,dir,FALSE,FALSE,TRUE,&folder); if (!full_path) { @@ -907,12 +920,6 @@ static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param) TRACE("Folder is %s\n",debugstr_w(full_path)); - /* UI stuff */ - uirow = MSI_CreateRecord(1); - MSI_RecordSetStringW(uirow,1,full_path); - ui_actiondata(package,szCreateFolders,uirow); - msiobj_release( &uirow->hdr ); - if (folder->State == 0) create_full_pathW(full_path); @@ -951,7 +958,7 @@ UINT msi_create_component_directories( MSIPACKAGE *package ) /* create all the folders required by the components are going to install */ LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry ) { - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL)) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) continue; msi_create_directory( package, comp->Directory ); } @@ -983,10 +990,24 @@ static UINT ACTION_CreateFolders(MSIPACKAGE *package) static UINT ITERATE_RemoveFolders( MSIRECORD *row, LPVOID param ) { MSIPACKAGE *package = param; - LPCWSTR dir; + LPCWSTR dir, component; LPWSTR full_path; MSIRECORD *uirow; MSIFOLDER *folder; + MSICOMPONENT *comp; + + component = MSI_RecordGetString(row, 2); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; dir = MSI_RecordGetString( row, 1 ); if (!dir) @@ -2192,21 +2213,51 @@ static LPSTR parse_value(MSIPACKAGE *package, LPCWSTR value, DWORD *type, return data; } +static const WCHAR *get_root_key( MSIPACKAGE *package, INT root, HKEY *root_key ) +{ + const WCHAR *ret; + + switch (root) + { + case -1: + if (msi_get_property_int( package, szAllUsers, 0 )) + { + *root_key = HKEY_LOCAL_MACHINE; + ret = szHLM; + } + else + { + *root_key = HKEY_CURRENT_USER; + ret = szHCU; + } + break; + case 0: + *root_key = HKEY_CLASSES_ROOT; + ret = szHCR; + break; + case 1: + *root_key = HKEY_CURRENT_USER; + ret = szHCU; + break; + case 2: + *root_key = HKEY_LOCAL_MACHINE; + ret = szHLM; + break; + case 3: + *root_key = HKEY_USERS; + ret = szHU; + break; + default: + ERR("Unknown root %i\n", root); + return NULL; + } + + return ret; +} + static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - static const WCHAR szHCR[] = - {'H','K','E','Y','_','C','L','A','S','S','E','S','_', - 'R','O','O','T','\\',0}; - static const WCHAR szHCU[] = - {'H','K','E','Y','_','C','U','R','R','E','N','T','_', - 'U','S','E','R','\\',0}; - static const WCHAR szHLM[] = - {'H','K','E','Y','_','L','O','C','A','L','_', - 'M','A','C','H','I','N','E','\\',0}; - static const WCHAR szHU[] = - {'H','K','E','Y','_','U','S','E','R','S','\\',0}; - LPSTR value_data = NULL; HKEY root_key, hkey; DWORD type,size; @@ -2231,16 +2282,12 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) if (!comp) return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL)) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping write due to disabled component %s\n", - debugstr_w(component)); - + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); comp->Action = comp->Installed; - return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; name = MSI_RecordGetString(row, 4); @@ -2258,44 +2305,8 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) root = MSI_RecordGetInteger(row,2); key = MSI_RecordGetString(row, 3); - /* get the root key */ - switch (root) - { - case -1: - { - LPWSTR all_users = msi_dup_property( package, szAllUsers ); - if (all_users && all_users[0] == '1') - { - root_key = HKEY_LOCAL_MACHINE; - szRoot = szHLM; - } - else - { - root_key = HKEY_CURRENT_USER; - szRoot = szHCU; - } - msi_free(all_users); - } - break; - case 0: root_key = HKEY_CLASSES_ROOT; - szRoot = szHCR; - break; - case 1: root_key = HKEY_CURRENT_USER; - szRoot = szHCU; - break; - case 2: root_key = HKEY_LOCAL_MACHINE; - szRoot = szHLM; - break; - case 3: root_key = HKEY_USERS; - szRoot = szHU; - break; - default: - ERR("Unknown root %i\n",root); - root_key=NULL; - szRoot = NULL; - break; - } - if (!root_key) + szRoot = get_root_key( package, root, &root_key ); + if (!szRoot) return ERROR_SUCCESS; deformat_string(package, key , &deformated); @@ -2390,6 +2401,212 @@ static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package) return rc; } +static void delete_reg_key_or_value( HKEY hkey_root, LPCWSTR key, LPCWSTR value, BOOL delete_key ) +{ + LONG res; + HKEY hkey; + DWORD num_subkeys, num_values; + + if (delete_key) + { + if ((res = RegDeleteTreeW( hkey_root, key ))) + { + WARN("Failed to delete key %s (%d)\n", debugstr_w(key), res); + } + return; + } + + if (!(res = RegOpenKeyW( hkey_root, key, &hkey ))) + { + if ((res = RegDeleteValueW( hkey, value ))) + { + WARN("Failed to delete value %s (%d)\n", debugstr_w(value), res); + } + res = RegQueryInfoKeyW( hkey, NULL, NULL, NULL, &num_subkeys, NULL, NULL, &num_values, + NULL, NULL, NULL, NULL ); + RegCloseKey( hkey ); + + if (!res && !num_subkeys && !num_values) + { + TRACE("Removing empty key %s\n", debugstr_w(key)); + RegDeleteKeyW( hkey_root, key ); + } + return; + } + WARN("Failed to open key %s (%d)\n", debugstr_w(key), res); +} + + +static UINT ITERATE_RemoveRegistryValuesOnUninstall( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, name, key_str, root_key_str; + LPWSTR deformated_key, deformated_name, ui_key_str; + MSICOMPONENT *comp; + MSIRECORD *uirow; + BOOL delete_key = FALSE; + HKEY hkey_root; + UINT size; + INT root; + + ui_progress( package, 2, 0, 0, 0 ); + + component = MSI_RecordGetString( row, 6 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + name = MSI_RecordGetString( row, 4 ); + if (MSI_RecordIsNull( row, 5 ) && name ) + { + if (name[0] == '+' && !name[1]) + return ERROR_SUCCESS; + else if ((name[0] == '-' && !name[1]) || (name[0] == '*' && !name[1])) + { + delete_key = TRUE; + name = NULL; + } + } + + root = MSI_RecordGetInteger( row, 2 ); + key_str = MSI_RecordGetString( row, 3 ); + + root_key_str = get_root_key( package, root, &hkey_root ); + if (!root_key_str) + return ERROR_SUCCESS; + + deformat_string( package, key_str, &deformated_key ); + size = strlenW( deformated_key ) + strlenW( root_key_str ) + 1; + ui_key_str = msi_alloc( size * sizeof(WCHAR) ); + strcpyW( ui_key_str, root_key_str ); + strcatW( ui_key_str, deformated_key ); + + deformat_string( package, name, &deformated_name ); + + delete_reg_key_or_value( hkey_root, deformated_key, deformated_name, delete_key ); + msi_free( deformated_key ); + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, ui_key_str ); + MSI_RecordSetStringW( uirow, 2, deformated_name ); + + ui_actiondata( package, szRemoveRegistryValues, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free( ui_key_str ); + msi_free( deformated_name ); + return ERROR_SUCCESS; +} + +static UINT ITERATE_RemoveRegistryValuesOnInstall( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, name, key_str, root_key_str; + LPWSTR deformated_key, deformated_name, ui_key_str; + MSICOMPONENT *comp; + MSIRECORD *uirow; + BOOL delete_key = FALSE; + HKEY hkey_root; + UINT size; + INT root; + + ui_progress( package, 2, 0, 0, 0 ); + + component = MSI_RecordGetString( row, 5 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; + + if ((name = MSI_RecordGetString( row, 4 ))) + { + if (name[0] == '-' && !name[1]) + { + delete_key = TRUE; + name = NULL; + } + } + + root = MSI_RecordGetInteger( row, 2 ); + key_str = MSI_RecordGetString( row, 3 ); + + root_key_str = get_root_key( package, root, &hkey_root ); + if (!root_key_str) + return ERROR_SUCCESS; + + deformat_string( package, key_str, &deformated_key ); + size = strlenW( deformated_key ) + strlenW( root_key_str ) + 1; + ui_key_str = msi_alloc( size * sizeof(WCHAR) ); + strcpyW( ui_key_str, root_key_str ); + strcatW( ui_key_str, deformated_key ); + + deformat_string( package, name, &deformated_name ); + + delete_reg_key_or_value( hkey_root, deformated_key, deformated_name, delete_key ); + msi_free( deformated_key ); + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, ui_key_str ); + MSI_RecordSetStringW( uirow, 2, deformated_name ); + + ui_actiondata( package, szRemoveRegistryValues, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free( ui_key_str ); + msi_free( deformated_name ); + return ERROR_SUCCESS; +} + +static UINT ACTION_RemoveRegistryValues( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR registry_query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','R','e','g','i','s','t','r','y','`',0 }; + static const WCHAR remove_registry_query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','R','e','m','o','v','e','R','e','g','i','s','t','r','y','`',0 }; + + /* increment progress bar each time action data is sent */ + ui_progress( package, 1, REG_PROGRESS_VALUE, 1, 0 ); + + rc = MSI_DatabaseOpenViewW( package->db, registry_query, &view ); + if (rc == ERROR_SUCCESS) + { + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveRegistryValuesOnUninstall, package ); + msiobj_release( &view->hdr ); + if (rc != ERROR_SUCCESS) + return rc; + } + + rc = MSI_DatabaseOpenViewW( package->db, remove_registry_query, &view ); + if (rc == ERROR_SUCCESS) + { + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveRegistryValuesOnInstall, package ); + msiobj_release( &view->hdr ); + if (rc != ERROR_SUCCESS) + return rc; + } + + return ERROR_SUCCESS; +} + static UINT ACTION_InstallInitialize(MSIPACKAGE *package) { package->script->CurrentlyScripting = TRUE; @@ -2623,7 +2840,7 @@ static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp ) { ComponentList *cl; - if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL )) + if (feature->ActionRequest != INSTALLSTATE_LOCAL) continue; LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry ) @@ -2638,7 +2855,7 @@ static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp ) { ComponentList *cl; - if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ABSENT )) + if (feature->ActionRequest != INSTALLSTATE_ABSENT) continue; LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry ) @@ -2704,8 +2921,8 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package) debugstr_w(comp->FullKeypath), comp->RefCount); - if (ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL) || - ACTION_VerifyComponentForAction( comp, INSTALLSTATE_SOURCE)) + if (comp->ActionRequest == INSTALLSTATE_LOCAL || + comp->ActionRequest == INSTALLSTATE_SOURCE) { if (!comp->FullKeypath) continue; @@ -2771,7 +2988,7 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package) } RegCloseKey(hkey); } - else if (ACTION_VerifyComponentForAction(comp, INSTALLSTATE_ABSENT)) + else if (comp->ActionRequest == INSTALLSTATE_ABSENT) { if (package->Context == MSIINSTALLCONTEXT_MACHINE) MSIREG_DeleteUserDataComponentKey(comp->ComponentId, szLocalSid); @@ -2862,28 +3079,25 @@ static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param) HMODULE module; HRESULT hr; - static const WCHAR szTYPELIB[] = {'T','Y','P','E','L','I','B',0}; - component = MSI_RecordGetString(row,3); comp = get_loaded_component(package,component); if (!comp) return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL)) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping typelib reg due to disabled component\n"); - + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); comp->Action = comp->Installed; - return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; file = get_loaded_file( package, comp->KeyPath ); if (!file) return ERROR_SUCCESS; + ui_actiondata( package, szRegisterTypeLibraries, row ); + module = LoadLibraryExW( file->TargetPath, NULL, LOAD_LIBRARY_AS_DATAFILE ); if (module) { @@ -2913,11 +3127,7 @@ static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param) ERR("Failed to register type library %s\n", debugstr_w(tl_struct.path)); else - { - ui_actiondata(package,szRegisterTypeLibraries,row); - TRACE("Registered %s\n", debugstr_w(tl_struct.path)); - } ITypeLib_Release(tl_struct.ptLib); msi_free(tl_struct.path); @@ -2935,7 +3145,7 @@ static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param) if (FAILED(hr)) { ERR("Failed to load type library: %08x\n", hr); - return ERROR_FUNCTION_FAILED; + return ERROR_INSTALL_FAILURE; } ITypeLib_Release(tlib); @@ -2967,31 +3177,119 @@ static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package) return rc; } +static UINT ITERATE_UnregisterTypeLibraries( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, guid; + MSICOMPONENT *comp; + GUID libid; + UINT version; + LCID language; + SYSKIND syskind; + HRESULT hr; + + component = MSI_RecordGetString( row, 3 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + ui_actiondata( package, szUnregisterTypeLibraries, row ); + + guid = MSI_RecordGetString( row, 1 ); + CLSIDFromString( (LPWSTR)guid, &libid ); + version = MSI_RecordGetInteger( row, 4 ); + language = MSI_RecordGetInteger( row, 2 ); + +#ifdef _WIN64 + syskind = SYS_WIN64; +#else + syskind = SYS_WIN32; +#endif + + hr = UnRegisterTypeLib( &libid, (version >> 8) & 0xffff, version & 0xff, language, syskind ); + if (FAILED(hr)) + { + WARN("Failed to unregister typelib: %08x\n", hr); + } + + return ERROR_SUCCESS; +} + +static UINT ACTION_UnregisterTypeLibraries( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','T','y','p','e','L','i','b','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_UnregisterTypeLibraries, package ); + msiobj_release( &view->hdr ); + return rc; +} + +static WCHAR *get_link_file( MSIPACKAGE *package, MSIRECORD *row ) +{ + static const WCHAR szlnk[] = {'.','l','n','k',0}; + LPCWSTR directory, extension; + LPWSTR link_folder, link_file, filename; + + directory = MSI_RecordGetString( row, 2 ); + link_folder = resolve_folder( package, directory, FALSE, FALSE, TRUE, NULL ); + + /* may be needed because of a bug somewhere else */ + create_full_pathW( link_folder ); + + filename = msi_dup_record_field( row, 3 ); + reduce_to_longfilename( filename ); + + extension = strchrW( filename, '.' ); + if (!extension || strcmpiW( extension, szlnk )) + { + int len = strlenW( filename ); + filename = msi_realloc( filename, len * sizeof(WCHAR) + sizeof(szlnk) ); + memcpy( filename + len, szlnk, sizeof(szlnk) ); + } + link_file = build_directory_name( 2, link_folder, filename ); + msi_free( link_folder ); + msi_free( filename ); + + return link_file; +} + static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - LPWSTR target_file, target_folder, filename; - LPCWSTR buffer, extension; + LPWSTR link_file, deformated, path; + LPCWSTR component, target; MSICOMPONENT *comp; - static const WCHAR szlnk[]={'.','l','n','k',0}; IShellLinkW *sl = NULL; IPersistFile *pf = NULL; HRESULT res; - buffer = MSI_RecordGetString(row,4); - comp = get_loaded_component(package,buffer); + component = MSI_RecordGetString(row, 4); + comp = get_loaded_component(package, component); if (!comp) return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL )) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping shortcut creation due to disabled component\n"); - + TRACE("Component not scheduled for installation %s\n", debugstr_w(component)); comp->Action = comp->Installed; - return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; ui_actiondata(package,szCreateShortcuts,row); @@ -3012,31 +3310,10 @@ static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) goto err; } - buffer = MSI_RecordGetString(row,2); - target_folder = resolve_folder(package, buffer,FALSE,FALSE,TRUE,NULL); - - /* may be needed because of a bug somewhere else */ - create_full_pathW(target_folder); - - filename = msi_dup_record_field( row, 3 ); - reduce_to_longfilename(filename); - - extension = strchrW(filename,'.'); - if (!extension || strcmpiW(extension,szlnk)) + target = MSI_RecordGetString(row, 5); + if (strchrW(target, '[')) { - int len = strlenW(filename); - filename = msi_realloc(filename, len * sizeof(WCHAR) + sizeof(szlnk)); - memcpy(filename + len, szlnk, sizeof(szlnk)); - } - target_file = build_directory_name(2, target_folder, filename); - msi_free(target_folder); - msi_free(filename); - - buffer = MSI_RecordGetString(row,5); - if (strchrW(buffer,'[')) - { - LPWSTR deformated; - deformat_string(package,buffer,&deformated); + deformat_string(package, target, &deformated); IShellLinkW_SetPath(sl,deformated); msi_free(deformated); } @@ -3048,17 +3325,16 @@ static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) if (!MSI_RecordIsNull(row,6)) { - LPWSTR deformated; - buffer = MSI_RecordGetString(row,6); - deformat_string(package,buffer,&deformated); + LPCWSTR arguments = MSI_RecordGetString(row, 6); + deformat_string(package, arguments, &deformated); IShellLinkW_SetArguments(sl,deformated); msi_free(deformated); } if (!MSI_RecordIsNull(row,7)) { - buffer = MSI_RecordGetString(row,7); - IShellLinkW_SetDescription(sl,buffer); + LPCWSTR description = MSI_RecordGetString(row, 7); + IShellLinkW_SetDescription(sl, description); } if (!MSI_RecordIsNull(row,8)) @@ -3066,20 +3342,18 @@ static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) if (!MSI_RecordIsNull(row,9)) { - LPWSTR Path; INT index; + LPCWSTR icon = MSI_RecordGetString(row, 9); - buffer = MSI_RecordGetString(row,9); - - Path = build_icon_path(package,buffer); + path = build_icon_path(package, icon); index = MSI_RecordGetInteger(row,10); /* no value means 0 */ if (index == MSI_NULL_INTEGER) index = 0; - IShellLinkW_SetIconLocation(sl,Path,index); - msi_free(Path); + IShellLinkW_SetIconLocation(sl, path, index); + msi_free(path); } if (!MSI_RecordIsNull(row,11)) @@ -3087,18 +3361,19 @@ static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param) if (!MSI_RecordIsNull(row,12)) { - LPWSTR Path; - buffer = MSI_RecordGetString(row,12); - Path = resolve_folder(package, buffer, FALSE, FALSE, TRUE, NULL); - if (Path) - IShellLinkW_SetWorkingDirectory(sl,Path); - msi_free(Path); + LPCWSTR wkdir = MSI_RecordGetString(row, 12); + path = resolve_folder(package, wkdir, FALSE, FALSE, TRUE, NULL); + if (path) + IShellLinkW_SetWorkingDirectory(sl, path); + msi_free(path); } - TRACE("Writing shortcut to %s\n",debugstr_w(target_file)); - IPersistFile_Save(pf,target_file,FALSE); + link_file = get_link_file(package, row); - msi_free(target_file); + TRACE("Writing shortcut to %s\n", debugstr_w(link_file)); + IPersistFile_Save(pf, link_file, FALSE); + + msi_free(link_file); err: if (pf) @@ -3133,6 +3408,58 @@ static UINT ACTION_CreateShortcuts(MSIPACKAGE *package) return rc; } +static UINT ITERATE_RemoveShortcuts( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPWSTR link_file; + LPCWSTR component; + MSICOMPONENT *comp; + + component = MSI_RecordGetString( row, 4 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + ui_actiondata( package, szRemoveShortcuts, row ); + + link_file = get_link_file( package, row ); + + TRACE("Removing shortcut file %s\n", debugstr_w( link_file )); + if (!DeleteFileW( link_file )) + { + WARN("Failed to remove shortcut file %u\n", GetLastError()); + } + msi_free( link_file ); + + return ERROR_SUCCESS; +} + +static UINT ACTION_RemoveShortcuts( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','S','h','o','r','t','c','u','t','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveShortcuts, package ); + msiobj_release( &view->hdr ); + + return rc; +} + static UINT ITERATE_PublishIcon(MSIRECORD *row, LPVOID param) { MSIPACKAGE* package = param; @@ -3142,7 +3469,6 @@ static UINT ITERATE_PublishIcon(MSIRECORD *row, LPVOID param) CHAR buffer[1024]; DWORD sz; UINT rc; - MSIRECORD *uirow; FileName = MSI_RecordGetString(row,1); if (!FileName) @@ -3181,14 +3507,8 @@ static UINT ITERATE_PublishIcon(MSIRECORD *row, LPVOID param) } while (sz == 1024); msi_free(FilePath); - CloseHandle(the_file); - uirow = MSI_CreateRecord(1); - MSI_RecordSetStringW(uirow,1,FileName); - ui_actiondata(package,szPublishProduct,uirow); - msiobj_release( &uirow->hdr ); - return ERROR_SUCCESS; } @@ -3450,8 +3770,8 @@ done: static UINT ACTION_PublishProduct(MSIPACKAGE *package) { UINT rc; - HKEY hukey=0; - HKEY hudkey=0; + HKEY hukey = NULL, hudkey = NULL; + MSIRECORD *uirow; /* FIXME: also need to publish if the product is in advertise mode */ if (!msi_check_publish(package)) @@ -3489,42 +3809,75 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package) rc = msi_publish_icons(package); end: + uirow = MSI_CreateRecord( 1 ); + MSI_RecordSetStringW( uirow, 1, package->ProductCode ); + ui_actiondata( package, szPublishProduct, uirow ); + msiobj_release( &uirow->hdr ); + RegCloseKey(hukey); RegCloseKey(hudkey); return rc; } +static WCHAR *get_ini_file_name( MSIPACKAGE *package, MSIRECORD *row ) +{ + WCHAR *filename, *ptr, *folder, *ret; + const WCHAR *dirprop; + + filename = msi_dup_record_field( row, 2 ); + if (filename && (ptr = strchrW( filename, '|' ))) + ptr++; + else + ptr = filename; + + dirprop = MSI_RecordGetString( row, 3 ); + if (dirprop) + { + folder = resolve_folder( package, dirprop, FALSE, FALSE, TRUE, NULL ); + if (!folder) + folder = msi_dup_property( package, dirprop ); + } + else + folder = msi_dup_property( package, szWindowsFolder ); + + if (!folder) + { + ERR("Unable to resolve folder %s\n", debugstr_w(dirprop)); + msi_free( filename ); + return NULL; + } + + ret = build_directory_name( 2, folder, ptr ); + + msi_free( filename ); + msi_free( folder ); + return ret; +} + static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - LPCWSTR component, section, key, value, identifier, dirproperty; - LPWSTR deformated_section, deformated_key, deformated_value; - LPWSTR folder, filename, fullname = NULL; - LPCWSTR filenameptr; + LPCWSTR component, section, key, value, identifier; + LPWSTR deformated_section, deformated_key, deformated_value, fullname; MSIRECORD * uirow; INT action; MSICOMPONENT *comp; - static const WCHAR szWindowsFolder[] = - {'W','i','n','d','o','w','s','F','o','l','d','e','r',0}; component = MSI_RecordGetString(row, 8); comp = get_loaded_component(package,component); + if (!comp) + return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL)) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping ini file due to disabled component %s\n", - debugstr_w(component)); - + TRACE("Component not scheduled for installation %s\n", debugstr_w(component)); comp->Action = comp->Installed; - return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; identifier = MSI_RecordGetString(row,1); - dirproperty = MSI_RecordGetString(row,3); section = MSI_RecordGetString(row,4); key = MSI_RecordGetString(row,5); value = MSI_RecordGetString(row,6); @@ -3534,28 +3887,7 @@ static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param) deformat_string(package,key,&deformated_key); deformat_string(package,value,&deformated_value); - filename = msi_dup_record_field(row, 2); - if (filename && (filenameptr = strchrW(filename, '|'))) - filenameptr++; - else - filenameptr = filename; - - if (dirproperty) - { - folder = resolve_folder(package, dirproperty, FALSE, FALSE, TRUE, NULL); - if (!folder) - folder = msi_dup_property( package, dirproperty ); - } - else - folder = msi_dup_property( package, szWindowsFolder ); - - if (!folder) - { - ERR("Unable to resolve folder! (%s)\n",debugstr_w(dirproperty)); - goto cleanup; - } - - fullname = build_directory_name(2, folder, filenameptr); + fullname = get_ini_file_name(package, row); if (action == 0) { @@ -3591,10 +3923,7 @@ static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param) ui_actiondata(package,szWriteIniValues,uirow); msiobj_release( &uirow->hdr ); -cleanup: - msi_free(filename); msi_free(fullname); - msi_free(folder); msi_free(deformated_key); msi_free(deformated_value); msi_free(deformated_section); @@ -3621,6 +3950,163 @@ static UINT ACTION_WriteIniValues(MSIPACKAGE *package) return rc; } +static UINT ITERATE_RemoveIniValuesOnUninstall( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, section, key, value, identifier; + LPWSTR deformated_section, deformated_key, deformated_value, filename; + MSICOMPONENT *comp; + MSIRECORD *uirow; + INT action; + + component = MSI_RecordGetString( row, 8 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + identifier = MSI_RecordGetString( row, 1 ); + section = MSI_RecordGetString( row, 4 ); + key = MSI_RecordGetString( row, 5 ); + value = MSI_RecordGetString( row, 6 ); + action = MSI_RecordGetInteger( row, 7 ); + + deformat_string( package, section, &deformated_section ); + deformat_string( package, key, &deformated_key ); + deformat_string( package, value, &deformated_value ); + + if (action == msidbIniFileActionAddLine || action == msidbIniFileActionCreateLine) + { + filename = get_ini_file_name( package, row ); + + TRACE("Removing key %s from section %s in %s\n", + debugstr_w(deformated_key), debugstr_w(deformated_section), debugstr_w(filename)); + + if (!WritePrivateProfileStringW( deformated_section, deformated_key, NULL, filename )) + { + WARN("Unable to remove key %u\n", GetLastError()); + } + msi_free( filename ); + } + else + FIXME("Unsupported action %d\n", action); + + + uirow = MSI_CreateRecord( 4 ); + MSI_RecordSetStringW( uirow, 1, identifier ); + MSI_RecordSetStringW( uirow, 2, deformated_section ); + MSI_RecordSetStringW( uirow, 3, deformated_key ); + MSI_RecordSetStringW( uirow, 4, deformated_value ); + ui_actiondata( package, szRemoveIniValues, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free( deformated_key ); + msi_free( deformated_value ); + msi_free( deformated_section ); + return ERROR_SUCCESS; +} + +static UINT ITERATE_RemoveIniValuesOnInstall( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR component, section, key, value, identifier; + LPWSTR deformated_section, deformated_key, deformated_value, filename; + MSICOMPONENT *comp; + MSIRECORD *uirow; + INT action; + + component = MSI_RecordGetString( row, 8 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; + + identifier = MSI_RecordGetString( row, 1 ); + section = MSI_RecordGetString( row, 4 ); + key = MSI_RecordGetString( row, 5 ); + value = MSI_RecordGetString( row, 6 ); + action = MSI_RecordGetInteger( row, 7 ); + + deformat_string( package, section, &deformated_section ); + deformat_string( package, key, &deformated_key ); + deformat_string( package, value, &deformated_value ); + + if (action == msidbIniFileActionRemoveLine) + { + filename = get_ini_file_name( package, row ); + + TRACE("Removing key %s from section %s in %s\n", + debugstr_w(deformated_key), debugstr_w(deformated_section), debugstr_w(filename)); + + if (!WritePrivateProfileStringW( deformated_section, deformated_key, NULL, filename )) + { + WARN("Unable to remove key %u\n", GetLastError()); + } + msi_free( filename ); + } + else + FIXME("Unsupported action %d\n", action); + + uirow = MSI_CreateRecord( 4 ); + MSI_RecordSetStringW( uirow, 1, identifier ); + MSI_RecordSetStringW( uirow, 2, deformated_section ); + MSI_RecordSetStringW( uirow, 3, deformated_key ); + MSI_RecordSetStringW( uirow, 4, deformated_value ); + ui_actiondata( package, szRemoveIniValues, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free( deformated_key ); + msi_free( deformated_value ); + msi_free( deformated_section ); + return ERROR_SUCCESS; +} + +static UINT ACTION_RemoveIniValues( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','I','n','i','F','i','l','e','`',0}; + static const WCHAR remove_query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','R','e','m','o','v','e','I','n','i','F','i','l','e','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc == ERROR_SUCCESS) + { + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveIniValuesOnUninstall, package ); + msiobj_release( &view->hdr ); + if (rc != ERROR_SUCCESS) + return rc; + } + + rc = MSI_DatabaseOpenViewW( package->db, remove_query, &view ); + if (rc == ERROR_SUCCESS) + { + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveIniValuesOnInstall, package ); + msiobj_release( &view->hdr ); + if (rc != ERROR_SUCCESS) + return rc; + } + + return ERROR_SUCCESS; +} + static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; @@ -3629,7 +4115,7 @@ static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param) MSIFILE *file; DWORD len; static const WCHAR ExeStr[] = - {'r','e','g','s','v','r','3','2','.','e','x','e',' ','\"',0}; + {'r','e','g','s','v','r','3','2','.','e','x','e',' ',' /',' s',' ','\"',0}; static const WCHAR close[] = {'\"',0}; STARTUPINFOW si; PROCESS_INFORMATION info; @@ -3708,7 +4194,7 @@ static UINT ACTION_SelfRegModules(MSIPACKAGE *package) static UINT ITERATE_SelfUnregModules( MSIRECORD *row, LPVOID param ) { static const WCHAR regsvr32[] = - {'r','e','g','s','v','r','3','2','.','e','x','e',' ','/','u',' ','\"',0}; + {'r','e','g','s','v','r','3','2','.','e','x','e',' ','/','u',' ','/','s',' ','\"',0}; static const WCHAR close[] = {'\"',0}; MSIPACKAGE *package = param; LPCWSTR filename; @@ -3792,8 +4278,7 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package) { MSIFEATURE *feature; UINT rc; - HKEY hkey; - HKEY userdata = NULL; + HKEY hkey = NULL, userdata = NULL; if (!msi_check_publish(package)) return ERROR_SUCCESS; @@ -3818,10 +4303,9 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package) BOOL absent = FALSE; MSIRECORD *uirow; - if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ) && - !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_SOURCE ) && - !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED )) - absent = TRUE; + if (feature->ActionRequest != INSTALLSTATE_LOCAL && + feature->ActionRequest != INSTALLSTATE_SOURCE && + feature->ActionRequest != INSTALLSTATE_ADVERTISED) absent = TRUE; size = 1; LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry ) @@ -4047,6 +4531,7 @@ static UINT msi_publish_install_properties(MSIPACKAGE *package, HKEY hkey) static UINT ACTION_RegisterProduct(MSIPACKAGE *package) { WCHAR squashed_pc[SQUISH_GUID_SIZE]; + MSIRECORD *uirow; LPWSTR upgrade_code; HKEY hkey, props; HKEY upgrade; @@ -4091,8 +4576,12 @@ static UINT ACTION_RegisterProduct(MSIPACKAGE *package) } done: - RegCloseKey(hkey); + uirow = MSI_CreateRecord( 1 ); + MSI_RecordSetStringW( uirow, 1, package->ProductCode ); + ui_actiondata( package, szRegisterProduct, uirow ); + msiobj_release( &uirow->hdr ); + RegCloseKey(hkey); return ERROR_SUCCESS; } @@ -4293,10 +4782,10 @@ static UINT ACTION_ResolveSource(MSIPACKAGE* package) static UINT ACTION_RegisterUser(MSIPACKAGE *package) { - HKEY hkey=0; - LPWSTR buffer; - LPWSTR productid; - UINT rc,i; + HKEY hkey = 0; + LPWSTR buffer, productid = NULL; + UINT i, rc = ERROR_SUCCESS; + MSIRECORD *uirow; static const WCHAR szPropKeys[][80] = { @@ -4317,12 +4806,12 @@ static UINT ACTION_RegisterUser(MSIPACKAGE *package) if (msi_check_unpublish(package)) { MSIREG_DeleteUserDataProductKey(package->ProductCode); - return ERROR_SUCCESS; + goto end; } productid = msi_dup_property( package, INSTALLPROPERTY_PRODUCTIDW ); if (!productid) - return ERROR_SUCCESS; + goto end; rc = MSIREG_OpenInstallProps(package->ProductCode, package->Context, NULL, &hkey, TRUE); @@ -4337,11 +4826,13 @@ static UINT ACTION_RegisterUser(MSIPACKAGE *package) } end: + uirow = MSI_CreateRecord( 1 ); + MSI_RecordSetStringW( uirow, 1, productid ); + ui_actiondata( package, szRegisterUser, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(productid); RegCloseKey(hkey); - - /* FIXME: call ui_actiondata */ - return rc; } @@ -4359,32 +4850,34 @@ static UINT ACTION_ExecuteAction(MSIPACKAGE *package) static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param) { MSIPACKAGE *package = param; - LPCWSTR compgroupid=NULL; - LPCWSTR feature=NULL; - LPCWSTR text = NULL; - LPCWSTR qualifier = NULL; - LPCWSTR component = NULL; - LPWSTR advertise = NULL; - LPWSTR output = NULL; - HKEY hkey; - UINT rc = ERROR_SUCCESS; + LPCWSTR compgroupid, component, feature, qualifier, text; + LPWSTR advertise = NULL, output = NULL; + HKEY hkey = NULL; + UINT rc; MSICOMPONENT *comp; - DWORD sz = 0; + MSIFEATURE *feat; + DWORD sz; MSIRECORD *uirow; - component = MSI_RecordGetString(rec,3); - comp = get_loaded_component(package,component); + feature = MSI_RecordGetString(rec, 5); + feat = get_loaded_feature(package, feature); + if (!feat) + return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL ) && - !ACTION_VerifyComponentForAction( comp, INSTALLSTATE_SOURCE ) && - !ACTION_VerifyComponentForAction( comp, INSTALLSTATE_ADVERTISED )) + if (feat->ActionRequest != INSTALLSTATE_LOCAL && + feat->ActionRequest != INSTALLSTATE_SOURCE && + feat->ActionRequest != INSTALLSTATE_ADVERTISED) { - TRACE("Skipping: Component %s not scheduled for install\n", - debugstr_w(component)); - + TRACE("Feature %s not scheduled for installation\n", debugstr_w(feature)); + feat->Action = feat->Installed; return ERROR_SUCCESS; } + component = MSI_RecordGetString(rec, 3); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + compgroupid = MSI_RecordGetString(rec,1); qualifier = MSI_RecordGetString(rec,2); @@ -4393,8 +4886,6 @@ static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param) goto end; text = MSI_RecordGetString(rec,4); - feature = MSI_RecordGetString(rec,5); - advertise = create_component_advertise_string(package, comp, feature); sz = strlenW(advertise); @@ -4452,6 +4943,80 @@ static UINT ACTION_PublishComponents(MSIPACKAGE *package) return rc; } +static UINT ITERATE_UnpublishComponent( MSIRECORD *rec, LPVOID param ) +{ + static const WCHAR szInstallerComponents[] = { + 'S','o','f','t','w','a','r','e','\\', + 'M','i','c','r','o','s','o','f','t','\\', + 'I','n','s','t','a','l','l','e','r','\\', + 'C','o','m','p','o','n','e','n','t','s','\\',0}; + + MSIPACKAGE *package = param; + LPCWSTR compgroupid, component, feature, qualifier; + MSICOMPONENT *comp; + MSIFEATURE *feat; + MSIRECORD *uirow; + WCHAR squashed[GUID_SIZE], keypath[MAX_PATH]; + LONG res; + + feature = MSI_RecordGetString( rec, 5 ); + feat = get_loaded_feature( package, feature ); + if (!feat) + return ERROR_SUCCESS; + + if (feat->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Feature %s not scheduled for removal\n", debugstr_w(feature)); + feat->Action = feat->Installed; + return ERROR_SUCCESS; + } + + component = MSI_RecordGetString( rec, 3 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + compgroupid = MSI_RecordGetString( rec, 1 ); + qualifier = MSI_RecordGetString( rec, 2 ); + + squash_guid( compgroupid, squashed ); + strcpyW( keypath, szInstallerComponents ); + strcatW( keypath, squashed ); + + res = RegDeleteKeyW( HKEY_CURRENT_USER, keypath ); + if (res != ERROR_SUCCESS) + { + WARN("Unable to delete component key %d\n", res); + } + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, compgroupid ); + MSI_RecordSetStringW( uirow, 2, qualifier ); + ui_actiondata( package, szUnpublishComponents, uirow ); + msiobj_release( &uirow->hdr ); + + return ERROR_SUCCESS; +} + +static UINT ACTION_UnpublishComponents( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','P','u','b','l','i','s','h', + 'C','o','m','p','o','n','e','n','t','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_UnpublishComponent, package ); + msiobj_release( &view->hdr ); + + return rc; +} + static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param) { MSIPACKAGE *package = param; @@ -4597,22 +5162,34 @@ static UINT ITERATE_StartService(MSIRECORD *rec, LPVOID param) { MSIPACKAGE *package = param; MSICOMPONENT *comp; - SC_HANDLE scm, service = NULL; - LPCWSTR *vector = NULL; + SC_HANDLE scm = NULL, service = NULL; + LPCWSTR component, *vector = NULL; LPWSTR name, args; DWORD event, numargs; UINT r = ERROR_FUNCTION_FAILED; - comp = get_loaded_component(package, MSI_RecordGetString(rec, 6)); - if (!comp || comp->Action == INSTALLSTATE_UNKNOWN || comp->Action == INSTALLSTATE_ABSENT) + component = MSI_RecordGetString(rec, 6); + comp = get_loaded_component(package, component); + if (!comp) return ERROR_SUCCESS; + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; + deformat_string(package, MSI_RecordGetString(rec, 2), &name); deformat_string(package, MSI_RecordGetString(rec, 4), &args); event = MSI_RecordGetInteger(rec, 3); if (!(event & msidbServiceControlEventStart)) - return ERROR_SUCCESS; + { + r = ERROR_SUCCESS; + goto done; + } scm = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT); if (!scm) @@ -4758,6 +5335,7 @@ static UINT ITERATE_StopService( MSIRECORD *rec, LPVOID param ) { MSIPACKAGE *package = param; MSICOMPONENT *comp; + LPCWSTR component; LPWSTR name; DWORD event; @@ -4765,10 +5343,19 @@ static UINT ITERATE_StopService( MSIRECORD *rec, LPVOID param ) if (!(event & msidbServiceControlEventStop)) return ERROR_SUCCESS; - comp = get_loaded_component( package, MSI_RecordGetString( rec, 6 ) ); - if (!comp || comp->Action == INSTALLSTATE_UNKNOWN || comp->Action == INSTALLSTATE_ABSENT) + component = MSI_RecordGetString( rec, 6 ); + comp = get_loaded_component( package, component ); + if (!comp) return ERROR_SUCCESS; + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + deformat_string( package, MSI_RecordGetString( rec, 2 ), &name ); stop_service( name ); msi_free( name ); @@ -4799,18 +5386,29 @@ static UINT ITERATE_DeleteService( MSIRECORD *rec, LPVOID param ) { MSIPACKAGE *package = param; MSICOMPONENT *comp; - LPWSTR name = NULL; - DWORD event; + MSIRECORD *uirow; + LPCWSTR component; + LPWSTR name = NULL, display_name = NULL; + DWORD event, len; SC_HANDLE scm = NULL, service = NULL; event = MSI_RecordGetInteger( rec, 3 ); if (!(event & msidbServiceControlEventDelete)) return ERROR_SUCCESS; - comp = get_loaded_component( package, MSI_RecordGetString(rec, 6) ); - if (!comp || comp->Action == INSTALLSTATE_UNKNOWN || comp->Action == INSTALLSTATE_ABSENT) + component = MSI_RecordGetString(rec, 6); + comp = get_loaded_component(package, component); + if (!comp) return ERROR_SUCCESS; + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + deformat_string( package, MSI_RecordGetString(rec, 2), &name ); stop_service( name ); @@ -4821,6 +5419,14 @@ static UINT ITERATE_DeleteService( MSIRECORD *rec, LPVOID param ) goto done; } + len = 0; + if (!GetServiceDisplayNameW( scm, name, NULL, &len ) && + GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + if ((display_name = msi_alloc( ++len * sizeof(WCHAR )))) + GetServiceDisplayNameW( scm, name, display_name, &len ); + } + service = OpenServiceW( scm, name, DELETE ); if (!service) { @@ -4832,9 +5438,16 @@ static UINT ITERATE_DeleteService( MSIRECORD *rec, LPVOID param ) WARN("Failed to delete service (%s): %u\n", debugstr_w(name), GetLastError()); done: + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, display_name ); + MSI_RecordSetStringW( uirow, 2, name ); + ui_actiondata( package, szDeleteServices, uirow ); + msiobj_release( &uirow->hdr ); + CloseServiceHandle( service ); CloseServiceHandle( scm ); msi_free( name ); + msi_free( display_name ); return ERROR_SUCCESS; } @@ -4877,6 +5490,7 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) LPWSTR driver, driver_path, ptr; WCHAR outpath[MAX_PATH]; MSIFILE *driver_file, *setup_file; + MSIRECORD *uirow; LPCWSTR desc; DWORD len, usage; UINT r = ERROR_SUCCESS; @@ -4893,15 +5507,17 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) driver_file = msi_find_file(package, MSI_RecordGetString(rec, 4)); setup_file = msi_find_file(package, MSI_RecordGetString(rec, 5)); - if (!driver_file || !setup_file) + if (!driver_file) { ERR("ODBC Driver entry not found!\n"); return ERROR_FUNCTION_FAILED; } - len = lstrlenW(desc) + lstrlenW(driver_fmt) + lstrlenW(driver_file->FileName) + - lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName) + - lstrlenW(usage_fmt) + 1; + len = lstrlenW(desc) + lstrlenW(driver_fmt) + lstrlenW(driver_file->FileName); + if (setup_file) + len += lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName); + len += lstrlenW(usage_fmt) + 2; /* \0\0 */ + driver = msi_alloc(len * sizeof(WCHAR)); if (!driver) return ERROR_OUTOFMEMORY; @@ -4910,11 +5526,14 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) lstrcpyW(ptr, desc); ptr += lstrlenW(ptr) + 1; - sprintfW(ptr, driver_fmt, driver_file->FileName); - ptr += lstrlenW(ptr) + 1; + len = sprintfW(ptr, driver_fmt, driver_file->FileName); + ptr += len + 1; - sprintfW(ptr, setup_fmt, setup_file->FileName); - ptr += lstrlenW(ptr) + 1; + if (setup_file) + { + len = sprintfW(ptr, setup_fmt, setup_file->FileName); + ptr += len + 1; + } lstrcpyW(ptr, usage_fmt); ptr += lstrlenW(ptr) + 1; @@ -4931,6 +5550,13 @@ static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param ) r = ERROR_FUNCTION_FAILED; } + uirow = MSI_CreateRecord( 5 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + MSI_RecordSetStringW( uirow, 3, driver_path ); + ui_actiondata( package, szInstallODBC, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(driver); msi_free(driver_path); @@ -4943,6 +5569,7 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) LPWSTR translator, translator_path, ptr; WCHAR outpath[MAX_PATH]; MSIFILE *translator_file, *setup_file; + MSIRECORD *uirow; LPCWSTR desc; DWORD len, usage; UINT r = ERROR_SUCCESS; @@ -4957,14 +5584,16 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) translator_file = msi_find_file(package, MSI_RecordGetString(rec, 4)); setup_file = msi_find_file(package, MSI_RecordGetString(rec, 5)); - if (!translator_file || !setup_file) + if (!translator_file) { ERR("ODBC Translator entry not found!\n"); return ERROR_FUNCTION_FAILED; } - len = lstrlenW(desc) + lstrlenW(translator_fmt) + lstrlenW(translator_file->FileName) + - lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName) + 1; + len = lstrlenW(desc) + lstrlenW(translator_fmt) + lstrlenW(translator_file->FileName) + 2; /* \0\0 */ + if (setup_file) + len += lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName); + translator = msi_alloc(len * sizeof(WCHAR)); if (!translator) return ERROR_OUTOFMEMORY; @@ -4973,11 +5602,14 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) lstrcpyW(ptr, desc); ptr += lstrlenW(ptr) + 1; - sprintfW(ptr, translator_fmt, translator_file->FileName); - ptr += lstrlenW(ptr) + 1; + len = sprintfW(ptr, translator_fmt, translator_file->FileName); + ptr += len + 1; - sprintfW(ptr, setup_fmt, setup_file->FileName); - ptr += lstrlenW(ptr) + 1; + if (setup_file) + { + len = sprintfW(ptr, setup_fmt, setup_file->FileName); + ptr += len + 1; + } *ptr = '\0'; translator_path = strdupW(translator_file->TargetPath); @@ -4991,6 +5623,13 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) r = ERROR_FUNCTION_FAILED; } + uirow = MSI_CreateRecord( 5 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + MSI_RecordSetStringW( uirow, 3, translator_path ); + ui_actiondata( package, szInstallODBC, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(translator); msi_free(translator_path); @@ -4999,12 +5638,14 @@ static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param ) static UINT ITERATE_InstallODBCDataSource( MSIRECORD *rec, LPVOID param ) { + MSIPACKAGE *package = param; LPWSTR attrs; LPCWSTR desc, driver; WORD request = ODBC_ADD_SYS_DSN; INT registration; DWORD len; UINT r = ERROR_SUCCESS; + MSIRECORD *uirow; static const WCHAR attrs_fmt[] = { 'D','S','N','=','%','s',0 }; @@ -5016,13 +5657,13 @@ static UINT ITERATE_InstallODBCDataSource( MSIRECORD *rec, LPVOID param ) if (registration == msidbODBCDataSourceRegistrationPerMachine) request = ODBC_ADD_SYS_DSN; else if (registration == msidbODBCDataSourceRegistrationPerUser) request = ODBC_ADD_DSN; - len = lstrlenW(attrs_fmt) + lstrlenW(desc) + 1 + 1; + len = lstrlenW(attrs_fmt) + lstrlenW(desc) + 2; /* \0\0 */ attrs = msi_alloc(len * sizeof(WCHAR)); if (!attrs) return ERROR_OUTOFMEMORY; - sprintfW(attrs, attrs_fmt, desc); - attrs[len - 1] = '\0'; + len = sprintfW(attrs, attrs_fmt, desc); + attrs[len + 1] = 0; if (!SQLConfigDataSourceW(NULL, request, driver, attrs)) { @@ -5030,6 +5671,13 @@ static UINT ITERATE_InstallODBCDataSource( MSIRECORD *rec, LPVOID param ) r = ERROR_FUNCTION_FAILED; } + uirow = MSI_CreateRecord( 5 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + MSI_RecordSetInteger( uirow, 3, request ); + ui_actiondata( package, szInstallODBC, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(attrs); return r; @@ -5076,6 +5724,145 @@ static UINT ACTION_InstallODBC( MSIPACKAGE *package ) return rc; } +static UINT ITERATE_RemoveODBCDriver( MSIRECORD *rec, LPVOID param ) +{ + MSIPACKAGE *package = param; + MSIRECORD *uirow; + DWORD usage; + LPCWSTR desc; + + desc = MSI_RecordGetString( rec, 3 ); + if (!SQLRemoveDriverW( desc, FALSE, &usage )) + { + WARN("Failed to remove ODBC driver\n"); + } + else if (!usage) + { + FIXME("Usage count reached 0\n"); + } + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + ui_actiondata( package, szRemoveODBC, uirow ); + msiobj_release( &uirow->hdr ); + + return ERROR_SUCCESS; +} + +static UINT ITERATE_RemoveODBCTranslator( MSIRECORD *rec, LPVOID param ) +{ + MSIPACKAGE *package = param; + MSIRECORD *uirow; + DWORD usage; + LPCWSTR desc; + + desc = MSI_RecordGetString( rec, 3 ); + if (!SQLRemoveTranslatorW( desc, &usage )) + { + WARN("Failed to remove ODBC translator\n"); + } + else if (!usage) + { + FIXME("Usage count reached 0\n"); + } + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + ui_actiondata( package, szRemoveODBC, uirow ); + msiobj_release( &uirow->hdr ); + + return ERROR_SUCCESS; +} + +static UINT ITERATE_RemoveODBCDataSource( MSIRECORD *rec, LPVOID param ) +{ + MSIPACKAGE *package = param; + MSIRECORD *uirow; + LPWSTR attrs; + LPCWSTR desc, driver; + WORD request = ODBC_REMOVE_SYS_DSN; + INT registration; + DWORD len; + + static const WCHAR attrs_fmt[] = { + 'D','S','N','=','%','s',0 }; + + desc = MSI_RecordGetString( rec, 3 ); + driver = MSI_RecordGetString( rec, 4 ); + registration = MSI_RecordGetInteger( rec, 5 ); + + if (registration == msidbODBCDataSourceRegistrationPerMachine) request = ODBC_REMOVE_SYS_DSN; + else if (registration == msidbODBCDataSourceRegistrationPerUser) request = ODBC_REMOVE_DSN; + + len = strlenW( attrs_fmt ) + strlenW( desc ) + 2; /* \0\0 */ + attrs = msi_alloc( len * sizeof(WCHAR) ); + if (!attrs) + return ERROR_OUTOFMEMORY; + + FIXME("Use ODBCSourceAttribute table\n"); + + len = sprintfW( attrs, attrs_fmt, desc ); + attrs[len + 1] = 0; + + if (!SQLConfigDataSourceW( NULL, request, driver, attrs )) + { + WARN("Failed to remove ODBC data source\n"); + } + msi_free( attrs ); + + uirow = MSI_CreateRecord( 3 ); + MSI_RecordSetStringW( uirow, 1, desc ); + MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) ); + MSI_RecordSetInteger( uirow, 3, request ); + ui_actiondata( package, szRemoveODBC, uirow ); + msiobj_release( &uirow->hdr ); + + return ERROR_SUCCESS; +} + +static UINT ACTION_RemoveODBC( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + + static const WCHAR driver_query[] = { + 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + 'O','D','B','C','D','r','i','v','e','r',0 }; + + static const WCHAR translator_query[] = { + 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + 'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0 }; + + static const WCHAR source_query[] = { + 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + 'O','D','B','C','D','a','t','a','S','o','u','r','c','e',0 }; + + rc = MSI_DatabaseOpenViewW( package->db, driver_query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCDriver, package ); + msiobj_release( &view->hdr ); + + rc = MSI_DatabaseOpenViewW( package->db, translator_query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCTranslator, package ); + msiobj_release( &view->hdr ); + + rc = MSI_DatabaseOpenViewW( package->db, source_query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCDataSource, package ); + msiobj_release( &view->hdr ); + + return rc; +} + #define ENV_ACT_SETALWAYS 0x1 #define ENV_ACT_SETABSENT 0x2 #define ENV_ACT_REMOVE 0x4 @@ -5088,7 +5875,7 @@ static UINT ACTION_InstallODBC( MSIPACKAGE *package ) #define check_flag_combo(x, y) ((x) & ~(y)) == (y) -static LONG env_set_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags ) +static UINT env_parse_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags ) { LPCWSTR cptr = *name; @@ -5169,17 +5956,8 @@ static LONG env_set_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags ) return ERROR_SUCCESS; } -static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) +static UINT open_env_key( DWORD flags, HKEY *key ) { - MSIPACKAGE *package = param; - LPCWSTR name, value; - LPWSTR data = NULL, newval = NULL; - LPWSTR deformatted = NULL, ptr; - DWORD flags, type, size; - LONG res; - HKEY env = NULL, root; - LPCWSTR environment; - static const WCHAR user_env[] = {'E','n','v','i','r','o','n','m','e','n','t',0}; static const WCHAR machine_env[] = @@ -5188,13 +5966,62 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) 'C','o','n','t','r','o','l','\\', 'S','e','s','s','i','o','n',' ','M','a','n','a','g','e','r','\\', 'E','n','v','i','r','o','n','m','e','n','t',0}; + const WCHAR *env; + HKEY root; + LONG res; + + if (flags & ENV_MOD_MACHINE) + { + env = machine_env; + root = HKEY_LOCAL_MACHINE; + } + else + { + env = user_env; + root = HKEY_CURRENT_USER; + } + + res = RegOpenKeyExW( root, env, 0, KEY_ALL_ACCESS, key ); + if (res != ERROR_SUCCESS) + { + WARN("Failed to open key %s (%d)\n", debugstr_w(env), res); + return ERROR_FUNCTION_FAILED; + } + + return ERROR_SUCCESS; +} + +static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPCWSTR name, value, component; + LPWSTR data = NULL, newval = NULL, deformatted = NULL, ptr; + DWORD flags, type, size; + UINT res; + HKEY env = NULL; + MSICOMPONENT *comp; + MSIRECORD *uirow; + int action = 0; + + component = MSI_RecordGetString(rec, 4); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; name = MSI_RecordGetString(rec, 2); value = MSI_RecordGetString(rec, 3); TRACE("name %s value %s\n", debugstr_w(name), debugstr_w(value)); - res = env_set_flags(&name, &value, &flags); + res = env_parse_flags(&name, &value, &flags); if (res != ERROR_SUCCESS || !value) goto done; @@ -5206,24 +6033,12 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) value = deformatted; - if (flags & ENV_MOD_MACHINE) - { - environment = machine_env; - root = HKEY_LOCAL_MACHINE; - } - else - { - environment = user_env; - root = HKEY_CURRENT_USER; - } - - res = RegCreateKeyExW(root, environment, 0, NULL, 0, - KEY_ALL_ACCESS, NULL, &env, NULL); + res = open_env_key( flags, &env ); if (res != ERROR_SUCCESS) goto done; - if (flags & ENV_ACT_REMOVE) - FIXME("Not removing environment variable on uninstall!\n"); + if (flags & ENV_MOD_MACHINE) + action |= 0x20000000; size = 0; type = REG_SZ; @@ -5234,6 +6049,8 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) if ((res == ERROR_FILE_NOT_FOUND || !(flags & ENV_MOD_MASK))) { + action = 0x2; + /* Nothing to do. */ if (!value) { @@ -5254,6 +6071,8 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) } else { + action = 0x1; + /* Contrary to MSDN, +-variable to [~];path works */ if (flags & ENV_ACT_SETABSENT && !(flags & ENV_MOD_MASK)) { @@ -5274,7 +6093,10 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) if (flags & ENV_ACT_REMOVEMATCH && (!value || !lstrcmpW(data, value))) { - res = RegDeleteKeyW(env, name); + action = 0x4; + res = RegDeleteValueW(env, name); + if (res != ERROR_SUCCESS) + WARN("Failed to remove value %s (%d)\n", debugstr_w(name), res); goto done; } @@ -5301,6 +6123,7 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) { lstrcpyW(newval, value); ptr = newval + lstrlenW(value); + action |= 0x80000000; } lstrcpyW(ptr, data); @@ -5308,12 +6131,24 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param ) if (flags & ENV_MOD_APPEND) { lstrcatW(newval, value); + action |= 0x40000000; } } TRACE("setting %s to %s\n", debugstr_w(name), debugstr_w(newval)); res = RegSetValueExW(env, name, 0, type, (LPVOID)newval, size); + if (res) + { + WARN("Failed to set %s to %s (%d)\n", debugstr_w(name), debugstr_w(newval), res); + } done: + uirow = MSI_CreateRecord( 3 ); + MSI_RecordSetStringW( uirow, 1, name ); + MSI_RecordSetStringW( uirow, 2, newval ); + MSI_RecordSetInteger( uirow, 3, action ); + ui_actiondata( package, szWriteEnvironmentStrings, uirow ); + msiobj_release( &uirow->hdr ); + if (env) RegCloseKey(env); msi_free(deformatted); msi_free(data); @@ -5338,333 +6173,98 @@ static UINT ACTION_WriteEnvironmentStrings( MSIPACKAGE *package ) return rc; } -#define is_dot_dir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0)))) - -typedef struct -{ - struct list entry; - LPWSTR sourcename; - LPWSTR destname; - LPWSTR source; - LPWSTR dest; -} FILE_LIST; - -static BOOL msi_move_file(LPCWSTR source, LPCWSTR dest, int options) -{ - BOOL ret; - - if (GetFileAttributesW(source) == FILE_ATTRIBUTE_DIRECTORY || - GetFileAttributesW(dest) == FILE_ATTRIBUTE_DIRECTORY) - { - WARN("Source or dest is directory, not moving\n"); - return FALSE; - } - - if (options == msidbMoveFileOptionsMove) - { - TRACE("moving %s -> %s\n", debugstr_w(source), debugstr_w(dest)); - ret = MoveFileExW(source, dest, MOVEFILE_REPLACE_EXISTING); - if (!ret) - { - WARN("MoveFile failed: %d\n", GetLastError()); - return FALSE; - } - } - else - { - TRACE("copying %s -> %s\n", debugstr_w(source), debugstr_w(dest)); - ret = CopyFileW(source, dest, FALSE); - if (!ret) - { - WARN("CopyFile failed: %d\n", GetLastError()); - return FALSE; - } - } - - return TRUE; -} - -static LPWSTR wildcard_to_file(LPWSTR wildcard, LPWSTR filename) -{ - LPWSTR path, ptr; - DWORD dirlen, pathlen; - - ptr = strrchrW(wildcard, '\\'); - dirlen = ptr - wildcard + 1; - - pathlen = dirlen + lstrlenW(filename) + 1; - path = msi_alloc(pathlen * sizeof(WCHAR)); - - lstrcpynW(path, wildcard, dirlen + 1); - lstrcatW(path, filename); - - return path; -} - -static void free_file_entry(FILE_LIST *file) -{ - msi_free(file->source); - msi_free(file->dest); - msi_free(file); -} - -static void free_list(FILE_LIST *list) -{ - while (!list_empty(&list->entry)) - { - FILE_LIST *file = LIST_ENTRY(list_head(&list->entry), FILE_LIST, entry); - - list_remove(&file->entry); - free_file_entry(file); - } -} - -static BOOL add_wildcard(FILE_LIST *files, LPWSTR source, LPWSTR dest) -{ - FILE_LIST *new, *file; - LPWSTR ptr, filename; - DWORD size; - - new = msi_alloc_zero(sizeof(FILE_LIST)); - if (!new) - return FALSE; - - new->source = strdupW(source); - ptr = strrchrW(dest, '\\') + 1; - filename = strrchrW(new->source, '\\') + 1; - - new->sourcename = filename; - - if (*ptr) - new->destname = ptr; - else - new->destname = new->sourcename; - - size = (ptr - dest) + lstrlenW(filename) + 1; - new->dest = msi_alloc(size * sizeof(WCHAR)); - if (!new->dest) - { - free_file_entry(new); - return FALSE; - } - - lstrcpynW(new->dest, dest, ptr - dest + 1); - lstrcatW(new->dest, filename); - - if (list_empty(&files->entry)) - { - list_add_head(&files->entry, &new->entry); - return TRUE; - } - - LIST_FOR_EACH_ENTRY(file, &files->entry, FILE_LIST, entry) - { - if (lstrcmpW(source, file->source) < 0) - { - list_add_before(&file->entry, &new->entry); - return TRUE; - } - } - - list_add_after(&file->entry, &new->entry); - return TRUE; -} - -static BOOL move_files_wildcard(LPWSTR source, LPWSTR dest, int options) -{ - WIN32_FIND_DATAW wfd; - HANDLE hfile; - LPWSTR path; - BOOL res; - FILE_LIST files, *file; - DWORD size; - - hfile = FindFirstFileW(source, &wfd); - if (hfile == INVALID_HANDLE_VALUE) return FALSE; - - list_init(&files.entry); - - for (res = TRUE; res; res = FindNextFileW(hfile, &wfd)) - { - if (is_dot_dir(wfd.cFileName)) continue; - - path = wildcard_to_file(source, wfd.cFileName); - if (!path) - { - res = FALSE; - goto done; - } - - add_wildcard(&files, path, dest); - msi_free(path); - } - - /* no files match the wildcard */ - if (list_empty(&files.entry)) - goto done; - - /* only the first wildcard match gets renamed to dest */ - file = LIST_ENTRY(list_head(&files.entry), FILE_LIST, entry); - size = (strrchrW(file->dest, '\\') - file->dest) + lstrlenW(file->destname) + 2; - file->dest = msi_realloc(file->dest, size * sizeof(WCHAR)); - if (!file->dest) - { - res = FALSE; - goto done; - } - - /* file->dest may be shorter after the reallocation, so add a NULL - * terminator. This is needed for the call to strrchrW, as there will no - * longer be a NULL terminator within the bounds of the allocation in this case. - */ - file->dest[size - 1] = '\0'; - lstrcpyW(strrchrW(file->dest, '\\') + 1, file->destname); - - while (!list_empty(&files.entry)) - { - file = LIST_ENTRY(list_head(&files.entry), FILE_LIST, entry); - - msi_move_file(file->source, file->dest, options); - - list_remove(&file->entry); - free_file_entry(file); - } - - res = TRUE; - -done: - free_list(&files); - FindClose(hfile); - return res; -} - -static UINT ITERATE_MoveFiles( MSIRECORD *rec, LPVOID param ) +static UINT ITERATE_RemoveEnvironmentString( MSIRECORD *rec, LPVOID param ) { MSIPACKAGE *package = param; + LPCWSTR name, value, component; + LPWSTR deformatted = NULL; + DWORD flags; + HKEY env; MSICOMPONENT *comp; - LPCWSTR sourcename; - LPWSTR destname = NULL; - LPWSTR sourcedir = NULL, destdir = NULL; - LPWSTR source = NULL, dest = NULL; - int options; - DWORD size; - BOOL ret, wildcards; + MSIRECORD *uirow; + int action = 0; + LONG res; + UINT r; - comp = get_loaded_component(package, MSI_RecordGetString(rec, 2)); - if (!comp || !comp->Enabled || - !(comp->Action & (INSTALLSTATE_LOCAL | INSTALLSTATE_SOURCE))) + component = MSI_RecordGetString( rec, 4 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) { - TRACE("Component not set for install, not moving file\n"); + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + name = MSI_RecordGetString( rec, 2 ); + value = MSI_RecordGetString( rec, 3 ); + + TRACE("name %s value %s\n", debugstr_w(name), debugstr_w(value)); + + r = env_parse_flags( &name, &value, &flags ); + if (r != ERROR_SUCCESS) + return r; + + if (!(flags & ENV_ACT_REMOVE)) + { + TRACE("Environment variable %s not marked for removal\n", debugstr_w(name)); return ERROR_SUCCESS; } - sourcename = MSI_RecordGetString(rec, 3); - options = MSI_RecordGetInteger(rec, 7); + if (value && !deformat_string( package, value, &deformatted )) + return ERROR_OUTOFMEMORY; - sourcedir = msi_dup_property(package, MSI_RecordGetString(rec, 5)); - if (!sourcedir) + value = deformatted; + + r = open_env_key( flags, &env ); + if (r != ERROR_SUCCESS) + { + r = ERROR_SUCCESS; goto done; - - destdir = msi_dup_property(package, MSI_RecordGetString(rec, 6)); - if (!destdir) - goto done; - - if (!sourcename) - { - if (GetFileAttributesW(sourcedir) == INVALID_FILE_ATTRIBUTES) - goto done; - - source = strdupW(sourcedir); - if (!source) - goto done; - } - else - { - size = lstrlenW(sourcedir) + lstrlenW(sourcename) + 2; - source = msi_alloc(size * sizeof(WCHAR)); - if (!source) - goto done; - - lstrcpyW(source, sourcedir); - if (source[lstrlenW(source) - 1] != '\\') - lstrcatW(source, szBackSlash); - lstrcatW(source, sourcename); } - wildcards = strchrW(source, '*') || strchrW(source, '?'); + if (flags & ENV_MOD_MACHINE) + action |= 0x20000000; - if (MSI_RecordIsNull(rec, 4)) + TRACE("Removing %s\n", debugstr_w(name)); + + res = RegDeleteValueW( env, name ); + if (res != ERROR_SUCCESS) { - if (!wildcards) - { - destname = strdupW(sourcename); - if (!destname) - goto done; - } + WARN("Failed to delete value %s (%d)\n", debugstr_w(name), res); + r = ERROR_SUCCESS; } - else - { - destname = strdupW(MSI_RecordGetString(rec, 4)); - if (destname) - reduce_to_longfilename(destname); - } - - size = 0; - if (destname) - size = lstrlenW(destname); - - size += lstrlenW(destdir) + 2; - dest = msi_alloc(size * sizeof(WCHAR)); - if (!dest) - goto done; - - lstrcpyW(dest, destdir); - if (dest[lstrlenW(dest) - 1] != '\\') - lstrcatW(dest, szBackSlash); - - if (destname) - lstrcatW(dest, destname); - - if (GetFileAttributesW(destdir) == INVALID_FILE_ATTRIBUTES) - { - ret = CreateDirectoryW(destdir, NULL); - if (!ret) - { - WARN("CreateDirectory failed: %d\n", GetLastError()); - return ERROR_SUCCESS; - } - } - - if (!wildcards) - msi_move_file(source, dest, options); - else - move_files_wildcard(source, dest, options); done: - msi_free(sourcedir); - msi_free(destdir); - msi_free(destname); - msi_free(source); - msi_free(dest); + uirow = MSI_CreateRecord( 3 ); + MSI_RecordSetStringW( uirow, 1, name ); + MSI_RecordSetStringW( uirow, 2, value ); + MSI_RecordSetInteger( uirow, 3, action ); + ui_actiondata( package, szRemoveEnvironmentStrings, uirow ); + msiobj_release( &uirow->hdr ); - return ERROR_SUCCESS; + if (env) RegCloseKey( env ); + msi_free( deformatted ); + return r; } -static UINT ACTION_MoveFiles( MSIPACKAGE *package ) +static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package ) { UINT rc; MSIQUERY *view; - - static const WCHAR ExecSeqQuery[] = + static const WCHAR query[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', - '`','M','o','v','e','F','i','l','e','`',0}; + '`','E','n','v','i','r','o','n','m','e','n','t','`',0}; - rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); if (rc != ERROR_SUCCESS) return ERROR_SUCCESS; - rc = MSI_IterateRecords(view, NULL, ITERATE_MoveFiles, package); - msiobj_release(&view->hdr); + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveEnvironmentString, package ); + msiobj_release( &view->hdr ); return rc; } @@ -5677,6 +6277,7 @@ typedef struct tagMSIASSEMBLY MSIFILE *file; LPWSTR manifest; LPWSTR application; + LPWSTR display_name; DWORD attributes; BOOL installed; } MSIASSEMBLY; @@ -5727,11 +6328,17 @@ static UINT install_assembly(MSIPACKAGE *package, MSIASSEMBLY *assembly, LPWSTR path) { IAssemblyCache *cache; + MSIRECORD *uirow; HRESULT hr; UINT r = ERROR_FUNCTION_FAILED; TRACE("installing assembly: %s\n", debugstr_w(path)); + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 2, assembly->display_name ); + ui_actiondata( package, szMsiPublishAssemblies, uirow ); + msiobj_release( &uirow->hdr ); + if (assembly->feature) msi_feature_set_state(package, assembly->feature, INSTALLSTATE_LOCAL); @@ -5821,81 +6428,87 @@ static void append_str(LPWSTR *str, DWORD *size, LPCWSTR append) lstrcatW(*str, append); } -static BOOL check_assembly_installed(MSIDATABASE *db, IAssemblyCache *cache, - MSICOMPONENT *comp) +static WCHAR *get_assembly_display_name( MSIDATABASE *db, MSICOMPONENT *comp ) { - ASSEMBLY_INFO asminfo; - ASSEMBLY_NAME name; - MSIQUERY *view; - LPWSTR disp; - DWORD size; - BOOL found; - UINT r; - static const WCHAR separator[] = {',',' ',0}; static const WCHAR Version[] = {'V','e','r','s','i','o','n','=',0}; static const WCHAR Culture[] = {'C','u','l','t','u','r','e','=',0}; - static const WCHAR PublicKeyToken[] = { - 'P','u','b','l','i','c','K','e','y','T','o','k','e','n','=',0}; + static const WCHAR PublicKeyToken[] = {'P','u','b','l','i','c','K','e','y','T','o','k','e','n','=',0}; static const WCHAR query[] = { 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', '`','M','s','i','A','s','s','e','m','b','l','y','N','a','m','e','`',' ', 'W','H','E','R','E',' ','`','C','o','m','p','o','n','e','n','t','_','`', '=','\'','%','s','\'',0}; + ASSEMBLY_NAME name; + MSIQUERY *view; + LPWSTR display_name; + DWORD size; + UINT r; - disp = NULL; - found = FALSE; - ZeroMemory(&name, sizeof(ASSEMBLY_NAME)); - ZeroMemory(&asminfo, sizeof(ASSEMBLY_INFO)); + display_name = NULL; + memset( &name, 0, sizeof(ASSEMBLY_NAME) ); - r = MSI_OpenQuery(db, &view, query, comp->Component); + r = MSI_OpenQuery( db, &view, query, comp->Component ); if (r != ERROR_SUCCESS) - return ERROR_SUCCESS; + return NULL; - MSI_IterateRecords(view, NULL, parse_assembly_name, &name); - msiobj_release(&view->hdr); + MSI_IterateRecords( view, NULL, parse_assembly_name, &name ); + msiobj_release( &view->hdr ); if (!name.name) { ERR("No assembly name specified!\n"); - goto done; + return NULL; } - append_str(&disp, &size, name.name); + append_str( &display_name, &size, name.name ); if (name.version) { - append_str(&disp, &size, separator); - append_str(&disp, &size, Version); - append_str(&disp, &size, name.version); + append_str( &display_name, &size, separator ); + append_str( &display_name, &size, Version ); + append_str( &display_name, &size, name.version ); } - if (name.culture) { - append_str(&disp, &size, separator); - append_str(&disp, &size, Culture); - append_str(&disp, &size, name.culture); + append_str( &display_name, &size, separator ); + append_str( &display_name, &size, Culture ); + append_str( &display_name, &size, name.culture ); } - if (name.pubkeytoken) { - append_str(&disp, &size, separator); - append_str(&disp, &size, PublicKeyToken); - append_str(&disp, &size, name.pubkeytoken); + append_str( &display_name, &size, separator ); + append_str( &display_name, &size, PublicKeyToken ); + append_str( &display_name, &size, name.pubkeytoken ); } + msi_free( name.name ); + msi_free( name.version ); + msi_free( name.culture ); + msi_free( name.pubkeytoken ); + + return display_name; +} + +static BOOL check_assembly_installed( MSIDATABASE *db, IAssemblyCache *cache, MSICOMPONENT *comp ) +{ + ASSEMBLY_INFO asminfo; + LPWSTR disp; + BOOL found = FALSE; + HRESULT hr; + + disp = get_assembly_display_name( db, comp ); + if (!disp) + return FALSE; + + memset( &asminfo, 0, sizeof(ASSEMBLY_INFO) ); asminfo.cbAssemblyInfo = sizeof(ASSEMBLY_INFO); - IAssemblyCache_QueryAssemblyInfo(cache, QUERYASMINFO_FLAG_VALIDATE, - disp, &asminfo); - found = (asminfo.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED); -done: - msi_free(disp); - msi_free(name.name); - msi_free(name.version); - msi_free(name.culture); - msi_free(name.pubkeytoken); + hr = IAssemblyCache_QueryAssemblyInfo( cache, QUERYASMINFO_FLAG_VALIDATE, disp, &asminfo ); + if (SUCCEEDED(hr)) + found = (asminfo.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED); + msi_free( disp ); return found; } @@ -5903,20 +6516,25 @@ static UINT load_assembly(MSIRECORD *rec, LPVOID param) { ASSEMBLY_LIST *list = param; MSIASSEMBLY *assembly; + LPCWSTR component; assembly = msi_alloc_zero(sizeof(MSIASSEMBLY)); if (!assembly) return ERROR_OUTOFMEMORY; - assembly->component = get_loaded_component(list->package, MSI_RecordGetString(rec, 1)); + component = MSI_RecordGetString(rec, 1); + assembly->component = get_loaded_component(list->package, component); + if (!assembly->component) + return ERROR_SUCCESS; - if (!assembly->component || !assembly->component->Enabled || - !(assembly->component->Action & (INSTALLSTATE_LOCAL | INSTALLSTATE_SOURCE))) + if (assembly->component->ActionRequest != INSTALLSTATE_LOCAL && + assembly->component->ActionRequest != INSTALLSTATE_SOURCE) { - TRACE("Component not set for install, not publishing assembly\n"); - msi_free(assembly); + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + assembly->component->Action = assembly->component->Installed; return ERROR_SUCCESS; } + assembly->component->Action = assembly->component->ActionRequest; assembly->feature = find_feature_by_name(list->package, MSI_RecordGetString(rec, 2)); assembly->file = msi_find_file(list->package, assembly->component->KeyPath); @@ -5996,6 +6614,7 @@ static void free_assemblies(struct list *assemblies) list_remove(&assembly->entry); msi_free(assembly->application); msi_free(assembly->manifest); + msi_free(assembly->display_name); msi_free(assembly); } } @@ -6125,6 +6744,30 @@ done: return r; } +static UINT ACTION_ValidateProductID( MSIPACKAGE *package ) +{ + LPWSTR key, template, id; + UINT r = ERROR_SUCCESS; + + id = msi_dup_property( package, szProductID ); + if (id) + { + msi_free( id ); + return ERROR_SUCCESS; + } + template = msi_dup_property( package, szPIDTemplate ); + key = msi_dup_property( package, szPIDKEY ); + + if (key && template) + { + FIXME( "partial stub: template %s key %s\n", debugstr_w(template), debugstr_w(key) ); + r = MSI_SetPropertyW( package, szProductID, key ); + } + msi_free( template ); + msi_free( key ); + return r; +} + static UINT ACTION_ScheduleReboot( MSIPACKAGE *package ) { TRACE("\n"); @@ -6132,6 +6775,35 @@ static UINT ACTION_ScheduleReboot( MSIPACKAGE *package ) return ERROR_SUCCESS; } +static UINT ACTION_AllocateRegistrySpace( MSIPACKAGE *package ) +{ + static const WCHAR szAvailableFreeReg[] = + {'A','V','A','I','L','A','B','L','E','F','R','E','E','R','E','G',0}; + MSIRECORD *uirow; + int space = msi_get_property_int( package, szAvailableFreeReg, 0 ); + + TRACE("%p %d kilobytes\n", package, space); + + uirow = MSI_CreateRecord( 1 ); + MSI_RecordSetInteger( uirow, 1, space ); + ui_actiondata( package, szAllocateRegistrySpace, uirow ); + msiobj_release( &uirow->hdr ); + + return ERROR_SUCCESS; +} + +static UINT ACTION_DisableRollback( MSIPACKAGE *package ) +{ + FIXME("%p\n", package); + return ERROR_SUCCESS; +} + +static UINT ACTION_InstallAdminPackage( MSIPACKAGE *package ) +{ + FIXME("%p\n", package); + return ERROR_SUCCESS; +} + static UINT msi_unimplemented_action_stub( MSIPACKAGE *package, LPCSTR action, LPCWSTR table ) { @@ -6156,19 +6828,6 @@ static UINT msi_unimplemented_action_stub( MSIPACKAGE *package, return ERROR_SUCCESS; } -static UINT ACTION_AllocateRegistrySpace( MSIPACKAGE *package ) -{ - TRACE("%p\n", package); - return ERROR_SUCCESS; -} - -static UINT ACTION_RemoveIniValues( MSIPACKAGE *package ) -{ - static const WCHAR table[] = - {'R','e','m','o','v','e','I','n','i','F','i','l','e',0 }; - return msi_unimplemented_action_stub( package, "RemoveIniValues", table ); -} - static UINT ACTION_PatchFiles( MSIPACKAGE *package ) { static const WCHAR table[] = { 'P','a','t','c','h',0 }; @@ -6184,7 +6843,7 @@ static UINT ACTION_BindImage( MSIPACKAGE *package ) static UINT ACTION_IsolateComponents( MSIPACKAGE *package ) { static const WCHAR table[] = { - 'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t',0 }; + 'I','s','o','l','a','t','e','d','C','o','m','p','o','n','e','n','t',0 }; return msi_unimplemented_action_stub( package, "IsolateComponents", table ); } @@ -6194,20 +6853,6 @@ static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "MigrateFeatureStates", table ); } -static UINT ACTION_ValidateProductID( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { - 'P','r','o','d','u','c','t','I','D',0 }; - return msi_unimplemented_action_stub( package, "ValidateProductID", table ); -} - -static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { - 'E','n','v','i','r','o','n','m','e','n','t',0 }; - return msi_unimplemented_action_stub( package, "RemoveEnvironmentStrings", table ); -} - static UINT ACTION_MsiUnpublishAssemblies( MSIPACKAGE *package ) { static const WCHAR table[] = { @@ -6215,12 +6860,6 @@ static UINT ACTION_MsiUnpublishAssemblies( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "MsiUnpublishAssemblies", table ); } -static UINT ACTION_UnregisterFonts( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'F','o','n','t',0 }; - return msi_unimplemented_action_stub( package, "UnregisterFonts", table ); -} - static UINT ACTION_RMCCPSearch( MSIPACKAGE *package ) { static const WCHAR table[] = { 'C','C','P','S','e','a','r','c','h',0 }; @@ -6245,48 +6884,18 @@ static UINT ACTION_InstallSFPCatalogFile( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "InstallSFPCatalogFile", table ); } -static UINT ACTION_RemoveDuplicateFiles( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'D','u','p','l','i','c','a','t','e','F','i','l','e',0 }; - return msi_unimplemented_action_stub( package, "RemoveDuplicateFiles", table ); -} - static UINT ACTION_RemoveExistingProducts( MSIPACKAGE *package ) { static const WCHAR table[] = { 'U','p','g','r','a','d','e',0 }; return msi_unimplemented_action_stub( package, "RemoveExistingProducts", table ); } -static UINT ACTION_RemoveODBC( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'O','D','B','C','D','r','i','v','e','r',0 }; - return msi_unimplemented_action_stub( package, "RemoveODBC", table ); -} - -static UINT ACTION_RemoveRegistryValues( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'R','e','m','o','v','e','R','e','g','i','s','t','r','y',0 }; - return msi_unimplemented_action_stub( package, "RemoveRegistryValues", table ); -} - -static UINT ACTION_RemoveShortcuts( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'S','h','o','r','t','c','u','t',0 }; - return msi_unimplemented_action_stub( package, "RemoveShortcuts", table ); -} - static UINT ACTION_SetODBCFolders( MSIPACKAGE *package ) { static const WCHAR table[] = { 'D','i','r','e','c','t','o','r','y',0 }; return msi_unimplemented_action_stub( package, "SetODBCFolders", table ); } -static UINT ACTION_UnpublishComponents( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t',0 }; - return msi_unimplemented_action_stub( package, "UnpublishComponents", table ); -} - static UINT ACTION_UnregisterClassInfo( MSIPACKAGE *package ) { static const WCHAR table[] = { 'A','p','p','I','d',0 }; @@ -6311,12 +6920,6 @@ static UINT ACTION_UnregisterProgIdInfo( MSIPACKAGE *package ) return msi_unimplemented_action_stub( package, "UnregisterProgIdInfo", table ); } -static UINT ACTION_UnregisterTypeLibraries( MSIPACKAGE *package ) -{ - static const WCHAR table[] = { 'T','y','p','e','L','i','b',0 }; - return msi_unimplemented_action_stub( package, "UnregisterTypeLibraries", table ); -} - typedef UINT (*STANDARDACTIONHANDLER)(MSIPACKAGE*); static const struct @@ -6335,13 +6938,13 @@ StandardActions[] = { szCreateFolders, ACTION_CreateFolders }, { szCreateShortcuts, ACTION_CreateShortcuts }, { szDeleteServices, ACTION_DeleteServices }, - { szDisableRollback, NULL }, + { szDisableRollback, ACTION_DisableRollback }, { szDuplicateFiles, ACTION_DuplicateFiles }, { szExecuteAction, ACTION_ExecuteAction }, { szFileCost, ACTION_FileCost }, { szFindRelatedProducts, ACTION_FindRelatedProducts }, { szForceReboot, ACTION_ForceReboot }, - { szInstallAdminPackage, NULL }, + { szInstallAdminPackage, ACTION_InstallAdminPackage }, { szInstallExecute, ACTION_InstallExecute }, { szInstallExecuteAgain, ACTION_InstallExecute }, { szInstallFiles, ACTION_InstallFiles}, diff --git a/dll/win32/msi/appsearch.c b/dll/win32/msi/appsearch.c index c4e4e588077..12c741178e3 100644 --- a/dll/win32/msi/appsearch.c +++ b/dll/win32/msi/appsearch.c @@ -1026,13 +1026,15 @@ static UINT ACTION_AppSearchSigName(MSIPACKAGE *package, LPCWSTR sigName, static UINT iterate_appsearch(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - LPWSTR propName, sigName, value = NULL; + LPCWSTR propName, sigName; + LPWSTR value = NULL; MSISIGNATURE sig; + MSIRECORD *uirow; UINT r; /* get property and signature */ - propName = msi_dup_record_field(row,1); - sigName = msi_dup_record_field(row,2); + propName = MSI_RecordGetString(row, 1); + sigName = MSI_RecordGetString(row, 2); TRACE("%s %s\n", debugstr_w(propName), debugstr_w(sigName)); @@ -1043,8 +1045,12 @@ static UINT iterate_appsearch(MSIRECORD *row, LPVOID param) msi_free(value); } ACTION_FreeSignature(&sig); - msi_free(propName); - msi_free(sigName); + + uirow = MSI_CreateRecord( 2 ); + MSI_RecordSetStringW( uirow, 1, propName ); + MSI_RecordSetStringW( uirow, 2, sigName ); + ui_actiondata( package, szAppSearch, uirow ); + msiobj_release( &uirow->hdr ); return r; } diff --git a/dll/win32/msi/classes.c b/dll/win32/msi/classes.c index 6ca35b9735a..acd8429bec4 100644 --- a/dll/win32/msi/classes.c +++ b/dll/win32/msi/classes.c @@ -809,16 +809,17 @@ UINT ACTION_RegisterClassInfo(MSIPACKAGE *package) continue; feature = cls->Feature; + if (!feature) + continue; /* * MSDN says that these are based on Feature not on Component. */ - if (!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL ) && - !ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED )) + if (feature->ActionRequest != INSTALLSTATE_LOCAL && + feature->ActionRequest != INSTALLSTATE_ADVERTISED ) { - TRACE("Skipping class %s reg due to disabled feature %s\n", - debugstr_w(cls->clsid), debugstr_w(feature->Feature)); - + TRACE("Feature %s not scheduled for installation, skipping regstration of class %s\n", + debugstr_w(feature->Feature), debugstr_w(cls->clsid)); continue; } @@ -1142,18 +1143,18 @@ UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package) continue; feature = ext->Feature; + if (!feature) + continue; /* * yes. MSDN says that these are based on _Feature_ not on * Component. So verify the feature is to be installed */ - if ((!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL )) && - !(install_on_demand && - ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED ))) + if (feature->ActionRequest != INSTALLSTATE_LOCAL && + !(install_on_demand && feature->ActionRequest == INSTALLSTATE_ADVERTISED)) { - TRACE("Skipping extension %s reg due to disabled feature %s\n", - debugstr_w(ext->Extension), debugstr_w(feature->Feature)); - + TRACE("Feature %s not scheduled for installation, skipping registration of extension %s\n", + debugstr_w(feature->Feature), debugstr_w(ext->Extension)); continue; } diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c index 2b2a3e1373f..584c0507c53 100644 --- a/dll/win32/msi/custom.c +++ b/dll/win32/msi/custom.c @@ -1120,38 +1120,44 @@ static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source, static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source, LPCWSTR target, const INT type, LPCWSTR action) { - LPWSTR filename, deformated; + LPWSTR workingdir, filename; STARTUPINFOW si; PROCESS_INFORMATION info; BOOL rc; - memset(&si,0,sizeof(STARTUPINFOW)); + memset(&si, 0, sizeof(STARTUPINFOW)); - filename = resolve_folder(package, source, FALSE, FALSE, TRUE, NULL); + workingdir = resolve_folder(package, source, FALSE, FALSE, TRUE, NULL); + + if (!workingdir) + return ERROR_FUNCTION_FAILED; + + deformat_string(package, target, &filename); if (!filename) + { + msi_free(workingdir); return ERROR_FUNCTION_FAILED; + } - SetCurrentDirectoryW(filename); - msi_free(filename); + TRACE("executing exe %s with working directory %s\n", + debugstr_w(filename), debugstr_w(workingdir)); - deformat_string(package,target,&deformated); - - if (!deformated) - return ERROR_FUNCTION_FAILED; - - TRACE("executing exe %s\n", debugstr_w(deformated)); - - rc = CreateProcessW(NULL, deformated, NULL, NULL, FALSE, 0, NULL, - c_collen, &si, &info); + rc = CreateProcessW(NULL, filename, NULL, NULL, FALSE, 0, NULL, + workingdir, &si, &info); if ( !rc ) { - ERR("Unable to execute command %s\n", debugstr_w(deformated)); - msi_free(deformated); + ERR("Unable to execute command %s with working directory %s\n", + debugstr_w(filename), debugstr_w(workingdir)); + msi_free(filename); + msi_free(workingdir); return ERROR_SUCCESS; } - msi_free(deformated); + + msi_free(filename); + msi_free(workingdir); + CloseHandle( info.hThread ); return wait_process_handle(package, type, info.hProcess, action); diff --git a/dll/win32/msi/database.c b/dll/win32/msi/database.c index 7855fea9186..8ec2411cb59 100644 --- a/dll/win32/msi/database.c +++ b/dll/win32/msi/database.c @@ -125,20 +125,14 @@ static UINT clone_open_stream( MSIDATABASE *db, LPCWSTR name, IStream **stm ) UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm ) { - LPWSTR encname; HRESULT r; - encname = encode_streamname(FALSE, stname); + TRACE("%s\n", debugstr_w(stname)); - TRACE("%s -> %s\n",debugstr_w(stname),debugstr_w(encname)); - - if (clone_open_stream( db, encname, stm ) == ERROR_SUCCESS) - { - msi_free( encname ); + if (clone_open_stream( db, stname, stm ) == ERROR_SUCCESS) return ERROR_SUCCESS; - } - r = IStorage_OpenStream( db->storage, encname, NULL, + r = IStorage_OpenStream( db->storage, stname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, stm ); if( FAILED( r ) ) { @@ -147,15 +141,13 @@ UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm ) LIST_FOR_EACH_ENTRY( transform, &db->transforms, MSITRANSFORM, entry ) { TRACE("looking for %s in transform storage\n", debugstr_w(stname) ); - r = IStorage_OpenStream( transform->stg, encname, NULL, + r = IStorage_OpenStream( transform->stg, stname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, stm ); if (SUCCEEDED(r)) break; } } - msi_free( encname ); - if( SUCCEEDED(r) ) { MSISTREAM *stream; @@ -181,10 +173,15 @@ UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname, ULONG sz, count; IStream *stm = NULL; STATSTG stat; + LPWSTR encname; + + encname = encode_streamname( FALSE, stname ); + r = db_get_raw_stream( db, encname, &stm ); + msi_free( encname ); - r = db_get_raw_stream( db, stname, &stm ); if( r != ERROR_SUCCESS) return ret; + r = IStream_Stat(stm, &stat, STATFLAG_NONAME ); if( FAILED( r ) ) { @@ -225,16 +222,6 @@ end: return ret; } -void append_storage_to_db( MSIDATABASE *db, IStorage *stg ) -{ - MSITRANSFORM *t; - - t = msi_alloc( sizeof *t ); - t->stg = stg; - IStorage_AddRef( stg ); - list_add_tail( &db->transforms, &t->entry ); -} - static void free_transforms( MSIDATABASE *db ) { while( !list_empty( &db->transforms ) ) @@ -259,6 +246,19 @@ static void free_streams( MSIDATABASE *db ) } } +void append_storage_to_db( MSIDATABASE *db, IStorage *stg ) +{ + MSITRANSFORM *t; + + t = msi_alloc( sizeof *t ); + t->stg = stg; + IStorage_AddRef( stg ); + list_add_tail( &db->transforms, &t->entry ); + + /* the transform may add or replace streams */ + free_streams( db ); +} + static VOID MSI_CloseDatabase( MSIOBJECTHDR *arg ) { MSIDATABASE *db = (MSIDATABASE *) arg; diff --git a/dll/win32/msi/dialog.c b/dll/win32/msi/dialog.c index 5fd4bbd138b..ac2e95af91f 100644 --- a/dll/win32/msi/dialog.c +++ b/dll/win32/msi/dialog.c @@ -801,11 +801,31 @@ static UINT msi_dialog_text_control( msi_dialog *dialog, MSIRECORD *rec ) return ERROR_SUCCESS; } +/* strip any leading text style label from text field */ +static WCHAR *msi_get_binary_name( MSIPACKAGE *package, MSIRECORD *rec ) +{ + WCHAR *p, *text; + + text = msi_get_deformatted_field( package, rec, 10 ); + if (!text) + return NULL; + + p = text; + while (*p && *p != '{') p++; + if (!*p++) return text; + + while (*p && *p != '}') p++; + if (!*p++) return text; + + p = strdupW( p ); + msi_free( text ); + return p; +} + static UINT msi_dialog_button_control( msi_dialog *dialog, MSIRECORD *rec ) { msi_control *control; UINT attributes, style; - LPWSTR text; TRACE("%p %p\n", dialog, rec); @@ -820,12 +840,19 @@ static UINT msi_dialog_button_control( msi_dialog *dialog, MSIRECORD *rec ) control->handler = msi_dialog_button_handler; - /* set the icon */ - text = msi_get_deformatted_field( dialog->package, rec, 10 ); - control->hIcon = msi_load_icon( dialog->package->db, text, attributes ); - if( attributes & msidbControlAttributesIcon ) - SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) control->hIcon ); - msi_free( text ); + if (attributes & msidbControlAttributesIcon) + { + /* set the icon */ + LPWSTR name = msi_get_binary_name( dialog->package, rec ); + control->hIcon = msi_load_icon( dialog->package->db, name, attributes ); + if (control->hIcon) + { + SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) control->hIcon ); + } + else + ERR("Failed to load icon %s\n", debugstr_w(name)); + msi_free( name ); + } return ERROR_SUCCESS; } @@ -1142,7 +1169,7 @@ static UINT msi_dialog_bitmap_control( msi_dialog *dialog, MSIRECORD *rec ) { UINT cx, cy, flags, style, attributes; msi_control *control; - LPWSTR text; + LPWSTR name; flags = LR_LOADFROMFILE; style = SS_BITMAP | SS_LEFT | WS_GROUP; @@ -1160,15 +1187,15 @@ static UINT msi_dialog_bitmap_control( msi_dialog *dialog, MSIRECORD *rec ) cx = msi_dialog_scale_unit( dialog, cx ); cy = msi_dialog_scale_unit( dialog, cy ); - text = msi_get_deformatted_field( dialog->package, rec, 10 ); - control->hBitmap = msi_load_picture( dialog->package->db, text, cx, cy, flags ); + name = msi_get_binary_name( dialog->package, rec ); + control->hBitmap = msi_load_picture( dialog->package->db, name, cx, cy, flags ); if( control->hBitmap ) SendMessageW( control->hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) control->hBitmap ); else - ERR("Failed to load bitmap %s\n", debugstr_w(text)); + ERR("Failed to load bitmap %s\n", debugstr_w(name)); - msi_free( text ); + msi_free( name ); return ERROR_SUCCESS; } @@ -1177,7 +1204,7 @@ static UINT msi_dialog_icon_control( msi_dialog *dialog, MSIRECORD *rec ) { msi_control *control; DWORD attributes; - LPWSTR text; + LPWSTR name; TRACE("\n"); @@ -1185,13 +1212,13 @@ static UINT msi_dialog_icon_control( msi_dialog *dialog, MSIRECORD *rec ) SS_ICON | SS_CENTERIMAGE | WS_GROUP ); attributes = MSI_RecordGetInteger( rec, 8 ); - text = msi_get_deformatted_field( dialog->package, rec, 10 ); - control->hIcon = msi_load_icon( dialog->package->db, text, attributes ); + name = msi_get_binary_name( dialog->package, rec ); + control->hIcon = msi_load_icon( dialog->package->db, name, attributes ); if( control->hIcon ) SendMessageW( control->hwnd, STM_SETICON, (WPARAM) control->hIcon, 0 ); else - ERR("Failed to load bitmap %s\n", debugstr_w(text)); - msi_free( text ); + ERR("Failed to load bitmap %s\n", debugstr_w(name)); + msi_free( name ); return ERROR_SUCCESS; } diff --git a/dll/win32/msi/events.c b/dll/win32/msi/events.c index f4697dd0a34..e8f22975594 100644 --- a/dll/win32/msi/events.c +++ b/dll/win32/msi/events.c @@ -386,9 +386,6 @@ static UINT ControlEvent_ReinstallMode(MSIPACKAGE *package, LPCWSTR argument, static UINT ControlEvent_ValidateProductID(MSIPACKAGE *package, LPCWSTR argument, msi_dialog *dialog) { - static const WCHAR szProductID[] = {'P','r','o','d','u','c','t','I','D',0}; - static const WCHAR szPIDTemplate[] = {'P','I','D','T','e','m','p','l','a','t','e',0}; - static const WCHAR szPIDKEY[] = {'P','I','D','K','E','Y',0}; LPWSTR key, template; UINT ret = ERROR_SUCCESS; diff --git a/dll/win32/msi/files.c b/dll/win32/msi/files.c index b7af4d39416..40501636af2 100644 --- a/dll/win32/msi/files.c +++ b/dll/win32/msi/files.c @@ -24,10 +24,10 @@ * * InstallFiles * DuplicateFiles - * MoveFiles (TODO) + * MoveFiles * PatchFiles (TODO) - * RemoveDuplicateFiles(TODO) - * RemoveFiles(TODO) + * RemoveDuplicateFiles + * RemoveFiles */ #include @@ -85,30 +85,13 @@ static int msi_compare_file_version(MSIFILE *file) return lstrcmpW(version, file->Version); } -static UINT get_file_target(MSIPACKAGE *package, LPCWSTR file_key, - MSIFILE** file) -{ - LIST_FOR_EACH_ENTRY( *file, &package->files, MSIFILE, entry ) - { - if (lstrcmpW( file_key, (*file)->File )==0) - { - if ((*file)->state >= msifs_overwrite) - return ERROR_SUCCESS; - else - return ERROR_FILE_NOT_FOUND; - } - } - - return ERROR_FUNCTION_FAILED; -} - static void schedule_install_files(MSIPACKAGE *package) { MSIFILE *file; LIST_FOR_EACH_ENTRY(file, &package->files, MSIFILE, entry) { - if (!ACTION_VerifyComponentForAction(file->Component, INSTALLSTATE_LOCAL)) + if (file->Component->ActionRequest != INSTALLSTATE_LOCAL) { TRACE("File %s is not scheduled for install\n", debugstr_w(file->File)); @@ -345,32 +328,420 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package) return rc; } +#define is_dot_dir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0)))) + +typedef struct +{ + struct list entry; + LPWSTR sourcename; + LPWSTR destname; + LPWSTR source; + LPWSTR dest; +} FILE_LIST; + +static BOOL msi_move_file(LPCWSTR source, LPCWSTR dest, int options) +{ + BOOL ret; + + if (GetFileAttributesW(source) == FILE_ATTRIBUTE_DIRECTORY || + GetFileAttributesW(dest) == FILE_ATTRIBUTE_DIRECTORY) + { + WARN("Source or dest is directory, not moving\n"); + return FALSE; + } + + if (options == msidbMoveFileOptionsMove) + { + TRACE("moving %s -> %s\n", debugstr_w(source), debugstr_w(dest)); + ret = MoveFileExW(source, dest, MOVEFILE_REPLACE_EXISTING); + if (!ret) + { + WARN("MoveFile failed: %d\n", GetLastError()); + return FALSE; + } + } + else + { + TRACE("copying %s -> %s\n", debugstr_w(source), debugstr_w(dest)); + ret = CopyFileW(source, dest, FALSE); + if (!ret) + { + WARN("CopyFile failed: %d\n", GetLastError()); + return FALSE; + } + } + + return TRUE; +} + +static LPWSTR wildcard_to_file(LPWSTR wildcard, LPWSTR filename) +{ + LPWSTR path, ptr; + DWORD dirlen, pathlen; + + ptr = strrchrW(wildcard, '\\'); + dirlen = ptr - wildcard + 1; + + pathlen = dirlen + lstrlenW(filename) + 1; + path = msi_alloc(pathlen * sizeof(WCHAR)); + + lstrcpynW(path, wildcard, dirlen + 1); + lstrcatW(path, filename); + + return path; +} + +static void free_file_entry(FILE_LIST *file) +{ + msi_free(file->source); + msi_free(file->dest); + msi_free(file); +} + +static void free_list(FILE_LIST *list) +{ + while (!list_empty(&list->entry)) + { + FILE_LIST *file = LIST_ENTRY(list_head(&list->entry), FILE_LIST, entry); + + list_remove(&file->entry); + free_file_entry(file); + } +} + +static BOOL add_wildcard(FILE_LIST *files, LPWSTR source, LPWSTR dest) +{ + FILE_LIST *new, *file; + LPWSTR ptr, filename; + DWORD size; + + new = msi_alloc_zero(sizeof(FILE_LIST)); + if (!new) + return FALSE; + + new->source = strdupW(source); + ptr = strrchrW(dest, '\\') + 1; + filename = strrchrW(new->source, '\\') + 1; + + new->sourcename = filename; + + if (*ptr) + new->destname = ptr; + else + new->destname = new->sourcename; + + size = (ptr - dest) + lstrlenW(filename) + 1; + new->dest = msi_alloc(size * sizeof(WCHAR)); + if (!new->dest) + { + free_file_entry(new); + return FALSE; + } + + lstrcpynW(new->dest, dest, ptr - dest + 1); + lstrcatW(new->dest, filename); + + if (list_empty(&files->entry)) + { + list_add_head(&files->entry, &new->entry); + return TRUE; + } + + LIST_FOR_EACH_ENTRY(file, &files->entry, FILE_LIST, entry) + { + if (lstrcmpW(source, file->source) < 0) + { + list_add_before(&file->entry, &new->entry); + return TRUE; + } + } + + list_add_after(&file->entry, &new->entry); + return TRUE; +} + +static BOOL move_files_wildcard(LPWSTR source, LPWSTR dest, int options) +{ + WIN32_FIND_DATAW wfd; + HANDLE hfile; + LPWSTR path; + BOOL res; + FILE_LIST files, *file; + DWORD size; + + hfile = FindFirstFileW(source, &wfd); + if (hfile == INVALID_HANDLE_VALUE) return FALSE; + + list_init(&files.entry); + + for (res = TRUE; res; res = FindNextFileW(hfile, &wfd)) + { + if (is_dot_dir(wfd.cFileName)) continue; + + path = wildcard_to_file(source, wfd.cFileName); + if (!path) + { + res = FALSE; + goto done; + } + + add_wildcard(&files, path, dest); + msi_free(path); + } + + /* no files match the wildcard */ + if (list_empty(&files.entry)) + goto done; + + /* only the first wildcard match gets renamed to dest */ + file = LIST_ENTRY(list_head(&files.entry), FILE_LIST, entry); + size = (strrchrW(file->dest, '\\') - file->dest) + lstrlenW(file->destname) + 2; + file->dest = msi_realloc(file->dest, size * sizeof(WCHAR)); + if (!file->dest) + { + res = FALSE; + goto done; + } + + /* file->dest may be shorter after the reallocation, so add a NULL + * terminator. This is needed for the call to strrchrW, as there will no + * longer be a NULL terminator within the bounds of the allocation in this case. + */ + file->dest[size - 1] = '\0'; + lstrcpyW(strrchrW(file->dest, '\\') + 1, file->destname); + + while (!list_empty(&files.entry)) + { + file = LIST_ENTRY(list_head(&files.entry), FILE_LIST, entry); + + msi_move_file(file->source, file->dest, options); + + list_remove(&file->entry); + free_file_entry(file); + } + + res = TRUE; + +done: + free_list(&files); + FindClose(hfile); + return res; +} + +static UINT ITERATE_MoveFiles( MSIRECORD *rec, LPVOID param ) +{ + MSIPACKAGE *package = param; + MSIRECORD *uirow; + MSICOMPONENT *comp; + LPCWSTR sourcename, component; + LPWSTR sourcedir, destname = NULL, destdir = NULL, source = NULL, dest = NULL; + int options; + DWORD size; + BOOL ret, wildcards; + + component = MSI_RecordGetString(rec, 2); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL && comp->ActionRequest != INSTALLSTATE_SOURCE) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = comp->ActionRequest; + + sourcename = MSI_RecordGetString(rec, 3); + options = MSI_RecordGetInteger(rec, 7); + + sourcedir = msi_dup_property(package, MSI_RecordGetString(rec, 5)); + if (!sourcedir) + goto done; + + destdir = msi_dup_property(package, MSI_RecordGetString(rec, 6)); + if (!destdir) + goto done; + + if (!sourcename) + { + if (GetFileAttributesW(sourcedir) == INVALID_FILE_ATTRIBUTES) + goto done; + + source = strdupW(sourcedir); + if (!source) + goto done; + } + else + { + size = lstrlenW(sourcedir) + lstrlenW(sourcename) + 2; + source = msi_alloc(size * sizeof(WCHAR)); + if (!source) + goto done; + + lstrcpyW(source, sourcedir); + if (source[lstrlenW(source) - 1] != '\\') + lstrcatW(source, szBackSlash); + lstrcatW(source, sourcename); + } + + wildcards = strchrW(source, '*') || strchrW(source, '?'); + + if (MSI_RecordIsNull(rec, 4)) + { + if (!wildcards) + { + destname = strdupW(sourcename); + if (!destname) + goto done; + } + } + else + { + destname = strdupW(MSI_RecordGetString(rec, 4)); + if (destname) + reduce_to_longfilename(destname); + } + + size = 0; + if (destname) + size = lstrlenW(destname); + + size += lstrlenW(destdir) + 2; + dest = msi_alloc(size * sizeof(WCHAR)); + if (!dest) + goto done; + + lstrcpyW(dest, destdir); + if (dest[lstrlenW(dest) - 1] != '\\') + lstrcatW(dest, szBackSlash); + + if (destname) + lstrcatW(dest, destname); + + if (GetFileAttributesW(destdir) == INVALID_FILE_ATTRIBUTES) + { + ret = CreateDirectoryW(destdir, NULL); + if (!ret) + { + WARN("CreateDirectory failed: %d\n", GetLastError()); + goto done; + } + } + + if (!wildcards) + msi_move_file(source, dest, options); + else + move_files_wildcard(source, dest, options); + +done: + uirow = MSI_CreateRecord( 9 ); + MSI_RecordSetStringW( uirow, 1, MSI_RecordGetString(rec, 1) ); + MSI_RecordSetInteger( uirow, 6, 1 ); /* FIXME */ + MSI_RecordSetStringW( uirow, 9, destdir ); + ui_actiondata( package, szMoveFiles, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free(sourcedir); + msi_free(destdir); + msi_free(destname); + msi_free(source); + msi_free(dest); + + return ERROR_SUCCESS; +} + +UINT ACTION_MoveFiles( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + + static const WCHAR ExecSeqQuery[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','M','o','v','e','F','i','l','e','`',0}; + + rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords(view, NULL, ITERATE_MoveFiles, package); + msiobj_release(&view->hdr); + + return rc; +} + +static WCHAR *get_duplicate_filename( MSIPACKAGE *package, MSIRECORD *row, const WCHAR *file_key, const WCHAR *src ) +{ + DWORD len; + WCHAR *dst_name, *dst_path, *dst; + + if (MSI_RecordIsNull( row, 4 )) + { + len = strlenW( src ) + 1; + if (!(dst_name = msi_alloc( len * sizeof(WCHAR)))) return NULL; + strcpyW( dst_name, strrchrW( src, '\\' ) + 1 ); + } + else + { + MSI_RecordGetStringW( row, 4, NULL, &len ); + if (!(dst_name = msi_alloc( ++len * sizeof(WCHAR) ))) return NULL; + MSI_RecordGetStringW( row, 4, dst_name, &len ); + reduce_to_longfilename( dst_name ); + } + + if (MSI_RecordIsNull( row, 5 )) + { + WCHAR *p; + dst_path = strdupW( src ); + p = strrchrW( dst_path, '\\' ); + if (p) *p = 0; + } + else + { + const WCHAR *dst_key = MSI_RecordGetString( row, 5 ); + + dst_path = resolve_folder( package, dst_key, FALSE, FALSE, TRUE, NULL ); + if (!dst_path) + { + /* try a property */ + dst_path = msi_dup_property( package, dst_key ); + if (!dst_path) + { + FIXME("Unable to get destination folder, try AppSearch properties\n"); + msi_free( dst_name ); + return NULL; + } + } + } + + dst = build_directory_name( 2, dst_path, dst_name ); + create_full_pathW( dst_path ); + + msi_free( dst_name ); + msi_free( dst_path ); + return dst; +} + static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - WCHAR dest_name[0x100]; - LPWSTR dest_path, dest; + LPWSTR dest; LPCWSTR file_key, component; - DWORD sz; - DWORD rc; MSICOMPONENT *comp; + MSIRECORD *uirow; MSIFILE *file; component = MSI_RecordGetString(row,2); comp = get_loaded_component(package,component); + if (!comp) + return ERROR_SUCCESS; - if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL )) + if (comp->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping copy due to disabled component %s\n", - debugstr_w(component)); - - /* the action taken was the same as the current install state */ - if (comp) - comp->Action = comp->Installed; - + TRACE("Component not scheduled for installation %s\n", debugstr_w(component)); + comp->Action = comp->Installed; return ERROR_SUCCESS; } - comp->Action = INSTALLSTATE_LOCAL; file_key = MSI_RecordGetString(row,3); @@ -380,70 +751,38 @@ static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param) return ERROR_FUNCTION_FAILED; } - rc = get_file_target(package,file_key,&file); - - if (rc != ERROR_SUCCESS) + file = get_loaded_file( package, file_key ); + if (!file) { - ERR("Original file unknown %s\n",debugstr_w(file_key)); + ERR("Original file unknown %s\n", debugstr_w(file_key)); return ERROR_SUCCESS; } - if (MSI_RecordIsNull(row,4)) - strcpyW(dest_name,strrchrW(file->TargetPath,'\\')+1); - else + dest = get_duplicate_filename( package, row, file_key, file->TargetPath ); + if (!dest) { - sz=0x100; - MSI_RecordGetStringW(row,4,dest_name,&sz); - reduce_to_longfilename(dest_name); + WARN("Unable to get duplicate filename\n"); + return ERROR_SUCCESS; } - if (MSI_RecordIsNull(row,5)) + TRACE("Duplicating file %s to %s\n", debugstr_w(file->TargetPath), debugstr_w(dest)); + + if (!CopyFileW( file->TargetPath, dest, TRUE )) { - LPWSTR p; - dest_path = strdupW(file->TargetPath); - p = strrchrW(dest_path,'\\'); - if (p) - *p=0; + WARN("Failed to copy file %s -> %s (%u)\n", + debugstr_w(file->TargetPath), debugstr_w(dest), GetLastError()); } - else - { - LPCWSTR destkey; - destkey = MSI_RecordGetString(row,5); - dest_path = resolve_folder(package, destkey, FALSE, FALSE, TRUE, NULL); - if (!dest_path) - { - /* try a Property */ - dest_path = msi_dup_property( package, destkey ); - if (!dest_path) - { - FIXME("Unable to get destination folder, try AppSearch properties\n"); - return ERROR_SUCCESS; - } - } - } - - dest = build_directory_name(2, dest_path, dest_name); - create_full_pathW(dest_path); - - TRACE("Duplicating file %s to %s\n",debugstr_w(file->TargetPath), - debugstr_w(dest)); - - if (strcmpW(file->TargetPath,dest)) - rc = !CopyFileW(file->TargetPath,dest,TRUE); - else - rc = ERROR_SUCCESS; - - if (rc != ERROR_SUCCESS) - ERR("Failed to copy file %s -> %s, last error %d\n", - debugstr_w(file->TargetPath), debugstr_w(dest_path), GetLastError()); FIXME("We should track these duplicate files as well\n"); - msi_free(dest_path); + uirow = MSI_CreateRecord( 9 ); + MSI_RecordSetStringW( uirow, 1, MSI_RecordGetString( row, 1 ) ); + MSI_RecordSetInteger( uirow, 6, file->FileSize ); + MSI_RecordSetStringW( uirow, 9, MSI_RecordGetString( row, 5 ) ); + ui_actiondata( package, szDuplicateFiles, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(dest); - - msi_file_update_ui(package, file, szDuplicateFiles); - return ERROR_SUCCESS; } @@ -465,6 +804,84 @@ UINT ACTION_DuplicateFiles(MSIPACKAGE *package) return rc; } +static UINT ITERATE_RemoveDuplicateFiles( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPWSTR dest; + LPCWSTR file_key, component; + MSICOMPONENT *comp; + MSIRECORD *uirow; + MSIFILE *file; + + component = MSI_RecordGetString( row, 2 ); + comp = get_loaded_component( package, component ); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; + + file_key = MSI_RecordGetString( row, 3 ); + if (!file_key) + { + ERR("Unable to get file key\n"); + return ERROR_FUNCTION_FAILED; + } + + file = get_loaded_file( package, file_key ); + if (!file) + { + ERR("Original file unknown %s\n", debugstr_w(file_key)); + return ERROR_SUCCESS; + } + + dest = get_duplicate_filename( package, row, file_key, file->TargetPath ); + if (!dest) + { + WARN("Unable to get duplicate filename\n"); + return ERROR_SUCCESS; + } + + TRACE("Removing duplicate %s of %s\n", debugstr_w(dest), debugstr_w(file->TargetPath)); + + if (!DeleteFileW( dest )) + { + WARN("Failed to delete duplicate file %s (%u)\n", debugstr_w(dest), GetLastError()); + } + + uirow = MSI_CreateRecord( 9 ); + MSI_RecordSetStringW( uirow, 1, MSI_RecordGetString( row, 1 ) ); + MSI_RecordSetStringW( uirow, 9, MSI_RecordGetString( row, 5 ) ); + ui_actiondata( package, szRemoveDuplicateFiles, uirow ); + msiobj_release( &uirow->hdr ); + + msi_free(dest); + return ERROR_SUCCESS; +} + +UINT ACTION_RemoveDuplicateFiles( MSIPACKAGE *package ) +{ + UINT rc; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0}; + + rc = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (rc != ERROR_SUCCESS) + return ERROR_SUCCESS; + + rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveDuplicateFiles, package ); + msiobj_release( &view->hdr ); + + return rc; +} + static BOOL verify_comp_for_removal(MSICOMPONENT *comp, UINT install_mode) { INSTALLSTATE request = comp->ActionRequest; @@ -495,6 +912,7 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; MSICOMPONENT *comp; + MSIRECORD *uirow; LPCWSTR component, filename, dirprop; UINT install_mode; LPWSTR dir = NULL, path = NULL; @@ -533,11 +951,10 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param) goto done; } - lstrcpyW(path, dir); - PathAddBackslashW(path); - if (filename) { + lstrcpyW(path, dir); + PathAddBackslashW(path); lstrcatW(path, filename); TRACE("Deleting misc file: %s\n", debugstr_w(path)); @@ -545,11 +962,17 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param) } else { - TRACE("Removing misc directory: %s\n", debugstr_w(path)); - RemoveDirectoryW(path); + TRACE("Removing misc directory: %s\n", debugstr_w(dir)); + RemoveDirectoryW(dir); } done: + uirow = MSI_CreateRecord( 9 ); + MSI_RecordSetStringW( uirow, 1, MSI_RecordGetString(row, 1) ); + MSI_RecordSetStringW( uirow, 9, dir ); + ui_actiondata( package, szRemoveFiles, uirow ); + msiobj_release( &uirow->hdr ); + msi_free(path); msi_free(dir); return ERROR_SUCCESS; @@ -564,6 +987,9 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package ) static const WCHAR query[] = { 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', '`','R','e','m','o','v','e','F','i','l','e','`',0}; + static const WCHAR folder_query[] = { + 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0}; r = MSI_DatabaseOpenViewW(package->db, query, &view); if (r == ERROR_SUCCESS) @@ -572,10 +998,14 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package ) msiobj_release(&view->hdr); } + r = MSI_DatabaseOpenViewW(package->db, folder_query, &view); + if (r == ERROR_SUCCESS) + msiobj_release(&view->hdr); + LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry ) { MSIRECORD *uirow; - LPWSTR uipath, p; + LPWSTR dir, uipath, p; if ( file->state == msifs_installed ) ERR("removing installed file %s\n", debugstr_w(file->TargetPath)); @@ -591,8 +1021,17 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package ) continue; TRACE("removing %s\n", debugstr_w(file->File) ); - if ( !DeleteFileW( file->TargetPath ) ) - TRACE("failed to delete %s\n", debugstr_w(file->TargetPath)); + if (!DeleteFileW( file->TargetPath )) + { + WARN("failed to delete %s\n", debugstr_w(file->TargetPath)); + } + /* FIXME: check persistence for each directory */ + else if (r && (dir = strdupW( file->TargetPath ))) + { + if ((p = strrchrW( dir, '\\' ))) *p = 0; + RemoveDirectoryW( dir ); + msi_free( dir ); + } file->state = msifs_missing; /* the UI chunk */ diff --git a/dll/win32/msi/font.c b/dll/win32/msi/font.c index 085d400a7b9..1b2c3c729dd 100644 --- a/dll/win32/msi/font.c +++ b/dll/win32/msi/font.c @@ -66,6 +66,21 @@ typedef struct _tagTT_NAME_RECORD { static const WCHAR szRegisterFonts[] = {'R','e','g','i','s','t','e','r','F','o','n','t','s',0}; +static const WCHAR szUnregisterFonts[] = + {'U','n','r','e','g','i','s','t','e','r','F','o','n','t','s',0}; + +static const WCHAR regfont1[] = + {'S','o','f','t','w','a','r','e','\\', + 'M','i','c','r','o','s','o','f','t','\\', + 'W','i','n','d','o','w','s',' ','N','T','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', + 'F','o','n','t','s',0}; +static const WCHAR regfont2[] = + {'S','o','f','t','w','a','r','e','\\', + 'M','i','c','r','o','s','o','f','t','\\', + 'W','i','n','d','o','w','s','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', + 'F','o','n','t','s',0}; /* * Code based off of code located here @@ -174,20 +189,7 @@ static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param) LPWSTR name; LPCWSTR filename; MSIFILE *file; - static const WCHAR regfont1[] = - {'S','o','f','t','w','a','r','e','\\', - 'M','i','c','r','o','s','o','f','t','\\', - 'W','i','n','d','o','w','s',' ','N','T','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', - 'F','o','n','t','s',0}; - static const WCHAR regfont2[] = - {'S','o','f','t','w','a','r','e','\\', - 'M','i','c','r','o','s','o','f','t','\\', - 'W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', - 'F','o','n','t','s',0}; - HKEY hkey1; - HKEY hkey2; + HKEY hkey1, hkey2; MSIRECORD *uirow; LPWSTR uipath, p; @@ -199,10 +201,9 @@ static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param) return ERROR_SUCCESS; } - /* check to make sure that component is installed */ - if (!ACTION_VerifyComponentForAction( file->Component, INSTALLSTATE_LOCAL)) + if (file->Component->ActionRequest != INSTALLSTATE_LOCAL) { - TRACE("Skipping: Component not scheduled for install\n"); + TRACE("Component not scheduled for installation\n"); return ERROR_SUCCESS; } @@ -259,3 +260,81 @@ UINT ACTION_RegisterFonts(MSIPACKAGE *package) return ERROR_SUCCESS; } + +static UINT ITERATE_UnregisterFonts( MSIRECORD *row, LPVOID param ) +{ + MSIPACKAGE *package = param; + LPWSTR name; + LPCWSTR filename; + MSIFILE *file; + HKEY hkey1, hkey2; + MSIRECORD *uirow; + LPWSTR uipath, p; + + filename = MSI_RecordGetString( row, 1 ); + file = get_loaded_file( package, filename ); + if (!file) + { + ERR("Unable to load file\n"); + return ERROR_SUCCESS; + } + + if (file->Component->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal\n"); + return ERROR_SUCCESS; + } + + RegCreateKeyW( HKEY_LOCAL_MACHINE, regfont1, &hkey1 ); + RegCreateKeyW( HKEY_LOCAL_MACHINE, regfont2, &hkey2 ); + + if (MSI_RecordIsNull( row, 2 )) + name = load_ttfname_from( file->TargetPath ); + else + name = msi_dup_record_field( row, 2 ); + + if (name) + { + RegDeleteValueW( hkey1, name ); + RegDeleteValueW( hkey2, name ); + } + + msi_free( name ); + RegCloseKey( hkey1 ); + RegCloseKey( hkey2 ); + + /* the UI chunk */ + uirow = MSI_CreateRecord( 1 ); + uipath = strdupW( file->TargetPath ); + p = strrchrW( uipath,'\\' ); + if (p) p++; + else p = uipath; + MSI_RecordSetStringW( uirow, 1, p ); + ui_actiondata( package, szUnregisterFonts, uirow ); + msiobj_release( &uirow->hdr ); + msi_free( uipath ); + /* FIXME: call ui_progress? */ + + return ERROR_SUCCESS; +} + +UINT ACTION_UnregisterFonts( MSIPACKAGE *package ) +{ + UINT r; + MSIQUERY *view; + static const WCHAR query[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ', + '`','F','o','n','t','`',0}; + + r = MSI_DatabaseOpenViewW( package->db, query, &view ); + if (r != ERROR_SUCCESS) + { + TRACE("MSI_DatabaseOpenViewW failed: %u\n", r); + return ERROR_SUCCESS; + } + + MSI_IterateRecords( view, NULL, ITERATE_UnregisterFonts, package ); + msiobj_release( &view->hdr ); + + return ERROR_SUCCESS; +} diff --git a/dll/win32/msi/helpers.c b/dll/win32/msi/helpers.c index e3009f7bce7..c45ba236d50 100644 --- a/dll/win32/msi/helpers.c +++ b/dll/win32/msi/helpers.c @@ -156,25 +156,6 @@ MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir ) return NULL; } -void msi_reset_folders( MSIPACKAGE *package, BOOL source ) -{ - MSIFOLDER *folder; - - LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry ) - { - if ( source ) - { - msi_free( folder->ResolvedSource ); - folder->ResolvedSource = NULL; - } - else - { - msi_free( folder->ResolvedTarget ); - folder->ResolvedTarget = NULL; - } - } -} - static LPWSTR get_source_root( MSIPACKAGE *package ) { LPWSTR path, p; @@ -604,28 +585,6 @@ void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record) msiobj_release(&row->hdr); } -BOOL ACTION_VerifyComponentForAction( const MSICOMPONENT* comp, INSTALLSTATE check ) -{ - if (!comp) - return FALSE; - - if (comp->ActionRequest == check) - return TRUE; - else - return FALSE; -} - -BOOL ACTION_VerifyFeatureForAction( const MSIFEATURE* feature, INSTALLSTATE check ) -{ - if (!feature) - return FALSE; - - if (feature->ActionRequest == check) - return TRUE; - else - return FALSE; -} - void reduce_to_longfilename(WCHAR* filename) { LPWSTR p = strchrW(filename,'|'); @@ -754,7 +713,7 @@ UINT register_unique_action(MSIPACKAGE *package, LPCWSTR action) if (!package->script) return FALSE; - TRACE("Registering Action %s as having fun\n",debugstr_w(action)); + TRACE("Registering %s as unique action\n", debugstr_w(action)); count = package->script->UniqueActionsCount; package->script->UniqueActionsCount++; diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c index b1d741a1625..c23075d61d3 100644 --- a/dll/win32/msi/install.c +++ b/dll/win32/msi/install.c @@ -661,6 +661,8 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode) MSIPACKAGE *package; BOOL r = FALSE; + TRACE("%d %d\n", hInstall, iRunMode); + package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); if (!package) { @@ -706,8 +708,16 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode) r = package->commit_action_running; break; + case MSIRUNMODE_MAINTENANCE: + r = msi_get_property_int( package, szInstalled, 0 ) != 0; + break; + + case MSIRUNMODE_REBOOTATEND: + r = package->need_reboot; + break; + default: - FIXME("%d %d\n", hInstall, iRunMode); + FIXME("unimplemented run mode: %d\n", iRunMode); r = TRUE; } @@ -719,8 +729,52 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode) */ UINT WINAPI MsiSetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode, BOOL fState) { - FIXME("%d %d %d\n", hInstall, iRunMode, fState); - return ERROR_SUCCESS; + MSIPACKAGE *package; + UINT r; + + TRACE("%d %d %d\n", hInstall, iRunMode, fState); + + package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE ); + if (!package) + { + HRESULT hr; + IWineMsiRemotePackage *remote_package; + + remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall ); + if (!remote_package) + return FALSE; + + hr = IWineMsiRemotePackage_SetMode( remote_package, iRunMode, fState ); + IWineMsiRemotePackage_Release( remote_package ); + + if (FAILED(hr)) + { + if (HRESULT_FACILITY(hr) == FACILITY_WIN32) + return HRESULT_CODE(hr); + + return ERROR_FUNCTION_FAILED; + } + + return ERROR_SUCCESS; + } + + switch (iRunMode) + { + case MSIRUNMODE_REBOOTATEND: + package->need_reboot = 1; + r = ERROR_SUCCESS; + break; + + case MSIRUNMODE_REBOOTNOW: + FIXME("unimplemented run mode: %d\n", iRunMode); + r = ERROR_FUNCTION_FAILED; + break; + + default: + r = ERROR_ACCESS_DENIED; + } + + return r; } /*********************************************************************** diff --git a/dll/win32/msi/msi.c b/dll/win32/msi/msi.c index 4d9da4cd68f..07356405718 100644 --- a/dll/win32/msi/msi.c +++ b/dll/win32/msi/msi.c @@ -1613,6 +1613,93 @@ done: return r; } +UINT WINAPI MsiGetPatchInfoA( LPCSTR patch, LPCSTR attr, LPSTR buffer, LPDWORD buflen ) +{ + UINT r = ERROR_OUTOFMEMORY; + DWORD size; + LPWSTR patchW = NULL, attrW = NULL, bufferW = NULL; + + TRACE("%s %s %p %p\n", debugstr_a(patch), debugstr_a(attr), buffer, buflen); + + if (!patch || !attr) + return ERROR_INVALID_PARAMETER; + + if (!(patchW = strdupAtoW( patch ))) + goto done; + + if (!(attrW = strdupAtoW( attr ))) + goto done; + + size = 0; + r = MsiGetPatchInfoW( patchW, attrW, NULL, &size ); + if (r != ERROR_SUCCESS) + goto done; + + size++; + if (!(bufferW = msi_alloc( size * sizeof(WCHAR) ))) + { + r = ERROR_OUTOFMEMORY; + goto done; + } + + r = MsiGetPatchInfoW( patchW, attrW, bufferW, &size ); + if (r == ERROR_SUCCESS) + { + int len = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL ); + if (len > *buflen) + r = ERROR_MORE_DATA; + else if (buffer) + WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, *buflen, NULL, NULL ); + + *buflen = len - 1; + } + +done: + msi_free( patchW ); + msi_free( attrW ); + msi_free( bufferW ); + return r; +} + +UINT WINAPI MsiGetPatchInfoW( LPCWSTR patch, LPCWSTR attr, LPWSTR buffer, LPDWORD buflen ) +{ + UINT r; + WCHAR product[GUID_SIZE]; + DWORD index; + + TRACE("%s %s %p %p\n", debugstr_w(patch), debugstr_w(attr), buffer, buflen); + + if (!patch || !attr) + return ERROR_INVALID_PARAMETER; + + if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW, attr )) + return ERROR_UNKNOWN_PROPERTY; + + index = 0; + while (1) + { + r = MsiEnumProductsW( index, product ); + if (r != ERROR_SUCCESS) + break; + + r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERMANAGED, attr, buffer, buflen ); + if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA) + return r; + + r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, attr, buffer, buflen ); + if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA) + return r; + + r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_MACHINE, attr, buffer, buflen ); + if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA) + return r; + + index++; + } + + return ERROR_UNKNOWN_PRODUCT; +} + UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes) { LPWSTR szwLogFile = NULL; diff --git a/dll/win32/msi/msi.rc b/dll/win32/msi/msi.rc index dfccd08a9a3..a12cd328670 100644 --- a/dll/win32/msi/msi.rc +++ b/dll/win32/msi/msi.rc @@ -29,28 +29,31 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include "msi_Bg.rc" #include "msi_Da.rc" -#include "msi_De.rc" #include "msi_En.rc" #include "msi_Eo.rc" #include "msi_Es.rc" #include "msi_Fi.rc" -#include "msi_Fr.rc" #include "msi_Hu.rc" -#include "msi_It.rc" #include "msi_Ko.rc" -#include "msi_Lt.rc" #include "msi_Nl.rc" #include "msi_No.rc" #include "msi_Pl.rc" #include "msi_Pt.rc" -#include "msi_Ro.rc" -#include "msi_Ru.rc" -#include "msi_Si.rc" #include "msi_Sv.rc" #include "msi_Tr.rc" #include "msi_Uk.rc" #include "msi_Zh.rc" +/* UTF-8 */ +#include "msi_De.rc" +#include "msi_Fr.rc" +#include "msi_It.rc" +#include "msi_Lt.rc" +#include "msi_Ro.rc" +#include "msi_Ru.rc" +#include "msi_Si.rc" + + LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL /* @makedep: msiserver.tlb */ diff --git a/dll/win32/msi/msi.spec b/dll/win32/msi/msi.spec index 147502811be..30daec931a6 100644 --- a/dll/win32/msi/msi.spec +++ b/dll/win32/msi/msi.spec @@ -171,8 +171,8 @@ 175 stdcall MsiApplyPatchW(wstr wstr long wstr) 176 stdcall MsiAdvertiseScriptA(str long ptr long) 177 stdcall MsiAdvertiseScriptW(wstr long ptr long) -178 stub MsiGetPatchInfoA -179 stub MsiGetPatchInfoW +178 stdcall MsiGetPatchInfoA(str str ptr ptr) +179 stdcall MsiGetPatchInfoW(wstr wstr ptr ptr) 180 stdcall MsiEnumPatchesA(str long ptr ptr ptr) 181 stdcall MsiEnumPatchesW(str long ptr ptr ptr) 182 stdcall -private DllGetVersion(ptr) diff --git a/dll/win32/msi/msi_It.rc b/dll/win32/msi/msi_It.rc index 9864806fd80..11525add056 100644 --- a/dll/win32/msi/msi_It.rc +++ b/dll/win32/msi/msi_It.rc @@ -20,17 +20,21 @@ #include "windef.h" +/*UTF-8*/ +#pragma code_page(65001) + LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { - 4 "The specified installation package could not be opened. Please check the file path and try again." + 4 "Impossibile aprire il pacchetto di installazione specificato. Per favore controlla l'indirizzo del file e riprova." 5 "percorso %s non trovato" 9 "inserire disco %s" 10 "parametri incorretti" 11 "immettere il nome della cartella che contiene %s" - 12 "sorgente di installazione per la funzionalit mancante" - 13 "periferica di rete per la funzionalit mancante" - 14 "funzionalit da:" + 12 "sorgente di installazione per la funzionalità mancante" + 13 "periferica di rete per la funzionalità mancante" + 14 "funzionalità da:" 15 "selezionare la cartella che contiene %s" } +#pragma code_page(default) diff --git a/dll/win32/msi/msipriv.h b/dll/win32/msi/msipriv.h index 43486e0a830..0516dd18da7 100644 --- a/dll/win32/msi/msipriv.h +++ b/dll/win32/msi/msipriv.h @@ -955,12 +955,15 @@ extern UINT ACTION_CCPSearch(MSIPACKAGE *package); extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package); extern UINT ACTION_InstallFiles(MSIPACKAGE *package); extern UINT ACTION_RemoveFiles(MSIPACKAGE *package); +extern UINT ACTION_MoveFiles(MSIPACKAGE *package); extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package); +extern UINT ACTION_RemoveDuplicateFiles(MSIPACKAGE *package); extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package); extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package); extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package); extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package); extern UINT ACTION_RegisterFonts(MSIPACKAGE *package); +extern UINT ACTION_UnregisterFonts(MSIPACKAGE *package); /* Helpers */ extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data ); @@ -974,15 +977,12 @@ extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Componen extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature ); extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file ); extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir ); -extern void msi_reset_folders( MSIPACKAGE *package, BOOL source ); extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path); extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action); extern void msi_free_action_script(MSIPACKAGE *package, UINT script); extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR); extern LPWSTR build_directory_name(DWORD , ...); extern BOOL create_full_pathW(const WCHAR *path); -extern BOOL ACTION_VerifyComponentForAction(const MSICOMPONENT*, INSTALLSTATE); -extern BOOL ACTION_VerifyFeatureForAction(const MSIFEATURE*, INSTALLSTATE); extern void reduce_to_longfilename(WCHAR*); extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR); extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature); @@ -1065,12 +1065,25 @@ static const WCHAR szRegisterProgIdInfo[] = {'R','e','g','i','s','t','e','r','P' static const WCHAR szRegisterExtensionInfo[] = {'R','e','g','i','s','t','e','r','E','x','t','e','n','s','i','o','n','I','n','f','o',0}; static const WCHAR szRegisterMIMEInfo[] = {'R','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0}; static const WCHAR szDuplicateFiles[] = {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0}; +static const WCHAR szRemoveDuplicateFiles[] = {'R','e','m','o','v','e','D','u','p','l','i','c','a','t','e','F','i','l','e','s',0}; static const WCHAR szInstallFiles[] = {'I','n','s','t','a','l','l','F','i','l','e','s',0}; static const WCHAR szRemoveFiles[] = {'R','e','m','o','v','e','F','i','l','e','s',0}; static const WCHAR szFindRelatedProducts[] = {'F','i','n','d','R','e','l','a','t','e','d','P','r','o','d','u','c','t','s',0}; static const WCHAR szAllUsers[] = {'A','L','L','U','S','E','R','S',0}; static const WCHAR szCustomActionData[] = {'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0}; static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0}; +static const WCHAR szProductID[] = {'P','r','o','d','u','c','t','I','D',0}; +static const WCHAR szPIDTemplate[] = {'P','I','D','T','e','m','p','l','a','t','e',0}; +static const WCHAR szPIDKEY[] = {'P','I','D','K','E','Y',0}; +static const WCHAR szTYPELIB[] = {'T','Y','P','E','L','I','B',0}; +static const WCHAR szSumInfo[] = {5 ,'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0}; +static const WCHAR szHCR[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T','\\',0}; +static const WCHAR szHCU[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','\\',0}; +static const WCHAR szHLM[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E','\\',0}; +static const WCHAR szHU[] = {'H','K','E','Y','_','U','S','E','R','S','\\',0}; +static const WCHAR szWindowsFolder[] = {'W','i','n','d','o','w','s','F','o','l','d','e','r',0}; +static const WCHAR szAppSearch[] = {'A','p','p','S','e','a','r','c','h',0}; +static const WCHAR szMoveFiles[] = {'M','o','v','e','F','i','l','e','s',0}; /* memory allocation macro functions */ static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1); diff --git a/dll/win32/msi/msiserver.idl b/dll/win32/msi/msiserver.idl index a8146957b06..25210fee155 100644 --- a/dll/win32/msi/msiserver.idl +++ b/dll/win32/msi/msiserver.idl @@ -29,7 +29,6 @@ typedef int INSTALLMESSAGE; typedef int MSICONDITION; typedef int MSIRUNMODE; typedef int INSTALLSTATE; -typedef WORD LANGID; cpp_quote("#endif") [ @@ -64,6 +63,7 @@ interface IWineMsiRemotePackage : IUnknown HRESULT SetTargetPath( [in] BSTR folder, [in] BSTR value ); HRESULT GetSourcePath( [in] BSTR folder, [out] BSTR *value, [out] DWORD *size ); HRESULT GetMode( [in] MSIRUNMODE mode, [out] BOOL *ret ); + HRESULT SetMode( [in] MSIRUNMODE mode, [in] BOOL state ); HRESULT GetFeatureState( [in] BSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action ); HRESULT SetFeatureState( [in] BSTR feature, [in] INSTALLSTATE state ); HRESULT GetComponentState( [in] BSTR component, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action ); diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c index 53804e22e56..b1741ae87cf 100644 --- a/dll/win32/msi/package.c +++ b/dll/win32/msi/package.c @@ -1621,6 +1621,25 @@ end: return r; } +static void msi_reset_folders( MSIPACKAGE *package, BOOL source ) +{ + MSIFOLDER *folder; + + LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry ) + { + if ( source ) + { + msi_free( folder->ResolvedSource ); + folder->ResolvedSource = NULL; + } + else + { + msi_free( folder->ResolvedTarget ); + folder->ResolvedTarget = NULL; + } + } +} + UINT MSI_SetPropertyW( MSIPACKAGE *package, LPCWSTR szName, LPCWSTR szValue) { MSIQUERY *view; @@ -2104,6 +2123,13 @@ static HRESULT WINAPI mrp_GetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode return S_OK; } +static HRESULT WINAPI mrp_SetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL state ) +{ + msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface ); + UINT r = MsiSetMode(This->package, mode, state); + return HRESULT_FROM_WIN32(r); +} + static HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR feature, INSTALLSTATE *installed, INSTALLSTATE *action ) { @@ -2196,6 +2222,7 @@ static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl = mrp_SetTargetPath, mrp_GetSourcePath, mrp_GetMode, + mrp_SetMode, mrp_GetFeatureState, mrp_SetFeatureState, mrp_GetComponentState, diff --git a/dll/win32/msi/streams.c b/dll/win32/msi/streams.c index 8d2e748e64d..66bda767a00 100644 --- a/dll/win32/msi/streams.c +++ b/dll/win32/msi/streams.c @@ -32,6 +32,7 @@ #include "query.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(msidb); @@ -486,7 +487,8 @@ static INT add_streams_to_table(MSISTREAMSVIEW *sv) STATSTG stat; STREAM *stream = NULL; HRESULT hr; - UINT count = 0, size; + UINT r, count = 0, size; + LPWSTR encname; hr = IStorage_EnumElements(sv->db->storage, 0, NULL, 0, &stgenum); if (FAILED(hr)) @@ -505,7 +507,10 @@ static INT add_streams_to_table(MSISTREAMSVIEW *sv) break; if (stat.type != STGTY_STREAM) + { + CoTaskMemFree(stat.pwcsName); continue; + } /* table streams are not in the _Streams table */ if (*stat.pwcsName == 0x4840) @@ -522,13 +527,22 @@ static INT add_streams_to_table(MSISTREAMSVIEW *sv) break; } - hr = IStorage_OpenStream(sv->db->storage, stat.pwcsName, 0, - STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream->stream); + /* these streams appear to be unencoded */ + if (*stat.pwcsName == 0x0005) + { + r = db_get_raw_stream(sv->db, stat.pwcsName, &stream->stream); + } + else + { + encname = encode_streamname(FALSE, stat.pwcsName); + r = db_get_raw_stream(sv->db, encname, &stream->stream); + msi_free(encname); + } CoTaskMemFree(stat.pwcsName); - if (FAILED(hr)) + if (r != ERROR_SUCCESS) { - WARN("failed to open stream: %08x\n", hr); + WARN("unable to get stream %u\n", r); count = -1; break; } diff --git a/dll/win32/msi/suminfo.c b/dll/win32/msi/suminfo.c index df35c4d0d4c..902a61f6544 100644 --- a/dll/win32/msi/suminfo.c +++ b/dll/win32/msi/suminfo.c @@ -86,9 +86,6 @@ static HRESULT (WINAPI *pPropVariantChangeType) #define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER)) -static const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y', - 'I','n','f','o','r','m','a','t','i','o','n',0 }; - static void free_prop( PROPVARIANT *prop ) { if (prop->vt == VT_LPSTR ) diff --git a/dll/win32/msi/table.c b/dll/win32/msi/table.c index cc40515e664..6737ac59168 100644 --- a/dll/win32/msi/table.c +++ b/dll/win32/msi/table.c @@ -1168,7 +1168,7 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt { MSITABLEVIEW *tv = (MSITABLEVIEW*)view; UINT r; - LPWSTR full_name = NULL; + LPWSTR encname, full_name = NULL; if( !view->ops->fetch_int ) return ERROR_INVALID_PARAMETER; @@ -1180,11 +1180,13 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt return r; } - r = db_get_raw_stream( tv->db, full_name, stm ); + encname = encode_streamname( FALSE, full_name ); + r = db_get_raw_stream( tv->db, encname, stm ); if( r ) ERR("fetching stream %s, error = %d\n",debugstr_w(full_name), r); - msi_free( full_name ); + msi_free( full_name ); + msi_free( encname ); return r; } diff --git a/dll/win32/msi/tokenize.c b/dll/win32/msi/tokenize.c index 04824562de4..e17ded88861 100644 --- a/dll/win32/msi/tokenize.c +++ b/dll/win32/msi/tokenize.c @@ -166,9 +166,9 @@ static int sqliteKeywordCode(const WCHAR *z, int n){ */ static const char isIdChar[] = { /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, /* 2x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 3x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 4x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 5x */ diff --git a/dll/win32/msi/upgrade.c b/dll/win32/msi/upgrade.c index 6d5f4cf6e28..a440070a4d8 100644 --- a/dll/win32/msi/upgrade.c +++ b/dll/win32/msi/upgrade.c @@ -182,9 +182,10 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param) continue; } - action_property = MSI_RecordGetString(rec,7); - append_productcode(package,action_property,productid); - ui_actiondata(package,szFindRelatedProducts,uirow); + action_property = MSI_RecordGetString(rec, 7); + append_productcode(package, action_property, productid); + MSI_RecordSetStringW(uirow, 1, productid); + ui_actiondata(package, szFindRelatedProducts, uirow); } index ++; } @@ -202,6 +203,12 @@ UINT ACTION_FindRelatedProducts(MSIPACKAGE *package) UINT rc = ERROR_SUCCESS; MSIQUERY *view; + if (msi_get_property_int(package, szInstalled, 0)) + { + TRACE("Skipping FindRelatedProducts action: product already installed\n"); + return ERROR_SUCCESS; + } + if (check_unique_action(package,szFindRelatedProducts)) { TRACE("Skipping FindRelatedProducts action: already done on client side\n"); diff --git a/dll/win32/msxml3/attribute.c b/dll/win32/msxml3/attribute.c index 04b8c46cb4e..d78fa479f40 100644 --- a/dll/win32/msxml3/attribute.c +++ b/dll/win32/msxml3/attribute.c @@ -55,7 +55,7 @@ static HRESULT WINAPI domattr_QueryInterface( void** ppvObject ) { domattr *This = impl_from_IXMLDOMAttribute( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMAttribute ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -213,7 +213,10 @@ static HRESULT WINAPI domattr_get_parentNode( IXMLDOMNode** parent ) { domattr *This = impl_from_IXMLDOMAttribute( iface ); - return IXMLDOMNode_get_parentNode( IXMLDOMNode_from_impl(&This->node), parent ); + TRACE("(%p)->(%p)\n", This, parent); + if (!parent) return E_INVALIDARG; + *parent = NULL; + return S_FALSE; } static HRESULT WINAPI domattr_get_childNodes( diff --git a/dll/win32/msxml3/cdata.c b/dll/win32/msxml3/cdata.c index 7d02a946a0c..3fba66cdbc7 100644 --- a/dll/win32/msxml3/cdata.c +++ b/dll/win32/msxml3/cdata.c @@ -55,7 +55,7 @@ static HRESULT WINAPI domcdata_QueryInterface( void** ppvObject ) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMCDATASection ) || IsEqualGUID( riid, &IID_IXMLDOMCharacterData) || @@ -480,7 +480,7 @@ static HRESULT WINAPI domcdata_get_data( BSTR *p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - HRESULT hr = E_FAIL; + HRESULT hr; VARIANT vRet; if(!p) @@ -500,17 +500,14 @@ static HRESULT WINAPI domcdata_put_data( BSTR data) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - HRESULT hr = E_FAIL; VARIANT val; - TRACE("%p %s\n", This, debugstr_w(data) ); + TRACE("(%p)->(%s)\n", This, debugstr_w(data) ); V_VT(&val) = VT_BSTR; V_BSTR(&val) = data; - hr = IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); - - return hr; + return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); } static HRESULT WINAPI domcdata_get_length( @@ -518,23 +515,21 @@ static HRESULT WINAPI domcdata_get_length( LONG *len) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlChar *pContent; - LONG nLength = 0; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%p)\n", This, len); if(!len) return E_INVALIDARG; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMCDATASection_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); - xmlFree(pContent); + *len = SysStringLen(data); + SysFreeString(data); } - *len = nLength; - return S_OK; } @@ -543,11 +538,10 @@ static HRESULT WINAPI domcdata_substringData( LONG offset, LONG count, BSTR *p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlChar *pContent; - LONG nLength = 0; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%d %d %p)\n", This, offset, count, p); if(!p) return E_INVALIDARG; @@ -557,26 +551,24 @@ static HRESULT WINAPI domcdata_substringData( return E_INVALIDARG; if(count == 0) - return hr; + return S_FALSE; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMCDATASection_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); + LONG len = SysStringLen(data); - if( offset < nLength) + if(offset < len) { - BSTR sContent = bstr_from_xmlChar(pContent); - if(offset + count > nLength) - *p = SysAllocString(&sContent[offset]); + if(offset + count > len) + *p = SysAllocString(&data[offset]); else - *p = SysAllocStringLen(&sContent[offset], count); - - SysFreeString(sContent); - hr = S_OK; + *p = SysAllocStringLen(&data[offset], count); } + else + hr = S_FALSE; - xmlFree(pContent); + SysFreeString(data); } return hr; @@ -587,26 +579,30 @@ static HRESULT WINAPI domcdata_appendData( BSTR p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlChar *pContent; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", iface); + TRACE("(%p)->(%s)\n", This, debugstr_w(p)); /* Nothing to do if NULL or an Empty string passed in. */ - if(p == NULL || SysStringLen(p) == 0) - return S_OK; + if((p_len = SysStringLen(p)) == 0) return S_OK; - pContent = xmlChar_from_wchar( p ); - if(pContent) + hr = IXMLDOMCDATASection_get_data(iface, &data); + if(hr == S_OK) { - if(xmlTextConcat(This->node.node, pContent, SysStringLen(p) ) == 0) - hr = S_OK; - else - hr = E_FAIL; + LONG len = SysStringLen(data); + BSTR str = SysAllocStringLen(NULL, p_len + len); + + memcpy(str, data, len*sizeof(WCHAR)); + memcpy(&str[len], p, p_len*sizeof(WCHAR)); + str[len+p_len] = 0; + + hr = IXMLDOMCDATASection_put_data(iface, str); + + SysFreeString(str); + SysFreeString(data); } - else - hr = E_FAIL; - heap_free(pContent); return hr; } @@ -616,16 +612,14 @@ static HRESULT WINAPI domcdata_insertData( LONG offset, BSTR p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlChar *pXmlContent; - BSTR sNewString; - HRESULT hr = S_FALSE; - LONG nLength = 0, nLengthP = 0; - xmlChar *str = NULL; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", This); + TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p)); /* If have a NULL or empty string, don't do anything. */ - if(SysStringLen(p) == 0) + if((p_len = SysStringLen(p)) == 0) return S_OK; if(offset < 0) @@ -633,48 +627,29 @@ static HRESULT WINAPI domcdata_insertData( return E_INVALIDARG; } - pXmlContent = xmlNodeGetContent(This->node.node); - if(pXmlContent) + hr = IXMLDOMCDATASection_get_data(iface, &data); + if(hr == S_OK) { - BSTR sContent = bstr_from_xmlChar( pXmlContent ); - nLength = SysStringLen(sContent); - nLengthP = SysStringLen(p); + LONG len = SysStringLen(data); + BSTR str; - if(nLength < offset) + if(len < offset) { - SysFreeString(sContent); - xmlFree(pXmlContent); - + SysFreeString(data); return E_INVALIDARG; } - sNewString = SysAllocStringLen(NULL, nLength + nLengthP + 1); - if(sNewString) - { - if(offset > 0) - memcpy(sNewString, sContent, offset * sizeof(WCHAR)); + str = SysAllocStringLen(NULL, len + p_len); + /* start part, supplied string and end part */ + memcpy(str, data, offset*sizeof(WCHAR)); + memcpy(&str[offset], p, p_len*sizeof(WCHAR)); + memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR)); + str[len+p_len] = 0; - memcpy(&sNewString[offset], p, nLengthP * sizeof(WCHAR)); + hr = IXMLDOMCDATASection_put_data(iface, str); - if(offset+nLengthP < nLength) - memcpy(&sNewString[offset+nLengthP], &sContent[offset], (nLength-offset) * sizeof(WCHAR)); - - sNewString[nLengthP + nLength] = 0; - - str = xmlChar_from_wchar(sNewString); - if(str) - { - xmlNodeSetContent(This->node.node, str); - hr = S_OK; - } - heap_free(str); - - SysFreeString(sNewString); - } - - SysFreeString(sContent); - - xmlFree(pXmlContent); + SysFreeString(str); + SysFreeString(data); } return hr; @@ -684,11 +659,12 @@ static HRESULT WINAPI domcdata_deleteData( IXMLDOMCDATASection *iface, LONG offset, LONG count) { + domcdata *This = impl_from_IXMLDOMCDATASection( iface ); HRESULT hr; LONG len = -1; BSTR str; - TRACE("%p %d %d\n", iface, offset, count); + TRACE("(%p)->(%d %d)\n", This, offset, count); hr = IXMLDOMCDATASection_get_length(iface, &len); if(hr != S_OK) return hr; @@ -731,15 +707,25 @@ static HRESULT WINAPI domcdata_replaceData( IXMLDOMCDATASection *iface, LONG offset, LONG count, BSTR p) { - FIXME("\n"); - return E_NOTIMPL; + domcdata *This = impl_from_IXMLDOMCDATASection( iface ); + HRESULT hr; + + TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p)); + + hr = IXMLDOMCDATASection_deleteData(iface, offset, count); + + if (hr == S_OK) + hr = IXMLDOMCDATASection_insertData(iface, offset, p); + + return hr; } static HRESULT WINAPI domcdata_splitText( IXMLDOMCDATASection *iface, LONG offset, IXMLDOMText **txtNode) { - FIXME("\n"); + domcdata *This = impl_from_IXMLDOMCDATASection( iface ); + FIXME("(%p)->(%d %p)\n", This, offset, txtNode); return E_NOTIMPL; } diff --git a/dll/win32/msxml3/comment.c b/dll/win32/msxml3/comment.c index 1e3b965e84a..e74de07e876 100644 --- a/dll/win32/msxml3/comment.c +++ b/dll/win32/msxml3/comment.c @@ -55,7 +55,7 @@ static HRESULT WINAPI domcomment_QueryInterface( void** ppvObject ) { domcomment *This = impl_from_IXMLDOMComment( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMComment ) || IsEqualGUID( riid, &IID_IXMLDOMCharacterData) || @@ -474,9 +474,11 @@ static HRESULT WINAPI domcomment_get_data( BSTR *p) { domcomment *This = impl_from_IXMLDOMComment( iface ); - HRESULT hr = E_FAIL; + HRESULT hr; VARIANT vRet; + TRACE("(%p)->(%p)\n", This, p); + if(!p) return E_INVALIDARG; @@ -494,17 +496,14 @@ static HRESULT WINAPI domcomment_put_data( BSTR data) { domcomment *This = impl_from_IXMLDOMComment( iface ); - HRESULT hr = E_FAIL; VARIANT val; - TRACE("%p %s\n", This, debugstr_w(data) ); + TRACE("(%p)->(%s)\n", This, debugstr_w(data) ); V_VT(&val) = VT_BSTR; V_BSTR(&val) = data; - hr = IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); - - return hr; + return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); } static HRESULT WINAPI domcomment_get_length( @@ -512,24 +511,22 @@ static HRESULT WINAPI domcomment_get_length( LONG *len) { domcomment *This = impl_from_IXMLDOMComment( iface ); - xmlChar *pContent; - LONG nLength = 0; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%p)\n", This, len); if(!len) return E_INVALIDARG; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMComment_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); - xmlFree(pContent); + *len = SysStringLen(data); + SysFreeString(data); } - *len = nLength; - - return S_OK; + return hr; } static HRESULT WINAPI domcomment_substringData( @@ -537,11 +534,10 @@ static HRESULT WINAPI domcomment_substringData( LONG offset, LONG count, BSTR *p) { domcomment *This = impl_from_IXMLDOMComment( iface ); - xmlChar *pContent; - LONG nLength = 0; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; - TRACE("%p %d %d %p\n", iface, offset, count, p); + TRACE("(%p)->(%d %d %p)\n", This, offset, count, p); if(!p) return E_INVALIDARG; @@ -553,24 +549,22 @@ static HRESULT WINAPI domcomment_substringData( if(count == 0) return S_FALSE; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMComment_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); + LONG len = SysStringLen(data); - if( offset < nLength) + if(offset < len) { - BSTR sContent = bstr_from_xmlChar(pContent); - if(offset + count > nLength) - *p = SysAllocString(&sContent[offset]); + if(offset + count > len) + *p = SysAllocString(&data[offset]); else - *p = SysAllocStringLen(&sContent[offset], count); - - SysFreeString(sContent); - hr = S_OK; + *p = SysAllocStringLen(&data[offset], count); } + else + hr = S_FALSE; - xmlFree(pContent); + SysFreeString(data); } return hr; @@ -581,40 +575,30 @@ static HRESULT WINAPI domcomment_appendData( BSTR p) { domcomment *This = impl_from_IXMLDOMComment( iface ); - xmlChar *pContent; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", iface); + TRACE("(%p)->(%s)\n", This, debugstr_w(p)); /* Nothing to do if NULL or an Empty string passed in. */ - if(p == NULL || SysStringLen(p) == 0) - return S_OK; + if((p_len = SysStringLen(p)) == 0) return S_OK; - pContent = xmlChar_from_wchar( p ); - if(pContent) + hr = IXMLDOMComment_get_data(iface, &data); + if(hr == S_OK) { - /* Older versions of libxml < 2.6.27 didn't correctly support - xmlTextConcat on Comment nodes. Fallback to setting the - contents directly if xmlTextConcat fails. - */ - if(xmlTextConcat(This->node.node, pContent, SysStringLen(p) ) == 0) - hr = S_OK; - else - { - xmlChar *pNew; - pNew = xmlStrcat(xmlNodeGetContent(This->node.node), pContent); - if(pNew) - { - xmlNodeSetContent(This->node.node, pNew); - hr = S_OK; - } - else - hr = E_FAIL; - } - HeapFree( GetProcessHeap(), 0, pContent ); + LONG len = SysStringLen(data); + BSTR str = SysAllocStringLen(NULL, p_len + len); + + memcpy(str, data, len*sizeof(WCHAR)); + memcpy(&str[len], p, p_len*sizeof(WCHAR)); + str[len+p_len] = 0; + + hr = IXMLDOMComment_put_data(iface, str); + + SysFreeString(str); + SysFreeString(data); } - else - hr = E_FAIL; return hr; } @@ -624,16 +608,14 @@ static HRESULT WINAPI domcomment_insertData( LONG offset, BSTR p) { domcomment *This = impl_from_IXMLDOMComment( iface ); - xmlChar *pXmlContent; - BSTR sNewString; - HRESULT hr = S_FALSE; - LONG nLength = 0, nLengthP = 0; - xmlChar *str = NULL; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p %d %p\n", iface, offset, p); + TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p)); /* If have a NULL or empty string, don't do anything. */ - if(SysStringLen(p) == 0) + if((p_len = SysStringLen(p)) == 0) return S_OK; if(offset < 0) @@ -641,48 +623,29 @@ static HRESULT WINAPI domcomment_insertData( return E_INVALIDARG; } - pXmlContent = xmlNodeGetContent(This->node.node); - if(pXmlContent) + hr = IXMLDOMComment_get_data(iface, &data); + if(hr == S_OK) { - BSTR sContent = bstr_from_xmlChar( pXmlContent ); - nLength = SysStringLen(sContent); - nLengthP = SysStringLen(p); + LONG len = SysStringLen(data); + BSTR str; - if(nLength < offset) + if(len < offset) { - SysFreeString(sContent); - xmlFree(pXmlContent); - + SysFreeString(data); return E_INVALIDARG; } - sNewString = SysAllocStringLen(NULL, nLength + nLengthP + 1); - if(sNewString) - { - if(offset > 0) - memcpy(sNewString, sContent, offset * sizeof(WCHAR)); + str = SysAllocStringLen(NULL, len + p_len); + /* start part, supplied string and end part */ + memcpy(str, data, offset*sizeof(WCHAR)); + memcpy(&str[offset], p, p_len*sizeof(WCHAR)); + memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR)); + str[len+p_len] = 0; - memcpy(&sNewString[offset], p, nLengthP * sizeof(WCHAR)); + hr = IXMLDOMComment_put_data(iface, str); - if(offset+nLengthP < nLength) - memcpy(&sNewString[offset+nLengthP], &sContent[offset], (nLength-offset) * sizeof(WCHAR)); - - sNewString[nLengthP + nLength] = 0; - - str = xmlChar_from_wchar(sNewString); - if(str) - { - xmlNodeSetContent(This->node.node, str); - hr = S_OK; - } - HeapFree( GetProcessHeap(), 0, str ); - - SysFreeString(sNewString); - } - - SysFreeString(sContent); - - xmlFree(pXmlContent); + SysFreeString(str); + SysFreeString(data); } return hr; @@ -696,7 +659,7 @@ static HRESULT WINAPI domcomment_deleteData( LONG len = -1; BSTR str; - TRACE("%p %d %d\n", iface, offset, count); + TRACE("(%p)->(%d %d)\n", iface, offset, count); hr = IXMLDOMComment_get_length(iface, &len); if(hr != S_OK) return hr; @@ -739,8 +702,17 @@ static HRESULT WINAPI domcomment_replaceData( IXMLDOMComment *iface, LONG offset, LONG count, BSTR p) { - FIXME("\n"); - return E_NOTIMPL; + domcomment *This = impl_from_IXMLDOMComment( iface ); + HRESULT hr; + + TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p)); + + hr = IXMLDOMComment_deleteData(iface, offset, count); + + if (hr == S_OK) + hr = IXMLDOMComment_insertData(iface, offset, p); + + return hr; } static const struct IXMLDOMCommentVtbl domcomment_vtbl = diff --git a/dll/win32/msxml3/docfrag.c b/dll/win32/msxml3/docfrag.c index b5f6e464799..fff3f62a419 100644 --- a/dll/win32/msxml3/docfrag.c +++ b/dll/win32/msxml3/docfrag.c @@ -55,7 +55,7 @@ static HRESULT WINAPI domfrag_QueryInterface( void** ppvObject ) { domfrag *This = impl_from_IXMLDOMDocumentFragment( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMDocumentFragment ) || IsEqualGUID( riid, &IID_IDispatch ) || diff --git a/dll/win32/msxml3/domdoc.c b/dll/win32/msxml3/domdoc.c index 4914a7c0064..a29e9b2fb3e 100644 --- a/dll/win32/msxml3/domdoc.c +++ b/dll/win32/msxml3/domdoc.c @@ -47,6 +47,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(msxml); #ifdef HAVE_LIBXML2 +#include + +/* not defined in older versions */ +#define XML_SAVE_FORMAT 1 +#define XML_SAVE_NO_DECL 2 +#define XML_SAVE_NO_EMPTY 4 +#define XML_SAVE_NO_XHTML 8 +#define XML_SAVE_XHTML 16 +#define XML_SAVE_AS_XML 32 +#define XML_SAVE_AS_HTML 64 + static const WCHAR SZ_PROPERTY_SELECTION_LANGUAGE[] = {'S','e','l','e','c','t','i','o','n','L','a','n','g','u','a','g','e',0}; static const WCHAR SZ_VALUE_XPATH[] = {'X','P','a','t','h',0}; static const WCHAR SZ_VALUE_XSLPATTERN[] = {'X','S','L','P','a','t','t','e','r','n',0}; @@ -290,7 +301,7 @@ static HRESULT WINAPI xmldoc_IPersistStream_IsDirty( { domdoc *This = impl_from_IPersistStream(iface); - FIXME("(%p->%p): stub!\n", iface, This); + FIXME("(%p): stub!\n", This); return S_FALSE; } @@ -306,7 +317,7 @@ static HRESULT WINAPI xmldoc_IPersistStream_Load( char *ptr; xmlDocPtr xmldoc = NULL; - TRACE("(%p, %p)\n", iface, pStm); + TRACE("(%p)->(%p)\n", This, pStm); if (!pStm) return E_INVALIDARG; @@ -355,7 +366,7 @@ static HRESULT WINAPI xmldoc_IPersistStream_Save( HRESULT hr; BSTR xmlString; - TRACE("(%p, %p, %d)\n", iface, pStm, fClearDirty); + TRACE("(%p)->(%p %d)\n", This, pStm, fClearDirty); hr = IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), &xmlString ); if(hr == S_OK) @@ -376,7 +387,8 @@ static HRESULT WINAPI xmldoc_IPersistStream_Save( static HRESULT WINAPI xmldoc_IPersistStream_GetSizeMax( IPersistStream *iface, ULARGE_INTEGER *pcbSize) { - TRACE("(%p, %p): stub!\n", iface, pcbSize); + domdoc *This = impl_from_IPersistStream(iface); + TRACE("(%p)->(%p): stub!\n", This, pcbSize); return E_NOTIMPL; } @@ -436,7 +448,7 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID rii { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject ); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid( riid ), ppvObject ); *ppvObject = NULL; @@ -459,6 +471,10 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID rii { *ppvObject = &(This->lpvtblIObjectWithSite); } + else if (IsEqualGUID(&IID_IObjectSafety, riid)) + { + *ppvObject = &(This->lpvtblIObjectSafety); + } else if( IsEqualGUID( riid, &IID_ISupportErrorInfo )) { *ppvObject = &This->lpvtblISupportErrorInfo; @@ -940,7 +956,8 @@ static HRESULT WINAPI domdoc_get_doctype( IXMLDOMDocument2 *iface, IXMLDOMDocumentType** documentType ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("(%p)\n", This); return E_NOTIMPL; } @@ -949,6 +966,10 @@ static HRESULT WINAPI domdoc_get_implementation( IXMLDOMDocument2 *iface, IXMLDOMImplementation** impl ) { + domdoc *This = impl_from_IXMLDOMDocument2(iface); + + TRACE("(%p)->(%p)\n", This, impl); + if(!impl) return E_INVALIDARG; @@ -967,7 +988,7 @@ static HRESULT WINAPI domdoc_get_documentElement( IXMLDOMNode *element_node; HRESULT hr; - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, DOMElement); if(!DOMElement) return E_INVALIDARG; @@ -1027,52 +1048,55 @@ static HRESULT WINAPI domdoc_createElement( BSTR tagname, IXMLDOMElement** element ) { - xmlNodePtr xmlnode; domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlChar *xml_name; - IUnknown *elem_unk; + IXMLDOMNode *node; + VARIANT type; HRESULT hr; - TRACE("%p->(%s,%p)\n", iface, debugstr_w(tagname), element); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(tagname), element); - xml_name = xmlChar_from_wchar(tagname); - xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL); - xmldoc_add_orphan(xmlnode->doc, xmlnode); + if (!element || !tagname) return E_INVALIDARG; - TRACE("created xmlptr %p\n", xmlnode); - elem_unk = create_element(xmlnode); - heap_free(xml_name); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_ELEMENT; + + hr = IXMLDOMDocument_createNode(iface, type, tagname, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMElement, (void**)element); + IXMLDOMNode_Release(node); + } - hr = IUnknown_QueryInterface(elem_unk, &IID_IXMLDOMElement, (void **)element); - IUnknown_Release(elem_unk); - TRACE("returning %p\n", *element); return hr; } static HRESULT WINAPI domdoc_createDocumentFragment( IXMLDOMDocument2 *iface, - IXMLDOMDocumentFragment** docFrag ) + IXMLDOMDocumentFragment** frag ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p\n", iface); + TRACE("(%p)->(%p)\n", This, frag); - if(!docFrag) - return E_INVALIDARG; + if (!frag) return E_INVALIDARG; - *docFrag = NULL; + *frag = NULL; - xmlnode = xmlNewDocFragment(get_doc( This ) ); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_DOCUMENT_FRAGMENT; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument_createNode(iface, type, NULL, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMDocumentFragment, (void**)frag); + IXMLDOMNode_Release(node); + } - xmldoc_add_orphan(xmlnode->doc, xmlnode); - *docFrag = (IXMLDOMDocumentFragment*)create_doc_fragment(xmlnode); - - return S_OK; + return hr; } @@ -1082,29 +1106,28 @@ static HRESULT WINAPI domdoc_createTextNode( IXMLDOMText** text ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; - xmlChar *xml_content; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p->(%s %p)\n", iface, debugstr_w(data), text); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), text); - if(!text) - return E_INVALIDARG; + if (!text) return E_INVALIDARG; *text = NULL; - xml_content = xmlChar_from_wchar(data); - xmlnode = xmlNewText(xml_content); - heap_free(xml_content); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_TEXT; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMText, (void**)text); + IXMLDOMNode_Release(node); + hr = IXMLDOMText_put_data(*text, data); + } - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *text = (IXMLDOMText*)create_text(xmlnode); - - return S_OK; + return hr; } @@ -1114,29 +1137,28 @@ static HRESULT WINAPI domdoc_createComment( IXMLDOMComment** comment ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; - xmlChar *xml_content; + VARIANT type; + HRESULT hr; + IXMLDOMNode *node; - TRACE("%p->(%s %p)\n", iface, debugstr_w(data), comment); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), comment); - if(!comment) - return E_INVALIDARG; + if (!comment) return E_INVALIDARG; *comment = NULL; - xml_content = xmlChar_from_wchar(data); - xmlnode = xmlNewComment(xml_content); - heap_free(xml_content); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_COMMENT; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMComment, (void**)comment); + IXMLDOMNode_Release(node); + hr = IXMLDOMComment_put_data(*comment, data); + } - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *comment = (IXMLDOMComment*)create_comment(xmlnode); - - return S_OK; + return hr; } @@ -1146,29 +1168,28 @@ static HRESULT WINAPI domdoc_createCDATASection( IXMLDOMCDATASection** cdata ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; - xmlChar *xml_content; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p->(%s %p)\n", iface, debugstr_w(data), cdata); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), cdata); - if(!cdata) - return E_INVALIDARG; + if (!cdata) return E_INVALIDARG; *cdata = NULL; - xml_content = xmlChar_from_wchar(data); - xmlnode = xmlNewCDataBlock(get_doc( This ), xml_content, strlen( (char*)xml_content) ); - heap_free(xml_content); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_CDATA_SECTION; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)cdata); + IXMLDOMNode_Release(node); + hr = IXMLDOMCDATASection_put_data(*cdata, data); + } - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *cdata = (IXMLDOMCDATASection*)create_cdata(xmlnode); - - return S_OK; + return hr; } @@ -1178,35 +1199,36 @@ static HRESULT WINAPI domdoc_createProcessingInstruction( BSTR data, IXMLDOMProcessingInstruction** pi ) { -#ifdef HAVE_XMLNEWDOCPI - xmlNodePtr xmlnode; domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlChar *xml_target, *xml_content; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p->(%s %s %p)\n", iface, debugstr_w(target), debugstr_w(data), pi); + TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), pi); - if(!pi) - return E_INVALIDARG; + if (!pi) return E_INVALIDARG; - if(!target || lstrlenW(target) == 0) - return E_FAIL; + *pi = NULL; - xml_target = xmlChar_from_wchar(target); - xml_content = xmlChar_from_wchar(data); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_PROCESSING_INSTRUCTION; - xmlnode = xmlNewDocPI(get_doc(This), xml_target, xml_content); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - TRACE("created xmlptr %p\n", xmlnode); - *pi = (IXMLDOMProcessingInstruction*)create_pi(xmlnode); + hr = IXMLDOMDocument2_createNode(iface, type, target, NULL, &node); + if (hr == S_OK) + { + VARIANT v_data; - heap_free(xml_content); - heap_free(xml_target); + /* this is to bypass check in ::put_data() that blocks "(%s %p)\n", iface, debugstr_w(name), attribute); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), attribute); - if(!attribute) - return E_INVALIDARG; + if (!attribute || !name) return E_INVALIDARG; - *attribute = NULL; + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_ATTRIBUTE; - xml_name = xmlChar_from_wchar(name); - xmlnode = (xmlNode *)xmlNewProp(NULL, xml_name, NULL); - heap_free(xml_name); + hr = IXMLDOMDocument_createNode(iface, type, name, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMAttribute, (void**)attribute); + IXMLDOMNode_Release(node); + } - if(!xmlnode) - return E_FAIL; - - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *attribute = (IXMLDOMAttribute*)create_attribute(xmlnode); - - return S_OK; + return hr; } static HRESULT WINAPI domdoc_createEntityReference( IXMLDOMDocument2 *iface, BSTR name, - IXMLDOMEntityReference** entityRef ) + IXMLDOMEntityReference** entityref ) { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - xmlNodePtr xmlnode; - xmlChar *xml_name; + IXMLDOMNode *node; + VARIANT type; + HRESULT hr; - TRACE("%p\n", iface); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), entityref); - if(!entityRef) - return E_INVALIDARG; + if (!entityref) return E_INVALIDARG; - *entityRef = NULL; + *entityref = NULL; - xml_name = xmlChar_from_wchar(name); - xmlnode = xmlNewReference(get_doc( This ), xml_name ); - heap_free(xml_name); + V_VT(&type) = VT_I1; + V_I1(&type) = NODE_ENTITY_REFERENCE; - if(!xmlnode) - return E_FAIL; + hr = IXMLDOMDocument2_createNode(iface, type, name, NULL, &node); + if (hr == S_OK) + { + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMEntityReference, (void**)entityref); + IXMLDOMNode_Release(node); + } - xmlnode->doc = get_doc( This ); - xmldoc_add_orphan(xmlnode->doc, xmlnode); - - *entityRef = (IXMLDOMEntityReference*)create_doc_entity_ref(xmlnode); - - return S_OK; + return hr; } @@ -1284,7 +1300,7 @@ static HRESULT WINAPI domdoc_getElementsByTagName( domdoc *This = impl_from_IXMLDOMDocument2( iface ); LPWSTR szPattern; HRESULT hr; - TRACE("(%p)->(%s, %p)\n", This, debugstr_w(tagName), resultList); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(tagName), resultList); if (tagName[0] == '*' && tagName[1] == 0) { @@ -1329,51 +1345,86 @@ static HRESULT WINAPI domdoc_createNode( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); DOMNodeType node_type; - xmlNodePtr xmlnode = NULL; + xmlNodePtr xmlnode; xmlChar *xml_name; HRESULT hr; - TRACE("(%p)->(type,%s,%s,%p)\n", This, debugstr_w(name), debugstr_w(namespaceURI), node); + TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(name), debugstr_w(namespaceURI), node); + + if(!node) return E_INVALIDARG; if(namespaceURI && namespaceURI[0]) FIXME("nodes with namespaces currently not supported.\n"); hr = get_node_type(Type, &node_type); - if(FAILED(hr)) - return hr; + if(FAILED(hr)) return hr; TRACE("node_type %d\n", node_type); + /* exit earlier for types that need name */ + switch(node_type) + { + case NODE_ELEMENT: + case NODE_ATTRIBUTE: + case NODE_ENTITY_REFERENCE: + case NODE_PROCESSING_INSTRUCTION: + if (!name || SysStringLen(name) == 0) return E_FAIL; + default: + break; + } + xml_name = xmlChar_from_wchar(name); switch(node_type) { case NODE_ELEMENT: xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL); - *node = create_node(xmlnode); - TRACE("created %p\n", xmlnode); break; case NODE_ATTRIBUTE: - xmlnode = (xmlNode *)xmlNewProp(NULL, xml_name, NULL); - if(xmlnode) - { - xmlnode->doc = get_doc( This ); - - *node = (IXMLDOMNode*)create_attribute(xmlnode); - } - - TRACE("created %p\n", xmlnode); + xmlnode = (xmlNodePtr)xmlNewDocProp(get_doc(This), xml_name, NULL); break; - + case NODE_TEXT: + xmlnode = (xmlNodePtr)xmlNewDocText(get_doc(This), NULL); + break; + case NODE_CDATA_SECTION: + xmlnode = xmlNewCDataBlock(get_doc(This), NULL, 0); + break; + case NODE_ENTITY_REFERENCE: + xmlnode = xmlNewReference(get_doc(This), xml_name); + break; + case NODE_PROCESSING_INSTRUCTION: +#ifdef HAVE_XMLNEWDOCPI + xmlnode = xmlNewDocPI(get_doc(This), xml_name, NULL); +#else + FIXME("xmlNewDocPI() not supported, use libxml2 2.6.15 or greater\n"); + xmlnode = NULL; +#endif + break; + case NODE_COMMENT: + xmlnode = xmlNewDocComment(get_doc(This), NULL); + break; + case NODE_DOCUMENT_FRAGMENT: + xmlnode = xmlNewDocFragment(get_doc(This)); + break; + /* unsupported types */ + case NODE_DOCUMENT: + case NODE_DOCUMENT_TYPE: + case NODE_ENTITY: + case NODE_NOTATION: + heap_free(xml_name); + return E_INVALIDARG; default: FIXME("unhandled node type %d\n", node_type); + xmlnode = NULL; break; } + *node = create_node(xmlnode); heap_free(xml_name); - if(xmlnode && *node) + if(*node) { + TRACE("created node (%d, %p, %p)\n", node_type, *node, xmlnode); xmldoc_add_orphan(xmlnode->doc, xmlnode); return S_OK; } @@ -1386,7 +1437,8 @@ static HRESULT WINAPI domdoc_nodeFromID( BSTR idString, IXMLDOMNode** node ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("(%p)->(%s %p)\n", This, debugstr_w(idString), node); return E_NOTIMPL; } @@ -1432,7 +1484,7 @@ static HRESULT WINAPI domdoc_load( IStream *pStream = NULL; xmlDocPtr xmldoc; - TRACE("type %d\n", V_VT(&xmlSource) ); + TRACE("(%p)->type %d\n", This, V_VT(&xmlSource) ); *isSuccessful = VARIANT_FALSE; @@ -1528,7 +1580,8 @@ static HRESULT WINAPI domdoc_get_readyState( IXMLDOMDocument2 *iface, LONG *value ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("(%p)->(%p)\n", This, value); return E_NOTIMPL; } @@ -1556,7 +1609,8 @@ static HRESULT WINAPI domdoc_get_url( IXMLDOMDocument2 *iface, BSTR* urlString ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("(%p)->(%p)\n", This, urlString); return E_NOTIMPL; } @@ -1567,7 +1621,7 @@ static HRESULT WINAPI domdoc_get_async( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p <- %d\n", isAsync, This->async); + TRACE("(%p)->(%p: %d)\n", This, isAsync, This->async); *isAsync = This->async; return S_OK; } @@ -1579,7 +1633,7 @@ static HRESULT WINAPI domdoc_put_async( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%d\n", isAsync); + TRACE("(%p)->(%d)\n", This, isAsync); This->async = isAsync; return S_OK; } @@ -1588,7 +1642,8 @@ static HRESULT WINAPI domdoc_put_async( static HRESULT WINAPI domdoc_abort( IXMLDOMDocument2 *iface ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2(iface); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1619,7 +1674,7 @@ static HRESULT WINAPI domdoc_loadXML( int len; HRESULT hr = S_FALSE, hr2; - TRACE("%p %s %p\n", This, debugstr_w( bstrXML ), isSuccessful ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w( bstrXML ), isSuccessful ); assert ( &This->node ); @@ -1651,6 +1706,24 @@ static HRESULT WINAPI domdoc_loadXML( return hr; } +static int XMLCALL domdoc_save_writecallback(void *ctx, const char *buffer, + int len) +{ + DWORD written = -1; + + if(!WriteFile(ctx, buffer, len, &written, NULL)) + { + WARN("write error\n"); + return -1; + } + else + return written; +} + +static int XMLCALL domdoc_save_closecallback(void *ctx) +{ + return CloseHandle(ctx) ? 0 : -1; +} static HRESULT WINAPI domdoc_save( IXMLDOMDocument2 *iface, @@ -1658,10 +1731,8 @@ static HRESULT WINAPI domdoc_save( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); HANDLE handle; - xmlChar *mem, *p; - int size; + xmlSaveCtxtPtr ctx; HRESULT ret = S_OK; - DWORD written; TRACE("(%p)->(var(vt %d, %s))\n", This, V_VT(&destination), V_VT(&destination) == VT_BSTR ? debugstr_w(V_BSTR(&destination)) : NULL); @@ -1707,31 +1778,19 @@ static HRESULT WINAPI domdoc_save( return S_FALSE; } - xmlDocDumpMemory(get_doc(This), &mem, &size); - - /* - * libxml2 always adds XML declaration on top of the file and one for each processing instruction node in DOM tree. - * MSXML adds XML declaration only for processing instruction nodes. - * We skip the first XML declaration generated by libxml2 to get exactly what we need. - */ - p = mem; - if(size > 2 && p[0] == '<' && p[1] == '?') { - while(p < mem+size && (p[0] != '?' || p[1] != '>')) - p++; - p += 2; - while(p < mem+size && isspace(*p)) - p++; - size -= p-mem; - } - - if(!WriteFile(handle, p, (DWORD)size, &written, NULL) || written != (DWORD)size) + /* disable top XML declaration */ + ctx = xmlSaveToIO(domdoc_save_writecallback, domdoc_save_closecallback, + handle, NULL, XML_SAVE_NO_DECL); + if (!ctx) { - WARN("write error\n"); - ret = S_FALSE; + CloseHandle(handle); + return S_FALSE; } - xmlFree(mem); - CloseHandle(handle); + if (xmlSaveDoc(ctx, get_doc(This)) == -1) ret = S_FALSE; + /* will close file through close callback */ + xmlSaveClose(ctx); + return ret; } @@ -1741,7 +1800,7 @@ static HRESULT WINAPI domdoc_get_validateOnParse( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p <- %d\n", isValidating, This->validating); + TRACE("(%p)->(%p: %d)\n", This, isValidating, This->validating); *isValidating = This->validating; return S_OK; } @@ -1753,7 +1812,7 @@ static HRESULT WINAPI domdoc_put_validateOnParse( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%d\n", isValidating); + TRACE("(%p)->(%d)\n", This, isValidating); This->validating = isValidating; return S_OK; } @@ -1765,7 +1824,7 @@ static HRESULT WINAPI domdoc_get_resolveExternals( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p <- %d\n", isResolving, This->resolving); + TRACE("(%p)->(%p: %d)\n", This, isResolving, This->resolving); *isResolving = This->resolving; return S_OK; } @@ -1777,7 +1836,7 @@ static HRESULT WINAPI domdoc_put_resolveExternals( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%d\n", isResolving); + TRACE("(%p)->(%d)\n", This, isResolving); This->resolving = isResolving; return S_OK; } @@ -1789,7 +1848,7 @@ static HRESULT WINAPI domdoc_get_preserveWhiteSpace( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%p <- %d\n", isPreserving, This->preserving); + TRACE("(%p)->(%p: %d)\n", This, isPreserving, This->preserving); *isPreserving = This->preserving; return S_OK; } @@ -1801,7 +1860,7 @@ static HRESULT WINAPI domdoc_put_preserveWhiteSpace( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); - TRACE("%d\n", isPreserving); + TRACE("(%p)->(%d)\n", This, isPreserving); This->preserving = isPreserving; return S_OK; } @@ -1811,7 +1870,8 @@ static HRESULT WINAPI domdoc_put_onReadyStateChange( IXMLDOMDocument2 *iface, VARIANT readyStateChangeSink ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1820,7 +1880,8 @@ static HRESULT WINAPI domdoc_put_onDataAvailable( IXMLDOMDocument2 *iface, VARIANT onDataAvailableSink ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1828,7 +1889,8 @@ static HRESULT WINAPI domdoc_put_onTransformNode( IXMLDOMDocument2 *iface, VARIANT onTransformNodeSink ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1836,7 +1898,8 @@ static HRESULT WINAPI domdoc_get_namespaces( IXMLDOMDocument2* iface, IXMLDOMSchemaCollection** schemaCollection ) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("(%p)->(%p)\n", This, schemaCollection); return E_NOTIMPL; } @@ -1903,7 +1966,8 @@ static HRESULT WINAPI domdoc_validate( IXMLDOMDocument2* iface, IXMLDOMParseError** err) { - FIXME("\n"); + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + FIXME("(%p)->(%p)\n", This, err); return E_NOTIMPL; } @@ -1914,6 +1978,8 @@ static HRESULT WINAPI domdoc_setProperty( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); + TRACE("(%p)->(%s)\n", This, debugstr_w(p)); + if (lstrcmpiW(p, SZ_PROPERTY_SELECTION_LANGUAGE) == 0) { VARIANT varStr; @@ -1953,6 +2019,8 @@ static HRESULT WINAPI domdoc_getProperty( { domdoc *This = impl_from_IXMLDOMDocument2( iface ); + TRACE("(%p)->(%p)\n", This, debugstr_w(p)); + if (var == NULL) return E_INVALIDARG; if (lstrcmpiW(p, SZ_PROPERTY_SELECTION_LANGUAGE) == 0) @@ -2082,7 +2150,7 @@ xmldoc_GetSite( IObjectWithSite *iface, REFIID iid, void ** ppvSite ) { domdoc *This = impl_from_IObjectWithSite(iface); - TRACE("%p %s %p\n", This, debugstr_guid( iid ), ppvSite ); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid( iid ), ppvSite ); if ( !This->site ) return E_FAIL; @@ -2095,7 +2163,7 @@ xmldoc_SetSite( IObjectWithSite *iface, IUnknown *punk ) { domdoc *This = impl_from_IObjectWithSite(iface); - TRACE("%p %p\n", iface, punk); + TRACE("(%p)->(%p)\n", iface, punk); if(!punk) { @@ -2146,7 +2214,7 @@ static ULONG WINAPI xmldoc_Safety_Release(IObjectSafety *iface) return IXMLDocument_Release((IXMLDocument *)This); } -#define SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER) +#define SAFETY_SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER) static HRESULT WINAPI xmldoc_Safety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions) @@ -2158,7 +2226,7 @@ static HRESULT WINAPI xmldoc_Safety_GetInterfaceSafetyOptions(IObjectSafety *ifa if(!pdwSupportedOptions || !pdwEnabledOptions) return E_POINTER; - *pdwSupportedOptions = SUPPORTED_OPTIONS; + *pdwSupportedOptions = SAFETY_SUPPORTED_OPTIONS; *pdwEnabledOptions = This->safeopt; return S_OK; @@ -2168,13 +2236,12 @@ static HRESULT WINAPI xmldoc_Safety_SetInterfaceSafetyOptions(IObjectSafety *ifa DWORD dwOptionSetMask, DWORD dwEnabledOptions) { domdoc *This = impl_from_IObjectSafety(iface); - TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions); - if(dwOptionSetMask & ~SUPPORTED_OPTIONS) + if ((dwOptionSetMask & ~SAFETY_SUPPORTED_OPTIONS) != 0) return E_FAIL; - This->safeopt = dwEnabledOptions & dwEnabledOptions; + This->safeopt = dwEnabledOptions & dwOptionSetMask & SAFETY_SUPPORTED_OPTIONS; return S_OK; } diff --git a/dll/win32/msxml3/domimpl.c b/dll/win32/msxml3/domimpl.c index 1a07676e33f..dd518a1bc3b 100644 --- a/dll/win32/msxml3/domimpl.c +++ b/dll/win32/msxml3/domimpl.c @@ -54,7 +54,7 @@ static HRESULT WINAPI dimimpl_QueryInterface( void** ppvObject ) { domimpl *This = impl_from_IXMLDOMImplementation( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMImplementation ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -181,7 +181,7 @@ static HRESULT WINAPI dimimpl_hasFeature(IXMLDOMImplementation* This, BSTR featu BOOL bValidFeature = FALSE; BOOL bValidVersion = FALSE; - TRACE("feature(%s) version (%s)\n", debugstr_w(feature), debugstr_w(version)); + TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(feature), debugstr_w(version), hasFeature); if(!feature || !hasFeature) return E_INVALIDARG; diff --git a/dll/win32/msxml3/element.c b/dll/win32/msxml3/element.c index f7bd3b03e08..b6caf73df15 100644 --- a/dll/win32/msxml3/element.c +++ b/dll/win32/msxml3/element.c @@ -62,7 +62,7 @@ static HRESULT WINAPI domelem_QueryInterface( { domelem *This = impl_from_IXMLDOMElement( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMElement ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -489,32 +489,24 @@ static HRESULT WINAPI domelem_get_tagName( { domelem *This = impl_from_IXMLDOMElement( iface ); xmlNodePtr element; - DWORD len; - DWORD offset = 0; - LPWSTR str; + const xmlChar *prefix; + xmlChar *qname; - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, p ); + + if (!p) return E_INVALIDARG; element = get_element( This ); if ( !element ) return E_FAIL; - len = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, NULL, 0 ); - if (element->ns) - len += MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->ns->prefix, -1, NULL, 0 ); - str = heap_alloc( len * sizeof (WCHAR) ); - if ( !str ) - return E_OUTOFMEMORY; - if (element->ns) - { - offset = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->ns->prefix, -1, str, len ); - str[offset - 1] = ':'; - } - MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, str + offset, len - offset ); - *p = SysAllocString( str ); - heap_free( str ); + prefix = element->ns ? element->ns->prefix : NULL; + qname = xmlBuildQName(element->name, prefix, NULL, 0); - return S_OK; + *p = bstr_from_xmlChar(qname); + if (qname != element->name) xmlFree(qname); + + return *p ? S_OK : E_OUTOFMEMORY; } static HRESULT WINAPI domelem_getAttribute( @@ -526,7 +518,7 @@ static HRESULT WINAPI domelem_getAttribute( xmlChar *xml_name, *xml_value = NULL; HRESULT hr = S_FALSE; - TRACE("(%p)->(%s,%p)\n", This, debugstr_w(name), value); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), value); if(!value || !name) return E_INVALIDARG; @@ -567,7 +559,7 @@ static HRESULT WINAPI domelem_setAttribute( HRESULT hr; VARIANT var; - TRACE("(%p)->(%s, var)\n", This, debugstr_w(name)); + TRACE("(%p)->(%s var)\n", This, debugstr_w(name)); element = get_element( This ); if ( !element ) @@ -660,7 +652,8 @@ static HRESULT WINAPI domelem_setAttributeNode( IXMLDOMAttribute* domAttribute, IXMLDOMAttribute** attributeNode) { - FIXME("\n"); + domelem *This = impl_from_IXMLDOMElement( iface ); + FIXME("(%p)->(%p %p)\n", This, domAttribute, attributeNode); return E_NOTIMPL; } @@ -669,7 +662,8 @@ static HRESULT WINAPI domelem_removeAttributeNode( IXMLDOMAttribute* domAttribute, IXMLDOMAttribute** attributeNode) { - FIXME("\n"); + domelem *This = impl_from_IXMLDOMElement( iface ); + FIXME("(%p)->(%p %p)\n", This, domAttribute, attributeNode); return E_NOTIMPL; } @@ -684,7 +678,7 @@ static HRESULT WINAPI domelem_getElementsByTagName( xmlNodePtr element; HRESULT hr; - TRACE("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), resultList); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrName), resultList); if (bstrName[0] == '*' && bstrName[1] == 0) { @@ -714,7 +708,8 @@ static HRESULT WINAPI domelem_getElementsByTagName( static HRESULT WINAPI domelem_normalize( IXMLDOMElement *iface ) { - FIXME("\n"); + domelem *This = impl_from_IXMLDOMElement( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } diff --git a/dll/win32/msxml3/entityref.c b/dll/win32/msxml3/entityref.c index 1489dbd0c57..db461934538 100644 --- a/dll/win32/msxml3/entityref.c +++ b/dll/win32/msxml3/entityref.c @@ -55,7 +55,7 @@ static HRESULT WINAPI entityref_QueryInterface( void** ppvObject ) { entityref *This = impl_from_IXMLDOMEntityReference( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMEntityReference ) || IsEqualGUID( riid, &IID_IDispatch ) || diff --git a/dll/win32/msxml3/factory.c b/dll/win32/msxml3/factory.c index 45ba3680c0f..af94d5cbcf1 100644 --- a/dll/win32/msxml3/factory.c +++ b/dll/win32/msxml3/factory.c @@ -167,7 +167,8 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv ) cf = (IClassFactory*) &domdoccf.lpVtbl; } else if( IsEqualCLSID( rclsid, &CLSID_SAXXMLReader) || - IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 )) + IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 ) || + IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 )) { cf = (IClassFactory*) &saxreadcf.lpVtbl; } diff --git a/dll/win32/msxml3/httprequest.c b/dll/win32/msxml3/httprequest.c index a477753a71a..458548406a0 100644 --- a/dll/win32/msxml3/httprequest.c +++ b/dll/win32/msxml3/httprequest.c @@ -50,7 +50,7 @@ static inline httprequest *impl_from_IXMLHTTPRequest( IXMLHTTPRequest *iface ) static HRESULT WINAPI httprequest_QueryInterface(IXMLHTTPRequest *iface, REFIID riid, void **ppvObject) { httprequest *This = impl_from_IXMLHTTPRequest( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLHTTPRequest) || IsEqualGUID( riid, &IID_IDispatch) || diff --git a/dll/win32/msxml3/msxml_private.h b/dll/win32/msxml3/msxml_private.h index e46642d84b6..1df3e8b6cd5 100644 --- a/dll/win32/msxml3/msxml_private.h +++ b/dll/win32/msxml3/msxml_private.h @@ -1,5 +1,5 @@ /* - * MSXML Class Factory + * Common definitions * * Copyright 2005 Mike McCormack * @@ -174,6 +174,8 @@ static inline BSTR bstr_from_xmlChar(const xmlChar *str) if(ret) MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)str, -1, ret, len); } + else + ret = SysAllocStringLen(NULL, 0); return ret; } diff --git a/dll/win32/msxml3/node.c b/dll/win32/msxml3/node.c index 6729512d69e..ac97681aac9 100644 --- a/dll/win32/msxml3/node.c +++ b/dll/win32/msxml3/node.c @@ -87,7 +87,7 @@ static HRESULT WINAPI xmlnode_QueryInterface( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if(This->pUnkOuter) return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject); @@ -230,7 +230,7 @@ static HRESULT WINAPI xmlnode_get_nodeName( xmlnode *This = impl_from_IXMLDOMNode( iface ); const xmlChar *str; - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, name ); if (!name) return E_INVALIDARG; @@ -250,16 +250,16 @@ static HRESULT WINAPI xmlnode_get_nodeName( str = (const xmlChar*) "#document-fragment"; break; case XML_TEXT_NODE: - str = (const xmlChar*) "#text"; - break; + str = (const xmlChar*) "#text"; + break; case XML_DOCUMENT_NODE: - str = (const xmlChar*) "#document"; - break; - case XML_ATTRIBUTE_NODE: - case XML_ELEMENT_NODE: - case XML_PI_NODE: + str = (const xmlChar*) "#document"; + break; + case XML_ATTRIBUTE_NODE: + case XML_ELEMENT_NODE: + case XML_PI_NODE: str = This->node->name; - break; + break; default: FIXME("nodeName not mapped correctly (%d)\n", This->node->type); str = This->node->name; @@ -280,7 +280,7 @@ static HRESULT WINAPI xmlnode_get_nodeValue( xmlnode *This = impl_from_IXMLDOMNode( iface ); HRESULT r = S_FALSE; - TRACE("%p %p\n", This, value); + TRACE("(%p)->(%p)\n", This, value); if(!value) return E_INVALIDARG; @@ -327,23 +327,11 @@ static HRESULT WINAPI xmlnode_put_nodeValue( { xmlnode *This = impl_from_IXMLDOMNode( iface ); HRESULT hr; - xmlChar *str = NULL; - VARIANT string_value; TRACE("%p type(%d)\n", This, This->node->type); - VariantInit(&string_value); - hr = VariantChangeType(&string_value, &value, 0, VT_BSTR); - if(FAILED(hr)) - { - VariantClear(&string_value); - WARN("Couldn't convert to VT_BSTR\n"); - return hr; - } - - hr = S_FALSE; /* Document, Document Fragment, Document Type, Element, - Entity, Entity Reference, Notation aren't supported. */ + Entity, Entity Reference, Notation aren't supported. */ switch ( This->node->type ) { case XML_ATTRIBUTE_NODE: @@ -351,20 +339,33 @@ static HRESULT WINAPI xmlnode_put_nodeValue( case XML_COMMENT_NODE: case XML_PI_NODE: case XML_TEXT_NODE: - { + { + VARIANT string_value; + xmlChar *str; + + VariantInit(&string_value); + hr = VariantChangeType(&string_value, &value, 0, VT_BSTR); + if(FAILED(hr)) + { + VariantClear(&string_value); + WARN("Couldn't convert to VT_BSTR\n"); + return hr; + } + str = xmlChar_from_wchar(V_BSTR(&string_value)); + VariantClear(&string_value); + xmlNodeSetContent(This->node, str); heap_free(str); hr = S_OK; break; - } + } default: /* Do nothing for unsupported types. */ + hr = E_FAIL; break; } - VariantClear(&string_value); - return hr; } @@ -374,7 +375,7 @@ static HRESULT WINAPI xmlnode_get_nodeType( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p %p\n", This, type); + TRACE("(%p)->(%p)\n", This, type); assert( (int)NODE_ELEMENT == (int)XML_ELEMENT_NODE ); assert( (int)NODE_NOTATION == (int)XML_NOTATION_NODE ); @@ -390,7 +391,7 @@ static HRESULT get_node( xmlNodePtr node, IXMLDOMNode **out ) { - TRACE("%p->%s %p\n", This, name, node ); + TRACE("(%p)->(%s %p %p)\n", This, name, node, out ); if ( !out ) return E_INVALIDARG; @@ -419,7 +420,7 @@ static HRESULT WINAPI xmlnode_get_childNodes( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p %p\n", This, childList ); + TRACE("(%p)->(%p)\n", This, childList ); if ( !childList ) return E_INVALIDARG; @@ -445,7 +446,7 @@ static HRESULT WINAPI xmlnode_get_lastChild( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, lastChild ); if (!lastChild) return E_INVALIDARG; @@ -470,7 +471,7 @@ static HRESULT WINAPI xmlnode_get_previousSibling( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, previousSibling ); if (!previousSibling) return E_INVALIDARG; @@ -494,7 +495,7 @@ static HRESULT WINAPI xmlnode_get_nextSibling( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, nextSibling ); if (!nextSibling) return E_INVALIDARG; @@ -517,7 +518,7 @@ static HRESULT WINAPI xmlnode_get_attributes( IXMLDOMNamedNodeMap** attributeMap) { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, attributeMap); if (!attributeMap) return E_INVALIDARG; @@ -553,7 +554,7 @@ static HRESULT WINAPI xmlnode_insertBefore( IXMLDOMNode *before = NULL, *new; HRESULT hr; - TRACE("(%p)->(%p,var,%p)\n",This,newChild,outNewChild); + TRACE("(%p)->(%p var %p)\n",This,newChild,outNewChild); if (!newChild) return E_INVALIDARG; @@ -620,7 +621,7 @@ static HRESULT WINAPI xmlnode_replaceChild( IXMLDOMNode *realOldChild; HRESULT hr; - TRACE("%p->(%p,%p,%p)\n",This,newChild,oldChild,outOldChild); + TRACE("(%p)->(%p %p %p)\n", This, newChild, oldChild, outOldChild); /* Do not believe any documentation telling that newChild == NULL means removal. It does certainly *not* apply to msxml3! */ @@ -684,7 +685,7 @@ static HRESULT WINAPI xmlnode_removeChild( HRESULT hr; IXMLDOMNode *child; - TRACE("%p->(%p, %p)\n", This, childNode, oldChild); + TRACE("(%p)->(%p %p)\n", This, childNode, oldChild); if(!childNode) return E_INVALIDARG; @@ -726,7 +727,7 @@ static HRESULT WINAPI xmlnode_appendChild( VARIANT var; HRESULT hr; - TRACE("(%p)->(%p,%p)\n", This, newChild, outNewChild); + TRACE("(%p)->(%p %p)\n", This, newChild, outNewChild); hr = IXMLDOMNode_get_nodeType(newChild, &type); if(FAILED(hr) || type == NODE_ATTRIBUTE) { @@ -744,7 +745,7 @@ static HRESULT WINAPI xmlnode_hasChildNodes( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, hasChild); if (!hasChild) return E_INVALIDARG; @@ -764,7 +765,7 @@ static HRESULT WINAPI xmlnode_get_ownerDocument( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p (%p)\n", This, DOMDocument); + TRACE("(%p)->(%p)\n", This, DOMDocument); return DOMDocument_create_from_xmldoc(This->node->doc, (IXMLDOMDocument2**)DOMDocument); } @@ -778,7 +779,7 @@ static HRESULT WINAPI xmlnode_cloneNode( xmlNodePtr pClone = NULL; IXMLDOMNode *pNode = NULL; - TRACE("%p (%d)\n", This, deep); + TRACE("(%p)->(%d %p)\n", This, deep, cloneRoot); if(!cloneRoot) return E_INVALIDARG; @@ -814,7 +815,7 @@ static HRESULT WINAPI xmlnode_get_nodeTypeString( xmlnode *This = impl_from_IXMLDOMNode( iface ); const xmlChar *str; - TRACE("%p\n", This ); + TRACE("(%p)->(%p)\n", This, xmlnodeType ); if (!xmlnodeType) return E_INVALIDARG; @@ -878,7 +879,7 @@ static HRESULT WINAPI xmlnode_get_text( BSTR str = NULL; xmlChar *pContent; - TRACE("%p type %d\n", This, This->node->type); + TRACE("(%p, type %d)->(%p)\n", This, This->node->type, text); if ( !text ) return E_INVALIDARG; @@ -906,7 +907,7 @@ static HRESULT WINAPI xmlnode_put_text( xmlnode *This = impl_from_IXMLDOMNode( iface ); xmlChar *str, *str2; - TRACE("%p\n", This); + TRACE("(%p)->(%s)\n", This, debugstr_w(text)); switch(This->node->type) { @@ -932,7 +933,8 @@ static HRESULT WINAPI xmlnode_get_specified( IXMLDOMNode *iface, VARIANT_BOOL* isSpecified) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("(%p)->(%p)\n", This, isSpecified); return E_NOTIMPL; } @@ -940,12 +942,11 @@ static HRESULT WINAPI xmlnode_get_definition( IXMLDOMNode *iface, IXMLDOMNode** definitionNode) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("(%p)->(%p)\n", This, definitionNode); return E_NOTIMPL; } -static HRESULT WINAPI xmlnode_get_dataType(IXMLDOMNode*, VARIANT*); - static inline BYTE hex_to_byte(xmlChar c) { if(c <= '9') return c-'0'; @@ -1136,7 +1137,7 @@ static HRESULT WINAPI xmlnode_get_nodeTypedValue( xmlChar *content; HRESULT hres = S_FALSE; - TRACE("iface %p\n", iface); + TRACE("(%p)->(%p)\n", This, typedValue); if(!typedValue) return E_INVALIDARG; @@ -1146,10 +1147,10 @@ static HRESULT WINAPI xmlnode_get_nodeTypedValue( if(This->node->type == XML_ELEMENT_NODE || This->node->type == XML_TEXT_NODE || This->node->type == XML_ENTITY_REF_NODE) - hres = xmlnode_get_dataType(iface, &type); + hres = IXMLDOMNode_get_dataType(iface, &type); if(hres != S_OK && This->node->type != XML_ELEMENT_NODE) - return xmlnode_get_nodeValue(iface, typedValue); + return IXMLDOMNode_get_nodeValue(iface, typedValue); content = xmlNodeGetContent(This->node); hres = VARIANT_from_xmlChar(content, typedValue, @@ -1164,7 +1165,8 @@ static HRESULT WINAPI xmlnode_put_nodeTypedValue( IXMLDOMNode *iface, VARIANT typedValue) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("%p\n", This); return E_NOTIMPL; } @@ -1175,7 +1177,7 @@ static HRESULT WINAPI xmlnode_get_dataType( xmlnode *This = impl_from_IXMLDOMNode( iface ); xmlChar *pVal; - TRACE("iface %p\n", iface); + TRACE("(%p)->(%p)\n", This, dataTypeName); if(!dataTypeName) return E_INVALIDARG; @@ -1220,7 +1222,7 @@ static HRESULT WINAPI xmlnode_put_dataType( xmlnode *This = impl_from_IXMLDOMNode( iface ); HRESULT hr = E_FAIL; - TRACE("iface %p\n", iface); + TRACE("(%p)->(%s)\n", This, debugstr_w(dataTypeName)); if(dataTypeName == NULL) return E_INVALIDARG; @@ -1382,7 +1384,7 @@ static HRESULT WINAPI xmlnode_get_xml( xmlBufferPtr pXmlBuf; int nSize; - TRACE("iface %p %d\n", iface, This->node->type); + TRACE("(%p %d)->(%p)\n", This, This->node->type, xmlString); if(!xmlString) return E_INVALIDARG; @@ -1440,7 +1442,7 @@ static HRESULT WINAPI xmlnode_transformNode( xmlDocPtr result = NULL; IXMLDOMNode *ssNew; - TRACE("%p %p %p\n", This, styleSheet, xmlString); + TRACE("(%p)->(%p %p)\n", This, styleSheet, xmlString); if (!libxslt_handle) return E_NOTIMPL; @@ -1517,7 +1519,7 @@ static HRESULT WINAPI xmlnode_selectNodes( { xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("%p %s %p\n", This, debugstr_w(queryString), resultList ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(queryString), resultList ); return queryresult_create( This->node, queryString, resultList ); } @@ -1531,7 +1533,7 @@ static HRESULT WINAPI xmlnode_selectSingleNode( IXMLDOMNodeList *list; HRESULT r; - TRACE("%p %s %p\n", This, debugstr_w(queryString), resultNode ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(queryString), resultNode ); *resultNode = NULL; r = IXMLDOMNode_selectNodes(iface, queryString, &list); @@ -1547,7 +1549,8 @@ static HRESULT WINAPI xmlnode_get_parsed( IXMLDOMNode *iface, VARIANT_BOOL* isParsed) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("(%p)->(%p)\n", This, isParsed); return E_NOTIMPL; } @@ -1559,7 +1562,7 @@ static HRESULT WINAPI xmlnode_get_namespaceURI( HRESULT hr = S_FALSE; xmlNsPtr *pNSList; - TRACE("%p %p\n", This, namespaceURI ); + TRACE("(%p)->(%p)\n", This, namespaceURI ); if(!namespaceURI) return E_INVALIDARG; @@ -1586,7 +1589,7 @@ static HRESULT WINAPI xmlnode_get_prefix( HRESULT hr = S_FALSE; xmlNsPtr *pNSList; - TRACE("%p %p\n", This, prefixString ); + TRACE("(%p)->(%p)\n", This, prefixString ); if(!prefixString) return E_INVALIDARG; @@ -1613,7 +1616,7 @@ static HRESULT WINAPI xmlnode_get_baseName( BSTR str = NULL; HRESULT r = S_FALSE; - TRACE("%p %p\n", This, nameString ); + TRACE("(%p)->(%p)\n", This, nameString ); if ( !nameString ) return E_INVALIDARG; @@ -1622,10 +1625,12 @@ static HRESULT WINAPI xmlnode_get_baseName( { case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: + case XML_PI_NODE: str = bstr_from_xmlChar( This->node->name ); r = S_OK; break; case XML_TEXT_NODE: + case XML_COMMENT_NODE: break; default: ERR("Unhandled type %d\n", This->node->type ); @@ -1643,7 +1648,8 @@ static HRESULT WINAPI xmlnode_transformNodeToObject( IXMLDOMNode* stylesheet, VARIANT outputObject) { - FIXME("\n"); + xmlnode *This = impl_from_IXMLDOMNode( iface ); + FIXME("(%p)->(%p)\n", This, stylesheet); return E_NOTIMPL; } @@ -1738,12 +1744,21 @@ IXMLDOMNode *create_node( xmlNodePtr node ) case XML_CDATA_SECTION_NODE: pUnk = create_cdata( node ); break; + case XML_ENTITY_REF_NODE: + pUnk = create_doc_entity_ref( node ); + break; + case XML_PI_NODE: + pUnk = create_pi( node ); + break; case XML_COMMENT_NODE: pUnk = create_comment( node ); break; case XML_DOCUMENT_NODE: pUnk = create_domdoc( node ); break; + case XML_DOCUMENT_FRAG_NODE: + pUnk = create_doc_fragment( node ); + break; default: { xmlnode *new_node; diff --git a/dll/win32/msxml3/nodelist.c b/dll/win32/msxml3/nodelist.c index 011fff0bf61..f643c5e8cbb 100644 --- a/dll/win32/msxml3/nodelist.c +++ b/dll/win32/msxml3/nodelist.c @@ -64,7 +64,7 @@ static HRESULT WINAPI xmlnodelist_QueryInterface( REFIID riid, void** ppvObject ) { - TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject); if(!ppvObject) return E_INVALIDARG; @@ -205,7 +205,7 @@ static HRESULT WINAPI xmlnodelist_get_item( xmlNodePtr curr; LONG nodeIndex = 0; - TRACE("%p %d\n", This, index); + TRACE("(%p)->(%d %p)\n", This, index, listItem); if(!listItem) return E_INVALIDARG; @@ -238,7 +238,7 @@ static HRESULT WINAPI xmlnodelist_get_length( xmlnodelist *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, listLength); if(!listLength) return E_INVALIDARG; @@ -260,7 +260,7 @@ static HRESULT WINAPI xmlnodelist_nextNode( { xmlnodelist *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p %p\n", This, nextItem ); + TRACE("(%p)->(%p)\n", This, nextItem ); if(!nextItem) return E_INVALIDARG; @@ -289,7 +289,8 @@ static HRESULT WINAPI xmlnodelist__newEnum( IXMLDOMNodeList* iface, IUnknown** ppUnk) { - FIXME("\n"); + xmlnodelist *This = impl_from_IXMLDOMNodeList( iface ); + FIXME("(%p)->(%p)\n", This, ppUnk); return E_NOTIMPL; } diff --git a/dll/win32/msxml3/nodemap.c b/dll/win32/msxml3/nodemap.c index 91f7a323e5e..7d23ec80bd5 100644 --- a/dll/win32/msxml3/nodemap.c +++ b/dll/win32/msxml3/nodemap.c @@ -62,7 +62,7 @@ static HRESULT WINAPI xmlnodemap_QueryInterface( REFIID riid, void** ppvObject ) { xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); - TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject); if( IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -207,7 +207,7 @@ static HRESULT WINAPI xmlnodemap_getNamedItem( xmlAttrPtr attr; xmlNodePtr node; - TRACE("%p %s %p\n", This, debugstr_w(name), namedItem ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), namedItem ); if ( !namedItem ) return E_INVALIDARG; @@ -242,7 +242,7 @@ static HRESULT WINAPI xmlnodemap_setNamedItem( IXMLDOMNode *pAttr = NULL; xmlNodePtr node; - TRACE("%p %p %p\n", This, newItem, namedItem ); + TRACE("(%p)->(%p %p)\n", This, newItem, namedItem ); if(!newItem) return E_INVALIDARG; @@ -292,7 +292,7 @@ static HRESULT WINAPI xmlnodemap_removeNamedItem( xmlAttrPtr attr; xmlNodePtr node; - TRACE("%p %s %p\n", This, debugstr_w(name), namedItem ); + TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), namedItem ); if ( !name) return E_INVALIDARG; @@ -337,7 +337,7 @@ static HRESULT WINAPI xmlnodemap_get_item( xmlAttrPtr curr; LONG attrIndex; - TRACE("%p %d\n", This, index); + TRACE("(%p)->(%d %p)\n", This, index, listItem); *listItem = NULL; @@ -370,7 +370,7 @@ static HRESULT WINAPI xmlnodemap_get_length( xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, listLength); if( !listLength ) return E_INVALIDARG; @@ -402,7 +402,8 @@ static HRESULT WINAPI xmlnodemap_getQualifiedItem( BSTR namespaceURI, IXMLDOMNode** qualifiedItem) { - FIXME("\n"); + xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); + FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(baseName), debugstr_w(namespaceURI), qualifiedItem); return E_NOTIMPL; } @@ -412,7 +413,8 @@ static HRESULT WINAPI xmlnodemap_removeQualifiedItem( BSTR namespaceURI, IXMLDOMNode** qualifiedItem) { - FIXME("\n"); + xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); + FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(baseName), debugstr_w(namespaceURI), qualifiedItem); return E_NOTIMPL; } @@ -425,7 +427,7 @@ static HRESULT WINAPI xmlnodemap_nextNode( xmlAttrPtr curr; LONG attrIndex; - TRACE("%p %d\n", This, This->iterator); + TRACE("(%p)->(%p: %d)\n", This, nextItem, This->iterator); *nextItem = NULL; @@ -451,7 +453,7 @@ static HRESULT WINAPI xmlnodemap_reset( { xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); - TRACE("%p %d\n", This, This->iterator); + TRACE("(%p: %d)\n", This, This->iterator); This->iterator = 0; @@ -462,7 +464,8 @@ static HRESULT WINAPI xmlnodemap__newEnum( IXMLDOMNamedNodeMap *iface, IUnknown** ppUnk) { - FIXME("\n"); + xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface ); + FIXME("(%p)->(%p)\n", This, ppUnk); return E_NOTIMPL; } diff --git a/dll/win32/msxml3/parseerror.c b/dll/win32/msxml3/parseerror.c index 40b17a0f3d9..4b0dc57f508 100644 --- a/dll/win32/msxml3/parseerror.c +++ b/dll/win32/msxml3/parseerror.c @@ -56,7 +56,7 @@ static HRESULT WINAPI parseError_QueryInterface( REFIID riid, void** ppvObject ) { - TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -208,7 +208,8 @@ static HRESULT WINAPI parseError_get_url( IXMLDOMParseError *iface, BSTR *url ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, url); return E_NOTIMPL; } @@ -232,7 +233,8 @@ static HRESULT WINAPI parseError_get_srcText( IXMLDOMParseError *iface, BSTR *srcText ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, srcText); return E_NOTIMPL; } @@ -240,7 +242,8 @@ static HRESULT WINAPI parseError_get_line( IXMLDOMParseError *iface, LONG *line ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, line); return E_NOTIMPL; } @@ -248,7 +251,8 @@ static HRESULT WINAPI parseError_get_linepos( IXMLDOMParseError *iface, LONG *linepos ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, linepos); return E_NOTIMPL; } @@ -256,7 +260,8 @@ static HRESULT WINAPI parseError_get_filepos( IXMLDOMParseError *iface, LONG *filepos ) { - FIXME("\n"); + parse_error_t *This = impl_from_IXMLDOMParseError( iface ); + FIXME("(%p)->(%p)\n", This, filepos); return E_NOTIMPL; } diff --git a/dll/win32/msxml3/pi.c b/dll/win32/msxml3/pi.c index f32cebf8300..0baefe49031 100644 --- a/dll/win32/msxml3/pi.c +++ b/dll/win32/msxml3/pi.c @@ -55,7 +55,7 @@ static HRESULT WINAPI dom_pi_QueryInterface( void** ppvObject ) { dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMProcessingInstruction ) || IsEqualGUID( riid, &IID_IDispatch ) || @@ -526,7 +526,7 @@ static HRESULT WINAPI dom_pi_put_data( BSTR sTarget; static const WCHAR szXML[] = {'x','m','l',0}; - TRACE("%p %s\n", This, debugstr_w(data) ); + TRACE("(%p)->(%s)\n", This, debugstr_w(data) ); /* Cannot set data to a PI node whose target is 'xml' */ hr = dom_pi_get_nodeName(iface, &sTarget); diff --git a/dll/win32/msxml3/queryresult.c b/dll/win32/msxml3/queryresult.c index ab545968c08..eab83a904b6 100644 --- a/dll/win32/msxml3/queryresult.c +++ b/dll/win32/msxml3/queryresult.c @@ -74,7 +74,7 @@ static HRESULT WINAPI queryresult_QueryInterface( { queryresult *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject); if(!ppvObject) return E_INVALIDARG; @@ -217,7 +217,7 @@ static HRESULT WINAPI queryresult_get_item( { queryresult *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p %d\n", This, index); + TRACE("(%p)->(%d %p)\n", This, index, listItem); if(!listItem) return E_INVALIDARG; @@ -239,7 +239,7 @@ static HRESULT WINAPI queryresult_get_length( { queryresult *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p\n", This); + TRACE("(%p)->(%p)\n", This, listLength); if(!listLength) return E_INVALIDARG; @@ -254,7 +254,7 @@ static HRESULT WINAPI queryresult_nextNode( { queryresult *This = impl_from_IXMLDOMNodeList( iface ); - TRACE("%p %p\n", This, nextItem ); + TRACE("(%p)->(%p)\n", This, nextItem ); if(!nextItem) return E_INVALIDARG; @@ -283,7 +283,8 @@ static HRESULT WINAPI queryresult__newEnum( IXMLDOMNodeList* iface, IUnknown** ppUnk) { - FIXME("\n"); + queryresult *This = impl_from_IXMLDOMNodeList( iface ); + FIXME("(%p)->(%p)\n", This, ppUnk); return E_NOTIMPL; } diff --git a/dll/win32/msxml3/schema.c b/dll/win32/msxml3/schema.c index f0a616979a0..72d78547082 100644 --- a/dll/win32/msxml3/schema.c +++ b/dll/win32/msxml3/schema.c @@ -51,7 +51,7 @@ static HRESULT WINAPI schema_cache_QueryInterface( IXMLDOMSchemaCollection *ifac { schema_t *This = impl_from_IXMLDOMSchemaCollection( iface ); - TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject ); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid( riid ), ppvObject ); if ( IsEqualIID( riid, &IID_IUnknown ) || IsEqualIID( riid, &IID_IDispatch ) || diff --git a/dll/win32/msxml3/text.c b/dll/win32/msxml3/text.c index 70ca3efee33..fdcb06b4cb3 100644 --- a/dll/win32/msxml3/text.c +++ b/dll/win32/msxml3/text.c @@ -56,7 +56,7 @@ static HRESULT WINAPI domtext_QueryInterface( void** ppvObject ) { domtext *This = impl_from_IXMLDOMText( iface ); - TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); if ( IsEqualGUID( riid, &IID_IXMLDOMText ) || IsEqualGUID( riid, &IID_IXMLDOMCharacterData) || @@ -482,7 +482,7 @@ static HRESULT WINAPI domtext_get_data( BSTR *p) { domtext *This = impl_from_IXMLDOMText( iface ); - HRESULT hr = E_FAIL; + HRESULT hr; VARIANT vRet; if(!p) @@ -502,17 +502,14 @@ static HRESULT WINAPI domtext_put_data( BSTR data) { domtext *This = impl_from_IXMLDOMText( iface ); - HRESULT hr = E_FAIL; VARIANT val; - TRACE("%p %s\n", This, debugstr_w(data) ); + TRACE("(%p)->(%s)\n", This, debugstr_w(data) ); V_VT(&val) = VT_BSTR; V_BSTR(&val) = data; - hr = IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); - - return hr; + return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val ); } static HRESULT WINAPI domtext_get_length( @@ -520,24 +517,22 @@ static HRESULT WINAPI domtext_get_length( LONG *len) { domtext *This = impl_from_IXMLDOMText( iface ); - xmlChar *pContent; - LONG nLength = 0; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%p)\n", This, len); if(!len) return E_INVALIDARG; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMText_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); - xmlFree(pContent); + *len = SysStringLen(data); + SysFreeString(data); } - *len = nLength; - - return S_OK; + return hr; } static HRESULT WINAPI domtext_substringData( @@ -545,11 +540,10 @@ static HRESULT WINAPI domtext_substringData( LONG offset, LONG count, BSTR *p) { domtext *This = impl_from_IXMLDOMText( iface ); - xmlChar *pContent; - LONG nLength = 0; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; - TRACE("%p\n", iface); + TRACE("(%p)->(%d %d %p)\n", This, offset, count, p); if(!p) return E_INVALIDARG; @@ -559,26 +553,24 @@ static HRESULT WINAPI domtext_substringData( return E_INVALIDARG; if(count == 0) - return hr; + return S_FALSE; - pContent = xmlNodeGetContent(This->node.node); - if(pContent) + hr = IXMLDOMText_get_data(iface, &data); + if(hr == S_OK) { - nLength = xmlStrlen(pContent); + LONG len = SysStringLen(data); - if( offset < nLength) + if(offset < len) { - BSTR sContent = bstr_from_xmlChar(pContent); - if(offset + count > nLength) - *p = SysAllocString(&sContent[offset]); + if(offset + count > len) + *p = SysAllocString(&data[offset]); else - *p = SysAllocStringLen(&sContent[offset], count); - - SysFreeString(sContent); - hr = S_OK; + *p = SysAllocStringLen(&data[offset], count); } + else + hr = S_FALSE; - xmlFree(pContent); + SysFreeString(data); } return hr; @@ -589,26 +581,30 @@ static HRESULT WINAPI domtext_appendData( BSTR p) { domtext *This = impl_from_IXMLDOMText( iface ); - xmlChar *pContent; - HRESULT hr = S_FALSE; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", iface); + TRACE("(%p)->(%s)\n", This, debugstr_w(p)); /* Nothing to do if NULL or an Empty string passed in. */ - if(p == NULL || SysStringLen(p) == 0) - return S_OK; + if((p_len = SysStringLen(p)) == 0) return S_OK; - pContent = xmlChar_from_wchar( p ); - if(pContent) + hr = IXMLDOMText_get_data(iface, &data); + if(hr == S_OK) { - if(xmlTextConcat(This->node.node, pContent, SysStringLen(p)) == 0) - hr = S_OK; - else - hr = E_FAIL; - heap_free( pContent ); + LONG len = SysStringLen(data); + BSTR str = SysAllocStringLen(NULL, p_len + len); + + memcpy(str, data, len*sizeof(WCHAR)); + memcpy(&str[len], p, p_len*sizeof(WCHAR)); + str[len+p_len] = 0; + + hr = IXMLDOMText_put_data(iface, str); + + SysFreeString(str); + SysFreeString(data); } - else - hr = E_FAIL; return hr; } @@ -618,16 +614,14 @@ static HRESULT WINAPI domtext_insertData( LONG offset, BSTR p) { domtext *This = impl_from_IXMLDOMText( iface ); - xmlChar *pXmlContent; - BSTR sNewString; - HRESULT hr = S_FALSE; - LONG nLength = 0, nLengthP = 0; - xmlChar *str = NULL; + HRESULT hr; + BSTR data; + LONG p_len; - TRACE("%p\n", This); + TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p)); /* If have a NULL or empty string, don't do anything. */ - if(SysStringLen(p) == 0) + if((p_len = SysStringLen(p)) == 0) return S_OK; if(offset < 0) @@ -635,48 +629,29 @@ static HRESULT WINAPI domtext_insertData( return E_INVALIDARG; } - pXmlContent = xmlNodeGetContent(This->node.node); - if(pXmlContent) + hr = IXMLDOMText_get_data(iface, &data); + if(hr == S_OK) { - BSTR sContent = bstr_from_xmlChar( pXmlContent ); - nLength = SysStringLen(sContent); - nLengthP = SysStringLen(p); + LONG len = SysStringLen(data); + BSTR str; - if(nLength < offset) + if(len < offset) { - SysFreeString(sContent); - xmlFree(pXmlContent); - + SysFreeString(data); return E_INVALIDARG; } - sNewString = SysAllocStringLen(NULL, nLength + nLengthP + 1); - if(sNewString) - { - if(offset > 0) - memcpy(sNewString, sContent, offset * sizeof(WCHAR)); + str = SysAllocStringLen(NULL, len + p_len); + /* start part, supplied string and end part */ + memcpy(str, data, offset*sizeof(WCHAR)); + memcpy(&str[offset], p, p_len*sizeof(WCHAR)); + memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR)); + str[len+p_len] = 0; - memcpy(&sNewString[offset], p, nLengthP * sizeof(WCHAR)); + hr = IXMLDOMText_put_data(iface, str); - if(offset+nLengthP < nLength) - memcpy(&sNewString[offset+nLengthP], &sContent[offset], (nLength-offset) * sizeof(WCHAR)); - - sNewString[nLengthP + nLength] = 0; - - str = xmlChar_from_wchar(sNewString); - if(str) - { - xmlNodeSetContent(This->node.node, str); - hr = S_OK; - } - heap_free(str); - - SysFreeString(sNewString); - } - - SysFreeString(sContent); - - xmlFree(pXmlContent); + SysFreeString(str); + SysFreeString(data); } return hr; @@ -690,7 +665,7 @@ static HRESULT WINAPI domtext_deleteData( LONG len = -1; BSTR str; - TRACE("%p %d %d\n", iface, offset, count); + TRACE("(%p)->(%d %d)\n", iface, offset, count); hr = IXMLDOMText_get_length(iface, &len); if(hr != S_OK) return hr; @@ -733,15 +708,25 @@ static HRESULT WINAPI domtext_replaceData( IXMLDOMText *iface, LONG offset, LONG count, BSTR p) { - FIXME("\n"); - return E_NOTIMPL; + domtext *This = impl_from_IXMLDOMText( iface ); + HRESULT hr; + + TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p)); + + hr = IXMLDOMText_deleteData(iface, offset, count); + + if (hr == S_OK) + hr = IXMLDOMText_insertData(iface, offset, p); + + return hr; } static HRESULT WINAPI domtext_splitText( IXMLDOMText *iface, LONG offset, IXMLDOMText **txtNode) { - FIXME("\n"); + domtext *This = impl_from_IXMLDOMText( iface ); + FIXME("(%p)->(%d %p)\n", This, offset, txtNode); return E_NOTIMPL; } diff --git a/dll/win32/netapi32/netapi32.c b/dll/win32/netapi32/netapi32.c index 12218fc2e70..fb4468f6950 100644 --- a/dll/win32/netapi32/netapi32.c +++ b/dll/win32/netapi32/netapi32.c @@ -26,6 +26,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(netbios); static HMODULE NETAPI32_hModule; +BOOL NETAPI_IsLocalComputer(LMCSTR ServerName); + BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { TRACE("%p,%x,%p\n", hinstDLL, fdwReason, lpvReserved); @@ -97,8 +99,59 @@ NET_API_STATUS WINAPI NetServerEnumEx( */ NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE* bufptr) { - FIXME("stub (%s, %d, %p)\n", debugstr_w(servername), level, bufptr); - return ERROR_ACCESS_DENIED; + NET_API_STATUS ret; + + TRACE("%s %d %p\n", debugstr_w( servername ), level, bufptr ); + if (servername) + { + if (!NETAPI_IsLocalComputer(servername)) + { + FIXME("remote computers not supported\n"); + return ERROR_INVALID_LEVEL; + } + } + if (!bufptr) return ERROR_INVALID_PARAMETER; + + switch (level) + { + case 100: + case 101: + { + DWORD computerNameLen, size; + WCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1]; + + computerNameLen = MAX_COMPUTERNAME_LENGTH + 1; + GetComputerNameW(computerName, &computerNameLen); + computerNameLen++; /* include NULL terminator */ + + size = sizeof(SERVER_INFO_101) + computerNameLen * sizeof(WCHAR); + ret = NetApiBufferAllocate(size, (LPVOID *)bufptr); + if (ret == NERR_Success) + { + /* INFO_100 structure is a subset of INFO_101 */ + PSERVER_INFO_101 info = (PSERVER_INFO_101)*bufptr; + OSVERSIONINFOW verInfo; + + info->sv101_platform_id = PLATFORM_ID_NT; + info->sv101_name = (LMSTR)(*bufptr + sizeof(SERVER_INFO_101)); + memcpy(info->sv101_name, computerName, + computerNameLen * sizeof(WCHAR)); + verInfo.dwOSVersionInfoSize = sizeof(verInfo); + GetVersionExW(&verInfo); + info->sv101_version_major = verInfo.dwMajorVersion; + info->sv101_version_minor = verInfo.dwMinorVersion; + /* Use generic type as no wine equivalent of DC / Server */ + info->sv101_type = SV_TYPE_NT; + info->sv101_comment = NULL; + } + break; + } + + default: + FIXME("level %d unimplemented\n", level); + ret = ERROR_INVALID_LEVEL; + } + return ret; } diff --git a/dll/win32/netid/lang/pl-PL.rc b/dll/win32/netid/lang/pl-PL.rc index 2bb82a0e6e2..3f0cbe9812d 100644 --- a/dll/win32/netid/lang/pl-PL.rc +++ b/dll/win32/netid/lang/pl-PL.rc @@ -75,12 +75,12 @@ BEGIN 22 "Witamy w grupie roboczej %1." 23 "Witamy w domenie %1." 24 "Musisz zrestartowa komputer aby zmiany odniosy skutek." - 25 "You can change the name and the membership of this computer. Changes may affect access to network resources." + 25 "Moesz zmieni nazw i czonkostwo tego komputera. Zmiany mog mie wpyw na dostp do zasobw sieciowych." 1021 "Uwaga: Tylko Administratorzy mog zmienia identyfikator tego komputera." 1022 "Uwaga: Identyfikator tego komputera nie zosta zmieniony, powd:" - 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?" + 1030 "Nowa nazwa komputera ""%s"" zawiera niedozwolone znaki. Do niedozwolonych znakw nale ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / oraz ?" 3210 "&Szczegy >>" 3220 "<< &Szczegy" - 4000 "Information" - 4001 "Can't set new a computer name!" + 4000 "Informacja" + 4001 "Nie mona zmieni nazwy komputera!" END diff --git a/dll/win32/objsel/factory.c b/dll/win32/objsel/factory.c index 11d81b90e69..090c1266a42 100644 --- a/dll/win32/objsel/factory.c +++ b/dll/win32/objsel/factory.c @@ -50,7 +50,7 @@ static HRESULT WINAPI OBJSEL_IClassFactory_QueryInterface( return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj); } - FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + FIXME("- no interface IID: %s\n", debugstr_guid(riid)); return E_NOINTERFACE; } diff --git a/dll/win32/objsel/objsel.c b/dll/win32/objsel/objsel.c index 51e8d0b594e..8179ce5e583 100644 --- a/dll/win32/objsel/objsel.c +++ b/dll/win32/objsel/objsel.c @@ -55,7 +55,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) if (IsEqualGUID(rclsid, &CLSID_DsObjectPicker)) return IClassFactory_QueryInterface((IClassFactory*)&OBJSEL_ClassFactory, iid, ppv); - FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid)); + FIXME("CLSID: %s, IID: %s\n", debugstr_guid(rclsid), debugstr_guid(iid)); return CLASS_E_CLASSNOTAVAILABLE; } @@ -147,7 +147,7 @@ static HRESULT WINAPI OBJSEL_IDsObjectPicker_QueryInterface( return S_OK; } - FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + FIXME("- no interface IID: %s\n", debugstr_guid(riid)); return E_NOINTERFACE; } diff --git a/dll/win32/oleacc/oleacc.rc b/dll/win32/oleacc/oleacc.rc index fcffbc11ce9..460ff1bf8a1 100644 --- a/dll/win32/oleacc/oleacc.rc +++ b/dll/win32/oleacc/oleacc.rc @@ -22,7 +22,15 @@ #include "oleacc.h" #include "oleacc_En.rc" -#include "oleacc_Fr.rc" #include "oleacc_Ko.rc" #include "oleacc_Nl.rc" #include "oleacc_Pl.rc" + +/* UTF-8 */ +#include "oleacc_De.rc" +#include "oleacc_Fr.rc" +#include "oleacc_Lt.rc" +#include "oleacc_No.rc" +#include "oleacc_Pt.rc" +#include "oleacc_Ro.rc" + diff --git a/dll/win32/oleacc/oleacc_De.rc b/dll/win32/oleacc/oleacc_De.rc new file mode 100644 index 00000000000..f15cc2dcbba --- /dev/null +++ b/dll/win32/oleacc/oleacc_De.rc @@ -0,0 +1,94 @@ +/* + * German resources for oleacc + * + * Copyright 2009 André Hentschel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +#pragma code_page(65001) + +LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + 0 "unbekanntes Objekt" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "Titelleiste" + ROLE_SYSTEM_MENUBAR "Menüleiste" + ROLE_SYSTEM_SCROLLBAR "Bildlaufleiste" + ROLE_SYSTEM_GRIP "Fangpunkt" + ROLE_SYSTEM_SOUND "Audio" + ROLE_SYSTEM_CURSOR "Cursor" + ROLE_SYSTEM_CARET "Caret-Zeichen" + ROLE_SYSTEM_ALERT "Warnung" + ROLE_SYSTEM_WINDOW "Fenster" + ROLE_SYSTEM_CLIENT "Client" + ROLE_SYSTEM_MENUPOPUP "Kontextmenü" + ROLE_SYSTEM_MENUITEM "Menübefehl" + ROLE_SYSTEM_TOOLTIP "Tooltip" + ROLE_SYSTEM_APPLICATION "Anwendung" + ROLE_SYSTEM_DOCUMENT "Dokument" + ROLE_SYSTEM_PANE "Ausschnitt" + ROLE_SYSTEM_CHART "Diagramm" + ROLE_SYSTEM_DIALOG "Dialog" + ROLE_SYSTEM_BORDER "Rahmen" + ROLE_SYSTEM_GROUPING "Gruppierung" + ROLE_SYSTEM_SEPARATOR "Trennlinie" + ROLE_SYSTEM_TOOLBAR "Symbolleiste" + ROLE_SYSTEM_STATUSBAR "Statusleiste" + ROLE_SYSTEM_TABLE "Tabelle" + ROLE_SYSTEM_COLUMNHEADER "Spaltenkopf" + ROLE_SYSTEM_ROWHEADER "Zeilenkopf" + ROLE_SYSTEM_COLUMN "Spalte" + ROLE_SYSTEM_ROW "Zeile" + ROLE_SYSTEM_CELL "Zelle" + ROLE_SYSTEM_LINK "Link" + ROLE_SYSTEM_HELPBALLOON "Hilfesprechblase" + ROLE_SYSTEM_CHARACTER "Assistent" + ROLE_SYSTEM_LIST "Liste" + ROLE_SYSTEM_LISTITEM "Listenelement" + ROLE_SYSTEM_OUTLINE "Gliederung" + ROLE_SYSTEM_OUTLINEITEM "Gliederungselement" + ROLE_SYSTEM_PAGETAB "Registerkarte" + ROLE_SYSTEM_PROPERTYPAGE "Eigenschaftenseite" + ROLE_SYSTEM_INDICATOR "Anzeige" + ROLE_SYSTEM_GRAPHIC "Grafik" + ROLE_SYSTEM_STATICTEXT "Text" + ROLE_SYSTEM_TEXT "Text" + ROLE_SYSTEM_PUSHBUTTON "Schaltfläche" + ROLE_SYSTEM_CHECKBUTTON "Kontrollkästchen" + ROLE_SYSTEM_RADIOBUTTON "Optionskästchen" + ROLE_SYSTEM_COMBOBOX "Kombinationsfeld" + ROLE_SYSTEM_DROPLIST "Drop Down" + ROLE_SYSTEM_PROGRESSBAR "Fortschrittsanzeige" + ROLE_SYSTEM_DIAL "wählen" + ROLE_SYSTEM_HOTKEYFIELD "Schnellzugriffsfeld" + ROLE_SYSTEM_SLIDER "Schieberegler" + ROLE_SYSTEM_SPINBUTTON "Drehfeld" + ROLE_SYSTEM_DIAGRAM "Diagramm" + ROLE_SYSTEM_ANIMATION "Animation" + ROLE_SYSTEM_EQUATION "Gleichung" + ROLE_SYSTEM_BUTTONDROPDOWN "Dropdown Schaltfläche" + ROLE_SYSTEM_BUTTONMENU "Menü Schaltfläche" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "Raster Dropdown Schaltfläche" + ROLE_SYSTEM_WHITESPACE "Leerzeichen" + ROLE_SYSTEM_PAGETABLIST "Register" + ROLE_SYSTEM_CLOCK "Uhr" + ROLE_SYSTEM_SPLITBUTTON "Trenn Schaltfläche" + ROLE_SYSTEM_IPADDRESS "IP Addresse" + ROLE_SYSTEM_OUTLINEBUTTON "Gliederung Schaltfläche" +} diff --git a/dll/win32/oleacc/oleacc_En.rc b/dll/win32/oleacc/oleacc_En.rc index 992d29c93f0..5c1af2de217 100644 --- a/dll/win32/oleacc/oleacc_En.rc +++ b/dll/win32/oleacc/oleacc_En.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/oleacc/oleacc_Fr.rc b/dll/win32/oleacc/oleacc_Fr.rc index 87bea0b5247..8eabc3cd4d5 100644 --- a/dll/win32/oleacc/oleacc_Fr.rc +++ b/dll/win32/oleacc/oleacc_Fr.rc @@ -2,6 +2,7 @@ * French resources for oleacc * * Copyright 2008 Jonathan Ernst + * Copyright 2009 Frédéric Delanoy * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,32 +19,37 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + +/* UTF-8 */ +#pragma code_page(65001) + LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE { - 0 "objet inconnu" /* undocumented */ + 0 "objet inconnu" /* non documenté */ ROLE_SYSTEM_TITLEBAR "barre de titre" - ROLE_SYSTEM_MENUBAR "barre de menu" + ROLE_SYSTEM_MENUBAR "barre de menus" ROLE_SYSTEM_SCROLLBAR "barre de défilement" - ROLE_SYSTEM_GRIP "grip" + ROLE_SYSTEM_GRIP "poignée" ROLE_SYSTEM_SOUND "son" ROLE_SYSTEM_CURSOR "curseur" - ROLE_SYSTEM_CARET "caret" + ROLE_SYSTEM_CARET "curseur texte" ROLE_SYSTEM_ALERT "alerte" ROLE_SYSTEM_WINDOW "fenêtre" ROLE_SYSTEM_CLIENT "client" - ROLE_SYSTEM_MENUPOPUP "menu popup" + ROLE_SYSTEM_MENUPOPUP "menu contextuel" ROLE_SYSTEM_MENUITEM "élément de menu" ROLE_SYSTEM_TOOLTIP "infobulle" ROLE_SYSTEM_APPLICATION "application" ROLE_SYSTEM_DOCUMENT "document" - ROLE_SYSTEM_PANE "pane" - ROLE_SYSTEM_CHART "chart" + ROLE_SYSTEM_PANE "panneau" + ROLE_SYSTEM_CHART "diagramme" ROLE_SYSTEM_DIALOG "boîte de dialogue" ROLE_SYSTEM_BORDER "bordure" - ROLE_SYSTEM_GROUPING "grouping" - ROLE_SYSTEM_SEPARATOR "separateur" + ROLE_SYSTEM_GROUPING "groupement" + ROLE_SYSTEM_SEPARATOR "séparateur" ROLE_SYSTEM_TOOLBAR "barre d'outils" ROLE_SYSTEM_STATUSBAR "barre d'état" ROLE_SYSTEM_TABLE "table" @@ -57,8 +63,8 @@ STRINGTABLE DISCARDABLE ROLE_SYSTEM_CHARACTER "caractère" ROLE_SYSTEM_LIST "liste" ROLE_SYSTEM_LISTITEM "élément de liste" - ROLE_SYSTEM_OUTLINE "outline" - ROLE_SYSTEM_OUTLINEITEM "outline item" + ROLE_SYSTEM_OUTLINE "plan" + ROLE_SYSTEM_OUTLINEITEM "élément du plan" ROLE_SYSTEM_PAGETAB "onglet de page" ROLE_SYSTEM_PROPERTYPAGE "page de propriétés" ROLE_SYSTEM_INDICATOR "indicateur" @@ -68,23 +74,23 @@ STRINGTABLE DISCARDABLE ROLE_SYSTEM_PUSHBUTTON "bouton pressoir" ROLE_SYSTEM_CHECKBUTTON "case à cocher" ROLE_SYSTEM_RADIOBUTTON "bouton radio" - ROLE_SYSTEM_COMBOBOX "combo box" - ROLE_SYSTEM_DROPLIST "drop down" + ROLE_SYSTEM_COMBOBOX "boîte combinée" + ROLE_SYSTEM_DROPLIST "liste déroulante" ROLE_SYSTEM_PROGRESSBAR "barre de progression" - ROLE_SYSTEM_DIAL "dial" - ROLE_SYSTEM_HOTKEYFIELD "hot key field" - ROLE_SYSTEM_SLIDER "slider" - ROLE_SYSTEM_SPINBUTTON "spin box" + ROLE_SYSTEM_DIAL "cadran" + ROLE_SYSTEM_HOTKEYFIELD "champ avec raccourci clavier" + ROLE_SYSTEM_SLIDER "glissière" + ROLE_SYSTEM_SPINBUTTON "bouton fléché" ROLE_SYSTEM_DIAGRAM "diagramme" ROLE_SYSTEM_ANIMATION "animation" ROLE_SYSTEM_EQUATION "équation" - ROLE_SYSTEM_BUTTONDROPDOWN "drop down button" + ROLE_SYSTEM_BUTTONDROPDOWN "bouton avec liste déroulante" ROLE_SYSTEM_BUTTONMENU "bouton de menu" - ROLE_SYSTEM_BUTTONDROPDOWNGRID "grid drop down button" - ROLE_SYSTEM_WHITESPACE "espace blanc" - ROLE_SYSTEM_PAGETABLIST "page tab list" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "bouton avec grille déroulante" + ROLE_SYSTEM_WHITESPACE "blanc" + ROLE_SYSTEM_PAGETABLIST "liste d'onglets de pages" ROLE_SYSTEM_CLOCK "horloge" - ROLE_SYSTEM_SPLITBUTTON "split button" - ROLE_SYSTEM_IPADDRESS "Adresse IP" - ROLE_SYSTEM_OUTLINEBUTTON "outline button" + ROLE_SYSTEM_SPLITBUTTON "bouton avec menu" + ROLE_SYSTEM_IPADDRESS "adresse IP" + ROLE_SYSTEM_OUTLINEBUTTON "bouton de résumé" } diff --git a/dll/win32/oleacc/oleacc_Ko.rc b/dll/win32/oleacc/oleacc_Ko.rc index a1993f133f9..919b8d4e5f2 100644 --- a/dll/win32/oleacc/oleacc_Ko.rc +++ b/dll/win32/oleacc/oleacc_Ko.rc @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE diff --git a/dll/win32/oleacc/oleacc_Lt.rc b/dll/win32/oleacc/oleacc_Lt.rc new file mode 100644 index 00000000000..4056c3dd9d6 --- /dev/null +++ b/dll/win32/oleacc/oleacc_Lt.rc @@ -0,0 +1,95 @@ +/* + * Lithuanian resources for oleacc + * + * Copyright 2009 Aurimas Fišeras + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + 0 "nežinomas objektas" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "lango antraštės juosta" + ROLE_SYSTEM_MENUBAR "meniu juosta" + ROLE_SYSTEM_SCROLLBAR "slankjuostė" + ROLE_SYSTEM_GRIP "rankenėlė" + ROLE_SYSTEM_SOUND "garsas" + ROLE_SYSTEM_CURSOR "pelės žymeklis" + ROLE_SYSTEM_CARET "žymeklis" + ROLE_SYSTEM_ALERT "įspėjimas" + ROLE_SYSTEM_WINDOW "langas" + ROLE_SYSTEM_CLIENT "klientas" + ROLE_SYSTEM_MENUPOPUP "iškylantis meniu" + ROLE_SYSTEM_MENUITEM "meniu elementas" + ROLE_SYSTEM_TOOLTIP "paaiškinimas" + ROLE_SYSTEM_APPLICATION "programa" + ROLE_SYSTEM_DOCUMENT "dokumentas" + ROLE_SYSTEM_PANE "polangis" + ROLE_SYSTEM_CHART "diagrama" + ROLE_SYSTEM_DIALOG "dialogo langas" + ROLE_SYSTEM_BORDER "rėmelis" + ROLE_SYSTEM_GROUPING "grupavimas" + ROLE_SYSTEM_SEPARATOR "skirtukas" + ROLE_SYSTEM_TOOLBAR "įrankių juosta" + ROLE_SYSTEM_STATUSBAR "būsenos juosta" + ROLE_SYSTEM_TABLE "lentelė" + ROLE_SYSTEM_COLUMNHEADER "stulpelio antraštė" + ROLE_SYSTEM_ROWHEADER "eilutės antraštė" + ROLE_SYSTEM_COLUMN "stulpelis" + ROLE_SYSTEM_ROW "eilutė" + ROLE_SYSTEM_CELL "langelis" + ROLE_SYSTEM_LINK "nuoroda" + ROLE_SYSTEM_HELPBALLOON "pagalbos balionas" + ROLE_SYSTEM_CHARACTER "personažas" + ROLE_SYSTEM_LIST "sąrašas" + ROLE_SYSTEM_LISTITEM "sąrašo elementas" + ROLE_SYSTEM_OUTLINE "planas" + ROLE_SYSTEM_OUTLINEITEM "plano elementas" + ROLE_SYSTEM_PAGETAB "kortelė" + ROLE_SYSTEM_PROPERTYPAGE "savybių lapas" + ROLE_SYSTEM_INDICATOR "indikatorius" + ROLE_SYSTEM_GRAPHIC "grafika" + ROLE_SYSTEM_STATICTEXT "statinis tekstas" + ROLE_SYSTEM_TEXT "tekstas" + ROLE_SYSTEM_PUSHBUTTON "mygtukas" + ROLE_SYSTEM_CHECKBUTTON "žymimasis langelis" + ROLE_SYSTEM_RADIOBUTTON "akutė" + ROLE_SYSTEM_COMBOBOX "jungtinis langelis" + ROLE_SYSTEM_DROPLIST "išskleidžiamasis sąrašas" + ROLE_SYSTEM_PROGRESSBAR "eigos juosta" + ROLE_SYSTEM_DIAL "sukiojama rankenėlė" + ROLE_SYSTEM_HOTKEYFIELD "sparčiojo klavišo laukas" + ROLE_SYSTEM_SLIDER "šliaužiklis" + ROLE_SYSTEM_SPINBUTTON "suktukas" + ROLE_SYSTEM_DIAGRAM "schema" + ROLE_SYSTEM_ANIMATION "animacija" + ROLE_SYSTEM_EQUATION "lygtis" + ROLE_SYSTEM_BUTTONDROPDOWN "išskleidžiamasis mygtukas" + ROLE_SYSTEM_BUTTONMENU "meniu mygtukas" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "tinklelio išskleidžiamasis mygtukas" + ROLE_SYSTEM_WHITESPACE "matomas tarpas" + ROLE_SYSTEM_PAGETABLIST "kortelių sąrašas" + ROLE_SYSTEM_CLOCK "laikrodis" + ROLE_SYSTEM_SPLITBUTTON "išskleidimo mygtukas" + ROLE_SYSTEM_IPADDRESS "IP adresas" + ROLE_SYSTEM_OUTLINEBUTTON "plano mygtukas" +} diff --git a/dll/win32/oleacc/oleacc_Nl.rc b/dll/win32/oleacc/oleacc_Nl.rc index b639128a9d9..47daa1fba20 100644 --- a/dll/win32/oleacc/oleacc_Nl.rc +++ b/dll/win32/oleacc/oleacc_Nl.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE @@ -76,8 +78,8 @@ STRINGTABLE DISCARDABLE ROLE_SYSTEM_SLIDER "schuifknop" ROLE_SYSTEM_SPINBUTTON "spin box" ROLE_SYSTEM_DIAGRAM "diagram" - ROLE_SYSTEM_ANIMATION "animation" - ROLE_SYSTEM_EQUATION "formula" + ROLE_SYSTEM_ANIMATION "animatie" + ROLE_SYSTEM_EQUATION "formule" ROLE_SYSTEM_BUTTONDROPDOWN "dropdown knop" ROLE_SYSTEM_BUTTONMENU "menu knop" ROLE_SYSTEM_BUTTONDROPDOWNGRID "dropdown grid knop" diff --git a/dll/win32/oleacc/oleacc_No.rc b/dll/win32/oleacc/oleacc_No.rc new file mode 100644 index 00000000000..1bbadf0507c --- /dev/null +++ b/dll/win32/oleacc/oleacc_No.rc @@ -0,0 +1,95 @@ +/* + * Norwegian Bokmål resources for oleacc + * + * Copyright 2009 Alexander N. Sørnes + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL + +STRINGTABLE DISCARDABLE +{ + 0 "unknown object" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "tittellinje" + ROLE_SYSTEM_MENUBAR "menylinje" + ROLE_SYSTEM_SCROLLBAR "rullefelt" + ROLE_SYSTEM_GRIP "grip" + ROLE_SYSTEM_SOUND "lyd" + ROLE_SYSTEM_CURSOR "peker" + ROLE_SYSTEM_CARET "markør" + ROLE_SYSTEM_ALERT "varsel" + ROLE_SYSTEM_WINDOW "vindu" + ROLE_SYSTEM_CLIENT "klient" + ROLE_SYSTEM_MENUPOPUP "sprettoppmeny" + ROLE_SYSTEM_MENUITEM "menyelement" + ROLE_SYSTEM_TOOLTIP "verktøytips" + ROLE_SYSTEM_APPLICATION "program" + ROLE_SYSTEM_DOCUMENT "dokument" + ROLE_SYSTEM_PANE "panel" + ROLE_SYSTEM_CHART "diagram" + ROLE_SYSTEM_DIALOG "meldingsvindu" + ROLE_SYSTEM_BORDER "kant" + ROLE_SYSTEM_GROUPING "gruppering" + ROLE_SYSTEM_SEPARATOR "skille" + ROLE_SYSTEM_TOOLBAR "verktøylinje" + ROLE_SYSTEM_STATUSBAR "status bar" + ROLE_SYSTEM_TABLE "tabell" + ROLE_SYSTEM_COLUMNHEADER "kolonneoverskrift" + ROLE_SYSTEM_ROWHEADER "radoverskrift" + ROLE_SYSTEM_COLUMN "kolonne" + ROLE_SYSTEM_ROW "rad" + ROLE_SYSTEM_CELL "celle" + ROLE_SYSTEM_LINK "kobling" + ROLE_SYSTEM_HELPBALLOON "hjelpetekst" + ROLE_SYSTEM_CHARACTER "tegn" + ROLE_SYSTEM_LIST "liste" + ROLE_SYSTEM_LISTITEM "listeelement" + ROLE_SYSTEM_OUTLINE "utheving" + ROLE_SYSTEM_OUTLINEITEM "uthevet element" + ROLE_SYSTEM_PAGETAB "sidefane" + ROLE_SYSTEM_PROPERTYPAGE "fane" + ROLE_SYSTEM_INDICATOR "indikator" + ROLE_SYSTEM_GRAPHIC "grafikk" + ROLE_SYSTEM_STATICTEXT "statisk tekst" + ROLE_SYSTEM_TEXT "tekst" + ROLE_SYSTEM_PUSHBUTTON "knapp" + ROLE_SYSTEM_CHECKBUTTON "avkrysningsboks" + ROLE_SYSTEM_RADIOBUTTON "radioknapp" + ROLE_SYSTEM_COMBOBOX "komboboks" + ROLE_SYSTEM_DROPLIST "rullemeny" + ROLE_SYSTEM_PROGRESSBAR "framgangsindikator" + ROLE_SYSTEM_DIAL "hjul" + ROLE_SYSTEM_HOTKEYFIELD "felt for hurtigtaster" + ROLE_SYSTEM_SLIDER "rullefelt" + ROLE_SYSTEM_SPINBUTTON "rullemeny" + ROLE_SYSTEM_DIAGRAM "diagram" + ROLE_SYSTEM_ANIMATION "animasjon" + ROLE_SYSTEM_EQUATION "likning" + ROLE_SYSTEM_BUTTONDROPDOWN "knapp for rullemeny" + ROLE_SYSTEM_BUTTONMENU "menyknapp" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "felt for rullemeny-knapp" + ROLE_SYSTEM_WHITESPACE "mellomrom" + ROLE_SYSTEM_PAGETABLIST "faneliste" + ROLE_SYSTEM_CLOCK "klokke" + ROLE_SYSTEM_SPLITBUTTON "oppdelt knapp" + ROLE_SYSTEM_IPADDRESS "IP-adresse" + ROLE_SYSTEM_OUTLINEBUTTON "utheving for knapp" +} diff --git a/dll/win32/oleacc/oleacc_Pl.rc b/dll/win32/oleacc/oleacc_Pl.rc index fc93cb052c3..5d45368cf13 100644 --- a/dll/win32/oleacc/oleacc_Pl.rc +++ b/dll/win32/oleacc/oleacc_Pl.rc @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "oleacc.h" + LANGUAGE LANG_POLISH, SUBLANG_NEUTRAL STRINGTABLE DISCARDABLE diff --git a/dll/win32/oleacc/oleacc_Pt.rc b/dll/win32/oleacc/oleacc_Pt.rc new file mode 100644 index 00000000000..395324a4330 --- /dev/null +++ b/dll/win32/oleacc/oleacc_Pt.rc @@ -0,0 +1,94 @@ +/* + * Portuguese resources for oleacc + * + * Copyright 2009 Ricardo Filipe + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +#pragma code_page(65001) + +LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE + +STRINGTABLE DISCARDABLE +{ + 0 "objecto desconhecido" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "barra de título" + ROLE_SYSTEM_MENUBAR "barra de menu" + ROLE_SYSTEM_SCROLLBAR "barra de scroll" + ROLE_SYSTEM_GRIP "grip" + ROLE_SYSTEM_SOUND "som" + ROLE_SYSTEM_CURSOR "cursor" + ROLE_SYSTEM_CARET "caret" + ROLE_SYSTEM_ALERT "alerta" + ROLE_SYSTEM_WINDOW "janela" + ROLE_SYSTEM_CLIENT "cliente" + ROLE_SYSTEM_MENUPOPUP "popup menu" + ROLE_SYSTEM_MENUITEM "item do menu" + ROLE_SYSTEM_TOOLTIP "dica" + ROLE_SYSTEM_APPLICATION "aplicação" + ROLE_SYSTEM_DOCUMENT "documento" + ROLE_SYSTEM_PANE "painel" + ROLE_SYSTEM_CHART "gráfico" + ROLE_SYSTEM_DIALOG "diálogo" + ROLE_SYSTEM_BORDER "margem" + ROLE_SYSTEM_GROUPING "agrupamento" + ROLE_SYSTEM_SEPARATOR "separador" + ROLE_SYSTEM_TOOLBAR "barra de ferramentas" + ROLE_SYSTEM_STATUSBAR "barra de estado" + ROLE_SYSTEM_TABLE "tabela" + ROLE_SYSTEM_COLUMNHEADER "cabeçalho da coluna" + ROLE_SYSTEM_ROWHEADER "cabeçalho da linha" + ROLE_SYSTEM_COLUMN "coluna" + ROLE_SYSTEM_ROW "linha" + ROLE_SYSTEM_CELL "célula" + ROLE_SYSTEM_LINK "ligação" + ROLE_SYSTEM_HELPBALLOON "balão de ajuda" + ROLE_SYSTEM_CHARACTER "caracter" + ROLE_SYSTEM_LIST "lista" + ROLE_SYSTEM_LISTITEM "item da lista" + ROLE_SYSTEM_OUTLINE "delinear" + ROLE_SYSTEM_OUTLINEITEM "item delinear" + ROLE_SYSTEM_PAGETAB "tab de página" + ROLE_SYSTEM_PROPERTYPAGE "página de propriedades" + ROLE_SYSTEM_INDICATOR "indicador" + ROLE_SYSTEM_GRAPHIC "gráfico" + ROLE_SYSTEM_STATICTEXT "texto estático" + ROLE_SYSTEM_TEXT "texto" + ROLE_SYSTEM_PUSHBUTTON "push button" + ROLE_SYSTEM_CHECKBUTTON "check button" + ROLE_SYSTEM_RADIOBUTTON "radio button" + ROLE_SYSTEM_COMBOBOX "combo box" + ROLE_SYSTEM_DROPLIST "drop down" + ROLE_SYSTEM_PROGRESSBAR "barra de progresso" + ROLE_SYSTEM_DIAL "dial" + ROLE_SYSTEM_HOTKEYFIELD "hot key field" + ROLE_SYSTEM_SLIDER "slider" + ROLE_SYSTEM_SPINBUTTON "spin box" + ROLE_SYSTEM_DIAGRAM "diagrama" + ROLE_SYSTEM_ANIMATION "animação" + ROLE_SYSTEM_EQUATION "equação" + ROLE_SYSTEM_BUTTONDROPDOWN "drop down button" + ROLE_SYSTEM_BUTTONMENU "menu button" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "grid drop down button" + ROLE_SYSTEM_WHITESPACE "espaço em branco" + ROLE_SYSTEM_PAGETABLIST "page tab list" + ROLE_SYSTEM_CLOCK "relógio" + ROLE_SYSTEM_SPLITBUTTON "split button" + ROLE_SYSTEM_IPADDRESS "endereço IP" + ROLE_SYSTEM_OUTLINEBUTTON "outline button" +} diff --git a/dll/win32/oleacc/oleacc_Ro.rc b/dll/win32/oleacc/oleacc_Ro.rc new file mode 100644 index 00000000000..52fc47b7dcb --- /dev/null +++ b/dll/win32/oleacc/oleacc_Ro.rc @@ -0,0 +1,93 @@ +/* + * Copyright 2008 Nikolay Sivov + * Copyright 2009 Michael Stefaniuc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "oleacc.h" + +LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL + +#pragma code_page(65001) + +STRINGTABLE DISCARDABLE +{ + 0 "obiect necunoscut" /* undocumented */ + ROLE_SYSTEM_TITLEBAR "bară de titlu" + ROLE_SYSTEM_MENUBAR "bară de meniu" + ROLE_SYSTEM_SCROLLBAR "bară de defilare" + ROLE_SYSTEM_GRIP "ghidaj" + ROLE_SYSTEM_SOUND "sunet" + ROLE_SYSTEM_CURSOR "cursor" + ROLE_SYSTEM_CARET "circumflex" + ROLE_SYSTEM_ALERT "atenționare" + ROLE_SYSTEM_WINDOW "fereastră" + ROLE_SYSTEM_CLIENT "client" + ROLE_SYSTEM_MENUPOPUP "meniu contextual" + ROLE_SYSTEM_MENUITEM "element de meniu" + ROLE_SYSTEM_TOOLTIP "indiciu" + ROLE_SYSTEM_APPLICATION "aplicație" + ROLE_SYSTEM_DOCUMENT "document" + ROLE_SYSTEM_PANE "panou" + ROLE_SYSTEM_CHART "diagramă" + ROLE_SYSTEM_DIALOG "dialog" + ROLE_SYSTEM_BORDER "margine" + ROLE_SYSTEM_GROUPING "grupare" + ROLE_SYSTEM_SEPARATOR "separator" + ROLE_SYSTEM_TOOLBAR "bară de unelte" + ROLE_SYSTEM_STATUSBAR "bară de stare" + ROLE_SYSTEM_TABLE "tabel" + ROLE_SYSTEM_COLUMNHEADER "antet de coloană" + ROLE_SYSTEM_ROWHEADER "antet de rând" + ROLE_SYSTEM_COLUMN "coloană" + ROLE_SYSTEM_ROW "rând" + ROLE_SYSTEM_CELL "celulă" + ROLE_SYSTEM_LINK "legătură" + ROLE_SYSTEM_HELPBALLOON "balon de ajutor" + ROLE_SYSTEM_CHARACTER "caracter" + ROLE_SYSTEM_LIST "listă" + ROLE_SYSTEM_LISTITEM "element din listă" + ROLE_SYSTEM_OUTLINE "contur" + ROLE_SYSTEM_OUTLINEITEM "conturare element" + ROLE_SYSTEM_PAGETAB "filă" + ROLE_SYSTEM_PROPERTYPAGE "pagină de proprietăți" + ROLE_SYSTEM_INDICATOR "indicator" + ROLE_SYSTEM_GRAPHIC "grafică" + ROLE_SYSTEM_STATICTEXT "text static" + ROLE_SYSTEM_TEXT "text" + ROLE_SYSTEM_PUSHBUTTON "buton de comandă" + ROLE_SYSTEM_CHECKBUTTON "buton de bifare" + ROLE_SYSTEM_RADIOBUTTON "buton radio" + ROLE_SYSTEM_COMBOBOX "căsuță combinată" + ROLE_SYSTEM_DROPLIST "listă verticală" + ROLE_SYSTEM_PROGRESSBAR "bară de progres" + ROLE_SYSTEM_DIAL "apelator" + ROLE_SYSTEM_HOTKEYFIELD "câmp de tastă rapidă" + ROLE_SYSTEM_SLIDER "glisor" + ROLE_SYSTEM_SPINBUTTON "căsuță incrementală" + ROLE_SYSTEM_DIAGRAM "diagramă" + ROLE_SYSTEM_ANIMATION "animație" + ROLE_SYSTEM_EQUATION "ecuație" + ROLE_SYSTEM_BUTTONDROPDOWN "buton listă verticală" + ROLE_SYSTEM_BUTTONMENU "buton meniu" + ROLE_SYSTEM_BUTTONDROPDOWNGRID "buton listă verticală de grilă" + ROLE_SYSTEM_WHITESPACE "spațiu gol" + ROLE_SYSTEM_PAGETABLIST "listă de file" + ROLE_SYSTEM_CLOCK "ceas" + ROLE_SYSTEM_SPLITBUTTON "buton separare" + ROLE_SYSTEM_IPADDRESS "adresă IP" + ROLE_SYSTEM_OUTLINEBUTTON "buton contur" +} diff --git a/dll/win32/oledlg/insobjdlg.c b/dll/win32/oledlg/insobjdlg.c index 5db79f61109..01d242e6322 100644 --- a/dll/win32/oledlg/insobjdlg.c +++ b/dll/win32/oledlg/insobjdlg.c @@ -380,7 +380,7 @@ static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo) *lpclsid = clsid; len = SendMessageW(pdlgInfo->hwndObjTypeLB, LB_ADDSTRING, 0, (LPARAM)keydesc); - SendMessageW(pdlgInfo->hwndObjTypeLB, LB_SETITEMDATA, (WPARAM)len, (LPARAM)lpclsid); + SendMessageW(pdlgInfo->hwndObjTypeLB, LB_SETITEMDATA, len, (LPARAM)lpclsid); } } @@ -426,7 +426,7 @@ static void UIINSERTOBJECTDLG_SelChange(InsertObjectDlgInfo* pdlgInfo) if (LoadStringW(OLEDLG_hInstance, IDS_RESULTOBJDESC, resstr, MAX_PATH) && ((index = SendMessageW(pdlgInfo->hwndObjTypeLB, LB_GETCURSEL, 0, 0)) >= 0) && - SendMessageW(pdlgInfo->hwndObjTypeLB, LB_GETTEXT, (WPARAM)index, (LPARAM)objname)) + SendMessageW(pdlgInfo->hwndObjTypeLB, LB_GETTEXT, index, (LPARAM)objname)) wsprintfW(objdesc, resstr, objname); else objdesc[0] = 0; @@ -452,7 +452,7 @@ static BOOL UIINSERTOBJECTDLG_OnOpen(InsertObjectDlgInfo* pdlgInfo) if (index >= 0) { CLSID* clsid = (CLSID*) SendMessageA(pdlgInfo->hwndObjTypeLB, - LB_GETITEMDATA, (WPARAM)index, 0); + LB_GETITEMDATA, index, 0); pdlgInfo->lpOleUIInsertObject->clsid = *clsid; if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CREATENEWOBJECT) @@ -525,7 +525,7 @@ static void UIINSERTOBJECTDLG_BrowseFile(InsertObjectDlgInfo* pdlgInfo) fn.nMaxCustFilter = 0; fn.nFilterIndex = 0; - SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)fname); + SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, MAX_PATH, (LPARAM)fname); fn.lpstrFile = fname; fn.nMaxFile = MAX_PATH; diff --git a/dll/win32/oledlg/oledlg_De.rc b/dll/win32/oledlg/oledlg_De.rc index 6f892091705..498fa80196b 100644 --- a/dll/win32/oledlg/oledlg_De.rc +++ b/dll/win32/oledlg/oledlg_De.rc @@ -75,11 +75,11 @@ BEGIN CONTROL "OK", IDOK, "Button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP | WS_VISIBLE, 224, 6, 66, 14 CONTROL "Abbrechen", IDCANCEL, "Button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE, 224, 23, 66, 14 CONTROL "&Hilfe", IDC_OLEUIHELP, "Button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE, 224, 42, 66, 14 - CONTROL "Als Symbol &darstellen", IDC_PS_DISPLAYASICON, "Button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE, 224, 59, 66, 14 + CONTROL "Als Sym&bol", IDC_PS_DISPLAYASICON, "Button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE, 224, 59, 66, 14 CONTROL "", IDC_PS_ICONDISPLAY, "Static", SS_ICON | WS_VISIBLE, 224, 75, 66, 44 CONTROL "&Symbol ändern...", IDC_PS_CHANGEICON, "Button", BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE, 224, 123, 66, 14 CONTROL "", IDC_PS_RESULTIMAGE, "Static", SS_ICON | WS_VISIBLE, 8, 101, 42, 34 - CONTROL "<< result text goes here >>", IDC_PS_RESULTTEXT, "Static", SS_NOPREFIX | WS_VISIBLE, 54, 100, 159, 35 + CONTROL "<< Ergebnis Text hier her >>", IDC_PS_RESULTTEXT, "Static", SS_NOPREFIX | WS_VISIBLE, 54, 100, 159, 35 CONTROL "Ergebnis", -1, "Button", BS_GROUPBOX | WS_GROUP | WS_VISIBLE, 6, 90, 212, 48 CONTROL "", IDC_PS_SOURCETEXT, "Edit", ES_READONLY | ES_AUTOHSCROLL | WS_VISIBLE, 37, 9, 180, 8 END diff --git a/dll/win32/oledlg/rsrc.rc b/dll/win32/oledlg/rsrc.rc index ef8e0ff42de..5966190236d 100644 --- a/dll/win32/oledlg/rsrc.rc +++ b/dll/win32/oledlg/rsrc.rc @@ -35,22 +35,25 @@ */ #include "oledlg_Cs.rc" #include "oledlg_Da.rc" -#include "oledlg_De.rc" #include "oledlg_En.rc" #include "oledlg_Es.rc" -#include "oledlg_Fr.rc" #include "oledlg_Hu.rc" #include "oledlg_It.rc" -#include "oledlg_Ja.rc" #include "oledlg_Ko.rc" -#include "oledlg_Lt.rc" #include "oledlg_Nl.rc" #include "oledlg_No.rc" #include "oledlg_Pl.rc" -#include "oledlg_Pt.rc" -#include "oledlg_Ru.rc" -#include "oledlg_Si.rc" #include "oledlg_Sv.rc" #include "oledlg_Tr.rc" #include "oledlg_Uk.rc" + +/* UTF-8 */ +#include "oledlg_De.rc" +#include "oledlg_Fr.rc" +#include "oledlg_Ja.rc" +#include "oledlg_Lt.rc" +#include "oledlg_Pt.rc" +#include "oledlg_Ru.rc" +#include "oledlg_Si.rc" #include "oledlg_Zh.rc" + diff --git a/dll/win32/olepro32/olepro32stubs.c b/dll/win32/olepro32/olepro32stubs.c index 04b1868dfc0..a93c24cb320 100644 --- a/dll/win32/olepro32/olepro32stubs.c +++ b/dll/win32/olepro32/olepro32stubs.c @@ -53,7 +53,6 @@ HRESULT WINAPI DllRegisterServer(void) */ HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("stub\n"); return S_OK; } diff --git a/dll/win32/pdh/pdh.spec b/dll/win32/pdh/pdh.spec index 135692f8c67..b475d5392c6 100644 --- a/dll/win32/pdh/pdh.spec +++ b/dll/win32/pdh/pdh.spec @@ -38,10 +38,10 @@ @ stub PdhEnumObjectsW @ stub PdhExpandCounterPathA @ stub PdhExpandCounterPathW -@ stub PdhExpandWildCardPathA +@ stdcall PdhExpandWildCardPathA(str str ptr ptr long) @ stub PdhExpandWildCardPathHA @ stub PdhExpandWildCardPathHW -@ stub PdhExpandWildCardPathW +@ stdcall PdhExpandWildCardPathW(wstr wstr ptr ptr long) @ stub PdhFormatFromRawValue @ stdcall PdhGetCounterInfoA(ptr long ptr ptr) @ stdcall PdhGetCounterInfoW(ptr long ptr ptr) @@ -57,7 +57,7 @@ @ stub PdhGetDefaultPerfObjectHA @ stub PdhGetDefaultPerfObjectHW @ stub PdhGetDefaultPerfObjectW -@ stub PdhGetDllVersion +@ stdcall PdhGetDllVersion(ptr) @ stub PdhGetFormattedCounterArrayA @ stub PdhGetFormattedCounterArrayW @ stdcall PdhGetFormattedCounterValue(ptr long ptr ptr) @@ -127,7 +127,7 @@ @ stub PdhSelectDataSourceA @ stub PdhSelectDataSourceW @ stdcall PdhSetCounterScaleFactor(ptr long) -@ stub PdhSetDefaultRealTimeDataSource +@ stdcall PdhSetDefaultRealTimeDataSource(long) @ stub PdhSetLogSetRunID @ stub PdhSetQueryTimeRange @ stub PdhTranslate009CounterA diff --git a/dll/win32/pdh/pdh_main.c b/dll/win32/pdh/pdh_main.c index 9ca174b957e..bdf83a94792 100644 --- a/dll/win32/pdh/pdh_main.c +++ b/dll/win32/pdh/pdh_main.c @@ -599,6 +599,24 @@ PDH_STATUS WINAPI PdhCollectQueryDataWithTime( PDH_HQUERY handle, LONGLONG *time return ERROR_SUCCESS; } +/*********************************************************************** + * PdhExpandWildCardPathA (PDH.@) + */ +PDH_STATUS WINAPI PdhExpandWildCardPathA( LPCSTR szDataSource, LPCSTR szWildCardPath, LPSTR mszExpandedPathList, LPDWORD pcchPathListLength, DWORD dwFlags ) +{ + FIXME("%s, %s, %p, %p, 0x%x: stub\n", debugstr_a(szDataSource), debugstr_a(szWildCardPath), mszExpandedPathList, pcchPathListLength, dwFlags); + return PDH_NOT_IMPLEMENTED; +} + +/*********************************************************************** + * PdhExpandWildCardPathW (PDH.@) + */ +PDH_STATUS WINAPI PdhExpandWildCardPathW( LPCWSTR szDataSource, LPCWSTR szWildCardPath, LPWSTR mszExpandedPathList, LPDWORD pcchPathListLength, DWORD dwFlags ) +{ + FIXME("%s, %s, %p, %p, 0x%x: stub\n", debugstr_w(szDataSource), debugstr_w(szWildCardPath), mszExpandedPathList, pcchPathListLength, dwFlags); + return PDH_NOT_IMPLEMENTED; +} + /*********************************************************************** * PdhGetCounterInfoA (PDH.@) */ @@ -707,6 +725,19 @@ PDH_STATUS WINAPI PdhGetCounterTimeBase( PDH_HCOUNTER handle, LONGLONG *base ) return ERROR_SUCCESS; } +/*********************************************************************** + * PdhGetDllVersion (PDH.@) + */ +PDH_STATUS WINAPI PdhGetDllVersion( LPDWORD version ) +{ + if (!version) + return PDH_INVALID_ARGUMENT; + + *version = PDH_VERSION; + + return ERROR_SUCCESS; +} + /*********************************************************************** * PdhGetFormattedCounterValue (PDH.@) */ @@ -1193,3 +1224,12 @@ PDH_STATUS WINAPI PdhEnumObjectItemsW(LPCWSTR szDataSource, LPCWSTR szMachineNam return PDH_NOT_IMPLEMENTED; } + +/*********************************************************************** + * PdhSetDefaultRealTimeDataSource (PDH.@) + */ +PDH_STATUS WINAPI PdhSetDefaultRealTimeDataSource( DWORD source ) +{ + FIXME("%u\n", source); + return ERROR_SUCCESS; +} diff --git a/dll/win32/pstorec/pstorec.c b/dll/win32/pstorec/pstorec.c index 7e6acc40c13..5b3f7e04c30 100644 --- a/dll/win32/pstorec/pstorec.c +++ b/dll/win32/pstorec/pstorec.c @@ -388,6 +388,5 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("\n"); return S_OK; } diff --git a/dll/win32/pstorec/pstorec.rbuild b/dll/win32/pstorec/pstorec.rbuild index 7bc8a8ae92b..c9d6818a777 100644 --- a/dll/win32/pstorec/pstorec.rbuild +++ b/dll/win32/pstorec/pstorec.rbuild @@ -1,8 +1,18 @@ + + + + + stdole2 + pstorec_tlb.idl + - . + . + pstorec_tlb wine uuid pstorec.c + rsrc.rc + diff --git a/dll/win32/pstorec/pstorec_tlb.idl b/dll/win32/pstorec/pstorec_tlb.idl new file mode 100644 index 00000000000..dff2e9fcb3b --- /dev/null +++ b/dll/win32/pstorec/pstorec_tlb.idl @@ -0,0 +1,21 @@ +/* + * Typelib for pstorec + * + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "pstore.idl" diff --git a/dll/win32/pstorec/rsrc.rc b/dll/win32/pstorec/rsrc.rc new file mode 100644 index 00000000000..85b6205eec8 --- /dev/null +++ b/dll/win32/pstorec/rsrc.rc @@ -0,0 +1,29 @@ +/* + * Resource file for pstorec + * + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winnls.h" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +/* @makedep: pstorec_tlb.tlb */ +1 TYPELIB LOADONCALL DISCARDABLE pstorec_tlb.tlb diff --git a/dll/win32/query/query_main.c b/dll/win32/query/query_main.c index cdf0966b052..2d4e4ae3043 100644 --- a/dll/win32/query/query_main.c +++ b/dll/win32/query/query_main.c @@ -64,7 +64,6 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) HRESULT WINAPI DllCanUnloadNow(void) { - FIXME("\n"); return S_FALSE; } diff --git a/dll/win32/rpcrt4/rpc_transport.c b/dll/win32/rpcrt4/rpc_transport.c index 735a19df648..b9077a3dc1a 100644 --- a/dll/win32/rpcrt4/rpc_transport.c +++ b/dll/win32/rpcrt4/rpc_transport.c @@ -207,7 +207,7 @@ static RPC_STATUS rpcrt4_conn_open_pipe(RpcConnection *Connection, LPCSTR pname, dwFlags |= SECURITY_DELEGATION; break; } - if (Connection->QOS->qos->IdentityTracking == RPC_C_QOS_IDENTIFY_DYNAMIC) + if (Connection->QOS->qos->IdentityTracking == RPC_C_QOS_IDENTITY_DYNAMIC) dwFlags |= SECURITY_CONTEXT_TRACKING; } pipe = CreateFileA(pname, GENERIC_READ|GENERIC_WRITE, 0, NULL, diff --git a/dll/win32/rsaenh/rsaenh.c b/dll/win32/rsaenh/rsaenh.c index 823468823d9..665bc40056f 100644 --- a/dll/win32/rsaenh/rsaenh.c +++ b/dll/win32/rsaenh/rsaenh.c @@ -1219,6 +1219,8 @@ static void destroy_key_container(OBJECTHDR *pObjectHdr) store_key_container_permissions(pKeyContainer); release_key_container_keys(pKeyContainer); } + else + release_key_container_keys(pKeyContainer); HeapFree( GetProcessHeap(), 0, pKeyContainer ); } @@ -1378,12 +1380,18 @@ static HCRYPTPROV read_key_container(PCHAR pszContainerName, DWORD dwFlags, cons (OBJECTHDR**)&pKeyContainer)) return (HCRYPTPROV)INVALID_HANDLE_VALUE; + /* read_key_value calls import_key, which calls import_private_key, + * which implicitly installs the key value into the appropriate key + * container key. Thus the ref count is incremented twice, once for + * the output key value, and once for the implicit install, and needs + * to be decremented to balance the two. + */ if (read_key_value(hKeyContainer, hKey, AT_KEYEXCHANGE, dwProtectFlags, &hCryptKey)) - pKeyContainer->hKeyExchangeKeyPair = hCryptKey; + release_handle(&handle_table, hCryptKey, RSAENH_MAGIC_KEY); if (read_key_value(hKeyContainer, hKey, AT_SIGNATURE, dwProtectFlags, &hCryptKey)) - pKeyContainer->hSignatureKeyPair = hCryptKey; + release_handle(&handle_table, hCryptKey, RSAENH_MAGIC_KEY); } return hKeyContainer; @@ -3065,9 +3073,9 @@ BOOL WINAPI RSAENH_CPGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYP if (pCryptKey) { new_key_impl(pCryptKey->aiAlgid, &pCryptKey->context, pCryptKey->dwKeyLen); setup_key(pCryptKey); - RSAENH_CPDestroyKey(hProv, pKeyContainer->hSignatureKeyPair); - copy_handle(&handle_table, *phKey, RSAENH_MAGIC_KEY, - &pKeyContainer->hSignatureKeyPair); + release_and_install_key(hProv, *phKey, + &pKeyContainer->hSignatureKeyPair, + FALSE); } break; @@ -3077,9 +3085,9 @@ BOOL WINAPI RSAENH_CPGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYP if (pCryptKey) { new_key_impl(pCryptKey->aiAlgid, &pCryptKey->context, pCryptKey->dwKeyLen); setup_key(pCryptKey); - RSAENH_CPDestroyKey(hProv, pKeyContainer->hKeyExchangeKeyPair); - copy_handle(&handle_table, *phKey, RSAENH_MAGIC_KEY, - &pKeyContainer->hKeyExchangeKeyPair); + release_and_install_key(hProv, *phKey, + &pKeyContainer->hKeyExchangeKeyPair, + FALSE); } break; @@ -4162,11 +4170,12 @@ BOOL WINAPI RSAENH_CPSignHash(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwKeySpe LPCWSTR sDescription, DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen) { - HCRYPTKEY hCryptKey; + HCRYPTKEY hCryptKey = (HCRYPTKEY)INVALID_HANDLE_VALUE; CRYPTKEY *pCryptKey; DWORD dwHashLen; BYTE abHashValue[RSAENH_MAX_HASH_SIZE]; ALG_ID aiAlgid; + BOOL ret = FALSE; TRACE("(hProv=%08lx, hHash=%08lx, dwKeySpec=%08x, sDescription=%s, dwFlags=%08x, " "pbSignature=%p, pdwSigLen=%p)\n", hProv, hHash, dwKeySpec, debugstr_w(sDescription), @@ -4183,18 +4192,19 @@ BOOL WINAPI RSAENH_CPSignHash(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwKeySpe (OBJECTHDR**)&pCryptKey)) { SetLastError(NTE_NO_KEY); - return FALSE; + goto out; } if (!pbSignature) { *pdwSigLen = pCryptKey->dwKeyLen; - return TRUE; + ret = TRUE; + goto out; } if (pCryptKey->dwKeyLen > *pdwSigLen) { SetLastError(ERROR_MORE_DATA); *pdwSigLen = pCryptKey->dwKeyLen; - return FALSE; + goto out; } *pdwSigLen = pCryptKey->dwKeyLen; @@ -4202,22 +4212,25 @@ BOOL WINAPI RSAENH_CPSignHash(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwKeySpe if (!RSAENH_CPHashData(hProv, hHash, (CONST BYTE*)sDescription, (DWORD)lstrlenW(sDescription)*sizeof(WCHAR), 0)) { - return FALSE; + goto out; } } dwHashLen = sizeof(DWORD); - if (!RSAENH_CPGetHashParam(hProv, hHash, HP_ALGID, (BYTE*)&aiAlgid, &dwHashLen, 0)) return FALSE; + if (!RSAENH_CPGetHashParam(hProv, hHash, HP_ALGID, (BYTE*)&aiAlgid, &dwHashLen, 0)) goto out; dwHashLen = RSAENH_MAX_HASH_SIZE; - if (!RSAENH_CPGetHashParam(hProv, hHash, HP_HASHVAL, abHashValue, &dwHashLen, 0)) return FALSE; + if (!RSAENH_CPGetHashParam(hProv, hHash, HP_HASHVAL, abHashValue, &dwHashLen, 0)) goto out; if (!build_hash_signature(pbSignature, *pdwSigLen, aiAlgid, abHashValue, dwHashLen, dwFlags)) { - return FALSE; + goto out; } - return encrypt_block_impl(pCryptKey->aiAlgid, PK_PRIVATE, &pCryptKey->context, pbSignature, pbSignature, RSAENH_ENCRYPT); + ret = encrypt_block_impl(pCryptKey->aiAlgid, PK_PRIVATE, &pCryptKey->context, pbSignature, pbSignature, RSAENH_ENCRYPT); +out: + RSAENH_CPDestroyKey(hProv, hCryptKey); + return ret; } /****************************************************************************** diff --git a/dll/win32/shdoclc/Bg.rc b/dll/win32/shdoclc/Bg.rc index 814ac7c918a..0cec8ec2f96 100644 --- a/dll/win32/shdoclc/Bg.rc +++ b/dll/win32/shdoclc/Bg.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT diff --git a/dll/win32/shdoclc/Da.rc b/dll/win32/shdoclc/Da.rc index 5f22bc8ed61..8a25db92dbf 100644 --- a/dll/win32/shdoclc/Da.rc +++ b/dll/win32/shdoclc/Da.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_DANISH, SUBLANG_DEFAULT diff --git a/dll/win32/shdoclc/De.rc b/dll/win32/shdoclc/De.rc index 253b6fc0007..f41619faeee 100644 --- a/dll/win32/shdoclc/De.rc +++ b/dll/win32/shdoclc/De.rc @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" + +#pragma code_page(65001) LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL @@ -36,19 +39,19 @@ IDR_BROWSE_CONTEXT_MENU MENU { POPUP "Standard" { - MENUITEM "&Zurck", IDM_GOBACKWARD - MENUITEM "V&orwrts", IDM_GOFORWARD + MENUITEM "&Zurück", IDM_GOBACKWARD + MENUITEM "V&orwärts", IDM_GOFORWARD MENUITEM SEPARATOR MENUITEM "&Speichere Hintergrund als...", IDM_SAVEBACKGROUND MENUITEM "Als Hintergrund", IDM_SETWALLPAPER MENUITEM "Hintergrund &kopieren", IDM_COPYBACKGROUND MENUITEM "Als Desktopelement einrichten...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "Alles &auswhlen", IDM_SELECTALL - MENUITEM "Ein&fgen", IDM_PASTE + MENUITEM "Alles &auswählen", IDM_SELECTALL + MENUITEM "Ein&fügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Erzeuge &Verknpfung", IDM_CREATESHORTCUT - MENUITEM "Zu &Favoriten hinzufgen", IDM_ADDFAVORITES + MENUITEM "Erzeuge &Verknüpfung", IDM_CREATESHORTCUT + MENUITEM "Zu &Favoriten hinzufügen", IDM_ADDFAVORITES MENUITEM "&Quelltextansicht", IDM_VIEWSOURCE MENUITEM SEPARATOR MENUITEM "&Textkodierung", IDM_LANGUAGE @@ -62,8 +65,8 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Bild" { - MENUITEM "&ffne Verweis", IDM_FOLLOWLINKC - MENUITEM "ffne Verweis in neuem Fenster", IDM_FOLLOWLINKN + MENUITEM "&Öffne Verweis", IDM_FOLLOWLINKC + MENUITEM "Öffne Verweis in neuem Fenster", IDM_FOLLOWLINKN MENUITEM "Speichere &Ziel als...", IDM_SAVETARGET MENUITEM "&Drucke Ziel", IDM_PRINTTARGET MENUITEM SEPARATOR @@ -77,10 +80,10 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "Verk&npfung kopieren", IDM_COPYSHORTCUT - MENUITEM "Ein&fgen", IDM_PASTE + MENUITEM "Verk&nüpfung kopieren", IDM_COPYSHORTCUT + MENUITEM "Ein&fügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Zu &Favoriten hinzufgen...", IDM_ADDFAVORITES + MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "&Eigenschaften", IDM_PROPERTIES @@ -88,20 +91,20 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Steuerung" { - MENUITEM "&Rckgngig", IDM_UNDO + MENUITEM "&Rückgängig", IDM_UNDO MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "Ein&fgen", IDM_PASTE - MENUITEM "&Lschen", IDM_DELETE + MENUITEM "Ein&fügen", IDM_PASTE + MENUITEM "&Löschen", IDM_DELETE MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Alles &auswhlen", IDM_SELECTALL + MENUITEM "Alles &auswählen", IDM_SELECTALL } POPUP "Tabelle" { - POPUP "&Auswhlen" + POPUP "&Auswählen" { MENUITEM "&Zelle", IDM_CELLSELECT MENUITEM "Zei&le", IDM_ROWSELECT @@ -110,33 +113,33 @@ IDR_BROWSE_CONTEXT_MENU MENU } MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Zellen-Eigenschaften", IDM_CELLPROPERTIES - MENUITEM "&Tabellen-Eigenschaften", IDM_TABLEPROPERTIES + MENUITEM "&Zellen Eigenschaften", IDM_CELLPROPERTIES + MENUITEM "&Tabellen Eigenschaften", IDM_TABLEPROPERTIES } POPUP "1DSeiten Auswahl" { MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "Ein&fgen", IDM_PASTE - MENUITEM "Alles &auswhlen", IDM_SELECTALL + MENUITEM "Ein&fügen", IDM_PASTE + MENUITEM "Alles &auswählen", IDM_SELECTALL MENUITEM "&Drucken", IDM_PRINT MENUITEM SEPARATOR } POPUP "Anker" { - MENUITEM "&ffnen", IDM_FOLLOWLINKC - MENUITEM "Im &neuen Fenster ffnen", IDM_FOLLOWLINKN + MENUITEM "&Öffnen", IDM_FOLLOWLINKC + MENUITEM "Im &neuen Fenster öffnen", IDM_FOLLOWLINKN MENUITEM "Speichere &Ziel als...", IDM_SAVETARGET MENUITEM "&Drucke Ziel", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "&Verknpfung kopieren", IDM_COPYSHORTCUT - MENUITEM "Ein&fgen", IDM_PASTE + MENUITEM "&Verknüpfung kopieren", IDM_COPYSHORTCUT + MENUITEM "Ein&fügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Zu &Favoriten hinzufgen...", IDM_ADDFAVORITES + MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "&Eigenschaften", IDM_PROPERTIES @@ -149,8 +152,8 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "DYNSRC Bild" { - MENUITEM "&ffne Verweis", IDM_FOLLOWLINKC - MENUITEM "ffne Verweis in &neuem Fenster", IDM_FOLLOWLINKN + MENUITEM "&Öffne Verweis", IDM_FOLLOWLINKC + MENUITEM "Öffne Verweis in &neuem Fenster", IDM_FOLLOWLINKN MENUITEM "Speichere &Ziel als...", IDM_SAVETARGET MENUITEM "&Drucke Ziel", IDM_PRINTTARGET MENUITEM SEPARATOR @@ -161,10 +164,10 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "&Verknpfung kopieren", IDM_COPYSHORTCUT - MENUITEM "Ein&fgen", IDM_PASTE + MENUITEM "&Verknüpfung kopieren", IDM_COPYSHORTCUT + MENUITEM "Ein&fügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Zu &Favoriten hinzufgen...", IDM_ADDFAVORITES + MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "Abspielen", IDM_DYNSRCPLAY @@ -174,8 +177,8 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "ART Bild" { - MENUITEM "&ffne Verweis", IDM_FOLLOWLINKC - MENUITEM "ffne Verweis in &neuem Fenster", IDM_FOLLOWLINKN + MENUITEM "&Öffne Verweis", IDM_FOLLOWLINKC + MENUITEM "Öffne Verweis in &neuem Fenster", IDM_FOLLOWLINKN MENUITEM "Speichere &Ziel als...", IDM_SAVETARGET MENUITEM "&Drucke Ziel", IDM_PRINTTARGET MENUITEM SEPARATOR @@ -186,14 +189,14 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Aus&schneiden", IDM_CUT MENUITEM "&Kopieren", IDM_COPY - MENUITEM "&Verknpfung kopieren", IDM_COPYSHORTCUT - MENUITEM "&Einfgen", IDM_PASTE + MENUITEM "&Verknüpfung kopieren", IDM_COPYSHORTCUT + MENUITEM "&Einfügen", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Zu &Favoriten hinzufgen...", IDM_ADDFAVORITES + MENUITEM "Zu &Favoriten hinzufügen...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM "Abspielen", IDM_IMGARTPLAY MENUITEM "Anhalten", IDM_IMGARTSTOP - MENUITEM "Rckspulen", IDM_IMGARTREWIND + MENUITEM "Rückspulen", IDM_IMGARTREWIND MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "&Eigenschaften", IDM_PROPERTIES diff --git a/dll/win32/shdoclc/En.rc b/dll/win32/shdoclc/En.rc index d237c519f80..4cb0a11d839 100644 --- a/dll/win32/shdoclc/En.rc +++ b/dll/win32/shdoclc/En.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT @@ -46,7 +47,7 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "&Paste", IDM_PASTE MENUITEM SEPARATOR MENUITEM "Create Shor&tcut", IDM_CREATESHORTCUT - MENUITEM "Add to &Favourites", IDM_ADDFAVORITES + MENUITEM "Add to &Favorites", IDM_ADDFAVORITES MENUITEM "&View Source", IDM_VIEWSOURCE MENUITEM SEPARATOR MENUITEM "&Encoding", IDM_LANGUAGE @@ -245,3 +246,221 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Scroll Right", IDM_SCROLL_RIGHT } } + +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Default" + { + MENUITEM "&Back", IDM_GOBACKWARD + MENUITEM "F&orward", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&Save Background As...", IDM_SAVEBACKGROUND + MENUITEM "Set As Back&ground", IDM_SETWALLPAPER + MENUITEM "&Copy Background", IDM_COPYBACKGROUND + MENUITEM "Set as &Desktop Item", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Select &All", IDM_SELECTALL + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Create Shor&tcut", IDM_CREATESHORTCUT + MENUITEM "Add to &Favourites", IDM_ADDFAVORITES + MENUITEM "&View Source", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "&Encoding", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "Pr&int", IDM_PRINT + MENUITEM "&Refresh", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "&Properties", IDM_PROPERTIES + } + + POPUP "Image" + { + MENUITEM "&Open Link", IDM_FOLLOWLINKC + MENUITEM "Open Link in &New Window", IDM_FOLLOWLINKN + MENUITEM "Save Target &As...", IDM_SAVETARGET + MENUITEM "&Print Target", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "S&how Picture", IDM_SHOWPICTURE + MENUITEM "&Save Picture As...", IDM_SAVEPICTURE + MENUITEM "&E-mail Picture...", IDM_MP_EMAILPICTURE + MENUITEM "Pr&int Picture...", IDM_MP_PRINTPICTURE + MENUITEM "&Go to My Pictures", IDM_MP_MYPICS + MENUITEM "Set as Back&ground", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Copy Shor&tcut", IDM_COPYSHORTCUT + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Add to &Favourites...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roperties", IDM_PROPERTIES + } + + POPUP "Control" + { + MENUITEM "&Undo", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "&Paste", IDM_PASTE + MENUITEM "&Delete", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Select &All", IDM_SELECTALL + } + + POPUP "Table" + { + POPUP "&Select" + { + MENUITEM "&Cell", IDM_CELLSELECT + MENUITEM "&Row", IDM_ROWSELECT + MENUITEM "&Column", IDM_COLUMNSELECT + MENUITEM "&Table", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "&Cell Properties", IDM_CELLPROPERTIES + MENUITEM "&Table Properties", IDM_TABLEPROPERTIES + } + + POPUP "1DSite Select" + { + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Paste", IDM_PASTE + MENUITEM "Select &All", IDM_SELECTALL + MENUITEM "&Print", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "Anchor" + { + MENUITEM "&Open", IDM_FOLLOWLINKC + MENUITEM "Open in &New Window", IDM_FOLLOWLINKN + MENUITEM "Save Target &As...", IDM_SAVETARGET + MENUITEM "&Print Target", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Cut", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Copy Shor&tcut", IDM_COPYSHORTCUT + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Add to &Favourites...",IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roperties", IDM_PROPERTIES + } + + POPUP "Context Unknown" + { + MENUITEM SEPARATOR + } + + POPUP "DYNSRC Image" + { + MENUITEM "&Open Link", IDM_FOLLOWLINKC + MENUITEM "Open Link in &New Window", IDM_FOLLOWLINKN + MENUITEM "Save Target &As...", IDM_SAVETARGET + MENUITEM "&Print Target", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "S&how Picture", IDM_SHOWPICTURE + MENUITEM "&Save Video As...", IDM_SAVEPICTURE + MENUITEM "Set as Back&ground", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Copy Shor&tcut", IDM_COPYSHORTCUT + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Add to &Favourites...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Play", IDM_DYNSRCPLAY + MENUITEM "Stop", IDM_DYNSRCSTOP + MENUITEM "P&roperties", IDM_PROPERTIES + } + + POPUP "ART Image" + { + MENUITEM "&Open Link", IDM_FOLLOWLINKC + MENUITEM "Open Link in &New Window", IDM_FOLLOWLINKN + MENUITEM "Save Target &As...", IDM_SAVETARGET + MENUITEM "&Print Target", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "S&how Picture", IDM_SHOWPICTURE + MENUITEM "&Save Picture As...", IDM_SAVEPICTURE + MENUITEM "Set as Back&ground", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Cu&t", IDM_CUT + MENUITEM "&Copy", IDM_COPY + MENUITEM "Copy Shor&tcut", IDM_COPYSHORTCUT + MENUITEM "&Paste", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Add to &Favourites...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Play", IDM_IMGARTPLAY + MENUITEM "Stop", IDM_IMGARTSTOP + MENUITEM "Rewind", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roperties", IDM_PROPERTIES + } + + POPUP "Debug" + { + MENUITEM "Trace Tags", IDM_TRACETAGS + MENUITEM "Resource Failures", IDM_RESOURCEFAILURES + MENUITEM "Dump Tracking Info", IDM_DUMPTRACKINGINFO + MENUITEM "Debug Break", IDM_DEBUGBREAK + MENUITEM "Debug View", IDM_DEBUGVIEW + MENUITEM "Dump Tree", IDM_DUMPTREE + MENUITEM "Dump Lines", IDM_DUMPLINES + MENUITEM "Dump DisplayTree", IDM_DUMPDISPLAYTREE + MENUITEM "Dump FormatCaches", IDM_DUMPFORMATCACHES + MENUITEM "Dump LayoutRects", IDM_DUMPLAYOUTRECTS + MENUITEM "Memory Monitor", IDM_MEMORYMONITOR + MENUITEM "Performance Meters", IDM_PERFORMANCEMETERS + MENUITEM "Save HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&Browse View", IDM_BROWSEMODE + MENUITEM "&Edit View", IDM_EDITMODE + } + + POPUP "Vertical Scrollbar" + { + MENUITEM "Scroll Here", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Top", IDM_SCROLL_TOP + MENUITEM "Bottom", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Page Up", IDM_SCROLL_PAGEUP + MENUITEM "Page Down", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Scroll Up", IDM_SCROLL_UP + MENUITEM "Scroll Down", IDM_SCROLL_DOWN + } + + POPUP "Horizontal Scrollbar" + { + MENUITEM "Scroll Here", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Left Edge", IDM_SCROLL_LEFTEDGE + MENUITEM "Right Edge", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Page Left", IDM_SCROLL_PAGELEFT + MENUITEM "Page Right", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Scroll Left", IDM_SCROLL_LEFT + MENUITEM "Scroll Right", IDM_SCROLL_RIGHT + } +} diff --git a/dll/win32/shdoclc/Es.rc b/dll/win32/shdoclc/Es.rc index 8be9757223a..fd2e3c7ce27 100644 --- a/dll/win32/shdoclc/Es.rc +++ b/dll/win32/shdoclc/Es.rc @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL diff --git a/dll/win32/shdoclc/Fi.rc b/dll/win32/shdoclc/Fi.rc index 81233d31f97..ae5e0c2b861 100644 --- a/dll/win32/shdoclc/Fi.rc +++ b/dll/win32/shdoclc/Fi.rc @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT diff --git a/dll/win32/shdoclc/Fr.rc b/dll/win32/shdoclc/Fr.rc index 75aefc7a1f2..9277938bb45 100644 --- a/dll/win32/shdoclc/Fr.rc +++ b/dll/win32/shdoclc/Fr.rc @@ -19,6 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" + +/* UTF-8 */ +#pragma code_page(65001) LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL @@ -35,74 +39,74 @@ STRINGTABLE DISCARDABLE IDR_BROWSE_CONTEXT_MENU MENU { - POPUP "Default" + POPUP "Standard" { - MENUITEM "Page pr&cdente", IDM_GOBACKWARD - MENUITEM "Page sui&vante", IDM_GOFORWARD + MENUITEM "Page &précédente", IDM_GOBACKWARD + MENUITEM "Page &suivante", IDM_GOFORWARD MENUITEM SEPARATOR - MENUITEM "Enregistrer l'&arrire-plan sous...", IDM_SAVEBACKGROUND - MENUITEM "t&ablir en tant qu'lment d'arrire-plan", IDM_SETWALLPAPER - MENUITEM "Copie&r l'arrire-plan", IDM_COPYBACKGROUND - MENUITEM "Dfinir comme lment du &Bureau...", IDM_SETDESKTOPITEM + MENUITEM "Enregistrer l'&arrière-plan sous...", IDM_SAVEBACKGROUND + MENUITEM "Définir &comme arrière-plan", IDM_SETWALLPAPER + MENUITEM "&Copier l'arrière-plan", IDM_COPYBACKGROUND + MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "&Slectionner tout", IDM_SELECTALL + MENUITEM "Sélectionner &tout", IDM_SELECTALL MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Crer &un raccourci", IDM_CREATESHORTCUT - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES - MENUITEM "A&fficher la source", IDM_VIEWSOURCE + MENUITEM "Créer un &raccourci", IDM_CREATESHORTCUT + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES + MENUITEM "Afficher la &source", IDM_VIEWSOURCE MENUITEM SEPARATOR - MENUITEM "Co&dage", IDM_LANGUAGE + MENUITEM "Coda&ge", IDM_LANGUAGE MENUITEM SEPARATOR MENUITEM "&Imprimer", IDM_PRINT MENUITEM "Actualis&er", _IDM_REFRESH MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Proprits", IDM_PROPERTIES + MENUITEM "Propri&étés", IDM_PROPERTIES } POPUP "Image" { MENUITEM "Ou&vrir le lien", IDM_FOLLOWLINKC - MENUITEM "Ouvrir le lien dans une &nouvelle fentre", IDM_FOLLOWLINKN + MENUITEM "Ouvrir le lien dans une &nouvelle fenêtre", IDM_FOLLOWLINKN MENUITEM "Enregistrer la cible so&us...", IDM_SAVETARGET MENUITEM "Imprimer la cib&le", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "Affic&her l'image", IDM_SHOWPICTURE MENUITEM "Enregistrer l'image &sous...", IDM_SAVEPICTURE - MENUITEM "Envoyer l'image par &courrier lectronique...", IDM_MP_EMAILPICTURE + MENUITEM "Envoyer l'image par &courrier électronique...", IDM_MP_EMAILPICTURE MENUITEM "&Imprimer l'image...", IDM_MP_PRINTPICTURE MENUITEM "Atteindre &Mes images", IDM_MP_MYPICS - MENUITEM "&tablir en tant qu'lment d'arrire-plan", IDM_SETWALLPAPER - MENUITEM "Dfinir comme lment du &Bureau...", IDM_SETDESKTOPITEM + MENUITEM "Déf&inir comme arrière-plan", IDM_SETWALLPAPER + MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY MENUITEM "Copier le r&accourci", IDM_COPYSHORTCUT MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Proprits", IDM_PROPERTIES + MENUITEM "Propri&étés", IDM_PROPERTIES } - POPUP "Control" + POPUP "Contrôle" { MENUITEM "&Annuler", IDM_UNDO MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY MENUITEM "C&oller", IDM_PASTE MENUITEM "Suppri&mer", IDM_DELETE MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Slectionner tout", IDM_SELECTALL + MENUITEM "&Sélectionner tout", IDM_SELECTALL } POPUP "Table" { - POPUP "&Slectionner" + POPUP "&Sélectionner" { MENUITEM "&cellule", IDM_CELLSELECT MENUITEM "&ligne", IDM_ROWSELECT @@ -111,96 +115,96 @@ IDR_BROWSE_CONTEXT_MENU MENU } MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "Proprits de la &cellule", IDM_CELLPROPERTIES - MENUITEM "Proprits de la &table", IDM_TABLEPROPERTIES + MENUITEM "Propriétés de la &cellule", IDM_CELLPROPERTIES + MENUITEM "Propriétés de la &table", IDM_TABLEPROPERTIES } POPUP "1DSite Select" { - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY - MENUITEM "Coller", IDM_PASTE - MENUITEM "&Slectionner tout", IDM_SELECTALL + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY + MENUITEM "C&oller", IDM_PASTE + MENUITEM "Sélectionner &tout", IDM_SELECTALL MENUITEM "&Imprimer", IDM_PRINT MENUITEM SEPARATOR } - POPUP "Anchor" + POPUP "Ancre" { MENUITEM "Ou&vrir", IDM_FOLLOWLINKC - MENUITEM "Ouvrir dans une &nouvelle fentre", IDM_FOLLOWLINKN - MENUITEM "Enregistrer la cible so&us...", IDM_SAVETARGET - MENUITEM "Imprimer la cib&le", IDM_PRINTTARGET + MENUITEM "Ouvrir dans une &nouvelle fenêtre", IDM_FOLLOWLINKN + MENUITEM "Enregistrer la cible &sous...", IDM_SAVETARGET + MENUITEM "&Imprimer la cible", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY - MENUITEM "Copier le r&accourci", IDM_COPYSHORTCUT + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY + MENUITEM "Copier le &raccourci", IDM_COPYSHORTCUT MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Proprits", IDM_PROPERTIES + MENUITEM "Propri&étés", IDM_PROPERTIES } - POPUP "Context Unknown" + POPUP "Contexte inconnu" { MENUITEM SEPARATOR } - POPUP "DYNSRC Image" + POPUP "Image DYNSRC" { MENUITEM "Ou&vrir le lien", IDM_FOLLOWLINKC - MENUITEM "Ouvrir le lien dans une &nouvelle fentre", IDM_FOLLOWLINKN + MENUITEM "Ouvrir le lien dans une &nouvelle fenêtre", IDM_FOLLOWLINKN MENUITEM "Enregistrer la cible so&us...", IDM_SAVETARGET - MENUITEM "Imprimer la cib&le", IDM_PRINTTARGET + MENUITEM "&Imprimer la cible", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "Affic&her l'image", IDM_SHOWPICTURE - MENUITEM "Enregistrer la vido &sous...", IDM_SAVEPICTURE - MENUITEM "&tablir en tant qu'lment d'arrire-plan", IDM_SETWALLPAPER - MENUITEM "Dfinir comme lment du &Bureau...", IDM_SETDESKTOPITEM + MENUITEM "Enregistrer la vidéo &sous...", IDM_SAVEPICTURE + MENUITEM "&Définir comme arrière-plan", IDM_SETWALLPAPER + MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY - MENUITEM "Copier le r&accourci", IDM_COPYSHORTCUT + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY + MENUITEM "Copier le &raccourci", IDM_COPYSHORTCUT MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "Lecture", IDM_DYNSRCPLAY - MENUITEM "Arrt", IDM_DYNSRCSTOP - MENUITEM "&Proprits", IDM_PROPERTIES + MENUITEM "Arrêt", IDM_DYNSRCSTOP + MENUITEM "Propri&étés", IDM_PROPERTIES } - POPUP "ART Image" + POPUP "Image ART" { MENUITEM "Ou&vrir le lien", IDM_FOLLOWLINKC - MENUITEM "Ouvrir le lien dans une &nouvelle fentre", IDM_FOLLOWLINKN + MENUITEM "Ouvrir le lien dans une &nouvelle fenêtre", IDM_FOLLOWLINKN MENUITEM "Enregistrer la cible so&us...", IDM_SAVETARGET MENUITEM "Imprimer la cib&le", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "Affic&her l'image", IDM_SHOWPICTURE MENUITEM "Enregistrer l'image &sous...", IDM_SAVEPICTURE - MENUITEM "&tablir en tant qu'lment d'arrire-plan", IDM_SETWALLPAPER - MENUITEM "Dfinir comme lment du &Bureau...", IDM_SETDESKTOPITEM + MENUITEM "&Définir comme arrière-plan", IDM_SETWALLPAPER + MENUITEM "Définir comme élément du &Bureau...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "Coupe&r", IDM_CUT - MENUITEM "Copi&er", IDM_COPY - MENUITEM "Copier le r&accourci", IDM_COPYSHORTCUT + MENUITEM "Cou&per", IDM_CUT + MENUITEM "&Copier", IDM_COPY + MENUITEM "Copier le &raccourci", IDM_COPYSHORTCUT MENUITEM "C&oller", IDM_PASTE MENUITEM SEPARATOR - MENUITEM "Ajouter au&x Favoris...", IDM_ADDFAVORITES + MENUITEM "Ajouter aux &Favoris...", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM "Lecture", IDM_IMGARTPLAY - MENUITEM "Arrt", IDM_IMGARTSTOP - MENUITEM "Retour arrire", IDM_IMGARTREWIND + MENUITEM "Arrêt", IDM_IMGARTSTOP + MENUITEM "Retour arrière", IDM_IMGARTREWIND MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Proprits", IDM_PROPERTIES + MENUITEM "Propri&étés", IDM_PROPERTIES } - POPUP "Debug" + POPUP "Déboguage" { MENUITEM "Trace Tags", IDM_TRACETAGS MENUITEM "Resource Failures", IDM_RESOURCEFAILURES @@ -220,31 +224,31 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "&Edit View", IDM_EDITMODE } - POPUP "Vertical Scrollbar" + POPUP "Barre de défilement verticale" { - MENUITEM "Dfilement ici", IDM_SCROLL_HERE + MENUITEM "Défilement ici", IDM_SCROLL_HERE MENUITEM SEPARATOR MENUITEM "Haut", IDM_SCROLL_TOP MENUITEM "Bas", IDM_SCROLL_BOTTOM MENUITEM SEPARATOR - MENUITEM "Page prcdente", IDM_SCROLL_PAGEUP + MENUITEM "Page précédente", IDM_SCROLL_PAGEUP MENUITEM "Page suivante", IDM_SCROLL_PAGEDOWN MENUITEM SEPARATOR - MENUITEM "Dfilement vers le haut", IDM_SCROLL_UP - MENUITEM "Dfilement vers le bas", IDM_SCROLL_DOWN + MENUITEM "Défilement vers le haut", IDM_SCROLL_UP + MENUITEM "Défilement vers le bas", IDM_SCROLL_DOWN } - POPUP "Horizontal Scrollbar" + POPUP "Barre de défilement horizontale" { - MENUITEM "Dfilement ici", IDM_SCROLL_HERE + MENUITEM "Défilement ici", IDM_SCROLL_HERE MENUITEM SEPARATOR - MENUITEM "Ct gauche", IDM_SCROLL_LEFTEDGE - MENUITEM "Ct droit", IDM_SCROLL_RIGHTEDGE + MENUITEM "Bord gauche", IDM_SCROLL_LEFTEDGE + MENUITEM "Bord droit", IDM_SCROLL_RIGHTEDGE MENUITEM SEPARATOR MENUITEM "Page vers la gauche", IDM_SCROLL_PAGELEFT MENUITEM "Page vers la droite", IDM_SCROLL_PAGERIGHT MENUITEM SEPARATOR - MENUITEM "Dfilement vers la gauche", IDM_SCROLL_LEFT - MENUITEM "Dfilement vers la droite", IDM_SCROLL_RIGHT + MENUITEM "Défilement vers la gauche", IDM_SCROLL_LEFT + MENUITEM "Défilement vers la droite", IDM_SCROLL_RIGHT } } diff --git a/dll/win32/shdoclc/Hu.rc b/dll/win32/shdoclc/Hu.rc index 9ed68caceda..2fdc4c202ef 100644 --- a/dll/win32/shdoclc/Hu.rc +++ b/dll/win32/shdoclc/Hu.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT diff --git a/dll/win32/shdoclc/Ko.rc b/dll/win32/shdoclc/Ko.rc index d038994151b..c30c21dd5b4 100644 --- a/dll/win32/shdoclc/Ko.rc +++ b/dll/win32/shdoclc/Ko.rc @@ -17,17 +17,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { - IDS_MESSAGE_BOX_TITLE, "Wine ͳ Explorer" + IDS_MESSAGE_BOX_TITLE, "Wine ͳ ͽξr" } STRINGTABLE DISCARDABLE { - IDS_PRINT_HEADER_TEMPLATE "&w&bPage &p" /* FIXME: should be "&w&bPage &p of &P" */ + IDS_PRINT_HEADER_TEMPLATE "&w&b &p" /* FIXME: should be "&w&bPage &p of &P" */ IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" } diff --git a/dll/win32/shdoclc/Lt.rc b/dll/win32/shdoclc/Lt.rc new file mode 100644 index 00000000000..e6c812d3bfe --- /dev/null +++ b/dll/win32/shdoclc/Lt.rc @@ -0,0 +1,251 @@ +/* + * Copyright 2009 Aurimas Fišeras + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "shdoclc.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_MESSAGE_BOX_TITLE, "Wine interneto naršyklė" +} + +STRINGTABLE DISCARDABLE +{ + IDS_PRINT_HEADER_TEMPLATE "&w&bPuslapis &p" /* FIXME: should be "&w&bPuslapis &p iš &P" */ + IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" +} + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Numatytasis" + { + MENUITEM "&Atgal", IDM_GOBACKWARD + MENUITEM "&Pirmyn", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&Išsaugoti foną kaip...", IDM_SAVEBACKGROUND + MENUITEM "Parinkti užsk&landos piešiniu", IDM_SETWALLPAPER + MENUITEM "Kopijuoti &foną", IDM_COPYBACKGROUND + MENUITEM "Nustatyti da&rbalaukio elementu", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Pažymėti &viską", IDM_SELECTALL + MENUITEM "Į&dėti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Sukurti &šaukinį", IDM_CREATESHORTCUT + MENUITEM "Pridėti į adr&esyną", IDM_ADDFAVORITES + MENUITEM "Pirminis &tekstas", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "&Koduotė", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "&Spausdinti", IDM_PRINT + MENUITEM "Atsiųsti iš &naujo", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Savy&bės", IDM_PROPERTIES + } + + POPUP "Paveikslas" + { + MENUITEM "&Atverti saitą", IDM_FOLLOWLINKC + MENUITEM "Atverti saitą &naujame lange", IDM_FOLLOWLINKN + MENUITEM "Įrašyti saistomą &objektą kaip...", IDM_SAVETARGET + MENUITEM "&Spausdinti saistomą objektą", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Rod&yti paveikslą", IDM_SHOWPICTURE + MENUITEM "Įrašyti pa&veikslą kaip...", IDM_SAVEPICTURE + MENUITEM "Išsiųsti pav&eikslą el. paštu...", IDM_MP_EMAILPICTURE + MENUITEM "S&pausdinti paveikslą...", IDM_MP_PRINTPICTURE + MENUITEM "Ei&ti į paveikslų aplanką", IDM_MP_MYPICS + MENUITEM "Parinkti užsk&landos piešiniu", IDM_SETWALLPAPER + MENUITEM "Nustatyti da&rbalaukio elementu...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&Iškirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Kopi&juoti adresą", IDM_COPYSHORTCUT + MENUITEM "Į&dėti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Prid&ėti į adresyną...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Savy&bės", IDM_PROPERTIES + } + + POPUP "Valdiklis" + { + MENUITEM "&Atšaukti", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "&Iškirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Į&dėti", IDM_PASTE + MENUITEM "&Šalinti", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Pažymėti &viską", IDM_SELECTALL + } + + POPUP "Lentelė" + { + POPUP "&Pažymėti" + { + MENUITEM "lan&gelį", IDM_CELLSELECT + MENUITEM "&eilutę", IDM_ROWSELECT + MENUITEM "&stulpelį", IDM_COLUMNSELECT + MENUITEM "&lentelę", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Lan&gelio savybės", IDM_CELLPROPERTIES + MENUITEM "&Lentelės savybės", IDM_TABLEPROPERTIES + } + + POPUP "1DPuslapio žymėjimas" + { + MENUITEM "&Iškirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Į&dėti", IDM_PASTE + MENUITEM "Pažymėti &viską", IDM_SELECTALL + MENUITEM "&Spausdinti", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "Žymė" + { + MENUITEM "&Atverti", IDM_FOLLOWLINKC + MENUITEM "Atverti &naujame lange", IDM_FOLLOWLINKN + MENUITEM "Įrašyti saistomą &objektą kaip...", IDM_SAVETARGET + MENUITEM "&Spausdinti saistomą objektą", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "&Iškirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Kopi&juoti adresą", IDM_COPYSHORTCUT + MENUITEM "Į&dėti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Pridėti į adr&esyną...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Savy&bės", IDM_PROPERTIES + } + + POPUP "Nežinomas kontekstas" + { + MENUITEM SEPARATOR + } + + POPUP "DYNSRC paveikslas" + { + MENUITEM "&Atverti saitą", IDM_FOLLOWLINKC + MENUITEM "Atverti saitą &naujame lange", IDM_FOLLOWLINKN + MENUITEM "Įrašyti saistomą &objektą kaip...", IDM_SAVETARGET + MENUITEM "&Spausdinti saistomą objektą", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Rod&yti paveikslą", IDM_SHOWPICTURE + MENUITEM "Įrašyti pa&veikslą kaip...", IDM_SAVEPICTURE + MENUITEM "Parinkti užsk&landos piešiniu", IDM_SETWALLPAPER + MENUITEM "Nustatyti da&rbalaukio elementu...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&Iškirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Kopi&juoti adresą", IDM_COPYSHORTCUT + MENUITEM "Į&dėti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Pridėti į adr&esyną...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Leisti", IDM_DYNSRCPLAY + MENUITEM "Stabdyti", IDM_DYNSRCSTOP + MENUITEM "Savy&bės", IDM_PROPERTIES + } + + POPUP "ART paveikslas" + { + MENUITEM "&Atverti saitą", IDM_FOLLOWLINKC + MENUITEM "Atverti saitą &naujame lange", IDM_FOLLOWLINKN + MENUITEM "Įrašyti saistomą &objektą kaip...", IDM_SAVETARGET + MENUITEM "&Spausdinti saistomą objektą", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Rod&yti paveikslą", IDM_SHOWPICTURE + MENUITEM "Įrašyti pa&veikslą kaip...", IDM_SAVEPICTURE + MENUITEM "Parinkti užsk&landos piešiniu", IDM_SETWALLPAPER + MENUITEM "Nustatyti da&rbalaukio elementu...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&Iškirpti", IDM_CUT + MENUITEM "&Kopijuoti", IDM_COPY + MENUITEM "Kopi&juoti adresą", IDM_COPYSHORTCUT + MENUITEM "Į&dėti", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Pridėti į adr&esyną...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Leisti", IDM_IMGARTPLAY + MENUITEM "Stabdyti", IDM_IMGARTSTOP + MENUITEM "Perleisti", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Savy&bės", IDM_PROPERTIES + } + + POPUP "Derinimas" + { + MENUITEM "Sekti gaires", IDM_TRACETAGS + MENUITEM "Išteklių klaidos", IDM_RESOURCEFAILURES + MENUITEM "Parodyti stebėjimo informaciją", IDM_DUMPTRACKINGINFO + MENUITEM "Derinimo pertraukimas", IDM_DEBUGBREAK + MENUITEM "Derinimo rodinys", IDM_DEBUGVIEW + MENUITEM "Parodyti medį", IDM_DUMPTREE + MENUITEM "Parodyti eilutes", IDM_DUMPLINES + MENUITEM "Parodyti rodymo medį", IDM_DUMPDISPLAYTREE + MENUITEM "Parodyti formatų podėlius", IDM_DUMPFORMATCACHES + MENUITEM "Parodyti išdėstymo stačiakampius", IDM_DUMPLAYOUTRECTS + MENUITEM "Atminties monitorius", IDM_MEMORYMONITOR + MENUITEM "Našumo skaitikliai", IDM_PERFORMANCEMETERS + MENUITEM "Išsaugoti HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&Naršyti rodinį", IDM_BROWSEMODE + MENUITEM "&Redaguoti rodinį", IDM_EDITMODE + } + + POPUP "Stačioji slankjuostė" + { + MENUITEM "Slinkti čia", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Viršus", IDM_SCROLL_TOP + MENUITEM "Apačia", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Ankstesnis lapas", IDM_SCROLL_PAGEUP + MENUITEM "Tolesnis lapas", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Slinkti aukštyn", IDM_SCROLL_UP + MENUITEM "Slinkti žemyn", IDM_SCROLL_DOWN + } + + POPUP "Gulsčioji slankjuostė" + { + MENUITEM "Slinkti čia", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Kairysis kraštas", IDM_SCROLL_LEFTEDGE + MENUITEM "Dešinysis kraštas", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Kairysis lapas", IDM_SCROLL_PAGELEFT + MENUITEM "Dešinysis lapas", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Slinkti kairėn", IDM_SCROLL_LEFT + MENUITEM "Slinkti dešinėn", IDM_SCROLL_RIGHT + } +} diff --git a/dll/win32/shdoclc/Nl.rc b/dll/win32/shdoclc/Nl.rc index 3f764753871..c10e8031fdb 100644 --- a/dll/win32/shdoclc/Nl.rc +++ b/dll/win32/shdoclc/Nl.rc @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL diff --git a/dll/win32/shdoclc/No.rc b/dll/win32/shdoclc/No.rc index 6c38a1f61c0..65f554a5777 100644 --- a/dll/win32/shdoclc/No.rc +++ b/dll/win32/shdoclc/No.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL diff --git a/dll/win32/shdoclc/Pt.rc b/dll/win32/shdoclc/Pt.rc index 393037f5f8a..737747304ff 100644 --- a/dll/win32/shdoclc/Pt.rc +++ b/dll/win32/shdoclc/Pt.rc @@ -16,12 +16,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" -LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL +#pragma code_page(65001) + +LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE STRINGTABLE DISCARDABLE { - IDS_MESSAGE_BOX_TITLE, "Wine Internet Explorer" + IDS_MESSAGE_BOX_TITLE, "Explorador de Internet Wine" } STRINGTABLE DISCARDABLE @@ -35,7 +38,7 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Default" { MENUITEM "&Retroceder", IDM_GOBACKWARD - MENUITEM "&Avanar", IDM_GOFORWARD + MENUITEM "&Avançar", IDM_GOFORWARD MENUITEM SEPARATOR MENUITEM "&Guardar fundo como...", IDM_SAVEBACKGROUND MENUITEM "&Definir como fundo", IDM_SETWALLPAPER @@ -47,9 +50,9 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Criar &Atalho", IDM_CREATESHORTCUT MENUITEM "Adicionar aos &Favoritos", IDM_ADDFAVORITES - MENUITEM "&Ver Cdigo Fonte", IDM_VIEWSOURCE + MENUITEM "&Ver Código Fonte", IDM_VIEWSOURCE MENUITEM SEPARATOR - MENUITEM "C&odificao", IDM_LANGUAGE + MENUITEM "C&odificação", IDM_LANGUAGE MENUITEM SEPARATOR MENUITEM "&Imprimir", IDM_PRINT MENUITEM "&Actualizar", _IDM_REFRESH @@ -60,10 +63,10 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Imagem" { - MENUITEM "&Abrir ligao", IDM_FOLLOWLINKC - MENUITEM "Abrir &ligao numa nova janela", IDM_FOLLOWLINKN - MENUITEM "&Guardar ligao como...", IDM_SAVETARGET - MENUITEM "&Imprimir ligao", IDM_PRINTTARGET + MENUITEM "&Abrir ligação", IDM_FOLLOWLINKC + MENUITEM "Abrir &ligação numa nova janela", IDM_FOLLOWLINKN + MENUITEM "&Guardar ligação como...", IDM_SAVETARGET + MENUITEM "&Imprimir ligação", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "&Mostrar imagem", IDM_SHOWPICTURE MENUITEM "G&uardar imagem como...", IDM_SAVEPICTURE @@ -101,14 +104,14 @@ IDR_BROWSE_CONTEXT_MENU MENU { POPUP "&Seleccionar" { - MENUITEM "&Clula", IDM_CELLSELECT + MENUITEM "&Célula", IDM_CELLSELECT MENUITEM "&Linha", IDM_ROWSELECT MENUITEM "C&oluna", IDM_COLUMNSELECT MENUITEM "&Tabela", IDM_TABLESELECT } MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&Propriedades da Clula", IDM_CELLPROPERTIES + MENUITEM "&Propriedades da Célula", IDM_CELLPROPERTIES MENUITEM "&Propriedades da Tabela", IDM_TABLEPROPERTIES } @@ -122,12 +125,12 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR } - POPUP "ncora" + POPUP "Âncora" { MENUITEM "&Abrir", IDM_FOLLOWLINKC MENUITEM "A&brir numa nova janela", IDM_FOLLOWLINKN - MENUITEM "&Guardar ligao como...", IDM_SAVETARGET - MENUITEM "&Imprimir ligao", IDM_PRINTTARGET + MENUITEM "&Guardar ligação como...", IDM_SAVETARGET + MENUITEM "&Imprimir ligação", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "&Cortar", IDM_CUT MENUITEM "C&opiar", IDM_COPY @@ -147,10 +150,10 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Imagem DYNSRC" { - MENUITEM "&Abrir ligao", IDM_FOLLOWLINKC - MENUITEM "A&brir ligao numa nova janela", IDM_FOLLOWLINKN - MENUITEM "&Guardar ligao como...", IDM_SAVETARGET - MENUITEM "&Imprimir ligao", IDM_PRINTTARGET + MENUITEM "&Abrir ligação", IDM_FOLLOWLINKC + MENUITEM "A&brir ligação numa nova janela", IDM_FOLLOWLINKN + MENUITEM "&Guardar ligação como...", IDM_SAVETARGET + MENUITEM "&Imprimir ligação", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "&Mostrar imagem", IDM_SHOWPICTURE MENUITEM "G&uardar video como...", IDM_SAVEPICTURE @@ -172,10 +175,10 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "Imagem ART" { - MENUITEM "&Abrir ligao", IDM_FOLLOWLINKC - MENUITEM "A&brir ligao numa nova janela", IDM_FOLLOWLINKN - MENUITEM "&Guardar ligao como...", IDM_SAVETARGET - MENUITEM "&Imprimir ligao", IDM_PRINTTARGET + MENUITEM "&Abrir ligação", IDM_FOLLOWLINKC + MENUITEM "A&brir ligação numa nova janela", IDM_FOLLOWLINKN + MENUITEM "&Guardar ligação como...", IDM_SAVETARGET + MENUITEM "&Imprimir ligação", IDM_PRINTTARGET MENUITEM SEPARATOR MENUITEM "&Mostrar imagem", IDM_SHOWPICTURE MENUITEM "G&uardar video como...", IDM_SAVEPICTURE @@ -189,10 +192,9 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM SEPARATOR MENUITEM "Adicionar aos &Favoritos...", IDM_ADDFAVORITES MENUITEM SEPARATOR - MENUITEM SEPARATOR - MENUITEM "I&niciar", IDM_DYNSRCPLAY - MENUITEM "&Parar", IDM_DYNSRCSTOP - MENUITEM "&Recomear", IDM_IMGARTREWIND + MENUITEM "I&niciar", IDM_IMGARTPLAY + MENUITEM "&Parar", IDM_IMGARTSTOP + MENUITEM "&Recomeçar", IDM_IMGARTREWIND MENUITEM SEPARATOR MENUITEM SEPARATOR MENUITEM "Propriedade&s", IDM_PROPERTIES @@ -225,8 +227,8 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Topo", IDM_SCROLL_TOP MENUITEM "Fundo", IDM_SCROLL_BOTTOM MENUITEM SEPARATOR - MENUITEM "Pgina Acima", IDM_SCROLL_PAGEUP - MENUITEM "Pgina abaixo", IDM_SCROLL_PAGEDOWN + MENUITEM "Página Acima", IDM_SCROLL_PAGEUP + MENUITEM "Página abaixo", IDM_SCROLL_PAGEDOWN MENUITEM SEPARATOR MENUITEM "Scroll Cima", IDM_SCROLL_UP MENUITEM "Scroll Baixo", IDM_SCROLL_DOWN @@ -239,8 +241,8 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Canto Esquerdo", IDM_SCROLL_LEFTEDGE MENUITEM "Canto Direito", IDM_SCROLL_RIGHTEDGE MENUITEM SEPARATOR - MENUITEM "Pgina esquerda", IDM_SCROLL_PAGELEFT - MENUITEM "Pgina direita", IDM_SCROLL_PAGERIGHT + MENUITEM "Página esquerda", IDM_SCROLL_PAGELEFT + MENUITEM "Página direita", IDM_SCROLL_PAGERIGHT MENUITEM SEPARATOR MENUITEM "Scroll Esquerda", IDM_SCROLL_LEFT MENUITEM "Scroll Direita", IDM_SCROLL_RIGHT diff --git a/dll/win32/shdoclc/Ro.rc b/dll/win32/shdoclc/Ro.rc new file mode 100644 index 00000000000..45a3c8800b6 --- /dev/null +++ b/dll/win32/shdoclc/Ro.rc @@ -0,0 +1,251 @@ +/* + * Copyright 2005-2006 Jacek Caban + * Copyright 2009 Michael Stefaniuc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "shdoclc.h" + +LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL + +#pragma code_page(65001) + +STRINGTABLE DISCARDABLE +{ + IDS_MESSAGE_BOX_TITLE, "Wine Internet Explorer" +} + +STRINGTABLE DISCARDABLE +{ + IDS_PRINT_HEADER_TEMPLATE "&w&bPagina &p" /* FIXME: should be "&w&bPagina &p of &P" */ + IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" +} + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Implicit" + { + MENUITEM "În&apoi", IDM_GOBACKWARD + MENUITEM "Î&nainte", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&Salvează imaginea de fundal ca...", IDM_SAVEBACKGROUND + MENUITEM "Definește ca &fundal", IDM_SETWALLPAPER + MENUITEM "&Copiază fundalul", IDM_COPYBACKGROUND + MENUITEM "&Definește ca element de desktop", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Selectează t&ot", IDM_SELECTALL + MENUITEM "&Lipește", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Crează s&curtătură", IDM_CREATESHORTCUT + MENUITEM "Adaugă la &favorite", IDM_ADDFAVORITES + MENUITEM "&Vizualizează sursa", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "Codificar&e", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "&Tipărește", IDM_PRINT + MENUITEM "&Actualizează", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Imagine" + { + MENUITEM "Deschide &legătura", IDM_FOLLOWLINKC + MENUITEM "Deschide legătura într-o fereastră &nouă", IDM_FOLLOWLINKN + MENUITEM "S&alvează destinația ca...", IDM_SAVETARGET + MENUITEM "&Tipărește destinația", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Arată i&maginea", IDM_SHOWPICTURE + MENUITEM "&Salvează imaginea ca...", IDM_SAVEPICTURE + MENUITEM "Transmite imaginea prin &email...", IDM_MP_EMAILPICTURE + MENUITEM "T&ipărește imaginea...", IDM_MP_PRINTPICTURE + MENUITEM "Du-te la My Pictures", IDM_MP_MYPICS + MENUITEM "Definește ca &fundal", IDM_SETWALLPAPER + MENUITEM "&Definește ca element de desktop...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "Copiază scur&tătura", IDM_COPYSHORTCUT + MENUITEM "&Lipește", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Adaugă la &favorite...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Control" + { + MENUITEM "&Refă", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "&Lipește", IDM_PASTE + MENUITEM "&Șterge", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Selectează t&ot", IDM_SELECTALL + } + + POPUP "Tabel" + { + POPUP "Selectare" + { + MENUITEM "&Celulă", IDM_CELLSELECT + MENUITEM "&Rând", IDM_ROWSELECT + MENUITEM "&Coloană", IDM_COLUMNSELECT + MENUITEM "&Tabel", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Proprietăți &celulă", IDM_CELLPROPERTIES + MENUITEM "Proprietăți &tabel", IDM_TABLEPROPERTIES + } + + POPUP "Selecție Pagini1D" + { + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "&Lipește", IDM_PASTE + MENUITEM "Selectează t&ot", IDM_SELECTALL + MENUITEM "&Tipărește", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "Ancorare" + { + MENUITEM "Deschide &legătura", IDM_FOLLOWLINKC + MENUITEM "Deschide legătura într-o fereastră &nouă", IDM_FOLLOWLINKN + MENUITEM "S&alvează destinația ca...", IDM_SAVETARGET + MENUITEM "&Tipărește destinația", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "Copiază scur&tătura", IDM_COPYSHORTCUT + MENUITEM "&Lipește", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Adaugă la &favorite...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Context necunoscut" + { + MENUITEM SEPARATOR + } + + POPUP "Imagine DYNSRC" + { + MENUITEM "Deschide &legătura", IDM_FOLLOWLINKC + MENUITEM "Deschide legătura într-o fereastră &nouă", IDM_FOLLOWLINKN + MENUITEM "S&alvează destinația ca...", IDM_SAVETARGET + MENUITEM "&Tipărește destinația", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Arată i&maginea", IDM_SHOWPICTURE + MENUITEM "&Salvează videoul ca...", IDM_SAVEPICTURE + MENUITEM "Definește ca &fundal", IDM_SETWALLPAPER + MENUITEM "&Definește ca element de desktop...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "Copiază scur&tătura", IDM_COPYSHORTCUT + MENUITEM "&Lipește", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Adaugă la &favorite...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Redă", IDM_DYNSRCPLAY + MENUITEM "Oprește", IDM_DYNSRCSTOP + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Imagine ART" + { + MENUITEM "Deschide &legătura", IDM_FOLLOWLINKC + MENUITEM "Deschide legătura într-o fereastră &nouă", IDM_FOLLOWLINKN + MENUITEM "S&alvează destinația ca...", IDM_SAVETARGET + MENUITEM "&Tipărește destinația", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Arată i&maginea", IDM_SHOWPICTURE + MENUITEM "&Salvează imaginea ca...", IDM_SAVEPICTURE + MENUITEM "Definește ca &fundal", IDM_SETWALLPAPER + MENUITEM "&Definește ca element de desktop...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "&Taie", IDM_CUT + MENUITEM "&Copiază", IDM_COPY + MENUITEM "Copiază scur&tătura", IDM_COPYSHORTCUT + MENUITEM "&Lipește", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Adaugă la &favorite...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Redă", IDM_IMGARTPLAY + MENUITEM "Oprește", IDM_IMGARTSTOP + MENUITEM "Derulează înapoi", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "P&roprietăți", IDM_PROPERTIES + } + + POPUP "Depanare" + { + MENUITEM "Urmărire etichete", IDM_TRACETAGS + MENUITEM "Erori în resursă", IDM_RESOURCEFAILURES + MENUITEM "Elimină informația de urmărire", IDM_DUMPTRACKINGINFO + MENUITEM "Întrerupere depanare", IDM_DEBUGBREAK + MENUITEM "Vizualizare depanare", IDM_DEBUGVIEW + MENUITEM "Elimină arborele", IDM_DUMPTREE + MENUITEM "Elimină liniile", IDM_DUMPLINES + MENUITEM "Elimină arborele de afișare", IDM_DUMPDISPLAYTREE + MENUITEM "Elimină cache-ul de format", IDM_DUMPFORMATCACHES + MENUITEM "Elimină dreptunghiurile de format", IDM_DUMPLAYOUTRECTS + MENUITEM "Monitor de memorie", IDM_MEMORYMONITOR + MENUITEM "Măsurători de performanță", IDM_PERFORMANCEMETERS + MENUITEM "Salvează HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&Răsfoiește vizualizarea", IDM_BROWSEMODE + MENUITEM "Editează vizualizarea", IDM_EDITMODE + } + + POPUP "Bara de defilare verticală" + { + MENUITEM "Derulează aici", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Sus", IDM_SCROLL_TOP + MENUITEM "Jos", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Pagină mai sus", IDM_SCROLL_PAGEUP + MENUITEM "Pagină mai jos", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Defilare în sus", IDM_SCROLL_UP + MENUITEM "Defilare în jos", IDM_SCROLL_DOWN + } + + POPUP "Bara de defilare orizontală" + { + MENUITEM "Derulează aici", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Marginea stîngă", IDM_SCROLL_LEFTEDGE + MENUITEM "Marginea dreaptă", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Pagină mai la stânga", IDM_SCROLL_PAGELEFT + MENUITEM "Pagină mai la dreapta", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Defilează la stînga", IDM_SCROLL_LEFT + MENUITEM "Defilează la dreapta", IDM_SCROLL_RIGHT + } +} diff --git a/dll/win32/shdoclc/Ru.rc b/dll/win32/shdoclc/Ru.rc index f20c2f469b3..06ca7193630 100644 --- a/dll/win32/shdoclc/Ru.rc +++ b/dll/win32/shdoclc/Ru.rc @@ -16,6 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" + +/* UTF-8 */ +#pragma code_page(65001) LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT @@ -26,7 +30,7 @@ STRINGTABLE DISCARDABLE STRINGTABLE DISCARDABLE { - IDS_PRINT_HEADER_TEMPLATE "&w&b &p" /* FIXME: should be "&w&bPage &p of &P" */ + IDS_PRINT_HEADER_TEMPLATE "&w&bСтраница &p" /* FIXME: should be "&w&bPage &p of &P" */ IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" } @@ -34,110 +38,110 @@ IDR_BROWSE_CONTEXT_MENU MENU { POPUP "Default" { - MENUITEM "&", IDM_GOBACKWARD - MENUITEM "&", IDM_GOFORWARD + MENUITEM "&Назад", IDM_GOBACKWARD + MENUITEM "&Вперед", IDM_GOFORWARD MENUITEM SEPARATOR - MENUITEM "& ...", IDM_SAVEBACKGROUND - MENUITEM "& ", IDM_SETWALLPAPER - MENUITEM "& ", IDM_COPYBACKGROUND - MENUITEM " & ...", IDM_SETDESKTOPITEM + MENUITEM "&Сохранить фон как...", IDM_SAVEBACKGROUND + MENUITEM "С&делать фоновым рисунком", IDM_SETWALLPAPER + MENUITEM "&Копировать фон", IDM_COPYBACKGROUND + MENUITEM "Сохранить как &элемент рабочего стола...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM " &", IDM_SELECTALL - MENUITEM "&", IDM_PASTE + MENUITEM "Выделить вс&ё", IDM_SELECTALL + MENUITEM "Вс&тавить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM " &", IDM_CREATESHORTCUT - MENUITEM " &", IDM_ADDFAVORITES - MENUITEM "& ",IDM_VIEWSOURCE + MENUITEM "Создать &ярлык", IDM_CREATESHORTCUT + MENUITEM "Добавить в &избранное", IDM_ADDFAVORITES + MENUITEM "&Открыть исходный текст",IDM_VIEWSOURCE MENUITEM SEPARATOR - MENUITEM "&", IDM_LANGUAGE + MENUITEM "&Кодировка", IDM_LANGUAGE MENUITEM SEPARATOR - MENUITEM "&", IDM_PRINT - MENUITEM "&", _IDM_REFRESH + MENUITEM "Пе&чать", IDM_PRINT + MENUITEM "О&бновить", _IDM_REFRESH MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&", IDM_PROPERTIES + MENUITEM "Сво&йства", IDM_PROPERTIES } POPUP "Image" { - MENUITEM "& ", IDM_FOLLOWLINKC - MENUITEM " & ",IDM_FOLLOWLINKN - MENUITEM " & ...", IDM_SAVETARGET - MENUITEM "& ", IDM_PRINTTARGET + MENUITEM "&Открыть ссылку", IDM_FOLLOWLINKC + MENUITEM "Открыть &ссылку в новом окне",IDM_FOLLOWLINKN + MENUITEM "Сохранить об&ъект как...", IDM_SAVETARGET + MENUITEM "&Печать объекта", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM " &", IDM_SHOWPICTURE - MENUITEM "& ...",IDM_SAVEPICTURE - MENUITEM "& E-mail...",IDM_MP_EMAILPICTURE - MENUITEM "& ...", IDM_MP_PRINTPICTURE - MENUITEM "& ", IDM_MP_MYPICS - MENUITEM "& ", IDM_SETWALLPAPER - MENUITEM " & ...", IDM_SETDESKTOPITEM + MENUITEM "Показать &рисунок", IDM_SHOWPICTURE + MENUITEM "Со&хранить рисунок как...",IDM_SAVEPICTURE + MENUITEM "&Отправить рисунок по E-mail...",IDM_MP_EMAILPICTURE + MENUITEM "&Печать рисунка...", IDM_MP_PRINTPICTURE + MENUITEM "&Перейти в папку Мои рисунки", IDM_MP_MYPICS + MENUITEM "С&делать фоновым рисунком", IDM_SETWALLPAPER + MENUITEM "Сохранить как &элемент рабочего стола...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "&", IDM_CUT - MENUITEM "&", IDM_COPY - MENUITEM " &", IDM_COPYSHORTCUT - MENUITEM "&", IDM_PASTE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Копировать &ярлык", IDM_COPYSHORTCUT + MENUITEM "&Вставить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM " &", IDM_ADDFAVORITES + MENUITEM "Добавить в &избранное", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&", IDM_PROPERTIES + MENUITEM "Сво&йства", IDM_PROPERTIES } POPUP "Control" { - MENUITEM "&", IDM_UNDO + MENUITEM "&Отменить", IDM_UNDO MENUITEM SEPARATOR - MENUITEM "&", IDM_CUT - MENUITEM "&", IDM_COPY - MENUITEM "&", IDM_PASTE - MENUITEM "&", IDM_DELETE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Вст&авить", IDM_PASTE + MENUITEM "&Удалить", IDM_DELETE MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM " &", IDM_SELECTALL + MENUITEM "Выделить в&сё", IDM_SELECTALL } POPUP "Table" { - POPUP "&" + POPUP "&Выделить" { - MENUITEM "&", IDM_CELLSELECT - MENUITEM "&", IDM_ROWSELECT - MENUITEM "&", IDM_COLUMNSELECT - MENUITEM "&", IDM_TABLESELECT + MENUITEM "&ячейку", IDM_CELLSELECT + MENUITEM "ст&року", IDM_ROWSELECT + MENUITEM "&колонку", IDM_COLUMNSELECT + MENUITEM "&таблицу", IDM_TABLESELECT } MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM " &", IDM_CELLPROPERTIES - MENUITEM "& ", IDM_TABLEPROPERTIES + MENUITEM "Свойства &ячейки", IDM_CELLPROPERTIES + MENUITEM "Сво&йства таблицы", IDM_TABLEPROPERTIES } POPUP "1DSite Select" { - MENUITEM "&", IDM_CUT - MENUITEM "&", IDM_COPY - MENUITEM "&", IDM_PASTE - MENUITEM " &", IDM_SELECTALL - MENUITEM "&", IDM_PRINT + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "&Вставить", IDM_PASTE + MENUITEM "Выделить в&сё", IDM_SELECTALL + MENUITEM "Пе&чать", IDM_PRINT MENUITEM SEPARATOR } POPUP "Anchor" { - MENUITEM "&", IDM_FOLLOWLINKC - MENUITEM " & ",IDM_FOLLOWLINKN - MENUITEM " & ...", IDM_SAVETARGET - MENUITEM "& ", IDM_PRINTTARGET + MENUITEM "&Открыть", IDM_FOLLOWLINKC + MENUITEM "Открыть в &новом окне",IDM_FOLLOWLINKN + MENUITEM "Сохранить об&ъект как...", IDM_SAVETARGET + MENUITEM "&Печать объекта", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM "&", IDM_CUT - MENUITEM "&", IDM_COPY - MENUITEM " &", IDM_COPYSHORTCUT - MENUITEM "&", IDM_PASTE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Копировать &ярлык", IDM_COPYSHORTCUT + MENUITEM "&Вставить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM " &",IDM_ADDFAVORITES + MENUITEM "Добавить в &избранное",IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&", IDM_PROPERTIES + MENUITEM "Сво&йства", IDM_PROPERTIES } POPUP "Context Unknown" @@ -147,54 +151,54 @@ IDR_BROWSE_CONTEXT_MENU MENU POPUP "DYNSRC Image" { - MENUITEM "& ", IDM_FOLLOWLINKC - MENUITEM " & ", IDM_FOLLOWLINKN - MENUITEM " & ...", IDM_SAVETARGET - MENUITEM "& ", IDM_PRINTTARGET + MENUITEM "&Открыть ссылку", IDM_FOLLOWLINKC + MENUITEM "Открыть ссылку в &новом окне", IDM_FOLLOWLINKN + MENUITEM "Сохранить об&ъект как...", IDM_SAVETARGET + MENUITEM "&Печать объекта", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM " &", IDM_SHOWPICTURE - MENUITEM "& ...",IDM_SAVEPICTURE - MENUITEM "& ", IDM_SETWALLPAPER - MENUITEM " & ...", IDM_SETDESKTOPITEM + MENUITEM "Показать &рисунок", IDM_SHOWPICTURE + MENUITEM "Со&хранить рисунок как...",IDM_SAVEPICTURE + MENUITEM "С&делать фоновым рисунком", IDM_SETWALLPAPER + MENUITEM "Сохранить как &элемент рабочего стола...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "&", IDM_CUT - MENUITEM "&", IDM_COPY - MENUITEM " &", IDM_COPYSHORTCUT - MENUITEM "&", IDM_PASTE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Копировать &ярлык", IDM_COPYSHORTCUT + MENUITEM "&Вставить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM " &", IDM_ADDFAVORITES + MENUITEM "Добавить в &избранное", IDM_ADDFAVORITES MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "", IDM_DYNSRCPLAY - MENUITEM "", IDM_DYNSRCSTOP - MENUITEM "&", IDM_PROPERTIES + MENUITEM "Воспроизвести", IDM_DYNSRCPLAY + MENUITEM "Остановить", IDM_DYNSRCSTOP + MENUITEM "Сво&йства", IDM_PROPERTIES } POPUP "ART Image" { - MENUITEM "& ", IDM_FOLLOWLINKC - MENUITEM " & ", IDM_FOLLOWLINKN - MENUITEM " & ...", IDM_SAVETARGET - MENUITEM "& ", IDM_PRINTTARGET + MENUITEM "&Открыть ссылку", IDM_FOLLOWLINKC + MENUITEM "Открыть ссылку в &новом окне", IDM_FOLLOWLINKN + MENUITEM "Сохранить об&ъект как...", IDM_SAVETARGET + MENUITEM "&Печать объекта", IDM_PRINTTARGET MENUITEM SEPARATOR - MENUITEM " &", IDM_SHOWPICTURE - MENUITEM "& ...",IDM_SAVEPICTURE - MENUITEM "& ", IDM_SETWALLPAPER - MENUITEM " & ...", IDM_SETDESKTOPITEM + MENUITEM "Показать &рисунок", IDM_SHOWPICTURE + MENUITEM "Со&хранить рисунок как...",IDM_SAVEPICTURE + MENUITEM "С&делать фоновым рисунком", IDM_SETWALLPAPER + MENUITEM "Сохранить как &элемент рабочего стола...", IDM_SETDESKTOPITEM MENUITEM SEPARATOR - MENUITEM "&", IDM_CUT - MENUITEM "&", IDM_COPY - MENUITEM " &", IDM_COPYSHORTCUT - MENUITEM "&", IDM_PASTE + MENUITEM "&Вырезать", IDM_CUT + MENUITEM "&Копировать", IDM_COPY + MENUITEM "Копировать &ярлык", IDM_COPYSHORTCUT + MENUITEM "&Вставить", IDM_PASTE MENUITEM SEPARATOR - MENUITEM " &", IDM_ADDFAVORITES + MENUITEM "Добавить в &избранное", IDM_ADDFAVORITES MENUITEM SEPARATOR - MENUITEM "", IDM_IMGARTPLAY - MENUITEM "", IDM_IMGARTSTOP - MENUITEM "", IDM_IMGARTREWIND + MENUITEM "Воспроизвести", IDM_IMGARTPLAY + MENUITEM "Остановить", IDM_IMGARTSTOP + MENUITEM "Перемотать", IDM_IMGARTREWIND MENUITEM SEPARATOR MENUITEM SEPARATOR - MENUITEM "&", IDM_PROPERTIES + MENUITEM "Сво&йства", IDM_PROPERTIES } POPUP "Debug" @@ -213,35 +217,35 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Performance Meters", IDM_PERFORMANCEMETERS MENUITEM "Save HTML", IDM_SAVEHTML MENUITEM SEPARATOR - MENUITEM " &", IDM_BROWSEMODE - MENUITEM "& ", IDM_EDITMODE + MENUITEM "Вид об&зора", IDM_BROWSEMODE + MENUITEM "Из&менить вид", IDM_EDITMODE } POPUP "Vertical Scrollbar" { - MENUITEM " ", IDM_SCROLL_HERE + MENUITEM "Прокрутка на месте", IDM_SCROLL_HERE MENUITEM SEPARATOR - MENUITEM "", IDM_SCROLL_TOP - MENUITEM "", IDM_SCROLL_BOTTOM + MENUITEM "Вверх", IDM_SCROLL_TOP + MENUITEM "Вниз", IDM_SCROLL_BOTTOM MENUITEM SEPARATOR - MENUITEM " ", IDM_SCROLL_PAGEUP - MENUITEM " ", IDM_SCROLL_PAGEDOWN + MENUITEM "Страница вверх", IDM_SCROLL_PAGEUP + MENUITEM "Страница вниз", IDM_SCROLL_PAGEDOWN MENUITEM SEPARATOR - MENUITEM " ", IDM_SCROLL_UP - MENUITEM " ", IDM_SCROLL_DOWN + MENUITEM "Прокрутка вверх", IDM_SCROLL_UP + MENUITEM "Прокрутка вниз", IDM_SCROLL_DOWN } POPUP "Horizontal Scrollbar" { - MENUITEM " ", IDM_SCROLL_HERE + MENUITEM "Прокрутка на месте", IDM_SCROLL_HERE MENUITEM SEPARATOR - MENUITEM " ", IDM_SCROLL_LEFTEDGE - MENUITEM " ", IDM_SCROLL_RIGHTEDGE + MENUITEM "К левому краю", IDM_SCROLL_LEFTEDGE + MENUITEM "К правому краю", IDM_SCROLL_RIGHTEDGE MENUITEM SEPARATOR - MENUITEM " ", IDM_SCROLL_PAGELEFT - MENUITEM " ", IDM_SCROLL_PAGERIGHT + MENUITEM "Страница влево", IDM_SCROLL_PAGELEFT + MENUITEM "Страница вправо", IDM_SCROLL_PAGERIGHT MENUITEM SEPARATOR - MENUITEM " ", IDM_SCROLL_LEFT - MENUITEM " ", IDM_SCROLL_RIGHT + MENUITEM "Прокрутка влево", IDM_SCROLL_LEFT + MENUITEM "Прокрутка вправо", IDM_SCROLL_RIGHT } } diff --git a/dll/win32/shdoclc/Si.rc b/dll/win32/shdoclc/Si.rc index ccc79002144..c95dc017089 100644 --- a/dll/win32/shdoclc/Si.rc +++ b/dll/win32/shdoclc/Si.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT @@ -247,5 +248,3 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "Drsenje desno", IDM_SCROLL_RIGHT } } - -#pragma code_page(default) diff --git a/dll/win32/shdoclc/Sv.rc b/dll/win32/shdoclc/Sv.rc index 9b20705b3d4..277745d5630 100644 --- a/dll/win32/shdoclc/Sv.rc +++ b/dll/win32/shdoclc/Sv.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL diff --git a/dll/win32/shdoclc/Tr.rc b/dll/win32/shdoclc/Tr.rc index 8bd4ed07fa0..ea238e14bf8 100644 --- a/dll/win32/shdoclc/Tr.rc +++ b/dll/win32/shdoclc/Tr.rc @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT diff --git a/dll/win32/shdoclc/Uk.rc b/dll/win32/shdoclc/Uk.rc new file mode 100644 index 00000000000..ae2356b92b4 --- /dev/null +++ b/dll/win32/shdoclc/Uk.rc @@ -0,0 +1,470 @@ +/* + * Copyright 2005-2006 Jacek Caban + * Copyright 2010 Igor Paliychuk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "shdoclc.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_MESSAGE_BOX_TITLE, "Wine Internet Explorer" +} + +STRINGTABLE DISCARDABLE +{ + IDS_PRINT_HEADER_TEMPLATE "&w&bPage &p" /* FIXME: should be "&w&bPage &p of &P" */ + IDS_PRINT_FOOTER_TEMPLATE "&u&b&d" +} + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Default" + { + MENUITEM "&Назад", IDM_GOBACKWARD + MENUITEM "&Вперед", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&Зберегти тло як...", IDM_SAVEBACKGROUND + MENUITEM "Зробити &фоновим малюнком", IDM_SETWALLPAPER + MENUITEM "&Копіювати тло", IDM_COPYBACKGROUND + MENUITEM "Set as &Desktop Item", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Виділити вс&е", IDM_SELECTALL + MENUITEM "В&ставити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Створити &ярлик", IDM_CREATESHORTCUT + MENUITEM "Додати до &Обраного", IDM_ADDFAVORITES + MENUITEM "&Переглянути вихідний код", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "&Кодування", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "&Друк", IDM_PRINT + MENUITEM "О&новити", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "В&ластивості", IDM_PROPERTIES + } + + POPUP "Image" + { + MENUITEM "&Відкрити посилання", IDM_FOLLOWLINKC + MENUITEM "Відкрити посилання в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &як...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "&Зберегти малюнок як...", IDM_SAVEPICTURE + MENUITEM "Відправити малюнок по &Е-mail...", IDM_MP_EMAILPICTURE + MENUITEM "Др&ук малюнка...", IDM_MP_PRINTPICTURE + MENUITEM "&Перейти до теки Мої Малюнки", IDM_MP_MYPICS + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Ви&різати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ярл&ик", IDM_COPYSHORTCUT + MENUITEM "В&ставити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Властивост&і", IDM_PROPERTIES + } + + POPUP "Control" + { + MENUITEM "&Відмінити", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "В&ставити", IDM_PASTE + MENUITEM "Ви&далити", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Виділ&ити все", IDM_SELECTALL + } + + POPUP "Table" + { + POPUP "&Виділити" + { + MENUITEM "&Комірку", IDM_CELLSELECT + MENUITEM "&Рядок", IDM_ROWSELECT + MENUITEM "&Стовпчик", IDM_COLUMNSELECT + MENUITEM "&Таблицю", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Властивості &Комірки", IDM_CELLPROPERTIES + MENUITEM "Властивості &Таблиці", IDM_TABLEPROPERTIES + } + + POPUP "1DSite Select" + { + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Вставити", IDM_PASTE + MENUITEM "Виділити в&се", IDM_SELECTALL + MENUITEM "&Друк", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "Anchor" + { + MENUITEM "&Відкрити", IDM_FOLLOWLINKC + MENUITEM "Відкрити в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &як...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Вирізати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати я&рлик", IDM_COPYSHORTCUT + MENUITEM "Вс&тавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "В&ластивості", IDM_PROPERTIES + } + + POPUP "Context Unknown" + { + MENUITEM SEPARATOR + } + + POPUP "DYNSRC Image" + { + MENUITEM "&Відкрити посилання", IDM_FOLLOWLINKC + MENUITEM "Відкрити посилання в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &як...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "&Save Video As...", IDM_SAVEPICTURE + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати я&рлик", IDM_COPYSHORTCUT + MENUITEM "Встав&ити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Грати", IDM_DYNSRCPLAY + MENUITEM "Зупинити", IDM_DYNSRCSTOP + MENUITEM "Властивост&і", IDM_PROPERTIES + } + + POPUP "ART Image" + { + MENUITEM "&Відкрити посилання", IDM_FOLLOWLINKC + MENUITEM "Відкрити посилання в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &як...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "Зберегти малюнок я&к...", IDM_SAVEPICTURE + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "В&ирізати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати я&рлик", IDM_COPYSHORTCUT + MENUITEM "Вс&тавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Грати", IDM_IMGARTPLAY + MENUITEM "Зупинити", IDM_IMGARTSTOP + MENUITEM "Перемотати", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Властивост&і", IDM_PROPERTIES + } + + POPUP "Debug" + { + MENUITEM "Trace Tags", IDM_TRACETAGS + MENUITEM "Resource Failures", IDM_RESOURCEFAILURES + MENUITEM "Dump Tracking Info", IDM_DUMPTRACKINGINFO + MENUITEM "Debug Break", IDM_DEBUGBREAK + MENUITEM "Debug View", IDM_DEBUGVIEW + MENUITEM "Dump Tree", IDM_DUMPTREE + MENUITEM "Dump Lines", IDM_DUMPLINES + MENUITEM "Dump DisplayTree", IDM_DUMPDISPLAYTREE + MENUITEM "Dump FormatCaches", IDM_DUMPFORMATCACHES + MENUITEM "Dump LayoutRects", IDM_DUMPLAYOUTRECTS + MENUITEM "Memory Monitor", IDM_MEMORYMONITOR + MENUITEM "Performance Meters", IDM_PERFORMANCEMETERS + MENUITEM "Save HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&Browse View", IDM_BROWSEMODE + MENUITEM "&Edit View", IDM_EDITMODE + } + + POPUP "Vertical Scrollbar" + { + MENUITEM "Прокрутити тут", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Вверх", IDM_SCROLL_TOP + MENUITEM "Вниз", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Сторінка вверх", IDM_SCROLL_PAGEUP + MENUITEM "Сторінка вниз", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Прокрутити вверх", IDM_SCROLL_UP + MENUITEM "Прокрутити вниз", IDM_SCROLL_DOWN + } + + POPUP "Horizontal Scrollbar" + { + MENUITEM "Прокрутити тут", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "До лівого краю", IDM_SCROLL_LEFTEDGE + MENUITEM "До правого краю", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Сторінка вліво", IDM_SCROLL_PAGELEFT + MENUITEM "Сторінка вправо", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Прокрутити вліво", IDM_SCROLL_LEFT + MENUITEM "Проктурити вправо", IDM_SCROLL_RIGHT + } +} + +LANGUAGE LANG_UKRAINIAN, SUBLANG_NEUTRAL + +IDR_BROWSE_CONTEXT_MENU MENU +{ + POPUP "Default" + { + MENUITEM "&Назад", IDM_GOBACKWARD + MENUITEM "&Вперед", IDM_GOFORWARD + MENUITEM SEPARATOR + MENUITEM "&Зберегти тло як...", IDM_SAVEBACKGROUND + MENUITEM "Зробити &фоновим малюнком", IDM_SETWALLPAPER + MENUITEM "&Копіювати тло", IDM_COPYBACKGROUND + MENUITEM "Set as &Desktop Item", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Виділити вс&е", IDM_SELECTALL + MENUITEM "В&ставити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Створити &ярлик", IDM_CREATESHORTCUT + MENUITEM "Додати до &Обраного", IDM_ADDFAVORITES + MENUITEM "&Переглянути вихідний код", IDM_VIEWSOURCE + MENUITEM SEPARATOR + MENUITEM "&Кодування", IDM_LANGUAGE + MENUITEM SEPARATOR + MENUITEM "&Друк", IDM_PRINT + MENUITEM "О&новити", _IDM_REFRESH + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "В&ластивості", IDM_PROPERTIES + } + + POPUP "Image" + { + MENUITEM "&Відкрити посилання", IDM_FOLLOWLINKC + MENUITEM "Відкрити посилання в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &як...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "&Зберегти малюнок як...", IDM_SAVEPICTURE + MENUITEM "Відправити малюнок по &Е-mail...", IDM_MP_EMAILPICTURE + MENUITEM "Др&ук малюнка...", IDM_MP_PRINTPICTURE + MENUITEM "&Перейти до теки Мої Малюнки", IDM_MP_MYPICS + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Ви&різати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати Ярл&ик", IDM_COPYSHORTCUT + MENUITEM "В&ставити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Властивост&і", IDM_PROPERTIES + } + + POPUP "Control" + { + MENUITEM "&Відмінити", IDM_UNDO + MENUITEM SEPARATOR + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "В&ставити", IDM_PASTE + MENUITEM "Ви&далити", IDM_DELETE + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Виділ&ити все", IDM_SELECTALL + } + + POPUP "Table" + { + POPUP "&Виділити" + { + MENUITEM "&Комірку", IDM_CELLSELECT + MENUITEM "&Рядок", IDM_ROWSELECT + MENUITEM "&Стовпчик", IDM_COLUMNSELECT + MENUITEM "&Таблицю", IDM_TABLESELECT + } + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Властивості &Комірки", IDM_CELLPROPERTIES + MENUITEM "Властивості &Таблиці", IDM_TABLEPROPERTIES + } + + POPUP "1DSite Select" + { + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Вставити", IDM_PASTE + MENUITEM "Виділити в&се", IDM_SELECTALL + MENUITEM "&Друк", IDM_PRINT + MENUITEM SEPARATOR + } + + POPUP "Anchor" + { + MENUITEM "&Відкрити", IDM_FOLLOWLINKC + MENUITEM "Відкрити в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &як...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Вирізати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати я&рлик", IDM_COPYSHORTCUT + MENUITEM "Вс&тавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "В&ластивості", IDM_PROPERTIES + } + + POPUP "Context Unknown" + { + MENUITEM SEPARATOR + } + + POPUP "DYNSRC Image" + { + MENUITEM "&Відкрити посилання", IDM_FOLLOWLINKC + MENUITEM "Відкрити посилання в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &як...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "&Save Video As...", IDM_SAVEPICTURE + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "Виріза&ти", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати я&рлик", IDM_COPYSHORTCUT + MENUITEM "Встав&ити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Грати", IDM_DYNSRCPLAY + MENUITEM "Зупинити", IDM_DYNSRCSTOP + MENUITEM "Властивост&і", IDM_PROPERTIES + } + + POPUP "ART Image" + { + MENUITEM "&Відкрити посилання", IDM_FOLLOWLINKC + MENUITEM "Відкрити посилання в &новому вікні", IDM_FOLLOWLINKN + MENUITEM "Зберегти об'єкт &як...", IDM_SAVETARGET + MENUITEM "&Друк об'єкту", IDM_PRINTTARGET + MENUITEM SEPARATOR + MENUITEM "Пок&азати малюнок", IDM_SHOWPICTURE + MENUITEM "Зберегти малюнок я&к...", IDM_SAVEPICTURE + MENUITEM "Зробити фоновим мал&юнком", IDM_SETWALLPAPER + MENUITEM "Set as &Desktop Item...", IDM_SETDESKTOPITEM + MENUITEM SEPARATOR + MENUITEM "В&ирізати", IDM_CUT + MENUITEM "&Копіювати", IDM_COPY + MENUITEM "Копіювати я&рлик", IDM_COPYSHORTCUT + MENUITEM "Вс&тавити", IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "Додати до &Обраного...", IDM_ADDFAVORITES + MENUITEM SEPARATOR + MENUITEM "Грати", IDM_IMGARTPLAY + MENUITEM "Зупинити", IDM_IMGARTSTOP + MENUITEM "Перемотати", IDM_IMGARTREWIND + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "Властивост&і", IDM_PROPERTIES + } + + POPUP "Debug" + { + MENUITEM "Trace Tags", IDM_TRACETAGS + MENUITEM "Resource Failures", IDM_RESOURCEFAILURES + MENUITEM "Dump Tracking Info", IDM_DUMPTRACKINGINFO + MENUITEM "Debug Break", IDM_DEBUGBREAK + MENUITEM "Debug View", IDM_DEBUGVIEW + MENUITEM "Dump Tree", IDM_DUMPTREE + MENUITEM "Dump Lines", IDM_DUMPLINES + MENUITEM "Dump DisplayTree", IDM_DUMPDISPLAYTREE + MENUITEM "Dump FormatCaches", IDM_DUMPFORMATCACHES + MENUITEM "Dump LayoutRects", IDM_DUMPLAYOUTRECTS + MENUITEM "Memory Monitor", IDM_MEMORYMONITOR + MENUITEM "Performance Meters", IDM_PERFORMANCEMETERS + MENUITEM "Save HTML", IDM_SAVEHTML + MENUITEM SEPARATOR + MENUITEM "&Browse View", IDM_BROWSEMODE + MENUITEM "&Edit View", IDM_EDITMODE + } + + POPUP "Vertical Scrollbar" + { + MENUITEM "Прокрутити тут", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "Вверх", IDM_SCROLL_TOP + MENUITEM "Вниз", IDM_SCROLL_BOTTOM + MENUITEM SEPARATOR + MENUITEM "Сторінка вверх", IDM_SCROLL_PAGEUP + MENUITEM "Сторінка вниз", IDM_SCROLL_PAGEDOWN + MENUITEM SEPARATOR + MENUITEM "Прокрутити вверх", IDM_SCROLL_UP + MENUITEM "Прокрутити вниз", IDM_SCROLL_DOWN + } + + POPUP "Horizontal Scrollbar" + { + MENUITEM "Прокрутити тут", IDM_SCROLL_HERE + MENUITEM SEPARATOR + MENUITEM "До лівого краю", IDM_SCROLL_LEFTEDGE + MENUITEM "До правого краю", IDM_SCROLL_RIGHTEDGE + MENUITEM SEPARATOR + MENUITEM "Сторінка вліво", IDM_SCROLL_PAGELEFT + MENUITEM "Сторінка вправо", IDM_SCROLL_PAGERIGHT + MENUITEM SEPARATOR + MENUITEM "Прокрутити вліво", IDM_SCROLL_LEFT + MENUITEM "Проктурити вправо", IDM_SCROLL_RIGHT + } +} diff --git a/dll/win32/shdoclc/Zh.rc b/dll/win32/shdoclc/Zh.rc index f3570e840ce..c597676882c 100644 --- a/dll/win32/shdoclc/Zh.rc +++ b/dll/win32/shdoclc/Zh.rc @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "shdoclc.h" /* Chinese text is encoded in UTF-8 */ #pragma code_page(65001) @@ -479,5 +480,3 @@ IDR_BROWSE_CONTEXT_MENU MENU MENUITEM "向右滾動", IDM_SCROLL_RIGHT } } - -#pragma code_page(default) diff --git a/dll/win32/shdoclc/rsrc.rc b/dll/win32/shdoclc/rsrc.rc index 847c2e120cd..4759265aaf9 100644 --- a/dll/win32/shdoclc/rsrc.rc +++ b/dll/win32/shdoclc/rsrc.rc @@ -24,18 +24,24 @@ #include "Bg.rc" #include "Da.rc" -#include "De.rc" #include "En.rc" #include "Es.rc" #include "Fi.rc" -#include "Fr.rc" #include "Hu.rc" #include "Ko.rc" #include "Nl.rc" #include "No.rc" -#include "Pt.rc" -#include "Ru.rc" -#include "Si.rc" #include "Sv.rc" #include "Tr.rc" + +/* UTF-8 */ +#include "De.rc" +#include "Fr.rc" +#include "Lt.rc" +#include "Pt.rc" +#include "Ro.rc" +#include "Ru.rc" +#include "Si.rc" +#include "Uk.rc" #include "Zh.rc" + diff --git a/dll/win32/shdoclc/shdoclc.h b/dll/win32/shdoclc/shdoclc.h index 2bc7626990a..b5492d6243a 100644 --- a/dll/win32/shdoclc/shdoclc.h +++ b/dll/win32/shdoclc/shdoclc.h @@ -16,6 +16,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include +#include + #define IDS_MESSAGE_BOX_TITLE 2213 #define IDS_PRINT_HEADER_TEMPLATE 8403 diff --git a/dll/win32/shdocvw/client.c b/dll/win32/shdocvw/client.c index a351bd1e37f..17fa35f96d1 100644 --- a/dll/win32/shdocvw/client.c +++ b/dll/win32/shdocvw/client.c @@ -73,7 +73,7 @@ static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID ri return S_OK; } - WARN("Unsupported intrface %s\n", debugstr_guid(riid)); + WARN("Unsupported interface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; } diff --git a/dll/win32/shdocvw/dochost.c b/dll/win32/shdocvw/dochost.c index f3035e1c15e..e8982e4f12a 100644 --- a/dll/win32/shdocvw/dochost.c +++ b/dll/win32/shdocvw/dochost.c @@ -362,6 +362,29 @@ void deactivate_document(DocHost *This) This->document = NULL; } +void release_dochost_client(DocHost *This) +{ + if(This->hwnd) { + DestroyWindow(This->hwnd); + This->hwnd = NULL; + } + + if(This->hostui) { + IDocHostUIHandler_Release(This->hostui); + This->hostui = NULL; + } + + if(This->client_disp) { + IDispatch_Release(This->client_disp); + This->client_disp = NULL; + } + + if(This->frame) { + IOleInPlaceFrame_Release(This->frame); + This->frame = NULL; + } +} + #define OLECMD_THIS(iface) DEFINE_THIS(DocHost, OleCommandTarget, iface) static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface, @@ -387,8 +410,13 @@ static HRESULT WINAPI ClOleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText) { DocHost *This = OLECMD_THIS(iface); + ULONG i= 0; FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText); + while (prgCmds && (cCmds > i)) { + FIXME("command_%u: %u, 0x%x\n", i, prgCmds[i].cmdID, prgCmds[i].cmdf); + i++; + } return E_NOTIMPL; } @@ -744,14 +772,10 @@ void DocHost_Init(DocHost *This, IDispatch *disp) void DocHost_Release(DocHost *This) { - if(This->client_disp) - IDispatch_Release(This->client_disp); - if(This->frame) - IOleInPlaceFrame_Release(This->frame); - + release_dochost_client(This); DocHost_ClientSite_Release(This); ConnectionPointContainer_Destroy(&This->cps); - SysFreeString(This->url); + CoTaskMemFree(This->url); } diff --git a/dll/win32/shdocvw/intshcut.c b/dll/win32/shdocvw/intshcut.c index 86bc543aa32..b389ec3727a 100644 --- a/dll/win32/shdocvw/intshcut.c +++ b/dll/win32/shdocvw/intshcut.c @@ -65,16 +65,51 @@ static inline InternetShortcut* impl_from_IPersistFile(IPersistFile *iface) return (InternetShortcut*)((char*)iface - FIELD_OFFSET(InternetShortcut, persistFile)); } -static BOOL StartLinkProcessor(LPCOLESTR szLink) +static BOOL run_winemenubuilder( const WCHAR *args ) { - static const WCHAR szFormat[] = { - 'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e', - ' ','-','w',' ','-','u',' ','"','%','s','"',0 }; + static const WCHAR menubuilder[] = {'\\','w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',0}; LONG len; LPWSTR buffer; STARTUPINFOW si; PROCESS_INFORMATION pi; BOOL ret; + WCHAR app[MAX_PATH]; + + GetSystemDirectoryW( app, MAX_PATH - sizeof(menubuilder)/sizeof(WCHAR) ); + strcatW( app, menubuilder ); + + len = (strlenW( app ) + strlenW( args ) + 1) * sizeof(WCHAR); + buffer = heap_alloc( len ); + if( !buffer ) + return FALSE; + + strcpyW( buffer, app ); + strcatW( buffer, args ); + + TRACE("starting %s\n",debugstr_w(buffer)); + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + + ret = CreateProcessW( app, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ); + + heap_free( buffer ); + + if (ret) + { + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); + } + + return ret; +} + +static BOOL StartLinkProcessor( LPCOLESTR szLink ) +{ + static const WCHAR szFormat[] = { ' ','-','w',' ','-','u',' ','"','%','s','"',0 }; + LONG len; + LPWSTR buffer; + BOOL ret; len = sizeof(szFormat) + lstrlenW( szLink ) * sizeof(WCHAR); buffer = heap_alloc( len ); @@ -82,22 +117,8 @@ static BOOL StartLinkProcessor(LPCOLESTR szLink) return FALSE; wsprintfW( buffer, szFormat, szLink ); - - TRACE("starting %s\n",debugstr_w(buffer)); - - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - - ret = CreateProcessW( NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ); - - HeapFree( GetProcessHeap(), 0, buffer ); - - if (ret) - { - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - } - + ret = run_winemenubuilder( buffer ); + heap_free( buffer ); return ret; } diff --git a/dll/win32/shdocvw/oleobject.c b/dll/win32/shdocvw/oleobject.c index 3657a7a5276..f67edb7583e 100644 --- a/dll/win32/shdocvw/oleobject.c +++ b/dll/win32/shdocvw/oleobject.c @@ -255,6 +255,36 @@ static HRESULT on_silent_change(WebBrowser *This) return S_OK; } +static void release_client_site(WebBrowser *This) +{ + release_dochost_client(&This->doc_host); + + if(This->shell_embedding_hwnd) { + DestroyWindow(This->shell_embedding_hwnd); + This->shell_embedding_hwnd = NULL; + } + + if(This->inplace) { + IOleInPlaceSite_Release(This->inplace); + This->inplace = NULL; + } + + if(This->container) { + IOleContainer_Release(This->container); + This->container = NULL; + } + + if(This->uiwindow) { + IOleInPlaceUIWindow_Release(This->uiwindow); + This->uiwindow = NULL; + } + + if(This->client) { + IOleClientSite_Release(This->client); + This->client = NULL; + } +} + /********************************************************************** * Implement the IOleObject interface for the WebBrowser control */ @@ -282,7 +312,9 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface) static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite) { WebBrowser *This = OLEOBJ_THIS(iface); + IDocHostUIHandler *hostui; IOleContainer *container; + IDispatch *disp; HRESULT hres; TRACE("(%p)->(%p)\n", This, pClientSite); @@ -290,29 +322,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE if(This->client == pClientSite) return S_OK; - if(This->doc_host.hwnd) { - DestroyWindow(This->doc_host.hwnd); - This->doc_host.hwnd = NULL; - } - if(This->shell_embedding_hwnd) { - DestroyWindow(This->shell_embedding_hwnd); - This->shell_embedding_hwnd = NULL; - } - - if(This->inplace) { - IOleInPlaceSite_Release(This->inplace); - This->inplace = NULL; - } - - if(This->doc_host.hostui) { - IDocHostUIHandler_Release(This->doc_host.hostui); - This->doc_host.hostui = NULL; - } - - if(This->client) - IOleClientSite_Release(This->client); - - This->client = pClientSite; + release_client_site(This); if(!pClientSite) { if(This->doc_host.document) @@ -321,12 +331,17 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE } IOleClientSite_AddRef(pClientSite); + This->client = pClientSite; - IOleClientSite_QueryInterface(This->client, &IID_IDispatch, - (void**)&This->doc_host.client_disp); + hres = IOleClientSite_QueryInterface(This->client, &IID_IDispatch, + (void**)&disp); + if(SUCCEEDED(hres)) + This->doc_host.client_disp = disp; - IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler, - (void**)&This->doc_host.hostui); + hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler, + (void**)&hostui); + if(SUCCEEDED(hres)) + This->doc_host.hostui = hostui; hres = IOleClientSite_GetContainer(This->client, &container); if(SUCCEEDED(hres)) { @@ -963,10 +978,5 @@ void WebBrowser_OleObject_Init(WebBrowser *This) void WebBrowser_OleObject_Destroy(WebBrowser *This) { - if(This->client) - IOleObject_SetClientSite(OLEOBJ(This), NULL); - if(This->container) - IOleContainer_Release(This->container); - if(This->uiwindow) - IOleInPlaceUIWindow_Release(This->uiwindow); + release_client_site(This); } diff --git a/dll/win32/shdocvw/shdocvw.h b/dll/win32/shdocvw/shdocvw.h index 9a511211f71..c5b9c9a1be5 100644 --- a/dll/win32/shdocvw/shdocvw.h +++ b/dll/win32/shdocvw/shdocvw.h @@ -205,6 +205,7 @@ void WebBrowser_OleObject_Destroy(WebBrowser*); void DocHost_Init(DocHost*,IDispatch*); void DocHost_ClientSite_Init(DocHost*); void DocHost_Frame_Init(DocHost*); +void release_dochost_client(DocHost*); void DocHost_Release(DocHost*); void DocHost_ClientSite_Release(DocHost*); @@ -252,6 +253,8 @@ HRESULT register_class_object(BOOL); HRESULT get_typeinfo(ITypeInfo**); DWORD register_iexplore(BOOL); +const char *debugstr_variant(const VARIANT*); + /* memory allocation functions */ static inline void *heap_alloc(size_t len) diff --git a/dll/win32/shdocvw/shdocvw.inf b/dll/win32/shdocvw/shdocvw.inf index 92e78845f35..932c9beaf25 100644 --- a/dll/win32/shdocvw/shdocvw.inf +++ b/dll/win32/shdocvw/shdocvw.inf @@ -34,10 +34,10 @@ HKCR,"CLSID\%CLSID_SearchAssistantOC%\InProcServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_SearchAssistantOC%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_SearchAssistantOC%\ProgID",,,"SearchAssistantOC.SearchAssistantOC.1" HKCR,"CLSID\%CLSID_SearchAssistantOC%\VersionIndependentProgID",,,"SearchAssistantOC.SearchAssistantOC" -HKCR,"SearchAssistantOC.SearchAssistantOC",,,"" +HKCR,"SearchAssistantOC.SearchAssistantOC",,,"SearchAssistantOC" HKCR,"SearchAssistantOC.SearchAssistantOC\CLSID",,,"%CLSID_SearchAssistantOC%" HKCR,"SearchAssistantOC.SearchAssistantOC\CurVer",,,"SearchAssistantOC.SearchAssistantOC.1" -HKCR,"SearchAssistantOC.SearchAssistantOC.1",,,"" +HKCR,"SearchAssistantOC.SearchAssistantOC.1",,,"SearchAssistantOC" HKCR,"SearchAssistantOC.SearchAssistantOC.1\CLSID",,,"%CLSID_SearchAssistantOC%" HKCR,"CLSID\%CLSID_ShellNameSpace%",,,"Shell Name Space" @@ -67,7 +67,7 @@ HKCR,"CLSID\%CLSID_ShellUIHelper%\ProgID",,,"Shell.UIHelper.1" HKCR,"Shell.UIHelper",,,"Microsoft Shell UI Helper" HKCR,"Shell.UIHelper\CLSID",,,"%CLSID_ShellUIHelper%" HKCR,"Shell.UIHelper\CurVer",,,"Shell.UIHelper.2" -HKCR,"Shell.UIHelper.1",,,"" +HKCR,"Shell.UIHelper.1",,,"Microsoft Shell UI Helper" HKCR,"Shell.UIHelper.1\CLSID",,,"%CLSID_ShellUIHelper%" HKCR,"CLSID\%CLSID_Internet%\DefaultIcon",,,"shdoclc.dll,-190" @@ -86,7 +86,7 @@ HKCR,"CLSID\%CLSID_WebBrowser%\VersionIndependentProgID",,,"Shell.Explorer" HKCR,"Shell.Explorer",,,"Microsoft Web Browser" HKCR,"Shell.Explorer\CLSID",,,"%CLSID_WebBrowser%" HKCR,"Shell.Explorer\CurVer",,,"Shell.Explorer.2" -HKCR,"Shell.Explorer.2",,,"" +HKCR,"Shell.Explorer.2",,,"Microsoft Web Browser" HKCR,"Shell.Explorer.2\CLSID",,,"%CLSID_WebBrowser%" HKCR,"CLSID\%CLSID_ShellWindows%",,,"ShellWindows" @@ -108,14 +108,14 @@ HKCR,"CLSID\%CLSID_WebBrowser_V1%\InProcServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_WebBrowser_V1%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_WebBrowser_V1%\ProgID",,,"Shell.Explorer.1" HKCR,"CLSID\%CLSID_WebBrowser_V1%\VersionIndependentProgID",,,"Shell.Explorer" -HKCR,"Shell.Explorer.1",,,"" +HKCR,"Shell.Explorer.1",,,"Microsoft Web Browser" HKCR,"Shell.Explorer.1\CLSID",,,"%CLSID_WebBrowser_V1%" HKCR,"CLSID\%CLSID_InternetShortcut%",,,"Internet Shortcut" HKCR,"CLSID\%CLSID_InternetShortcut%\InProcServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_InternetShortcut%\InProcServer32","ThreadingModel",,"Apartment" HKCR,"CLSID\%CLSID_InternetShortcut%\ProgID",,,"InternetShortcut" -HKCR,"CLSID\%CLSID_InternetShortcut%\shellex\MayChangeDefaultMenu",,, +HKCR,"CLSID\%CLSID_InternetShortcut%\shellex\MayChangeDefaultMenu",,16 HKCR,"InternetShortcut",,,"Internet Shortcut" HKCR,"InternetShortcut","EditFlags",2,"2" HKCR,"InternetShortcut","IsShortcut",, diff --git a/dll/win32/shdocvw/shdocvw_main.c b/dll/win32/shdocvw/shdocvw_main.c index 9090b7d47f4..746753f0ab2 100644 --- a/dll/win32/shdocvw/shdocvw_main.c +++ b/dll/win32/shdocvw/shdocvw_main.c @@ -67,6 +67,31 @@ HRESULT get_typeinfo(ITypeInfo **typeinfo) return hres; } +const char *debugstr_variant(const VARIANT *v) +{ + if(!v) + return "(null)"; + + switch(V_VT(v)) { + case VT_EMPTY: + return "{VT_EMPTY}"; + case VT_NULL: + return "{VT_NULL}"; + case VT_I4: + return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v)); + case VT_R8: + return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v)); + case VT_BSTR: + return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v))); + case VT_DISPATCH: + return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v)); + case VT_BOOL: + return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v)); + default: + return wine_dbg_sprintf("{vt %d}", V_VT(v)); + } +} + /************************************************************************* * SHDOCVW DllMain */ diff --git a/dll/win32/shdocvw/taskbarlist.c b/dll/win32/shdocvw/taskbarlist.c index 028169584f0..2c380800ddf 100644 --- a/dll/win32/shdocvw/taskbarlist.c +++ b/dll/win32/shdocvw/taskbarlist.c @@ -81,9 +81,9 @@ static ULONG STDMETHODCALLTYPE taskbar_list_Release(ITaskbarList *iface) static HRESULT STDMETHODCALLTYPE taskbar_list_HrInit(ITaskbarList *iface) { - FIXME("iface %p stub!\n", iface); + TRACE("iface %p\n", iface); - return E_NOTIMPL; + return S_OK; } static HRESULT STDMETHODCALLTYPE taskbar_list_AddTab(ITaskbarList *iface, HWND hwnd) diff --git a/dll/win32/shdocvw/webbrowser.c b/dll/win32/shdocvw/webbrowser.c index 323e9addfcb..b0633b03f19 100644 --- a/dll/win32/shdocvw/webbrowser.c +++ b/dll/win32/shdocvw/webbrowser.c @@ -269,8 +269,9 @@ static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl, { WebBrowser *This = WEBBROWSER_THIS(iface); - TRACE("(%p)->(%s %p %p %p %p)\n", This, debugstr_w(szUrl), Flags, TargetFrameName, - PostData, Headers); + TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags), + debugstr_variant(TargetFrameName), debugstr_variant(PostData), + debugstr_variant(Headers)); return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers); } @@ -285,7 +286,7 @@ static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface) static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%p)\n", This, Level); + FIXME("(%p)->(%s)\n", This, debugstr_variant(Level)); return E_NOTIMPL; } @@ -516,22 +517,28 @@ static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, i static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(szProperty)); + FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue)); return E_NOTIMPL; } static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%s %p)\n", This, debugstr_w(szProperty), pvtValue); + FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue)); return E_NOTIMPL; } static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name) { + static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b', + ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0}; WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%p)\n", This, Name); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, Name); + + *Name = SysAllocString(sName); + + return S_OK; } static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND) @@ -726,7 +733,8 @@ static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VA WebBrowser *This = WEBBROWSER_THIS(iface); LPCWSTR url; - TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers); + TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags), + debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers)); if(!This->client) return E_FAIL; @@ -761,7 +769,7 @@ static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%d %d %p %p)\n", This, cmdID, cmdexecopt, pvaIn, pvaOut); + FIXME("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut); return E_NOTIMPL; } @@ -769,7 +777,8 @@ static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pv VARIANT *pvarShow, VARIANT *pvarSize) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%p %p %p)\n", This, pvaClsid, pvarShow, pvarSize); + FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow), + debugstr_variant(pvarSize)); return E_NOTIMPL; } diff --git a/dll/win32/shell32/dataobject.c b/dll/win32/shell32/dataobject.c index 503ff4568d4..6da709528c8 100644 --- a/dll/win32/shell32/dataobject.c +++ b/dll/win32/shell32/dataobject.c @@ -428,9 +428,9 @@ LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, dto->apidl = _ILCopyaPidl(apidl, cidl); dto->cidl = cidl; - dto->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + dto->cfShellIDList = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); dto->cfFileNameA = RegisterClipboardFormatA(CFSTR_FILENAMEA); - dto->cfFileNameW = RegisterClipboardFormatA(CFSTR_FILENAMEW); + dto->cfFileNameW = RegisterClipboardFormatW(CFSTR_FILENAMEW); InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL); InitFormatEtc(dto->pFormatEtc[1], CF_HDROP, TYMED_HGLOBAL); InitFormatEtc(dto->pFormatEtc[2], dto->cfFileNameA, TYMED_HGLOBAL); diff --git a/dll/win32/shell32/lang/pl-PL.rc b/dll/win32/shell32/lang/pl-PL.rc index c7877828959..b6d33a64fd4 100644 --- a/dll/win32/shell32/lang/pl-PL.rc +++ b/dll/win32/shell32/lang/pl-PL.rc @@ -755,5 +755,5 @@ BEGIN IDS_INSTALLNEWFONT "Zainstaluj Now Czcionk..." IDS_DEFAULT_CLUSTER_SIZE "Domylny rozmiar jednostki alokacji" - IDS_COPY_OF "Copy of" + IDS_COPY_OF "Kopia" END diff --git a/dll/win32/shell32/pidl.c b/dll/win32/shell32/pidl.c index 0b4f226031b..f229bd9626a 100644 --- a/dll/win32/shell32/pidl.c +++ b/dll/win32/shell32/pidl.c @@ -413,7 +413,7 @@ HRESULT WINAPI SHILCreateFromPathAW (LPCVOID path, LPITEMIDLIST * ppidl, DWORD * * Caller is responsible for deallocating the returned ItemIDList with the * shells IMalloc interface, aka ILFree. */ -PIDLIST_ABSOLUTE WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate) +LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate) { LPITEMIDLIST ppidl; TRACE_(shell)("(hwnd=%p,csidl=0x%x,%s).\n", hwndOwner, nFolder, fCreate ? "T" : "F"); @@ -696,7 +696,7 @@ HRESULT WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPCITEMIDLIST pidlSimple, LPITEM STGMEDIUM medium; FORMATETC fmt; - fmt.cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); fmt.ptd = NULL; fmt.dwAspect = DVASPECT_CONTENT; fmt.lindex = -1; diff --git a/dll/win32/shell32/she_ocmenu.c b/dll/win32/shell32/she_ocmenu.c index 618d6ad8cf4..dc66376cdea 100644 --- a/dll/win32/shell32/she_ocmenu.c +++ b/dll/win32/shell32/she_ocmenu.c @@ -1185,7 +1185,7 @@ SHEOW_LoadOpenWithItems(SHEOWImpl *This, IDataObject *pdtobj) LPWSTR szPtr; static const WCHAR szShortCut[] = { '.','l','n','k', 0 }; - fmt.cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); fmt.ptd = NULL; fmt.dwAspect = DVASPECT_CONTENT; fmt.lindex = -1; diff --git a/dll/win32/shell32/shelllink.c b/dll/win32/shell32/shelllink.c index 5e05bc59a94..2d9ef1c20ee 100644 --- a/dll/win32/shell32/shelllink.c +++ b/dll/win32/shell32/shelllink.c @@ -734,30 +734,30 @@ static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str ) TRACE("%p\n",stm); - r = IStream_Read( stm, &buffer.cbSize, sizeof (DWORD), &count ); + r = IStream_Read( stm, &buffer.dbh.cbSize, sizeof (DWORD), &count ); if( FAILED( r ) ) return r; /* make sure that we read the size of the structure even on error */ size = sizeof buffer - sizeof (DWORD); - if( buffer.cbSize != sizeof buffer ) + if( buffer.dbh.cbSize != sizeof buffer ) { ERR("Ooops. This structure is not as expected...\n"); return E_FAIL; } - r = IStream_Read( stm, &buffer.dwSignature, size, &count ); + r = IStream_Read( stm, &buffer.dbh.dwSignature, size, &count ); if( FAILED( r ) ) return r; if( count != size ) return E_FAIL; - TRACE("magic %08x string = %s\n", buffer.dwSignature, debugstr_w(buffer.szwDarwinID)); + TRACE("magic %08x string = %s\n", buffer.dbh.dwSignature, debugstr_w(buffer.szwDarwinID)); - if( (buffer.dwSignature&0xffff0000) != 0xa0000000 ) + if( (buffer.dbh.dwSignature&0xffff0000) != 0xa0000000 ) { - ERR("Unknown magic number %08x in advertised shortcut\n", buffer.dwSignature); + ERR("Unknown magic number %08x in advertised shortcut\n", buffer.dbh.dwSignature); return E_FAIL; } @@ -1031,8 +1031,8 @@ static EXP_DARWIN_LINK* shelllink_build_darwinid( LPCWSTR string, DWORD magic ) EXP_DARWIN_LINK *buffer; buffer = LocalAlloc( LMEM_ZEROINIT, sizeof *buffer ); - buffer->cbSize = sizeof *buffer; - buffer->dwSignature = magic; + buffer->dbh.cbSize = sizeof *buffer; + buffer->dbh.dwSignature = magic; lstrcpynW( buffer->szwDarwinID, string, MAX_PATH ); WideCharToMultiByte(CP_ACP, 0, string, -1, buffer->szDarwinID, MAX_PATH, NULL, NULL ); @@ -1048,7 +1048,7 @@ static HRESULT Stream_WriteAdvertiseInfo( IStream* stm, LPCWSTR string, DWORD ma buffer = shelllink_build_darwinid( string, magic ); - return IStream_Write( stm, buffer, buffer->cbSize, &count ); + return IStream_Write( stm, buffer, buffer->dbh.cbSize, &count ); } /************************************************************************ diff --git a/dll/win32/shell32/shfldr_fs.c b/dll/win32/shell32/shfldr_fs.c index 381293d6cbf..6a0c9537f2f 100644 --- a/dll/win32/shell32/shfldr_fs.c +++ b/dll/win32/shell32/shfldr_fs.c @@ -97,7 +97,7 @@ static void SF_RegisterClipFmt (IGenericSFImpl * This) TRACE ("(%p)\n", This); if (!This->cfShellIDList) { - This->cfShellIDList = RegisterClipboardFormatA (CFSTR_SHELLIDLIST); + This->cfShellIDList = RegisterClipboardFormatW (CFSTR_SHELLIDLIST); } } @@ -1578,7 +1578,7 @@ IFSFldr_PersistFolder3_GetFolderTargetInfo (IPersistFolder3 * iface, { IGenericSFImpl *This = impl_from_IPersistFolder3(iface); FIXME ("(%p)->(%p)\n", This, ppfti); - ZeroMemory (ppfti, sizeof (ppfti)); + ZeroMemory (ppfti, sizeof (*ppfti)); return E_NOTIMPL; } diff --git a/dll/win32/shell32/shlfolder.c b/dll/win32/shell32/shlfolder.c index a08b755deb6..f9d5c1eea5e 100644 --- a/dll/win32/shell32/shlfolder.c +++ b/dll/win32/shell32/shlfolder.c @@ -554,7 +554,7 @@ HRESULT WINAPI SHCreateLinks( HWND hWnd, LPCSTR lpszDir, LPDATAOBJECT lpDataObje */ HRESULT WINAPI -SHOpenFolderAndSelectItems(PCIDLIST_ABSOLUTE pidlFolder, +SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY *apidl, DWORD dwFlags) diff --git a/dll/win32/shell32/shlview.c b/dll/win32/shell32/shlview.c index 696cd11e46b..ef7f587f7c1 100644 --- a/dll/win32/shell32/shlview.c +++ b/dll/win32/shell32/shlview.c @@ -914,7 +914,7 @@ static HRESULT ShellView_OpenSelectedItems(IShellViewImpl * This) if (0 == CF_IDLIST) { - CF_IDLIST = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + CF_IDLIST = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); } fetc.cfFormat = CF_IDLIST; fetc.ptd = NULL; diff --git a/dll/win32/shell32/shv_def_cmenu.c b/dll/win32/shell32/shv_def_cmenu.c index 3df3dd21e74..71c25a7d407 100644 --- a/dll/win32/shell32/shv_def_cmenu.c +++ b/dll/win32/shell32/shv_def_cmenu.c @@ -294,7 +294,7 @@ HasClipboardData() TRACE("pda=%p\n", pda); /* Set the FORMATETC structure*/ - InitFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); + InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); if(SUCCEEDED(IDataObject_GetData(pda,&formatetc,&medium))) { ret = TRUE; @@ -1018,7 +1018,7 @@ DoPaste( if (OleGetClipboard(&pda) != S_OK) return E_FAIL; - InitFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); + InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); hr = IDataObject_GetData(pda,&formatetc,&medium); if (FAILED(hr)) diff --git a/dll/win32/shell32/stubs.c b/dll/win32/shell32/stubs.c index 1ead574e1f4..b3192ea2c25 100644 --- a/dll/win32/shell32/stubs.c +++ b/dll/win32/shell32/stubs.c @@ -381,7 +381,7 @@ CDefFolderMenu_MergeMenu(HINSTANCE hInstance, */ HRESULT WINAPI -CDefFolderMenu_Create(PCIDLIST_ABSOLUTE pidlFolder, +CDefFolderMenu_Create(LPITEMIDLIST pidlFolder, HWND hwnd, UINT uidl, PCUITEMID_CHILD_ARRAY *apidl, diff --git a/dll/win32/shlwapi/msgbox.c b/dll/win32/shlwapi/msgbox.c index 0936e0becf1..506bd4651b7 100644 --- a/dll/win32/shlwapi/msgbox.c +++ b/dll/win32/shlwapi/msgbox.c @@ -147,10 +147,10 @@ INT_PTR WINAPI SHMessageBoxCheckExA(HWND hWnd, HINSTANCE hInst, LPCSTR lpszName, WCHAR szNameBuff[MAX_PATH], szIdBuff[MAX_PATH]; LPCWSTR szName = szNameBuff; - if (HIWORD(lpszName)) - MultiByteToWideChar(CP_ACP, 0, lpszName, -1, szNameBuff, MAX_PATH); - else + if (IS_INTRESOURCE(lpszName)) szName = (LPCWSTR)lpszName; /* Resource Id or NULL */ + else + MultiByteToWideChar(CP_ACP, 0, lpszName, -1, szNameBuff, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, lpszId, -1, szIdBuff, MAX_PATH); diff --git a/dll/win32/shlwapi/ordinal.c b/dll/win32/shlwapi/ordinal.c index 0ecbab81ed5..375ddaf7ad2 100644 --- a/dll/win32/shlwapi/ordinal.c +++ b/dll/win32/shlwapi/ordinal.c @@ -46,6 +46,7 @@ #include "shlwapi.h" #include "shellapi.h" #include "commdlg.h" +#include "mlang.h" #include "mshtmhst.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -450,14 +451,14 @@ RegisterDefaultAcceptHeaders_Exit: * * PARAMS * langbuf [O] Destination for language string - * buflen [I] Length of langbuf + * buflen [I] Length of langbuf in characters * [0] Success: used length of langbuf * * RETURNS * Success: S_OK. langbuf is set to the language string found. * Failure: E_FAIL, If any arguments are invalid, error occurred, or Explorer * does not contain the setting. - * E_INVALIDARG, If the buffer is not big enough + * HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), If the buffer is not big enough */ HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen) { @@ -468,49 +469,50 @@ HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen) 'I','n','t','e','r','n','a','t','i','o','n','a','l',0}; static const WCHAR valueW[] = { 'A','c','c','e','p','t','L','a','n','g','u','a','g','e',0}; - static const WCHAR enusW[] = {'e','n','-','u','s',0}; DWORD mystrlen, mytype; + DWORD len; HKEY mykey; HRESULT retval; LCID mylcid; WCHAR *mystr; + LONG lres; + + TRACE("(%p, %p) *%p: %d\n", langbuf, buflen, buflen, buflen ? *buflen : -1); if(!langbuf || !buflen || !*buflen) return E_FAIL; mystrlen = (*buflen > 20) ? *buflen : 20 ; - mystr = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * mystrlen); + len = mystrlen * sizeof(WCHAR); + mystr = HeapAlloc(GetProcessHeap(), 0, len); + mystr[0] = 0; RegOpenKeyW(HKEY_CURRENT_USER, szkeyW, &mykey); - if(RegQueryValueExW(mykey, valueW, 0, &mytype, (PBYTE)mystr, &mystrlen)) { - /* Did not find value */ - mylcid = GetUserDefaultLCID(); - /* somehow the mylcid translates into "en-us" - * this is similar to "LOCALE_SABBREVLANGNAME" - * which could be gotten via GetLocaleInfo. - * The only problem is LOCALE_SABBREVLANGUAGE" is - * a 3 char string (first 2 are country code and third is - * letter for "sublanguage", which does not come close to - * "en-us" - */ - lstrcpyW(mystr, enusW); - mystrlen = lstrlenW(mystr); - } else { - /* handle returned string */ - FIXME("missing code\n"); - } - memcpy( langbuf, mystr, min(*buflen,strlenW(mystr)+1)*sizeof(WCHAR) ); - - if(*buflen > strlenW(mystr)) { - *buflen = strlenW(mystr); - retval = S_OK; - } else { - *buflen = 0; - retval = E_INVALIDARG; - SetLastError(ERROR_INSUFFICIENT_BUFFER); - } + lres = RegQueryValueExW(mykey, valueW, 0, &mytype, (PBYTE)mystr, &len); RegCloseKey(mykey); + len = lstrlenW(mystr); + + if (!lres && (*buflen > len)) { + lstrcpyW(langbuf, mystr); + *buflen = len; + HeapFree(GetProcessHeap(), 0, mystr); + return S_OK; + } + + /* Did not find a value in the registry or the user buffer is to small */ + mylcid = GetUserDefaultLCID(); + retval = LcidToRfc1766W(mylcid, mystr, mystrlen); + len = lstrlenW(mystr); + + memcpy( langbuf, mystr, min(*buflen, len+1)*sizeof(WCHAR) ); HeapFree(GetProcessHeap(), 0, mystr); - return retval; + + if (*buflen > len) { + *buflen = len; + return S_OK; + } + + *buflen = 0; + return __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } /************************************************************************* @@ -524,6 +526,8 @@ HRESULT WINAPI GetAcceptLanguagesA( LPSTR langbuf, LPDWORD buflen) DWORD buflenW, convlen; HRESULT retval; + TRACE("(%p, %p) *%p: %d\n", langbuf, buflen, buflen, buflen ? *buflen : -1); + if(!langbuf || !buflen || !*buflen) return E_FAIL; buflenW = *buflen; @@ -533,11 +537,20 @@ HRESULT WINAPI GetAcceptLanguagesA( LPSTR langbuf, LPDWORD buflen) if (retval == S_OK) { convlen = WideCharToMultiByte(CP_ACP, 0, langbufW, -1, langbuf, *buflen, NULL, NULL); + convlen--; /* do not count the terminating 0 */ } else /* copy partial string anyway */ { convlen = WideCharToMultiByte(CP_ACP, 0, langbufW, *buflen, langbuf, *buflen, NULL, NULL); - if (convlen < *buflen) langbuf[convlen] = 0; + if (convlen < *buflen) + { + langbuf[convlen] = 0; + convlen--; /* do not count the terminating 0 */ + } + else + { + convlen = *buflen; + } } *buflen = buflenW ? convlen : 0; @@ -1069,23 +1082,25 @@ HRESULT WINAPI IUnknown_Exec(IUnknown* lpUnknown, REFGUID pguidCmdGroup, * PARAMS * hWnd [I] Window to get value from * offset [I] Offset of value - * wMask [I] Mask for uiFlags - * wFlags [I] Bits to set in window value + * mask [I] Mask for flags + * flags [I] Bits to set in window value * * RETURNS * The new value as it was set, or 0 if any parameter is invalid. * * NOTES - * Any bits set in uiMask are cleared from the value, then any bits set in - * uiFlags are set in the value. + * Only bits specified in mask are affected - set if present in flags and + * reset otherwise. */ -LONG WINAPI SHSetWindowBits(HWND hwnd, INT offset, UINT wMask, UINT wFlags) +LONG WINAPI SHSetWindowBits(HWND hwnd, INT offset, UINT mask, UINT flags) { - LONG ret = GetWindowLongA(hwnd, offset); - LONG newFlags = (wFlags & wMask) | (ret & ~wFlags); + LONG ret = GetWindowLongW(hwnd, offset); + LONG new_flags = (flags & mask) | (ret & ~mask); - if (newFlags != ret) - ret = SetWindowLongA(hwnd, offset, newFlags); + TRACE("%p %d %x %x\n", hwnd, offset, mask, flags); + + if (new_flags != ret) + ret = SetWindowLongW(hwnd, offset, new_flags); return ret; } @@ -1128,7 +1143,7 @@ HWND WINAPI SHSetParentHwnd(HWND hWnd, HWND hWndParent) * PARAMS * lpUnkSink [I] Sink for the connection point advise call * riid [I] REFIID of connection point to advise - * bAdviseOnly [I] TRUE = Advise only, FALSE = Unadvise first + * fConnect [I] TRUE = Connection being establisted, FALSE = broken * lpUnknown [I] Object supporting the IConnectionPointContainer interface * lpCookie [O] Pointer to connection point cookie * lppCP [O] Destination for the IConnectionPoint found @@ -1140,7 +1155,7 @@ HWND WINAPI SHSetParentHwnd(HWND hWnd, HWND hWndParent) * E_NOINTERFACE, if lpUnknown isn't an IConnectionPointContainer, * Or an HRESULT error code if any call fails. */ -HRESULT WINAPI ConnectToConnectionPoint(IUnknown* lpUnkSink, REFIID riid, BOOL bAdviseOnly, +HRESULT WINAPI ConnectToConnectionPoint(IUnknown* lpUnkSink, REFIID riid, BOOL fConnect, IUnknown* lpUnknown, LPDWORD lpCookie, IConnectionPoint **lppCP) { @@ -1148,7 +1163,7 @@ HRESULT WINAPI ConnectToConnectionPoint(IUnknown* lpUnkSink, REFIID riid, BOOL b IConnectionPointContainer* lpContainer; IConnectionPoint *lpCP; - if(!lpUnknown || (bAdviseOnly && !lpUnkSink)) + if(!lpUnknown || (fConnect && !lpUnkSink)) return E_FAIL; if(lppCP) @@ -1162,9 +1177,10 @@ HRESULT WINAPI ConnectToConnectionPoint(IUnknown* lpUnkSink, REFIID riid, BOOL b if (SUCCEEDED(hRet)) { - if(!bAdviseOnly) + if(!fConnect) hRet = IConnectionPoint_Unadvise(lpCP, *lpCookie); - hRet = IConnectionPoint_Advise(lpCP, lpUnkSink, lpCookie); + else + hRet = IConnectionPoint_Advise(lpCP, lpUnkSink, lpCookie); if (FAILED(hRet)) *lpCookie = 0; @@ -2929,20 +2945,27 @@ static HRESULT SHLWAPI_InvokeByIID( { IEnumConnections *enumerator; CONNECTDATA rgcd; + static DISPPARAMS empty = {NULL, NULL, 0, 0}; + DISPPARAMS* params = dispParams; HRESULT result = IConnectionPoint_EnumConnections(iCP, &enumerator); if (FAILED(result)) return result; + /* Invoke is never happening with an NULL dispParams */ + if (!params) + params = ∅ + while(IEnumConnections_Next(enumerator, 1, &rgcd, NULL)==S_OK) { IDispatch *dispIface; - if (SUCCEEDED(IUnknown_QueryInterface(rgcd.pUnk, iid, (LPVOID*)&dispIface)) || + if ((iid && SUCCEEDED(IUnknown_QueryInterface(rgcd.pUnk, iid, (LPVOID*)&dispIface))) || SUCCEEDED(IUnknown_QueryInterface(rgcd.pUnk, &IID_IDispatch, (LPVOID*)&dispIface))) { - IDispatch_Invoke(dispIface, dispId, &IID_NULL, 0, DISPATCH_METHOD, dispParams, NULL, NULL, NULL); + IDispatch_Invoke(dispIface, dispId, &IID_NULL, 0, DISPATCH_METHOD, params, NULL, NULL, NULL); IDispatch_Release(dispIface); } + IUnknown_Release(rgcd.pUnk); } IEnumConnections_Release(enumerator); @@ -2965,6 +2988,8 @@ HRESULT WINAPI IConnectionPoint_InvokeWithCancel( IConnectionPoint* iCP, result = IConnectionPoint_GetConnectionInterface(iCP, &iid); if (SUCCEEDED(result)) result = SHLWAPI_InvokeByIID(iCP, &iid, dispId, dispParams); + else + result = SHLWAPI_InvokeByIID(iCP, NULL, dispId, dispParams); return result; } @@ -2988,6 +3013,8 @@ HRESULT WINAPI IConnectionPoint_SimpleInvoke( result = IConnectionPoint_GetConnectionInterface(iCP, &iid); if (SUCCEEDED(result)) result = SHLWAPI_InvokeByIID(iCP, &iid, dispId, dispParams); + else + result = SHLWAPI_InvokeByIID(iCP, NULL, dispId, dispParams); return result; } @@ -3901,6 +3928,8 @@ BOOL WINAPI IsOS(DWORD feature) case OS_APPLIANCE: FIXME("(OS_APPLIANCE) What should we return here?\n"); return FALSE; + case 0x25: /*OS_VISTAORGREATER*/ + ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && majorv >= 6) } #undef ISOS_RETURN @@ -4632,7 +4661,7 @@ HRESULT WINAPI SHGetViewStatePropertyBag(LPCITEMIDLIST pidl, LPWSTR bag_name, * fileTime [I] Pointer to FILETIME structure specifying the time * flags [I] Flags specifying the desired output * buf [O] Pointer to buffer for output - * bufSize [I] Number of characters that can be contained in buffer + * size [I] Number of characters that can be contained in buffer * * RETURNS * success: number of characters written to the buffer @@ -4640,10 +4669,65 @@ HRESULT WINAPI SHGetViewStatePropertyBag(LPCITEMIDLIST pidl, LPWSTR bag_name, * */ INT WINAPI SHFormatDateTimeW(const FILETIME UNALIGNED *fileTime, DWORD *flags, - LPWSTR buf, UINT bufSize) + LPWSTR buf, UINT size) { - FIXME("%p %p %s %d STUB\n", fileTime, flags, debugstr_w(buf), bufSize); - return 0; +#define SHFORMATDT_UNSUPPORTED_FLAGS (FDTF_RELATIVE | FDTF_LTRDATE | FDTF_RTLDATE | FDTF_NOAUTOREADINGORDER) + DWORD fmt_flags = flags ? *flags : FDTF_DEFAULT; + SYSTEMTIME st; + FILETIME ft; + INT ret = 0; + + TRACE("%p %p %p %u\n", fileTime, flags, buf, size); + + if (!buf || !size) + return 0; + + if (fmt_flags & SHFORMATDT_UNSUPPORTED_FLAGS) + FIXME("ignoring some flags - 0x%08x\n", fmt_flags & SHFORMATDT_UNSUPPORTED_FLAGS); + + FileTimeToLocalFileTime(fileTime, &ft); + FileTimeToSystemTime(&ft, &st); + + /* first of all date */ + if (fmt_flags & (FDTF_LONGDATE | FDTF_SHORTDATE)) + { + static const WCHAR sep1[] = {',',' ',0}; + static const WCHAR sep2[] = {' ',0}; + + DWORD date = fmt_flags & FDTF_LONGDATE ? DATE_LONGDATE : DATE_SHORTDATE; + ret = GetDateFormatW(LOCALE_USER_DEFAULT, date, &st, NULL, buf, size); + if (ret >= size) return ret; + + /* add separator */ + if (ret < size && (fmt_flags & (FDTF_LONGTIME | FDTF_SHORTTIME))) + { + if ((fmt_flags & FDTF_LONGDATE) && (ret < size + 2)) + { + if (ret < size + 2) + { + lstrcatW(&buf[ret-1], sep1); + ret += 2; + } + } + else + { + lstrcatW(&buf[ret-1], sep2); + ret++; + } + } + } + /* time part */ + if (fmt_flags & (FDTF_LONGTIME | FDTF_SHORTTIME)) + { + DWORD time = fmt_flags & FDTF_LONGTIME ? 0 : TIME_NOSECONDS; + + if (ret) ret--; + ret += GetTimeFormatW(LOCALE_USER_DEFAULT, time, &st, NULL, &buf[ret], size - ret); + } + + return ret; + +#undef SHFORMATDT_UNSUPPORTED_FLAGS } /*********************************************************************** @@ -4653,21 +4737,19 @@ INT WINAPI SHFormatDateTimeW(const FILETIME UNALIGNED *fileTime, DWORD *flags, * */ INT WINAPI SHFormatDateTimeA(const FILETIME UNALIGNED *fileTime, DWORD *flags, - LPCSTR buf, UINT bufSize) + LPSTR buf, UINT size) { WCHAR *bufW; - DWORD buflenW, convlen; INT retval; - if (!buf || !bufSize) + if (!buf || !size) return 0; - buflenW = bufSize; - bufW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * buflenW); - retval = SHFormatDateTimeW(fileTime, flags, bufW, buflenW); + bufW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * size); + retval = SHFormatDateTimeW(fileTime, flags, bufW, size); if (retval != 0) - convlen = WideCharToMultiByte(CP_ACP, 0, bufW, -1, (LPSTR) buf, bufSize, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, size, NULL, NULL); HeapFree(GetProcessHeap(), 0, bufW); return retval; @@ -4697,3 +4779,78 @@ INT WINAPI ZoneCheckUrlExW(LPWSTR szURL, PVOID pUnknown, DWORD dwUnknown2, return 0; } + +/*********************************************************************** + * SHVerbExistsNA [SHLWAPI.196] + * + * + * PARAMS + * + * verb [I] a string, often appears to be an extension. + * + * Other parameters currently unknown. + * + * RETURNS + * unknown + */ +INT WINAPI SHVerbExistsNA(LPSTR verb, PVOID pUnknown, PVOID pUnknown2, DWORD dwUnknown3) +{ + FIXME("(%s, %p, %p, %i) STUB\n",verb, pUnknown, pUnknown2, dwUnknown3); + return 0; +} + +/************************************************************************* + * @ [SHLWAPI.538] + * + * Undocumented: Implementation guessed at via Name and behavior + * + * PARAMS + * lpUnknown [I] Object to get an IServiceProvider interface from + * riid [I] Function requested for QueryService call + * lppOut [O] Destination for the service interface pointer + * + * RETURNS + * Success: S_OK. lppOut contains an object providing the requested service + * Failure: An HRESULT error code + * + * NOTES + * lpUnknown is expected to support the IServiceProvider interface. + */ +HRESULT WINAPI IUnknown_QueryServiceForWebBrowserApp(IUnknown* lpUnknown, + REFGUID riid, LPVOID *lppOut) +{ + FIXME("%p %s %p semi-STUB\n", lpUnknown, debugstr_guid(riid), lppOut); + return IUnknown_QueryService(lpUnknown,&IID_IWebBrowserApp,riid,lppOut); +} + +/************************************************************************** + * SHPropertyBag_ReadLONG (SHLWAPI.496) + * + * This function asks a property bag to read a named property as a LONG. + * + * PARAMS + * ppb: a IPropertyBag interface + * pszPropName: Unicode string that names the property + * pValue: address to receive the property value as a 32-bit signed integer + * + * RETURNS + * 0 for Success + */ +BOOL WINAPI SHPropertyBag_ReadLONG(IPropertyBag *ppb, LPCWSTR pszPropName, LPLONG pValue) +{ + VARIANT var; + HRESULT hr; + TRACE("%p %s %p\n", ppb,debugstr_w(pszPropName),pValue); + if (!pszPropName || !ppb || !pValue) + return E_INVALIDARG; + V_VT(&var) = VT_I4; + hr = IPropertyBag_Read(ppb, pszPropName, &var, NULL); + if (SUCCEEDED(hr)) + { + if (V_VT(&var) == VT_I4) + *pValue = V_I4(&var); + else + hr = DISP_E_BADVARTYPE; + } + return hr; +} diff --git a/dll/win32/shlwapi/reg.c b/dll/win32/shlwapi/reg.c index 9f652c9df92..d641955ba05 100644 --- a/dll/win32/shlwapi/reg.c +++ b/dll/win32/shlwapi/reg.c @@ -1137,68 +1137,6 @@ DWORD WINAPI SHGetValueA(HKEY hKey, LPCSTR lpszSubKey, LPCSTR lpszValue, return dwRet; } -/************************************************************************* - * SHRegGetValueA [SHLWAPI.@] - * - * Get a value from the registry. - * - * PARAMS - * hKey [I] Handle to registry key - * lpszSubKey [I] Name of sub key containing value to get - * lpszValue [I] Name of value to get - * srrf [I] Flags for restricting returned data - * pwType [O] Pointer to the values type - * pvData [O] Pointer to the values data - * pcbData [O] Pointer to the values size - * - * RETURNS - * Success: ERROR_SUCCESS. Output parameters contain the details read. - * Failure: An error code from RegOpenKeyExA() or SHQueryValueExA(). - */ -DWORD WINAPI SHRegGetValueA(HKEY hKey, LPCSTR lpszSubKey, LPCSTR lpszValue, DWORD srrfFlags, - LPDWORD pwType, LPVOID pvData, LPDWORD pcbData) -{ - DWORD dwRet = 0; - HKEY hSubKey = 0; - - TRACE("(hkey=%p,%s,%s,%p,%p,%p)\n", hKey, debugstr_a(lpszSubKey), - debugstr_a(lpszValue), pwType, pvData, pcbData); - FIXME("Semi-Stub: Find meaning and implement handling of SRFF Flags 0x%08x\n", srrfFlags); - - dwRet = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_QUERY_VALUE, &hSubKey); - if (! dwRet) - { - /* SHQueryValueEx expands Environment strings */ - dwRet = SHQueryValueExA(hSubKey, lpszValue, 0, pwType, pvData, pcbData); - RegCloseKey(hSubKey); - } - return dwRet; -} - -/************************************************************************* - * SHReg GetRegValueW [SHLWAPI.@] - * - * See SHGetValueA. - */ -DWORD WINAPI SHRegGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD srrfFlags, - LPDWORD pwType, LPVOID pvData, LPDWORD pcbData) -{ - DWORD dwRet = 0; - HKEY hSubKey = 0; - - TRACE("(hkey=%p,%s,%s,0x%08x, %p,%p,%p)\n", hKey, debugstr_w(lpszSubKey), - debugstr_w(lpszValue), srrfFlags,pwType, pvData, pcbData); - FIXME("Semi-Stub: Find meaning and implement handling of SRFF Flags 0x%08x\n", srrfFlags); - - dwRet = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_QUERY_VALUE, &hSubKey); - if (! dwRet) - { - dwRet = SHQueryValueExW(hSubKey, lpszValue, 0, pwType, pvData, pcbData); - RegCloseKey(hSubKey); - } - return dwRet; -} - /************************************************************************* * SHGetValueW [SHLWAPI.@] * diff --git a/dll/win32/shlwapi/shlwapi.rc b/dll/win32/shlwapi/shlwapi.rc index f9e68738d4c..52b88cfa6d6 100644 --- a/dll/win32/shlwapi/shlwapi.rc +++ b/dll/win32/shlwapi/shlwapi.rc @@ -26,26 +26,29 @@ #include "version.rc" #include "shlwapi_Da.rc" -#include "shlwapi_De.rc" #include "shlwapi_En.rc" #include "shlwapi_Eo.rc" #include "shlwapi_Es.rc" #include "shlwapi_Fi.rc" -#include "shlwapi_Fr.rc" #include "shlwapi_Hu.rc" #include "shlwapi_It.rc" -#include "shlwapi_Ja.rc" #include "shlwapi_Ko.rc" -#include "shlwapi_Lt.rc" #include "shlwapi_Nl.rc" -#include "shlwapi_No.rc" #include "shlwapi_Pl.rc" #include "shlwapi_Pt.rc" -#include "shlwapi_Ro.rc" -#include "shlwapi_Ru.rc" -#include "shlwapi_Si.rc" #include "shlwapi_Sk.rc" #include "shlwapi_Sv.rc" #include "shlwapi_Tr.rc" #include "shlwapi_Uk.rc" #include "shlwapi_Zh.rc" + +/* UTF-8 */ + +#include "shlwapi_De.rc" +#include "shlwapi_Fr.rc" +#include "shlwapi_Ja.rc" +#include "shlwapi_Lt.rc" +#include "shlwapi_No.rc" +#include "shlwapi_Ro.rc" +#include "shlwapi_Ru.rc" +#include "shlwapi_Si.rc" diff --git a/dll/win32/shlwapi/shlwapi.spec b/dll/win32/shlwapi/shlwapi.spec index a8e7428c6f3..3091783f580 100644 --- a/dll/win32/shlwapi/shlwapi.spec +++ b/dll/win32/shlwapi/shlwapi.spec @@ -193,7 +193,7 @@ 193 stdcall -noname SHGetCurColorRes() 194 stdcall -noname SHWaitForSendMessageThread(ptr long) 195 stdcall -noname SHIsExpandableFolder(ptr ptr) -196 stdcall -noname DnsRecordSetCompare(ptr ptr ptr ptr) dnsapi.DnsRecordSetCompare +196 stdcall -noname SHVerbExistsNA(str ptr ptr long) 197 stdcall -noname SHFillRectClr(long ptr long) 198 stdcall -noname SHSearchMapInt(ptr ptr long long) 199 stdcall -noname IUnknown_Set(ptr ptr) @@ -460,8 +460,8 @@ 460 stdcall -noname SHExpandEnvironmentStringsW(wstr ptr long) kernel32.ExpandEnvironmentStringsW 461 stdcall -noname SHGetAppCompatFlags(long) 462 stdcall -noname UrlFixupW(wstr wstr long) -463 stub -noname SHExpandEnvironmentStringsForUserA -464 stub -noname SHExpandEnvironmentStringsForUserW +463 stdcall -noname SHExpandEnvironmentStringsForUserA(ptr str ptr long) userenv.ExpandEnvironmentStringsForUserA +464 stdcall -noname SHExpandEnvironmentStringsForUserW(ptr wstr ptr long) userenv.ExpandEnvironmentStringsForUserW 465 stub -noname PathUnExpandEnvStringsForUserA 466 stub -noname PathUnExpandEnvStringsForUserW 467 stub -noname SHRunIndirectRegClientCommand @@ -493,7 +493,7 @@ 493 stub -noname SHPropertyBag_ReadType 494 stub -noname SHPropertyBag_ReadStr 495 stub -noname SHPropertyBag_WriteStr -496 stub -noname SHPropertyBag_ReadLONG +496 stdcall -noname SHPropertyBag_ReadLONG(ptr wstr ptr) 497 stub -noname SHPropertyBag_WriteLONG 498 stub -noname SHPropertyBag_ReadBOOLOld 499 stub -noname SHPropertyBag_WriteBOOL @@ -531,7 +531,7 @@ 535 stub -noname SHPropertyBag_Delete 536 stub -noname IUnknown_QueryServicePropertyBag 537 stub -noname SHBoolSystemParametersInfo -538 stub -noname IUnknown_QueryServiceForWebBrowserApp +538 stdcall -noname IUnknown_QueryServiceForWebBrowserApp(ptr ptr ptr) 539 stub -noname IUnknown_ShowBrowserBar 540 stub -noname SHInvokeCommandOnContextMenu 541 stub -noname SHInvokeCommandsOnContextMen @@ -725,8 +725,8 @@ @ stdcall SHRegGetPathW(long wstr wstr ptr long) @ stdcall SHRegGetUSValueA ( str str ptr ptr ptr long ptr long ) @ stdcall SHRegGetUSValueW ( wstr wstr ptr ptr ptr long ptr long ) -@ stdcall SHRegGetValueA ( long str str long ptr ptr ptr ) -@ stdcall SHRegGetValueW ( long wstr wstr long ptr ptr ptr ) +@ stdcall SHRegGetValueA ( long str str long ptr ptr ptr ) advapi32.RegGetValueA +@ stdcall SHRegGetValueW ( long wstr wstr long ptr ptr ptr ) advapi32.RegGetValueW @ stdcall SHRegOpenUSKeyA ( str long long long long ) @ stdcall SHRegOpenUSKeyW ( wstr long long long long ) @ stdcall SHRegQueryInfoUSKeyA ( long ptr ptr ptr ptr long ) diff --git a/dll/win32/shlwapi/shlwapi_De.rc b/dll/win32/shlwapi/shlwapi_De.rc index f33681e1136..8980769933f 100644 --- a/dll/win32/shlwapi/shlwapi_De.rc +++ b/dll/win32/shlwapi/shlwapi_De.rc @@ -45,4 +45,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " Min" IDS_TIME_INTERVAL_SECONDS " Sek" } -#pragma code_page(default) diff --git a/dll/win32/shlwapi/shlwapi_Fr.rc b/dll/win32/shlwapi/shlwapi_Fr.rc index d32b9a898b7..745b4fd0ee0 100644 --- a/dll/win32/shlwapi/shlwapi_Fr.rc +++ b/dll/win32/shlwapi/shlwapi_Fr.rc @@ -46,4 +46,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " min" IDS_TIME_INTERVAL_SECONDS " sec" } -#pragma code_page(default) diff --git a/dll/win32/shlwapi/shlwapi_Ja.rc b/dll/win32/shlwapi/shlwapi_Ja.rc index 2c79e3215ab..4b9c6ae5255 100644 --- a/dll/win32/shlwapi/shlwapi_Ja.rc +++ b/dll/win32/shlwapi/shlwapi_Ja.rc @@ -46,4 +46,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " min" IDS_TIME_INTERVAL_SECONDS " sec" } -#pragma code_page(default) diff --git a/dll/win32/shlwapi/shlwapi_No.rc b/dll/win32/shlwapi/shlwapi_No.rc index b48106a9a51..9a99ac3feea 100644 --- a/dll/win32/shlwapi/shlwapi_No.rc +++ b/dll/win32/shlwapi/shlwapi_No.rc @@ -43,4 +43,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " min" IDS_TIME_INTERVAL_SECONDS " sec" } -#pragma code_page(default) diff --git a/dll/win32/shlwapi/shlwapi_Si.rc b/dll/win32/shlwapi/shlwapi_Si.rc index d6394dd1562..820b6ce5ed1 100644 --- a/dll/win32/shlwapi/shlwapi_Si.rc +++ b/dll/win32/shlwapi/shlwapi_Si.rc @@ -45,4 +45,3 @@ STRINGTABLE DISCARDABLE IDS_TIME_INTERVAL_MINUTES " min" IDS_TIME_INTERVAL_SECONDS " sek" } -#pragma code_page(default) diff --git a/dll/win32/shlwapi/url.c b/dll/win32/shlwapi/url.c index 2b7a8cd1686..2fdae3de523 100644 --- a/dll/win32/shlwapi/url.c +++ b/dll/win32/shlwapi/url.c @@ -33,6 +33,7 @@ #include "winternl.h" #define NO_SHLWAPI_STREAM #include "shlwapi.h" +#include "intshcut.h" #include "wine/debug.h" HMODULE WINAPI MLLoadLibraryW(LPCWSTR,HMODULE,DWORD); @@ -157,8 +158,8 @@ HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y) ptr++; if (*ptr != ':' || ptr <= x+1) { - y->pszProtocol = NULL; - return 0x80041001; + y->pszProtocol = NULL; + return URL_E_INVALID_SYNTAX; } y->pszProtocol = x; @@ -191,8 +192,8 @@ HRESULT WINAPI ParseURLW(LPCWSTR x, PARSEDURLW *y) ptr++; if (*ptr != ':' || ptr <= x+1) { - y->pszProtocol = NULL; - return 0x80041001; + y->pszProtocol = NULL; + return URL_E_INVALID_SYNTAX; } y->pszProtocol = x; @@ -283,6 +284,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, WCHAR slash = '/'; static const WCHAR wszFile[] = {'f','i','l','e',':'}; + static const WCHAR wszRes[] = {'r','e','s',':'}; static const WCHAR wszLocalhost[] = {'l','o','c','a','l','h','o','s','t'}; TRACE("(%s, %p, %p, 0x%08x) *pcchCanonicalized: %d\n", debugstr_w(pszUrl), pszCanonicalized, @@ -304,6 +306,11 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, && !memcmp(wszFile, pszUrl, sizeof(wszFile))) slash = '\\'; + if(nByteLen >= sizeof(wszRes) && !memcmp(wszRes, pszUrl, sizeof(wszRes))) { + dwFlags &= ~URL_FILE_USE_PATHURL; + slash = '\0'; + } + /* * state = * 0 initial 1,3 @@ -368,10 +375,12 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, wk1 += nWkLen; wk2 += nWkLen; - while(mp < wk2) { - if(*mp == '/' || *mp == '\\') - *mp = slash; - mp++; + if(slash) { + while(mp < wk2) { + if(*mp == '/' || *mp == '\\') + *mp = slash; + mp++; + } } break; case 4: @@ -380,13 +389,20 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, while(isalnumW(*wk1) || (*wk1 == '-') || (*wk1 == '.') || (*wk1 == ':')) *wk2++ = *wk1++; state = 5; - if (!*wk1) - *wk2++ = slash; + if (!*wk1) { + if(slash) + *wk2++ = slash; + else + *wk2++ = '/'; + } break; case 5: if (*wk1 != '/' && *wk1 != '\\') {state = 3; break;} while(*wk1 == '/' || *wk1 == '\\') { - *wk2++ = slash; + if(slash) + *wk2++ = slash; + else + *wk2++ = *wk1; wk1++; } state = 6; @@ -419,7 +435,10 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, wk2 += nLen; wk1 += nLen; } - *wk2++ = slash; + if(slash) + *wk2++ = slash; + else + *wk2++ = *wk1; wk1++; if (*wk1 == '.') { @@ -436,7 +455,10 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, /* case /../ -> need to backup wk2 */ TRACE("found '/../'\n"); *(wk2-1) = '\0'; /* set end of string */ - mp = strrchrW(root, slash); + mp = strrchrW(root, '/'); + mp2 = strrchrW(root, '\\'); + if(mp2 && (!mp || mp2 < mp)) + mp = mp2; if (mp && (mp >= root)) { /* found valid backup point */ wk2 = mp + 1; @@ -608,6 +630,8 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, process_case = 1; } else do { + BOOL manual_search = FALSE; + /* mk is a special case */ if(base.nScheme == URL_SCHEME_MK) { static const WCHAR wsz[] = {':',':',0}; @@ -637,13 +661,45 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, } } - /* Change .sizep2 to not have the last leaf in it, - * Note: we need to start after the location (if it exists) - */ - work = strrchrW((base.pszSuffix+sizeloc), '/'); - if (work) { - len = (DWORD)(work - base.pszSuffix + 1); - base.cchSuffix = len; + /* If there is a '#' and the characters immediately preceeding it are + * ".htm[l]", then begin looking for the last leaf starting from + * the '#'. Otherwise the '#' is not meaningful and just start + * looking from the end. */ + if ((work = strchrW(base.pszSuffix + sizeloc, '#'))) { + const WCHAR htmlW[] = {'.','h','t','m','l',0}; + const int len_htmlW = 5; + const WCHAR htmW[] = {'.','h','t','m',0}; + const int len_htmW = 4; + + if (work - base.pszSuffix > len_htmW * sizeof(WCHAR)) { + work -= len_htmW; + if (strncmpiW(work, htmW, len_htmW) == 0) + manual_search = TRUE; + work += len_htmW; + } + + if (!manual_search && + work - base.pszSuffix > len_htmlW * sizeof(WCHAR)) { + work -= len_htmlW; + if (strncmpiW(work, htmlW, len_htmlW) == 0) + manual_search = TRUE; + work += len_htmlW; + } + } + + if (manual_search) { + /* search backwards starting from the current position */ + while (*work != '/' && work > base.pszSuffix + sizeloc) + --work; + if (work > base.pszSuffix + sizeloc) + base.cchSuffix = work - base.pszSuffix + 1; + }else { + /* search backwards starting from the end of the string */ + work = strrchrW((base.pszSuffix+sizeloc), '/'); + if (work) { + len = (DWORD)(work - base.pszSuffix + 1); + base.cchSuffix = len; + } } /* @@ -1379,8 +1435,7 @@ HRESULT WINAPI HashData(const unsigned char *lpSrc, DWORD nSrcLen, { INT srcCount = nSrcLen - 1, destCount = nDestLen - 1; - if (IsBadReadPtr(lpSrc, nSrcLen) || - IsBadWritePtr(lpDest, nDestLen)) + if (!lpSrc || !lpDest) return E_INVALIDARG; while (destCount >= 0) @@ -1856,7 +1911,8 @@ static LPCWSTR URL_ScanID(LPCWSTR start, LPDWORD size, WINE_URL_SCAN_TYPE type) (*start == '_') || (*start == '+') || (*start == '-') || - (*start == '.')) { + (*start == '.') || + (*start == ' ')) { start++; (*size)++; } else if (*start == '%') { @@ -1886,7 +1942,8 @@ static LPCWSTR URL_ScanID(LPCWSTR start, LPDWORD size, WINE_URL_SCAN_TYPE type) while (cont) { if (isalnumW(*start) || (*start == '-') || - (*start == '.') ) { + (*start == '.') || + (*start == ' ') ) { start++; (*size)++; } @@ -1915,7 +1972,7 @@ static LONG URL_ParseUrl(LPCWSTR pszUrl, WINE_PARSE_URL *pl) work = URL_ScanID(pl->pScheme, &pl->szScheme, SCHEME); if (!*work || (*work != ':')) goto ErrorExit; work++; - if ((*work != '/') || (*(work+1) != '/')) goto ErrorExit; + if ((*work != '/') || (*(work+1) != '/')) goto SuccessExit; pl->pUserName = work + 2; work = URL_ScanID(pl->pUserName, &pl->szUserName, USERPASS); if (*work == ':' ) { @@ -1956,6 +2013,7 @@ static LONG URL_ParseUrl(LPCWSTR pszUrl, WINE_PARSE_URL *pl) pl->pQuery = strchrW(work, '?'); if (pl->pQuery) pl->szQuery = strlenW(pl->pQuery); } + SuccessExit: TRACE("parse successful: scheme=%p(%d), user=%p(%d), pass=%p(%d), host=%p(%d), port=%p(%d), query=%p(%d)\n", pl->pScheme, pl->szScheme, pl->pUserName, pl->szUserName, @@ -2002,7 +2060,7 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut, len = INTERNET_MAX_URL_LENGTH; ret = UrlGetPartW(in, out, &len, dwPart, dwFlags); - if (ret != S_OK) { + if (FAILED(ret)) { HeapFree(GetProcessHeap(), 0, in); return ret; } @@ -2013,10 +2071,10 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut, HeapFree(GetProcessHeap(), 0, in); return E_POINTER; } - WideCharToMultiByte(0, 0, out, len+1, pszOut, *pcchOut, 0, 0); - *pcchOut = len2; + len2 = WideCharToMultiByte(0, 0, out, len+1, pszOut, *pcchOut, 0, 0); + *pcchOut = len2-1; HeapFree(GetProcessHeap(), 0, in); - return S_OK; + return ret; } /************************************************************************* @@ -2029,12 +2087,18 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, { WINE_PARSE_URL pl; HRESULT ret; - DWORD size, schsize; + DWORD scheme, size, schsize; LPCWSTR addr, schaddr; TRACE("(%s %p %p(%d) %08x %08x)\n", debugstr_w(pszIn), pszOut, pcchOut, *pcchOut, dwPart, dwFlags); + addr = strchrW(pszIn, ':'); + if(!addr) + return E_FAIL; + + scheme = get_scheme_code(pszIn, addr-pszIn); + ret = URL_ParseUrl(pszIn, &pl); if (ret == S_OK) { schaddr = pl.pScheme; @@ -2048,6 +2112,26 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, break; case URL_PART_HOSTNAME: + switch(scheme) { + case URL_SCHEME_FTP: + case URL_SCHEME_HTTP: + case URL_SCHEME_GOPHER: + case URL_SCHEME_TELNET: + case URL_SCHEME_FILE: + case URL_SCHEME_HTTPS: + break; + default: + return E_FAIL; + } + + if(scheme==URL_SCHEME_FILE && (!pl.szHostName || + (pl.szHostName==1 && *(pl.pHostName+1)==':'))) { + if(pcchOut) + *pszOut = '\0'; + *pcchOut = 0; + return S_FALSE; + } + if (!pl.szHostName) return E_INVALIDARG; addr = pl.pHostName; size = pl.szHostName; @@ -2099,7 +2183,13 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, *pcchOut = size; } TRACE("len=%d %s\n", *pcchOut, debugstr_w(pszOut)); + }else if(dwPart==URL_PART_HOSTNAME && scheme==URL_SCHEME_FILE) { + if(*pcchOut) + *pszOut = '\0'; + *pcchOut = 0; + return S_FALSE; } + return ret; } @@ -2259,7 +2349,7 @@ HRESULT WINAPI UrlCreateFromPathW(LPCWSTR pszPath, LPWSTR pszUrl, LPDWORD pcchUr */ HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags) { - FIXME("SHAutoComplete stub\n"); + FIXME("stub\n"); return S_FALSE; } @@ -2350,7 +2440,7 @@ HRESULT WINAPI MLBuildResURLW(LPCWSTR lpszLibName, HMODULE hMod, DWORD dwFlags, dwResLen = strlenW(lpszRes) + 1; if (dwDestLen >= dwResLen + 1) { - lpszDest[szResLen + dwPathLen + dwResLen] = '/'; + lpszDest[szResLen + dwPathLen-1] = '/'; memcpy(lpszDest + szResLen + dwPathLen, lpszRes, dwResLen * sizeof(WCHAR)); hRet = S_OK; } @@ -2386,7 +2476,7 @@ HRESULT WINAPI UrlFixupW(LPCWSTR url, LPWSTR translatedUrl, DWORD maxChars) if (!url) return E_FAIL; - srcLen = lstrlenW(url); + srcLen = lstrlenW(url) + 1; /* For now just copy the URL directly */ lstrcpynW(translatedUrl, url, (maxChars < srcLen) ? maxChars : srcLen); diff --git a/dll/win32/tapi32/line.c b/dll/win32/tapi32/line.c index 214e504c084..6ccdf13eb0a 100644 --- a/dll/win32/tapi32/line.c +++ b/dll/win32/tapi32/line.c @@ -53,12 +53,21 @@ DWORD WINAPI lineAccept(HCALL hCall, LPCSTR lpsUserUserInfo, DWORD dwSize) } /*********************************************************************** - * lineAddProvider (TAPI32.@) + * lineAddProviderA (TAPI32.@) */ DWORD WINAPI lineAddProviderA(LPCSTR lpszProviderName, HWND hwndOwner, LPDWORD lpdwPermanentProviderID) { FIXME("(%s, %p, %p): stub.\n", lpszProviderName, hwndOwner, lpdwPermanentProviderID); - return 1; + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineAddProviderW (TAPI32.@) + */ +DWORD WINAPI lineAddProviderW(LPCWSTR lpszProviderName, HWND hwndOwner, LPDWORD lpdwPermanentProviderID) +{ + FIXME("(%s, %p, %p): stub.\n", wine_dbgstr_w(lpszProviderName), hwndOwner, lpdwPermanentProviderID); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** @@ -457,12 +466,25 @@ DWORD WINAPI lineGetCountryA(DWORD dwCountryID, DWORD dwAPIVersion, LPLINECOUNTR } /*********************************************************************** - * lineGetDevCaps (TAPI32.@) + * lineGetDevCapsW (TAPI32.@) */ -DWORD WINAPI lineGetDevCapsA(HLINEAPP hLineApp, DWORD dwDeviceID, DWORD dwAPIVersion, DWORD dwExtVersion, LPLINEDEVCAPS lpLineDevCaps) +DWORD WINAPI lineGetDevCapsW(HLINEAPP hLineApp, DWORD dwDeviceID, DWORD dwAPIVersion, + DWORD dwExtVersion, LPLINEDEVCAPS lpLineDevCaps) { - FIXME("(%p, %08x, %08x, %08x, %p): stub.\n", hLineApp, dwDeviceID, dwAPIVersion, dwExtVersion, lpLineDevCaps); - return 0; + FIXME("(%p, %08x, %08x, %08x, %p): stub.\n", hLineApp, dwDeviceID, dwAPIVersion, + dwExtVersion, lpLineDevCaps); + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineGetDevCapsA (TAPI32.@) + */ +DWORD WINAPI lineGetDevCapsA(HLINEAPP hLineApp, DWORD dwDeviceID, DWORD dwAPIVersion, + DWORD dwExtVersion, LPLINEDEVCAPS lpLineDevCaps) +{ + FIXME("(%p, %08x, %08x, %08x, %p): stub.\n", hLineApp, dwDeviceID, dwAPIVersion, + dwExtVersion, lpLineDevCaps); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** @@ -475,12 +497,26 @@ DWORD WINAPI lineGetDevConfigA(DWORD dwDeviceID, LPVARSTRING lpDeviceConfig, LPC } /*********************************************************************** - * lineGetID (TAPI32.@) + * lineGetIDW (TAPI32.@) */ -DWORD WINAPI lineGetIDA(HLINE hLine, DWORD dwAddressID, HCALL hCall, DWORD dwSelect, LPVARSTRING lpDeviceID, LPCSTR lpszDeviceClass) +DWORD WINAPI lineGetIDW(HLINE hLine, DWORD dwAddressID, HCALL hCall, DWORD dwSelect, + LPVARSTRING lpDeviceID, LPCWSTR lpszDeviceClass) { - FIXME("(%p, %08x, %p, %08x, %p, %s): stub.\n", hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass); - return 0; + FIXME("(%p, %08x, %p, %08x, %p, %s): stub.\n", hLine, dwAddressID, hCall, + dwSelect, lpDeviceID, + debugstr_w(lpszDeviceClass)); + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineGetIDA (TAPI32.@) + */ +DWORD WINAPI lineGetIDA(HLINE hLine, DWORD dwAddressID, HCALL hCall, DWORD dwSelect, + LPVARSTRING lpDeviceID, LPCSTR lpszDeviceClass) +{ + FIXME("(%p, %08x, %p, %08x, %p, %s): stub.\n", hLine, dwAddressID, hCall, + dwSelect, lpDeviceID, lpszDeviceClass); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** @@ -520,12 +556,21 @@ DWORD WINAPI lineGetNumRings(HLINE hLine, DWORD dwAddressID, LPDWORD lpdwNumRing } /*********************************************************************** - * lineGetProviderList (TAPI32.@) + * lineGetProviderListA (TAPI32.@) */ DWORD WINAPI lineGetProviderListA(DWORD dwAPIVersion, LPLINEPROVIDERLIST lpProviderList) { FIXME("(%08x, %p): stub.\n", dwAPIVersion, lpProviderList); - return 0; + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineGetProviderListW (TAPI32.@) + */ +DWORD WINAPI lineGetProviderListW(DWORD dwAPIVersion, LPLINEPROVIDERLIST lpProviderList) +{ + FIXME("(%08x, %p): stub.\n", dwAPIVersion, lpProviderList); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** @@ -974,12 +1019,25 @@ LONG WINAPI lineInitializeExA(LPHLINEAPP lphLineApp, HINSTANCE hInstance, LINECA } /*********************************************************************** - * lineMakeCall (TAPI32.@) + * lineMakeCallW (TAPI32.@) */ -DWORD WINAPI lineMakeCallA(HLINE hLine, LPHCALL lphCall, LPCSTR lpszDestAddress, DWORD dwCountryCode, LPLINECALLPARAMS lpCallParams) +DWORD WINAPI lineMakeCallW(HLINE hLine, LPHCALL lphCall, LPCWSTR lpszDestAddress, + DWORD dwCountryCode, LPLINECALLPARAMS lpCallParams) { - FIXME("(%p, %p, %s, %08x, %p): stub.\n", hLine, lphCall, lpszDestAddress, dwCountryCode, lpCallParams); - return 1; + FIXME("(%p, %p, %s, %08x, %p): stub.\n", hLine, lphCall, debugstr_w(lpszDestAddress), + dwCountryCode, lpCallParams); + return LINEERR_OPERATIONFAILED; +} + +/*********************************************************************** + * lineMakeCallA (TAPI32.@) + */ +DWORD WINAPI lineMakeCallA(HLINE hLine, LPHCALL lphCall, LPCSTR lpszDestAddress, + DWORD dwCountryCode, LPLINECALLPARAMS lpCallParams) +{ + FIXME("(%p, %p, %s, %08x, %p): stub.\n", hLine, lphCall, lpszDestAddress, + dwCountryCode, lpCallParams); + return LINEERR_OPERATIONFAILED; } /*********************************************************************** diff --git a/dll/win32/urlmon/binding.c b/dll/win32/urlmon/binding.c index 210e8e2ed43..dcf0207278c 100644 --- a/dll/win32/urlmon/binding.c +++ b/dll/win32/urlmon/binding.c @@ -98,6 +98,7 @@ struct Binding { LPWSTR mime; UINT clipboard_format; LPWSTR url; + LPWSTR redirect_url; IID iid; BOOL report_mime; DWORD state; @@ -829,6 +830,7 @@ static ULONG WINAPI Binding_Release(IBinding *iface) This->section.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->section); heap_free(This->mime); + heap_free(This->redirect_url); heap_free(This->url); heap_free(This); @@ -967,6 +969,11 @@ static HRESULT WINAPI InternetProtocolSink_ReportProgress(IInternetProtocolSink case BINDSTATUS_CONNECTING: on_progress(This, 0, 0, BINDSTATUS_CONNECTING, szStatusText); break; + case BINDSTATUS_REDIRECTING: + heap_free(This->redirect_url); + This->redirect_url = heap_strdupW(szStatusText); + on_progress(This, 0, 0, BINDSTATUS_REDIRECTING, szStatusText); + break; case BINDSTATUS_BEGINDOWNLOADDATA: fill_stgmed_buffer(This->stgmed_buf); break; @@ -1474,6 +1481,8 @@ static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, I if(binding_ctx) { set_binding_sink(binding->protocol, PROTSINK(binding)); + if(binding_ctx->redirect_url) + IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_REDIRECTING, binding_ctx->redirect_url); report_data(binding, 0, 0, 0); }else { hres = IInternetProtocol_Start(binding->protocol, url, PROTSINK(binding), diff --git a/dll/win32/urlmon/bindprot.c b/dll/win32/urlmon/bindprot.c index e4f203d28f5..07d6fc2f525 100644 --- a/dll/win32/urlmon/bindprot.c +++ b/dll/win32/urlmon/bindprot.c @@ -205,7 +205,7 @@ static void push_task(BindProtocol *This, task_header_t *task, task_proc_t proc) This->task_queue_tail = task; }else { This->task_queue_tail = This->task_queue_head = task; - do_post = TRUE; + do_post = !This->continue_call; } LeaveCriticalSection(&This->section); @@ -960,6 +960,7 @@ static void report_progress(BindProtocol *This, ULONG status_code, LPCWSTR statu switch(status_code) { case BINDSTATUS_FINDINGRESOURCE: case BINDSTATUS_CONNECTING: + case BINDSTATUS_REDIRECTING: case BINDSTATUS_BEGINDOWNLOADDATA: case BINDSTATUS_SENDINGREQUEST: case BINDSTATUS_CACHEFILENAMEAVAILABLE: diff --git a/dll/win32/urlmon/download.c b/dll/win32/urlmon/download.c index d81dffaedc4..ebcb9c932c7 100644 --- a/dll/win32/urlmon/download.c +++ b/dll/win32/urlmon/download.c @@ -140,6 +140,7 @@ static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG u debugstr_w(szStatusText)); switch(ulStatusCode) { + case BINDSTATUS_CONNECTING: case BINDSTATUS_BEGINDOWNLOADDATA: case BINDSTATUS_DOWNLOADINGDATA: case BINDSTATUS_ENDDOWNLOADDATA: @@ -153,8 +154,7 @@ static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG u This->cache_file = heap_strdupW(szStatusText); break; - case BINDSTATUS_FINDINGRESOURCE: - case BINDSTATUS_CONNECTING: + case BINDSTATUS_FINDINGRESOURCE: /* FIXME */ break; default: diff --git a/dll/win32/urlmon/http.c b/dll/win32/urlmon/http.c index bb81ec820b6..fc0b8c4ecfe 100644 --- a/dll/win32/urlmon/http.c +++ b/dll/win32/urlmon/http.c @@ -17,11 +17,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -/* - * TODO: - * - Handle redirects as native. - */ - #include "urlmon_main.h" #include "wininet.h" @@ -84,7 +79,7 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ URL_COMPONENTSW url_comp; BYTE security_id[512]; DWORD len = 0; - ULONG num = 0; + ULONG num; BOOL res, b; HRESULT hres; @@ -95,7 +90,7 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ memset(&url_comp, 0, sizeof(url_comp)); url_comp.dwStructSize = sizeof(url_comp); - url_comp.dwSchemeLength = url_comp.dwHostNameLength = url_comp.dwUrlPathLength = + url_comp.dwSchemeLength = url_comp.dwHostNameLength = url_comp.dwUrlPathLength = url_comp.dwExtraInfoLength = url_comp.dwUserNameLength = url_comp.dwPasswordLength = 1; if (!InternetCrackUrlW(url, 0, 0, &url_comp)) return MK_E_SYNTAX; @@ -124,7 +119,12 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ } accept_mimes[num] = 0; - path = heap_strndupW(url_comp.lpszUrlPath, url_comp.dwUrlPathLength); + path = heap_alloc((url_comp.dwUrlPathLength+url_comp.dwExtraInfoLength+1)*sizeof(WCHAR)); + if(url_comp.dwUrlPathLength) + memcpy(path, url_comp.lpszUrlPath, url_comp.dwUrlPathLength*sizeof(WCHAR)); + if(url_comp.dwExtraInfoLength) + memcpy(path+url_comp.dwUrlPathLength, url_comp.lpszExtraInfo, url_comp.dwExtraInfoLength*sizeof(WCHAR)); + path[url_comp.dwUrlPathLength+url_comp.dwExtraInfoLength] = 0; if(This->https) request_flags |= INTERNET_FLAG_SECURE; This->base.request = HttpOpenRequestW(This->base.connection, @@ -132,8 +132,8 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ ? wszBindVerb[This->base.bind_info.dwBindVerb] : This->base.bind_info.szCustomVerb, path, NULL, NULL, (LPCWSTR *)accept_mimes, request_flags, (DWORD_PTR)&This->base); heap_free(path); - while (numbase.request) { WARN("HttpOpenRequest failed: %d\n", GetLastError()); return INET_E_RESOURCE_NOT_FOUND; @@ -227,7 +227,7 @@ static HRESULT HttpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD requ static HRESULT HttpProtocol_start_downloading(Protocol *prot) { HttpProtocol *This = ASYNCPROTOCOL_THIS(prot); - LPWSTR content_type = 0, content_length = 0; + LPWSTR content_type, content_length, ranges; DWORD len = sizeof(DWORD); DWORD status_code; BOOL res; @@ -258,8 +258,11 @@ static HRESULT HttpProtocol_start_downloading(Protocol *prot) WARN("HttpQueryInfo failed: %d\n", GetLastError()); } - if(This->https) + ranges = query_http_info(This, HTTP_QUERY_ACCEPT_RANGES); + if(ranges) { IInternetProtocolSink_ReportProgress(This->base.protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL); + heap_free(ranges); + } content_type = query_http_info(This, HTTP_QUERY_CONTENT_TYPE); if(content_type) { diff --git a/dll/win32/urlmon/internet.c b/dll/win32/urlmon/internet.c index 8bde7b4790f..6a79e48b526 100644 --- a/dll/win32/urlmon/internet.c +++ b/dll/win32/urlmon/internet.c @@ -38,6 +38,9 @@ static HRESULT parse_schema(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, if(ptr) len = ptr-url; + if(rsize) + *rsize = len; + if(len >= size) return E_POINTER; @@ -45,9 +48,6 @@ static HRESULT parse_schema(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, memcpy(result, url, len*sizeof(WCHAR)); result[len] = 0; - if(rsize) - *rsize = len; - return S_OK; } @@ -170,6 +170,100 @@ static HRESULT parse_security_domain(LPCWSTR url, DWORD flags, LPWSTR result, return E_FAIL; } +static HRESULT parse_domain(LPCWSTR url, DWORD flags, LPWSTR result, + DWORD size, DWORD *rsize) +{ + IInternetProtocolInfo *protocol_info; + HRESULT hres; + + TRACE("(%s %08x %p %d %p)\n", debugstr_w(url), flags, result, size, rsize); + + protocol_info = get_protocol_info(url); + + if(protocol_info) { + hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_DOMAIN, + flags, result, size, rsize, 0); + IInternetProtocolInfo_Release(protocol_info); + if(SUCCEEDED(hres)) + return hres; + } + + hres = UrlGetPartW(url, result, &size, URL_PART_HOSTNAME, flags); + if(rsize) + *rsize = size; + + if(hres == E_POINTER) + return S_FALSE; + + if(FAILED(hres)) + return E_FAIL; + return S_OK; +} + +static HRESULT parse_rootdocument(LPCWSTR url, DWORD flags, LPWSTR result, + DWORD size, DWORD *rsize) +{ + IInternetProtocolInfo *protocol_info; + PARSEDURLW url_info; + HRESULT hres; + + TRACE("(%s %08x %p %d %p)\n", debugstr_w(url), flags, result, size, rsize); + + protocol_info = get_protocol_info(url); + + if(protocol_info) { + hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_ROOTDOCUMENT, + flags, result, size, rsize, 0); + IInternetProtocolInfo_Release(protocol_info); + if(SUCCEEDED(hres)) + return hres; + } + + url_info.cbSize = sizeof(url_info); + if(FAILED(ParseURLW(url, &url_info))) + return E_FAIL; + + switch(url_info.nScheme) { + case URL_SCHEME_FTP: + case URL_SCHEME_HTTP: + case URL_SCHEME_HTTPS: + if(url_info.cchSuffix<3 || *(url_info.pszSuffix)!='/' + || *(url_info.pszSuffix+1)!='/') + return E_FAIL; + + if(size < url_info.cchProtocol+3) { + size = 0; + hres = UrlGetPartW(url, result, &size, URL_PART_HOSTNAME, flags); + + if(rsize) + *rsize = size+url_info.cchProtocol+3; + + if(hres == E_POINTER) + return S_FALSE; + + return hres; + } + + size -= url_info.cchProtocol+3; + hres = UrlGetPartW(url, result+url_info.cchProtocol+3, + &size, URL_PART_HOSTNAME, flags); + + if(hres == E_POINTER) + return S_FALSE; + + if(FAILED(hres)) + return E_FAIL; + + if(rsize) + *rsize = size+url_info.cchProtocol+3; + + memcpy(result, url, (url_info.cchProtocol+3)*sizeof(WCHAR)); + return hres; + default: + return E_FAIL; + } +} + /************************************************************************** * CoInternetParseUrl (URLMON.@) */ @@ -192,6 +286,10 @@ HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD return parse_schema(pwzUrl, dwFlags, pszResult, cchResult, pcchResult); case PARSE_SECURITY_DOMAIN: return parse_security_domain(pwzUrl, dwFlags, pszResult, cchResult, pcchResult); + case PARSE_DOMAIN: + return parse_domain(pwzUrl, dwFlags, pszResult, cchResult, pcchResult); + case PARSE_ROOTDOCUMENT: + return parse_rootdocument(pwzUrl, dwFlags, pszResult, cchResult, pcchResult); default: FIXME("not supported action %d\n", ParseAction); } diff --git a/dll/win32/urlmon/protocol.c b/dll/win32/urlmon/protocol.c index 9b25cbf4307..3f3cbe505bc 100644 --- a/dll/win32/urlmon/protocol.c +++ b/dll/win32/urlmon/protocol.c @@ -151,6 +151,11 @@ static void WINAPI internet_status_callback(HINTERNET internet, DWORD_PTR contex report_progress(protocol, BINDSTATUS_SENDINGREQUEST, (LPWSTR)status_info); break; + case INTERNET_STATUS_REDIRECT: + TRACE("%p INTERNET_STATUS_REDIRECT\n", protocol); + report_progress(protocol, BINDSTATUS_REDIRECTING, (LPWSTR)status_info); + break; + case INTERNET_STATUS_REQUEST_COMPLETE: request_complete(protocol, status_info); break; diff --git a/dll/win32/urlmon/regsvr.c b/dll/win32/urlmon/regsvr.c index 9561a23feaf..9e278259e37 100644 --- a/dll/win32/urlmon/regsvr.c +++ b/dll/win32/urlmon/regsvr.c @@ -495,6 +495,12 @@ static struct regsvr_coclass const coclass_list[] = { "urlmon.dll", "Both" }, + { &CLSID_PSFactoryBuffer, + "URLMoniker ProxyStub Factory", + NULL, + "urlmon.dll", + "Apartment" + }, { NULL } /* list terminator */ }; @@ -573,12 +579,14 @@ HRESULT WINAPI DllRegisterServer(void) TRACE("\n"); - hr = register_coclasses(coclass_list); - if (SUCCEEDED(hr)) + hr = URLMON_DllRegisterServer(); + if(SUCCEEDED(hr)) + hr = register_coclasses(coclass_list); + if(SUCCEEDED(hr)) hr = register_interfaces(interface_list); - if(FAILED(hr)) - return hr; - return register_inf(TRUE); + if(SUCCEEDED(hr)) + hr = register_inf(TRUE); + return hr; } /*********************************************************************** @@ -590,10 +598,12 @@ HRESULT WINAPI DllUnregisterServer(void) TRACE("\n"); - hr = unregister_coclasses(coclass_list); - if (SUCCEEDED(hr)) + hr = URLMON_DllUnregisterServer(); + if(SUCCEEDED(hr)) + hr = unregister_coclasses(coclass_list); + if(SUCCEEDED(hr)) hr = unregister_interfaces(interface_list); - if(FAILED(hr)) - return hr; - return register_inf(FALSE); + if(SUCCEEDED(hr)) + hr = register_inf(FALSE); + return hr; } diff --git a/dll/win32/urlmon/sec_mgr.c b/dll/win32/urlmon/sec_mgr.c index 7a1255a49ad..81f2f507d0d 100644 --- a/dll/win32/urlmon/sec_mgr.c +++ b/dll/win32/urlmon/sec_mgr.c @@ -147,12 +147,18 @@ static HRESULT map_url_to_zone(LPCWSTR url, DWORD *zone, LPWSTR *ret_url) DWORD size=0; HRESULT hres; - secur_url = heap_alloc(INTERNET_MAX_URL_LENGTH*sizeof(WCHAR)); *zone = -1; - hres = CoInternetParseUrl(url, PARSE_SECURITY_URL, 0, secur_url, INTERNET_MAX_URL_LENGTH, &size, 0); - if(hres != S_OK) - strcpyW(secur_url, url); + hres = CoInternetGetSecurityUrl(url, &secur_url, PSU_SECURITY_URL_ONLY, 0); + if(hres != S_OK) { + size = strlenW(url)*sizeof(WCHAR); + + secur_url = heap_alloc(size); + if(!secur_url) + return E_OUTOFMEMORY; + + memcpy(secur_url, url, size); + } hres = CoInternetParseUrl(secur_url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(WCHAR), &size, 0); if(FAILED(hres) || !*schema) { @@ -1228,3 +1234,84 @@ HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider* pSP, IInternetZoneM TRACE("(%p %p %x)\n", pSP, ppZM, dwReserved); return ZoneMgrImpl_Construct(NULL, (void**)ppZM); } + +/******************************************************************** + * CoInternetGetSecurityUrl (URLMON.@) + */ +HRESULT WINAPI CoInternetGetSecurityUrl(LPCWSTR pwzUrl, LPWSTR *ppwzSecUrl, PSUACTION psuAction, DWORD dwReserved) +{ + WCHAR buf1[INTERNET_MAX_URL_LENGTH], buf2[INTERNET_MAX_URL_LENGTH]; + LPWSTR url, domain; + DWORD len; + HRESULT hres; + + TRACE("(%p,%p,%u,%u)\n", pwzUrl, ppwzSecUrl, psuAction, dwReserved); + + url = buf1; + domain = buf2; + strcpyW(url, pwzUrl); + + while(1) { + hres = CoInternetParseUrl(url, PARSE_SECURITY_URL, 0, domain, INTERNET_MAX_URL_LENGTH, &len, 0); + if(hres!=S_OK || !strcmpW(url, domain)) + break; + + if(url == buf1) { + url = buf2; + domain = buf1; + } else { + url = buf1; + domain = buf2; + } + } + + if(psuAction==PSU_SECURITY_URL_ONLY) { + len = lstrlenW(url)+1; + *ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ppwzSecUrl) + return E_OUTOFMEMORY; + + memcpy(*ppwzSecUrl, url, len*sizeof(WCHAR)); + return S_OK; + } + + hres = CoInternetParseUrl(url, PARSE_SECURITY_DOMAIN, 0, domain, + INTERNET_MAX_URL_LENGTH, &len, 0); + if(SUCCEEDED(hres)) { + len++; + *ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ppwzSecUrl) + return E_OUTOFMEMORY; + + memcpy(*ppwzSecUrl, domain, len*sizeof(WCHAR)); + return S_OK; + } + + hres = CoInternetParseUrl(url, PARSE_ROOTDOCUMENT, 0, domain, 0, &len, 0); + if(hres == S_FALSE) { + hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, domain, + INTERNET_MAX_URL_LENGTH, &len, 0); + if(hres == S_OK) { + domain[len] = ':'; + hres = CoInternetParseUrl(url, PARSE_DOMAIN, 0, domain+len+1, + INTERNET_MAX_URL_LENGTH-len-1, &len, 0); + if(hres == S_OK) { + len = lstrlenW(domain)+1; + *ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ppwzSecUrl) + return E_OUTOFMEMORY; + + memcpy(*ppwzSecUrl, domain, len*sizeof(WCHAR)); + return S_OK; + } + } + } + + len = lstrlenW(url)+1; + *ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR)); + if(!*ppwzSecUrl) + return E_OUTOFMEMORY; + + memcpy(*ppwzSecUrl, url, len*sizeof(WCHAR)); + return S_OK; +} diff --git a/dll/win32/urlmon/umon.c b/dll/win32/urlmon/umon.c index e6e20b9d11c..5e6a8f6c21f 100644 --- a/dll/win32/urlmon/umon.c +++ b/dll/win32/urlmon/umon.c @@ -755,3 +755,14 @@ HRESULT WINAPI GetSoftwareUpdateInfo( LPCWSTR szDistUnit, LPSOFTDISTINFO psdi ) FIXME("%s %p\n", debugstr_w(szDistUnit), psdi ); return E_FAIL; } + +/*********************************************************************** + * AsyncInstallDistributionUnit (URLMON.@) + */ +HRESULT WINAPI AsyncInstallDistributionUnit( LPCWSTR szDistUnit, LPCWSTR szTYPE, + LPCWSTR szExt, DWORD dwFileVersionMS, DWORD dwFileVersionLS, + LPCWSTR szURL, IBindCtx *pbc, LPVOID pvReserved, DWORD flags ) +{ + FIXME(": stub\n"); + return E_NOTIMPL; +} diff --git a/dll/win32/urlmon/uri.c b/dll/win32/urlmon/uri.c new file mode 100644 index 00000000000..d4d6b47e5ab --- /dev/null +++ b/dll/win32/urlmon/uri.c @@ -0,0 +1,302 @@ +/* + * Copyright 2010 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "urlmon_main.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(urlmon); + +typedef struct { + const IUriVtbl *lpIUriVtbl; + LONG ref; +} Uri; + +#define URI(x) ((IUri*) &(x)->lpIUriVtbl) + +#define URI_THIS(iface) DEFINE_THIS(Uri, IUri, iface) + +static HRESULT WINAPI Uri_QueryInterface(IUri *iface, REFIID riid, void **ppv) +{ + Uri *This = URI_THIS(iface); + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = URI(This); + }else if(IsEqualGUID(&IID_IUri, riid)) { + TRACE("(%p)->(IID_IUri %p)\n", This, ppv); + *ppv = URI(This); + }else { + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI Uri_AddRef(IUri *iface) +{ + Uri *This = URI_THIS(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; +} + +static ULONG WINAPI Uri_Release(IUri *iface) +{ + Uri *This = URI_THIS(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) + heap_free(This); + + return ref; +} + +static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BSTR *pbstrProperty, DWORD dwFlags) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_HasProperty(IUri *iface, Uri_PROPERTY uriProp, BOOL *pfHasProperty) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->()\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetAbsoluteUri(IUri *iface, BSTR *pstrAbsoluteUri) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrAbsoluteUri); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetAuthority(IUri *iface, BSTR *pstrAuthority) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrAuthority); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetDisplayUri(IUri *iface, BSTR *pstrDisplayUri) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrDisplayUri); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetDomain(IUri *iface, BSTR *pstrDomain) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrDomain); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetExtension(IUri *iface, BSTR *pstrExtension) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrExtension); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetFragment(IUri *iface, BSTR *pstrFragment) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrFragment); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetHost(IUri *iface, BSTR *pstrHost) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrHost); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPassword(IUri *iface, BSTR *pstrPassword) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrPassword); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPath(IUri *iface, BSTR *pstrPath) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrPath); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPathAndQuery(IUri *iface, BSTR *pstrPathAndQuery) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrPathAndQuery); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetQuery(IUri *iface, BSTR *pstrQuery) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrQuery); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetRawUri(IUri *iface, BSTR *pstrRawUri) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrRawUri); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetSchemeName(IUri *iface, BSTR *pstrSchemeName) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrSchemeName); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetUserInfo(IUri *iface, BSTR *pstrUserInfo) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrUserInfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetUserName(IUri *iface, BSTR *pstrUserName) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pstrUserName); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetHostType(IUri *iface, DWORD *pdwHostType) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwHostType); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetPort(IUri *iface, DWORD *pdwPort) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwPort); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetScheme(IUri *iface, DWORD *pdwScheme) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwScheme); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetZone(IUri *iface, DWORD *pdwZone) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwZone); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_GetProperties(IUri *iface, DWORD *pdwProperties) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p)\n", This, pdwProperties); + return E_NOTIMPL; +} + +static HRESULT WINAPI Uri_IsEqual(IUri *iface, IUri *pUri, BOOL *pfEqual) +{ + Uri *This = URI_THIS(iface); + FIXME("(%p)->(%p %p)\n", This, pUri, pfEqual); + return E_NOTIMPL; +} + +#undef URI_THIS + +static const IUriVtbl UriVtbl = { + Uri_QueryInterface, + Uri_AddRef, + Uri_Release, + Uri_GetPropertyBSTR, + Uri_GetPropertyLength, + Uri_GetPropertyDWORD, + Uri_HasProperty, + Uri_GetAbsoluteUri, + Uri_GetAuthority, + Uri_GetDisplayUri, + Uri_GetDomain, + Uri_GetExtension, + Uri_GetFragment, + Uri_GetHost, + Uri_GetPassword, + Uri_GetPath, + Uri_GetPathAndQuery, + Uri_GetQuery, + Uri_GetRawUri, + Uri_GetSchemeName, + Uri_GetUserInfo, + Uri_GetUserName, + Uri_GetHostType, + Uri_GetPort, + Uri_GetScheme, + Uri_GetZone, + Uri_GetProperties, + Uri_IsEqual +}; + +/*********************************************************************** + * CreateUri (urlmon.@) + */ +HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI) +{ + Uri *ret; + + TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI), dwFlags, (DWORD)dwReserved, ppURI); + + ret = heap_alloc(sizeof(Uri)); + if(!ret) + return E_OUTOFMEMORY; + + ret->lpIUriVtbl = &UriVtbl; + ret->ref = 1; + + *ppURI = URI(ret); + return S_OK; +} diff --git a/dll/win32/urlmon/urlmon.inf b/dll/win32/urlmon/urlmon.inf index 4d781c73bd0..c9debb43a80 100644 --- a/dll/win32/urlmon/urlmon.inf +++ b/dll/win32/urlmon/urlmon.inf @@ -43,7 +43,6 @@ HKCR,"PROTOCOLS\Filter\lzdhtml","CLSID",,"%CLSID_DeCompMimeFilter%" [ZoneMap.Reg] -HKCU,"Software\Microsoft\Windows\CurrentVersion\Internet Settings",,, HKCU,"%PATH_ZONEMAP%",,, HKLM,"%PATH_ZONEMAP%",,, HKCU,"%PATH_ZONEMAP%","ProxyByPass", 0x10001,0x1 diff --git a/dll/win32/urlmon/urlmon.rbuild b/dll/win32/urlmon/urlmon.rbuild index 48034c5b4bb..c904c5726a0 100644 --- a/dll/win32/urlmon/urlmon.rbuild +++ b/dll/win32/urlmon/urlmon.rbuild @@ -27,18 +27,29 @@ session.c umon.c umstream.c + uri.c urlmon_main.c + usrmarshal.c rsrc.rc wine uuid + rpcrt4 ole32 shlwapi wininet user32 advapi32 + pseh + urlmon_proxy ntdll - - urlmon_local.idl + + + URLMON_ + + + + "{0x79EAC9F1,0xBAF9,0x11CE,{0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B}}" + urlmon_urlmon.idl diff --git a/dll/win32/urlmon/urlmon.spec b/dll/win32/urlmon/urlmon.spec index 2ed99886d21..a67004a9b0b 100644 --- a/dll/win32/urlmon/urlmon.spec +++ b/dll/win32/urlmon/urlmon.spec @@ -6,7 +6,7 @@ #3 stub IsJITInProgress @ stub AsyncGetClassBits -@ stub AsyncInstallDistributionUnit +@ stdcall AsyncInstallDistributionUnit(ptr ptr ptr long long ptr ptr ptr long) @ stdcall BindAsyncMoniker(ptr long ptr ptr ptr) @ stdcall CoGetClassObjectFromURL(ptr wstr long long wstr ptr long ptr ptr ptr) @ stub CoInstall @@ -15,7 +15,7 @@ @ stdcall CoInternetCreateSecurityManager(ptr ptr long) @ stdcall CoInternetCreateZoneManager(ptr ptr long) @ stub CoInternetGetProtocolFlags -@ stub CoInternetGetSecurityUrl +@ stdcall CoInternetGetSecurityUrl(ptr ptr long long) @ stdcall CoInternetGetSession(long ptr long) @ stdcall CoInternetParseUrl(wstr long long wstr long ptr long) @ stdcall CoInternetQueryInfo(ptr long long ptr long ptr long) @@ -26,6 +26,7 @@ @ stdcall CreateAsyncBindCtx(long ptr ptr ptr) @ stdcall CreateAsyncBindCtxEx(ptr long ptr ptr ptr long) @ stdcall CreateFormatEnumerator(long ptr ptr) +@ stdcall CreateUri(wstr long long ptr) @ stdcall CreateURLMoniker(ptr wstr ptr) @ stdcall CreateURLMonikerEx(ptr wstr ptr long) @ stdcall -private DllCanUnloadNow() diff --git a/dll/win32/urlmon/urlmon_local.idl b/dll/win32/urlmon/urlmon_local.idl deleted file mode 100644 index 1a1403ea73e..00000000000 --- a/dll/win32/urlmon/urlmon_local.idl +++ /dev/null @@ -1,2 +0,0 @@ - -#include "urlmon.idl" diff --git a/dll/win32/urlmon/urlmon_main.c b/dll/win32/urlmon/urlmon_main.c index a420308453d..272884eb2a6 100644 --- a/dll/win32/urlmon/urlmon_main.c +++ b/dll/win32/urlmon/urlmon_main.c @@ -348,6 +348,7 @@ static void init_session(BOOL init) HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { unsigned int i; + HRESULT hr; TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); @@ -357,6 +358,10 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) return IClassFactory_QueryInterface(object_creation[i].cf, riid, ppv); } + hr = URLMON_DllGetClassObject(rclsid, riid, ppv); + if(SUCCEEDED(hr)) + return hr; + FIXME("%s: no class found.\n", debugstr_guid(rclsid)); return CLASS_E_CLASSNOTAVAILABLE; } diff --git a/dll/win32/urlmon/urlmon_main.h b/dll/win32/urlmon/urlmon_main.h index 21b93430a60..8db786b7d80 100644 --- a/dll/win32/urlmon/urlmon_main.h +++ b/dll/win32/urlmon/urlmon_main.h @@ -48,6 +48,12 @@ extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT MimeFilter_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); +extern HRESULT WINAPI URLMON_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) DECLSPEC_HIDDEN; +extern HRESULT WINAPI URLMON_DllRegisterServer(void) DECLSPEC_HIDDEN; +extern HRESULT WINAPI URLMON_DllUnregisterServer(void) DECLSPEC_HIDDEN; + +extern GUID const CLSID_PSFactoryBuffer DECLSPEC_HIDDEN; + /********************************************************************** * Dll lifetime tracking declaration for urlmon.dll */ diff --git a/dll/win32/urlmon/urlmon_urlmon.idl b/dll/win32/urlmon/urlmon_urlmon.idl new file mode 100644 index 00000000000..71a0719d7d9 --- /dev/null +++ b/dll/win32/urlmon/urlmon_urlmon.idl @@ -0,0 +1,19 @@ +/* + * Copyright 2009 Piotr Caban for Codeweavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "urlmon.idl" diff --git a/dll/win32/urlmon/usrmarshal.c b/dll/win32/urlmon/usrmarshal.c new file mode 100644 index 00000000000..b94556362be --- /dev/null +++ b/dll/win32/urlmon/usrmarshal.c @@ -0,0 +1,162 @@ +/* + * Copyright 2009 Piotr Caban for Codeweavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "urlmon_main.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(urlmon); + +HRESULT CALLBACK IWinInetHttpInfo_QueryInfo_Proxy(IWinInetHttpInfo* This, + DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf, DWORD *pdwFlags, + DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IWinInetHttpInfo_QueryInfo_Stub(IWinInetHttpInfo* This, + DWORD dwOption, BYTE *pBuffer, DWORD *pcbBuf, DWORD *pdwFlags, + DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IWinInetInfo_QueryOption_Proxy(IWinInetInfo* This, + DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IWinInetInfo_QueryOption_Stub(IWinInetInfo* This, + DWORD dwOption, BYTE *pBuffer, DWORD *pcbBuf) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindHost_MonikerBindToStorage_Proxy(IBindHost* This, + IMoniker *pMk, IBindCtx *pBC, IBindStatusCallback *pBSC, + REFIID riid, void **ppvObj) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindHost_MonikerBindToStorage_Stub(IBindHost* This, + IMoniker *pMk, IBindCtx *pBC, IBindStatusCallback *pBSC, + REFIID riid, IUnknown **ppvObj) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindHost_MonikerBindToObject_Proxy(IBindHost* This, + IMoniker *pMk, IBindCtx *pBC, IBindStatusCallback *pBSC, + REFIID riid, void **ppvObj) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindHost_MonikerBindToObject_Stub(IBindHost* This, + IMoniker *pMk, IBindCtx *pBC, IBindStatusCallback *pBSC, + REFIID riid, IUnknown **ppvObj) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindStatusCallbackEx_GetBindInfoEx_Proxy( + IBindStatusCallbackEx* This, DWORD *grfBINDF, BINDINFO *pbindinfo, + DWORD *grfBINDF2, DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindStatusCallbackEx_GetBindInfoEx_Stub( + IBindStatusCallbackEx* This, DWORD *grfBINDF, RemBINDINFO *pbindinfo, + RemSTGMEDIUM *pstgmed, DWORD *grfBINDF2, DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindStatusCallback_GetBindInfo_Proxy( + IBindStatusCallback* This, DWORD *grfBINDF, BINDINFO *pbindinfo) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindStatusCallback_GetBindInfo_Stub( + IBindStatusCallback* This, DWORD *grfBINDF, + RemBINDINFO *pbindinfo, RemSTGMEDIUM *pstgmed) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBindStatusCallback_OnDataAvailable_Proxy( + IBindStatusCallback* This, DWORD grfBSCF, DWORD dwSize, + FORMATETC *pformatetc, STGMEDIUM *pstgmed) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBindStatusCallback_OnDataAvailable_Stub( + IBindStatusCallback* This, DWORD grfBSCF, DWORD dwSize, + RemFORMATETC *pformatetc, RemSTGMEDIUM *pstgmed) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT CALLBACK IBinding_GetBindResult_Proxy(IBinding* This, + CLSID *pclsidProtocol, DWORD *pdwResult, + LPOLESTR *pszResult, DWORD *pdwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT __RPC_STUB IBinding_GetBindResult_Stub(IBinding* This, + CLSID *pclsidProtocol, DWORD *pdwResult, + LPOLESTR *pszResult, DWORD dwReserved) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT STDMETHODCALLTYPE IWindowForBindingUI_GetWindow_Proxy( + IWindowForBindingUI* This, REFGUID rguidReason, HWND *phwnd) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +void __RPC_STUB IWindowForBindingUI_GetWindow_Stub(IRpcStubBuffer* This, + IRpcChannelBuffer* pRpcChannelBuffer, PRPC_MESSAGE pRpcMessage, + DWORD* pdwStubPhase) +{ + FIXME("stub\n"); +} diff --git a/dll/win32/user32/controls/button.c b/dll/win32/user32/controls/button.c index 4eb8bc66547..1f448bd1885 100644 --- a/dll/win32/user32/controls/button.c +++ b/dll/win32/user32/controls/button.c @@ -102,8 +102,6 @@ static void GB_Paint( HWND hwnd, HDC hDC, UINT action ); static void UB_Paint( HWND hwnd, HDC hDC, UINT action ); static void OB_Paint( HWND hwnd, HDC hDC, UINT action ); static void BUTTON_CheckAutoRadioButton( HWND hwnd ); -//static LRESULT WINAPI ButtonWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); -//static LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); #define MAX_BTN_TYPE 12 @@ -291,6 +289,13 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, } if (btn_type >= MAX_BTN_TYPE) return -1; /* abort */ + + /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */ + if (btn_type == BS_USERBUTTON ) + { + style = (style & ~0x0f) | BS_PUSHBUTTON; + SetWindowLongPtrW( hWnd, GWL_STYLE, style ); + } set_button_state( hWnd, BUTTON_UNCHECKED ); button_update_uistate( hWnd, unicode ); return 0; @@ -474,9 +479,6 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, InvalidateRect( hWnd, NULL, FALSE ); break; -#ifndef __REACTOS__ - case BM_SETSTYLE16: -#endif case BM_SETSTYLE: if ((wParam & 0x0f) >= MAX_BTN_TYPE) break; btn_type = wParam & 0x0f; @@ -485,7 +487,7 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, /* Only redraw if lParam flag is set.*/ if (lParam) - paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); + InvalidateRect( hWnd, NULL, TRUE ); break; @@ -514,15 +516,9 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, case BM_GETIMAGE: return GetWindowLongPtrW( hWnd, HIMAGE_GWL_OFFSET ); -#ifndef __REACTOS__ - case BM_GETCHECK16: -#endif case BM_GETCHECK: return get_button_state( hWnd ) & 3; -#ifndef __REACTOS__ - case BM_SETCHECK16: -#endif case BM_SETCHECK: if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type]; state = get_button_state( hWnd ); @@ -541,15 +537,9 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, BUTTON_CheckAutoRadioButton( hWnd ); break; -#ifndef __REACTOS__ - case BM_GETSTATE16: -#endif case BM_GETSTATE: return get_button_state( hWnd ); -#ifndef __REACTOS__ - case BM_SETSTATE16: -#endif case BM_SETSTATE: state = get_button_state( hWnd ); if (wParam) @@ -871,9 +861,15 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) if (get_button_type(style) == BS_DEFPUSHBUTTON) { - Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); + if (action != ODA_FOCUS) + Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); InflateRect( &rc, -1, -1 ); } + + focus_rect = rc; + + /* completely skip the drawing if only focus has changed */ + if (action == ODA_FOCUS) goto draw_focus; uState = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT; @@ -892,8 +888,6 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) DrawFrameControl( hDC, &rc, DFC_BUTTON, uState ); - focus_rect = rc; - /* draw button label */ r = rc; dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r); @@ -912,7 +906,9 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) SetTextColor( hDC, oldTxtColor ); - if (state & BUTTON_HASFOCUS) +draw_focus: + if ((action == ODA_FOCUS) || + ((action == ODA_DRAWENTIRE) && (state & BUTTON_HASFOCUS))) { if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) { @@ -1165,6 +1161,8 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action ) if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) DrawFocusRect( hDC, &rc ); } + + BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT ); } diff --git a/dll/win32/user32/controls/combo.c b/dll/win32/user32/controls/combo.c index 99193b17a07..2a7ab1822b9 100644 --- a/dll/win32/user32/controls/combo.c +++ b/dll/win32/user32/controls/combo.c @@ -74,9 +74,6 @@ static UINT CBitHeight, CBitWidth; #define COMBO_EDITBUTTONSPACE() 0 #define EDIT_CONTROL_PADDING() 1 -//static LRESULT WINAPI ComboWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); -//static LRESULT WINAPI ComboWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); - /********************************************************************* * combo class descriptor */ diff --git a/dll/win32/user32/controls/edit.c b/dll/win32/user32/controls/edit.c index 2dccbac3842..683c9dfe72a 100644 --- a/dll/win32/user32/controls/edit.c +++ b/dll/win32/user32/controls/edit.c @@ -1648,13 +1648,16 @@ static LRESULT EDIT_EM_Scroll(EDITSTATE *es, INT action) INT vlc = get_vertical_line_count(es); /* check if we are going to move too far */ if(es->y_offset + dy > es->line_count - vlc) - dy = es->line_count - vlc - es->y_offset; + dy = max(es->line_count - vlc, 0) - es->y_offset; /* Notification is done in EDIT_EM_LineScroll */ - if(dy) + if(dy) { EDIT_EM_LineScroll(es, 0, dy); + return MAKELONG((SHORT)dy, (BOOL)TRUE); + } + } - return MAKELONG((SHORT)dy, (BOOL)TRUE); + return (LRESULT)FALSE; } diff --git a/dll/win32/user32/controls/icontitle.c b/dll/win32/user32/controls/icontitle.c index 01231cdd03c..465a1a40ca4 100644 --- a/dll/win32/user32/controls/icontitle.c +++ b/dll/win32/user32/controls/icontitle.c @@ -30,8 +30,6 @@ static BOOL bMultiLineTitle; static HFONT hIconTitleFont; -//static LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); - /********************************************************************* * icon title class descriptor */ diff --git a/dll/win32/user32/controls/listbox.c b/dll/win32/user32/controls/listbox.c index d46c1bb81ba..0f66305a285 100644 --- a/dll/win32/user32/controls/listbox.c +++ b/dll/win32/user32/controls/listbox.c @@ -40,13 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(listbox); /* Start of hack section -------------------------------- */ -typedef short *LPINT16; - -BOOL is_old_app(HWND hwnd) -{ - return FALSE; -} - #define WM_LBTRACKPOINT 0x0131 #define WS_EX_DRAGDETECT 0x00000002L #define WM_BEGINDRAG 0x022C @@ -105,7 +98,7 @@ typedef struct HFONT font; /* Current font */ LCID locale; /* Current locale for string comparisons */ LPHEADCOMBO lphc; /* ComboLBox */ - LONG UIState; + LONG UIState; // REACTOS } LB_DESCR; @@ -138,9 +131,6 @@ typedef enum static TIMER_DIRECTION LISTBOX_Timer = LB_TIMER_NONE; -//static LRESULT WINAPI ListBoxWndProcA( HWND hwnd, UINT msg, WPARAM wParam,LPARAM lParam ); -//static LRESULT WINAPI ListBoxWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); - static LRESULT LISTBOX_GetItemRect( const LB_DESCR *descr, INT index, RECT *rect ); /********************************************************************* @@ -174,14 +164,6 @@ const struct builtin_class_descr COMBOLBOX_builtin_class = 0 /* brush */ }; -#ifndef __REACTOS__ -/* check whether app is a Win 3.1 app */ -static inline BOOL is_old_app( LB_DESCR *descr ) -{ - return (GetExpWinVer16( GetWindowLongPtrW(descr->self, GWLP_HINSTANCE) ) & 0xFF00 ) == 0x0300; -} -#endif - /*********************************************************************** * LISTBOX_GetCurrentPageSize @@ -409,16 +391,6 @@ static void LISTBOX_UpdateSize( LB_DESCR *descr ) remaining = 0; if ((descr->height > descr->item_height) && remaining) { -#ifndef __REACTOS__ - if (is_old_app(descr)) - { /* give a margin for error to 16 bits programs - if we need - less than the height of the nonclient area, round to the - *next* number of items */ - int ncheight = rect.bottom - rect.top - descr->height; - if ((descr->item_height - remaining) <= ncheight) - remaining = remaining - descr->item_height; - } -#endif TRACE("[%p]: changing height %d -> %d\n", descr->self, descr->height, descr->height - remaining ); SetWindowPos( descr->self, 0, 0, 0, rect.right - rect.left, @@ -565,10 +537,10 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, if (!item) { if (action == ODA_FOCUS) - { - if (!(descr->UIState & UISF_HIDEFOCUS)) - DrawFocusRect( hdc, rect ); - } + { // REACTOS + if (!(descr->UIState & UISF_HIDEFOCUS)) + DrawFocusRect( hdc, rect ); + } // else ERR("called with an out of bounds index %d(%d) in owner draw, Not good.\n",index,descr->nb_items); return; @@ -608,7 +580,7 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, if (action == ODA_FOCUS) { - if (!(descr->UIState & UISF_HIDEFOCUS)) + if (!(descr->UIState & UISF_HIDEFOCUS)) // REACTOS DrawFocusRect( hdc, rect ); return; } @@ -771,7 +743,7 @@ static LRESULT LISTBOX_InitStorage( LB_DESCR *descr, INT nb_items ) /*********************************************************************** * LISTBOX_SetTabStops */ -static BOOL LISTBOX_SetTabStops( LB_DESCR *descr, INT count, LPINT tabs, BOOL short_ints ) +static BOOL LISTBOX_SetTabStops( LB_DESCR *descr, INT count, LPINT tabs ) { INT i; @@ -790,23 +762,7 @@ static BOOL LISTBOX_SetTabStops( LB_DESCR *descr, INT count, LPINT tabs, BOOL sh if (!(descr->tabs = HeapAlloc( GetProcessHeap(), 0, descr->nb_tabs * sizeof(INT) ))) return FALSE; -#ifndef __REACTOS__ - if (short_ints) - { - INT i; - LPINT16 p = (LPINT16)tabs; - - TRACE("[%p]: settabstops ", descr->self ); - for (i = 0; i < descr->nb_tabs; i++) { - descr->tabs[i] = *p++<<1; /* FIXME */ - TRACE("%hd ", descr->tabs[i]); - } - TRACE("\n"); - } - else memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(INT) ); -#else - memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(INT) ); -#endif + memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(INT) ); /* convert into "dialog units"*/ for (i = 0; i < descr->nb_tabs; i++) @@ -1049,23 +1005,6 @@ static LRESULT LISTBOX_GetSelCount( const LB_DESCR *descr ) } -#ifndef __REACTOS__ -/*********************************************************************** - * LISTBOX_GetSelItems16 - */ -static LRESULT LISTBOX_GetSelItems16( const LB_DESCR *descr, INT16 max, LPINT16 array ) -{ - INT i, count; - const LB_ITEMDATA *item = descr->items; - - if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR; - for (i = count = 0; (i < descr->nb_items) && (count < max); i++, item++) - if (item->selected) array[count++] = (INT16)i; - return count; -} -#endif - - /*********************************************************************** * LISTBOX_GetSelItems */ @@ -1595,15 +1534,8 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index, /* We need to grow the array */ max_items += LB_ARRAY_GRANULARITY; if (descr->items) - { item = HeapReAlloc( GetProcessHeap(), 0, descr->items, max_items * sizeof(LB_ITEMDATA) ); - if (!item) - { - SEND_NOTIFICATION( descr, LBN_ERRSPACE ); - return LB_ERRSPACE; - } - } else item = HeapAlloc( GetProcessHeap(), 0, max_items * sizeof(LB_ITEMDATA) ); @@ -2166,7 +2098,7 @@ static LRESULT LISTBOX_HandleLButtonDown( LB_DESCR *descr, DWORD keys, INT x, IN } if (!descr->lphc) - { + { // See rev 40864 use Ptr for 64 bit. if (GetWindowLongPtrW( descr->self, GWL_EXSTYLE ) & WS_EX_DRAGDETECT) { POINT pt; @@ -2539,7 +2471,7 @@ static LRESULT LISTBOX_HandleChar( LB_DESCR *descr, WCHAR charW ) return 0; } -/* Retrieve the UI state for the control */ +/* ReactOS Retrieve the UI state for the control */ static BOOL LISTBOX_update_uistate(LB_DESCR *descr) { LONG prev_flags; @@ -2589,18 +2521,6 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) descr->locale = GetUserDefaultLCID(); descr->lphc = lphc; -#ifndef __REACTOS__ - if (is_old_app(descr) && ( descr->style & ( WS_VSCROLL | WS_HSCROLL ) ) ) - { - /* Win95 document "List Box Differences" from MSDN: - If a list box in a version 3.x application has either the - WS_HSCROLL or WS_VSCROLL style, the list box receives both - horizontal and vertical scroll bars. - */ - descr->style |= WS_VSCROLL | WS_HSCROLL; - } -#endif - if( lphc ) { TRACE("[%p]: resetting owner %p -> %p\n", descr->self, descr->owner, lphc->self ); @@ -2609,7 +2529,7 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) SetWindowLongPtrW( descr->self, 0, (LONG_PTR)descr ); - LISTBOX_update_uistate(descr); + LISTBOX_update_uistate(descr); // ReactOS /* if (wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) descr->style &= ~LBS_NOTIFY; */ @@ -2689,20 +2609,12 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, switch(msg) { -#ifndef __REACTOS__ - case LB_RESETCONTENT16: -#endif case LB_RESETCONTENT: LISTBOX_ResetContent( descr ); LISTBOX_UpdateScroll( descr ); InvalidateRect( descr->self, NULL, TRUE ); return 0; -#ifndef __REACTOS__ - case LB_ADDSTRING16: - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_ADDSTRING: case LB_ADDSTRING_LOWER: case LB_ADDSTRING_UPPER: @@ -2733,12 +2645,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_INSERTSTRING16: - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - wParam = (INT)(INT16)wParam; - /* fall through */ -#endif case LB_INSERTSTRING: case LB_INSERTSTRING_UPPER: case LB_INSERTSTRING_LOWER: @@ -2768,11 +2674,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_ADDFILE16: - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_ADDFILE: { INT ret; @@ -2795,9 +2696,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_DELETESTRING16: -#endif case LB_DELETESTRING: if (LISTBOX_RemoveItem( descr, wParam) != LB_ERR) return descr->nb_items; @@ -2807,9 +2705,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return LB_ERR; } -#ifndef __REACTOS__ - case LB_GETITEMDATA16: -#endif case LB_GETITEMDATA: if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) { @@ -2818,9 +2713,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, } return descr->items[wParam].data; -#ifndef __REACTOS__ - case LB_SETITEMDATA16: -#endif case LB_SETITEMDATA: if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) { @@ -2831,24 +2723,12 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, /* undocumented: returns TRUE, not LB_OKAY (0) */ return TRUE; -#ifndef __REACTOS__ - case LB_GETCOUNT16: -#endif case LB_GETCOUNT: return descr->nb_items; -#ifndef __REACTOS__ - case LB_GETTEXT16: - lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_GETTEXT: return LISTBOX_GetText( descr, wParam, (LPWSTR)lParam, unicode ); -#ifndef __REACTOS__ - case LB_GETTEXTLEN16: - /* fall through */ -#endif case LB_GETTEXTLEN: if ((INT)wParam >= descr->nb_items || (INT)wParam < 0) { @@ -2860,9 +2740,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return WideCharToMultiByte( CP_ACP, 0, descr->items[wParam].str, strlenW(descr->items[wParam].str), NULL, 0, NULL, NULL ); -#ifndef __REACTOS__ - case LB_GETCURSEL16: -#endif case LB_GETCURSEL: if (descr->nb_items == 0) return LB_ERR; @@ -2873,23 +2750,12 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return descr->focus_item; /* otherwise, if the user tries to move the selection with the */ /* arrow keys, we will give the application something to choke on */ -#ifndef __REACTOS__ - case LB_GETTOPINDEX16: -#endif case LB_GETTOPINDEX: return descr->top_item; -#ifndef __REACTOS__ - case LB_GETITEMHEIGHT16: -#endif case LB_GETITEMHEIGHT: return LISTBOX_GetItemHeight( descr, wParam ); -#ifndef __REACTOS__ - case LB_SETITEMHEIGHT16: - lParam = LOWORD(lParam); - /* fall through */ -#endif case LB_SETITEMHEIGHT: return LISTBOX_SetItemHeight( descr, wParam, lParam, TRUE ); @@ -2931,9 +2797,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return MAKELONG(index, hit ? 0 : 1); } -#ifndef __REACTOS__ - case LB_SETCARETINDEX16: -#endif case LB_SETCARETINDEX: if ((!IS_MULTISELECT(descr)) && (descr->selected_item != -1)) return LB_ERR; if (LISTBOX_SetCaretIndex( descr, wParam, !lParam ) == LB_ERR) @@ -2943,47 +2806,18 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, else return LB_OKAY; -#ifndef __REACTOS__ - case LB_GETCARETINDEX16: -#endif case LB_GETCARETINDEX: return descr->focus_item; -#ifndef __REACTOS__ - case LB_SETTOPINDEX16: -#endif case LB_SETTOPINDEX: return LISTBOX_SetTopItem( descr, wParam, TRUE ); -#ifndef __REACTOS__ - case LB_SETCOLUMNWIDTH16: -#endif case LB_SETCOLUMNWIDTH: return LISTBOX_SetColumnWidth( descr, wParam ); -#ifndef __REACTOS__ - case LB_GETITEMRECT16: - { - RECT rect; - RECT16 *r16 = MapSL(lParam); - ret = LISTBOX_GetItemRect( descr, (INT16)wParam, &rect ); - r16->left = rect.left; - r16->top = rect.top; - r16->right = rect.right; - r16->bottom = rect.bottom; - } - return ret; -#endif - case LB_GETITEMRECT: return LISTBOX_GetItemRect( descr, wParam, (RECT *)lParam ); -#ifndef __REACTOS__ - case LB_FINDSTRING16: - wParam = (INT)(INT16)wParam; - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_FINDSTRING: { INT ret; @@ -3003,12 +2837,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_FINDSTRINGEXACT16: - wParam = (INT)(INT16)wParam; - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_FINDSTRINGEXACT: { INT ret; @@ -3028,12 +2856,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return ret; } -#ifndef __REACTOS__ - case LB_SELECTSTRING16: - wParam = (INT)(INT16)wParam; - if (HAS_STRINGS(descr)) lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_SELECTSTRING: { INT index; @@ -3062,29 +2884,14 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return index; } -#ifndef __REACTOS__ - case LB_GETSEL16: - wParam = (INT)(INT16)wParam; - /* fall through */ -#endif case LB_GETSEL: if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) return LB_ERR; return descr->items[wParam].selected; -#ifndef __REACTOS__ - case LB_SETSEL16: - lParam = (INT)(INT16)lParam; - /* fall through */ -#endif case LB_SETSEL: return LISTBOX_SetSelection( descr, lParam, wParam, FALSE ); -#ifndef __REACTOS__ - case LB_SETCURSEL16: - wParam = (INT)(INT16)wParam; - /* fall through */ -#endif case LB_SETCURSEL: if (IS_MULTISELECT(descr)) return LB_ERR; LISTBOX_SetCaretIndex( descr, wParam, FALSE ); @@ -3092,23 +2899,12 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, if (ret != LB_ERR) ret = descr->selected_item; return ret; -#ifndef __REACTOS__ - case LB_GETSELCOUNT16: -#endif case LB_GETSELCOUNT: return LISTBOX_GetSelCount( descr ); -#ifndef __REACTOS__ - case LB_GETSELITEMS16: - return LISTBOX_GetSelItems16( descr, wParam, (LPINT16)MapSL(lParam) ); -#endif - case LB_GETSELITEMS: return LISTBOX_GetSelItems( descr, wParam, (LPINT)lParam ); -#ifndef __REACTOS__ - case LB_SELITEMRANGE16: -#endif case LB_SELITEMRANGE: if (LOWORD(lParam) <= HIWORD(lParam)) return LISTBOX_SelectItemRange( descr, LOWORD(lParam), @@ -3117,38 +2913,21 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, return LISTBOX_SelectItemRange( descr, HIWORD(lParam), LOWORD(lParam), wParam ); -#ifndef __REACTOS__ - case LB_SELITEMRANGEEX16: -#endif case LB_SELITEMRANGEEX: if ((INT)lParam >= (INT)wParam) return LISTBOX_SelectItemRange( descr, wParam, lParam, TRUE ); else return LISTBOX_SelectItemRange( descr, lParam, wParam, FALSE); -#ifndef __REACTOS__ - case LB_GETHORIZONTALEXTENT16: -#endif case LB_GETHORIZONTALEXTENT: return descr->horz_extent; -#ifndef __REACTOS__ - case LB_SETHORIZONTALEXTENT16: -#endif case LB_SETHORIZONTALEXTENT: return LISTBOX_SetHorizontalExtent( descr, wParam ); -#ifndef __REACTOS__ - case LB_GETANCHORINDEX16: -#endif case LB_GETANCHORINDEX: return descr->anchor_item; -#ifndef __REACTOS__ - case LB_SETANCHORINDEX16: - wParam = (INT)(INT16)wParam; - /* fall through */ -#endif case LB_SETANCHORINDEX: if (((INT)wParam < -1) || ((INT)wParam >= descr->nb_items)) { @@ -3158,14 +2937,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, descr->anchor_item = (INT)wParam; return LB_OKAY; -#ifndef __REACTOS__ - case LB_DIR16: - /* according to Win16 docs, DDL_DRIVES should make DDL_EXCLUSIVE - * be set automatically (this is different in Win32) */ - if (wParam & DDL_DRIVES) wParam |= DDL_EXCLUSIVE; - lParam = (LPARAM)MapSL(lParam); - /* fall through */ -#endif case LB_DIR: { INT ret; @@ -3204,17 +2975,9 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, case LB_SETCOUNT: return LISTBOX_SetCount( descr, (INT)wParam ); -#ifndef __REACTOS__ - case LB_SETTABSTOPS16: - return LISTBOX_SetTabStops( descr, (INT)(INT16)wParam, MapSL(lParam), TRUE ); -#endif - case LB_SETTABSTOPS: - return LISTBOX_SetTabStops( descr, wParam, (LPINT)lParam, FALSE ); + return LISTBOX_SetTabStops( descr, wParam, (LPINT)lParam ); -#ifndef __REACTOS__ - case LB_CARETON16: -#endif case LB_CARETON: if (descr->caret_on) return LB_OKAY; @@ -3223,9 +2986,6 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS ); return LB_OKAY; -#ifndef __REACTOS__ - case LB_CARETOFF16: -#endif case LB_CARETOFF: if (!descr->caret_on) return LB_OKAY; @@ -3418,7 +3178,7 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, case WM_NCACTIVATE: if (lphc) return 0; break; - +// ReactOS case WM_UPDATEUISTATE: if (unicode) DefWindowProcW(descr->self, msg, wParam, lParam); @@ -3432,7 +3192,7 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, LISTBOX_DrawFocusRect( descr, descr->in_focus ); } break; - +// default: if ((msg >= WM_USER) && (msg < 0xc000)) WARN("[%p]: unknown msg %04x wp %08lx lp %08lx\n", diff --git a/dll/win32/user32/controls/scrollbar.c b/dll/win32/user32/controls/scrollbar.c index e55baadffb9..460fd6a3ea1 100644 --- a/dll/win32/user32/controls/scrollbar.c +++ b/dll/win32/user32/controls/scrollbar.c @@ -68,9 +68,6 @@ static BOOL ScrollTrackVertical; HBRUSH DefWndControlColor(HDC hDC, UINT ctlType); -//static LRESULT WINAPI ScrollBarWndProcW( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); -//static LRESULT WINAPI ScrollBarWndProcA( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); - UINT WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC); BOOL WINAPI KillSystemTimer(HWND,UINT_PTR); @@ -712,6 +709,22 @@ IntScrollDrawSizeGrip(HWND Wnd, HDC Dc) DrawFrameControl(Dc, &Rect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); } +/*********************************************************************** + * SCROLL_RefreshScrollBar + * + * Repaint the scroll bar interior after a SetScrollRange() or + * SetScrollPos() call. + */ +static void SCROLL_RefreshScrollBar( HWND hwnd, INT nBar, + BOOL arrows, BOOL interior ) +{ + HDC hdc = GetDCEx( hwnd, 0, + DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW) ); + if (!hdc) return; + + IntDrawScrollBar( hwnd, hdc, nBar);//, arrows, interior ); + ReleaseDC( hwnd, hdc ); +} /*********************************************************************** @@ -1399,14 +1412,14 @@ ScrollBarWndProc(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARA case SBM_GETPOS: return IntScrollGetScrollPos(Wnd, SB_CTL); + case SBM_SETRANGEREDRAW: case SBM_SETRANGE: { INT OldPos = IntScrollGetScrollPos(Wnd, SB_CTL); SetScrollRange(Wnd, SB_CTL, wParam, lParam, FALSE); - if (OldPos != IntScrollGetScrollPos(Wnd, SB_CTL)) - { - return OldPos; - } + if (Msg == SBM_SETRANGEREDRAW) + SCROLL_RefreshScrollBar( Wnd, SB_CTL, TRUE, TRUE ); + if (OldPos != IntScrollGetScrollPos(Wnd, SB_CTL)) return OldPos; } return 0; @@ -1416,27 +1429,19 @@ ScrollBarWndProc(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARA case SBM_ENABLE_ARROWS: return EnableScrollBar(Wnd, SB_CTL, wParam); - case SBM_SETRANGEREDRAW: - { - INT OldPos = IntScrollGetScrollPos(Wnd, SB_CTL); - SetScrollRange(Wnd, SB_CTL, wParam, lParam, TRUE); - if (OldPos != IntScrollGetScrollPos(Wnd, SB_CTL)) - { - return OldPos; - } - } - return 0; - case SBM_SETSCROLLINFO: return NtUserSetScrollInfo(Wnd, SB_CTL, (SCROLLINFO *) lParam, wParam); case SBM_GETSCROLLINFO: return NtUserSBGetParms(Wnd, SB_CTL, NULL, (SCROLLINFO *) lParam); + case SBM_GETSCROLLBARINFO: + ((PSCROLLBARINFO)lParam)->cbSize = sizeof(SCROLLBARINFO); + return NtUserGetScrollBarInfo(Wnd, OBJID_CLIENT, (PSCROLLBARINFO)lParam); + case 0x00e5: case 0x00e7: case 0x00e8: - case 0x00eb: case 0x00ec: case 0x00ed: case 0x00ee: @@ -1505,8 +1510,8 @@ RealGetScrollInfo(HWND Wnd, INT SBType, LPSCROLLINFO Info) PWND pWnd; PSBDATA pSBData = NULL; - if (SB_CTL == SBType) - { + if (SB_CTL == SBType) + { return SendMessageW(Wnd, SBM_GETSCROLLINFO, 0, (LPARAM) Info); } diff --git a/dll/win32/user32/controls/static.c b/dll/win32/user32/controls/static.c index df8b7bf3ef5..db0f4408980 100644 --- a/dll/win32/user32/controls/static.c +++ b/dll/win32/user32/controls/static.c @@ -296,23 +296,25 @@ static HANDLE STATIC_GetImage( HWND hwnd, WPARAM wParam, DWORD style ) * * Load the icon for an SS_ICON control. */ -static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style ) +static HICON STATIC_LoadIconA( HINSTANCE hInstance, LPCSTR name, DWORD style ) { - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); - if ((style & SS_REALSIZEIMAGE) != 0) + HICON hicon = 0; + + if (hInstance && ((ULONG_PTR)hInstance >> 16)) { - return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED); - } - else - { - HICON hicon = LoadIconA( hInstance, name ); - if (!hicon) hicon = LoadCursorA( hInstance, name ); - if (!hicon) hicon = LoadIconA( 0, name ); - /* Windows doesn't try to load a standard cursor, - probably because most IDs for standard cursors conflict - with the IDs for standard icons anyway */ - return hicon; + if ((style & SS_REALSIZEIMAGE) != 0) + hicon = LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED); + else + { + hicon = LoadIconA( hInstance, name ); + if (!hicon) hicon = LoadCursorA( hInstance, name ); + } } + if (!hicon) hicon = LoadIconA( 0, name ); + /* Windows doesn't try to load a standard cursor, + probably because most IDs for standard cursors conflict + with the IDs for standard icons anyway */ + return hicon; } /*********************************************************************** @@ -320,48 +322,27 @@ static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style ) * * Load the icon for an SS_ICON control. */ -static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name, DWORD style ) +static HICON STATIC_LoadIconW( HINSTANCE hInstance, LPCWSTR name, DWORD style ) { - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); - if ((style & SS_REALSIZEIMAGE) != 0) + HICON hicon = 0; + + if (hInstance && ((ULONG_PTR)hInstance >> 16)) { - return LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED); - } - else - { - HICON hicon = LoadIconW( hInstance, name ); - if (!hicon) hicon = LoadCursorW( hInstance, name ); - if (!hicon) hicon = LoadIconW( 0, name ); - /* Windows doesn't try to load a standard cursor, - probably because most IDs for standard cursors conflict - with the IDs for standard icons anyway */ - return hicon; + if ((style & SS_REALSIZEIMAGE) != 0) + hicon = LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED); + else + { + hicon = LoadIconW( hInstance, name ); + if (!hicon) hicon = LoadCursorW( hInstance, name ); + } } + if (!hicon) hicon = LoadIconW( 0, name ); + /* Windows doesn't try to load a standard cursor, + probably because most IDs for standard cursors conflict + with the IDs for standard icons anyway */ + return hicon; } -/*********************************************************************** - * STATIC_LoadBitmapA - * - * Load the bitmap for an SS_BITMAP control. - */ -static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name ) -{ - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); - /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */ - return LoadBitmapA( hInstance, name ); -} - -/*********************************************************************** - * STATIC_LoadBitmapW - * - * Load the bitmap for an SS_BITMAP control. - */ -static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name ) -{ - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); - /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */ - return LoadBitmapW( hInstance, name ); -} /*********************************************************************** * STATIC_TryPaintFcn @@ -513,6 +494,7 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, { LPCSTR textA; LPCWSTR textW; + HINSTANCE hInstance; if (full_style & SS_SUNKEN) SetWindowLongPtrW( hwnd, GWL_EXSTYLE, @@ -527,26 +509,30 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, { textA = ((LPCREATESTRUCTA)lParam)->lpszName; textW = NULL; + } + hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); + switch (style) { case SS_ICON: { HICON hIcon; - if(unicode) - hIcon = STATIC_LoadIconW(hwnd, textW, full_style); + if(unicode ) + hIcon = STATIC_LoadIconW(hInstance, textW, full_style); else - hIcon = STATIC_LoadIconA(hwnd, textA, full_style); + hIcon = STATIC_LoadIconA(hInstance, textA, full_style); STATIC_SetIcon(hwnd, hIcon, full_style); } break; case SS_BITMAP: + if ((ULONG_PTR)hInstance >> 16) { HBITMAP hBitmap; if(unicode) - hBitmap = STATIC_LoadBitmapW(hwnd, textW); + hBitmap = LoadBitmapW(hInstance, textW); else - hBitmap = STATIC_LoadBitmapA(hwnd, textA); + hBitmap = LoadBitmapA(hInstance, textA); STATIC_SetBitmap(hwnd, hBitmap, full_style); } break; @@ -575,8 +561,8 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, if (hasTextStyle( full_style )) { SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, wParam ); - if (LOWORD(lParam)) - RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN ); + if (LOWORD(lParam)) + RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN ); } break; @@ -608,9 +594,7 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, case STM_GETIMAGE: return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style ); -#ifndef __REACTOS__ - case STM_GETICON16: -#endif + case STM_GETICON: return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style ); @@ -636,9 +620,6 @@ LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, STATIC_TryPaintFcn( hwnd, full_style ); break; -#ifndef __REACTOS__ - case STM_SETICON16: -#endif case STM_SETICON: lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style ); STATIC_TryPaintFcn( hwnd, full_style ); diff --git a/dll/win32/user32/windows/dialog.c b/dll/win32/user32/windows/dialog.c index 1f2720e54e9..eec7b45512f 100644 --- a/dll/win32/user32/windows/dialog.c +++ b/dll/win32/user32/windows/dialog.c @@ -560,6 +560,12 @@ INT DIALOG_DoDialogBox( HWND hwnd, HWND owner ) DispatchMessageW( &msg ); } if (dlgInfo->flags & DF_END) break; + + if (bFirstEmpty && msg.message == WM_TIMER) + { + ShowWindow( hwnd, SW_SHOWNORMAL ); + bFirstEmpty = FALSE; + } } } if (dlgInfo->flags & DF_OWNERENABLED) DIALOG_EnableOwner( owner ); @@ -968,10 +974,13 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, if (dlgProc) { - if (SendMessageW( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ) && + HWND focus = GetNextDlgTabItem( hwnd, 0, FALSE ); + if (SendMessageW( hwnd, WM_INITDIALOG, (WPARAM)focus, param ) && ((~template.style & DS_CONTROL) || (template.style & WS_VISIBLE))) { - /* By returning TRUE, app has requested a default focus assignment */ + /* By returning TRUE, app has requested a default focus assignment. + * WM_INITDIALOG may have changed the tab order, so find the first + * tabstop control again. */ dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE); if( dlgInfo->hwndFocus ) SetFocus( dlgInfo->hwndFocus ); diff --git a/dll/win32/user32/windows/mdi.c b/dll/win32/user32/windows/mdi.c index fcf053ce43d..cde115d6a14 100644 --- a/dll/win32/user32/windows/mdi.c +++ b/dll/win32/user32/windows/mdi.c @@ -100,7 +100,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(mdi); typedef struct { + /* At some points, particularly when switching MDI children, active and + * maximized MDI children may be not the same window, so we need to track + * them separately. + * The only place where we switch to/from maximized state is DefMDIChildProc + * WM_SIZE/SIZE_MAXIMIZED handler. We get that notification only after the + * ShowWindow(SW_SHOWMAXIMIZED) request, therefore window is guaranteed to + * be visible at the time we get the notification, and it's safe to assume + * that hwndChildMaximized is always visible. + * If the app plays games with WS_VISIBLE, WS_MAXIMIZE or any other window + * states it must keep coherency with USER32 on its own. This is true for + * Windows as well. + */ UINT nActiveChildren; + HWND hwndChildMaximized; HWND hwndActiveChild; HWND *child; /* array of tracked children */ HMENU hFrameMenu; @@ -116,15 +129,13 @@ typedef struct //static HBITMAP hBmpClose = 0; /* ----------------- declarations ----------------- */ -static void MDI_UpdateFrameText( HWND, HWND, LPCWSTR); +static void MDI_UpdateFrameText( HWND, HWND, BOOL, LPCWSTR); static BOOL MDI_AugmentFrameMenu( HWND, HWND ); static BOOL MDI_RestoreFrameMenu( HWND, HWND, HBITMAP ); static LONG MDI_ChildActivate( HWND, HWND ); static LRESULT MDI_RefreshMenu(MDICLIENTINFO *); static HWND MDI_MoreWindowsDialog(HWND); -//static LRESULT WINAPI MDIClientWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ); -//static LRESULT WINAPI MDIClientWndProcW( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ); HWND* WIN_ListChildren (HWND hWndparent) { @@ -220,13 +231,15 @@ static MDICLIENTINFO *get_client_info( HWND client ) WND *win = WIN_GetPtr( client ); if (win) { - if (win == WND_OTHER_PROCESS) + if (win == WND_OTHER_PROCESS || win == WND_DESKTOP) { - if (IsWindow(client)) ERR( "client %p belongs to other process\n", client ); + if (IsWindow(client)) WARN( "client %p belongs to other process\n", client ); return NULL; } - if (win->cbWndExtra < sizeof(MDICLIENTINFO)) WARN( "%p is not an MDI client\n", client ); - else ret = (MDICLIENTINFO *)win->wExtra; + if (win->flags & WIN_ISMDICLIENT) + ret = (MDICLIENTINFO *)win->wExtra; + else + WARN( "%p is not an MDI client\n", client ); WIN_ReleasePtr( win ); } return ret; @@ -247,7 +260,6 @@ static BOOL is_close_enabled(HWND hwnd, HMENU hSysMenu) return TRUE; } - /********************************************************************** * MDI_GetWindow * @@ -343,12 +355,14 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame, if (!(ci = get_client_info( hwnd ))) return 0; + TRACE("old frame menu %p, old window menu %p\n", ci->hFrameMenu, ci->hWindowMenu); + if (hmenuFrame) { if (hmenuFrame == ci->hFrameMenu) return (LRESULT)hmenuFrame; - if (IsZoomed(ci->hwndActiveChild)) - MDI_RestoreFrameMenu( hwndFrame, ci->hwndActiveChild, ci->hBmpClose ); + if (ci->hwndChildMaximized) + MDI_RestoreFrameMenu( hwndFrame, ci->hwndChildMaximized, ci->hBmpClose ); } if( hmenuWindow && hmenuWindow != ci->hWindowMenu ) @@ -382,8 +396,8 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame, HMENU oldFrameMenu = ci->hFrameMenu; ci->hFrameMenu = hmenuFrame; - if (IsZoomed(ci->hwndActiveChild) && (GetWindowLongPtrW(ci->hwndActiveChild, GWL_STYLE) & WS_VISIBLE)) - MDI_AugmentFrameMenu( hwndFrame, ci->hwndActiveChild ); + if (ci->hwndChildMaximized) + MDI_AugmentFrameMenu( hwndFrame, ci->hwndChildMaximized ); return (LRESULT)oldFrameMenu; } @@ -396,8 +410,8 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame, * that the "if" to this "else" wouldn't catch the need to * augment the frame menu. */ - if( IsZoomed(ci->hwndActiveChild) ) - MDI_AugmentFrameMenu( hwndFrame, ci->hwndActiveChild ); + if( ci->hwndChildMaximized ) + MDI_AugmentFrameMenu( hwndFrame, ci->hwndChildMaximized ); } return 0; @@ -577,12 +591,15 @@ static LRESULT MDIDestroyChild( HWND client, MDICLIENTINFO *ci, else { ShowWindow(child, SW_HIDE); - if (IsZoomed(child)) + if (child == ci->hwndChildMaximized) { - MDI_RestoreFrameMenu(GetParent(client), child, ci->hBmpClose); - MDI_UpdateFrameText(GetParent(client), client, NULL); + HWND frame = GetParent(client); + MDI_RestoreFrameMenu(frame, child, ci->hBmpClose); + ci->hwndChildMaximized = 0; + MDI_UpdateFrameText(frame, client, TRUE, NULL); } - MDI_ChildActivate(client, 0); + if (flagDestroy) + MDI_ChildActivate(client, 0); } } @@ -613,10 +630,9 @@ static LRESULT MDIDestroyChild( HWND client, MDICLIENTINFO *ci, } } - SendMessageW(client, WM_MDIREFRESHMENU, 0, 0); - if (flagDestroy) { + SendMessageW(client, WM_MDIREFRESHMENU, 0, 0); MDI_PostUpdate(GetParent(child), ci, SB_BOTH+1); DestroyWindow(child); } @@ -663,7 +679,13 @@ static LONG MDI_ChildActivate( HWND client, HWND child ) if( isActiveFrameWnd ) { SendMessageW( child, WM_NCACTIVATE, TRUE, 0L); - SetFocus( client ); + /* Let the client window manage focus for children, but if the focus + * is already on the client (for instance this is the 1st child) then + * SetFocus won't work. It appears that Windows sends WM_SETFOCUS + * manually in this case. + */ + if (SetFocus( client ) == client) + SendMessageW( client, WM_SETFOCUS, (WPARAM)client, 0 ); } SendMessageW( child, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, (LPARAM)child ); @@ -715,8 +737,8 @@ static LONG MDICascade( HWND client, MDICLIENTINFO *ci ) BOOL has_icons = FALSE; int i, total; - if (IsZoomed(ci->hwndActiveChild)) - SendMessageW(client, WM_MDIRESTORE, (WPARAM)ci->hwndActiveChild, 0); + if (ci->hwndChildMaximized) + SendMessageW(client, WM_MDIRESTORE, (WPARAM)ci->hwndChildMaximized, 0); if (ci->nActiveChildren == 0) return 0; @@ -745,13 +767,17 @@ static LONG MDICascade( HWND client, MDICLIENTINFO *ci ) /* walk the list (backwards) and move windows */ for (i = total - 1; i >= 0; i--) { - MDI_CalcDefaultChildPos(client, n++, pos, delta, NULL); + LONG style; + LONG posOptions = SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER; + MDI_CalcDefaultChildPos(client, n++, pos, delta, NULL); TRACE("move %p to (%ld,%ld) size [%ld,%ld]\n", win_array[i], pos[0].x, pos[0].y, pos[1].x, pos[1].y); + style = GetWindowLongW(win_array[i], GWL_STYLE); + if (!(style & WS_SIZEBOX)) posOptions |= SWP_NOSIZE; SetWindowPos( win_array[i], 0, pos[0].x, pos[0].y, pos[1].x, pos[1].y, - SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); + posOptions); } } HeapFree( GetProcessHeap(), 0, win_array ); @@ -769,8 +795,8 @@ static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam ) int i, total; BOOL has_icons = FALSE; - if (IsZoomed(ci->hwndActiveChild)) - SendMessageW(client, WM_MDIRESTORE, (WPARAM)ci->hwndActiveChild, 0); + if (ci->hwndChildMaximized) + SendMessageW(client, WM_MDIRESTORE, (WPARAM)ci->hwndChildMaximized, 0); if (ci->nActiveChildren == 0) return; @@ -831,8 +857,11 @@ static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam ) y = 0; for (r = 1; r <= rows && *pWnd; r++, i++) { - SetWindowPos(*pWnd, 0, x, y, xsize, ysize, - SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); + LONG posOptions = SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER; + LONG style = GetWindowLongW(win_array[i], GWL_STYLE); + if (!(style & WS_SIZEBOX)) posOptions |= SWP_NOSIZE; + + SetWindowPos(*pWnd, 0, x, y, xsize, ysize, posOptions); y += ysize; pWnd++; } @@ -854,23 +883,26 @@ static BOOL MDI_AugmentFrameMenu( HWND frame, HWND hChild ) HMENU menu = GetMenu( frame ); HMENU hSysPopup = 0; HBITMAP hSysMenuBitmap = 0; + HICON hIcon; INT nItems; UINT iId; - HICON hIcon; TRACE("frame %p,child %p\n",frame,hChild); if( !menu ) return 0; - +//// ReactOS start /* if the system buttons already exist do not add them again */ nItems = GetMenuItemCount(menu) - 1; iId = GetMenuItemID(menu,nItems) ; if (iId == SC_RESTORE || iId == SC_CLOSE) - return 0; + return 0; /* create a copy of sysmenu popup and insert it into frame menu bar */ if (!(hSysPopup = GetSystemMenu(hChild, FALSE))) - return 0; + { + TRACE("child %p doesn't have a system menu\n", hChild); + return 0; + } AppendMenuW(menu, MF_HELP | MF_BITMAP, SC_MINIMIZE, (LPCWSTR)HBMMENU_MBAR_MINIMIZE ) ; @@ -886,6 +918,7 @@ static BOOL MDI_AugmentFrameMenu( HWND frame, HWND hChild ) hIcon = (HICON)GetClassLongPtrW(hChild, GCLP_HICON); if (!hIcon) hIcon = LoadIconW(NULL, IDI_APPLICATION); +//// End if (hIcon) { HDC hMemDC; @@ -938,15 +971,17 @@ static BOOL MDI_RestoreFrameMenu( HWND frame, HWND hChild, HBITMAP hBmpClose ) { MENUITEMINFOW menuInfo; HMENU menu = GetMenu( frame ); - INT nItems = GetMenuItemCount(menu) - 1; - UINT iId = GetMenuItemID(menu,nItems) ; + INT nItems; + UINT iId; - TRACE("frame %p,child %p,nIt=%d,iId=%d\n",frame,hChild,nItems,iId); + TRACE("frame %p,child %p\n",frame, hChild); if( !menu ) return 0; /* if there is no system buttons then nothing to do */ - if(!(iId == SC_RESTORE || iId == SC_CLOSE) ) + nItems = GetMenuItemCount(menu) - 1; + iId = GetMenuItemID(menu,nItems) ; + if( !(iId == SC_RESTORE || iId == SC_CLOSE) ) return 0; /* @@ -994,7 +1029,7 @@ static BOOL MDI_RestoreFrameMenu( HWND frame, HWND hChild, HBITMAP hBmpClose ) * * Note: lpTitle can be NULL */ -static void MDI_UpdateFrameText( HWND frame, HWND hClient, LPCWSTR lpTitle ) +static void MDI_UpdateFrameText( HWND frame, HWND hClient, BOOL repaint, LPCWSTR lpTitle ) { WCHAR lpBuffer[MDI_MAXTITLELENGTH+1]; MDICLIENTINFO *ci = get_client_info( hClient ); @@ -1019,7 +1054,7 @@ static void MDI_UpdateFrameText( HWND frame, HWND hClient, LPCWSTR lpTitle ) if (ci->frameTitle) { - if (IsZoomed(ci->hwndActiveChild) && IsWindowVisible(ci->hwndActiveChild)) + if (ci->hwndChildMaximized) { /* combine frame title and child title if possible */ @@ -1048,6 +1083,10 @@ static void MDI_UpdateFrameText( HWND frame, HWND hClient, LPCWSTR lpTitle ) lpBuffer[0] = '\0'; DefWindowProcW( frame, WM_SETTEXT, 0, (LPARAM)lpBuffer ); + + if (repaint) + SetWindowPos( frame, 0,0,0,0,0, SWP_FRAMECHANGED | + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER ); } @@ -1057,63 +1096,43 @@ static void MDI_UpdateFrameText( HWND frame, HWND hClient, LPCWSTR lpTitle ) /********************************************************************** * MDIClientWndProc_common */ -LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam, BOOL unicode ) +LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, BOOL unicode ) { MDICLIENTINFO *ci = NULL; TRACE("%p %04x (%s) %08lx %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam); - if (WM_NCCREATE != message && NULL == (ci = get_client_info(hwnd))) + if (!(ci = get_client_info(hwnd))) { - return 0; - } - -#ifndef __REACTOS__ - if (!(ci = get_client_info( hwnd ))) return 0; + if (message == WM_NCCREATE) + { +#ifdef __REACTOS__ + if (!(ci = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ci)))) + return FALSE; + SetWindowLongPtrW( hwnd, 0, (LONG_PTR)ci ); + ci->hBmpClose = 0; +#else + WND *wndPtr = WIN_GetPtr( hwnd ); + wndPtr->flags |= WIN_ISMDICLIENT; + WIN_ReleasePtr( wndPtr ); #endif + } + return unicode ? DefWindowProcW( hwnd, message, wParam, lParam ) : + DefWindowProcA( hwnd, message, wParam, lParam ); + } switch (message) { -#ifdef __REACTOS__ - case WM_NCCREATE: - if (!(ci = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ci)))) - return FALSE; - SetWindowLongPtrW( hwnd, 0, (LONG_PTR)ci ); - ci->hBmpClose = 0; - return TRUE; -#endif - case WM_CREATE: { /* Since we are using only cs->lpCreateParams, we can safely * cast to LPCREATESTRUCTA here */ - LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam; -#ifndef __REACTOS__ - WND *wndPtr = WIN_GetPtr( hwnd ); + LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam; + LPCLIENTCREATESTRUCT ccs = (LPCLIENTCREATESTRUCT)cs->lpCreateParams; - wndPtr->flags |= WIN_ISMDICLIENT; -#endif - /* Translation layer doesn't know what's in the cs->lpCreateParams - * so we have to keep track of what environment we're in. */ - -#ifndef __REACTOS__ - if( wndPtr->flags & WIN_ISWIN32 ) -#endif - { - LPCLIENTCREATESTRUCT ccs = (LPCLIENTCREATESTRUCT)cs->lpCreateParams; - ci->hWindowMenu = ccs->hWindowMenu; - ci->idFirstChild = ccs->idFirstChild; - } -#ifndef __REACTOS__ - else - { - LPCLIENTCREATESTRUCT16 ccs = MapSL((SEGPTR)cs->lpCreateParams); - ci->hWindowMenu = HMENU_32(ccs->hWindowMenu); - ci->idFirstChild = ccs->idFirstChild; - } - WIN_ReleasePtr( wndPtr ); -#endif + ci->hWindowMenu = ccs->hWindowMenu; + ci->idFirstChild = ccs->idFirstChild; + ci->hwndChildMaximized = 0; ci->child = NULL; ci->nActiveChildren = 0; ci->nTotalCreated = 0; @@ -1130,8 +1149,8 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, case WM_DESTROY: { - if( IsZoomed(ci->hwndActiveChild) ) - MDI_RestoreFrameMenu(GetParent(hwnd), ci->hwndActiveChild, ci->hBmpClose); + if( ci->hwndChildMaximized ) + MDI_RestoreFrameMenu(GetParent(hwnd), ci->hwndChildMaximized, ci->hBmpClose); ci->nActiveChildren = 0; MDI_RefreshMenu(ci); @@ -1147,7 +1166,8 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, case WM_MDIACTIVATE: { - MDI_SwitchActiveChild( ci, (HWND)wParam, TRUE ); + if( ci->hwndActiveChild != (HWND)wParam ) + SetWindowPos((HWND)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE); return 0; } @@ -1177,18 +1197,13 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, hwnd, 0, csA->hOwner, (LPVOID)csA->lParam); } - - if (IsZoomed(ci->hwndActiveChild)) - { - MDI_AugmentFrameMenu(GetParent(hwnd), child); - MDI_UpdateFrameText(GetParent(hwnd), hwnd, NULL); - } return (LRESULT)child; } return 0; case WM_MDIDESTROY: return MDIDestroyChild( hwnd, ci, (HWND)wParam, TRUE ); + case WM_MDIGETACTIVE: if (lParam) *(BOOL *)lParam = IsZoomed(ci->hwndActiveChild); return (LRESULT)ci->hwndActiveChild; @@ -1212,7 +1227,7 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, } case WM_MDIRESTORE: - SendMessageW( (HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0); + ShowWindow( (HWND)wParam, SW_SHOWNORMAL ); return 0; case WM_MDISETMENU: @@ -1251,11 +1266,15 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, case WM_CREATE: if (GetWindowLongPtrW((HWND)lParam, GWL_EXSTYLE) & WS_EX_MDICHILD) { + // ReactOS See rev 33503 if (!ci->child) ci->child = HeapAlloc(GetProcessHeap(), 0, sizeof(HWND)); else ci->child = HeapReAlloc(GetProcessHeap(), 0, ci->child, sizeof(HWND) * (ci->nActiveChildren + 1)); + TRACE("Adding MDI child %p, # of children %d\n", + (HWND)lParam, ci->nActiveChildren); + if (ci->child != NULL) { ci->child[ci->nActiveChildren] = (HWND)lParam; @@ -1279,12 +1298,14 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, SetWindowPos(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE ); break; } + + case WM_DESTROY: + return MDIDestroyChild( hwnd, ci, WIN_GetFullHandle( (HWND)lParam ), FALSE ); } return 0; case WM_SIZE: - if( IsWindow(ci->hwndActiveChild) && IsZoomed(ci->hwndActiveChild) && - (GetWindowLongPtrW(ci->hwndActiveChild, GWL_STYLE) & WS_VISIBLE) ) + if( ci->hwndActiveChild && IsZoomed(ci->hwndActiveChild) ) { RECT rect; @@ -1292,7 +1313,6 @@ LRESULT WINAPI MDIClientWndProc_common( HWND hwnd, UINT message, rect.top = 0; rect.right = LOWORD(lParam); rect.bottom = HIWORD(lParam); - AdjustWindowRectEx(&rect, GetWindowLongPtrA(ci->hwndActiveChild, GWL_STYLE), 0, GetWindowLongPtrA(ci->hwndActiveChild, GWL_EXSTYLE) ); MoveWindow(ci->hwndActiveChild, rect.left, rect.top, @@ -1351,7 +1371,7 @@ LRESULT WINAPI DefFrameProcA( HWND hwnd, HWND hwndMDIClient, if (text == NULL) return 0; MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, text, len ); - MDI_UpdateFrameText( hwnd, hwndMDIClient, text ); + MDI_UpdateFrameText( hwnd, hwndMDIClient, FALSE, text ); HeapFree( GetProcessHeap(), 0, text ); } return 1; /* success. FIXME: check text length */ @@ -1389,7 +1409,7 @@ LRESULT WINAPI DefFrameProcW( HWND hwnd, HWND hwndMDIClient, if (id < ci->idFirstChild || id >= ci->idFirstChild + ci->nActiveChildren) { if( (id - 0xf000) & 0xf00f ) break; - if( !IsZoomed(ci->hwndActiveChild) ) break; + if( !ci->hwndChildMaximized ) break; switch( id ) { case SC_CLOSE: @@ -1426,7 +1446,7 @@ LRESULT WINAPI DefFrameProcW( HWND hwnd, HWND hwndMDIClient, break; case WM_SETTEXT: - MDI_UpdateFrameText( hwnd, hwndMDIClient, (LPWSTR)lParam ); + MDI_UpdateFrameText( hwnd, hwndMDIClient, FALSE, (LPWSTR)lParam ); return 1; /* success. FIXME: check text length */ case WM_SETFOCUS: @@ -1482,8 +1502,8 @@ LRESULT WINAPI DefMDIChildProcA( HWND hwnd, UINT message, { case WM_SETTEXT: DefWindowProcA(hwnd, message, wParam, lParam); - if( ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild) ) - MDI_UpdateFrameText( GetParent(client), client, NULL ); + if( ci->hwndChildMaximized == hwnd ) + MDI_UpdateFrameText( GetParent(client), client, TRUE, NULL ); return 1; /* success. FIXME: check text length */ case WM_GETMINMAXINFO: @@ -1516,6 +1536,7 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, MDICLIENTINFO *ci = get_client_info( client ); TRACE("%p %04x (%s) %08lx %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam); + hwnd = WIN_GetFullHandle( hwnd ); if (!ci) return DefWindowProcW( hwnd, message, wParam, lParam ); @@ -1523,8 +1544,8 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, { case WM_SETTEXT: DefWindowProcW(hwnd, message, wParam, lParam); - if( ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild) ) - MDI_UpdateFrameText( GetParent(client), client, NULL ); + if( ci->hwndChildMaximized == hwnd ) + MDI_UpdateFrameText( GetParent(client), client, TRUE, NULL ); return 1; /* success. FIXME: check text length */ case WM_GETMINMAXINFO: @@ -1538,22 +1559,27 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, SendMessageW( client, WM_MDIDESTROY, (WPARAM)hwnd, 0 ); return 0; + case WM_SETFOCUS: + if (ci->hwndActiveChild != hwnd) + MDI_ChildActivate( client, hwnd ); + break; + case WM_CHILDACTIVATE: MDI_ChildActivate( client, hwnd ); return 0; case WM_SYSCOMMAND: - switch( wParam ) + switch( wParam & 0xfff0) { case SC_MOVE: - if( ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild)) + if( ci->hwndChildMaximized == hwnd ) return 0; break; case SC_RESTORE: case SC_MINIMIZE: break; case SC_MAXIMIZE: - if (ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild)) + if (ci->hwndChildMaximized == hwnd ) return SendMessageW( GetParent(client), message, wParam, lParam); break; case SC_NEXTWINDOW: @@ -1569,25 +1595,60 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, #ifndef __REACTOS__ case WM_SETVISIBLE: #endif - if (IsZoomed(ci->hwndActiveChild)) ci->mdiFlags &= ~MDIF_NEEDUPDATE; + if (ci->hwndChildMaximized) ci->mdiFlags &= ~MDIF_NEEDUPDATE; else MDI_PostUpdate(client, ci, SB_BOTH+1); break; case WM_SIZE: - if( hwnd == ci->hwndActiveChild ) - { - if( wParam == SIZE_MAXIMIZED ) - { - TRACE("maximizing child %p\n", hwnd ); + /* This is the only place where we switch to/from maximized state */ + /* do not change */ + TRACE("current active %p, maximized %p\n", ci->hwndActiveChild, ci->hwndChildMaximized); - MDI_AugmentFrameMenu( GetParent(client), hwnd ); - } - else - MDI_RestoreFrameMenu( GetParent(client), hwnd , ci->hBmpClose); + if( ci->hwndChildMaximized == hwnd && wParam != SIZE_MAXIMIZED) + { + HWND frame; + + ci->hwndChildMaximized = 0; + + frame = GetParent(client); + MDI_RestoreFrameMenu( frame, hwnd, ci->hBmpClose ); + MDI_UpdateFrameText( frame, client, TRUE, NULL ); } - MDI_UpdateFrameText( GetParent(client), client, NULL ); - MDI_RefreshMenu(ci); + if( wParam == SIZE_MAXIMIZED ) + { + HWND frame, hMaxChild = ci->hwndChildMaximized; + + if( hMaxChild == hwnd ) break; + + if( hMaxChild) + { + SendMessageW( hMaxChild, WM_SETREDRAW, FALSE, 0 ); + + MDI_RestoreFrameMenu( GetParent(client), hMaxChild, ci->hBmpClose ); + ShowWindow( hMaxChild, SW_SHOWNOACTIVATE ); + + SendMessageW( hMaxChild, WM_SETREDRAW, TRUE, 0 ); + } + + TRACE("maximizing child %p\n", hwnd ); + + /* keep track of the maximized window. */ + ci->hwndChildMaximized = hwnd; /* !!! */ + + frame = GetParent(client); + MDI_AugmentFrameMenu( frame, hwnd ); + MDI_UpdateFrameText( frame, client, TRUE, NULL ); + } + + if( wParam == SIZE_MINIMIZED ) + { + HWND switchTo = MDI_GetWindow( ci, hwnd, TRUE, WS_MINIMIZE ); + + if (!switchTo) switchTo = hwnd; + SendMessageW( switchTo, WM_CHILDACTIVATE, 0, 0 ); + } + MDI_PostUpdate(client, ci, SB_BOTH+1); break; @@ -1613,7 +1674,7 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, case WM_SYSCHAR: if (wParam == '-') { - SendMessageW( hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (DWORD)VK_SPACE); + SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE); return 0; } break; @@ -1716,7 +1777,7 @@ BOOL WINAPI TranslateMDISysAccel( HWND hwndClient, LPMSG msg ) return 0; } TRACE("wParam = %04lx\n", wParam); - SendMessageW(ci->hwndActiveChild, WM_SYSCOMMAND, wParam, (LPARAM)msg->wParam); + SendMessageW(ci->hwndActiveChild, WM_SYSCOMMAND, wParam, msg->wParam); return 1; } } @@ -1903,6 +1964,14 @@ CascadeWindows (HWND hwndParent, UINT wFlags, LPCRECT lpRect, return 0; } +/*********************************************************************** + * CascadeChildWindows (USER32.@) + */ +WORD WINAPI CascadeChildWindows( HWND parent, UINT flags ) +{ + return CascadeWindows( parent, flags, NULL, 0, NULL ); +} + /****************************************************************************** * TileWindows (USER32.@) Tiles MDI child windows @@ -1919,6 +1988,15 @@ TileWindows (HWND hwndParent, UINT wFlags, LPCRECT lpRect, return 0; } +/*********************************************************************** + * TileChildWindows (USER32.@) + */ +WORD WINAPI TileChildWindows( HWND parent, UINT flags ) +{ + return TileWindows( parent, flags, NULL, 0, NULL ); +} + + /************************************************************************ * "More Windows..." functionality */ @@ -2022,7 +2100,6 @@ static HWND MDI_MoreWindowsDialog(HWND hwnd) if (template == 0) return 0; - return (HWND) DialogBoxIndirectParamA(User32Instance, - (const DLGTEMPLATE*) template, - hwnd, MDI_MoreWindowsDlgProc, (LPARAM) hwnd); + return (HWND) DialogBoxIndirectParamA(User32Instance, template, hwnd, + MDI_MoreWindowsDlgProc, (LPARAM) hwnd); } diff --git a/dll/win32/user32/windows/window.c b/dll/win32/user32/windows/window.c index 5fbcd0281ba..6ed38cce020 100644 --- a/dll/win32/user32/windows/window.c +++ b/dll/win32/user32/windows/window.c @@ -103,17 +103,6 @@ SwitchToThisWindow(HWND hwnd, BOOL fUnknown) } -/* - * @implemented - */ -WORD -WINAPI -CascadeChildWindows ( HWND hWndParent, WORD wFlags ) -{ - return CascadeWindows(hWndParent, wFlags, NULL, 0, NULL); -} - - /* * @implemented */ @@ -1982,16 +1971,6 @@ ScrollWindowEx(HWND hWnd, flags); } -/* - * @implemented - */ -WORD -WINAPI -TileChildWindows(HWND hWndParent, WORD wFlags) -{ - return TileWindows(hWndParent, wFlags, NULL, 0, NULL); -} - /* * @implemented */ diff --git a/dll/win32/uxtheme/draw.c b/dll/win32/uxtheme/draw.c index 9e220254db3..17900f8352b 100644 --- a/dll/win32/uxtheme/draw.c +++ b/dll/win32/uxtheme/draw.c @@ -56,7 +56,7 @@ HRESULT WINAPI EnableThemeDialogTexture(HWND hwnd, DWORD dwFlags) TRACE("(%p,0x%08x\n", hwnd, dwFlags); res = SetPropW (hwnd, (LPCWSTR)MAKEINTATOM(atDialogThemeEnabled), - (HANDLE)(dwFlags|0x80000000)); + UlongToHandle(dwFlags|0x80000000)); /* 0x80000000 serves as a "flags set" flag */ if (!res) return HRESULT_FROM_WIN32(GetLastError()); @@ -74,8 +74,7 @@ BOOL WINAPI IsThemeDialogTextureEnabled(HWND hwnd) DWORD dwDialogTextureFlags; TRACE("(%p)\n", hwnd); - dwDialogTextureFlags = (DWORD)GetPropW (hwnd, - (LPCWSTR)MAKEINTATOM(atDialogThemeEnabled)); + dwDialogTextureFlags = HandleToUlong( GetPropW( hwnd, (LPCWSTR)MAKEINTATOM(atDialogThemeEnabled) )); if (dwDialogTextureFlags == 0) /* Means EnableThemeDialogTexture wasn't called for this dialog */ return TRUE; diff --git a/dll/win32/uxtheme/msstyles.c b/dll/win32/uxtheme/msstyles.c index 825645d2f4b..0adb70d529a 100644 --- a/dll/win32/uxtheme/msstyles.c +++ b/dll/win32/uxtheme/msstyles.c @@ -364,7 +364,10 @@ static BOOL MSSTYLES_ParseIniSectionName(LPCWSTR lpSection, DWORD dwLen, LPWSTR lstrcpynW(part, comp, sizeof(part)/sizeof(part[0])); comp = tmp; /* now get the state */ - *strchrW(comp, ')') = 0; + tmp = strchrW(comp, ')'); + if (!tmp) + return FALSE; + *tmp = 0; lstrcpynW(state, comp, sizeof(state)/sizeof(state[0])); } else { @@ -378,7 +381,10 @@ static BOOL MSSTYLES_ParseIniSectionName(LPCWSTR lpSection, DWORD dwLen, LPWSTR lstrcpynW(szClassName, comp, MAX_THEME_CLASS_NAME); comp = tmp; /* now get the state */ - *strchrW(comp, ')') = 0; + tmp = strchrW(comp, ')'); + if (!tmp) + return FALSE; + *tmp = 0; lstrcpynW(state, comp, sizeof(state)/sizeof(state[0])); } else { @@ -1087,7 +1093,7 @@ static BOOL prepare_alpha (HBITMAP bmp, BOOL* hasAlpha) *hasAlpha = TRUE; p = dib.dsBm.bmBits; - n = abs(dib.dsBmih.biHeight) * dib.dsBmih.biWidth; + n = dib.dsBmih.biHeight * dib.dsBmih.biWidth; /* AlphaBlend() wants premultiplied alpha, so do that now */ while (n-- > 0) { diff --git a/dll/win32/uxtheme/system.c b/dll/win32/uxtheme/system.c index 28395393729..b84e978dba8 100644 --- a/dll/win32/uxtheme/system.c +++ b/dll/win32/uxtheme/system.c @@ -393,8 +393,7 @@ static void UXTHEME_RestoreSystemMetrics(void) if (RegQueryValueExW (hKey, bsp->keyName, 0, &type, (LPBYTE)&value, &count) == ERROR_SUCCESS) { - SystemParametersInfoW (bsp->spiSet, 0, (LPVOID)value, - SPIF_UPDATEINIFILE); + SystemParametersInfoW (bsp->spiSet, 0, UlongToPtr(value), SPIF_UPDATEINIFILE); } bsp++; @@ -445,9 +444,7 @@ static void UXTHEME_SaveSystemMetrics(void) DWORD value; SystemParametersInfoW (bsp->spiGet, 0, &value, 0); - SystemParametersInfoW (bsp->spiSet, 0, (LPVOID)value, - SPIF_UPDATEINIFILE); - + SystemParametersInfoW (bsp->spiSet, 0, UlongToPtr(value), SPIF_UPDATEINIFILE); bsp++; } diff --git a/dll/win32/windowscodecs/pngformat.c b/dll/win32/windowscodecs/pngformat.c index f3613637e49..22b37b063f4 100644 --- a/dll/win32/windowscodecs/pngformat.c +++ b/dll/win32/windowscodecs/pngformat.c @@ -51,6 +51,7 @@ MAKE_FUNCPTR(png_destroy_write_struct); MAKE_FUNCPTR(png_error); MAKE_FUNCPTR(png_get_bit_depth); MAKE_FUNCPTR(png_get_color_type); +MAKE_FUNCPTR(png_get_error_ptr); MAKE_FUNCPTR(png_get_image_height); MAKE_FUNCPTR(png_get_image_width); MAKE_FUNCPTR(png_get_io_ptr); @@ -58,8 +59,13 @@ MAKE_FUNCPTR(png_get_pHYs); MAKE_FUNCPTR(png_get_PLTE); MAKE_FUNCPTR(png_get_tRNS); MAKE_FUNCPTR(png_set_bgr); -MAKE_FUNCPTR(png_set_filler); +MAKE_FUNCPTR(png_set_error_fn); +#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 +MAKE_FUNCPTR(png_set_expand_gray_1_2_4_to_8); +#else MAKE_FUNCPTR(png_set_gray_1_2_4_to_8); +#endif +MAKE_FUNCPTR(png_set_filler); MAKE_FUNCPTR(png_set_gray_to_rgb); MAKE_FUNCPTR(png_set_IHDR); MAKE_FUNCPTR(png_set_pHYs); @@ -92,6 +98,7 @@ static void *load_libpng(void) LOAD_FUNCPTR(png_error); LOAD_FUNCPTR(png_get_bit_depth); LOAD_FUNCPTR(png_get_color_type); + LOAD_FUNCPTR(png_get_error_ptr); LOAD_FUNCPTR(png_get_image_height); LOAD_FUNCPTR(png_get_image_width); LOAD_FUNCPTR(png_get_io_ptr); @@ -99,8 +106,13 @@ static void *load_libpng(void) LOAD_FUNCPTR(png_get_PLTE); LOAD_FUNCPTR(png_get_tRNS); LOAD_FUNCPTR(png_set_bgr); - LOAD_FUNCPTR(png_set_filler); + LOAD_FUNCPTR(png_set_error_fn); +#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 + LOAD_FUNCPTR(png_set_expand_gray_1_2_4_to_8); +#else LOAD_FUNCPTR(png_set_gray_1_2_4_to_8); +#endif + LOAD_FUNCPTR(png_set_filler); LOAD_FUNCPTR(png_set_gray_to_rgb); LOAD_FUNCPTR(png_set_IHDR); LOAD_FUNCPTR(png_set_pHYs); @@ -120,6 +132,23 @@ static void *load_libpng(void) return libpng_handle; } +static void user_error_fn(png_structp png_ptr, png_const_charp error_message) +{ + jmp_buf *pjmpbuf; + + /* This uses setjmp/longjmp just like the default. We can't use the + * default because there's no way to access the jmp buffer in the png_struct + * that works in 1.2 and 1.4 and allows us to dynamically load libpng. */ + WARN("PNG error: %s\n", debugstr_a(error_message)); + pjmpbuf = ppng_get_error_ptr(png_ptr); + longjmp(*pjmpbuf, 1); +} + +static void user_warning_fn(png_structp png_ptr, png_const_charp warning_message) +{ + WARN("PNG warning: %s\n", debugstr_a(warning_message)); +} + typedef struct { const IWICBitmapDecoderVtbl *lpVtbl; const IWICBitmapFrameDecodeVtbl *lpFrameVtbl; @@ -226,6 +255,8 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p int num_trans; png_uint_32 transparency; png_color_16p trans_values; + jmp_buf jmpbuf; + TRACE("(%p,%p,%x)\n", iface, pIStream, cacheOptions); /* initialize libpng */ @@ -249,13 +280,14 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p } /* set up setjmp/longjmp error handling */ - if (setjmp(png_jmpbuf(This->png_ptr))) + if (setjmp(jmpbuf)) { ppng_destroy_read_struct(&This->png_ptr, &This->info_ptr, &This->end_info); HeapFree(GetProcessHeap(), 0, row_pointers); This->png_ptr = NULL; return E_FAIL; } + ppng_set_error_fn(This->png_ptr, &jmpbuf, user_error_fn, user_warning_fn); /* seek to the start of the stream */ seek.QuadPart = 0; @@ -282,7 +314,11 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p { if (bit_depth < 8) { +#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 + ppng_set_expand_gray_1_2_4_to_8(This->png_ptr); +#else ppng_set_gray_1_2_4_to_8(This->png_ptr); +#endif bit_depth = 8; } ppng_set_gray_to_rgb(This->png_ptr); @@ -849,6 +885,7 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, PngEncoder *This = encoder_from_frame(iface); png_byte **row_pointers=NULL; UINT i; + jmp_buf jmpbuf; TRACE("(%p,%u,%u,%u,%p)\n", iface, lineCount, cbStride, cbBufferSize, pbPixels); if (!This->frame_initialized || !This->width || !This->height || !This->format) @@ -858,11 +895,12 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, return E_INVALIDARG; /* set up setjmp/longjmp error handling */ - if (setjmp(png_jmpbuf(This->png_ptr))) + if (setjmp(jmpbuf)) { HeapFree(GetProcessHeap(), 0, row_pointers); return E_FAIL; } + ppng_set_error_fn(This->png_ptr, &jmpbuf, user_error_fn, user_warning_fn); if (!This->info_written) { @@ -978,16 +1016,18 @@ static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, static HRESULT WINAPI PngFrameEncode_Commit(IWICBitmapFrameEncode *iface) { PngEncoder *This = encoder_from_frame(iface); + jmp_buf jmpbuf; TRACE("(%p)\n", iface); if (!This->info_written || This->lines_written != This->height || This->frame_committed) return WINCODEC_ERR_WRONGSTATE; /* set up setjmp/longjmp error handling */ - if (setjmp(png_jmpbuf(This->png_ptr))) + if (setjmp(jmpbuf)) { return E_FAIL; } + ppng_set_error_fn(This->png_ptr, &jmpbuf, user_error_fn, user_warning_fn); ppng_write_end(This->png_ptr, This->info_ptr); @@ -1093,6 +1133,7 @@ static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface, IStream *pIStream, WICBitmapEncoderCacheOption cacheOption) { PngEncoder *This = (PngEncoder*)iface; + jmp_buf jmpbuf; TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption); @@ -1116,7 +1157,7 @@ static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface, This->stream = pIStream; /* set up setjmp/longjmp error handling */ - if (setjmp(png_jmpbuf(This->png_ptr))) + if (setjmp(jmpbuf)) { ppng_destroy_write_struct(&This->png_ptr, &This->info_ptr); This->png_ptr = NULL; @@ -1124,6 +1165,7 @@ static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface, This->stream = NULL; return E_FAIL; } + ppng_set_error_fn(This->png_ptr, &jmpbuf, user_error_fn, user_warning_fn); /* set up custom i/o handling */ ppng_set_write_fn(This->png_ptr, This, user_write_data, user_flush); diff --git a/dll/win32/wintrust/asn.c b/dll/win32/wintrust/asn.c index 002eab5374d..69c9dd3d604 100644 --- a/dll/win32/wintrust/asn.c +++ b/dll/win32/wintrust/asn.c @@ -1469,6 +1469,11 @@ struct AsnDecodeSequenceItem */ #define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1)) +#define FINALMEMBERSIZE(s, member) (sizeof(s) - offsetof(s, member)) +#define MEMBERSIZE(s, member, nextmember) \ + (offsetof(s, nextmember) - offsetof(s, member)) + + /* Decodes the items in a sequence, where the items are described in items, * the encoded data are in pbEncoded with length cbEncoded. Decodes into * pvStructInfo. nextData is a pointer to the memory location at which the @@ -1520,8 +1525,13 @@ static BOOL CRYPT_AsnDecodeSequenceItems(DWORD dwCertEncodingType, : NULL, &items[i].size); if (ret) { - /* Account for alignment padding */ - items[i].size = ALIGN_DWORD_PTR(items[i].size); + if (items[i].size < items[i].minSize) + items[i].size = items[i].minSize; + else if (items[i].size > items[i].minSize) + { + /* Account for alignment padding */ + items[i].size = ALIGN_DWORD_PTR(items[i].size); + } TRACE("item %d size: %d\n", i, items[i].size); if (nextData && items[i].hasPointer && items[i].size > items[i].minSize) @@ -2179,62 +2189,24 @@ BOOL WINAPI WVTAsn1SpcSpOpusInfoDecode(DWORD dwCertEncodingType, return ret; } -static BOOL CRYPT_AsnDecodeInteger(const BYTE *pbEncoded, - DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo) -{ - BOOL ret; - DWORD bytesNeeded, dataLen; - - if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) - { - BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); - - bytesNeeded = dataLen + sizeof(CRYPT_INTEGER_BLOB); - if (!pvStructInfo) - *pcbStructInfo = bytesNeeded; - else if (*pcbStructInfo < bytesNeeded) - { - *pcbStructInfo = bytesNeeded; - SetLastError(ERROR_MORE_DATA); - ret = FALSE; - } - else - { - CRYPT_INTEGER_BLOB *blob = pvStructInfo; - - *pcbStructInfo = bytesNeeded; - blob->cbData = dataLen; - assert(blob->pbData); - if (blob->cbData) - { - DWORD i; - - for (i = 0; i < blob->cbData; i++) - { - blob->pbData[i] = *(pbEncoded + 1 + lenBytes + - dataLen - i - 1); - } - } - } - } - return ret; -} - /* Ignores tag. Only allows integers 4 bytes or smaller in size. */ static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo) { BOOL ret; - BYTE buf[sizeof(CRYPT_INTEGER_BLOB) + sizeof(int)]; - CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; - DWORD size = sizeof(buf); + DWORD dataLen; - blob->pbData = buf + sizeof(CRYPT_INTEGER_BLOB); - ret = CRYPT_AsnDecodeInteger(pbEncoded, cbEncoded, 0, buf, &size); - if (ret) + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) { - if (!pvStructInfo) + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + + if (dataLen > sizeof(int)) + { + SetLastError(CRYPT_E_ASN1_LARGE); + ret = FALSE; + } + else if (!pvStructInfo) *pcbStructInfo = sizeof(int); else if (*pcbStructInfo < sizeof(int)) { @@ -2248,23 +2220,21 @@ static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, DWORD i; *pcbStructInfo = sizeof(int); - if (blob->pbData[blob->cbData - 1] & 0x80) + if (dataLen && pbEncoded[1 + lenBytes] & 0x80) { /* initialize to a negative value to sign-extend */ val = -1; } else val = 0; - for (i = 0; i < blob->cbData; i++) + for (i = 0; i < dataLen; i++) { val <<= 8; - val |= blob->pbData[blob->cbData - i - 1]; + val |= pbEncoded[1 + lenBytes + i]; } memcpy(pvStructInfo, &val, sizeof(int)); } } - else if (GetLastError() == ERROR_MORE_DATA) - SetLastError(CRYPT_E_ASN1_LARGE); return ret; } @@ -2284,7 +2254,7 @@ BOOL WINAPI WVTAsn1CatMemberInfoDecode(DWORD dwCertEncodingType, CRYPT_AsnDecodeBMPString, sizeof(LPWSTR), FALSE, TRUE, offsetof(CAT_MEMBERINFO, pwszSubjGuid), 0 }, { ASN_INTEGER, offsetof(CAT_MEMBERINFO, dwCertVersion), - CRYPT_AsnDecodeInt, sizeof(DWORD), + CRYPT_AsnDecodeInt, FINALMEMBERSIZE(CAT_MEMBERINFO, dwCertVersion), FALSE, FALSE, 0, 0 }, }; @@ -2317,7 +2287,8 @@ BOOL WINAPI WVTAsn1CatNameValueDecode(DWORD dwCertEncodingType, CRYPT_AsnDecodeBMPString, sizeof(LPWSTR), FALSE, TRUE, offsetof(CAT_NAMEVALUE, pwszTag), 0 }, { ASN_INTEGER, offsetof(CAT_NAMEVALUE, fdwFlags), - CRYPT_AsnDecodeInt, sizeof(DWORD), FALSE, FALSE, 0, 0 }, + CRYPT_AsnDecodeInt, MEMBERSIZE(CAT_NAMEVALUE, fdwFlags, Value), + FALSE, FALSE, 0, 0 }, { ASN_OCTETSTRING, offsetof(CAT_NAMEVALUE, Value), CRYPT_AsnDecodeOctets, sizeof(CRYPT_DER_BLOB), FALSE, TRUE, offsetof(CAT_NAMEVALUE, Value.pbData), 0 }, @@ -2391,9 +2362,11 @@ BOOL WINAPI WVTAsn1SpcFinancialCriteriaInfoDecode(DWORD dwCertEncodingType, { struct AsnDecodeSequenceItem items[] = { { ASN_BOOL, offsetof(SPC_FINANCIAL_CRITERIA, fFinancialInfoAvailable), - CRYPT_AsnDecodeBool, sizeof(BOOL), FALSE, FALSE, 0, 0 }, + CRYPT_AsnDecodeBool, MEMBERSIZE(SPC_FINANCIAL_CRITERIA, + fFinancialInfoAvailable, fMeetsCriteria), FALSE, FALSE, 0, 0 }, { ASN_BOOL, offsetof(SPC_FINANCIAL_CRITERIA, fMeetsCriteria), - CRYPT_AsnDecodeBool, sizeof(BOOL), FALSE, FALSE, 0, 0 }, + CRYPT_AsnDecodeBool, FINALMEMBERSIZE(SPC_FINANCIAL_CRITERIA, + fMeetsCriteria), FALSE, FALSE, 0, 0 }, }; ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, diff --git a/dll/win32/wintrust/crypt.c b/dll/win32/wintrust/crypt.c index d9fa5633562..c41a56b1d1a 100644 --- a/dll/win32/wintrust/crypt.c +++ b/dll/win32/wintrust/crypt.c @@ -1028,7 +1028,18 @@ static BOOL WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO *pSubjectInfo, /* app hasn't passed buffer, just get the length */ ret = ImageGetCertificateHeader(pSubjectInfo->hFile, dwIndex, &cert); if (ret) - *pcbSignedDataMsg = cert.dwLength; + { + switch (cert.wCertificateType) + { + case WIN_CERT_TYPE_X509: + case WIN_CERT_TYPE_PKCS_SIGNED_DATA: + *pcbSignedDataMsg = cert.dwLength; + break; + default: + WARN("unknown certificate type %d\n", cert.wCertificateType); + ret = FALSE; + } + } } else { @@ -1065,9 +1076,10 @@ static BOOL WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO *pSubjectInfo, *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING; break; default: - FIXME("don't know what to do for encoding type %d\n", + WARN("don't know what to do for encoding type %d\n", pCert->wCertificateType); *pdwEncodingType = 0; + ret = FALSE; } } } diff --git a/dll/win32/wintrust/softpub.c b/dll/win32/wintrust/softpub.c index 1db4b47107f..9fa0d05d406 100644 --- a/dll/win32/wintrust/softpub.c +++ b/dll/win32/wintrust/softpub.c @@ -75,9 +75,9 @@ HRESULT WINAPI DriverFinalPolicy(CRYPT_PROVIDER_DATA *data) /* Assumes data->pWintrustData->u.pFile exists. Makes sure a file handle is * open for the file. */ -static BOOL SOFTPUB_OpenFile(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_OpenFile(CRYPT_PROVIDER_DATA *data) { - BOOL ret = TRUE; + DWORD err = ERROR_SUCCESS; /* PSDK implies that all values should be initialized to NULL, so callers * typically have hFile as NULL rather than INVALID_HANDLE_VALUE. Check @@ -92,65 +92,64 @@ static BOOL SOFTPUB_OpenFile(CRYPT_PROVIDER_DATA *data) if (data->pWintrustData->u.pFile->hFile != INVALID_HANDLE_VALUE) data->fOpenedFile = TRUE; else - ret = FALSE; + err = GetLastError(); } - if (ret) + if (!err) GetFileTime(data->pWintrustData->u.pFile->hFile, &data->sftSystemTime, NULL, NULL); - TRACE("returning %d\n", ret); - return ret; + TRACE("returning %d\n", err); + return err; } /* Assumes data->pWintrustData->u.pFile exists. Sets data->pPDSip->gSubject to * the file's subject GUID. */ -static BOOL SOFTPUB_GetFileSubject(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_GetFileSubject(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; if (!WVT_ISINSTRUCT(WINTRUST_FILE_INFO, data->pWintrustData->u.pFile->cbStruct, pgKnownSubject) || !data->pWintrustData->u.pFile->pgKnownSubject) { - ret = CryptSIPRetrieveSubjectGuid( + if (!CryptSIPRetrieveSubjectGuid( data->pWintrustData->u.pFile->pcwszFilePath, data->pWintrustData->u.pFile->hFile, - &data->u.pPDSip->gSubject); + &data->u.pPDSip->gSubject)) + err = GetLastError(); } else - { data->u.pPDSip->gSubject = *data->pWintrustData->u.pFile->pgKnownSubject; - ret = TRUE; - } - TRACE("returning %d\n", ret); - return ret; + TRACE("returning %d\n", err); + return err; } /* Assumes data->u.pPDSip exists, and its gSubject member set. * Allocates data->u.pPDSip->pSip and loads it, if possible. */ -static BOOL SOFTPUB_GetSIP(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_GetSIP(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; data->u.pPDSip->pSip = data->psPfns->pfnAlloc(sizeof(SIP_DISPATCH_INFO)); if (data->u.pPDSip->pSip) - ret = CryptSIPLoad(&data->u.pPDSip->gSubject, 0, data->u.pPDSip->pSip); - else { - SetLastError(ERROR_OUTOFMEMORY); - ret = FALSE; + if (!CryptSIPLoad(&data->u.pPDSip->gSubject, 0, data->u.pPDSip->pSip)) + err = GetLastError(); } - TRACE("returning %d\n", ret); - return ret; + else + err = ERROR_OUTOFMEMORY; + TRACE("returning %d\n", err); + return err; } /* Assumes data->u.pPDSip has been loaded, and data->u.pPDSip->pSip allocated. * Calls data->u.pPDSip->pSip->pfGet to construct data->hMsg. */ -static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, +static DWORD SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, LPCWSTR filePath) { + DWORD err = ERROR_SUCCESS; BOOL ret; LPBYTE buf = NULL; DWORD size = 0; @@ -158,10 +157,7 @@ static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, data->u.pPDSip->psSipSubjectInfo = data->psPfns->pfnAlloc(sizeof(SIP_SUBJECTINFO)); if (!data->u.pPDSip->psSipSubjectInfo) - { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } + return ERROR_OUTOFMEMORY; data->u.pPDSip->psSipSubjectInfo->cbSize = sizeof(SIP_SUBJECTINFO); data->u.pPDSip->psSipSubjectInfo->pgSubjectType = &data->u.pPDSip->gSubject; @@ -171,17 +167,11 @@ static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, ret = data->u.pPDSip->pSip->pfGet(data->u.pPDSip->psSipSubjectInfo, &data->dwEncoding, 0, &size, 0); if (!ret) - { - SetLastError(TRUST_E_NOSIGNATURE); - return FALSE; - } + return TRUST_E_NOSIGNATURE; buf = data->psPfns->pfnAlloc(size); if (!buf) - { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } + return ERROR_OUTOFMEMORY; ret = data->u.pPDSip->pSip->pfGet(data->u.pPDSip->psSipSubjectInfo, &data->dwEncoding, 0, &size, buf); @@ -190,88 +180,111 @@ static BOOL SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file, data->hMsg = CryptMsgOpenToDecode(data->dwEncoding, 0, 0, data->hProv, NULL, NULL); if (data->hMsg) + { ret = CryptMsgUpdate(data->hMsg, buf, size, TRUE); + if (!ret) + err = GetLastError(); + } } + else + err = GetLastError(); data->psPfns->pfnFree(buf); - TRACE("returning %d\n", ret); - return ret; + TRACE("returning %d\n", err); + return err; } -static BOOL SOFTPUB_CreateStoreFromMessage(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_CreateStoreFromMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret = FALSE; + DWORD err = ERROR_SUCCESS; HCERTSTORE store; store = CertOpenStore(CERT_STORE_PROV_MSG, data->dwEncoding, data->hProv, CERT_STORE_NO_CRYPT_RELEASE_FLAG, data->hMsg); if (store) { - ret = data->psPfns->pfnAddStore2Chain(data, store); + if (!data->psPfns->pfnAddStore2Chain(data, store)) + err = GetLastError(); CertCloseStore(store, 0); } - TRACE("returning %d\n", ret); - return ret; + else + err = GetLastError(); + TRACE("returning %d\n", err); + return err; } static DWORD SOFTPUB_DecodeInnerContent(CRYPT_PROVIDER_DATA *data) { BOOL ret; - DWORD size; + DWORD size, err = ERROR_SUCCESS; LPSTR oid = NULL; LPBYTE buf = NULL; ret = CryptMsgGetParam(data->hMsg, CMSG_INNER_CONTENT_TYPE_PARAM, 0, NULL, &size); if (!ret) + { + err = GetLastError(); goto error; + } oid = data->psPfns->pfnAlloc(size); if (!oid) { - SetLastError(ERROR_OUTOFMEMORY); - ret = FALSE; + err = ERROR_OUTOFMEMORY; goto error; } ret = CryptMsgGetParam(data->hMsg, CMSG_INNER_CONTENT_TYPE_PARAM, 0, oid, &size); if (!ret) + { + err = GetLastError(); goto error; + } ret = CryptMsgGetParam(data->hMsg, CMSG_CONTENT_PARAM, 0, NULL, &size); if (!ret) + { + err = GetLastError(); goto error; + } buf = data->psPfns->pfnAlloc(size); if (!buf) { - SetLastError(ERROR_OUTOFMEMORY); - ret = FALSE; + err = ERROR_OUTOFMEMORY; goto error; } ret = CryptMsgGetParam(data->hMsg, CMSG_CONTENT_PARAM, 0, buf, &size); if (!ret) + { + err = GetLastError(); goto error; + } ret = CryptDecodeObject(data->dwEncoding, oid, buf, size, 0, NULL, &size); if (!ret) + { + err = GetLastError(); goto error; + } data->u.pPDSip->psIndirectData = data->psPfns->pfnAlloc(size); if (!data->u.pPDSip->psIndirectData) { - SetLastError(ERROR_OUTOFMEMORY); - ret = FALSE; + err = ERROR_OUTOFMEMORY; goto error; } ret = CryptDecodeObject(data->dwEncoding, oid, buf, size, 0, data->u.pPDSip->psIndirectData, &size); + if (!ret) + err = GetLastError(); error: - TRACE("returning %d\n", ret); + TRACE("returning %d\n", err); data->psPfns->pfnFree(oid); data->psPfns->pfnFree(buf); - return ret; + return err; } -static BOOL SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; if (data->pWintrustData->u.pCert && WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(WINTRUST_CERT_INFO, @@ -281,6 +294,7 @@ static BOOL SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data) { CRYPT_PROVIDER_SGNR signer = { sizeof(signer), { 0 } }; DWORD i; + BOOL ret; /* Add a signer with nothing but the time to verify, so we can * add a cert to it @@ -308,55 +322,57 @@ static BOOL SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data) ret = data->psPfns->pfnAddStore2Chain(data, data->pWintrustData->u.pCert->pahStores[i]); } - } - else - { - /* Do nothing!? See the tests */ - ret = TRUE; + if (!ret) + err = GetLastError(); } } else - { - SetLastError(ERROR_INVALID_PARAMETER); - ret = FALSE; - } - return ret; + err = ERROR_INVALID_PARAMETER; + return err; } -static BOOL SOFTPUB_LoadFileMessage(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_LoadFileMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; if (!data->pWintrustData->u.pFile) { - SetLastError(ERROR_INVALID_PARAMETER); - ret = FALSE; + err = ERROR_INVALID_PARAMETER; goto error; } - ret = SOFTPUB_OpenFile(data); - if (!ret) + err = SOFTPUB_OpenFile(data); + if (err) goto error; - ret = SOFTPUB_GetFileSubject(data); - if (!ret) + err = SOFTPUB_GetFileSubject(data); + if (err) goto error; - ret = SOFTPUB_GetSIP(data); - if (!ret) + err = SOFTPUB_GetSIP(data); + if (err) goto error; - ret = SOFTPUB_GetMessageFromFile(data, data->pWintrustData->u.pFile->hFile, + err = SOFTPUB_GetMessageFromFile(data, data->pWintrustData->u.pFile->hFile, data->pWintrustData->u.pFile->pcwszFilePath); - if (!ret) + if (err) goto error; - ret = SOFTPUB_CreateStoreFromMessage(data); - if (!ret) + err = SOFTPUB_CreateStoreFromMessage(data); + if (err) goto error; - ret = SOFTPUB_DecodeInnerContent(data); + err = SOFTPUB_DecodeInnerContent(data); + error: - return ret; + if (err && data->fOpenedFile && data->pWintrustData->u.pFile) + { + /* The caller won't expect the file to be open on failure, so close it. + */ + CloseHandle(data->pWintrustData->u.pFile->hFile); + data->pWintrustData->u.pFile->hFile = INVALID_HANDLE_VALUE; + data->fOpenedFile = FALSE; + } + return err; } -static BOOL SOFTPUB_LoadCatalogMessage(CRYPT_PROVIDER_DATA *data) +static DWORD SOFTPUB_LoadCatalogMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err; HANDLE catalog = INVALID_HANDLE_VALUE; if (!data->pWintrustData->u.pCatalog) @@ -368,32 +384,34 @@ static BOOL SOFTPUB_LoadCatalogMessage(CRYPT_PROVIDER_DATA *data) GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (catalog == INVALID_HANDLE_VALUE) - return FALSE; - ret = CryptSIPRetrieveSubjectGuid( + return GetLastError(); + if (!CryptSIPRetrieveSubjectGuid( data->pWintrustData->u.pCatalog->pcwszCatalogFilePath, catalog, - &data->u.pPDSip->gSubject); - if (!ret) + &data->u.pPDSip->gSubject)) + { + err = GetLastError(); goto error; - ret = SOFTPUB_GetSIP(data); - if (!ret) + } + err = SOFTPUB_GetSIP(data); + if (err) goto error; - ret = SOFTPUB_GetMessageFromFile(data, catalog, + err = SOFTPUB_GetMessageFromFile(data, catalog, data->pWintrustData->u.pCatalog->pcwszCatalogFilePath); - if (!ret) + if (err) goto error; - ret = SOFTPUB_CreateStoreFromMessage(data); - if (!ret) + err = SOFTPUB_CreateStoreFromMessage(data); + if (err) goto error; - ret = SOFTPUB_DecodeInnerContent(data); + err = SOFTPUB_DecodeInnerContent(data); /* FIXME: this loads the catalog file, but doesn't validate the member. */ error: CloseHandle(catalog); - return ret; + return err; } HRESULT WINAPI SoftpubLoadMessage(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err = ERROR_SUCCESS; TRACE("(%p)\n", data); @@ -403,26 +421,24 @@ HRESULT WINAPI SoftpubLoadMessage(CRYPT_PROVIDER_DATA *data) switch (data->pWintrustData->dwUnionChoice) { case WTD_CHOICE_CERT: - ret = SOFTPUB_LoadCertMessage(data); + err = SOFTPUB_LoadCertMessage(data); break; case WTD_CHOICE_FILE: - ret = SOFTPUB_LoadFileMessage(data); + err = SOFTPUB_LoadFileMessage(data); break; case WTD_CHOICE_CATALOG: - ret = SOFTPUB_LoadCatalogMessage(data); + err = SOFTPUB_LoadCatalogMessage(data); break; default: FIXME("unimplemented for %d\n", data->pWintrustData->dwUnionChoice); - SetLastError(ERROR_INVALID_PARAMETER); - ret = FALSE; + err = ERROR_INVALID_PARAMETER; } - if (!ret) - data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] = - GetLastError(); - TRACE("returning %d (%08x)\n", ret ? S_OK : S_FALSE, + if (err) + data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] = err; + TRACE("returning %d (%08x)\n", !err ? S_OK : S_FALSE, data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]); - return ret ? S_OK : S_FALSE; + return !err ? S_OK : S_FALSE; } static CMSG_SIGNER_INFO *WINTRUST_GetSigner(CRYPT_PROVIDER_DATA *data, @@ -453,9 +469,9 @@ static CMSG_SIGNER_INFO *WINTRUST_GetSigner(CRYPT_PROVIDER_DATA *data, return signerInfo; } -static BOOL WINTRUST_SaveSigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) +static DWORD WINTRUST_SaveSigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) { - BOOL ret; + DWORD err; CMSG_SIGNER_INFO *signerInfo = WINTRUST_GetSigner(data, signerIdx); if (signerInfo) @@ -464,11 +480,14 @@ static BOOL WINTRUST_SaveSigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) sgnr.psSigner = signerInfo; sgnr.sftVerifyAsOf = data->sftSystemTime; - ret = data->psPfns->pfnAddSgnr2Chain(data, FALSE, signerIdx, &sgnr); + if (!data->psPfns->pfnAddSgnr2Chain(data, FALSE, signerIdx, &sgnr)) + err = GetLastError(); + else + err = ERROR_SUCCESS; } else - ret = FALSE; - return ret; + err = GetLastError(); + return err; } static CERT_INFO *WINTRUST_GetSignerCertInfo(CRYPT_PROVIDER_DATA *data, @@ -499,9 +518,9 @@ static CERT_INFO *WINTRUST_GetSignerCertInfo(CRYPT_PROVIDER_DATA *data, return certInfo; } -static BOOL WINTRUST_VerifySigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) +static DWORD WINTRUST_VerifySigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) { - BOOL ret; + DWORD err; CERT_INFO *certInfo = WINTRUST_GetSignerCertInfo(data, signerIdx); if (certInfo) @@ -514,30 +533,29 @@ static BOOL WINTRUST_VerifySigner(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA para = { sizeof(para), 0, signerIdx, CMSG_VERIFY_SIGNER_CERT, (LPVOID)subject }; - ret = CryptMsgControl(data->hMsg, 0, CMSG_CTRL_VERIFY_SIGNATURE_EX, - ¶); - if (!ret) - SetLastError(TRUST_E_CERT_SIGNATURE); + if (!CryptMsgControl(data->hMsg, 0, CMSG_CTRL_VERIFY_SIGNATURE_EX, + ¶)) + err = TRUST_E_CERT_SIGNATURE; else + { data->psPfns->pfnAddCert2Chain(data, signerIdx, FALSE, 0, subject); + err = ERROR_SUCCESS; + } CertFreeCertificateContext(subject); } else - { - SetLastError(TRUST_E_NO_SIGNER_CERT); - ret = FALSE; - } + err = TRUST_E_NO_SIGNER_CERT; data->psPfns->pfnFree(certInfo); } else - ret = FALSE; - return ret; + err = GetLastError(); + return err; } HRESULT WINAPI SoftpubLoadSignature(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err; TRACE("(%p)\n", data); @@ -549,27 +567,26 @@ HRESULT WINAPI SoftpubLoadSignature(CRYPT_PROVIDER_DATA *data) DWORD signerCount, size; size = sizeof(signerCount); - ret = CryptMsgGetParam(data->hMsg, CMSG_SIGNER_COUNT_PARAM, 0, - &signerCount, &size); - if (ret) + if (CryptMsgGetParam(data->hMsg, CMSG_SIGNER_COUNT_PARAM, 0, + &signerCount, &size)) { DWORD i; - for (i = 0; ret && i < signerCount; i++) + err = ERROR_SUCCESS; + for (i = 0; !err && i < signerCount; i++) { - if ((ret = WINTRUST_SaveSigner(data, i))) - ret = WINTRUST_VerifySigner(data, i); + if (!(err = WINTRUST_SaveSigner(data, i))) + err = WINTRUST_VerifySigner(data, i); } } else - SetLastError(TRUST_E_NOSIGNATURE); + err = TRUST_E_NOSIGNATURE; } else - ret = TRUE; - if (!ret) - data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_SIGPROV] = - GetLastError(); - return ret ? S_OK : S_FALSE; + err = ERROR_SUCCESS; + if (err) + data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_SIGPROV] = err; + return !err ? S_OK : S_FALSE; } static DWORD WINTRUST_TrustStatusToConfidence(DWORD errorStatus) @@ -672,24 +689,22 @@ static DWORD WINTRUST_TrustStatusToError(DWORD errorStatus) return error; } -static BOOL WINTRUST_CopyChain(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) +static DWORD WINTRUST_CopyChain(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) { - BOOL ret; + DWORD err, i; PCERT_SIMPLE_CHAIN simpleChain = data->pasSigners[signerIdx].pChainContext->rgpChain[0]; - DWORD i; data->pasSigners[signerIdx].pasCertChain[0].dwConfidence = WINTRUST_TrustStatusToConfidence( simpleChain->rgpElement[0]->TrustStatus.dwErrorStatus); data->pasSigners[signerIdx].pasCertChain[0].pChainElement = simpleChain->rgpElement[0]; - ret = TRUE; - for (i = 1; ret && i < simpleChain->cElement; i++) + err = ERROR_SUCCESS; + for (i = 1; !err && i < simpleChain->cElement; i++) { - ret = data->psPfns->pfnAddCert2Chain(data, signerIdx, FALSE, 0, - simpleChain->rgpElement[i]->pCertContext); - if (ret) + if (data->psPfns->pfnAddCert2Chain(data, signerIdx, FALSE, 0, + simpleChain->rgpElement[i]->pCertContext)) { data->pasSigners[signerIdx].pasCertChain[i].pChainElement = simpleChain->rgpElement[i]; @@ -697,12 +712,14 @@ static BOOL WINTRUST_CopyChain(CRYPT_PROVIDER_DATA *data, DWORD signerIdx) WINTRUST_TrustStatusToConfidence( simpleChain->rgpElement[i]->TrustStatus.dwErrorStatus); } + else + err = GetLastError(); } data->pasSigners[signerIdx].pasCertChain[simpleChain->cElement - 1].dwError = WINTRUST_TrustStatusToError( simpleChain->rgpElement[simpleChain->cElement - 1]-> TrustStatus.dwErrorStatus); - return ret; + return err; } static void WINTRUST_CreateChainPolicyCreateInfo( @@ -731,11 +748,11 @@ static void WINTRUST_CreateChainPolicyCreateInfo( info->pvReserved = NULL; } -static BOOL WINTRUST_CreateChainForSigner(CRYPT_PROVIDER_DATA *data, +static DWORD WINTRUST_CreateChainForSigner(CRYPT_PROVIDER_DATA *data, DWORD signer, PWTD_GENERIC_CHAIN_POLICY_CREATE_INFO createInfo, PCERT_CHAIN_PARA chainPara) { - BOOL ret = TRUE; + DWORD err = ERROR_SUCCESS; HCERTSTORE store = NULL; if (data->chStores) @@ -749,53 +766,64 @@ static BOOL WINTRUST_CreateChainForSigner(CRYPT_PROVIDER_DATA *data, for (i = 0; i < data->chStores; i++) CertAddStoreToCollection(store, data->pahStores[i], 0, 0); } + else + err = GetLastError(); } - /* Expect the end certificate for each signer to be the only cert in the - * chain: - */ - if (data->pasSigners[signer].csCertChain) + if (!err) { - /* Create a certificate chain for each signer */ - ret = CertGetCertificateChain(createInfo->hChainEngine, - data->pasSigners[signer].pasCertChain[0].pCert, - &data->pasSigners[signer].sftVerifyAsOf, store, - chainPara, createInfo->dwFlags, createInfo->pvReserved, - &data->pasSigners[signer].pChainContext); - if (ret) + /* Expect the end certificate for each signer to be the only cert in + * the chain: + */ + if (data->pasSigners[signer].csCertChain) { - if (data->pasSigners[signer].pChainContext->cChain != 1) + BOOL ret; + + /* Create a certificate chain for each signer */ + ret = CertGetCertificateChain(createInfo->hChainEngine, + data->pasSigners[signer].pasCertChain[0].pCert, + &data->pasSigners[signer].sftVerifyAsOf, store, + chainPara, createInfo->dwFlags, createInfo->pvReserved, + &data->pasSigners[signer].pChainContext); + if (ret) { - FIXME("unimplemented for more than 1 simple chain\n"); - ret = FALSE; - } - else - { - if ((ret = WINTRUST_CopyChain(data, signer))) + if (data->pasSigners[signer].pChainContext->cChain != 1) { - if (data->psPfns->pfnCertCheckPolicy) - ret = data->psPfns->pfnCertCheckPolicy(data, signer, - FALSE, 0); - else - TRACE("no cert check policy, skipping policy check\n"); + FIXME("unimplemented for more than 1 simple chain\n"); + err = E_NOTIMPL; + } + else + { + if (!(err = WINTRUST_CopyChain(data, signer))) + { + if (data->psPfns->pfnCertCheckPolicy) + { + ret = data->psPfns->pfnCertCheckPolicy(data, signer, + FALSE, 0); + if (!ret) + err = GetLastError(); + } + else + TRACE( + "no cert check policy, skipping policy check\n"); + } } } + else + err = GetLastError(); } + CertCloseStore(store, 0); } - CertCloseStore(store, 0); - return ret; + return err; } HRESULT WINAPI WintrustCertificateTrust(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err; TRACE("(%p)\n", data); if (!data->csSigners) - { - ret = FALSE; - SetLastError(TRUST_E_NOSIGNATURE); - } + err = TRUST_E_NOSIGNATURE; else { DWORD i; @@ -803,22 +831,21 @@ HRESULT WINAPI WintrustCertificateTrust(CRYPT_PROVIDER_DATA *data) CERT_CHAIN_PARA chainPara; WINTRUST_CreateChainPolicyCreateInfo(data, &createInfo, &chainPara); - ret = TRUE; - for (i = 0; i < data->csSigners; i++) - ret = WINTRUST_CreateChainForSigner(data, i, &createInfo, + err = ERROR_SUCCESS; + for (i = 0; !err && i < data->csSigners; i++) + err = WINTRUST_CreateChainForSigner(data, i, &createInfo, &chainPara); } - if (!ret) - data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] = - GetLastError(); - TRACE("returning %d (%08x)\n", ret ? S_OK : S_FALSE, + if (err) + data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] = err; + TRACE("returning %d (%08x)\n", !err ? S_OK : S_FALSE, data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV]); - return ret ? S_OK : S_FALSE; + return !err ? S_OK : S_FALSE; } HRESULT WINAPI GenericChainCertificateTrust(CRYPT_PROVIDER_DATA *data) { - BOOL ret; + DWORD err; WTD_GENERIC_CHAIN_POLICY_DATA *policyData = data->pWintrustData->pPolicyCallbackData; @@ -827,15 +854,11 @@ HRESULT WINAPI GenericChainCertificateTrust(CRYPT_PROVIDER_DATA *data) if (policyData && policyData->u.cbSize != sizeof(WTD_GENERIC_CHAIN_POLICY_CREATE_INFO)) { - SetLastError(ERROR_INVALID_PARAMETER); - ret = FALSE; + err = ERROR_INVALID_PARAMETER; goto end; } if (!data->csSigners) - { - ret = FALSE; - SetLastError(TRUST_E_NOSIGNATURE); - } + err = TRUST_E_NOSIGNATURE; else { DWORD i; @@ -853,19 +876,18 @@ HRESULT WINAPI GenericChainCertificateTrust(CRYPT_PROVIDER_DATA *data) pChainPara = &chainPara; pCreateInfo = &createInfo; } - ret = TRUE; - for (i = 0; i < data->csSigners; i++) - ret = WINTRUST_CreateChainForSigner(data, i, pCreateInfo, + err = ERROR_SUCCESS; + for (i = 0; !err && i < data->csSigners; i++) + err = WINTRUST_CreateChainForSigner(data, i, pCreateInfo, pChainPara); } end: - if (!ret) - data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] = - GetLastError(); - TRACE("returning %d (%08x)\n", ret ? S_OK : S_FALSE, + if (err) + data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] = err; + TRACE("returning %d (%08x)\n", !err ? S_OK : S_FALSE, data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV]); - return ret ? S_OK : S_FALSE; + return !err ? S_OK : S_FALSE; } HRESULT WINAPI SoftpubAuthenticode(CRYPT_PROVIDER_DATA *data) @@ -1078,7 +1100,8 @@ HRESULT WINAPI SoftpubCleanup(CRYPT_PROVIDER_DATA *data) CryptMsgClose(data->hMsg); - if (data->fOpenedFile) + if (data->fOpenedFile && + data->pWintrustData->dwUnionChoice == WTD_CHOICE_FILE) CloseHandle(data->pWintrustData->u.pFile->hFile); return S_OK; diff --git a/dll/win32/wintrust/wintrust_main.c b/dll/win32/wintrust/wintrust_main.c index c61f6e0f2d6..1c87b6ee07f 100644 --- a/dll/win32/wintrust/wintrust_main.c +++ b/dll/win32/wintrust/wintrust_main.c @@ -77,11 +77,118 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) */ BOOL WINAPI TrustIsCertificateSelfSigned( PCCERT_CONTEXT cert ) { + PCERT_EXTENSION ext; + DWORD size; BOOL ret; TRACE("%p\n", cert); - ret = CertCompareCertificateName(cert->dwCertEncodingType, - &cert->pCertInfo->Subject, &cert->pCertInfo->Issuer); + if ((ext = CertFindExtension(szOID_AUTHORITY_KEY_IDENTIFIER2, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + { + CERT_AUTHORITY_KEY_ID2_INFO *info; + + ret = CryptDecodeObjectEx(cert->dwCertEncodingType, + X509_AUTHORITY_KEY_ID2, ext->Value.pbData, ext->Value.cbData, + CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL, + &info, &size); + if (ret) + { + if (info->AuthorityCertIssuer.cAltEntry && + info->AuthorityCertSerialNumber.cbData) + { + PCERT_ALT_NAME_ENTRY directoryName = NULL; + DWORD i; + + for (i = 0; !directoryName && + i < info->AuthorityCertIssuer.cAltEntry; i++) + if (info->AuthorityCertIssuer.rgAltEntry[i].dwAltNameChoice + == CERT_ALT_NAME_DIRECTORY_NAME) + directoryName = + &info->AuthorityCertIssuer.rgAltEntry[i]; + if (directoryName) + { + ret = CertCompareCertificateName(cert->dwCertEncodingType, + &directoryName->u.DirectoryName, &cert->pCertInfo->Issuer) + && CertCompareIntegerBlob(&info->AuthorityCertSerialNumber, + &cert->pCertInfo->SerialNumber); + } + else + { + FIXME("no supported name type in authority key id2\n"); + ret = FALSE; + } + } + else if (info->KeyId.cbData) + { + ret = CertGetCertificateContextProperty(cert, + CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size); + if (ret && size == info->KeyId.cbData) + { + LPBYTE buf = CryptMemAlloc(size); + + if (buf) + { + CertGetCertificateContextProperty(cert, + CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); + ret = !memcmp(buf, info->KeyId.pbData, size); + CryptMemFree(buf); + } + else + ret = FALSE; + } + else + ret = FALSE; + } + LocalFree(info); + } + } + else if ((ext = CertFindExtension(szOID_AUTHORITY_KEY_IDENTIFIER, + cert->pCertInfo->cExtension, cert->pCertInfo->rgExtension))) + { + CERT_AUTHORITY_KEY_ID_INFO *info; + + ret = CryptDecodeObjectEx(cert->dwCertEncodingType, + X509_AUTHORITY_KEY_ID, ext->Value.pbData, ext->Value.cbData, + CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL, + &info, &size); + if (ret) + { + if (info->CertIssuer.cbData && info->CertSerialNumber.cbData) + { + ret = CertCompareCertificateName(cert->dwCertEncodingType, + &info->CertIssuer, &cert->pCertInfo->Issuer) && + CertCompareIntegerBlob(&info->CertSerialNumber, + &cert->pCertInfo->SerialNumber); + } + else if (info->KeyId.cbData) + { + ret = CertGetCertificateContextProperty(cert, + CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size); + if (ret && size == info->KeyId.cbData) + { + LPBYTE buf = CryptMemAlloc(size); + + if (buf) + { + CertGetCertificateContextProperty(cert, + CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); + ret = !memcmp(buf, info->KeyId.pbData, size); + CryptMemFree(buf); + } + else + ret = FALSE; + } + else + ret = FALSE; + } + else + ret = FALSE; + LocalFree(info); + } + } + else + ret = CertCompareCertificateName(cert->dwCertEncodingType, + &cert->pCertInfo->Subject, &cert->pCertInfo->Issuer); return ret; } diff --git a/dll/win32/wtsapi32/wtsapi32.c b/dll/win32/wtsapi32/wtsapi32.c index fc40494666f..880f3c9a925 100644 --- a/dll/win32/wtsapi32/wtsapi32.c +++ b/dll/win32/wtsapi32/wtsapi32.c @@ -487,6 +487,36 @@ BOOL WINAPI WTSQuerySessionInformationW( return FALSE; } +/************************************************************ + * WTSQueryUserToken (WTSAPI32.@) + * + * Obtains the primary access token of the logged-on user specified by the session ID. + * + * PARAMS + * SessionId [in] -- RDP session identifier + * phToken [out] -- pointer to the token handle for the logged-on user + * + * + * RETURNS + * - On success - pointer to the primary token of the user + * - On failure - zero + * + * + * NOTES + * - token handle should be closed after use with CloseHandle + * - on Failure, extended error information is available via GetLastError + * + */ +BOOL WINAPI WTSQueryUserToken( + ULONG SessionId, + PHANDLE phToken) +{ + *phToken = (HANDLE)0; + SetLastError(ERROR_NO_TOKEN); + FIXME("Stub %d\n", SessionId); + return FALSE; +} + /************************************************************ * WTSWaitSystemEvent (WTSAPI32.@) */ diff --git a/dll/win32/wtsapi32/wtsapi32.spec b/dll/win32/wtsapi32/wtsapi32.spec index 059b6daa540..2be9df00c9d 100644 --- a/dll/win32/wtsapi32/wtsapi32.spec +++ b/dll/win32/wtsapi32/wtsapi32.spec @@ -14,6 +14,7 @@ @ stdcall WTSQuerySessionInformationW(long long long ptr ptr) @ stub WTSQueryUserConfigA @ stub WTSQueryUserConfigW +@ stdcall WTSQueryUserToken(long ptr) @ stdcall WTSRegisterSessionNotification(long long) @ stub WTSSendMessageA @ stub WTSSendMessageW diff --git a/dll/win32/xmllite/reader.c b/dll/win32/xmllite/reader.c new file mode 100644 index 00000000000..00a48fc693d --- /dev/null +++ b/dll/win32/xmllite/reader.c @@ -0,0 +1,493 @@ +/* + * IXmlReader implementation + * + * Copyright 2010 Nikolay Sivov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS + +#include +#include "windef.h" +#include "winbase.h" +#include "initguid.h" +#include "objbase.h" +#include "xmllite.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(xmllite); + +/* not defined in public headers */ +DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda); + +static HRESULT xmlreaderinput_query_for_stream(IXmlReaderInput *iface, void **pObj); + +typedef struct _xmlreader +{ + const IXmlReaderVtbl *lpVtbl; + LONG ref; + IXmlReaderInput *input; + ISequentialStream *stream;/* stored as sequential stream, cause currently + optimizations possible with IStream aren't implemented */ + XmlReadState state; + UINT line, pos; /* reader position in XML stream */ +} xmlreader; + +typedef struct _xmlreaderinput +{ + const IUnknownVtbl *lpVtbl; + LONG ref; + IUnknown *input; /* reference passed on IXmlReaderInput creation */ +} xmlreaderinput; + +static inline xmlreader *impl_from_IXmlReader(IXmlReader *iface) +{ + return (xmlreader *)((char*)iface - FIELD_OFFSET(xmlreader, lpVtbl)); +} + +static inline xmlreaderinput *impl_from_IXmlReaderInput(IXmlReaderInput *iface) +{ + return (xmlreaderinput *)((char*)iface - FIELD_OFFSET(xmlreaderinput, lpVtbl)); +} + +static HRESULT WINAPI xmlreader_QueryInterface(IXmlReader *iface, REFIID riid, void** ppvObject) +{ + xmlreader *This = impl_from_IXmlReader(iface); + + TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_IXmlReader)) + { + *ppvObject = iface; + } + else + { + FIXME("interface %s not implemented\n", debugstr_guid(riid)); + return E_NOINTERFACE; + } + + IXmlReader_AddRef(iface); + + return S_OK; +} + +static ULONG WINAPI xmlreader_AddRef(IXmlReader *iface) +{ + xmlreader *This = impl_from_IXmlReader(iface); + TRACE("%p\n", This); + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI xmlreader_Release(IXmlReader *iface) +{ + xmlreader *This = impl_from_IXmlReader(iface); + LONG ref; + + TRACE("%p\n", This); + + ref = InterlockedDecrement(&This->ref); + if (ref == 0) + { + if (This->input) IUnknown_Release(This->input); + if (This->stream) IUnknown_Release(This->stream); + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input) +{ + xmlreader *This = impl_from_IXmlReader(iface); + HRESULT hr; + + TRACE("(%p %p)\n", This, input); + + if (This->input) + { + IUnknown_Release(This->input); + This->input = NULL; + } + + if (This->stream) + { + IUnknown_Release(This->stream); + This->stream = NULL; + } + + This->line = This->pos = 0; + + /* just reset current input */ + if (!input) + { + This->state = XmlReadState_Initial; + return S_OK; + } + + /* now try IXmlReaderInput, ISequentialStream, IStream */ + hr = IUnknown_QueryInterface(input, &IID_IXmlReaderInput, (void**)&This->input); + if (hr != S_OK) + { + /* create IXmlReaderInput basing on supplied interface */ + hr = CreateXmlReaderInputWithEncodingName(input, + NULL, NULL, FALSE, NULL, &This->input); + if (hr != S_OK) return hr; + } + + /* set stream for supplied IXmlReaderInput */ + hr = xmlreaderinput_query_for_stream(This->input, (void**)&This->stream); + if (hr == S_OK) + This->state = XmlReadState_Initial; + + return hr; +} + +static HRESULT WINAPI xmlreader_GetProperty(IXmlReader* iface, UINT property, LONG_PTR *value) +{ + xmlreader *This = impl_from_IXmlReader(iface); + + TRACE("(%p %u %p)\n", This, property, value); + + if (!value) return E_INVALIDARG; + + switch (property) + { + case XmlReaderProperty_ReadState: + *value = This->state; + break; + default: + FIXME("Unimplemented property (%u)\n", property); + return E_NOTIMPL; + } + + return S_OK; +} + +static HRESULT WINAPI xmlreader_SetProperty(IXmlReader* iface, UINT property, LONG_PTR value) +{ + FIXME("(%p %u %lu): stub\n", iface, property, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_Read(IXmlReader* iface, XmlNodeType *node_type) +{ + FIXME("(%p %p): stub\n", iface, node_type); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetNodeType(IXmlReader* iface, XmlNodeType *node_type) +{ + FIXME("(%p %p): stub\n", iface, node_type); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_MoveToFirstAttribute(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_MoveToNextAttribute(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface, + LPCWSTR local_name, + LPCWSTR namespaceUri) +{ + FIXME("(%p %p %p): stub\n", iface, local_name, namespaceUri); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *qualifiedName, + UINT *qualifiedName_length) +{ + FIXME("(%p %p %p): stub\n", iface, qualifiedName, qualifiedName_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetNamespaceUri(IXmlReader* iface, + LPCWSTR *namespaceUri, + UINT *namespaceUri_length) +{ + FIXME("(%p %p %p): stub\n", iface, namespaceUri, namespaceUri_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetLocalName(IXmlReader* iface, + LPCWSTR *local_name, + UINT *local_name_length) +{ + FIXME("(%p %p %p): stub\n", iface, local_name, local_name_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetPrefix(IXmlReader* iface, + LPCWSTR *prefix, + UINT *prefix_length) +{ + FIXME("(%p %p %p): stub\n", iface, prefix, prefix_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetValue(IXmlReader* iface, + LPCWSTR *value, + UINT *value_length) +{ + FIXME("(%p %p %p): stub\n", iface, value, value_length); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_ReadValueChunk(IXmlReader* iface, + WCHAR *buffer, + UINT chunk_size, + UINT *read) +{ + FIXME("(%p %p %u %p): stub\n", iface, buffer, chunk_size, read); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetBaseUri(IXmlReader* iface, + LPCWSTR *baseUri, + UINT *baseUri_length) +{ + FIXME("(%p %p %p): stub\n", iface, baseUri, baseUri_length); + return E_NOTIMPL; +} + +static BOOL WINAPI xmlreader_IsDefault(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static BOOL WINAPI xmlreader_IsEmptyElement(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetLineNumber(IXmlReader* iface, UINT *lineNumber) +{ + xmlreader *This = impl_from_IXmlReader(iface); + + TRACE("(%p %p)\n", This, lineNumber); + + if (!lineNumber) return E_INVALIDARG; + + *lineNumber = This->line; + + return S_OK; +} + +static HRESULT WINAPI xmlreader_GetLinePosition(IXmlReader* iface, UINT *linePosition) +{ + xmlreader *This = impl_from_IXmlReader(iface); + + TRACE("(%p %p)\n", This, linePosition); + + if (!linePosition) return E_INVALIDARG; + + *linePosition = This->pos; + + return S_OK; +} + +static HRESULT WINAPI xmlreader_GetAttributeCount(IXmlReader* iface, UINT *attributeCount) +{ + FIXME("(%p %p): stub\n", iface, attributeCount); + return E_NOTIMPL; +} + +static HRESULT WINAPI xmlreader_GetDepth(IXmlReader* iface, UINT *depth) +{ + FIXME("(%p %p): stub\n", iface, depth); + return E_NOTIMPL; +} + +static BOOL WINAPI xmlreader_IsEOF(IXmlReader* iface) +{ + FIXME("(%p): stub\n", iface); + return E_NOTIMPL; +} + +static const struct IXmlReaderVtbl xmlreader_vtbl = +{ + xmlreader_QueryInterface, + xmlreader_AddRef, + xmlreader_Release, + xmlreader_SetInput, + xmlreader_GetProperty, + xmlreader_SetProperty, + xmlreader_Read, + xmlreader_GetNodeType, + xmlreader_MoveToFirstAttribute, + xmlreader_MoveToNextAttribute, + xmlreader_MoveToAttributeByName, + xmlreader_MoveToElement, + xmlreader_GetQualifiedName, + xmlreader_GetNamespaceUri, + xmlreader_GetLocalName, + xmlreader_GetPrefix, + xmlreader_GetValue, + xmlreader_ReadValueChunk, + xmlreader_GetBaseUri, + xmlreader_IsDefault, + xmlreader_IsEmptyElement, + xmlreader_GetLineNumber, + xmlreader_GetLinePosition, + xmlreader_GetAttributeCount, + xmlreader_GetDepth, + xmlreader_IsEOF +}; + +/** IXmlReaderInput **/ + +/* Queries already stored interface for IStream/ISequentialStream. + Interface supplied on creation will be overwritten */ +static HRESULT xmlreaderinput_query_for_stream(IXmlReaderInput *iface, void **pObj) +{ + xmlreaderinput *This = impl_from_IXmlReaderInput(iface); + HRESULT hr; + + hr = IUnknown_QueryInterface(This->input, &IID_IStream, pObj); + if (hr != S_OK) + hr = IUnknown_QueryInterface(This->input, &IID_ISequentialStream, pObj); + + return hr; +} + +static HRESULT WINAPI xmlreaderinput_QueryInterface(IXmlReaderInput *iface, REFIID riid, void** ppvObject) +{ + xmlreaderinput *This = impl_from_IXmlReaderInput(iface); + + TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject); + + if (IsEqualGUID(riid, &IID_IXmlReaderInput) || + IsEqualGUID(riid, &IID_IUnknown)) + { + *ppvObject = iface; + } + else + { + FIXME("interface %s not implemented\n", debugstr_guid(riid)); + return E_NOINTERFACE; + } + + IUnknown_AddRef(iface); + + return S_OK; +} + +static ULONG WINAPI xmlreaderinput_AddRef(IXmlReaderInput *iface) +{ + xmlreaderinput *This = impl_from_IXmlReaderInput(iface); + TRACE("%p\n", This); + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI xmlreaderinput_Release(IXmlReaderInput *iface) +{ + xmlreaderinput *This = impl_from_IXmlReaderInput(iface); + LONG ref; + + TRACE("%p\n", This); + + ref = InterlockedDecrement(&This->ref); + if (ref == 0) + { + if (This->input) IUnknown_Release(This->input); + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static const struct IUnknownVtbl xmlreaderinput_vtbl = +{ + xmlreaderinput_QueryInterface, + xmlreaderinput_AddRef, + xmlreaderinput_Release +}; + +HRESULT WINAPI CreateXmlReader(REFIID riid, void **pObject, IMalloc *pMalloc) +{ + xmlreader *reader; + + TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), pObject, pMalloc); + + if (pMalloc) FIXME("custom IMalloc not supported yet\n"); + + if (!IsEqualGUID(riid, &IID_IXmlReader)) + { + ERR("Unexpected IID requested -> (%s)\n", wine_dbgstr_guid(riid)); + return E_FAIL; + } + + reader = HeapAlloc(GetProcessHeap(), 0, sizeof (*reader)); + if(!reader) return E_OUTOFMEMORY; + + reader->lpVtbl = &xmlreader_vtbl; + reader->ref = 1; + reader->stream = NULL; + reader->input = NULL; + reader->state = XmlReadState_Closed; + reader->line = reader->pos = 0; + + *pObject = &reader->lpVtbl; + + TRACE("returning iface %p\n", *pObject); + + return S_OK; +} + +HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, + IMalloc *pMalloc, + LPCWSTR encoding, + BOOL hint, + LPCWSTR base_uri, + IXmlReaderInput **ppInput) +{ + xmlreaderinput *readerinput; + + FIXME("%p %p %s %d %s %p: stub\n", stream, pMalloc, wine_dbgstr_w(encoding), + hint, wine_dbgstr_w(base_uri), ppInput); + + if (!stream || !ppInput) return E_INVALIDARG; + + readerinput = HeapAlloc(GetProcessHeap(), 0, sizeof (*readerinput)); + if(!readerinput) return E_OUTOFMEMORY; + + readerinput->lpVtbl = &xmlreaderinput_vtbl; + readerinput->ref = 1; + IUnknown_QueryInterface(stream, &IID_IUnknown, (void**)&readerinput->input); + + *ppInput = (IXmlReaderInput*)&readerinput->lpVtbl; + + TRACE("returning iface %p\n", *ppInput); + + return S_OK; +} diff --git a/dll/win32/xmllite/xmllite.rbuild b/dll/win32/xmllite/xmllite.rbuild index 207c7839091..c74cd88e8c5 100644 --- a/dll/win32/xmllite/xmllite.rbuild +++ b/dll/win32/xmllite/xmllite.rbuild @@ -4,5 +4,6 @@ include/reactos/wine wine + reader.c xmllite_main.c diff --git a/dll/win32/xmllite/xmllite.spec b/dll/win32/xmllite/xmllite.spec index cf436372b36..d2d0ff7fad0 100644 --- a/dll/win32/xmllite/xmllite.spec +++ b/dll/win32/xmllite/xmllite.spec @@ -1,6 +1,6 @@ -@ stub CreateXmlReader +@ stdcall CreateXmlReader(ptr ptr ptr) @ stub CreateXmlReaderInputWithEncodingCodePage -@ stub CreateXmlReaderInputWithEncodingName +@ stdcall CreateXmlReaderInputWithEncodingName(ptr ptr ptr long ptr ptr) @ stub CreateXmlWriter @ stub CreateXmlWriterOutputWithEncodingCodePage @ stub CreateXmlWriterOutputWithEncodingName diff --git a/drivers/battery/battc/battc.c b/drivers/battery/battc/battc.c new file mode 100644 index 00000000000..a626d8c9171 --- /dev/null +++ b/drivers/battery/battc/battc.c @@ -0,0 +1,373 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/battery/battc/battc.c + * PURPOSE: Battery Class Driver + * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) + */ + +#include + +#define NDEBUG +#include + +NTSTATUS +NTAPI +DriverEntry(PDRIVER_OBJECT DriverObject, + PUNICODE_STRING RegistryPath) +{ + DPRINT("Battery class driver initialized\n"); + + return STATUS_SUCCESS; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassUnload(PVOID ClassData) +{ + PBATTERY_CLASS_DATA BattClass = ClassData; + + DPRINT("Battery 0x%x is being unloaded\n"); + + if (BattClass->InterfaceName.Length != 0) + { + IoSetDeviceInterfaceState(&BattClass->InterfaceName, FALSE); + RtlFreeUnicodeString(&BattClass->InterfaceName); + } + + ExFreePoolWithTag(BattClass, + BATTERY_CLASS_DATA_TAG); + + return STATUS_SUCCESS; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassSystemControl(PVOID ClassData, + PWMILIB_CONTEXT WmiLibContext, + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PSYSCTL_IRP_DISPOSITION Disposition) +{ + NTSTATUS Status; + + UNIMPLEMENTED + + /* FIXME: Uncomment when WmiCompleteRequest is implemented */ +#if 0 + Status = STATUS_WMI_GUID_NOT_FOUND; + WmiCompleteRequest(DeviceObject, + Irp, + Status, + 0, + IO_NO_INCREMENT); +#else + Irp->IoStatus.Status = Status = STATUS_WMI_GUID_NOT_FOUND; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); +#endif + + return Status; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassQueryWmiDataBlock(PVOID ClassData, + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + ULONG GuidIndex, + PULONG InstanceLengthArray, + ULONG OutBufferSize, + PUCHAR Buffer) +{ + UNIMPLEMENTED + + return STATUS_WMI_GUID_NOT_FOUND; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassStatusNotify(PVOID ClassData) +{ + PBATTERY_CLASS_DATA BattClass = ClassData; + PBATTERY_WAIT_STATUS BattWait = BattClass->EventTriggerContext; + BATTERY_STATUS BattStatus; + NTSTATUS Status; + + DPRINT("Received battery status notification from 0x%x\n", ClassData); + + ExAcquireFastMutex(&BattClass->Mutex); + if (!BattClass->Waiting) + { + ExReleaseFastMutex(&BattClass->Mutex); + return STATUS_SUCCESS; + } + + switch (BattClass->EventTrigger) + { + case EVENT_BATTERY_TAG: + ExReleaseFastMutex(&BattClass->Mutex); + DPRINT1("Waiting for battery is UNIMPLEMENTED!\n"); + break; + + case EVENT_BATTERY_STATUS: + ExReleaseFastMutex(&BattClass->Mutex); + Status = BattClass->MiniportInfo.QueryStatus(BattClass->MiniportInfo.Context, + BattWait->BatteryTag, + &BattStatus); + if (!NT_SUCCESS(Status)) + return Status; + + ExAcquireFastMutex(&BattClass->Mutex); + + if (!(BattWait->PowerState & BattStatus.PowerState) || + (BattWait->HighCapacity > BattStatus.Capacity) || + (BattWait->LowCapacity < BattStatus.Capacity)) + { + KeSetEvent(&BattClass->WaitEvent, IO_NO_INCREMENT, FALSE); + } + + ExReleaseFastMutex(&BattClass->Mutex); + break; + + default: + ExReleaseFastMutex(&BattClass->Mutex); + ASSERT(FALSE); + break; + } + + return STATUS_SUCCESS; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassInitializeDevice(PBATTERY_MINIPORT_INFO MiniportInfo, + PVOID *ClassData) +{ + NTSTATUS Status; + PBATTERY_CLASS_DATA BattClass = ExAllocatePoolWithTag(NonPagedPool, + sizeof(BATTERY_CLASS_DATA), + BATTERY_CLASS_DATA_TAG); + + if (!BattClass) + return STATUS_INSUFFICIENT_RESOURCES; + + RtlZeroMemory(BattClass, sizeof(BATTERY_CLASS_DATA)); + + RtlCopyMemory(&BattClass->MiniportInfo, + MiniportInfo, + sizeof(BattClass->MiniportInfo)); + + KeInitializeEvent(&BattClass->WaitEvent, SynchronizationEvent, FALSE); + + ExInitializeFastMutex(&BattClass->Mutex); + + Status = IoRegisterDeviceInterface(MiniportInfo->Pdo, + &GUID_DEVICE_BATTERY, + NULL, + &BattClass->InterfaceName); + if (NT_SUCCESS(Status)) + { + DPRINT("Initialized battery interface: %wZ\n", &BattClass->InterfaceName); + IoSetDeviceInterfaceState(&BattClass->InterfaceName, TRUE); + } + else + { + DPRINT1("IoRegisterDeviceInterface failed (0x%x)\n", Status); + } + + *ClassData = BattClass; + + return STATUS_SUCCESS; +} + +BCLASSAPI +NTSTATUS +DDKAPI +BatteryClassIoctl(PVOID ClassData, + PIRP Irp) +{ + PBATTERY_CLASS_DATA BattClass = ClassData; + PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); + NTSTATUS Status; + ULONG WaitTime; + PBATTERY_WAIT_STATUS BattWait; + PBATTERY_QUERY_INFORMATION BattQueryInfo; + PBATTERY_SET_INFORMATION BattSetInfo; + LARGE_INTEGER Timeout; + PBATTERY_STATUS BattStatus; + BATTERY_NOTIFY BattNotify; + + Irp->IoStatus.Information = 0; + + DPRINT("Received IOCTL %x for 0x%x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode, + ClassData); + + switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) + { + case IOCTL_BATTERY_QUERY_TAG: + if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(ULONG) || + IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG)) + { + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + WaitTime = *(PULONG)Irp->AssociatedIrp.SystemBuffer; + + Timeout.QuadPart = Int32x32To64(WaitTime, -1000); + + Status = BattClass->MiniportInfo.QueryTag(BattClass->MiniportInfo.Context, + (PULONG)Irp->AssociatedIrp.SystemBuffer); + if (!NT_SUCCESS(Status)) + { + ExAcquireFastMutex(&BattClass->Mutex); + BattClass->EventTrigger = EVENT_BATTERY_TAG; + BattClass->Waiting = TRUE; + ExReleaseFastMutex(&BattClass->Mutex); + + Status = KeWaitForSingleObject(&BattClass->WaitEvent, + Executive, + KernelMode, + FALSE, + WaitTime != -1 ? &Timeout : NULL); + + ExAcquireFastMutex(&BattClass->Mutex); + BattClass->Waiting = FALSE; + ExReleaseFastMutex(&BattClass->Mutex); + + if (Status == STATUS_SUCCESS) + { + Status = BattClass->MiniportInfo.QueryTag(BattClass->MiniportInfo.Context, + (PULONG)Irp->AssociatedIrp.SystemBuffer); + if (NT_SUCCESS(Status)) + Irp->IoStatus.Information = sizeof(ULONG); + } + else + { + Status = STATUS_NO_SUCH_DEVICE; + } + } + else + Irp->IoStatus.Information = sizeof(ULONG); + break; + + case IOCTL_BATTERY_QUERY_STATUS: + if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(*BattWait) || + IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(BATTERY_STATUS)) + { + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + BattWait = Irp->AssociatedIrp.SystemBuffer; + + Timeout.QuadPart = Int32x32To64(BattWait->Timeout, -1000); + + Status = BattClass->MiniportInfo.QueryStatus(BattClass->MiniportInfo.Context, + BattWait->BatteryTag, + (PBATTERY_STATUS)Irp->AssociatedIrp.SystemBuffer); + + BattStatus = Irp->AssociatedIrp.SystemBuffer; + + if (!NT_SUCCESS(Status) || + ((BattWait->PowerState & BattStatus->PowerState) && + (BattWait->HighCapacity <= BattStatus->Capacity) && + (BattWait->LowCapacity >= BattStatus->Capacity))) + { + BattNotify.PowerState = BattWait->PowerState; + BattNotify.HighCapacity = BattWait->HighCapacity; + BattNotify.LowCapacity = BattWait->LowCapacity; + + BattClass->MiniportInfo.SetStatusNotify(BattClass->MiniportInfo.Context, + BattWait->BatteryTag, + &BattNotify); + + ExAcquireFastMutex(&BattClass->Mutex); + BattClass->EventTrigger = EVENT_BATTERY_STATUS; + BattClass->EventTriggerContext = BattWait; + BattClass->Waiting = TRUE; + ExReleaseFastMutex(&BattClass->Mutex); + + Status = KeWaitForSingleObject(&BattClass->WaitEvent, + Executive, + KernelMode, + FALSE, + BattWait->Timeout != -1 ? &Timeout : NULL); + + ExAcquireFastMutex(&BattClass->Mutex); + BattClass->Waiting = FALSE; + ExReleaseFastMutex(&BattClass->Mutex); + + BattClass->MiniportInfo.DisableStatusNotify(BattClass->MiniportInfo.Context); + + if (Status == STATUS_SUCCESS) + { + Status = BattClass->MiniportInfo.QueryStatus(BattClass->MiniportInfo.Context, + BattWait->BatteryTag, + (PBATTERY_STATUS)Irp->AssociatedIrp.SystemBuffer); + if (NT_SUCCESS(Status)) + Irp->IoStatus.Information = sizeof(ULONG); + } + else + { + Status = STATUS_NO_SUCH_DEVICE; + } + } + else + Irp->IoStatus.Information = sizeof(BATTERY_STATUS); + break; + + case IOCTL_BATTERY_QUERY_INFORMATION: + if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(*BattQueryInfo)) + { + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + BattQueryInfo = Irp->AssociatedIrp.SystemBuffer; + + Status = BattClass->MiniportInfo.QueryInformation(BattClass->MiniportInfo.Context, + BattQueryInfo->BatteryTag, + BattQueryInfo->InformationLevel, + BattQueryInfo->AtRate, + Irp->AssociatedIrp.SystemBuffer, + IrpSp->Parameters.DeviceIoControl.OutputBufferLength, + &Irp->IoStatus.Information); + if (!NT_SUCCESS(Status)) + DPRINT1("QueryInformation failed (0x%x)\n", Status); + break; + case IOCTL_BATTERY_SET_INFORMATION: + if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(*BattSetInfo)) + { + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + BattSetInfo = Irp->AssociatedIrp.SystemBuffer; + + Status = BattClass->MiniportInfo.SetInformation(BattClass->MiniportInfo.Context, + BattSetInfo->BatteryTag, + BattSetInfo->InformationLevel, + BattSetInfo->Buffer); + if (!NT_SUCCESS(Status)) + DPRINT1("SetInformation failed (0x%x)\n", Status); + break; + + default: + DPRINT1("Received unsupported IRP %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode); + /* Do NOT complete the irp */ + return STATUS_NOT_SUPPORTED; + } + + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return Status; +} diff --git a/drivers/battery/battc/battc.h b/drivers/battery/battc/battc.h new file mode 100644 index 00000000000..b7c5af49333 --- /dev/null +++ b/drivers/battery/battc/battc.h @@ -0,0 +1,30 @@ +/* +* PROJECT: ReactOS Kernel +* LICENSE: GPL - See COPYING in the top level directory +* FILE: drivers/battery/battc/battc.h +* PURPOSE: Battery Class Driver +* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) +*/ + +#pragma once + +#include +#include +#include + +typedef struct _BATTERY_CLASS_DATA { + BATTERY_MINIPORT_INFO MiniportInfo; + KEVENT WaitEvent; + BOOLEAN Waiting; + FAST_MUTEX Mutex; + UCHAR EventTrigger; + PVOID EventTriggerContext; + UNICODE_STRING InterfaceName; +} BATTERY_CLASS_DATA, *PBATTERY_CLASS_DATA; + +/* Memory tags */ +#define BATTERY_CLASS_DATA_TAG 'CtaB' + +/* Event triggers */ +#define EVENT_BATTERY_TAG 0x01 +#define EVENT_BATTERY_STATUS 0x02 diff --git a/drivers/battery/battc/battc.rbuild b/drivers/battery/battc/battc.rbuild new file mode 100644 index 00000000000..c0261344994 --- /dev/null +++ b/drivers/battery/battc/battc.rbuild @@ -0,0 +1,10 @@ + + + + ntoskrnl + hal + + . + battc.c + battc.rc + diff --git a/drivers/battery/battc/battc.rc b/drivers/battery/battc/battc.rc new file mode 100644 index 00000000000..2230092b4a4 --- /dev/null +++ b/drivers/battery/battc/battc.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Battery Class Driver\0" +#define REACTOS_STR_INTERNAL_NAME "battc\0" +#define REACTOS_STR_ORIGINAL_FILENAME "battc.sys\0" +#include diff --git a/drivers/battery/battc/battc.spec b/drivers/battery/battc/battc.spec new file mode 100644 index 00000000000..c2d21b7ec20 --- /dev/null +++ b/drivers/battery/battc/battc.spec @@ -0,0 +1,6 @@ +@ stdcall BatteryClassInitializeDevice(ptr ptr) +@ stdcall BatteryClassIoctl(ptr ptr) +@ stdcall BatteryClassQueryWmiDataBlock(ptr ptr ptr long ptr long ptr) +@ stdcall BatteryClassStatusNotify(ptr) +@ stdcall BatteryClassSystemControl(ptr ptr ptr ptr ptr) +@ stdcall BatteryClassUnload(ptr) diff --git a/drivers/battery/cmbatt/cmbatt.c b/drivers/battery/cmbatt/cmbatt.c new file mode 100644 index 00000000000..b85f3ebc504 --- /dev/null +++ b/drivers/battery/cmbatt/cmbatt.c @@ -0,0 +1,188 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/battery/cmbatt/cmbatt.c + * PURPOSE: Control Method Battery Miniclass Driver + * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) + */ + +#include + +#define NDEBUG +#include + +LIST_ENTRY BatteryList; +KSPIN_LOCK BatteryListLock; + +VOID +NTAPI +CmBattUnload(PDRIVER_OBJECT DriverObject) +{ + DPRINT("Control method battery miniclass driver unloaded\n"); +} + +NTSTATUS +NTAPI +CmBattDeviceControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + NTSTATUS Status; + + Status = BatteryClassIoctl(DeviceExtension->BattClassHandle, + Irp); + + if (Status == STATUS_NOT_SUPPORTED) + { + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + + return Status; +} + +NTSTATUS +NTAPI +CmBattPnP(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + + UNIMPLEMENTED + + IoSkipCurrentIrpStackLocation(Irp); + + return IoCallDriver(DeviceExtension->Ldo, Irp); +} + +NTSTATUS +NTAPI +CmBattSystemControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + UNIMPLEMENTED + + Irp->IoStatus.Status = STATUS_WMI_GUID_NOT_FOUND; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return STATUS_WMI_GUID_NOT_FOUND; +} + +NTSTATUS +NTAPI +CmBattPower(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + + UNIMPLEMENTED + + IoSkipCurrentIrpStackLocation(Irp); + + PoStartNextPowerIrp(Irp); + + return PoCallDriver(DeviceExtension->Ldo, Irp); +} + +NTSTATUS +NTAPI +CmBattCreateClose(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmBattAddDevice(PDRIVER_OBJECT DriverObject, + PDEVICE_OBJECT PhysicalDeviceObject) +{ + NTSTATUS Status; + PDEVICE_OBJECT DeviceObject; + PCMBATT_DEVICE_EXTENSION DeviceExtension; + BATTERY_MINIPORT_INFO BattInfo; + + Status = IoCreateDevice(DriverObject, + sizeof(CMBATT_DEVICE_EXTENSION), + NULL, + FILE_DEVICE_BATTERY, + 0, + FALSE, + &DeviceObject); + if (!NT_SUCCESS(Status)) + return Status; + + DeviceExtension = DeviceObject->DeviceExtension; + + DeviceExtension->Pdo = PhysicalDeviceObject; + DeviceExtension->Fdo = DeviceObject; + DeviceExtension->Ldo = IoAttachDeviceToDeviceStack(DeviceObject, + PhysicalDeviceObject); + + DeviceObject->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE; + + /* We require an extra stack entry */ + DeviceObject->StackSize = PhysicalDeviceObject->StackSize + 2; + + BattInfo.MajorVersion = BATTERY_CLASS_MAJOR_VERSION; + BattInfo.MinorVersion = BATTERY_CLASS_MINOR_VERSION; + BattInfo.Context = DeviceExtension; + BattInfo.QueryTag = CmBattQueryTag; + BattInfo.QueryInformation = CmBattQueryInformation; + BattInfo.SetInformation = CmBattSetInformation; + BattInfo.QueryStatus = CmBattQueryStatus; + BattInfo.SetStatusNotify = CmBattSetStatusNotify; + BattInfo.DisableStatusNotify = CmBattDisableStatusNotify; + BattInfo.Pdo = PhysicalDeviceObject; + BattInfo.DeviceName = NULL; + + Status = BatteryClassInitializeDevice(&BattInfo, + &DeviceExtension->BattClassHandle); + if (!NT_SUCCESS(Status)) + { + IoDetachDevice(DeviceExtension->Ldo); + IoDeleteDevice(DeviceObject); + return Status; + } + + ExInterlockedInsertTailList(&BatteryList, + &DeviceExtension->ListEntry, + &BatteryListLock); + + DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + DPRINT("Successfully registered battery with battc (0x%x)\n", DeviceExtension->BattClassHandle); + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +DriverEntry(PDRIVER_OBJECT DriverObject, + PUNICODE_STRING RegistryPath) +{ + DPRINT("Control method battery miniclass driver initialized\n"); + + DriverObject->DriverUnload = CmBattUnload; + DriverObject->DriverExtension->AddDevice = CmBattAddDevice; + DriverObject->MajorFunction[IRP_MJ_POWER] = CmBattPower; + DriverObject->MajorFunction[IRP_MJ_PNP] = CmBattPnP; + DriverObject->MajorFunction[IRP_MJ_CREATE] = CmBattCreateClose; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = CmBattCreateClose; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CmBattDeviceControl; + DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = CmBattSystemControl; + + KeInitializeSpinLock(&BatteryListLock); + InitializeListHead(&BatteryList); + + return STATUS_SUCCESS; +} diff --git a/drivers/battery/cmbatt/cmbatt.h b/drivers/battery/cmbatt/cmbatt.h new file mode 100644 index 00000000000..e70b561d3df --- /dev/null +++ b/drivers/battery/cmbatt/cmbatt.h @@ -0,0 +1,58 @@ +/* +* PROJECT: ReactOS Kernel +* LICENSE: GPL - See COPYING in the top level directory +* FILE: drivers/battery/cmbatt/cmbatt.h +* PURPOSE: Control Method Battery Miniclass Driver +* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) +*/ + +#pragma once + +#include +#include + +typedef struct _CMBATT_DEVICE_EXTENSION { + PDEVICE_OBJECT Pdo; + PDEVICE_OBJECT Ldo; + PDEVICE_OBJECT Fdo; + PVOID BattClassHandle; + LIST_ENTRY ListEntry; +} CMBATT_DEVICE_EXTENSION, *PCMBATT_DEVICE_EXTENSION; + +NTSTATUS +NTAPI +CmBattQueryTag(PVOID Context, + PULONG BatteryTag); + +NTSTATUS +NTAPI +CmBattDisableStatusNotify(PVOID Context); + +NTSTATUS +NTAPI +CmBattSetStatusNotify(PVOID Context, + ULONG BatteryTag, + PBATTERY_NOTIFY BatteryNotify); + +NTSTATUS +NTAPI +CmBattQueryInformation(PVOID Context, + ULONG BatteryTag, + BATTERY_QUERY_INFORMATION_LEVEL Level, + OPTIONAL LONG AtRate, + PVOID Buffer, + ULONG BufferLength, + PULONG ReturnedLength); + +NTSTATUS +NTAPI +CmBattQueryStatus(PVOID Context, + ULONG BatteryTag, + PBATTERY_STATUS BatteryStatus); + +NTSTATUS +NTAPI +CmBattSetInformation(PVOID Context, + ULONG BatteryTag, + BATTERY_SET_INFORMATION_LEVEL Level, + OPTIONAL PVOID Buffer); diff --git a/drivers/battery/cmbatt/cmbatt.rbuild b/drivers/battery/cmbatt/cmbatt.rbuild new file mode 100644 index 00000000000..c41a072779c --- /dev/null +++ b/drivers/battery/cmbatt/cmbatt.rbuild @@ -0,0 +1,11 @@ + + + + ntoskrnl + hal + battc + . + cmbatt.c + miniclass.c + cmbatt.rc + diff --git a/drivers/battery/cmbatt/cmbatt.rc b/drivers/battery/cmbatt/cmbatt.rc new file mode 100644 index 00000000000..2fd6bc7713c --- /dev/null +++ b/drivers/battery/cmbatt/cmbatt.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Control Method Battery Miniclass Driver\0" +#define REACTOS_STR_INTERNAL_NAME "cmbatt\0" +#define REACTOS_STR_ORIGINAL_FILENAME "cmbatt.sys\0" +#include diff --git a/drivers/battery/cmbatt/miniclass.c b/drivers/battery/cmbatt/miniclass.c new file mode 100644 index 00000000000..bb75d9aa319 --- /dev/null +++ b/drivers/battery/cmbatt/miniclass.c @@ -0,0 +1,82 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/battery/cmbatt/miniclass.c + * PURPOSE: Control Method Battery Miniclass Driver + * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) + */ + +#include + +#define NDEBUG +#include + +NTSTATUS +NTAPI +CmBattQueryTag(PVOID Context, + PULONG BatteryTag) +{ + UNIMPLEMENTED + + *BatteryTag = 0; + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmBattDisableStatusNotify(PVOID Context) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +CmBattSetStatusNotify(PVOID Context, + ULONG BatteryTag, + PBATTERY_NOTIFY BatteryNotify) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +CmBattQueryInformation(PVOID Context, + ULONG BatteryTag, + BATTERY_QUERY_INFORMATION_LEVEL Level, + OPTIONAL LONG AtRate, + PVOID Buffer, + ULONG BufferLength, + PULONG ReturnedLength) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +CmBattQueryStatus(PVOID Context, + ULONG BatteryTag, + PBATTERY_STATUS BatteryStatus) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +CmBattSetInformation(PVOID Context, + ULONG BatteryTag, + BATTERY_SET_INFORMATION_LEVEL Level, + OPTIONAL PVOID Buffer) +{ + UNIMPLEMENTED + + return STATUS_NOT_SUPPORTED; +} diff --git a/drivers/battery/directory.rbuild b/drivers/battery/directory.rbuild new file mode 100644 index 00000000000..2da9fe08c92 --- /dev/null +++ b/drivers/battery/directory.rbuild @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/drivers/bus/acpi/acpi.rbuild b/drivers/bus/acpi/acpi.rbuild index 94b960a9b6f..f2b6a13cbca 100644 --- a/drivers/bus/acpi/acpi.rbuild +++ b/drivers/bus/acpi/acpi.rbuild @@ -1,142 +1,30 @@ - + + + + + + + include - ospm/include + include ntoskrnl hal - - dsfield.c - dsmethod.c - dsmthdat.c - dsobject.c - dsopcode.c - dsutils.c - dswexec.c - dswload.c - dswscope.c - dswstate.c - - - evevent.c - evmisc.c - evregion.c - evrgnini.c - evsci.c - evxface.c - evxfevnt.c - evxfregn.c - - - amconfig.c - amconvrt.c - amcreate.c - amdump.c - amdyadic.c - amfield.c - amfldio.c - ammisc.c - ammonad.c - ammutex.c - amnames.c - amprep.c - amregion.c - amresnte.c - amresolv.c - amresop.c - amstore.c - amstoren.c - amstorob.c - amsystem.c - amutils.c - amxface.c - - - hwacpi.c - hwgpe.c - hwregs.c - hwsleep.c - hwtimer.c - - - nsaccess.c - nsalloc.c - nseval.c - nsinit.c - nsload.c - nsnames.c - nsobject.c - nssearch.c - nsutils.c - nswalk.c - nsxfname.c - nsxfobj.c - - - - bm.c - bmnotify.c - bmpm.c - bmpower.c - bmrequest.c - bmsearch.c - bmutils.c - bmxface.c - - acpienum.c - acpisys.c - bn.c - fdo.c - osl.c - pdo.c - - - psargs.c - psopcode.c - psparse.c - psscope.c - pstree.c - psutils.c - pswalk.c - psxface.c - - - rsaddr.c - rscalc.c - rscreate.c - rsdump.c - rsio.c - rsirq.c - rslist.c - rsmemory.c - rsmisc.c - rsutils.c - rsxface.c - - - tbconvrt.c - tbget.c - tbinstal.c - tbutils.c - tbxface.c - tbxfroot.c - - - cmalloc.c - cmclib.c - cmcopy.c - cmdebug.c - cmdelete.c - cmeval.c - cmglobal.c - cminit.c - cmobject.c - cmutils.c - cmxface.c - - acpi.rc - - acpi.h + wdmguid + acpica + + bus.c + button.c + power.c + utils.c + system.c + osl.c + acpienum.c + pnp.c + power.c + buspdo.c + main.c diff --git a/drivers/bus/acpi/acpi.rc b/drivers/bus/acpi/acpi.rc index 41b00065cb0..7a466943475 100644 --- a/drivers/bus/acpi/acpi.rc +++ b/drivers/bus/acpi/acpi.rc @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: acpi.rc 21698 2006-04-22 05:55:17Z tretiakov $ */ #define REACTOS_VERSION_DLL #define REACTOS_STR_FILE_DESCRIPTION "ReactOS ACPI Driver\0" diff --git a/drivers/bus/acpi/acpica/acpica.rbuild b/drivers/bus/acpi/acpica/acpica.rbuild new file mode 100644 index 00000000000..b23eed8d5b2 --- /dev/null +++ b/drivers/bus/acpi/acpica/acpica.rbuild @@ -0,0 +1,143 @@ + + + + + include + + dsfield.c + dsinit.c + dsmethod.c + dsmthdat.c + dsobject.c + dsopcode.c + dsutils.c + dswexec.c + dswload.c + dswscope.c + dswstate.c + + + evevent.c + evgpe.c + evgpeblk.c + evmisc.c + evregion.c + evrgnini.c + evsci.c + evxface.c + evxfevnt.c + evxfregn.c + + + exconfig.c + exconvrt.c + excreate.c + exdump.c + exfield.c + exfldio.c + exmisc.c + exmutex.c + exoparg1.c + exoparg2.c + exoparg3.c + exoparg6.c + exnames.c + exprep.c + exregion.c + exresnte.c + exresolv.c + exresop.c + exstore.c + exstoren.c + exstorob.c + exsystem.c + exutils.c + + + hwacpi.c + hwgpe.c + hwregs.c + hwsleep.c + hwtimer.c + hwvalid.c + hwxface.c + + + nsaccess.c + nsalloc.c + nsdump.c + nsdumpdv.c + nseval.c + nsinit.c + nsload.c + nsnames.c + nsobject.c + nsparse.c + nspredef.c + nsrepair.c + nsrepair2.c + nssearch.c + nsutils.c + nswalk.c + nsxfeval.c + nsxfname.c + nsxfobj.c + + + + psargs.c + psloop.c + psopcode.c + psparse.c + psscope.c + pstree.c + psutils.c + pswalk.c + psxface.c + + + rsaddr.c + rscalc.c + rscreate.c + rsdump.c + rsinfo.c + rsio.c + rsirq.c + rslist.c + rsmemory.c + rsmisc.c + rsutils.c + rsxface.c + + + tbfadt.c + tbfind.c + tbinstal.c + tbutils.c + tbxface.c + tbxfroot.c + + + utalloc.c + utcache.c + utclib.c + utcopy.c + utdebug.c + utdelete.c + uteval.c + utglobal.c + utids.c + utinit.c + utlock.c + utmath.c + utmisc.c + utmutex.c + utobject.c + utresrc.c + utstate.c + uttrack.c + utxface.c + + diff --git a/drivers/bus/acpi/acpica/dispatcher/dsfield.c b/drivers/bus/acpi/acpica/dispatcher/dsfield.c new file mode 100644 index 00000000000..12d55f40c43 --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dsfield.c @@ -0,0 +1,776 @@ +/****************************************************************************** + * + * Module Name: dsfield - Dispatcher field routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSFIELD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acparser.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsfield") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsGetFieldNames ( + ACPI_CREATE_FIELD_INFO *Info, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateBufferField + * + * PARAMETERS: Op - Current parse op (CreateXXField) + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Execute the CreateField operators: + * CreateBitFieldOp, + * CreateByteFieldOp, + * CreateWordFieldOp, + * CreateDWordFieldOp, + * CreateQWordFieldOp, + * CreateFieldOp (all of which define a field in a buffer) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateBufferField ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *SecondDesc = NULL; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE (DsCreateBufferField); + + + /* + * Get the NameString argument (name of the new BufferField) + */ + if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) + { + /* For CreateField, name is the 4th argument */ + + Arg = AcpiPsGetArg (Op, 3); + } + else + { + /* For all other CreateXXXField operators, name is the 3rd argument */ + + Arg = AcpiPsGetArg (Op, 2); + } + + if (!Arg) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + if (WalkState->DeferredNode) + { + Node = WalkState->DeferredNode; + Status = AE_OK; + } + else + { + /* Execute flag should always be set when this function is entered */ + + if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE)) + { + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Creating new namespace node, should not already exist */ + + Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND; + + /* + * Mark node temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } + + /* Enter the NameString into the namespace */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, + Flags, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + } + + /* + * We could put the returned object (Node) on the object stack for later, + * but for now, we will put it in the "op" object that the parser uses, + * so we can get it again at the end of this scope. + */ + Op->Common.Node = Node; + + /* + * If there is no object attached to the node, this node was just created + * and we need to create the field object. Otherwise, this was a lookup + * of an existing node and we don't want to create the field object again. + */ + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * The Field definition is not fully parsed at this time. + * (We must save the address of the AML for the buffer and index operands) + */ + + /* Create the buffer field object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Remember location in AML stream of the field unit opcode and operands -- + * since the buffer and index operands must be evaluated. + */ + SecondDesc = ObjDesc->Common.NextObject; + SecondDesc->Extra.AmlStart = Op->Named.Data; + SecondDesc->Extra.AmlLength = Op->Named.Length; + ObjDesc->BufferField.Node = Node; + + /* Attach constructed field descriptors to parent node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + +Cleanup: + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetFieldNames + * + * PARAMETERS: Info - CreateField info structure + * ` WalkState - Current method state + * Arg - First parser arg for the field name list + * + * RETURN: Status + * + * DESCRIPTION: Process all named fields in a field declaration. Names are + * entered into the namespace. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsGetFieldNames ( + ACPI_CREATE_FIELD_INFO *Info, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg) +{ + ACPI_STATUS Status; + ACPI_INTEGER Position; + + + ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info); + + + /* First field starts at bit zero */ + + Info->FieldBitPosition = 0; + + /* Process all elements in the field list (of parse nodes) */ + + while (Arg) + { + /* + * Three types of field elements are handled: + * 1) Offset - specifies a bit offset + * 2) AccessAs - changes the access mode + * 3) Name - Enters a new named field into the namespace + */ + switch (Arg->Common.AmlOpcode) + { + case AML_INT_RESERVEDFIELD_OP: + + Position = (ACPI_INTEGER) Info->FieldBitPosition + + (ACPI_INTEGER) Arg->Common.Value.Size; + + if (Position > ACPI_UINT32_MAX) + { + ACPI_ERROR ((AE_INFO, + "Bit offset within field too large (> 0xFFFFFFFF)")); + return_ACPI_STATUS (AE_SUPPORT); + } + + Info->FieldBitPosition = (UINT32) Position; + break; + + + case AML_INT_ACCESSFIELD_OP: + + /* + * Get a new AccessType and AccessAttribute -- to be used for all + * field units that follow, until field end or another AccessAs + * keyword. + * + * In FieldFlags, preserve the flag bits other than the + * ACCESS_TYPE bits + */ + Info->FieldFlags = (UINT8) + ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | + ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8))); + + Info->Attribute = (UINT8) (Arg->Common.Value.Integer); + break; + + + case AML_INT_NAMEDFIELD_OP: + + /* Lookup the name, it should already exist */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, + (char *) &Arg->Named.Name, Info->FieldType, + ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &Info->FieldNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); + return_ACPI_STATUS (Status); + } + else + { + Arg->Common.Node = Info->FieldNode; + Info->FieldBitLength = Arg->Common.Value.Size; + + /* + * If there is no object attached to the node, this node was + * just created and we need to create the field object. + * Otherwise, this was a lookup of an existing node and we + * don't want to create the field object again. + */ + if (!AcpiNsGetAttachedObject (Info->FieldNode)) + { + Status = AcpiExPrepFieldValue (Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + /* Keep track of bit position for the next field */ + + Position = (ACPI_INTEGER) Info->FieldBitPosition + + (ACPI_INTEGER) Arg->Common.Value.Size; + + if (Position > ACPI_UINT32_MAX) + { + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)", + ACPI_CAST_PTR (char, &Info->FieldNode->Name))); + return_ACPI_STATUS (AE_SUPPORT); + } + + Info->FieldBitPosition += Info->FieldBitLength; + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "Invalid opcode in field list: %X", Arg->Common.AmlOpcode)); + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + Arg = Arg->Common.Next; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * ` WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_CREATE_FIELD_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op); + + + /* First arg is the name of the parent OpRegion (must already exist) */ + + Arg = Op->Common.Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, + ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the field flags */ + + Arg = Arg->Common.Next; + Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; + Info.Attribute = 0; + + /* Each remaining arg is a Named Field */ + + Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD; + Info.RegionNode = RegionNode; + + Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitFieldObjects + * + * PARAMETERS: Op - Op containing the Field definition and args + * ` WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: For each "Field Unit" name in the argument list that is + * part of the field declaration, enter the name into the + * namespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitFieldObjects ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_NAMESPACE_NODE *Node; + UINT8 Type = 0; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op); + + + /* Execute flag should always be set when this function is entered */ + + if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE)) + { + if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP) + { + /* BankField Op is deferred, just return OK */ + + return_ACPI_STATUS (AE_OK); + } + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * Get the FieldList argument for this opcode. This is the start of the + * list of field elements. + */ + switch (WalkState->Opcode) + { + case AML_FIELD_OP: + Arg = AcpiPsGetArg (Op, 2); + Type = ACPI_TYPE_LOCAL_REGION_FIELD; + break; + + case AML_BANK_FIELD_OP: + Arg = AcpiPsGetArg (Op, 4); + Type = ACPI_TYPE_LOCAL_BANK_FIELD; + break; + + case AML_INDEX_FIELD_OP: + Arg = AcpiPsGetArg (Op, 3); + Type = ACPI_TYPE_LOCAL_INDEX_FIELD; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Creating new namespace node(s), should not already exist */ + + Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND; + + /* + * Mark node(s) temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } + + /* + * Walk the list of entries in the FieldList + * Note: FieldList can be of zero length. In this case, Arg will be NULL. + */ + while (Arg) + { + /* + * Ignore OFFSET and ACCESSAS terms here; we are only interested in the + * field names in order to enter them into the namespace. + */ + if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, + (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1, + Flags, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); + if (Status != AE_ALREADY_EXISTS) + { + return_ACPI_STATUS (Status); + } + + /* Name already exists, just ignore this error */ + + Status = AE_OK; + } + + Arg->Common.Node = Node; + } + + /* Get the next field element in the list */ + + Arg = Arg->Common.Next; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateBankField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new bank field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateBankField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_CREATE_FIELD_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op); + + + /* First arg is the name of the parent OpRegion (must already exist) */ + + Arg = Op->Common.Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, + ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the Bank Register (Field) (must already exist) */ + + Arg = Arg->Common.Next; + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + + /* + * Third arg is the BankValue + * This arg is a TermArg, not a constant + * It will be evaluated later, by AcpiDsEvalBankFieldOperands + */ + Arg = Arg->Common.Next; + + /* Fourth arg is the field flags */ + + Arg = Arg->Common.Next; + Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; + + /* Each remaining arg is a Named Field */ + + Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD; + Info.RegionNode = RegionNode; + + /* + * Use Info.DataRegisterNode to store BankField Op + * It's safe because DataRegisterNode will never be used when create bank field + * We store AmlStart and AmlLength in the BankField Op for late evaluation + * Used in AcpiExPrepFieldValue(Info) + * + * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like "void *ParentOp"? + */ + Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op; + + Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateIndexField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * ` WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new index field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_CREATE_FIELD_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op); + + + /* First arg is the name of the Index register (must already exist) */ + + Arg = Op->Common.Value.Arg; + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + + /* Second arg is the data register (must already exist) */ + + Arg = Arg->Common.Next; + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + + /* Next arg is the field flags */ + + Arg = Arg->Common.Next; + Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; + + /* Each remaining arg is a Named Field */ + + Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD; + Info.RegionNode = RegionNode; + + Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/dispatcher/dsinit.c b/drivers/bus/acpi/acpica/dispatcher/dsinit.c new file mode 100644 index 00000000000..efea20e83d3 --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dsinit.c @@ -0,0 +1,310 @@ +/****************************************************************************** + * + * Module Name: dsinit - Object initialization namespace walk + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSINIT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsinit") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitOneObject + * + * PARAMETERS: ObjHandle - Node for the object + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Operation Regions + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * We are only interested in NS nodes owned by the table that + * was just loaded + */ + if (Node->OwnerId != Info->OwnerId) + { + return (AE_OK); + } + + Info->ObjectCount++; + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + + switch (Type) + { + case ACPI_TYPE_REGION: + + Status = AcpiDsInitializeRegion (ObjHandle); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "During Region initialization %p [%4.4s]", + ObjHandle, AcpiUtGetNodeName (ObjHandle))); + } + + Info->OpRegionCount++; + break; + + + case ACPI_TYPE_METHOD: + + Info->MethodCount++; + break; + + + case ACPI_TYPE_DEVICE: + + Info->DeviceCount++; + break; + + + default: + break; + } + + /* + * We ignore errors from above, and always return OK, since + * we don't want to abort the walk on a single error. + */ + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitializeObjects + * + * PARAMETERS: TableDesc - Descriptor for parent ACPI table + * StartNode - Root of subtree to be initialized. + * + * RETURN: Status + * + * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any + * necessary initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitializeObjects ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + ACPI_TABLE_HEADER *Table; + ACPI_OWNER_ID OwnerId; + + + ACPI_FUNCTION_TRACE (DsInitializeObjects); + + + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "**** Starting initialization of namespace objects ****\n")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:")); + + Info.MethodCount = 0; + Info.OpRegionCount = 0; + Info.ObjectCount = 0; + Info.DeviceCount = 0; + Info.TableIndex = TableIndex; + Info.OwnerId = OwnerId; + + /* Walk entire namespace from the supplied root */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * We don't use AcpiWalkNamespace since we do not want to acquire + * the namespace reader lock. + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); + } + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", + Table->Signature, OwnerId, Info.ObjectCount, + Info.DeviceCount, Info.MethodCount, Info.OpRegionCount)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "%hd Methods, %hd Regions\n", Info.MethodCount, Info.OpRegionCount)); + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/dispatcher/dsmethod.c b/drivers/bus/acpi/acpica/dispatcher/dsmethod.c new file mode 100644 index 00000000000..48172e962e2 --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dsmethod.c @@ -0,0 +1,762 @@ +/****************************************************************************** + * + * Module Name: dsmethod - Parser/Interpreter interface - control method parsing + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSMETHOD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdisasm.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsmethod") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsCreateMethodMutex ( + ACPI_OPERAND_OBJECT *MethodDesc); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodError + * + * PARAMETERS: Status - Execution status + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Called on method error. Invoke the global exception handler if + * present, dump the method data if the disassembler is configured + * + * Note: Allows the exception handler to change the status code + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodError ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Ignore AE_OK and control exception codes */ + + if (ACPI_SUCCESS (Status) || + (Status & AE_CODE_CONTROL)) + { + return (Status); + } + + /* Invoke the global exception handler */ + + if (AcpiGbl_ExceptionHandler) + { + /* Exit the interpreter, allow handler to execute methods */ + + AcpiExExitInterpreter (); + + /* + * Handler can map the exception code to anything it wants, including + * AE_OK, in which case the executing method will not be aborted. + */ + Status = AcpiGbl_ExceptionHandler (Status, + WalkState->MethodNode ? + WalkState->MethodNode->Name.Integer : 0, + WalkState->Opcode, WalkState->AmlOffset, NULL); + AcpiExEnterInterpreter (); + } + + AcpiDsClearImplicitReturn (WalkState); + +#ifdef ACPI_DISASSEMBLER + if (ACPI_FAILURE (Status)) + { + /* Display method locals/args if disassembler is present */ + + AcpiDmDumpMethodInfo (Status, WalkState, WalkState->Op); + } +#endif + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateMethodMutex + * + * PARAMETERS: ObjDesc - The method object + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object for a serialized control method + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsCreateMethodMutex ( + ACPI_OPERAND_OBJECT *MethodDesc) +{ + ACPI_OPERAND_OBJECT *MutexDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DsCreateMethodMutex); + + + /* Create the new mutex object */ + + MutexDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); + if (!MutexDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Create the actual OS Mutex */ + + Status = AcpiOsCreateMutex (&MutexDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + MutexDesc->Mutex.SyncLevel = MethodDesc->Method.SyncLevel; + MethodDesc->Method.Mutex = MutexDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBeginMethodExecution + * + * PARAMETERS: MethodNode - Node of the method + * ObjDesc - The method object + * WalkState - current state, NULL if not yet executing + * a method. + * + * RETURN: Status + * + * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, + * increments the thread count, and waits at the method semaphore + * for clearance to execute. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode); + + + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + /* Prevent wraparound of thread count */ + + if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX) + { + ACPI_ERROR ((AE_INFO, + "Method reached maximum reentrancy limit (255)")); + return_ACPI_STATUS (AE_AML_METHOD_LIMIT); + } + + /* + * If this method is serialized, we need to acquire the method mutex. + */ + if (ObjDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) + { + /* + * Create a mutex for the method if it is defined to be Serialized + * and a mutex has not already been created. We defer the mutex creation + * until a method is actually executed, to minimize the object count + */ + if (!ObjDesc->Method.Mutex) + { + Status = AcpiDsCreateMethodMutex (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * The CurrentSyncLevel (per-thread) must be less than or equal to + * the sync level of the method. This mechanism provides some + * deadlock prevention + * + * Top-level method invocation has no walk state at this point + */ + if (WalkState && + (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel)) + { + ACPI_ERROR ((AE_INFO, + "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)", + AcpiUtGetNodeName (MethodNode), + WalkState->Thread->CurrentSyncLevel)); + + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + /* + * Obtain the method mutex if necessary. Do not acquire mutex for a + * recursive call. + */ + if (!WalkState || + !ObjDesc->Method.Mutex->Mutex.ThreadId || + (WalkState->Thread->ThreadId != ObjDesc->Method.Mutex->Mutex.ThreadId)) + { + /* + * Acquire the method mutex. This releases the interpreter if we + * block (and reacquires it before it returns) + */ + Status = AcpiExSystemWaitMutex (ObjDesc->Method.Mutex->Mutex.OsMutex, + ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Update the mutex and walk info and save the original SyncLevel */ + + if (WalkState) + { + ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = + WalkState->Thread->CurrentSyncLevel; + + ObjDesc->Method.Mutex->Mutex.ThreadId = WalkState->Thread->ThreadId; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Method.SyncLevel; + } + else + { + ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = + ObjDesc->Method.Mutex->Mutex.SyncLevel; + } + } + + /* Always increase acquisition depth */ + + ObjDesc->Method.Mutex->Mutex.AcquisitionDepth++; + } + + /* + * Allocate an Owner ID for this method, only if this is the first thread + * to begin concurrent execution. We only need one OwnerId, even if the + * method is invoked recursively. + */ + if (!ObjDesc->Method.OwnerId) + { + Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + /* + * Increment the method parse tree thread count since it has been + * reentered one more time (even if it is the same thread) + */ + ObjDesc->Method.ThreadCount++; + AcpiMethodCount++; + return_ACPI_STATUS (Status); + + +Cleanup: + /* On error, must release the method mutex (if present) */ + + if (ObjDesc->Method.Mutex) + { + AcpiOsReleaseMutex (ObjDesc->Method.Mutex->Mutex.OsMutex); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCallControlMethod + * + * PARAMETERS: Thread - Info for this thread + * ThisWalkState - Current walk state + * Op - Current Op to be walked + * + * RETURN: Status + * + * DESCRIPTION: Transfer execution to a called control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_THREAD_STATE *Thread, + ACPI_WALK_STATE *ThisWalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_WALK_STATE *NextWalkState = NULL; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_EVALUATE_INFO *Info; + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Calling method %p, currentstate=%p\n", + ThisWalkState->PrevOp, ThisWalkState)); + + /* + * Get the namespace entry for the control method we are about to call + */ + MethodNode = ThisWalkState->MethodCallNode; + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Init for new method, possibly wait on method mutex */ + + Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, + ThisWalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Begin method parse/execution. Create a new walk state */ + + NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId, + NULL, ObjDesc, Thread); + if (!NextWalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * The resolved arguments were put on the previous walk state's operand + * stack. Operands on the previous walk state stack always + * start at index 0. Also, null terminate the list of arguments + */ + ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL; + + /* + * Allocate and initialize the evaluation information block + * TBD: this is somewhat inefficient, should change interface to + * DsInitAmlWalk. For now, keeps this struct off the CPU stack + */ + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Parameters = &ThisWalkState->Operands[0]; + + Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode, + ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, + Info, ACPI_IMODE_EXECUTE); + + ACPI_FREE (Info); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Delete the operands on the previous walkstate operand stack + * (they were copied to new objects) + */ + for (i = 0; i < ObjDesc->Method.ParamCount; i++) + { + AcpiUtRemoveReference (ThisWalkState->Operands [i]); + ThisWalkState->Operands [i] = NULL; + } + + /* Clear the operand stack */ + + ThisWalkState->NumOperands = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "**** Begin nested execution of [%4.4s] **** WalkState=%p\n", + MethodNode->Name.Ascii, NextWalkState)); + + /* Invoke an internal method if necessary */ + + if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + { + Status = ObjDesc->Method.Extra.Implementation (NextWalkState); + if (Status == AE_OK) + { + Status = AE_CTRL_TERMINATE; + } + } + + return_ACPI_STATUS (Status); + + +Cleanup: + + /* On error, we must terminate the method properly */ + + AcpiDsTerminateControlMethod (ObjDesc, NextWalkState); + if (NextWalkState) + { + AcpiDsDeleteWalkState (NextWalkState); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsRestartControlMethod + * + * PARAMETERS: WalkState - State for preempted method (caller) + * ReturnDesc - Return value from the called method + * + * RETURN: Status + * + * DESCRIPTION: Restart a method that was preempted by another (nested) method + * invocation. Handle the return value (if any) from the callee. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc) +{ + ACPI_STATUS Status; + int SameAsImplicitReturn; + + + ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState); + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n", + AcpiUtGetNodeName (WalkState->MethodNode), + WalkState->MethodCallOp, ReturnDesc)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n", + WalkState->ReturnUsed, + WalkState->Results, WalkState)); + + /* Did the called method return a value? */ + + if (ReturnDesc) + { + /* Is the implicit return object the same as the return desc? */ + + SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc); + + /* Are we actually going to use the return value? */ + + if (WalkState->ReturnUsed) + { + /* Save the return value from the previous method */ + + Status = AcpiDsResultPush (ReturnDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + return_ACPI_STATUS (Status); + } + + /* + * Save as THIS method's return value in case it is returned + * immediately to yet another method + */ + WalkState->ReturnDesc = ReturnDesc; + } + + /* + * The following code is the optional support for the so-called + * "implicit return". Some AML code assumes that the last value of the + * method is "implicitly" returned to the caller, in the absence of an + * explicit return value. + * + * Just save the last result of the method as the return value. + * + * NOTE: this is optional because the ASL language does not actually + * support this behavior. + */ + else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) || + SameAsImplicitReturn) + { + /* + * Delete the return value if it will not be used by the + * calling method or remove one reference if the explicit return + * is the same as the implicit return value. + */ + AcpiUtRemoveReference (ReturnDesc); + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsTerminateControlMethod + * + * PARAMETERS: MethodDesc - Method object + * WalkState - State associated with the method + * + * RETURN: None + * + * DESCRIPTION: Terminate a control method. Delete everything that the method + * created, delete all locals and arguments, and delete the parse + * tree if requested. + * + * MUTEX: Interpreter is locked + * + ******************************************************************************/ + +void +AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState); + + + /* MethodDesc is required, WalkState is optional */ + + if (!MethodDesc) + { + return_VOID; + } + + if (WalkState) + { + /* Delete all arguments and locals */ + + AcpiDsMethodDataDeleteAll (WalkState); + + /* + * If method is serialized, release the mutex and restore the + * current sync level for this thread + */ + if (MethodDesc->Method.Mutex) + { + /* Acquisition Depth handles recursive calls */ + + MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--; + if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth) + { + WalkState->Thread->CurrentSyncLevel = + MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; + + AcpiOsReleaseMutex (MethodDesc->Method.Mutex->Mutex.OsMutex); + MethodDesc->Method.Mutex->Mutex.ThreadId = 0; + } + } + + /* + * Delete any namespace objects created anywhere within the + * namespace by the execution of this method. Unless this method + * is a module-level executable code method, in which case we + * want make the objects permanent. + */ + if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) + { + AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); + } + } + + /* Decrement the thread count on the method */ + + if (MethodDesc->Method.ThreadCount) + { + MethodDesc->Method.ThreadCount--; + } + else + { + ACPI_ERROR ((AE_INFO, + "Invalid zero thread count in method")); + } + + /* Are there any other threads currently executing this method? */ + + if (MethodDesc->Method.ThreadCount) + { + /* + * Additional threads. Do not release the OwnerId in this case, + * we immediately reuse it for the next thread executing this method + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "*** Completed execution of one thread, %d threads remaining\n", + MethodDesc->Method.ThreadCount)); + } + else + { + /* This is the only executing thread for this method */ + + /* + * Support to dynamically change a method from NotSerialized to + * Serialized if it appears that the method is incorrectly written and + * does not support multiple thread execution. The best example of this + * is if such a method creates namespace objects and blocks. A second + * thread will fail with an AE_ALREADY_EXISTS exception + * + * This code is here because we must wait until the last thread exits + * before creating the synchronization semaphore. + */ + if ((MethodDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) && + (!MethodDesc->Method.Mutex)) + { + (void) AcpiDsCreateMethodMutex (MethodDesc); + } + + /* No more threads, we can free the OwnerId */ + + if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) + { + AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId); + } + } + + return_VOID; +} + + diff --git a/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c b/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c new file mode 100644 index 00000000000..551e8480a98 --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c @@ -0,0 +1,846 @@ +/******************************************************************************* + * + * Module Name: dsmthdat - control method arguments and local variables + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSMTHDAT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsmthdat") + +/* Local prototypes */ + +static void +AcpiDsMethodDataDeleteValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState); +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInit + * + * PARAMETERS: WalkState - Current walk state object + * + * RETURN: Status + * + * DESCRIPTION: Initialize the data structures that hold the method's arguments + * and locals. The data struct is an array of namespace nodes for + * each - this allows RefOf and DeRefOf to work properly for these + * special data types. + * + * NOTES: WalkState fields are initialized to zero by the + * ACPI_ALLOCATE_ZEROED(). + * + * A pseudo-Namespace Node is assigned to each argument and local + * so that RefOf() can return a pointer to the Node. + * + ******************************************************************************/ + +void +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (DsMethodDataInit); + + + /* Init the method arguments */ + + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE); + WalkState->Arguments[i].Name.Integer |= (i << 24); + WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED; + WalkState->Arguments[i].Type = ACPI_TYPE_ANY; + WalkState->Arguments[i].Flags = + ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; + } + + /* Init the method locals */ + + for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) + { + ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE); + + WalkState->LocalVariables[i].Name.Integer |= (i << 24); + WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED; + WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; + WalkState->LocalVariables[i].Flags = + ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteAll + * + * PARAMETERS: WalkState - Current walk state object + * + * RETURN: None + * + * DESCRIPTION: Delete method locals and arguments. Arguments are only + * deleted if this method was called from another method. + * + ******************************************************************************/ + +void +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 Index; + + + ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll); + + + /* Detach the locals */ + + for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++) + { + if (WalkState->LocalVariables[Index].Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", + Index, WalkState->LocalVariables[Index].Object)); + + /* Detach object (if present) and remove a reference */ + + AcpiNsDetachObject (&WalkState->LocalVariables[Index]); + } + } + + /* Detach the arguments */ + + for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++) + { + if (WalkState->Arguments[Index].Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", + Index, WalkState->Arguments[Index].Object)); + + /* Detach object (if present) and remove a reference */ + + AcpiNsDetachObject (&WalkState->Arguments[Index]); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInitArgs + * + * PARAMETERS: *Params - Pointer to a parameter list for the method + * MaxParamCount - The arg count for this method + * WalkState - Current walk state object + * + * RETURN: Status + * + * DESCRIPTION: Initialize arguments for a method. The parameter list is a list + * of ACPI operand objects, either null terminated or whose length + * is defined by MaxParamCount. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + UINT32 Index = 0; + + + ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params); + + + if (!Params) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); + return_ACPI_STATUS (AE_OK); + } + + /* Copy passed parameters into the new method stack frame */ + + while ((Index < ACPI_METHOD_NUM_ARGS) && + (Index < MaxParamCount) && + Params[Index]) + { + /* + * A valid parameter. + * Store the argument in the method/walk descriptor. + * Do not copy the arg in order to implement call by reference + */ + Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index, + Params[Index], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Index++; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetNode + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which Local or Arg whose type to get + * WalkState - Current walk state object + * Node - Where the node is returned. + * + * RETURN: Status and node + * + * DESCRIPTION: Get the Node associated with a local or arg. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetNode ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **Node) +{ + ACPI_FUNCTION_TRACE (DsMethodDataGetNode); + + + /* + * Method Locals and Arguments are supported + */ + switch (Type) + { + case ACPI_REFCLASS_LOCAL: + + if (Index > ACPI_METHOD_MAX_LOCAL) + { + ACPI_ERROR ((AE_INFO, + "Local index %d is invalid (max %d)", + Index, ACPI_METHOD_MAX_LOCAL)); + return_ACPI_STATUS (AE_AML_INVALID_INDEX); + } + + /* Return a pointer to the pseudo-node */ + + *Node = &WalkState->LocalVariables[Index]; + break; + + case ACPI_REFCLASS_ARG: + + if (Index > ACPI_METHOD_MAX_ARG) + { + ACPI_ERROR ((AE_INFO, + "Arg index %d is invalid (max %d)", + Index, ACPI_METHOD_MAX_ARG)); + return_ACPI_STATUS (AE_AML_INVALID_INDEX); + } + + /* Return a pointer to the pseudo-node */ + + *Node = &WalkState->Arguments[Index]; + break; + + default: + ACPI_ERROR ((AE_INFO, "Type %d is invalid", Type)); + return_ACPI_STATUS (AE_TYPE); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataSetValue + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which Local or Arg to get + * Object - Object to be inserted into the stack entry + * WalkState - Current walk state object + * + * RETURN: Status + * + * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. + * Note: There is no "implicit conversion" for locals. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (DsMethodDataSetValue); + + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "NewObj %p Type %2.2X, Refs=%d [%s]\n", Object, + Type, Object->Common.ReferenceCount, + AcpiUtGetTypeName (Object->Common.Type))); + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Increment ref count so object can't be deleted while installed. + * NOTE: We do not copy the object in order to preserve the call by + * reference semantics of ACPI Control Method invocation. + * (See ACPI Specification 2.0C) + */ + AcpiUtAddReference (Object); + + /* Install the object */ + + Node->Object = Object; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetValue + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which localVar or argument to get + * WalkState - Current walk state object + * DestDesc - Where Arg or Local value is returned + * + * RETURN: Status + * + * DESCRIPTION: Retrieve value of selected Arg or Local for this method + * Used only in AcpiExResolveToValue(). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (DsMethodDataGetValue); + + + /* Validate the object descriptor */ + + if (!DestDesc) + { + ACPI_ERROR ((AE_INFO, "Null object descriptor pointer")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the object from the node */ + + Object = Node->Object; + + /* Examine the returned object, it must be valid. */ + + if (!Object) + { + /* + * Index points to uninitialized object. + * This means that either 1) The expected argument was + * not passed to the method, or 2) A local variable + * was referenced by the method (via the ASL) + * before it was initialized. Either case is an error. + */ + + /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */ + + if (AcpiGbl_EnableInterpreterSlack) + { + Object = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!Object) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Node->Object = Object; + } + + /* Otherwise, return the error */ + + else switch (Type) + { + case ACPI_REFCLASS_ARG: + + ACPI_ERROR ((AE_INFO, + "Uninitialized Arg[%d] at node %p", + Index, Node)); + + return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); + + case ACPI_REFCLASS_LOCAL: + + /* + * No error message for this case, will be trapped again later to + * detect and ignore cases of Store(LocalX,LocalX) + */ + return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); + + default: + + ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: %X", Type)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + } + + /* + * The Index points to an initialized and valid object. + * Return an additional reference to the object + */ + *DestDesc = Object; + AcpiUtAddReference (Object); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteValue + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which localVar or argument to delete + * WalkState - Current walk state object + * + * RETURN: None + * + * DESCRIPTION: Delete the entry at Opcode:Index. Inserts + * a null into the stack slot after the object is deleted. + * + ******************************************************************************/ + +static void +AcpiDsMethodDataDeleteValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue); + + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Get the associated object */ + + Object = AcpiNsGetAttachedObject (Node); + + /* + * Undefine the Arg or Local by setting its descriptor + * pointer to NULL. Locals/Args can contain both + * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs + */ + Node->Object = NULL; + + if ((Object) && + (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND)) + { + /* + * There is a valid object. + * Decrement the reference count by one to balance the + * increment when the object was stored. + */ + AcpiUtRemoveReference (Object); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsStoreObjectToLocal + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which Local or Arg to set + * ObjDesc - Value to be stored + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed + * as the new value for the Arg or Local and the reference count + * for ObjDesc is incremented. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsStoreObjectToLocal ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *CurrentObjDesc; + ACPI_OPERAND_OBJECT *NewObjDesc; + + + ACPI_FUNCTION_TRACE (DsStoreObjectToLocal); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n", + Type, Index, ObjDesc)); + + /* Parameter validation */ + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + CurrentObjDesc = AcpiNsGetAttachedObject (Node); + if (CurrentObjDesc == ObjDesc) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", + ObjDesc)); + return_ACPI_STATUS (Status); + } + + /* + * If the reference count on the object is more than one, we must + * take a copy of the object before we store. A reference count + * of exactly 1 means that the object was just created during the + * evaluation of an expression, and we can safely use it since it + * is not used anywhere else. + */ + NewObjDesc = ObjDesc; + if (ObjDesc->Common.ReferenceCount > 1) + { + Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * If there is an object already in this slot, we either + * have to delete it, or if this is an argument and there + * is an object reference stored there, we have to do + * an indirect store! + */ + if (CurrentObjDesc) + { + /* + * Check for an indirect store if an argument + * contains an object reference (stored as an Node). + * We don't allow this automatic dereferencing for + * locals, since a store to a local should overwrite + * anything there, including an object reference. + * + * If both Arg0 and Local0 contain RefOf (Local4): + * + * Store (1, Arg0) - Causes indirect store to local4 + * Store (1, Local0) - Stores 1 in local0, overwriting + * the reference to local4 + * Store (1, DeRefof (Local0)) - Causes indirect store to local4 + * + * Weird, but true. + */ + if (Type == ACPI_REFCLASS_ARG) + { + /* + * If we have a valid reference object that came from RefOf(), + * do the indirect store + */ + if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) && + (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Arg (%p) is an ObjRef(Node), storing in node %p\n", + NewObjDesc, CurrentObjDesc)); + + /* + * Store this object to the Node (perform the indirect store) + * NOTE: No implicit conversion is performed, as per the ACPI + * specification rules on storing to Locals/Args. + */ + Status = AcpiExStoreObjectToNode (NewObjDesc, + CurrentObjDesc->Reference.Object, WalkState, + ACPI_NO_IMPLICIT_CONVERSION); + + /* Remove local reference if we copied the object above */ + + if (NewObjDesc != ObjDesc) + { + AcpiUtRemoveReference (NewObjDesc); + } + return_ACPI_STATUS (Status); + } + } + + /* Delete the existing object before storing the new one */ + + AcpiDsMethodDataDeleteValue (Type, Index, WalkState); + } + + /* + * Install the Obj descriptor (*NewObjDesc) into + * the descriptor for the Arg or Local. + * (increments the object reference count by one) + */ + Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState); + + /* Remove local reference if we copied the object above */ + + if (NewObjDesc != ObjDesc) + { + AcpiUtRemoveReference (NewObjDesc); + } + + return_ACPI_STATUS (Status); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetType + * + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * Index - Which Local or Arg whose type to get + * WalkState - Current walk state object + * + * RETURN: Data type of current value of the selected Arg or Local + * + * DESCRIPTION: Get the type of the object stored in the Local or Arg + * + ******************************************************************************/ + +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (DsMethodDataGetType); + + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_VALUE ((ACPI_TYPE_NOT_FOUND)); + } + + /* Get the object */ + + Object = AcpiNsGetAttachedObject (Node); + if (!Object) + { + /* Uninitialized local/arg, return TYPE_ANY */ + + return_VALUE (ACPI_TYPE_ANY); + } + + /* Get the object type */ + + return_VALUE (Object->Type); +} +#endif + + diff --git a/drivers/bus/acpi/acpica/dispatcher/dsobject.c b/drivers/bus/acpi/acpica/dispatcher/dsobject.c new file mode 100644 index 00000000000..cf444a1df2b --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dsobject.c @@ -0,0 +1,925 @@ +/****************************************************************************** + * + * Module Name: dsobject - Dispatcher object management routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSOBJECT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsobject") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr); + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiDsBuildInternalObject + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op object to the equivalent namespace object + * Simple objects are any objects other than a package object! + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DsBuildInternalObject); + + + *ObjDescPtr = NULL; + if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) + { + /* + * This is a named object reference. If this name was + * previously looked up in the namespace, it was stored in this op. + * Otherwise, go ahead and look it up now + */ + if (!Op->Common.Node) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, + Op->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node))); + if (ACPI_FAILURE (Status)) + { + /* Check if we are resolving a named reference within a package */ + + if ((Status == AE_NOT_FOUND) && (AcpiGbl_EnableInterpreterSlack) && + + ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + /* + * We didn't find the target and we are populating elements + * of a package - ignore if slack enabled. Some ASL code + * contains dangling invalid references in packages and + * expects that no exception will be issued. Leave the + * element as a null element. It cannot be used, but it + * can be overwritten by subsequent ASL code - this is + * typically the case. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Ignoring unresolved reference in package [%4.4s]\n", + WalkState->ScopeInfo->Scope.Node->Name.Ascii)); + + return_ACPI_STATUS (AE_OK); + } + else + { + ACPI_ERROR_NAMESPACE (Op->Common.Value.String, Status); + } + + return_ACPI_STATUS (Status); + } + } + + /* Special object resolution for elements of a package */ + + if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + /* + * Attempt to resolve the node to a value before we insert it into + * the package. If this is a reference to a common data type, + * resolve it immediately. According to the ACPI spec, package + * elements can only be "data objects" or method references. + * Attempt to resolve to an Integer, Buffer, String or Package. + * If cannot, return the named reference (for things like Devices, + * Methods, etc.) Buffer Fields and Fields will resolve to simple + * objects (int/buf/str/pkg). + * + * NOTE: References to things like Devices, Methods, Mutexes, etc. + * will remain as named references. This behavior is not described + * in the ACPI spec, but it appears to be an oversight. + */ + ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Op->Common.Node); + + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + switch (Op->Common.Node->Type) + { + /* + * For these types, we need the actual node, not the subobject. + * However, the subobject did not get an extra reference count above. + * + * TBD: should ExResolveNodeToValue be changed to fix this? + */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + + AcpiUtAddReference (Op->Common.Node->Object); + + /*lint -fallthrough */ + /* + * For these types, we need the actual node, not the subobject. + * The subobject got an extra reference count in ExResolveNodeToValue. + */ + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_METHOD: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_REGION: + + /* We will create a reference object for these types below */ + break; + + default: + /* + * All other types - the node was resolved to an actual + * object, we are done. + */ + goto Exit; + } + } + } + + /* Create and init a new internal ACPI object */ + + ObjDesc = AcpiUtCreateInternalObject ( + (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); + } + +Exit: + *ObjDescPtr = ObjDesc; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBuildInternalBufferObj + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * BufferLength - Length of the buffer + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalBufferObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 BufferLength, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *ByteList; + UINT32 ByteListLength = 0; + + + ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj); + + + /* + * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". + * The buffer object already exists (from the NS node), otherwise it must + * be created. + */ + ObjDesc = *ObjDescPtr; + if (!ObjDesc) + { + /* Create a new buffer object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* + * Second arg is the buffer data (optional) ByteList can be either + * individual bytes or a string initializer. In either case, a + * ByteList appears in the AML. + */ + Arg = Op->Common.Value.Arg; /* skip first arg */ + + ByteList = Arg->Named.Next; + if (ByteList) + { + if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP) + { + ACPI_ERROR ((AE_INFO, + "Expecting bytelist, got AML opcode %X in op %p", + ByteList->Common.AmlOpcode, ByteList)); + + AcpiUtRemoveReference (ObjDesc); + return (AE_TYPE); + } + + ByteListLength = (UINT32) ByteList->Common.Value.Integer; + } + + /* + * The buffer length (number of bytes) will be the larger of: + * 1) The specified buffer length and + * 2) The length of the initializer byte list + */ + ObjDesc->Buffer.Length = BufferLength; + if (ByteListLength > BufferLength) + { + ObjDesc->Buffer.Length = ByteListLength; + } + + /* Allocate the buffer */ + + if (ObjDesc->Buffer.Length == 0) + { + ObjDesc->Buffer.Pointer = NULL; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Buffer defined with zero length in AML, creating\n")); + } + else + { + ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED ( + ObjDesc->Buffer.Length); + if (!ObjDesc->Buffer.Pointer) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize buffer from the ByteList (if present) */ + + if (ByteList) + { + ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data, + ByteListLength); + } + } + + ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBuildInternalPackageObj + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * ElementCount - Number of elements in the package - this is + * the NumElements argument to Package() + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object + * + * NOTE: The number of elements in the package will be always be the NumElements + * count, regardless of the number of elements in the package list. If + * NumElements is smaller, only that many package list elements are used. + * if NumElements is larger, the Package object is padded out with + * objects of type Uninitialized (as per ACPI spec.) + * + * Even though the ASL compilers do not allow NumElements to be smaller + * than the Package list length (for the fixed length package opcode), some + * BIOS code modifies the AML on the fly to adjust the NumElements, and + * this code compensates for that. This also provides compatibility with + * other AML interpreters. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 ElementCount, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_PARSE_OBJECT *Parent; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_STATUS Status = AE_OK; + UINT32 i; + UINT16 Index; + UINT16 ReferenceCount; + + + ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj); + + + /* Find the parent of a possibly nested package */ + + Parent = Op->Common.Parent; + while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + Parent = Parent->Common.Parent; + } + + /* + * If we are evaluating a Named package object "Name (xxxx, Package)", + * the package object already exists, otherwise it must be created. + */ + ObjDesc = *ObjDescPtr; + if (!ObjDesc) + { + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Package.Node = Parent->Common.Node; + } + + /* + * Allocate the element array (array of pointers to the individual + * objects) based on the NumElements parameter. Add an extra pointer slot + * so that the list is always null terminated. + */ + ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) ElementCount + 1) * sizeof (void *)); + + if (!ObjDesc->Package.Elements) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Package.Count = ElementCount; + + /* + * Initialize the elements of the package, up to the NumElements count. + * Package is automatically padded with uninitialized (NULL) elements + * if NumElements is greater than the package list length. Likewise, + * Package is truncated if NumElements is less than the list length. + */ + Arg = Op->Common.Value.Arg; + Arg = Arg->Common.Next; + for (i = 0; Arg && (i < ElementCount); i++) + { + if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) + { + if (Arg->Common.Node->Type == ACPI_TYPE_METHOD) + { + /* + * A method reference "looks" to the parser to be a method + * invocation, so we special case it here + */ + Arg->Common.AmlOpcode = AML_INT_NAMEPATH_OP; + Status = AcpiDsBuildInternalObject (WalkState, Arg, + &ObjDesc->Package.Elements[i]); + } + else + { + /* This package element is already built, just get it */ + + ObjDesc->Package.Elements[i] = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); + } + } + else + { + Status = AcpiDsBuildInternalObject (WalkState, Arg, + &ObjDesc->Package.Elements[i]); + } + + if (*ObjDescPtr) + { + /* Existing package, get existing reference count */ + + ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount; + if (ReferenceCount > 1) + { + /* Make new element ref count match original ref count */ + + for (Index = 0; Index < (ReferenceCount - 1); Index++) + { + AcpiUtAddReference ((ObjDesc->Package.Elements[i])); + } + } + } + + Arg = Arg->Common.Next; + } + + /* Check for match between NumElements and actual length of PackageList */ + + if (Arg) + { + /* + * NumElements was exhausted, but there are remaining elements in the + * PackageList. Truncate the package to NumElements. + * + * Note: technically, this is an error, from ACPI spec: "It is an error + * for NumElements to be less than the number of elements in the + * PackageList". However, we just print a message and + * no exception is returned. This provides Windows compatibility. Some + * BIOSs will alter the NumElements on the fly, creating this type + * of ill-formed package object. + */ + while (Arg) + { + /* + * We must delete any package elements that were created earlier + * and are not going to be used because of the package truncation. + */ + if (Arg->Common.Node) + { + AcpiUtRemoveReference ( + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node)); + Arg->Common.Node = NULL; + } + + /* Find out how many elements there really are */ + + i++; + Arg = Arg->Common.Next; + } + + ACPI_INFO ((AE_INFO, + "Actual Package length (0x%X) is larger than NumElements field (0x%X), truncated\n", + i, ElementCount)); + } + else if (i < ElementCount) + { + /* + * Arg list (elements) was exhausted, but we did not reach NumElements count. + * Note: this is not an error, the package is padded out with NULLs. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Package List length (0x%X) smaller than NumElements count (0x%X), padded with null elements\n", + i, ElementCount)); + } + + ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateNode + * + * PARAMETERS: WalkState - Current walk state + * Node - NS Node to be initialized + * Op - Parser object to be translated + * + * RETURN: Status + * + * DESCRIPTION: Create the object to be associated with a namespace node + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op); + + + /* + * Because of the execution pass through the non-control-method + * parts of the table, we can arrive here twice. Only init + * the named object node the first time through + */ + if (AcpiNsGetAttachedObject (Node)) + { + return_ACPI_STATUS (AE_OK); + } + + if (!Op->Common.Value.Arg) + { + /* No arguments, there is nothing to do */ + + return_ACPI_STATUS (AE_OK); + } + + /* Build an internal object for the argument(s) */ + + Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Re-type the object according to its argument */ + + Node->Type = ObjDesc->Common.Type; + + /* Attach obj to node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + +#endif /* ACPI_NO_METHOD_EXECUTION */ + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitObjectFromOp + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser op used to init the internal object + * Opcode - AML opcode associated with the object + * RetObjDesc - Namespace object to be initialized + * + * RETURN: Status + * + * DESCRIPTION: Initialize a namespace object from a parser Op and its + * associated arguments. The namespace object is a more compact + * representation of the Op and its arguments. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitObjectFromOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode, + ACPI_OPERAND_OBJECT **RetObjDesc) +{ + const ACPI_OPCODE_INFO *OpInfo; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (DsInitObjectFromOp); + + + ObjDesc = *RetObjDesc; + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + /* Unknown opcode */ + + return_ACPI_STATUS (AE_TYPE); + } + + /* Perform per-object initialization */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* + * Defer evaluation of Buffer TermArg operand + */ + ObjDesc->Buffer.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); + ObjDesc->Buffer.AmlStart = Op->Named.Data; + ObjDesc->Buffer.AmlLength = Op->Named.Length; + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * Defer evaluation of Package TermArg operand + */ + ObjDesc->Package.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); + ObjDesc->Package.AmlStart = Op->Named.Data; + ObjDesc->Package.AmlLength = Op->Named.Length; + break; + + + case ACPI_TYPE_INTEGER: + + switch (OpInfo->Type) + { + case AML_TYPE_CONSTANT: + /* + * Resolve AML Constants here - AND ONLY HERE! + * All constants are integers. + * We mark the integer with a flag that indicates that it started + * life as a constant -- so that stores to constants will perform + * as expected (noop). ZeroOp is used as a placeholder for optional + * target operands. + */ + ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT; + + switch (Opcode) + { + case AML_ZERO_OP: + + ObjDesc->Integer.Value = 0; + break; + + case AML_ONE_OP: + + ObjDesc->Integer.Value = 1; + break; + + case AML_ONES_OP: + + ObjDesc->Integer.Value = ACPI_INTEGER_MAX; + + /* Truncate value if we are executing from a 32-bit ACPI table */ + +#ifndef ACPI_NO_METHOD_EXECUTION + AcpiExTruncateFor32bitTable (ObjDesc); +#endif + break; + + case AML_REVISION_OP: + + ObjDesc->Integer.Value = ACPI_CA_VERSION; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown constant opcode %X", Opcode)); + Status = AE_AML_OPERAND_TYPE; + break; + } + break; + + + case AML_TYPE_LITERAL: + + ObjDesc->Integer.Value = Op->Common.Value.Integer; +#ifndef ACPI_NO_METHOD_EXECUTION + AcpiExTruncateFor32bitTable (ObjDesc); +#endif + break; + + + default: + ACPI_ERROR ((AE_INFO, "Unknown Integer type %X", + OpInfo->Type)); + Status = AE_AML_OPERAND_TYPE; + break; + } + break; + + + case ACPI_TYPE_STRING: + + ObjDesc->String.Pointer = Op->Common.Value.String; + ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String); + + /* + * The string is contained in the ACPI table, don't ever try + * to delete it + */ + ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; + break; + + + case ACPI_TYPE_METHOD: + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + switch (OpInfo->Type) + { + case AML_TYPE_LOCAL_VARIABLE: + + /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */ + + ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP; + ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL; + +#ifndef ACPI_NO_METHOD_EXECUTION + Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL, + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); +#endif + break; + + + case AML_TYPE_METHOD_ARGUMENT: + + /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */ + + ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP; + ObjDesc->Reference.Class = ACPI_REFCLASS_ARG; + +#ifndef ACPI_NO_METHOD_EXECUTION + Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG, + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); +#endif + break; + + default: /* Object name or Debug object */ + + switch (Op->Common.AmlOpcode) + { + case AML_INT_NAMEPATH_OP: + + /* Node was saved in Op */ + + ObjDesc->Reference.Node = Op->Common.Node; + ObjDesc->Reference.Object = Op->Common.Node->Object; + ObjDesc->Reference.Class = ACPI_REFCLASS_NAME; + break; + + case AML_DEBUG_OP: + + ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unimplemented reference type for AML opcode: %4.4X", Opcode)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + break; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unimplemented data type: %X", + ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + break; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/dispatcher/dsopcode.c b/drivers/bus/acpi/acpica/dispatcher/dsopcode.c new file mode 100644 index 00000000000..3edbacc1d95 --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dsopcode.c @@ -0,0 +1,1619 @@ +/****************************************************************************** + * + * Module Name: dsopcode - Dispatcher Op Region support and handling of + * "control" opcodes + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSOPCODE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsopcode") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsExecuteArguments ( + ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart); + +static ACPI_STATUS +AcpiDsInitBufferField ( + UINT16 AmlOpcode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *BufferDesc, + ACPI_OPERAND_OBJECT *OffsetDesc, + ACPI_OPERAND_OBJECT *LengthDesc, + ACPI_OPERAND_OBJECT *ResultDesc); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsExecuteArguments + * + * PARAMETERS: Node - Object NS node + * ScopeNode - Parent NS node + * AmlLength - Length of executable AML + * AmlStart - Pointer to the AML + * + * RETURN: Status. + * + * DESCRIPTION: Late (deferred) execution of region or field arguments + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsExecuteArguments ( + ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (DsExecuteArguments); + + + /* + * Allocate a new parser op to be the root of the parsed tree + */ + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save the Node for use in AcpiPsParseAml */ + + Op->Common.Node = ScopeNode; + + /* Create and initialize a new parser state */ + + WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, + AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* Mark this parse as a deferred opcode */ + + WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP; + WalkState->DeferredNode = Node; + + /* Pass1: Parse the entire declaration */ + + Status = AcpiPsParseAml (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Get and init the Op created above */ + + Op->Common.Node = Node; + AcpiPsDeleteParseTree (Op); + + /* Evaluate the deferred arguments */ + + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Op->Common.Node = ScopeNode; + + /* Create and initialize a new parser state */ + + WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Execute the opcode and arguments */ + + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, + AmlLength, NULL, ACPI_IMODE_EXECUTE); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* Mark this execution as a deferred opcode */ + + WalkState->DeferredNode = Node; + Status = AcpiPsParseAml (WalkState); + +Cleanup: + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetBufferFieldArguments + * + * PARAMETERS: ObjDesc - A valid BufferField object + * + * RETURN: Status. + * + * DESCRIPTION: Get BufferField Buffer and Index. This implements the late + * evaluation of these field attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetBufferFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT *ExtraDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the AML pointer (method object) and BufferField node */ + + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + Node = ObjDesc->BufferField.Node; + + ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", + AcpiUtGetNodeName (Node))); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetBankFieldArguments + * + * PARAMETERS: ObjDesc - A valid BankField object + * + * RETURN: Status. + * + * DESCRIPTION: Get BankField BankValue. This implements the late + * evaluation of these field attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetBankFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT *ExtraDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the AML pointer (method object) and BankField node */ + + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + Node = ObjDesc->BankField.Node; + + ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD, Node, NULL)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n", + AcpiUtGetNodeName (Node))); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetBufferArguments + * + * PARAMETERS: ObjDesc - A valid Buffer object + * + * RETURN: Status. + * + * DESCRIPTION: Get Buffer length and initializer byte list. This implements + * the late evaluation of these attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetBufferArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the Buffer node */ + + Node = ObjDesc->Buffer.Node; + if (!Node) + { + ACPI_ERROR ((AE_INFO, + "No pointer back to NS node in buffer obj %p", ObjDesc)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node, + ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetPackageArguments + * + * PARAMETERS: ObjDesc - A valid Package object + * + * RETURN: Status. + * + * DESCRIPTION: Get Package length and initializer byte list. This implements + * the late evaluation of these attributes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsGetPackageArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the Package node */ + + Node = ObjDesc->Package.Node; + if (!Node) + { + ACPI_ERROR ((AE_INFO, + "No pointer back to NS node in package %p", ObjDesc)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node, + ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetRegionArguments + * + * PARAMETERS: ObjDesc - A valid region object + * + * RETURN: Status. + * + * DESCRIPTION: Get region address and length. This implements the late + * evaluation of these region attributes. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetRegionArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ExtraDesc; + + + ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc); + + + if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + if (!ExtraDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Get the Region node */ + + Node = ObjDesc->Region.Node; + + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL)); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", + AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart)); + + /* Execute the argument AML */ + + Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitializeRegion + * + * PARAMETERS: ObjHandle - Region namespace node + * + * RETURN: Status + * + * DESCRIPTION: Front end to EvInitializeRegion + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitializeRegion ( + ACPI_HANDLE ObjHandle) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ObjDesc = AcpiNsGetAttachedObject (ObjHandle); + + /* Namespace is NOT locked */ + + Status = AcpiEvInitializeRegion (ObjDesc, FALSE); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitBufferField + * + * PARAMETERS: AmlOpcode - CreateXxxField + * ObjDesc - BufferField object + * BufferDesc - Host Buffer + * OffsetDesc - Offset into buffer + * LengthDesc - Length of field (CREATE_FIELD_OP only) + * ResultDesc - Where to store the result + * + * RETURN: Status + * + * DESCRIPTION: Perform actual initialization of a buffer field + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsInitBufferField ( + UINT16 AmlOpcode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *BufferDesc, + ACPI_OPERAND_OBJECT *OffsetDesc, + ACPI_OPERAND_OBJECT *LengthDesc, + ACPI_OPERAND_OBJECT *ResultDesc) +{ + UINT32 Offset; + UINT32 BitOffset; + UINT32 BitCount; + UINT8 FieldFlags; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc); + + + /* Host object must be a Buffer */ + + if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER) + { + ACPI_ERROR ((AE_INFO, + "Target of Create Field is not a Buffer object - %s", + AcpiUtGetObjectTypeName (BufferDesc))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * The last parameter to all of these opcodes (ResultDesc) started + * out as a NameString, and should therefore now be a NS node + * after resolution in AcpiExResolveOperands(). + */ + if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, + "(%s) destination not a NS Node [%s]", + AcpiPsGetOpcodeName (AmlOpcode), + AcpiUtGetDescriptorName (ResultDesc))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + Offset = (UINT32) OffsetDesc->Integer.Value; + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + switch (AmlOpcode) + { + case AML_CREATE_FIELD_OP: + + /* Offset is in bits, count is in bits */ + + FieldFlags = AML_FIELD_ACCESS_BYTE; + BitOffset = Offset; + BitCount = (UINT32) LengthDesc->Integer.Value; + + /* Must have a valid (>0) bit count */ + + if (BitCount == 0) + { + ACPI_ERROR ((AE_INFO, + "Attempt to CreateField of length zero")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + break; + + case AML_CREATE_BIT_FIELD_OP: + + /* Offset is in bits, Field is one bit */ + + BitOffset = Offset; + BitCount = 1; + FieldFlags = AML_FIELD_ACCESS_BYTE; + break; + + case AML_CREATE_BYTE_FIELD_OP: + + /* Offset is in bytes, field is one byte */ + + BitOffset = 8 * Offset; + BitCount = 8; + FieldFlags = AML_FIELD_ACCESS_BYTE; + break; + + case AML_CREATE_WORD_FIELD_OP: + + /* Offset is in bytes, field is one word */ + + BitOffset = 8 * Offset; + BitCount = 16; + FieldFlags = AML_FIELD_ACCESS_WORD; + break; + + case AML_CREATE_DWORD_FIELD_OP: + + /* Offset is in bytes, field is one dword */ + + BitOffset = 8 * Offset; + BitCount = 32; + FieldFlags = AML_FIELD_ACCESS_DWORD; + break; + + case AML_CREATE_QWORD_FIELD_OP: + + /* Offset is in bytes, field is one qword */ + + BitOffset = 8 * Offset; + BitCount = 64; + FieldFlags = AML_FIELD_ACCESS_QWORD; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown field creation opcode %02x", + AmlOpcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* Entire field must fit within the current length of the buffer */ + + if ((BitOffset + BitCount) > + (8 * (UINT32) BufferDesc->Buffer.Length)) + { + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)", + AcpiUtGetNodeName (ResultDesc), + BitOffset + BitCount, + AcpiUtGetNodeName (BufferDesc->Buffer.Node), + 8 * (UINT32) BufferDesc->Buffer.Length)); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + /* + * Initialize areas of the field object that are common to all fields + * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), + * UPDATE_RULE = 0 (UPDATE_PRESERVE) + */ + Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, + BitOffset, BitCount); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + ObjDesc->BufferField.BufferObj = BufferDesc; + + /* Reference count for BufferDesc inherits ObjDesc count */ + + BufferDesc->Common.ReferenceCount = (UINT16) + (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount); + + +Cleanup: + + /* Always delete the operands */ + + AcpiUtRemoveReference (OffsetDesc); + AcpiUtRemoveReference (BufferDesc); + + if (AmlOpcode == AML_CREATE_FIELD_OP) + { + AcpiUtRemoveReference (LengthDesc); + } + + /* On failure, delete the result descriptor */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ + } + else + { + /* Now the address and length are valid for this BufferField */ + + ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalBufferFieldOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid BufferField Op object + * + * RETURN: Status + * + * DESCRIPTION: Get BufferField Buffer and Index + * Called from AcpiDsExecEndOp during BufferField parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalBufferFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op); + + + /* + * This is where we evaluate the address and length fields of the + * CreateXxxField declaration + */ + Node = Op->Common.Node; + + /* NextOp points to the op that holds the Buffer */ + + NextOp = Op->Common.Value.Arg; + + /* Evaluate/create the address and length operands */ + + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Resolve the operands */ + + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "(%s) bad operand(s) (%X)", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); + + return_ACPI_STATUS (Status); + } + + /* Initialize the Buffer Field */ + + if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) + { + /* NOTE: Slightly different operands for this opcode */ + + Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, + WalkState->Operands[0], WalkState->Operands[1], + WalkState->Operands[2], WalkState->Operands[3]); + } + else + { + /* All other, CreateXxxField opcodes */ + + Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, + WalkState->Operands[0], WalkState->Operands[1], + NULL, WalkState->Operands[2]); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalRegionOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid region Op object + * + * RETURN: Status + * + * DESCRIPTION: Get region address and length + * Called from AcpiDsExecEndOp during OpRegion parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *OperandDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op); + + + /* + * This is where we evaluate the address and length fields of the + * OpRegion declaration + */ + Node = Op->Common.Node; + + /* NextOp points to the op that holds the SpaceID */ + + NextOp = Op->Common.Value.Arg; + + /* NextOp points to address op */ + + NextOp = NextOp->Common.Next; + + /* Evaluate/create the address and length operands */ + + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Resolve the length and address operands to numbers */ + + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * Get the length operand and save it + * (at Top of stack) + */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; + + ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; + AcpiUtRemoveReference (OperandDesc); + + /* + * Get the address and save it + * (at top of stack - 1) + */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; + + ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) + OperandDesc->Integer.Value; + AcpiUtRemoveReference (OperandDesc); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", + ObjDesc, + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length)); + + /* Now the address and length are valid for this opregion */ + + ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalTableRegionOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid region Op object + * + * RETURN: Status + * + * DESCRIPTION: Get region address and length + * Called from AcpiDsExecEndOp during DataTableRegion parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalTableRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **Operand; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + UINT32 TableIndex; + ACPI_TABLE_HEADER *Table; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op); + + + /* + * This is where we evaluate the SignatureString and OemIDString + * and OemTableIDString of the DataTableRegion declaration + */ + Node = Op->Common.Node; + + /* NextOp points to SignatureString op */ + + NextOp = Op->Common.Value.Arg; + + /* + * Evaluate/create the SignatureString and OemIDString + * and OemTableIDString operands + */ + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Resolve the SignatureString and OemIDString + * and OemTableIDString operands + */ + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Operand = &WalkState->Operands[0]; + + /* Find the ACPI table */ + + Status = AcpiTbFindTable (Operand[0]->String.Pointer, + Operand[1]->String.Pointer, Operand[2]->String.Pointer, + &TableIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtRemoveReference (Operand[0]); + AcpiUtRemoveReference (Operand[1]); + AcpiUtRemoveReference (Operand[2]); + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); + ObjDesc->Region.Length = Table->Length; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", + ObjDesc, + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length)); + + /* Now the address and length are valid for this opregion */ + + ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalDataObjectOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid DataObject Op object + * ObjDesc - DataObject + * + * RETURN: Status + * + * DESCRIPTION: Get the operands and complete the following data object types: + * Buffer, Package. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalDataObjectOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ArgDesc; + UINT32 Length; + + + ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands); + + + /* The first operand (for all of these data objects) is the length */ + + /* + * Set proper index into operand stack for AcpiDsObjStackPush + * invoked inside AcpiDsCreateOperand. + */ + WalkState->OperandIndex = WalkState->NumOperands; + + Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveOperands (WalkState->Opcode, + &(WalkState->Operands [WalkState->NumOperands -1]), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Extract length operand */ + + ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; + Length = (UINT32) ArgDesc->Integer.Value; + + /* Cleanup for length operand */ + + Status = AcpiDsObjStackPop (1, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtRemoveReference (ArgDesc); + + /* + * Create the actual data object + */ + switch (Op->Common.AmlOpcode) + { + case AML_BUFFER_OP: + + Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); + break; + + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); + break; + + default: + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + if (ACPI_SUCCESS (Status)) + { + /* + * Return the object in the WalkState, unless the parent is a package - + * in this case, the return object will be stored in the parse tree + * for the package. + */ + if ((!Op->Common.Parent) || + ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && + (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) && + (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) + { + WalkState->ResultObj = ObjDesc; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalBankFieldOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid BankField Op object + * + * RETURN: Status + * + * DESCRIPTION: Get BankField BankValue + * Called from AcpiDsExecEndOp during BankField parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalBankFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *OperandDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *Arg; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op); + + + /* + * This is where we evaluate the BankValue field of the + * BankField declaration + */ + + /* NextOp points to the op that holds the Region */ + + NextOp = Op->Common.Value.Arg; + + /* NextOp points to the op that holds the Bank Register */ + + NextOp = NextOp->Common.Next; + + /* NextOp points to the op that holds the Bank Value */ + + NextOp = NextOp->Common.Next; + + /* + * Set proper index into operand stack for AcpiDsObjStackPush + * invoked inside AcpiDsCreateOperand. + * + * We use WalkState->Operands[0] to store the evaluated BankValue + */ + WalkState->OperandIndex = 0; + + Status = AcpiDsCreateOperand (WalkState, NextOp, 0); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1); + /* + * Get the BankValue operand and save it + * (at Top of stack) + */ + OperandDesc = WalkState->Operands[0]; + + /* Arg points to the start Bank Field */ + + Arg = AcpiPsGetArg (Op, 4); + while (Arg) + { + /* Ignore OFFSET and ACCESSAS terms here */ + + if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) + { + Node = Arg->Common.Node; + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value; + } + + /* Move to next field in the list */ + + Arg = Arg->Common.Next; + } + + AcpiUtRemoveReference (OperandDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsExecBeginControlOp + * + * PARAMETERS: WalkList - The list that owns the walk stack + * Op - The control Op + * + * RETURN: Status + * + * DESCRIPTION: Handles all control ops encountered during control method + * execution. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsExecBeginControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *ControlState; + + + ACPI_FUNCTION_NAME (DsExecBeginControlOp); + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, + Op->Common.AmlOpcode, WalkState)); + + switch (Op->Common.AmlOpcode) + { + case AML_WHILE_OP: + + /* + * If this is an additional iteration of a while loop, continue. + * There is no need to allocate a new control state. + */ + if (WalkState->ControlState) + { + if (WalkState->ControlState->Control.AmlPredicateStart == + (WalkState->ParserState.Aml - 1)) + { + /* Reset the state to start-of-loop */ + + WalkState->ControlState->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; + break; + } + } + + /*lint -fallthrough */ + + case AML_IF_OP: + + /* + * IF/WHILE: Create a new control state to manage these + * constructs. We need to manage these as a stack, in order + * to handle nesting. + */ + ControlState = AcpiUtCreateControlState (); + if (!ControlState) + { + Status = AE_NO_MEMORY; + break; + } + /* + * Save a pointer to the predicate for multiple executions + * of a loop + */ + ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; + ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; + ControlState->Control.Opcode = Op->Common.AmlOpcode; + + + /* Push the control state on this walk's control stack */ + + AcpiUtPushGenericState (&WalkState->ControlState, ControlState); + break; + + case AML_ELSE_OP: + + /* Predicate is in the state object */ + /* If predicate is true, the IF was executed, ignore ELSE part */ + + if (WalkState->LastPredicate) + { + Status = AE_CTRL_TRUE; + } + + break; + + case AML_RETURN_OP: + + break; + + default: + break; + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsExecEndControlOp + * + * PARAMETERS: WalkList - The list that owns the walk stack + * Op - The control Op + * + * RETURN: Status + * + * DESCRIPTION: Handles all control ops encountered during control method + * execution. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsExecEndControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *ControlState; + + + ACPI_FUNCTION_NAME (DsExecEndControlOp); + + + switch (Op->Common.AmlOpcode) + { + case AML_IF_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op)); + + /* + * Save the result of the predicate in case there is an + * ELSE to come + */ + WalkState->LastPredicate = + (BOOLEAN) WalkState->ControlState->Common.Value; + + /* + * Pop the control state that was created at the start + * of the IF and free it + */ + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + break; + + + case AML_ELSE_OP: + + break; + + + case AML_WHILE_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op)); + + ControlState = WalkState->ControlState; + if (ControlState->Common.Value) + { + /* Predicate was true, the body of the loop was just executed */ + + /* + * This loop counter mechanism allows the interpreter to escape + * possibly infinite loops. This can occur in poorly written AML + * when the hardware does not respond within a while loop and the + * loop does not implement a timeout. + */ + ControlState->Control.LoopCount++; + if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS) + { + Status = AE_AML_INFINITE_LOOP; + break; + } + + /* + * Go back and evaluate the predicate and maybe execute the loop + * another time + */ + Status = AE_CTRL_PENDING; + WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; + break; + } + + /* Predicate was false, terminate this while loop */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[WHILE_OP] termination! Op=%p\n",Op)); + + /* Pop this control state and free it */ + + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + break; + + + case AML_RETURN_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg)); + + /* + * One optional operand -- the return value + * It can be either an immediate operand or a result that + * has been bubbled up the tree + */ + if (Op->Common.Value.Arg) + { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + + /* Return statement has an immediate operand */ + + Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * If value being returned is a Reference (such as + * an arg or local), resolve it now because it may + * cease to exist at the end of the method. + */ + Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Get the return value and save as the last result + * value. This is the only place where WalkState->ReturnDesc + * is set to anything other than zero! + */ + WalkState->ReturnDesc = WalkState->Operands[0]; + } + else if (WalkState->ResultCount) + { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + + /* + * The return value has come from a previous calculation. + * + * If value being returned is a Reference (such as + * an arg or local), resolve it now because it may + * cease to exist at the end of the method. + * + * Allow references created by the Index operator to return unchanged. + */ + if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && + ((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + ((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX)) + { + Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0]; + } + else + { + /* No return operand */ + + if (WalkState->NumOperands) + { + AcpiUtRemoveReference (WalkState->Operands [0]); + } + + WalkState->Operands [0] = NULL; + WalkState->NumOperands = 0; + WalkState->ReturnDesc = NULL; + } + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Completed RETURN_OP State=%p, RetVal=%p\n", + WalkState, WalkState->ReturnDesc)); + + /* End the control method execution right now */ + + Status = AE_CTRL_TERMINATE; + break; + + + case AML_NOOP_OP: + + /* Just do nothing! */ + break; + + + case AML_BREAK_POINT_OP: + + /* + * Set the single-step flag. This will cause the debugger (if present) + * to break to the console within the AML debugger at the start of the + * next AML instruction. + */ + ACPI_DEBUGGER_EXEC ( + AcpiGbl_CmSingleStep = TRUE); + ACPI_DEBUGGER_EXEC ( + AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n")); + + /* Call to the OSL in case OS wants a piece of the action */ + + Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, + "Executed AML Breakpoint opcode"); + break; + + + case AML_BREAK_OP: + case AML_CONTINUE_OP: /* ACPI 2.0 */ + + + /* Pop and delete control states until we find a while */ + + while (WalkState->ControlState && + (WalkState->ControlState->Control.Opcode != AML_WHILE_OP)) + { + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + } + + /* No while found? */ + + if (!WalkState->ControlState) + { + return (AE_AML_NO_WHILE); + } + + /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ + + WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; + + /* Return status depending on opcode */ + + if (Op->Common.AmlOpcode == AML_BREAK_OP) + { + Status = AE_CTRL_BREAK; + } + else + { + Status = AE_CTRL_CONTINUE; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown control opcode=%X Op=%p", + Op->Common.AmlOpcode, Op)); + + Status = AE_AML_BAD_OPCODE; + break; + } + + return (Status); +} + diff --git a/drivers/bus/acpi/acpica/dispatcher/dsutils.c b/drivers/bus/acpi/acpica/dispatcher/dsutils.c new file mode 100644 index 00000000000..6c211ace8c6 --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dsutils.c @@ -0,0 +1,1009 @@ +/******************************************************************************* + * + * Module Name: dsutils - Dispatcher utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsClearImplicitReturn + * + * PARAMETERS: WalkState - Current State + * + * RETURN: None. + * + * DESCRIPTION: Clear and remove a reference on an implicit return value. Used + * to delete "stale" return values (if enabled, the return value + * from every operator is saved at least momentarily, in case the + * parent method exits.) + * + ******************************************************************************/ + +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME (DsClearImplicitReturn); + + + /* + * Slack must be enabled for this feature + */ + if (!AcpiGbl_EnableInterpreterSlack) + { + return; + } + + if (WalkState->ImplicitReturnObj) + { + /* + * Delete any "stale" implicit return. However, in + * complex statements, the implicit return value can be + * bubbled up several levels. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Removing reference on stale implicit return obj %p\n", + WalkState->ImplicitReturnObj)); + + AcpiUtRemoveReference (WalkState->ImplicitReturnObj); + WalkState->ImplicitReturnObj = NULL; + } +} + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiDsDoImplicitReturn + * + * PARAMETERS: ReturnDesc - The return value + * WalkState - Current State + * AddReference - True if a reference should be added to the + * return object + * + * RETURN: TRUE if implicit return enabled, FALSE otherwise + * + * DESCRIPTION: Implements the optional "implicit return". We save the result + * of every ASL operator and control method invocation in case the + * parent method exit. Before storing a new return value, we + * delete the previous return value. + * + ******************************************************************************/ + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference) +{ + ACPI_FUNCTION_NAME (DsDoImplicitReturn); + + + /* + * Slack must be enabled for this feature, and we must + * have a valid return object + */ + if ((!AcpiGbl_EnableInterpreterSlack) || + (!ReturnDesc)) + { + return (FALSE); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result %p will be implicitly returned; Prev=%p\n", + ReturnDesc, + WalkState->ImplicitReturnObj)); + + /* + * Delete any "stale" implicit return value first. However, in + * complex statements, the implicit return value can be + * bubbled up several levels, so we don't clear the value if it + * is the same as the ReturnDesc. + */ + if (WalkState->ImplicitReturnObj) + { + if (WalkState->ImplicitReturnObj == ReturnDesc) + { + return (TRUE); + } + AcpiDsClearImplicitReturn (WalkState); + } + + /* Save the implicit return value, add a reference if requested */ + + WalkState->ImplicitReturnObj = ReturnDesc; + if (AddReference) + { + AcpiUtAddReference (ReturnDesc); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsIsResultUsed + * + * PARAMETERS: Op - Current Op + * WalkState - Current State + * + * RETURN: TRUE if result is used, FALSE otherwise + * + * DESCRIPTION: Check if a result object will be used by the parent + * + ******************************************************************************/ + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + const ACPI_OPCODE_INFO *ParentInfo; + + ACPI_FUNCTION_TRACE_PTR (DsIsResultUsed, Op); + + + /* Must have both an Op and a Result Object */ + + if (!Op) + { + ACPI_ERROR ((AE_INFO, "Null Op")); + return_UINT8 (TRUE); + } + + /* + * We know that this operator is not a + * Return() operator (would not come here.) The following code is the + * optional support for a so-called "implicit return". Some AML code + * assumes that the last value of the method is "implicitly" returned + * to the caller. Just save the last result as the return value. + * NOTE: this is optional because the ASL language does not actually + * support this behavior. + */ + (void) AcpiDsDoImplicitReturn (WalkState->ResultObj, WalkState, TRUE); + + /* + * Now determine if the parent will use the result + * + * If there is no parent, or the parent is a ScopeOp, we are executing + * at the method level. An executing method typically has no parent, + * since each method is parsed separately. A method invoked externally + * via ExecuteControlMethod has a ScopeOp as the parent. + */ + if ((!Op->Common.Parent) || + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) + { + /* No parent, the return value cannot possibly be used */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "At Method level, result of [%s] not used\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode))); + return_UINT8 (FALSE); + } + + /* Get info on the parent. The RootOp is AML_SCOPE */ + + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); + if (ParentInfo->Class == AML_CLASS_UNKNOWN) + { + ACPI_ERROR ((AE_INFO, + "Unknown parent opcode Op=%p", Op)); + return_UINT8 (FALSE); + } + + /* + * Decide what to do with the result based on the parent. If + * the parent opcode will not use the result, delete the object. + * Otherwise leave it as is, it will be deleted when it is used + * as an operand later. + */ + switch (ParentInfo->Class) + { + case AML_CLASS_CONTROL: + + switch (Op->Common.Parent->Common.AmlOpcode) + { + case AML_RETURN_OP: + + /* Never delete the return value associated with a return opcode */ + + goto ResultUsed; + + case AML_IF_OP: + case AML_WHILE_OP: + + /* + * If we are executing the predicate AND this is the predicate op, + * we will use the return value + */ + if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + goto ResultUsed; + } + break; + + default: + /* Ignore other control opcodes */ + break; + } + + /* The general control opcode returns no result */ + + goto ResultNotUsed; + + + case AML_CLASS_CREATE: + + /* + * These opcodes allow TermArg(s) as operands and therefore + * the operands can be method calls. The result is used. + */ + goto ResultUsed; + + + case AML_CLASS_NAMED_OBJECT: + + if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP)) + { + /* + * These opcodes allow TermArg(s) as operands and therefore + * the operands can be method calls. The result is used. + */ + goto ResultUsed; + } + + goto ResultNotUsed; + + + default: + + /* + * In all other cases. the parent will actually use the return + * object, so keep it. + */ + goto ResultUsed; + } + + +ResultUsed: + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + + return_UINT8 (TRUE); + + +ResultNotUsed: + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] not used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + + return_UINT8 (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDeleteResultIfNotUsed + * + * PARAMETERS: Op - Current parse Op + * ResultObj - Result of the operation + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Used after interpretation of an opcode. If there is an internal + * result descriptor, check if the parent opcode will actually use + * this result. If not, delete the result now so that it will + * not become orphaned. + * + ******************************************************************************/ + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsDeleteResultIfNotUsed, ResultObj); + + + if (!Op) + { + ACPI_ERROR ((AE_INFO, "Null Op")); + return_VOID; + } + + if (!ResultObj) + { + return_VOID; + } + + if (!AcpiDsIsResultUsed (Op, WalkState)) + { + /* Must pop the result stack (ObjDesc should be equal to ResultObj) */ + + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_SUCCESS (Status)) + { + AcpiUtRemoveReference (ResultObj); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResolveOperands + * + * PARAMETERS: WalkState - Current walk state with operands on stack + * + * RETURN: Status + * + * DESCRIPTION: Resolve all operands to their values. Used to prepare + * arguments to a control method invocation (a call from one + * method to another.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResolveOperands ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (DsResolveOperands, WalkState); + + + /* + * Attempt to resolve each of the valid operands + * Method arguments are passed by reference, not by value. This means + * that the actual objects are passed, not copies of the objects. + */ + for (i = 0; i < WalkState->NumOperands; i++) + { + Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsClearOperands + * + * PARAMETERS: WalkState - Current walk state with operands on stack + * + * RETURN: None + * + * DESCRIPTION: Clear all operands on the current walk state operand stack. + * + ******************************************************************************/ + +void +AcpiDsClearOperands ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (DsClearOperands, WalkState); + + + /* Remove a reference on each operand on the stack */ + + for (i = 0; i < WalkState->NumOperands; i++) + { + /* + * Remove a reference to all operands, including both + * "Arguments" and "Targets". + */ + AcpiUtRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + + WalkState->NumOperands = 0; + return_VOID; +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperand + * + * PARAMETERS: WalkState - Current walk state + * Arg - Parse object for the argument + * ArgIndex - Which argument (zero based) + * + * RETURN: Status + * + * DESCRIPTION: Translate a parse tree object that is an argument to an AML + * opcode to the equivalent interpreter object. This may include + * looking up a name or entering a new name into the internal + * namespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg, + UINT32 ArgIndex) +{ + ACPI_STATUS Status = AE_OK; + char *NameString; + UINT32 NameLength; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *ParentOp; + UINT16 Opcode; + ACPI_INTERPRETER_MODE InterpreterMode; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateOperand, Arg); + + + /* A valid name must be looked up in the namespace */ + + if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && + (Arg->Common.Value.String) && + !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg)); + + /* Get the entire name string from the AML stream */ + + Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Common.Value.Buffer, + &NameString, &NameLength); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* All prefixes have been handled, and the name is in NameString */ + + /* + * Special handling for BufferField declarations. This is a deferred + * opcode that unfortunately defines the field name as the last + * parameter instead of the first. We get here when we are performing + * the deferred execution, so the actual name of the field is already + * in the namespace. We don't want to attempt to look it up again + * because we may be executing in a different scope than where the + * actual opcode exists. + */ + if ((WalkState->DeferredNode) && + (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) && + (ArgIndex == (UINT32) ((WalkState->Opcode == AML_CREATE_FIELD_OP) ? 3 : 2))) + { + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, WalkState->DeferredNode); + Status = AE_OK; + } + else /* All other opcodes */ + { + /* + * Differentiate between a namespace "create" operation + * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. + * IMODE_EXECUTE) in order to support the creation of + * namespace objects during the execution of control methods. + */ + ParentOp = Arg->Common.Parent; + OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode); + if ((OpInfo->Flags & AML_NSNODE) && + (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) && + (ParentOp->Common.AmlOpcode != AML_REGION_OP) && + (ParentOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)) + { + /* Enter name into namespace if not found */ + + InterpreterMode = ACPI_IMODE_LOAD_PASS2; + } + else + { + /* Return a failure if name not found */ + + InterpreterMode = ACPI_IMODE_EXECUTE; + } + + Status = AcpiNsLookup (WalkState->ScopeInfo, NameString, + ACPI_TYPE_ANY, InterpreterMode, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc)); + /* + * The only case where we pass through (ignore) a NOT_FOUND + * error is for the CondRefOf opcode. + */ + if (Status == AE_NOT_FOUND) + { + if (ParentOp->Common.AmlOpcode == AML_COND_REF_OF_OP) + { + /* + * For the Conditional Reference op, it's OK if + * the name is not found; We just need a way to + * indicate this to the interpreter, set the + * object to the root + */ + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); + Status = AE_OK; + } + else + { + /* + * We just plain didn't find it -- which is a + * very serious error at this point + */ + Status = AE_AML_NAME_NOT_FOUND; + } + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (NameString, Status); + } + } + + /* Free the namestring created above */ + + ACPI_FREE (NameString); + + /* Check status from the lookup */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Put the resulting object onto the current object stack */ + + Status = AcpiDsObjStackPush (ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + else + { + /* Check for null name case */ + + if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && + !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + { + /* + * If the name is null, this means that this is an + * optional result parameter that was not specified + * in the original ASL. Create a Zero Constant for a + * placeholder. (Store to a constant is a Noop.) + */ + Opcode = AML_ZERO_OP; /* Has no arguments! */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Null namepath: Arg=%p\n", Arg)); + } + else + { + Opcode = Arg->Common.AmlOpcode; + } + + /* Get the object type of the argument */ + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (OpInfo->ObjectType == ACPI_TYPE_INVALID) + { + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + if ((OpInfo->Flags & AML_HAS_RETVAL) || (Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Argument previously created, already stacked\n")); + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject ( + WalkState->Operands [WalkState->NumOperands - 1], WalkState)); + + /* + * Use value that was already previously returned + * by the evaluation of this argument + */ + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* + * Only error is underflow, and this indicates + * a missing or null operand! + */ + ACPI_EXCEPTION ((AE_INFO, Status, + "Missing or null operand")); + return_ACPI_STATUS (Status); + } + } + else + { + /* Create an ACPI_INTERNAL_OBJECT for the argument */ + + ObjDesc = AcpiUtCreateInternalObject (OpInfo->ObjectType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new object */ + + Status = AcpiDsInitObjectFromOp ( + WalkState, Arg, Opcode, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (Status); + } + } + + /* Put the operand object on the object stack */ + + Status = AcpiDsObjStackPush (ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperands + * + * PARAMETERS: WalkState - Current state + * FirstArg - First argument of a parser argument tree + * + * RETURN: Status + * + * DESCRIPTION: Convert an operator's arguments from a parse tree format to + * namespace objects and place those argument object on the object + * stack in preparation for evaluation by the interpreter. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg; + ACPI_PARSE_OBJECT *Arguments[ACPI_OBJ_NUM_OPERANDS]; + UINT32 ArgCount = 0; + UINT32 Index = WalkState->NumOperands; + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateOperands, FirstArg); + + + /* Get all arguments in the list */ + + Arg = FirstArg; + while (Arg) + { + if (Index >= ACPI_OBJ_NUM_OPERANDS) + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + Arguments[Index] = Arg; + WalkState->Operands [Index] = NULL; + + /* Move on to next argument, if any */ + + Arg = Arg->Common.Next; + ArgCount++; + Index++; + } + + Index--; + + /* It is the appropriate order to get objects from the Result stack */ + + for (i = 0; i < ArgCount; i++) + { + Arg = Arguments[Index]; + + /* Force the filling of the operand stack in inverse order */ + + WalkState->OperandIndex = (UINT8) Index; + + Status = AcpiDsCreateOperand (WalkState, Arg, Index); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Index--; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n", + Index, Arg, FirstArg)); + } + + return_ACPI_STATUS (Status); + + +Cleanup: + /* + * We must undo everything done above; meaning that we must + * pop everything off of the operand stack and delete those + * objects + */ + AcpiDsObjStackPopAndDelete (ArgCount, WalkState); + + ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %d", Index)); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsEvaluateNamePath + * + * PARAMETERS: WalkState - Current state of the parse tree walk, + * the opcode of current operation should be + * AML_INT_NAMEPATH_OP + * + * RETURN: Status + * + * DESCRIPTION: Translate the -NamePath- parse tree object to the equivalent + * interpreter object, convert it to value, if needed, duplicate + * it, if needed, and push it onto the current result stack. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsEvaluateNamePath ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = WalkState->Op; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *NewObjDesc; + UINT8 Type; + + + ACPI_FUNCTION_TRACE_PTR (DsEvaluateNamePath, WalkState); + + + if (!Op->Common.Parent) + { + /* This happens after certain exception processing */ + + goto Exit; + } + + if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_REF_OF_OP)) + { + /* TBD: Should we specify this feature as a bit of OpInfo->Flags of these opcodes? */ + + goto Exit; + } + + Status = AcpiDsCreateOperand (WalkState, Op, 0); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Op->Common.Flags & ACPI_PARSEOP_TARGET) + { + NewObjDesc = *Operand; + goto PushResult; + } + + Type = (*Operand)->Common.Type; + + Status = AcpiExResolveToValue (Operand, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Type == ACPI_TYPE_INTEGER) + { + /* It was incremented by AcpiExResolveToValue */ + + AcpiUtRemoveReference (*Operand); + + Status = AcpiUtCopyIobjectToIobject (*Operand, &NewObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + else + { + /* + * The object either was anew created or is + * a Namespace node - don't decrement it. + */ + NewObjDesc = *Operand; + } + + /* Cleanup for name-path operand */ + + Status = AcpiDsObjStackPop (1, WalkState); + if (ACPI_FAILURE (Status)) + { + WalkState->ResultObj = NewObjDesc; + goto Exit; + } + +PushResult: + + WalkState->ResultObj = NewObjDesc; + + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + if (ACPI_SUCCESS (Status)) + { + /* Force to take it from stack */ + + Op->Common.Flags |= ACPI_PARSEOP_IN_STACK; + } + +Exit: + + return_ACPI_STATUS (Status); +} diff --git a/drivers/bus/acpi/acpica/dispatcher/dswexec.c b/drivers/bus/acpi/acpica/dispatcher/dswexec.c new file mode 100644 index 00000000000..9485c62bb1c --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dswexec.c @@ -0,0 +1,853 @@ +/****************************************************************************** + * + * Module Name: dswexec - Dispatcher method execution callbacks; + * dispatch to interpreter. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWEXEC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswexec") + +/* + * Dispatch table for opcode classes + */ +static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = +{ + AcpiExOpcode_0A_0T_1R, + AcpiExOpcode_1A_0T_0R, + AcpiExOpcode_1A_0T_1R, + AcpiExOpcode_1A_1T_0R, + AcpiExOpcode_1A_1T_1R, + AcpiExOpcode_2A_0T_0R, + AcpiExOpcode_2A_0T_1R, + AcpiExOpcode_2A_1T_1R, + AcpiExOpcode_2A_2T_1R, + AcpiExOpcode_3A_0T_0R, + AcpiExOpcode_3A_1T_1R, + AcpiExOpcode_6A_0T_1R +}; + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetPredicateValue + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * ResultObj - if non-zero, pop result from result stack + * + * RETURN: Status + * + * DESCRIPTION: Get the result of a predicate evaluation + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ResultObj) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *LocalObjDesc = NULL; + + + ACPI_FUNCTION_TRACE_PTR (DsGetPredicateValue, WalkState); + + + WalkState->ControlState->Common.State = 0; + + if (ResultObj) + { + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not get result from predicate evaluation")); + + return_ACPI_STATUS (Status); + } + } + else + { + Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = WalkState->Operands [0]; + } + + if (!ObjDesc) + { + ACPI_ERROR ((AE_INFO, + "No predicate ObjDesc=%p State=%p", + ObjDesc, WalkState)); + + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * Result of predicate evaluation must be an Integer + * object. Implicitly convert the argument if necessary. + */ + Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, 16); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (LocalObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, + "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X", + ObjDesc, WalkState, ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* Truncate the predicate to 32-bits if necessary */ + + AcpiExTruncateFor32bitTable (LocalObjDesc); + + /* + * Save the result of the predicate evaluation on + * the control stack + */ + if (LocalObjDesc->Integer.Value) + { + WalkState->ControlState->Common.Value = TRUE; + } + else + { + /* + * Predicate is FALSE, we will just toss the + * rest of the package + */ + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_FALSE; + } + + /* Predicate can be used for an implicit return value */ + + (void) AcpiDsDoImplicitReturn (LocalObjDesc, WalkState, TRUE); + + +Cleanup: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", + WalkState->ControlState->Common.Value, WalkState->Op)); + + /* Break to debugger to display result */ + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (LocalObjDesc, WalkState)); + + /* + * Delete the predicate result object (we know that + * we don't need it anymore) + */ + if (LocalObjDesc != ObjDesc) + { + AcpiUtRemoveReference (LocalObjDesc); + } + AcpiUtRemoveReference (ObjDesc); + + WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL; + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecBeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * OutOp - Where to return op if a new one is created + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the execution of control + * methods. This is where most operators and operands are + * dispatched to the interpreter. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecBeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_STATUS Status = AE_OK; + UINT32 OpcodeClass; + + + ACPI_FUNCTION_TRACE_PTR (DsExecBeginOp, WalkState); + + + Op = WalkState->Op; + if (!Op) + { + Status = AcpiDsLoad2BeginOp (WalkState, OutOp); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + Op = *OutOp; + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + + if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "(%s) Popping scope for Op %p\n", + AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op)); + + Status = AcpiDsScopeStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + } + } + + if (Op == WalkState->Origin) + { + if (OutOp) + { + *OutOp = Op; + } + + return_ACPI_STATUS (AE_OK); + } + + /* + * If the previous opcode was a conditional, this opcode + * must be the beginning of the associated predicate. + * Save this knowledge in the current scope descriptor + */ + if ((WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n", + Op, WalkState)); + + WalkState->ControlState->Common.State = ACPI_CONTROL_PREDICATE_EXECUTING; + + /* Save start of predicate */ + + WalkState->ControlState->Control.PredicateOp = Op; + } + + + OpcodeClass = WalkState->OpInfo->Class; + + /* We want to send namepaths to the load code */ + + if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) + { + OpcodeClass = AML_CLASS_NAMED_OBJECT; + } + + /* + * Handle the opcode based upon the opcode type + */ + switch (OpcodeClass) + { + case AML_CLASS_CONTROL: + + Status = AcpiDsExecBeginControlOp (WalkState, Op); + break; + + + case AML_CLASS_NAMED_OBJECT: + + if (WalkState->WalkType & ACPI_WALK_METHOD) + { + /* + * Found a named object declaration during method execution; + * we must enter this object into the namespace. The created + * object is temporary and will be deleted upon completion of + * the execution of this method. + */ + Status = AcpiDsLoad2BeginOp (WalkState, NULL); + } + + break; + + + case AML_CLASS_EXECUTE: + case AML_CLASS_CREATE: + + break; + + + default: + break; + } + + /* Nothing to do here during method execution */ + + return_ACPI_STATUS (Status); + + +ErrorExit: + Status = AcpiDsMethodError (Status, WalkState); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecEndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the execution of control + * methods. The only thing we really need to do here is to + * notice the beginning of IF, ELSE, and WHILE blocks. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_STATUS Status = AE_OK; + UINT32 OpType; + UINT32 OpClass; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *FirstArg; + + + ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState); + + + Op = WalkState->Op; + OpType = WalkState->OpInfo->Type; + OpClass = WalkState->OpInfo->Class; + + if (OpClass == AML_CLASS_UNKNOWN) + { + ACPI_ERROR ((AE_INFO, "Unknown opcode %X", Op->Common.AmlOpcode)); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + FirstArg = Op->Common.Value.Arg; + + /* Init the walk state */ + + WalkState->NumOperands = 0; + WalkState->OperandIndex = 0; + WalkState->ReturnDesc = NULL; + WalkState->ResultObj = NULL; + + /* Call debugger for single step support (DEBUG build only) */ + + ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass)); + ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);}); + + /* Decode the Opcode Class */ + + switch (OpClass) + { + case AML_CLASS_ARGUMENT: /* Constants, literals, etc. */ + + if (WalkState->Opcode == AML_INT_NAMEPATH_OP) + { + Status = AcpiDsEvaluateNamePath (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + break; + + + case AML_CLASS_EXECUTE: /* Most operators with arguments */ + + /* Build resolved operand stack */ + + Status = AcpiDsCreateOperands (WalkState, FirstArg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * All opcodes require operand resolution, with the only exceptions + * being the ObjectType and SizeOf operators. + */ + if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE)) + { + /* Resolve all operands */ + + Status = AcpiExResolveOperands (WalkState->Opcode, + &(WalkState->Operands [WalkState->NumOperands -1]), + WalkState); + } + + if (ACPI_SUCCESS (Status)) + { + /* + * Dispatch the request to the appropriate interpreter handler + * routine. There is one routine per opcode "type" based upon the + * number of opcode arguments and return type. + */ + Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState); + } + else + { + /* + * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the + * Local is uninitialized. + */ + if ((Status == AE_AML_UNINITIALIZED_LOCAL) && + (WalkState->Opcode == AML_STORE_OP) && + (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (WalkState->Operands[0]->Reference.Class == + WalkState->Operands[1]->Reference.Class) && + (WalkState->Operands[0]->Reference.Value == + WalkState->Operands[1]->Reference.Value)) + { + Status = AE_OK; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While resolving operands for [%s]", + AcpiPsGetOpcodeName (WalkState->Opcode))); + } + } + + /* Always delete the argument objects and clear the operand stack */ + + AcpiDsClearOperands (WalkState); + + /* + * If a result object was returned from above, push it on the + * current result stack + */ + if (ACPI_SUCCESS (Status) && + WalkState->ResultObj) + { + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + } + break; + + + default: + + switch (OpType) + { + case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ + + /* 1 Operand, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiDsExecEndControlOp (WalkState, Op); + + break; + + + case AML_TYPE_METHOD_CALL: + + /* + * If the method is referenced from within a package + * declaration, it is not a invocation of the method, just + * a reference to it. + */ + if ((Op->Asl.Parent) && + ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) || + (Op->Asl.Parent->Asl.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Method Reference in a Package, Op=%p\n", Op)); + + Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node; + AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object); + return_ACPI_STATUS (AE_OK); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op)); + + /* + * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains + * the method Node pointer + */ + /* NextOp points to the op that holds the method name */ + + NextOp = FirstArg; + + /* NextOp points to first argument op */ + + NextOp = NextOp->Common.Next; + + /* + * Get the method's arguments and put them on the operand stack + */ + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + break; + } + + /* + * Since the operands will be passed to another control method, + * we must resolve all local references here (Local variables, + * arguments to *this* method, etc.) + */ + Status = AcpiDsResolveOperands (WalkState); + if (ACPI_FAILURE (Status)) + { + /* On error, clear all resolved operands */ + + AcpiDsClearOperands (WalkState); + break; + } + + /* + * Tell the walk loop to preempt this running method and + * execute the new method + */ + Status = AE_CTRL_TRANSFER; + + /* + * Return now; we don't want to disturb anything, + * especially the operand count! + */ + return_ACPI_STATUS (Status); + + + case AML_TYPE_CREATE_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing CreateField Buffer/Index Op=%p\n", Op)); + + Status = AcpiDsLoad2EndOp (WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + + Status = AcpiDsEvalBufferFieldOperands (WalkState, Op); + break; + + + case AML_TYPE_CREATE_OBJECT: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing CreateObject (Buffer/Package) Op=%p\n", Op)); + + switch (Op->Common.Parent->Common.AmlOpcode) + { + case AML_NAME_OP: + + /* + * Put the Node on the object stack (Contains the ACPI Name + * of this object) + */ + WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node; + WalkState->NumOperands = 1; + + Status = AcpiDsCreateNode (WalkState, + Op->Common.Parent->Common.Node, + Op->Common.Parent); + if (ACPI_FAILURE (Status)) + { + break; + } + + /* Fall through */ + /*lint -fallthrough */ + + case AML_INT_EVAL_SUBTREE_OP: + + Status = AcpiDsEvalDataObjectOperands (WalkState, Op, + AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); + break; + + default: + + Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL); + break; + } + + /* + * If a result object was returned from above, push it on the + * current result stack + */ + if (WalkState->ResultObj) + { + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + } + break; + + + case AML_TYPE_NAMED_FIELD: + case AML_TYPE_NAMED_COMPLEX: + case AML_TYPE_NAMED_SIMPLE: + case AML_TYPE_NAMED_NO_OBJ: + + Status = AcpiDsLoad2EndOp (WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing OpRegion Address/Length Op=%p\n", Op)); + + Status = AcpiDsEvalRegionOperands (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + } + else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing DataTableRegion Strings Op=%p\n", Op)); + + Status = AcpiDsEvalTableRegionOperands (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + } + else if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing BankField Op=%p\n", Op)); + + Status = AcpiDsEvalBankFieldOperands (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + } + break; + + + case AML_TYPE_UNDEFINED: + + ACPI_ERROR ((AE_INFO, + "Undefined opcode type Op=%p", Op)); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + + + case AML_TYPE_BOGUS: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Internal opcode=%X type Op=%p\n", + WalkState->Opcode, Op)); + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p", + OpClass, OpType, Op->Common.AmlOpcode, Op)); + + Status = AE_NOT_IMPLEMENTED; + break; + } + } + + /* + * ACPI 2.0 support for 64-bit integers: Truncate numeric + * result value if we are executing from a 32-bit ACPI table + */ + AcpiExTruncateFor32bitTable (WalkState->ResultObj); + + /* + * Check if we just completed the evaluation of a + * conditional predicate + */ + if ((ACPI_SUCCESS (Status)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj); + WalkState->ResultObj = NULL; + } + + +Cleanup: + + if (WalkState->ResultObj) + { + /* Break to debugger to display result */ + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, + WalkState)); + + /* + * Delete the result op if and only if: + * Parent will not use the result -- such as any + * non-nested type2 op in a method (parent will be method) + */ + AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState); + } + +#ifdef _UNDER_DEVELOPMENT + + if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd) + { + AcpiDbMethodEnd (WalkState); + } +#endif + + /* Invoke exception handler on error */ + + if (ACPI_FAILURE (Status)) + { + Status = AcpiDsMethodError (Status, WalkState); + } + + /* Always clear the object stack */ + + WalkState->NumOperands = 0; + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/dispatcher/dswload.c b/drivers/bus/acpi/acpica/dispatcher/dswload.c new file mode 100644 index 00000000000..48c4ae6f163 --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dswload.c @@ -0,0 +1,1316 @@ +/****************************************************************************** + * + * Module Name: dswload - Dispatcher namespace load callbacks + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWLOAD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" + +#ifdef ACPI_ASL_COMPILER +#include "acdisasm.h" +#endif + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswload") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitCallbacks + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * PassNumber - 1, 2, or 3 + * + * RETURN: Status + * + * DESCRIPTION: Init walk state callbacks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitCallbacks ( + ACPI_WALK_STATE *WalkState, + UINT32 PassNumber) +{ + + switch (PassNumber) + { + case 1: + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; + WalkState->DescendingCallback = AcpiDsLoad1BeginOp; + WalkState->AscendingCallback = AcpiDsLoad1EndOp; + break; + + case 2: + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; + WalkState->DescendingCallback = AcpiDsLoad2BeginOp; + WalkState->AscendingCallback = AcpiDsLoad2EndOp; + break; + + case 3: +#ifndef ACPI_NO_METHOD_EXECUTION + WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | + ACPI_PARSE_DELETE_TREE; + WalkState->DescendingCallback = AcpiDsExecBeginOp; + WalkState->AscendingCallback = AcpiDsExecEndOp; +#endif + break; + + default: + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad1BeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * OutOp - Where to return op if a new one is created + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad1BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE ObjectType; + char *Path; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE (DsLoad1BeginOp); + + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); + + /* We are only interested in opcodes that have an associated name */ + + if (Op) + { + if (!(WalkState->OpInfo->Flags & AML_NAMED)) + { + *OutOp = Op; + return_ACPI_STATUS (AE_OK); + } + + /* Check if this object has already been installed in the namespace */ + + if (Op->Common.Node) + { + *OutOp = Op; + return_ACPI_STATUS (AE_OK); + } + } + + Path = AcpiPsGetNextNamestring (&WalkState->ParserState); + + /* Map the raw opcode into an internal object type */ + + ObjectType = WalkState->OpInfo->ObjectType; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "State=%p Op=%p [%s]\n", WalkState, Op, AcpiUtGetTypeName (ObjectType))); + + switch (WalkState->Opcode) + { + case AML_SCOPE_OP: + + /* + * The target name of the Scope() operator must exist at this point so + * that we can actually open the scope to enter new names underneath it. + * Allow search-to-root for single namesegs. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); +#ifdef ACPI_ASL_COMPILER + if (Status == AE_NOT_FOUND) + { + /* + * Table disassembly: + * Target of Scope() not found. Generate an External for it, and + * insert the name into the namespace. + */ + AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0); + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, + WalkState, &Node); + } +#endif + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + return_ACPI_STATUS (Status); + } + + /* + * Check to make sure that the target is + * one of the opcodes that actually opens a scope + */ + switch (Node->Type) + { + case ACPI_TYPE_ANY: + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* These are acceptable types */ + break; + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * These types we will allow, but we will change the type. + * This enables some existing code of the form: + * + * Name (DEB, 0) + * Scope (DEB) { ... } + * + * Note: silently change the type here. On the second pass, + * we will report a warning + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Type override - [%4.4s] had invalid type (%s) " + "for Scope operator, changed to type ANY\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); + + Node->Type = ACPI_TYPE_ANY; + WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; + break; + + default: + + /* All other types are an error */ + + ACPI_ERROR ((AE_INFO, + "Invalid type (%s) for target of " + "Scope operator [%4.4s] (Cannot override)", + AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + break; + + + default: + /* + * For all other named opcodes, we will enter the name into + * the namespace. + * + * Setup the search flags. + * Since we are entering a name into the namespace, we do not want to + * enable the search-to-root upsearch. + * + * There are only two conditions where it is acceptable that the name + * already exists: + * 1) the Scope() operator can reopen a scoping object that was + * previously defined (Scope, Method, Device, etc.) + * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, + * BufferField, or Package), the name of the object is already + * in the namespace. + */ + if (WalkState->DeferredNode) + { + /* This name is already in the namespace, get the node */ + + Node = WalkState->DeferredNode; + Status = AE_OK; + break; + } + + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (WalkState->MethodNode) + { + Node = NULL; + Status = AE_OK; + break; + } + + Flags = ACPI_NS_NO_UPSEARCH; + if ((WalkState->Opcode != AML_SCOPE_OP) && + (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) + { + Flags |= ACPI_NS_ERROR_IF_FOUND; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", + AcpiUtGetTypeName (ObjectType))); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[%s] Both Find or Create allowed\n", + AcpiUtGetTypeName (ObjectType))); + } + + /* + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_ALREADY_EXISTS) + { + /* The name already exists in this scope */ + + if (Node->Flags & ANOBJ_IS_EXTERNAL) + { + /* + * Allow one create on an object or segment that was + * previously declared External + */ + Node->Flags &= ~ANOBJ_IS_EXTERNAL; + Node->Type = (UINT8) ObjectType; + + /* Just retyped a node, probably will need to open a scope */ + + if (AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + Status = AE_OK; + } + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + return_ACPI_STATUS (Status); + } + } + break; + } + + /* Common exit */ + + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* Initialize the op */ + +#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) + Op->Named.Path = ACPI_CAST_PTR (UINT8, Path); +#endif + + if (Node) + { + /* + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + Op->Common.Node = Node; + Op->Named.Name = Node->Name.Integer; + } + + AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); + *OutOp = Op; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad1EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_OBJECT_TYPE ObjectType; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (DsLoad1EndOp); + + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); + + /* We are only interested in opcodes that have an associated name */ + + if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the object type to determine if we should pop the scope */ + + ObjectType = WalkState->OpInfo->ObjectType; + +#ifndef ACPI_NO_METHOD_EXECUTION + if (WalkState->OpInfo->Flags & AML_FIELD) + { + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!WalkState->MethodNode) + { + if (WalkState->Opcode == AML_FIELD_OP || + WalkState->Opcode == AML_BANK_FIELD_OP || + WalkState->Opcode == AML_INDEX_FIELD_OP) + { + Status = AcpiDsInitFieldObjects (Op, WalkState); + } + } + return_ACPI_STATUS (Status); + } + + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!WalkState->MethodNode) + { + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, + (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) + { + Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, + REGION_DATA_TABLE, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } +#endif + + if (Op->Common.AmlOpcode == AML_NAME_OP) + { + /* For Name opcode, get the object type from the argument */ + + if (Op->Common.Value.Arg) + { + ObjectType = (AcpiPsGetOpcodeInfo ( + (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; + + /* Set node type if we have a namespace node */ + + if (Op->Common.Node) + { + Op->Common.Node->Type = (UINT8) ObjectType; + } + } + } + + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!WalkState->MethodNode) + { + if (Op->Common.AmlOpcode == AML_METHOD_OP) + { + /* + * MethodOp PkgLength NameString MethodFlags TermList + * + * Note: We must create the method node/object pair as soon as we + * see the method declaration. This allows later pass1 parsing + * of invocations of the method (need to know the number of + * arguments.) + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "LOADING-Method: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Op->Named.Node)); + + if (!AcpiNsGetAttachedObject (Op->Named.Node)) + { + WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); + WalkState->NumOperands = 1; + + Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiExCreateMethod (Op->Named.Data, + Op->Named.Length, WalkState); + } + + WalkState->Operands[0] = NULL; + WalkState->NumOperands = 0; + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + } + + /* Pop the scope stack (only if loading a table) */ + + if (!WalkState->MethodNode && + AcpiNsOpensScope (ObjectType)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", + AcpiUtGetTypeName (ObjectType), Op)); + + Status = AcpiDsScopeStackPop (WalkState); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad2BeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * OutOp - Wher to return op if a new one is created + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE ObjectType; + char *BufferPtr; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE (DsLoad2BeginOp); + + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); + + if (Op) + { + if ((WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) + { + /* We are executing a while loop outside of a method */ + + Status = AcpiDsExecBeginOp (WalkState, OutOp); + return_ACPI_STATUS (Status); + } + + /* We only care about Namespace opcodes here */ + + if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && + (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || + (!(WalkState->OpInfo->Flags & AML_NAMED))) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the name we are going to enter or lookup in the namespace */ + + if (WalkState->Opcode == AML_INT_NAMEPATH_OP) + { + /* For Namepath op, get the path string */ + + BufferPtr = Op->Common.Value.String; + if (!BufferPtr) + { + /* No name, just exit */ + + return_ACPI_STATUS (AE_OK); + } + } + else + { + /* Get name from the op */ + + BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name); + } + } + else + { + /* Get the namestring from the raw AML */ + + BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState); + } + + /* Map the opcode into an internal object type */ + + ObjectType = WalkState->OpInfo->ObjectType; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType)); + + switch (WalkState->Opcode) + { + case AML_FIELD_OP: + case AML_BANK_FIELD_OP: + case AML_INDEX_FIELD_OP: + + Node = NULL; + Status = AE_OK; + break; + + case AML_INT_NAMEPATH_OP: + /* + * The NamePath is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); + break; + + case AML_SCOPE_OP: + + /* Special case for Scope(\) -> refers to the Root node */ + + if (Op && (Op->Named.Node == AcpiGbl_RootNode)) + { + Node = Op->Named.Node; + + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* + * The Path is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); + if (ACPI_FAILURE (Status)) + { +#ifdef ACPI_ASL_COMPILER + if (Status == AE_NOT_FOUND) + { + Status = AE_OK; + } + else + { + ACPI_ERROR_NAMESPACE (BufferPtr, Status); + } +#else + ACPI_ERROR_NAMESPACE (BufferPtr, Status); +#endif + return_ACPI_STATUS (Status); + } + } + + /* + * We must check to make sure that the target is + * one of the opcodes that actually opens a scope + */ + switch (Node->Type) + { + case ACPI_TYPE_ANY: + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* These are acceptable types */ + break; + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * These types we will allow, but we will change the type. + * This enables some existing code of the form: + * + * Name (DEB, 0) + * Scope (DEB) { ... } + */ + ACPI_WARNING ((AE_INFO, + "Type override - [%4.4s] had invalid type (%s) " + "for Scope operator, changed to type ANY\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); + + Node->Type = ACPI_TYPE_ANY; + WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; + break; + + default: + + /* All other types are an error */ + + ACPI_ERROR ((AE_INFO, + "Invalid type (%s) for target of " + "Scope operator [%4.4s] (Cannot override)", + AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); + + return (AE_AML_OPERAND_TYPE); + } + break; + + default: + + /* All other opcodes */ + + if (Op && Op->Common.Node) + { + /* This op/node was previously entered into the namespace */ + + Node = Op->Common.Node; + + if (AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (AE_OK); + } + + /* + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. + * + * Note: Name may already exist if we are executing a deferred opcode. + */ + if (WalkState->DeferredNode) + { + /* This name is already in the namespace, get the node */ + + Node = WalkState->DeferredNode; + Status = AE_OK; + break; + } + + Flags = ACPI_NS_NO_UPSEARCH; + if (WalkState->PassNumber == ACPI_IMODE_EXECUTE) + { + /* Execution mode, node cannot already exist, node is temporary */ + + Flags |= ACPI_NS_ERROR_IF_FOUND; + + if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } + } + + /* Add new entry or lookup existing entry */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node); + + if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "***New Node [%4.4s] %p is temporary\n", + AcpiUtGetNodeName (Node), Node)); + } + break; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (BufferPtr, Status); + return_ACPI_STATUS (Status); + } + + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new op */ + + if (Node) + { + Op->Named.Name = Node->Name.Integer; + } + *OutOp = Op; + } + + /* + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + Op->Common.Node = Node; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad2EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_STATUS Status = AE_OK; + ACPI_OBJECT_TYPE ObjectType; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *NewNode; +#ifndef ACPI_NO_METHOD_EXECUTION + UINT32 i; + UINT8 RegionSpace; +#endif + + + ACPI_FUNCTION_TRACE (DsLoad2EndOp); + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", + WalkState->OpInfo->Name, Op, WalkState)); + + /* Check if opcode had an associated namespace object */ + + if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) + { + return_ACPI_STATUS (AE_OK); + } + + if (Op->Common.AmlOpcode == AML_SCOPE_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Ending scope Op=%p State=%p\n", Op, WalkState)); + } + + ObjectType = WalkState->OpInfo->ObjectType; + + /* + * Get the Node/name from the earlier lookup + * (It was saved in the *op structure) + */ + Node = Op->Common.Node; + + /* + * Put the Node on the object stack (Contains the ACPI Name of + * this object) + */ + WalkState->Operands[0] = (void *) Node; + WalkState->NumOperands = 1; + + /* Pop the scope stack */ + + if (AcpiNsOpensScope (ObjectType) && + (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", + AcpiUtGetTypeName (ObjectType), Op)); + + Status = AcpiDsScopeStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + /* + * Named operations are as follows: + * + * AML_ALIAS + * AML_BANKFIELD + * AML_CREATEBITFIELD + * AML_CREATEBYTEFIELD + * AML_CREATEDWORDFIELD + * AML_CREATEFIELD + * AML_CREATEQWORDFIELD + * AML_CREATEWORDFIELD + * AML_DATA_REGION + * AML_DEVICE + * AML_EVENT + * AML_FIELD + * AML_INDEXFIELD + * AML_METHOD + * AML_METHODCALL + * AML_MUTEX + * AML_NAME + * AML_NAMEDFIELD + * AML_OPREGION + * AML_POWERRES + * AML_PROCESSOR + * AML_SCOPE + * AML_THERMALZONE + */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node)); + + /* Decode the opcode */ + + Arg = Op->Common.Value.Arg; + + switch (WalkState->OpInfo->Type) + { +#ifndef ACPI_NO_METHOD_EXECUTION + + case AML_TYPE_CREATE_FIELD: + /* + * Create the field object, but the field buffer and index must + * be evaluated later during the execution phase + */ + Status = AcpiDsCreateBufferField (Op, WalkState); + break; + + + case AML_TYPE_NAMED_FIELD: + /* + * If we are executing a method, initialize the field + */ + if (WalkState->MethodNode) + { + Status = AcpiDsInitFieldObjects (Op, WalkState); + } + + switch (Op->Common.AmlOpcode) + { + case AML_INDEX_FIELD_OP: + + Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, + WalkState); + break; + + case AML_BANK_FIELD_OP: + + Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState); + break; + + case AML_FIELD_OP: + + Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState); + break; + + default: + /* All NAMED_FIELD opcodes must be handled above */ + break; + } + break; + + + case AML_TYPE_NAMED_SIMPLE: + + Status = AcpiDsCreateOperands (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + switch (Op->Common.AmlOpcode) + { + case AML_PROCESSOR_OP: + + Status = AcpiExCreateProcessor (WalkState); + break; + + case AML_POWER_RES_OP: + + Status = AcpiExCreatePowerResource (WalkState); + break; + + case AML_MUTEX_OP: + + Status = AcpiExCreateMutex (WalkState); + break; + + case AML_EVENT_OP: + + Status = AcpiExCreateEvent (WalkState); + break; + + + case AML_ALIAS_OP: + + Status = AcpiExCreateAlias (WalkState); + break; + + default: + /* Unknown opcode */ + + Status = AE_OK; + goto Cleanup; + } + + /* Delete operands */ + + for (i = 1; i < WalkState->NumOperands; i++) + { + AcpiUtRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + + break; +#endif /* ACPI_NO_METHOD_EXECUTION */ + + case AML_TYPE_NAMED_COMPLEX: + + switch (Op->Common.AmlOpcode) + { +#ifndef ACPI_NO_METHOD_EXECUTION + case AML_REGION_OP: + case AML_DATA_REGION_OP: + + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + RegionSpace = (ACPI_ADR_SPACE_TYPE) + ((Op->Common.Value.Arg)->Common.Value.Integer); + } + else + { + RegionSpace = REGION_DATA_TABLE; + } + + /* + * The OpRegion is not fully parsed at this time. The only valid + * argument is the SpaceId. (We must save the address of the + * AML of the address and length operands) + * + * If we have a valid region, initialize it. The namespace is + * unlocked at this point. + * + * Need to unlock interpreter if it is locked (if we are running + * a control method), in order to allow _REG methods to be run + * during AcpiEvInitializeRegion. + */ + if (WalkState->MethodNode) + { + /* + * Executing a method: initialize the region and unlock + * the interpreter + */ + Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, + RegionSpace, WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiExExitInterpreter (); + } + + Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), + FALSE); + if (WalkState->MethodNode) + { + AcpiExEnterInterpreter (); + } + + if (ACPI_FAILURE (Status)) + { + /* + * If AE_NOT_EXIST is returned, it is not fatal + * because many regions get created before a handler + * is installed for said region. + */ + if (AE_NOT_EXIST == Status) + { + Status = AE_OK; + } + } + break; + + + case AML_NAME_OP: + + Status = AcpiDsCreateNode (WalkState, Node, Op); + break; + + + case AML_METHOD_OP: + /* + * MethodOp PkgLength NameString MethodFlags TermList + * + * Note: We must create the method node/object pair as soon as we + * see the method declaration. This allows later pass1 parsing + * of invocations of the method (need to know the number of + * arguments.) + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "LOADING-Method: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Op->Named.Node)); + + if (!AcpiNsGetAttachedObject (Op->Named.Node)) + { + WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); + WalkState->NumOperands = 1; + + Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiExCreateMethod (Op->Named.Data, + Op->Named.Length, WalkState); + } + WalkState->Operands[0] = NULL; + WalkState->NumOperands = 0; + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + break; + +#endif /* ACPI_NO_METHOD_EXECUTION */ + + default: + /* All NAMED_COMPLEX opcodes must be handled above */ + break; + } + break; + + + case AML_CLASS_INTERNAL: + + /* case AML_INT_NAMEPATH_OP: */ + break; + + + case AML_CLASS_METHOD_CALL: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + /* + * Lookup the method name and save the Node + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &(NewNode)); + if (ACPI_SUCCESS (Status)) + { + /* + * Make sure that what we found is indeed a method + * We didn't search for a method on purpose, to see if the name + * would resolve + */ + if (NewNode->Type != ACPI_TYPE_METHOD) + { + Status = AE_AML_OPERAND_TYPE; + } + + /* We could put the returned object (Node) on the object stack for + * later, but for now, we will put it in the "op" object that the + * parser uses, so we can get it again at the end of this scope + */ + Op->Common.Node = NewNode; + } + else + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + } + break; + + + default: + break; + } + +Cleanup: + + /* Remove the Node pushed at the very beginning */ + + WalkState->Operands[0] = NULL; + WalkState->NumOperands = 0; + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/dispatcher/dswscope.c b/drivers/bus/acpi/acpica/dispatcher/dswscope.c new file mode 100644 index 00000000000..023f9ef6662 --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dswscope.c @@ -0,0 +1,311 @@ +/****************************************************************************** + * + * Module Name: dswscope - Scope stack manipulation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWSCOPE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswscope") + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackClear + * + * PARAMETERS: WalkState - Current state + * + * RETURN: None + * + * DESCRIPTION: Pop (and free) everything on the scope stack except the + * root scope object (which remains at the stack top.) + * + ***************************************************************************/ + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + + ACPI_FUNCTION_NAME (DsScopeStackClear); + + + while (WalkState->ScopeInfo) + { + /* Pop a scope off the stack */ + + ScopeInfo = WalkState->ScopeInfo; + WalkState->ScopeInfo = ScopeInfo->Scope.Next; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Popped object type (%s)\n", + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + AcpiUtDeleteGenericState (ScopeInfo); + } +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPush + * + * PARAMETERS: Node - Name to be made current + * Type - Type of frame being pushed + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Push the current scope on the scope stack, and make the + * passed Node current. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + ACPI_GENERIC_STATE *OldScopeInfo; + + + ACPI_FUNCTION_TRACE (DsScopeStackPush); + + + if (!Node) + { + /* Invalid scope */ + + ACPI_ERROR ((AE_INFO, "Null scope parameter")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Make sure object type is valid */ + + if (!AcpiUtValidObjectType (Type)) + { + ACPI_WARNING ((AE_INFO, + "Invalid object type: 0x%X", Type)); + } + + /* Allocate a new scope object */ + + ScopeInfo = AcpiUtCreateGenericState (); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init new scope object */ + + ScopeInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_WSCOPE; + ScopeInfo->Scope.Node = Node; + ScopeInfo->Common.Value = (UINT16) Type; + + WalkState->ScopeDepth++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[%.2d] Pushed scope ", (UINT32) WalkState->ScopeDepth)); + + OldScopeInfo = WalkState->ScopeInfo; + if (OldScopeInfo) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[%4.4s] (%s)", + AcpiUtGetNodeName (OldScopeInfo->Scope.Node), + AcpiUtGetTypeName (OldScopeInfo->Common.Value))); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[\\___] (%s)", "ROOT")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + ", New scope -> [%4.4s] (%s)\n", + AcpiUtGetNodeName (ScopeInfo->Scope.Node), + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + + /* Push new scope object onto stack */ + + AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo); + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPop + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Pop the scope stack once. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + ACPI_GENERIC_STATE *NewScopeInfo; + + + ACPI_FUNCTION_TRACE (DsScopeStackPop); + + + /* + * Pop scope info object off the stack. + */ + ScopeInfo = AcpiUtPopGenericState (&WalkState->ScopeInfo); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_STACK_UNDERFLOW); + } + + WalkState->ScopeDepth--; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[%.2d] Popped scope [%4.4s] (%s), New scope -> ", + (UINT32) WalkState->ScopeDepth, + AcpiUtGetNodeName (ScopeInfo->Scope.Node), + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + + NewScopeInfo = WalkState->ScopeInfo; + if (NewScopeInfo) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[%4.4s] (%s)\n", + AcpiUtGetNodeName (NewScopeInfo->Scope.Node), + AcpiUtGetTypeName (NewScopeInfo->Common.Value))); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[\\___] (ROOT)\n")); + } + + AcpiUtDeleteGenericState (ScopeInfo); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/dispatcher/dswstate.c b/drivers/bus/acpi/acpica/dispatcher/dswstate.c new file mode 100644 index 00000000000..f0962bf53f1 --- /dev/null +++ b/drivers/bus/acpi/acpica/dispatcher/dswstate.c @@ -0,0 +1,918 @@ +/****************************************************************************** + * + * Module Name: dswstate - Dispatcher parse tree walk management routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __DSWSTATE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswstate") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsResultStackPush ( + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultPop + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop an object off the top of this walk's result stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState) +{ + UINT32 Index; + ACPI_GENERIC_STATE *State; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (DsResultPop); + + + State = WalkState->Results; + + /* Incorrect state of result stack */ + + if (State && !WalkState->ResultCount) + { + ACPI_ERROR ((AE_INFO, "No results on result stack")); + return (AE_AML_INTERNAL); + } + + if (!State && WalkState->ResultCount) + { + ACPI_ERROR ((AE_INFO, "No result state for result stack")); + return (AE_AML_INTERNAL); + } + + /* Empty result stack */ + + if (!State) + { + ACPI_ERROR ((AE_INFO, "Result stack is empty! State=%p", WalkState)); + return (AE_AML_NO_RETURN_VALUE); + } + + /* Return object of the top element and clean that top element result stack */ + + WalkState->ResultCount--; + Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; + + *Object = State->Results.ObjDesc [Index]; + if (!*Object) + { + ACPI_ERROR ((AE_INFO, "No result objects on result stack, State=%p", + WalkState)); + return (AE_AML_NO_RETURN_VALUE); + } + + State->Results.ObjDesc [Index] = NULL; + if (Index == 0) + { + Status = AcpiDsResultStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object, + AcpiUtGetObjectTypeName (*Object), + Index, WalkState, WalkState->ResultCount)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultPush + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto the current result stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultPush ( + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + ACPI_STATUS Status; + UINT32 Index; + + + ACPI_FUNCTION_NAME (DsResultPush); + + + if (WalkState->ResultCount > WalkState->ResultSize) + { + ACPI_ERROR ((AE_INFO, "Result stack is full")); + return (AE_AML_INTERNAL); + } + else if (WalkState->ResultCount == WalkState->ResultSize) + { + /* Extend the result stack */ + + Status = AcpiDsResultStackPush (WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Failed to extend the result stack")); + return (Status); + } + } + + if (!(WalkState->ResultCount < WalkState->ResultSize)) + { + ACPI_ERROR ((AE_INFO, "No free elements in result stack")); + return (AE_AML_INTERNAL); + } + + State = WalkState->Results; + if (!State) + { + ACPI_ERROR ((AE_INFO, "No result stack frame during push")); + return (AE_AML_INTERNAL); + } + + if (!Object) + { + ACPI_ERROR ((AE_INFO, + "Null Object! Obj=%p State=%p Num=%X", + Object, WalkState, WalkState->ResultCount)); + return (AE_BAD_PARAMETER); + } + + /* Assign the address of object to the top free element of result stack */ + + Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; + State->Results.ObjDesc [Index] = Object; + WalkState->ResultCount++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", + Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), + WalkState, WalkState->ResultCount, WalkState->CurrentResult)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPush + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto the WalkState result stack + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsResultStackPush ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_NAME (DsResultStackPush); + + + /* Check for stack overflow */ + + if (((UINT32) WalkState->ResultSize + ACPI_RESULTS_FRAME_OBJ_NUM) > + ACPI_RESULTS_OBJ_NUM_MAX) + { + ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%X", + WalkState, WalkState->ResultSize)); + return (AE_STACK_OVERFLOW); + } + + State = AcpiUtCreateGenericState (); + if (!State) + { + return (AE_NO_MEMORY); + } + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RESULT; + AcpiUtPushGenericState (&WalkState->Results, State); + + /* Increase the length of the result stack by the length of frame */ + + WalkState->ResultSize += ACPI_RESULTS_FRAME_OBJ_NUM; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", + State, WalkState)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPop + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop an object off of the WalkState result stack + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_NAME (DsResultStackPop); + + + /* Check for stack underflow */ + + if (WalkState->Results == NULL) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result stack underflow - State=%p\n", + WalkState)); + return (AE_AML_NO_OPERAND); + } + + if (WalkState->ResultSize < ACPI_RESULTS_FRAME_OBJ_NUM) + { + ACPI_ERROR ((AE_INFO, "Insufficient result stack size")); + return (AE_AML_INTERNAL); + } + + State = AcpiUtPopGenericState (&WalkState->Results); + AcpiUtDeleteGenericState (State); + + /* Decrease the length of result stack by the length of frame */ + + WalkState->ResultSize -= ACPI_RESULTS_FRAME_OBJ_NUM; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Result=%p RemainingResults=%X State=%p\n", + State, WalkState->ResultCount, WalkState)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPush + * + * PARAMETERS: Object - Object to push + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto this walk's object/operand stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME (DsObjStackPush); + + + /* Check for stack overflow */ + + if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS) + { + ACPI_ERROR ((AE_INFO, + "Object stack overflow! Obj=%p State=%p #Ops=%X", + Object, WalkState, WalkState->NumOperands)); + return (AE_STACK_OVERFLOW); + } + + /* Put the object onto the stack */ + + WalkState->Operands [WalkState->OperandIndex] = Object; + WalkState->NumOperands++; + + /* For the usual order of filling the operand stack */ + + WalkState->OperandIndex++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", + Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), + WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPop + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT + * deleted by this routine. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_NAME (DsObjStackPop); + + + for (i = 0; i < PopCount; i++) + { + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + ACPI_ERROR ((AE_INFO, + "Object stack underflow! Count=%X State=%p #Ops=%X", + PopCount, WalkState, WalkState->NumOperands)); + return (AE_STACK_UNDERFLOW); + } + + /* Just set the stack entry to null */ + + WalkState->NumOperands--; + WalkState->Operands [WalkState->NumOperands] = NULL; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPopAndDelete + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack and delete each object that is + * popped off. + * + ******************************************************************************/ + +void +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState) +{ + INT32 i; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (DsObjStackPopAndDelete); + + + if (PopCount == 0) + { + return; + } + + for (i = (INT32) PopCount - 1; i >= 0; i--) + { + if (WalkState->NumOperands == 0) + { + return; + } + + /* Pop the stack and delete an object if present in this stack entry */ + + WalkState->NumOperands--; + ObjDesc = WalkState->Operands [i]; + if (ObjDesc) + { + AcpiUtRemoveReference (WalkState->Operands [i]); + WalkState->Operands [i] = NULL; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetCurrentWalkState + * + * PARAMETERS: Thread - Get current active state for this Thread + * + * RETURN: Pointer to the current walk state + * + * DESCRIPTION: Get the walk state that is at the head of the list (the "current" + * walk state.) + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsGetCurrentWalkState ( + ACPI_THREAD_STATE *Thread) +{ + ACPI_FUNCTION_NAME (DsGetCurrentWalkState); + + + if (!Thread) + { + return (NULL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current WalkState %p\n", + Thread->WalkStateList)); + + return (Thread->WalkStateList); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPushWalkState + * + * PARAMETERS: WalkState - State to push + * Thread - Thread state object + * + * RETURN: None + * + * DESCRIPTION: Place the Thread state at the head of the state list + * + ******************************************************************************/ + +void +AcpiDsPushWalkState ( + ACPI_WALK_STATE *WalkState, + ACPI_THREAD_STATE *Thread) +{ + ACPI_FUNCTION_TRACE (DsPushWalkState); + + + WalkState->Next = Thread->WalkStateList; + Thread->WalkStateList = WalkState; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPopWalkState + * + * PARAMETERS: Thread - Current thread state + * + * RETURN: A WalkState object popped from the thread's stack + * + * DESCRIPTION: Remove and return the walkstate object that is at the head of + * the walk stack for the given walk list. NULL indicates that + * the list is empty. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_THREAD_STATE *Thread) +{ + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (DsPopWalkState); + + + WalkState = Thread->WalkStateList; + + if (WalkState) + { + /* Next walk state becomes the current walk state */ + + Thread->WalkStateList = WalkState->Next; + + /* + * Don't clear the NEXT field, this serves as an indicator + * that there is a parent WALK STATE + * Do Not: WalkState->Next = NULL; + */ + } + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateWalkState + * + * PARAMETERS: OwnerId - ID for object creation + * Origin - Starting point for this walk + * MethodDesc - Method object + * Thread - Current thread state + * + * RETURN: Pointer to the new walk state. + * + * DESCRIPTION: Allocate and initialize a new walk state. The current walk + * state is set to this new state. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_THREAD_STATE *Thread) +{ + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (DsCreateWalkState); + + + WalkState = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_WALK_STATE)); + if (!WalkState) + { + return_PTR (NULL); + } + + WalkState->DescriptorType = ACPI_DESC_TYPE_WALK; + WalkState->MethodDesc = MethodDesc; + WalkState->OwnerId = OwnerId; + WalkState->Origin = Origin; + WalkState->Thread = Thread; + + WalkState->ParserState.StartOp = Origin; + + /* Init the method args/local */ + +#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + AcpiDsMethodDataInit (WalkState); +#endif + + /* Put the new state at the head of the walk list */ + + if (Thread) + { + AcpiDsPushWalkState (WalkState, Thread); + } + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitAmlWalk + * + * PARAMETERS: WalkState - New state to be initialized + * Op - Current parse op + * MethodNode - Control method NS node, if any + * AmlStart - Start of AML + * AmlLength - Length of AML + * Info - Method info block (params, etc.) + * PassNumber - 1, 2, or 3 + * + * RETURN: Status + * + * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitAmlWalk ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *MethodNode, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_EVALUATE_INFO *Info, + UINT8 PassNumber) +{ + ACPI_STATUS Status; + ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; + ACPI_PARSE_OBJECT *ExtraOp; + + + ACPI_FUNCTION_TRACE (DsInitAmlWalk); + + + WalkState->ParserState.Aml = + WalkState->ParserState.AmlStart = AmlStart; + WalkState->ParserState.AmlEnd = + WalkState->ParserState.PkgEnd = AmlStart + AmlLength; + + /* The NextOp of the NextWalk will be the beginning of the method */ + + WalkState->NextOp = NULL; + WalkState->PassNumber = PassNumber; + + if (Info) + { + WalkState->Params = Info->Parameters; + WalkState->CallerReturnDesc = &Info->ReturnObject; + } + + Status = AcpiPsInitScope (&WalkState->ParserState, Op); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (MethodNode) + { + WalkState->ParserState.StartNode = MethodNode; + WalkState->WalkType = ACPI_WALK_METHOD; + WalkState->MethodNode = MethodNode; + WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode); + + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Init the method arguments */ + + Status = AcpiDsMethodDataInitArgs (WalkState->Params, + ACPI_METHOD_NUM_ARGS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* + * Setup the current scope. + * Find a Named Op that has a namespace node associated with it. + * search upwards from this Op. Current scope is the first + * Op with a namespace node. + */ + ExtraOp = ParserState->StartOp; + while (ExtraOp && !ExtraOp->Common.Node) + { + ExtraOp = ExtraOp->Common.Parent; + } + + if (!ExtraOp) + { + ParserState->StartNode = NULL; + } + else + { + ParserState->StartNode = ExtraOp->Common.Node; + } + + if (ParserState->StartNode) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (ParserState->StartNode, + ParserState->StartNode->Type, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + Status = AcpiDsInitCallbacks (WalkState, PassNumber); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDeleteWalkState + * + * PARAMETERS: WalkState - State to delete + * + * RETURN: Status + * + * DESCRIPTION: Delete a walk state including all internal data structures + * + ******************************************************************************/ + +void +AcpiDsDeleteWalkState ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR (DsDeleteWalkState, WalkState); + + + if (!WalkState) + { + return; + } + + if (WalkState->DescriptorType != ACPI_DESC_TYPE_WALK) + { + ACPI_ERROR ((AE_INFO, "%p is not a valid walk state", + WalkState)); + return; + } + + /* There should not be any open scopes */ + + if (WalkState->ParserState.Scope) + { + ACPI_ERROR ((AE_INFO, "%p walk still has a scope list", + WalkState)); + AcpiPsCleanupScope (&WalkState->ParserState); + } + + /* Always must free any linked control states */ + + while (WalkState->ControlState) + { + State = WalkState->ControlState; + WalkState->ControlState = State->Common.Next; + + AcpiUtDeleteGenericState (State); + } + + /* Always must free any linked parse states */ + + while (WalkState->ScopeInfo) + { + State = WalkState->ScopeInfo; + WalkState->ScopeInfo = State->Common.Next; + + AcpiUtDeleteGenericState (State); + } + + /* Always must free any stacked result states */ + + while (WalkState->Results) + { + State = WalkState->Results; + WalkState->Results = State->Common.Next; + + AcpiUtDeleteGenericState (State); + } + + ACPI_FREE (WalkState); + return_VOID; +} + + diff --git a/drivers/bus/acpi/acpica/events/evevent.c b/drivers/bus/acpi/acpica/events/evevent.c new file mode 100644 index 00000000000..16f40271fcf --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evevent.c @@ -0,0 +1,430 @@ +/****************************************************************************** + * + * Module Name: evevent - Fixed Event handling and dispatch + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evevent") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvFixedEventInitialize ( + void); + +static UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeEvents + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeEvents ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInitializeEvents); + + + /* + * Initialize the Fixed and General Purpose Events. This is done prior to + * enabling SCIs to prevent interrupts from occurring before the handlers + * are installed. + */ + Status = AcpiEvFixedEventInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to initialize fixed events")); + return_ACPI_STATUS (Status); + } + + Status = AcpiEvGpeInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to initialize general purpose events")); + return_ACPI_STATUS (Status); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallFadtGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks + * (0 and 1). This causes the _PRW methods to be run, so the HW + * must be fully initialized at this point, including global lock + * support. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallFadtGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInstallFadtGpes); + + + /* Namespace must be locked */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* FADT GPE Block 0 */ + + (void) AcpiEvInitializeGpeBlock ( + AcpiGbl_FadtGpeDevice, AcpiGbl_GpeFadtBlocks[0]); + + /* FADT GPE Block 1 */ + + (void) AcpiEvInitializeGpeBlock ( + AcpiGbl_FadtGpeDevice, AcpiGbl_GpeFadtBlocks[1]); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallXruptHandlers + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install interrupt handlers for the SCI and Global Lock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallXruptHandlers ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInstallXruptHandlers); + + + /* Install the SCI handler */ + + Status = AcpiEvInstallSciHandler (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to install System Control Interrupt handler")); + return_ACPI_STATUS (Status); + } + + /* Install the handler for the Global Lock */ + + Status = AcpiEvInitGlobalLockHandler (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to initialize Global Lock handler")); + return_ACPI_STATUS (Status); + } + + AcpiGbl_EventsInitialized = TRUE; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFixedEventInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install the fixed event handlers and disable all fixed events. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvFixedEventInitialize ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* + * Initialize the structure that keeps track of fixed event handlers and + * enable the fixed events. + */ + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + AcpiGbl_FixedEventHandlers[i].Handler = NULL; + AcpiGbl_FixedEventHandlers[i].Context = NULL; + + /* Disable the fixed event */ + + if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) + { + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[i].EnableRegisterId, + ACPI_DISABLE_EVENT); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFixedEventDetect + * + * PARAMETERS: None + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Checks the PM status register for active fixed events + * + ******************************************************************************/ + +UINT32 +AcpiEvFixedEventDetect ( + void) +{ + UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; + UINT32 FixedStatus; + UINT32 FixedEnable; + UINT32 i; + + + ACPI_FUNCTION_NAME (EvFixedEventDetect); + + + /* + * Read the fixed feature status and enable registers, as all the cases + * depend on their values. Ignore errors here. + */ + (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_STATUS, &FixedStatus); + (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_ENABLE, &FixedEnable); + + ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, + "Fixed Event Block: Enable %08X Status %08X\n", + FixedEnable, FixedStatus)); + + /* + * Check for all possible Fixed Events and dispatch those that are active + */ + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + /* Both the status and enable bits must be on for this event */ + + if ((FixedStatus & AcpiGbl_FixedEventInfo[i].StatusBitMask) && + (FixedEnable & AcpiGbl_FixedEventInfo[i].EnableBitMask)) + { + /* Found an active (signalled) event */ + + AcpiFixedEventCount[i]++; + IntStatus |= AcpiEvFixedEventDispatch (i); + } + } + + return (IntStatus); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFixedEventDispatch + * + * PARAMETERS: Event - Event type + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Clears the status bit for the requested event, calls the + * handler that previously registered for the event. + * + ******************************************************************************/ + +static UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* Clear the status bit */ + + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); + + /* + * Make sure we've got a handler. If not, report an error. The event is + * disabled to prevent further interrupts. + */ + if (NULL == AcpiGbl_FixedEventHandlers[Event].Handler) + { + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); + + ACPI_ERROR ((AE_INFO, + "No installed handler for fixed event [%08X]", + Event)); + + return (ACPI_INTERRUPT_NOT_HANDLED); + } + + /* Invoke the Fixed Event handler */ + + return ((AcpiGbl_FixedEventHandlers[Event].Handler)( + AcpiGbl_FixedEventHandlers[Event].Context)); +} + + diff --git a/drivers/bus/acpi/acpica/events/evgpe.c b/drivers/bus/acpi/acpica/events/evgpe.c new file mode 100644 index 00000000000..17738b38404 --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evgpe.c @@ -0,0 +1,897 @@ +/****************************************************************************** + * + * Module Name: evgpe - General Purpose Event handling and dispatch + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpe") + +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchExecuteGpeMethod ( + void *Context); + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchEnableGpe ( + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSetGpeType + * + * PARAMETERS: GpeEventInfo - GPE to set + * Type - New type + * + * RETURN: Status + * + * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvSetGpeType); + + + /* Validate type and update register enable masks */ + + switch (Type) + { + case ACPI_GPE_TYPE_WAKE: + case ACPI_GPE_TYPE_RUNTIME: + case ACPI_GPE_TYPE_WAKE_RUN: + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Disable the GPE if currently enabled */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + + /* Clear the type bits and insert the new Type */ + + GpeEventInfo->Flags &= ~ACPI_GPE_TYPE_MASK; + GpeEventInfo->Flags |= Type; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvUpdateGpeEnableMasks + * + * PARAMETERS: GpeEventInfo - GPE to update + * Type - What to do: ACPI_GPE_DISABLE or + * ACPI_GPE_ENABLE + * + * RETURN: Status + * + * DESCRIPTION: Updates GPE register enable masks based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT8 RegisterBit; + + + ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMasks); + + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + RegisterBit = (UINT8) + (1 << (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber)); + + /* 1) Disable case. Simply clear all enable bits */ + + if (Type == ACPI_GPE_DISABLE) + { + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + return_ACPI_STATUS (AE_OK); + } + + /* 2) Enable case. Set/Clear the appropriate enable bits */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + break; + + case ACPI_GPE_TYPE_RUNTIME: + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvEnableGpe + * + * PARAMETERS: GpeEventInfo - GPE to enable + * WriteToHardware - Enable now, or just mark data structs + * (WAKE GPEs should be deferred) + * + * RETURN: Status + * + * DESCRIPTION: Enable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvEnableGpe); + + + /* Make sure HW enable masks are updated */ + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_ENABLE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Mark wake-enabled or HW enable, or both */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + + /*lint -fallthrough */ + + case ACPI_GPE_TYPE_RUNTIME: + + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED); + + if (WriteToHardware) + { + /* Clear the GPE (of stale events), then enable it */ + + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Enable the requested runtime GPE */ + + Status = AcpiHwWriteGpeEnableReg (GpeEventInfo); + } + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDisableGpe + * + * PARAMETERS: GpeEventInfo - GPE to disable + * + * RETURN: Status + * + * DESCRIPTION: Disable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvDisableGpe); + + + /* + * Note: Always disable the GPE, even if we think that that it is already + * disabled. It is possible that the AML or some other code has enabled + * the GPE behind our back. + */ + + /* Make sure HW enable masks are updated */ + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Clear the appropriate enabled flags for this GPE */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + + /*lint -fallthrough */ + + case ACPI_GPE_TYPE_RUNTIME: + + /* Disable the requested runtime GPE */ + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED); + break; + + default: + break; + } + + /* + * Always H/W disable this GPE, even if we don't know the GPE type. + * Simply clear the enable bit for this particular GPE, but do not + * write out the current GPE enable mask since this may inadvertently + * enable GPEs too early. An example is a rogue GPE that has arrived + * during ACPICA initialization - possibly because AML or other code + * has enabled the GPE. + */ + Status = AcpiHwLowDisableGpe (GpeEventInfo); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeEventInfo + * + * PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1 + * GpeNumber - Raw GPE number + * + * RETURN: A GPE EventInfo struct. NULL if not a valid GPE + * + * DESCRIPTION: Returns the EventInfo struct associated with this GPE. + * Validates the GpeBlock and the GpeNumber + * + * Should be called only when the GPE lists are semaphore locked + * and not subject to change. + * + ******************************************************************************/ + +ACPI_GPE_EVENT_INFO * +AcpiEvGetGpeEventInfo ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_GPE_BLOCK_INFO *GpeBlock; + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + /* A NULL GpeBlock means use the FADT-defined GPE block(s) */ + + if (!GpeDevice) + { + /* Examine GPE Block 0 and 1 (These blocks are permanent) */ + + for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) + { + GpeBlock = AcpiGbl_GpeFadtBlocks[i]; + if (GpeBlock) + { + if ((GpeNumber >= GpeBlock->BlockBaseNumber) && + (GpeNumber < GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8))) + { + return (&GpeBlock->EventInfo[GpeNumber - + GpeBlock->BlockBaseNumber]); + } + } + } + + /* The GpeNumber was not in the range of either FADT GPE block */ + + return (NULL); + } + + /* A Non-NULL GpeDevice means this is a GPE Block Device */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) GpeDevice); + if (!ObjDesc || + !ObjDesc->Device.GpeBlock) + { + return (NULL); + } + + GpeBlock = ObjDesc->Device.GpeBlock; + + if ((GpeNumber >= GpeBlock->BlockBaseNumber) && + (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8))) + { + return (&GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]); + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeDetect + * + * PARAMETERS: GpeXruptList - Interrupt block for this interrupt. + * Can have multiple GPE blocks attached. + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Detect if any GP events have occurred. This function is + * executed at interrupt level. + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDetect ( + ACPI_GPE_XRUPT_INFO *GpeXruptList) +{ + ACPI_STATUS Status; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; + UINT8 EnabledStatusByte; + UINT32 StatusReg; + UINT32 EnableReg; + ACPI_CPU_FLAGS Flags; + UINT32 i; + UINT32 j; + + + ACPI_FUNCTION_NAME (EvGpeDetect); + + /* Check for the case where there are no GPEs */ + + if (!GpeXruptList) + { + return (IntStatus); + } + + /* + * We need to obtain the GPE lock for both the data structs and registers + * Note: Not necessary to obtain the hardware lock, since the GPE + * registers are owned by the GpeLock. + */ + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Examine all GPE blocks attached to this interrupt level */ + + GpeBlock = GpeXruptList->GpeBlockListHead; + while (GpeBlock) + { + /* + * Read all of the 8-bit GPE status and enable registers in this GPE + * block, saving all of them. Find all currently active GP events. + */ + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Get the next status/enable pair */ + + GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; + + /* Read the Status Register */ + + Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Read the Enable Register */ + + Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, + "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", + GpeRegisterInfo->BaseGpeNumber, StatusReg, EnableReg)); + + /* Check if there is anything active at all in this register */ + + EnabledStatusByte = (UINT8) (StatusReg & EnableReg); + if (!EnabledStatusByte) + { + /* No active GPEs in this register, move on */ + + continue; + } + + /* Now look at the individual GPEs in this byte register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + /* Examine one GPE bit */ + + if (EnabledStatusByte & (1 << j)) + { + /* + * Found an active GPE. Dispatch the event to a handler + * or method. + */ + IntStatus |= AcpiEvGpeDispatch ( + &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j], + j + GpeRegisterInfo->BaseGpeNumber); + } + } + } + + GpeBlock = GpeBlock->Next; + } + +UnlockAndExit: + + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return (IntStatus); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAsynchExecuteGpeMethod + * + * PARAMETERS: Context (GpeEventInfo) - Info for this GPE + * + * RETURN: None + * + * DESCRIPTION: Perform the actual execution of a GPE control method. This + * function is called from an invocation of AcpiOsExecute and + * therefore does NOT execute at interrupt level - so that + * the control method itself is not executed in the context of + * an interrupt handler. + * + ******************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchExecuteGpeMethod ( + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo = Context; + ACPI_STATUS Status; + ACPI_GPE_EVENT_INFO *LocalGpeEventInfo; + ACPI_EVALUATE_INFO *Info; + + + ACPI_FUNCTION_TRACE (EvAsynchExecuteGpeMethod); + + + /* Allocate a local GPE block */ + + LocalGpeEventInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_EVENT_INFO)); + if (!LocalGpeEventInfo) + { + ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, + "while handling a GPE")); + return_VOID; + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Must revalidate the GpeNumber/GpeBlock */ + + if (!AcpiEvValidGpeEvent (GpeEventInfo)) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_VOID; + } + + /* Set the GPE flags for return to enabled state */ + + (void) AcpiEvEnableGpe (GpeEventInfo, FALSE); + + /* + * Take a snapshot of the GPE info for this level - we copy the info to + * prevent a race condition with RemoveHandler/RemoveBlock. + */ + ACPI_MEMCPY (LocalGpeEventInfo, GpeEventInfo, + sizeof (ACPI_GPE_EVENT_INFO)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* + * Must check for control method type dispatch one more time to avoid a + * race with EvGpeInstallHandler + */ + if ((LocalGpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) + { + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + Status = AE_NO_MEMORY; + } + else + { + /* + * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx + * control method that corresponds to this GPE + */ + Info->PrefixNode = LocalGpeEventInfo->Dispatch.MethodNode; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info); + ACPI_FREE (Info); + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "while evaluating GPE method [%4.4s]", + AcpiUtGetNodeName (LocalGpeEventInfo->Dispatch.MethodNode))); + } + } + + /* Defer enabling of GPE until all notify handlers are done */ + + Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, + AcpiEvAsynchEnableGpe, LocalGpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (LocalGpeEventInfo); + } + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAsynchEnableGpe + * + * PARAMETERS: Context (GpeEventInfo) - Info for this GPE + * + * RETURN: None + * + * DESCRIPTION: Asynchronous clear/enable for GPE. This allows the GPE to + * complete (i.e., finish execution of Notify) + * + ******************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchEnableGpe ( + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo = Context; + ACPI_STATUS Status; + + + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) + { + /* + * GPE is level-triggered, we clear the GPE status bit after handling + * the event. + */ + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + + /* Enable this GPE */ + + (void) AcpiHwWriteGpeEnableReg (GpeEventInfo); + +Exit: + ACPI_FREE (GpeEventInfo); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeDispatch + * + * PARAMETERS: GpeEventInfo - Info for this GPE + * GpeNumber - Number relative to the parent GPE block + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC) + * or method (e.g. _Lxx/_Exx) handler. + * + * This function executes at interrupt level. + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDispatch ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT32 GpeNumber) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvGpeDispatch); + + + AcpiGpeCount++; + + /* + * If edge-triggered, clear the GPE status bit now. Note that + * level-triggered events are cleared after the GPE is serviced. + */ + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_EDGE_TRIGGERED) + { + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to clear GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + } + + /* + * Dispatch the GPE to either an installed handler, or the control method + * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke + * it and do not attempt to run the method. If there is neither a handler + * nor a method, we disable this GPE to prevent further such pointless + * events from firing. + */ + switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) + { + case ACPI_GPE_DISPATCH_HANDLER: + + /* + * Invoke the installed handler (at interrupt level) + * Ignore return status for now. + * TBD: leave GPE disabled on error? + */ + (void) GpeEventInfo->Dispatch.Handler->Address ( + GpeEventInfo->Dispatch.Handler->Context); + + /* It is now safe to clear level-triggered events. */ + + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) + { + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to clear GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + } + break; + + case ACPI_GPE_DISPATCH_METHOD: + + /* + * Disable the GPE, so it doesn't keep firing before the method has a + * chance to run (it runs asynchronously with interrupts enabled). + */ + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to disable GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + + /* + * Execute the method associated with the GPE + * NOTE: Level-triggered GPEs are cleared after the method completes. + */ + Status = AcpiOsExecute (OSL_GPE_HANDLER, + AcpiEvAsynchExecuteGpeMethod, GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to queue handler for GPE[%2X] - event disabled", + GpeNumber)); + } + break; + + default: + + /* No handler or method to run! */ + + ACPI_ERROR ((AE_INFO, + "No handler or method for GPE[%2X], disabling event", + GpeNumber)); + + /* + * Disable the GPE. The GPE will remain disabled until the ACPICA + * Core Subsystem is restarted, or a handler is installed. + */ + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to disable GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + break; + } + + return_UINT32 (ACPI_INTERRUPT_HANDLED); +} + diff --git a/drivers/bus/acpi/acpica/events/evgpeblk.c b/drivers/bus/acpi/acpica/events/evgpeblk.c new file mode 100644 index 00000000000..c86f80aa7f5 --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evgpeblk.c @@ -0,0 +1,1402 @@ +/****************************************************************************** + * + * Module Name: evgpeblk - GPE block creation and initialization. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpeblk") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvSaveMethodInfo ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc, + void **ReturnValue); + +static ACPI_STATUS +AcpiEvMatchPrwAndGpe ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Info, + void **ReturnValue); + +static ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptNumber); + +static ACPI_STATUS +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt); + +static ACPI_STATUS +AcpiEvInstallGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock, + UINT32 InterruptNumber); + +static ACPI_STATUS +AcpiEvCreateGpeInfoBlocks ( + ACPI_GPE_BLOCK_INFO *GpeBlock); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvValidGpeEvent + * + * PARAMETERS: GpeEventInfo - Info for this GPE + * + * RETURN: TRUE if the GpeEvent is valid + * + * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. + * Should be called only when the GPE lists are semaphore locked + * and not subject to change. + * + ******************************************************************************/ + +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptBlock; + ACPI_GPE_BLOCK_INFO *GpeBlock; + + + ACPI_FUNCTION_ENTRY (); + + + /* No need for spin lock since we are not changing any list elements */ + + /* Walk the GPE interrupt levels */ + + GpeXruptBlock = AcpiGbl_GpeXruptListHead; + while (GpeXruptBlock) + { + GpeBlock = GpeXruptBlock->GpeBlockListHead; + + /* Walk the GPE blocks on this interrupt level */ + + while (GpeBlock) + { + if ((&GpeBlock->EventInfo[0] <= GpeEventInfo) && + (&GpeBlock->EventInfo[((ACPI_SIZE) + GpeBlock->RegisterCount) * 8] > GpeEventInfo)) + { + return (TRUE); + } + + GpeBlock = GpeBlock->Next; + } + + GpeXruptBlock = GpeXruptBlock->Next; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvWalkGpeList + * + * PARAMETERS: GpeWalkCallback - Routine called for each GPE block + * Context - Value passed to callback + * + * RETURN: Status + * + * DESCRIPTION: Walk the GPE lists. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context) +{ + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptInfo; + ACPI_STATUS Status = AE_OK; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvWalkGpeList); + + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Walk the interrupt level descriptor list */ + + GpeXruptInfo = AcpiGbl_GpeXruptListHead; + while (GpeXruptInfo) + { + /* Walk all Gpe Blocks attached to this interrupt level */ + + GpeBlock = GpeXruptInfo->GpeBlockListHead; + while (GpeBlock) + { + /* One callback per GPE block */ + + Status = GpeWalkCallback (GpeXruptInfo, GpeBlock, Context); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_END) /* Callback abort */ + { + Status = AE_OK; + } + goto UnlockAndExit; + } + + GpeBlock = GpeBlock->Next; + } + + GpeXruptInfo = GpeXruptInfo->Next; + } + +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDeleteGpeHandlers + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Delete all Handler objects found in the GPE data structs. + * Used only prior to termination. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + UINT32 i; + UINT32 j; + + + ACPI_FUNCTION_TRACE (EvDeleteGpeHandlers); + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Now look at the individual GPEs in this byte register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j]; + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + ACPI_FREE (GpeEventInfo->Dispatch.Handler); + GpeEventInfo->Dispatch.Handler = NULL; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; + } + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSaveMethodInfo + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a + * control method under the _GPE portion of the namespace. + * Extract the name and GPE type from the object, saving this + * information for quick lookup during GPE dispatch + * + * The name of each GPE control method is of the form: + * "_Lxx" or "_Exx" + * Where: + * L - means that the GPE is level triggered + * E - means that the GPE is edge triggered + * xx - is the GPE number [in HEX] + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvSaveMethodInfo ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc, + void **ReturnValue) +{ + ACPI_GPE_BLOCK_INFO *GpeBlock = (void *) ObjDesc; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + UINT32 GpeNumber; + char Name[ACPI_NAME_SIZE + 1]; + UINT8 Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvSaveMethodInfo); + + + /* + * _Lxx and _Exx GPE method support + * + * 1) Extract the name from the object and convert to a string + */ + ACPI_MOVE_32_TO_32 ( + Name, &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Integer); + Name[ACPI_NAME_SIZE] = 0; + + /* + * 2) Edge/Level determination is based on the 2nd character + * of the method name + * + * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE + * if a _PRW object is found that points to this GPE. + */ + switch (Name[1]) + { + case 'L': + Type = ACPI_GPE_LEVEL_TRIGGERED; + break; + + case 'E': + Type = ACPI_GPE_EDGE_TRIGGERED; + break; + + default: + /* Unknown method type, just ignore it! */ + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Ignoring unknown GPE method type: %s " + "(name not of form _Lxx or _Exx)", + Name)); + return_ACPI_STATUS (AE_OK); + } + + /* Convert the last two characters of the name to the GPE Number */ + + GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); + if (GpeNumber == ACPI_UINT32_MAX) + { + /* Conversion failed; invalid method, just ignore it */ + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Could not extract GPE number from name: %s " + "(name is not of form _Lxx or _Exx)", + Name)); + return_ACPI_STATUS (AE_OK); + } + + /* Ensure that we have a valid GPE number for this GPE block */ + + if ((GpeNumber < GpeBlock->BlockBaseNumber) || + (GpeNumber >= (GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8)))) + { + /* + * Not valid for this GPE block, just ignore it. However, it may be + * valid for a different GPE block, since GPE0 and GPE1 methods both + * appear under \_GPE. + */ + return_ACPI_STATUS (AE_OK); + } + + /* + * Now we can add this information to the GpeEventInfo block for use + * during dispatch of this GPE. Default type is RUNTIME, although this may + * change when the _PRW methods are executed later. + */ + GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]; + + GpeEventInfo->Flags = (UINT8) + (Type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME); + + GpeEventInfo->Dispatch.MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle; + + /* Update enable mask, but don't enable the HW GPE as of yet */ + + Status = AcpiEvEnableGpe (GpeEventInfo, FALSE); + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Registered GPE method %s as GPE number 0x%.2X\n", + Name, GpeNumber)); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvMatchPrwAndGpe + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is + * not aborted on a single _PRW failure. + * + * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a + * Device. Run the _PRW method. If present, extract the GPE + * number and mark the GPE as a WAKE GPE. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvMatchPrwAndGpe ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Info, + void **ReturnValue) +{ + ACPI_GPE_WALK_INFO *GpeInfo = (void *) Info; + ACPI_NAMESPACE_NODE *GpeDevice; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_NAMESPACE_NODE *TargetGpeDevice; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_OPERAND_OBJECT *PkgDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 GpeNumber; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvMatchPrwAndGpe); + + + /* Check for a _PRW method under this device */ + + Status = AcpiUtEvaluateObject (ObjHandle, METHOD_NAME__PRW, + ACPI_BTYPE_PACKAGE, &PkgDesc); + if (ACPI_FAILURE (Status)) + { + /* Ignore all errors from _PRW, we don't want to abort the subsystem */ + + return_ACPI_STATUS (AE_OK); + } + + /* The returned _PRW package must have at least two elements */ + + if (PkgDesc->Package.Count < 2) + { + goto Cleanup; + } + + /* Extract pointers from the input context */ + + GpeDevice = GpeInfo->GpeDevice; + GpeBlock = GpeInfo->GpeBlock; + + /* + * The _PRW object must return a package, we are only interested in the + * first element + */ + ObjDesc = PkgDesc->Package.Elements[0]; + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + /* Use FADT-defined GPE device (from definition of _PRW) */ + + TargetGpeDevice = AcpiGbl_FadtGpeDevice; + + /* Integer is the GPE number in the FADT described GPE blocks */ + + GpeNumber = (UINT32) ObjDesc->Integer.Value; + } + else if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + /* Package contains a GPE reference and GPE number within a GPE block */ + + if ((ObjDesc->Package.Count < 2) || + ((ObjDesc->Package.Elements[0])->Common.Type != + ACPI_TYPE_LOCAL_REFERENCE) || + ((ObjDesc->Package.Elements[1])->Common.Type != + ACPI_TYPE_INTEGER)) + { + goto Cleanup; + } + + /* Get GPE block reference and decode */ + + TargetGpeDevice = ObjDesc->Package.Elements[0]->Reference.Node; + GpeNumber = (UINT32) ObjDesc->Package.Elements[1]->Integer.Value; + } + else + { + /* Unknown type, just ignore it */ + + goto Cleanup; + } + + /* + * Is this GPE within this block? + * + * TRUE if and only if these conditions are true: + * 1) The GPE devices match. + * 2) The GPE index(number) is within the range of the Gpe Block + * associated with the GPE device. + */ + if ((GpeDevice == TargetGpeDevice) && + (GpeNumber >= GpeBlock->BlockBaseNumber) && + (GpeNumber < GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8))) + { + GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - + GpeBlock->BlockBaseNumber]; + + /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ + + GpeEventInfo->Flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); + + Status = AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); + } + +Cleanup: + AcpiUtRemoveReference (PkgDesc); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeXruptBlock + * + * PARAMETERS: InterruptNumber - Interrupt for a GPE block + * + * RETURN: A GPE interrupt block + * + * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt + * block per unique interrupt level used for GPEs. Should be + * called only when the GPE lists are semaphore locked and not + * subject to change. + * + ******************************************************************************/ + +static ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptNumber) +{ + ACPI_GPE_XRUPT_INFO *NextGpeXrupt; + ACPI_GPE_XRUPT_INFO *GpeXrupt; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock); + + + /* No need for lock since we are not changing any list elements here */ + + NextGpeXrupt = AcpiGbl_GpeXruptListHead; + while (NextGpeXrupt) + { + if (NextGpeXrupt->InterruptNumber == InterruptNumber) + { + return_PTR (NextGpeXrupt); + } + + NextGpeXrupt = NextGpeXrupt->Next; + } + + /* Not found, must allocate a new xrupt descriptor */ + + GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO)); + if (!GpeXrupt) + { + return_PTR (NULL); + } + + GpeXrupt->InterruptNumber = InterruptNumber; + + /* Install new interrupt descriptor with spin lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (AcpiGbl_GpeXruptListHead) + { + NextGpeXrupt = AcpiGbl_GpeXruptListHead; + while (NextGpeXrupt->Next) + { + NextGpeXrupt = NextGpeXrupt->Next; + } + + NextGpeXrupt->Next = GpeXrupt; + GpeXrupt->Previous = NextGpeXrupt; + } + else + { + AcpiGbl_GpeXruptListHead = GpeXrupt; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Install new interrupt handler if not SCI_INT */ + + if (InterruptNumber != AcpiGbl_FADT.SciInterrupt) + { + Status = AcpiOsInstallInterruptHandler (InterruptNumber, + AcpiEvGpeXruptHandler, GpeXrupt); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not install GPE interrupt handler at level 0x%X", + InterruptNumber)); + return_PTR (NULL); + } + } + + return_PTR (GpeXrupt); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDeleteGpeXrupt + * + * PARAMETERS: GpeXrupt - A GPE interrupt info block + * + * RETURN: Status + * + * DESCRIPTION: Remove and free a GpeXrupt block. Remove an associated + * interrupt handler if not the SCI interrupt. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt) +{ + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvDeleteGpeXrupt); + + + /* We never want to remove the SCI interrupt handler */ + + if (GpeXrupt->InterruptNumber == AcpiGbl_FADT.SciInterrupt) + { + GpeXrupt->GpeBlockListHead = NULL; + return_ACPI_STATUS (AE_OK); + } + + /* Disable this interrupt */ + + Status = AcpiOsRemoveInterruptHandler ( + GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Unlink the interrupt block with lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeXrupt->Previous) + { + GpeXrupt->Previous->Next = GpeXrupt->Next; + } + else + { + /* No previous, update list head */ + + AcpiGbl_GpeXruptListHead = GpeXrupt->Next; + } + + if (GpeXrupt->Next) + { + GpeXrupt->Next->Previous = GpeXrupt->Previous; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Free the block */ + + ACPI_FREE (GpeXrupt); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallGpeBlock + * + * PARAMETERS: GpeBlock - New GPE block + * InterruptNumber - Xrupt to be associated with this + * GPE block + * + * RETURN: Status + * + * DESCRIPTION: Install new GPE block with mutex support + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvInstallGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock, + UINT32 InterruptNumber) +{ + ACPI_GPE_BLOCK_INFO *NextGpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptBlock; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvInstallGpeBlock); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + GpeXruptBlock = AcpiEvGetGpeXruptBlock (InterruptNumber); + if (!GpeXruptBlock) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Install the new block at the end of the list with lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeXruptBlock->GpeBlockListHead) + { + NextGpeBlock = GpeXruptBlock->GpeBlockListHead; + while (NextGpeBlock->Next) + { + NextGpeBlock = NextGpeBlock->Next; + } + + NextGpeBlock->Next = GpeBlock; + GpeBlock->Previous = NextGpeBlock; + } + else + { + GpeXruptBlock->GpeBlockListHead = GpeBlock; + } + + GpeBlock->XruptBlock = GpeXruptBlock; + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDeleteGpeBlock + * + * PARAMETERS: GpeBlock - Existing GPE block + * + * RETURN: Status + * + * DESCRIPTION: Remove a GPE block + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDeleteGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvInstallGpeBlock); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Disable all GPEs in this block */ + + Status = AcpiHwDisableGpeBlock (GpeBlock->XruptBlock, GpeBlock, NULL); + + if (!GpeBlock->Previous && !GpeBlock->Next) + { + /* This is the last GpeBlock on this interrupt */ + + Status = AcpiEvDeleteGpeXrupt (GpeBlock->XruptBlock); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + else + { + /* Remove the block on this interrupt with lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeBlock->Previous) + { + GpeBlock->Previous->Next = GpeBlock->Next; + } + else + { + GpeBlock->XruptBlock->GpeBlockListHead = GpeBlock->Next; + } + + if (GpeBlock->Next) + { + GpeBlock->Next->Previous = GpeBlock->Previous; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + } + + AcpiCurrentGpeCount -= GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH; + + /* Free the GpeBlock */ + + ACPI_FREE (GpeBlock->RegisterInfo); + ACPI_FREE (GpeBlock->EventInfo); + ACPI_FREE (GpeBlock); + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvCreateGpeInfoBlocks + * + * PARAMETERS: GpeBlock - New GPE block + * + * RETURN: Status + * + * DESCRIPTION: Create the RegisterInfo and EventInfo blocks for this GPE block + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvCreateGpeInfoBlocks ( + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo = NULL; + ACPI_GPE_EVENT_INFO *GpeEventInfo = NULL; + ACPI_GPE_EVENT_INFO *ThisEvent; + ACPI_GPE_REGISTER_INFO *ThisRegister; + UINT32 i; + UINT32 j; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvCreateGpeInfoBlocks); + + + /* Allocate the GPE register information block */ + + GpeRegisterInfo = ACPI_ALLOCATE_ZEROED ( + (ACPI_SIZE) GpeBlock->RegisterCount * + sizeof (ACPI_GPE_REGISTER_INFO)); + if (!GpeRegisterInfo) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate the GpeRegisterInfo table")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Allocate the GPE EventInfo block. There are eight distinct GPEs + * per register. Initialization to zeros is sufficient. + */ + GpeEventInfo = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) GpeBlock->RegisterCount * + ACPI_GPE_REGISTER_WIDTH) * + sizeof (ACPI_GPE_EVENT_INFO)); + if (!GpeEventInfo) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate the GpeEventInfo table")); + Status = AE_NO_MEMORY; + goto ErrorExit; + } + + /* Save the new Info arrays in the GPE block */ + + GpeBlock->RegisterInfo = GpeRegisterInfo; + GpeBlock->EventInfo = GpeEventInfo; + + /* + * Initialize the GPE Register and Event structures. A goal of these + * tables is to hide the fact that there are two separate GPE register + * sets in a given GPE hardware block, the status registers occupy the + * first half, and the enable registers occupy the second half. + */ + ThisRegister = GpeRegisterInfo; + ThisEvent = GpeEventInfo; + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Init the RegisterInfo for this GPE register (8 GPEs) */ + + ThisRegister->BaseGpeNumber = (UINT8) (GpeBlock->BlockBaseNumber + + (i * ACPI_GPE_REGISTER_WIDTH)); + + ThisRegister->StatusAddress.Address = + GpeBlock->BlockAddress.Address + i; + + ThisRegister->EnableAddress.Address = + GpeBlock->BlockAddress.Address + i + GpeBlock->RegisterCount; + + ThisRegister->StatusAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; + ThisRegister->EnableAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; + ThisRegister->StatusAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->EnableAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->StatusAddress.BitOffset = 0; + ThisRegister->EnableAddress.BitOffset = 0; + + /* Init the EventInfo for each GPE within this register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + ThisEvent->GpeNumber = (UINT8) (ThisRegister->BaseGpeNumber + j); + ThisEvent->RegisterInfo = ThisRegister; + ThisEvent++; + } + + /* Disable all GPEs within this register */ + + Status = AcpiHwWrite (0x00, &ThisRegister->EnableAddress); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Clear any pending GPE events within this register */ + + Status = AcpiHwWrite (0xFF, &ThisRegister->StatusAddress); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ThisRegister++; + } + + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + if (GpeRegisterInfo) + { + ACPI_FREE (GpeRegisterInfo); + } + if (GpeEventInfo) + { + ACPI_FREE (GpeEventInfo); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvCreateGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE block + * GpeBlockAddress - Address and SpaceID + * RegisterCount - Number of GPE register pairs in the block + * GpeBlockBaseNumber - Starting GPE number for the block + * InterruptNumber - H/W interrupt for the block + * ReturnGpeBlock - Where the new block descriptor is returned + * + * RETURN: Status + * + * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within + * the block are disabled at exit. + * Note: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvCreateGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT8 GpeBlockBaseNumber, + UINT32 InterruptNumber, + ACPI_GPE_BLOCK_INFO **ReturnGpeBlock) +{ + ACPI_STATUS Status; + ACPI_GPE_BLOCK_INFO *GpeBlock; + + + ACPI_FUNCTION_TRACE (EvCreateGpeBlock); + + + if (!RegisterCount) + { + return_ACPI_STATUS (AE_OK); + } + + /* Allocate a new GPE block */ + + GpeBlock = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_BLOCK_INFO)); + if (!GpeBlock) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new GPE block */ + + GpeBlock->Node = GpeDevice; + GpeBlock->RegisterCount = RegisterCount; + GpeBlock->BlockBaseNumber = GpeBlockBaseNumber; + + ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, + sizeof (ACPI_GENERIC_ADDRESS)); + + /* + * Create the RegisterInfo and EventInfo sub-structures + * Note: disables and clears all GPEs in the block + */ + Status = AcpiEvCreateGpeInfoBlocks (GpeBlock); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (GpeBlock); + return_ACPI_STATUS (Status); + } + + /* Install the new block in the global lists */ + + Status = AcpiEvInstallGpeBlock (GpeBlock, InterruptNumber); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (GpeBlock); + return_ACPI_STATUS (Status); + } + + /* Find all GPE methods (_Lxx, _Exx) for this block */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiEvSaveMethodInfo, NULL, GpeBlock, NULL); + + /* Return the new block */ + + if (ReturnGpeBlock) + { + (*ReturnGpeBlock) = GpeBlock; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", + (UINT32) GpeBlock->BlockBaseNumber, + (UINT32) (GpeBlock->BlockBaseNumber + + ((GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) -1)), + GpeDevice->Name.Ascii, + GpeBlock->RegisterCount, + InterruptNumber)); + + /* Update global count of currently available GPEs */ + + AcpiCurrentGpeCount += RegisterCount * ACPI_GPE_REGISTER_WIDTH; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE block + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Initialize and enable a GPE block. First find and run any + * _PRT methods associated with the block, then enable the + * appropriate GPEs. + * Note: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_STATUS Status; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_GPE_WALK_INFO GpeInfo; + UINT32 WakeGpeCount; + UINT32 GpeEnabledCount; + UINT32 i; + UINT32 j; + + + ACPI_FUNCTION_TRACE (EvInitializeGpeBlock); + + + /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */ + + if (!GpeBlock) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Runtime option: Should wake GPEs be enabled at runtime? The default + * is no, they should only be enabled just as the machine goes to sleep. + */ + if (AcpiGbl_LeaveWakeGpesDisabled) + { + /* + * Differentiate runtime vs wake GPEs, via the _PRW control methods. + * Each GPE that has one or more _PRWs that reference it is by + * definition a wake GPE and will not be enabled while the machine + * is running. + */ + GpeInfo.GpeBlock = GpeBlock; + GpeInfo.GpeDevice = GpeDevice; + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, + AcpiEvMatchPrwAndGpe, NULL, &GpeInfo, NULL); + } + + /* + * Enable all GPEs in this block that have these attributes: + * 1) are "runtime" or "run/wake" GPEs, and + * 2) have a corresponding _Lxx or _Exx method + * + * Any other GPEs within this block must be enabled via the + * AcpiEnableGpe() external interface. + */ + WakeGpeCount = 0; + GpeEnabledCount = 0; + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + for (j = 0; j < 8; j++) + { + /* Get the info block for this particular GPE */ + + GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j]; + + if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) && + (GpeEventInfo->Flags & ACPI_GPE_TYPE_RUNTIME)) + { + GpeEnabledCount++; + } + + if (GpeEventInfo->Flags & ACPI_GPE_TYPE_WAKE) + { + WakeGpeCount++; + } + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Found %u Wake, Enabled %u Runtime GPEs in this block\n", + WakeGpeCount, GpeEnabledCount)); + + /* Enable all valid runtime GPEs found above */ + + Status = AcpiHwEnableRuntimeGpeBlock (NULL, GpeBlock, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not enable GPEs in GpeBlock %p", + GpeBlock)); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize the GPE data structures + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvGpeInitialize ( + void) +{ + UINT32 RegisterCount0 = 0; + UINT32 RegisterCount1 = 0; + UINT32 GpeNumberMax = 0; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvGpeInitialize); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Initialize the GPE Block(s) defined in the FADT + * + * Why the GPE register block lengths are divided by 2: From the ACPI + * Spec, section "General-Purpose Event Registers", we have: + * + * "Each register block contains two registers of equal length + * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the + * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN + * The length of the GPE1_STS and GPE1_EN registers is equal to + * half the GPE1_LEN. If a generic register block is not supported + * then its respective block pointer and block length values in the + * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need + * to be the same size." + */ + + /* + * Determine the maximum GPE number for this machine. + * + * Note: both GPE0 and GPE1 are optional, and either can exist without + * the other. + * + * If EITHER the register length OR the block address are zero, then that + * particular block is not supported. + */ + if (AcpiGbl_FADT.Gpe0BlockLength && + AcpiGbl_FADT.XGpe0Block.Address) + { + /* GPE block 0 exists (has both length and address > 0) */ + + RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2); + + GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1; + + /* Install GPE Block 0 */ + + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create GPE Block 0")); + } + } + + if (AcpiGbl_FADT.Gpe1BlockLength && + AcpiGbl_FADT.XGpe1Block.Address) + { + /* GPE block 1 exists (has both length and address > 0) */ + + RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2); + + /* Check for GPE0/GPE1 overlap (if both banks exist) */ + + if ((RegisterCount0) && + (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base)) + { + ACPI_ERROR ((AE_INFO, + "GPE0 block (GPE 0 to %d) overlaps the GPE1 block " + "(GPE %d to %d) - Ignoring GPE1", + GpeNumberMax, AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.Gpe1Base + + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1))); + + /* Ignore GPE1 block by setting the register count to zero */ + + RegisterCount1 = 0; + } + else + { + /* Install GPE Block 1 */ + + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT.XGpe1Block, RegisterCount1, + AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create GPE Block 1")); + } + + /* + * GPE0 and GPE1 do not have to be contiguous in the GPE number + * space. However, GPE0 always starts at GPE number zero. + */ + GpeNumberMax = AcpiGbl_FADT.Gpe1Base + + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); + } + } + + /* Exit if there are no GPE registers */ + + if ((RegisterCount0 + RegisterCount1) == 0) + { + /* GPEs are not required by ACPI, this is OK */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "There are no GPE blocks defined in the FADT\n")); + Status = AE_OK; + goto Cleanup; + } + + /* Check for Max GPE number out-of-range */ + + if (GpeNumberMax > ACPI_GPE_MAX) + { + ACPI_ERROR ((AE_INFO, + "Maximum GPE number from FADT is too large: 0x%X", + GpeNumberMax)); + Status = AE_BAD_VALUE; + goto Cleanup; + } + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/events/evmisc.c b/drivers/bus/acpi/acpica/events/evmisc.c new file mode 100644 index 00000000000..1e7f9e1cb56 --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evmisc.c @@ -0,0 +1,740 @@ +/****************************************************************************** + * + * Module Name: evmisc - Miscellaneous event manager support functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evmisc") + + +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvNotifyDispatch ( + void *Context); + +static UINT32 +AcpiEvGlobalLockHandler ( + void *Context); + +static ACPI_STATUS +AcpiEvRemoveGlobalLockHandler ( + void); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIsNotifyObject + * + * PARAMETERS: Node - Node to check + * + * RETURN: TRUE if notifies allowed on this object + * + * DESCRIPTION: Check type of node for a object that supports notifies. + * + * TBD: This could be replaced by a flag bit in the node. + * + ******************************************************************************/ + +BOOLEAN +AcpiEvIsNotifyObject ( + ACPI_NAMESPACE_NODE *Node) +{ + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + /* + * These are the ONLY objects that can receive ACPI notifications + */ + return (TRUE); + + default: + return (FALSE); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvQueueNotifyRequest + * + * PARAMETERS: Node - NS node for the notified object + * NotifyValue - Value from the Notify() request + * + * RETURN: Status + * + * DESCRIPTION: Dispatch a device notification event to a previously + * installed handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvQueueNotifyRequest ( + ACPI_NAMESPACE_NODE *Node, + UINT32 NotifyValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj = NULL; + ACPI_GENERIC_STATE *NotifyInfo; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_NAME (EvQueueNotifyRequest); + + + /* + * For value 3 (Ejection Request), some device method may need to be run. + * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need + * to be run. + * For value 0x80 (Status Change) on the power button or sleep button, + * initiate soft-off or sleep operation? + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n", + AcpiUtGetNodeName (Node), Node, NotifyValue, + AcpiUtGetNotifyName (NotifyValue))); + + /* Get the notify object attached to the NS Node */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* We have the notify object, Get the right handler */ + + switch (Node->Type) + { + /* Notify allowed only on these types */ + + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_PROCESSOR: + + if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) + { + HandlerObj = ObjDesc->CommonNotify.SystemNotify; + } + else + { + HandlerObj = ObjDesc->CommonNotify.DeviceNotify; + } + break; + + default: + + /* All other types are not supported */ + + return (AE_TYPE); + } + } + + /* + * If there is any handler to run, schedule the dispatcher. + * Check for: + * 1) Global system notify handler + * 2) Global device notify handler + * 3) Per-device notify handler + */ + if ((AcpiGbl_SystemNotify.Handler && + (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) || + (AcpiGbl_DeviceNotify.Handler && + (NotifyValue > ACPI_MAX_SYS_NOTIFY)) || + HandlerObj) + { + NotifyInfo = AcpiUtCreateGenericState (); + if (!NotifyInfo) + { + return (AE_NO_MEMORY); + } + + if (!HandlerObj) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Executing system notify handler for Notify (%4.4s, %X) " + "node %p\n", + AcpiUtGetNodeName (Node), NotifyValue, Node)); + } + + NotifyInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY; + NotifyInfo->Notify.Node = Node; + NotifyInfo->Notify.Value = (UINT16) NotifyValue; + NotifyInfo->Notify.HandlerObj = HandlerObj; + + Status = AcpiOsExecute ( + OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, NotifyInfo); + if (ACPI_FAILURE (Status)) + { + AcpiUtDeleteGenericState (NotifyInfo); + } + } + else + { + /* There is no notify handler (per-device or system) for this device */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "No notify handler for Notify (%4.4s, %X) node %p\n", + AcpiUtGetNodeName (Node), NotifyValue, Node)); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvNotifyDispatch + * + * PARAMETERS: Context - To be passed to the notify handler + * + * RETURN: None. + * + * DESCRIPTION: Dispatch a device notification event to a previously + * installed handler. + * + ******************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AcpiEvNotifyDispatch ( + void *Context) +{ + ACPI_GENERIC_STATE *NotifyInfo = (ACPI_GENERIC_STATE *) Context; + ACPI_NOTIFY_HANDLER GlobalHandler = NULL; + void *GlobalContext = NULL; + ACPI_OPERAND_OBJECT *HandlerObj; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * We will invoke a global notify handler if installed. This is done + * _before_ we invoke the per-device handler attached to the device. + */ + if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY) + { + /* Global system notification handler */ + + if (AcpiGbl_SystemNotify.Handler) + { + GlobalHandler = AcpiGbl_SystemNotify.Handler; + GlobalContext = AcpiGbl_SystemNotify.Context; + } + } + else + { + /* Global driver notification handler */ + + if (AcpiGbl_DeviceNotify.Handler) + { + GlobalHandler = AcpiGbl_DeviceNotify.Handler; + GlobalContext = AcpiGbl_DeviceNotify.Context; + } + } + + /* Invoke the system handler first, if present */ + + if (GlobalHandler) + { + GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, + GlobalContext); + } + + /* Now invoke the per-device handler, if present */ + + HandlerObj = NotifyInfo->Notify.HandlerObj; + if (HandlerObj) + { + HandlerObj->Notify.Handler (NotifyInfo->Notify.Node, + NotifyInfo->Notify.Value, + HandlerObj->Notify.Context); + } + + /* All done with the info object */ + + AcpiUtDeleteGenericState (NotifyInfo); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGlobalLockHandler + * + * PARAMETERS: Context - From thread interface, not used + * + * RETURN: ACPI_INTERRUPT_HANDLED + * + * DESCRIPTION: Invoked directly from the SCI handler when a global lock + * release interrupt occurs. Attempt to acquire the global lock, + * if successful, signal the thread waiting for the lock. + * + * NOTE: Assumes that the semaphore can be signaled from interrupt level. If + * this is not possible for some reason, a separate thread will have to be + * scheduled to do this. + * + ******************************************************************************/ + +static UINT32 +AcpiEvGlobalLockHandler ( + void *Context) +{ + BOOLEAN Acquired = FALSE; + ACPI_STATUS Status; + + + /* + * Attempt to get the lock. + * + * If we don't get it now, it will be marked pending and we will + * take another interrupt when it becomes free. + */ + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired); + if (Acquired) + { + /* Got the lock, now wake the thread waiting for it */ + + AcpiGbl_GlobalLockAcquired = TRUE; + + /* Send a unit to the semaphore */ + + Status = AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, 1); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not signal Global Lock semaphore")); + } + } + + return (ACPI_INTERRUPT_HANDLED); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitGlobalLockHandler + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for the global lock release event + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitGlobalLockHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInitGlobalLockHandler); + + + /* Attempt installation of the global lock handler */ + + Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, + AcpiEvGlobalLockHandler, NULL); + + /* + * If the global lock does not exist on this platform, the attempt to + * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick). + * Map to AE_OK, but mark global lock as not present. Any attempt to + * actually use the global lock will be flagged with an error. + */ + if (Status == AE_NO_HARDWARE_RESPONSE) + { + ACPI_ERROR ((AE_INFO, + "No response from Global Lock hardware, disabling lock")); + + AcpiGbl_GlobalLockPresent = FALSE; + return_ACPI_STATUS (AE_OK); + } + + AcpiGbl_GlobalLockPresent = TRUE; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvRemoveGlobalLockHandler + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Remove the handler for the Global Lock + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvRemoveGlobalLockHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvRemoveGlobalLockHandler); + + AcpiGbl_GlobalLockPresent = FALSE; + Status = AcpiRemoveFixedEventHandler (ACPI_EVENT_GLOBAL, + AcpiEvGlobalLockHandler); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvAcquireGlobalLock + * + * PARAMETERS: Timeout - Max time to wait for the lock, in millisec. + * + * RETURN: Status + * + * DESCRIPTION: Attempt to gain ownership of the Global Lock. + * + * MUTEX: Interpreter must be locked + * + * Note: The original implementation allowed multiple threads to "acquire" the + * Global Lock, and the OS would hold the lock until the last thread had + * released it. However, this could potentially starve the BIOS out of the + * lock, especially in the case where there is a tight handshake between the + * Embedded Controller driver and the BIOS. Therefore, this implementation + * allows only one thread to acquire the HW Global Lock at a time, and makes + * the global lock appear as a standard mutex on the OS side. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiEvAcquireGlobalLock ( + UINT16 Timeout) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN Acquired = FALSE; + + + ACPI_FUNCTION_TRACE (EvAcquireGlobalLock); + + + /* + * Only one thread can acquire the GL at a time, the GlobalLockMutex + * enforces this. This interface releases the interpreter if we must wait. + */ + Status = AcpiExSystemWaitMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex, + Timeout); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Update the global lock handle and check for wraparound. The handle is + * only used for the external global lock interfaces, but it is updated + * here to properly handle the case where a single thread may acquire the + * lock via both the AML and the AcpiAcquireGlobalLock interfaces. The + * handle is therefore updated on the first acquire from a given thread + * regardless of where the acquisition request originated. + */ + AcpiGbl_GlobalLockHandle++; + if (AcpiGbl_GlobalLockHandle == 0) + { + AcpiGbl_GlobalLockHandle = 1; + } + + /* + * Make sure that a global lock actually exists. If not, just treat the + * lock as a standard mutex. + */ + if (!AcpiGbl_GlobalLockPresent) + { + AcpiGbl_GlobalLockAcquired = TRUE; + return_ACPI_STATUS (AE_OK); + } + + /* Attempt to acquire the actual hardware lock */ + + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired); + if (Acquired) + { + /* We got the lock */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired hardware Global Lock\n")); + + AcpiGbl_GlobalLockAcquired = TRUE; + return_ACPI_STATUS (AE_OK); + } + + /* + * Did not get the lock. The pending bit was set above, and we must now + * wait until we get the global lock released interrupt. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for hardware Global Lock\n")); + + /* + * Wait for handshake with the global lock interrupt handler. + * This interface releases the interpreter if we must wait. + */ + Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, + ACPI_WAIT_FOREVER); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvReleaseGlobalLock + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Releases ownership of the Global Lock. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvReleaseGlobalLock ( + void) +{ + BOOLEAN Pending = FALSE; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (EvReleaseGlobalLock); + + + /* Lock must be already acquired */ + + if (!AcpiGbl_GlobalLockAcquired) + { + ACPI_WARNING ((AE_INFO, + "Cannot release the ACPI Global Lock, it has not been acquired")); + return_ACPI_STATUS (AE_NOT_ACQUIRED); + } + + if (AcpiGbl_GlobalLockPresent) + { + /* Allow any thread to release the lock */ + + ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_FACS, Pending); + + /* + * If the pending bit was set, we must write GBL_RLS to the control + * register + */ + if (Pending) + { + Status = AcpiWriteBitRegister ( + ACPI_BITREG_GLOBAL_LOCK_RELEASE, ACPI_ENABLE_EVENT); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Released hardware Global Lock\n")); + } + + AcpiGbl_GlobalLockAcquired = FALSE; + + /* Release the local GL mutex */ + + AcpiOsReleaseMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Disable events and free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiEvTerminate ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvTerminate); + + + if (AcpiGbl_EventsInitialized) + { + /* + * Disable all event-related functionality. In all cases, on error, + * print a message but obviously we don't abort. + */ + + /* Disable all fixed events */ + + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + Status = AcpiDisableEvent (i, 0); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not disable fixed event %d", (UINT32) i)); + } + } + + /* Disable all GPEs in all GPE blocks */ + + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); + + /* Remove SCI handler */ + + Status = AcpiEvRemoveSciHandler (); + if (ACPI_FAILURE(Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not remove SCI handler")); + } + + Status = AcpiEvRemoveGlobalLockHandler (); + if (ACPI_FAILURE(Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not remove Global Lock handler")); + } + } + + /* Deallocate all handler objects installed within GPE info structs */ + + Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, NULL); + + /* Return to original mode if necessary */ + + if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY) + { + Status = AcpiDisable (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "AcpiDisable failed")); + } + } + return_VOID; +} + diff --git a/drivers/bus/acpi/acpica/events/evregion.c b/drivers/bus/acpi/acpica/events/evregion.c new file mode 100644 index 00000000000..2bdfb872fe0 --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evregion.c @@ -0,0 +1,1284 @@ +/****************************************************************************** + * + * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVREGION_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evregion") + + +/* Local prototypes */ + +static BOOLEAN +AcpiEvHasDefaultHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId); + +static ACPI_STATUS +AcpiEvRegRun ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiEvInstallHandler ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +/* These are the address spaces that will get default handlers */ + +#define ACPI_NUM_DEFAULT_SPACES 4 + +static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = +{ + ACPI_ADR_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_IO, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_ADR_SPACE_DATA_TABLE +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallRegionHandlers + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Installs the core subsystem default address space handlers. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (EvInstallRegionHandlers); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * All address spaces (PCI Config, EC, SMBus) are scope dependent and + * registration must occur for a specific device. + * + * In the case of the system memory and IO address spaces there is + * currently no device associated with the address space. For these we + * use the root. + * + * We install the default PCI config space handler at the root so that + * this space is immediately available even though the we have not + * enumerated all the PCI Root Buses yet. This is to conform to the ACPI + * specification which states that the PCI config space must be always + * available -- even though we are nowhere near ready to find the PCI root + * buses at this point. + * + * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler + * has already been installed (via AcpiInstallAddressSpaceHandler). + * Similar for AE_SAME_HANDLER. + */ + for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) + { + Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i], + ACPI_DEFAULT_HANDLER, NULL, NULL); + switch (Status) + { + case AE_OK: + case AE_SAME_HANDLER: + case AE_ALREADY_EXISTS: + + /* These exceptions are all OK */ + + Status = AE_OK; + break; + + default: + + goto UnlockAndExit; + } + } + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvHasDefaultHandler + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * + * RETURN: TRUE if default handler is installed, FALSE otherwise + * + * DESCRIPTION: Check if the default handler is installed for the requested + * space ID. + * + ******************************************************************************/ + +static BOOLEAN +AcpiEvHasDefaultHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + + + /* Must have an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + HandlerObj = ObjDesc->Device.Handler; + + /* Walk the linked list of handlers for this object */ + + while (HandlerObj) + { + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + if (HandlerObj->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) + { + return (TRUE); + } + } + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeOpRegions + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG methods for all Operation Regions that have + * an installed default region handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeOpRegions ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (EvInitializeOpRegions); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Run the _REG methods for OpRegions in each default address space */ + + for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) + { + /* + * Make sure the installed handler is the DEFAULT handler. If not the + * default, the _REG methods will have already been run (when the + * handler was installed) + */ + if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i])) + { + Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i]); + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvExecuteRegMethod + * + * PARAMETERS: RegionObj - Region object + * Function - Passed to _REG: On (1) or Off (0) + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG method for a region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function) +{ + ACPI_EVALUATE_INFO *Info; + ACPI_OPERAND_OBJECT *Args[3]; + ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvExecuteRegMethod); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (RegionObj2->Extra.Method_REG == NULL) + { + return_ACPI_STATUS (AE_OK); + } + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = RegionObj2->Extra.Method_REG; + Info->Pathname = NULL; + Info->Parameters = Args; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + /* + * The _REG method has two arguments: + * + * Arg0 - Integer: + * Operation region space ID Same value as RegionObj->Region.SpaceId + * + * Arg1 - Integer: + * connection status 1 for connecting the handler, 0 for disconnecting + * the handler (Passed as a parameter) + */ + Args[0] = AcpiUtCreateIntegerObject ((UINT64) RegionObj->Region.SpaceId); + if (!Args[0]) + { + Status = AE_NO_MEMORY; + goto Cleanup1; + } + + Args[1] = AcpiUtCreateIntegerObject ((UINT64) Function); + if (!Args[1]) + { + Status = AE_NO_MEMORY; + goto Cleanup2; + } + + Args[2] = NULL; /* Terminate list */ + + /* Execute the method, no return value */ + + ACPI_DEBUG_EXEC ( + AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Info->PrefixNode, NULL)); + + Status = AcpiNsEvaluate (Info); + AcpiUtRemoveReference (Args[1]); + +Cleanup2: + AcpiUtRemoveReference (Args[0]); + +Cleanup1: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAddressSpaceDispatch + * + * PARAMETERS: RegionObj - Internal region object + * Function - Read or Write operation + * RegionOffset - Where in the region to read or write + * BitWidth - Field width in bits (8, 16, 32, or 64) + * Value - Pointer to in or out value, must be + * full 64-bit ACPI_INTEGER + * + * RETURN: Status + * + * DESCRIPTION: Dispatch an address space or operation region access to + * a previously installed handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + UINT32 RegionOffset, + UINT32 BitWidth, + ACPI_INTEGER *Value) +{ + ACPI_STATUS Status; + ACPI_ADR_SPACE_HANDLER Handler; + ACPI_ADR_SPACE_SETUP RegionSetup; + ACPI_OPERAND_OBJECT *HandlerDesc; + ACPI_OPERAND_OBJECT *RegionObj2; + void *RegionContext = NULL; + + + ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Ensure that there is a handler associated with this region */ + + HandlerDesc = RegionObj->Region.Handler; + if (!HandlerDesc) + { + ACPI_ERROR ((AE_INFO, + "No handler for Region [%4.4s] (%p) [%s]", + AcpiUtGetNodeName (RegionObj->Region.Node), + RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * It may be the case that the region has never been initialized. + * Some types of regions require special init code + */ + if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)) + { + /* This region has not been initialized yet, do it */ + + RegionSetup = HandlerDesc->AddressSpace.Setup; + if (!RegionSetup) + { + /* No initialization routine, exit with error */ + + ACPI_ERROR ((AE_INFO, + "No init routine for region(%p) [%s]", + RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * We must exit the interpreter because the region setup will + * potentially execute control methods (for example, the _REG method + * for this region) + */ + AcpiExExitInterpreter (); + + Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE, + HandlerDesc->AddressSpace.Context, &RegionContext); + + /* Re-enter the interpreter */ + + AcpiExEnterInterpreter (); + + /* Check for failure of the Region Setup */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "During region initialization: [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + return_ACPI_STATUS (Status); + } + + /* Region initialization may have been completed by RegionSetup */ + + if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)) + { + RegionObj->Region.Flags |= AOPOBJ_SETUP_COMPLETE; + + if (RegionObj2->Extra.RegionContext) + { + /* The handler for this region was already installed */ + + ACPI_FREE (RegionContext); + } + else + { + /* + * Save the returned context for use in all accesses to + * this particular region + */ + RegionObj2->Extra.RegionContext = RegionContext; + } + } + } + + /* We have everything we need, we can invoke the address space handler */ + + Handler = HandlerDesc->AddressSpace.Handler; + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", + &RegionObj->Region.Handler->AddressSpace, Handler, + ACPI_FORMAT_NATIVE_UINT (RegionObj->Region.Address + RegionOffset), + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + if (!(HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + { + /* + * For handlers other than the default (supplied) handlers, we must + * exit the interpreter because the handler *might* block -- we don't + * know what it will do, so we can't hold the lock on the intepreter. + */ + AcpiExExitInterpreter(); + } + + /* Call the handler */ + + Status = Handler (Function, + (RegionObj->Region.Address + RegionOffset), BitWidth, Value, + HandlerDesc->AddressSpace.Context, RegionObj2->Extra.RegionContext); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "Returned by Handler for [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } + + if (!(HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + { + /* + * We just returned from a non-default handler, we must re-enter the + * interpreter + */ + AcpiExEnterInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDetachRegion + * + * PARAMETERS: RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? + * + * RETURN: None + * + * DESCRIPTION: Break the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +void +AcpiEvDetachRegion( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **LastObjPtr; + ACPI_ADR_SPACE_SETUP RegionSetup; + void **RegionContext; + ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvDetachRegion); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_VOID; + } + RegionContext = &RegionObj2->Extra.RegionContext; + + /* Get the address handler from the region object */ + + HandlerObj = RegionObj->Region.Handler; + if (!HandlerObj) + { + /* This region has no handler, all done */ + + return_VOID; + } + + /* Find this region in the handler's list */ + + ObjDesc = HandlerObj->AddressSpace.RegionList; + LastObjPtr = &HandlerObj->AddressSpace.RegionList; + + while (ObjDesc) + { + /* Is this the correct Region? */ + + if (ObjDesc == RegionObj) + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Removing Region %p from address handler %p\n", + RegionObj, HandlerObj)); + + /* This is it, remove it from the handler's list */ + + *LastObjPtr = ObjDesc->Region.Next; + ObjDesc->Region.Next = NULL; /* Must clear field */ + + if (AcpiNsIsLocked) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + } + + /* Now stop region accesses by executing the _REG method */ + + Status = AcpiEvExecuteRegMethod (RegionObj, 0); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "from region _REG, [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } + + if (AcpiNsIsLocked) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + } + + /* + * If the region has been activated, call the setup handler with + * the deactivate notification + */ + if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) + { + RegionSetup = HandlerObj->AddressSpace.Setup; + Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE, + HandlerObj->AddressSpace.Context, RegionContext); + + /* Init routine may fail, Just ignore errors */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "from region handler - deactivate, [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } + + RegionObj->Region.Flags &= ~(AOPOBJ_SETUP_COMPLETE); + } + + /* + * Remove handler reference in the region + * + * NOTE: this doesn't mean that the region goes away, the region + * is just inaccessible as indicated to the _REG method + * + * If the region is on the handler's list, this must be the + * region's handler + */ + RegionObj->Region.Handler = NULL; + AcpiUtRemoveReference (HandlerObj); + + return_VOID; + } + + /* Walk the linked list of handlers */ + + LastObjPtr = &ObjDesc->Region.Next; + ObjDesc = ObjDesc->Region.Next; + } + + /* If we get here, the region was not in the handler's region list */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Cannot remove region %p from address handler %p\n", + RegionObj, HandlerObj)); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAttachRegion + * + * PARAMETERS: HandlerObj - Handler Object + * RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? + * + * RETURN: None + * + * DESCRIPTION: Create the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvAttachRegion ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked) +{ + + ACPI_FUNCTION_TRACE (EvAttachRegion); + + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Adding Region [%4.4s] %p to address handler %p [%s]\n", + AcpiUtGetNodeName (RegionObj->Region.Node), + RegionObj, HandlerObj, + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + /* Link this region to the front of the handler's list */ + + RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList; + HandlerObj->AddressSpace.RegionList = RegionObj; + + /* Install the region's handler */ + + if (RegionObj->Region.Handler) + { + return_ACPI_STATUS (AE_ALREADY_EXISTS); + } + + RegionObj->Region.Handler = HandlerObj; + AcpiUtAddReference (HandlerObj); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallHandler + * + * PARAMETERS: WalkNamespace callback + * + * DESCRIPTION: This routine installs an address handler into objects that are + * of type Region or Device. + * + * If the Object is a Device, and the device has a handler of + * the same type then the search is terminated in that branch. + * + * This is because the existing handler is closer in proximity + * to any more regions than the one we are trying to install. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvInstallHandler ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *NextHandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (EvInstallHandler); + + + HandlerObj = (ACPI_OPERAND_OBJECT *) Context; + + /* Parameter validation */ + + if (!HandlerObj) + { + return (AE_OK); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* + * We only care about regions and objects that are allowed to have + * address space handlers + */ + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_REGION) && + (Node != AcpiGbl_RootNode)) + { + return (AE_OK); + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, just exit */ + + return (AE_OK); + } + + /* Devices are handled different than regions */ + + if (ObjDesc->Common.Type == ACPI_TYPE_DEVICE) + { + /* Check if this Device already has a handler for this address space */ + + NextHandlerObj = ObjDesc->Device.Handler; + while (NextHandlerObj) + { + /* Found a handler, is it for the same address space? */ + + if (NextHandlerObj->AddressSpace.SpaceId == + HandlerObj->AddressSpace.SpaceId) + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Found handler for region [%s] in device %p(%p) " + "handler %p\n", + AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId), + ObjDesc, NextHandlerObj, HandlerObj)); + + /* + * Since the object we found it on was a device, then it + * means that someone has already installed a handler for + * the branch of the namespace from this device on. Just + * bail out telling the walk routine to not traverse this + * branch. This preserves the scoping rule for handlers. + */ + return (AE_CTRL_DEPTH); + } + + /* Walk the linked list of handlers attached to this device */ + + NextHandlerObj = NextHandlerObj->AddressSpace.Next; + } + + /* + * As long as the device didn't have a handler for this space we + * don't care about it. We just ignore it and proceed. + */ + return (AE_OK); + } + + /* Object is a Region */ + + if (ObjDesc->Region.SpaceId != HandlerObj->AddressSpace.SpaceId) + { + /* This region is for a different address space, just ignore it */ + + return (AE_OK); + } + + /* + * Now we have a region and it is for the handler's address space type. + * + * First disconnect region for any previous handler (if any) + */ + AcpiEvDetachRegion (ObjDesc, FALSE); + + /* Connect the region to the new handler */ + + Status = AcpiEvAttachRegion (HandlerObj, ObjDesc, FALSE); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallSpaceHandler + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE Type; + UINT8 Flags = 0; + + + ACPI_FUNCTION_TRACE (EvInstallSpaceHandler); + + + /* + * This registration is valid for only the types below and the root. This + * is where the default handlers get placed. + */ + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if (Handler == ACPI_DEFAULT_HANDLER) + { + Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; + + switch (SpaceId) + { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + Handler = AcpiExSystemMemorySpaceHandler; + Setup = AcpiEvSystemMemoryRegionSetup; + break; + + case ACPI_ADR_SPACE_SYSTEM_IO: + Handler = AcpiExSystemIoSpaceHandler; + Setup = AcpiEvIoSpaceRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_CONFIG: + Handler = AcpiExPciConfigSpaceHandler; + Setup = AcpiEvPciConfigRegionSetup; + break; + + case ACPI_ADR_SPACE_CMOS: + Handler = AcpiExCmosSpaceHandler; + Setup = AcpiEvCmosRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_BAR_TARGET: + Handler = AcpiExPciBarSpaceHandler; + Setup = AcpiEvPciBarRegionSetup; + break; + + case ACPI_ADR_SPACE_DATA_TABLE: + Handler = AcpiExDataTableSpaceHandler; + Setup = NULL; + break; + + default: + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* If the caller hasn't specified a setup routine, use the default */ + + if (!Setup) + { + Setup = AcpiEvDefaultRegionSetup; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* + * The attached device object already exists. Make sure the handler + * is not already installed. + */ + HandlerObj = ObjDesc->Device.Handler; + + /* Walk the handler list for this device */ + + while (HandlerObj) + { + /* Same SpaceId indicates a handler already installed */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + if (HandlerObj->AddressSpace.Handler == Handler) + { + /* + * It is (relatively) OK to attempt to install the SAME + * handler twice. This can easily happen with the + * PCI_Config space. + */ + Status = AE_SAME_HANDLER; + goto UnlockAndExit; + } + else + { + /* A handler is already installed */ + + Status = AE_ALREADY_EXISTS; + } + goto UnlockAndExit; + } + + /* Walk the linked list of handlers */ + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Creating object on Device %p while installing handler\n", Node)); + + /* ObjDesc does not exist, create one */ + + if (Node->Type == ACPI_TYPE_ANY) + { + Type = ACPI_TYPE_DEVICE; + } + else + { + Type = Node->Type; + } + + ObjDesc = AcpiUtCreateInternalObject (Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init new descriptor */ + + ObjDesc->Common.Type = (UINT8) Type; + + /* Attach the new object to the Node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", + AcpiUtGetRegionName (SpaceId), SpaceId, + AcpiUtGetNodeName (Node), Node, ObjDesc)); + + /* + * Install the handler + * + * At this point there is no existing handler. Just allocate the object + * for the handler and link it into the list. + */ + HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); + if (!HandlerObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init handler obj */ + + HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId; + HandlerObj->AddressSpace.HandlerFlags = Flags; + HandlerObj->AddressSpace.RegionList = NULL; + HandlerObj->AddressSpace.Node = Node; + HandlerObj->AddressSpace.Handler = Handler; + HandlerObj->AddressSpace.Context = Context; + HandlerObj->AddressSpace.Setup = Setup; + + /* Install at head of Device.AddressSpace list */ + + HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; + + /* + * The Device object is the first reference on the HandlerObj. + * Each region that uses the handler adds a reference. + */ + ObjDesc->Device.Handler = HandlerObj; + + /* + * Walk the namespace finding all of the regions this + * handler will manage. + * + * Start at the device and search the branch toward + * the leaf nodes until either the leaf is encountered or + * a device is detected that has an address handler of the + * same type. + * + * In either case, back up and search down the remainder + * of the branch + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, NULL, + HandlerObj, NULL); + +UnlockAndExit: + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvExecuteRegMethods + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * + * RETURN: Status + * + * DESCRIPTION: Run all _REG methods for the input Space ID; + * Note: assumes namespace is locked, or system init time. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvExecuteRegMethods); + + + /* + * Run all _REG methods for all Operation Regions for this space ID. This + * is a separate walk in order to handle any interdependencies between + * regions and _REG methods. (i.e. handlers must be installed for all + * regions of this Space ID before we can run any _REG methods) + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL, + &SpaceId, NULL); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvRegRun + * + * PARAMETERS: WalkNamespace callback + * + * DESCRIPTION: Run _REG method for region objects of the requested spaceID + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvRegRun ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_ADR_SPACE_TYPE SpaceId; + ACPI_STATUS Status; + + + SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context); + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* + * We only care about regions.and objects that are allowed to have address + * space handlers + */ + if ((Node->Type != ACPI_TYPE_REGION) && + (Node != AcpiGbl_RootNode)) + { + return (AE_OK); + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, just exit */ + + return (AE_OK); + } + + /* Object is a Region */ + + if (ObjDesc->Region.SpaceId != SpaceId) + { + /* This region is for a different address space, just ignore it */ + + return (AE_OK); + } + + Status = AcpiEvExecuteRegMethod (ObjDesc, 1); + return (Status); +} + diff --git a/drivers/bus/acpi/acpica/events/evrgnini.c b/drivers/bus/acpi/acpica/events/evrgnini.c new file mode 100644 index 00000000000..67f6cddf66d --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evrgnini.c @@ -0,0 +1,799 @@ +/****************************************************************************** + * + * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVRGNINI_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evrgnini") + +/* Local prototypes */ + +static BOOLEAN +AcpiEvIsPciRootBridge ( + ACPI_NAMESPACE_NODE *Node); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSystemMemoryRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a SystemMemory operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_OPERAND_OBJECT *RegionDesc = (ACPI_OPERAND_OBJECT *) Handle; + ACPI_MEM_SPACE_CONTEXT *LocalRegionContext; + + + ACPI_FUNCTION_TRACE (EvSystemMemoryRegionSetup); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + if (*RegionContext) + { + LocalRegionContext = (ACPI_MEM_SPACE_CONTEXT *) *RegionContext; + + /* Delete a cached mapping if present */ + + if (LocalRegionContext->MappedLength) + { + AcpiOsUnmapMemory (LocalRegionContext->MappedLogicalAddress, + LocalRegionContext->MappedLength); + } + ACPI_FREE (LocalRegionContext); + *RegionContext = NULL; + } + return_ACPI_STATUS (AE_OK); + } + + /* Create a new context */ + + LocalRegionContext = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_MEM_SPACE_CONTEXT)); + if (!(LocalRegionContext)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save the region length and address for use in the handler */ + + LocalRegionContext->Length = RegionDesc->Region.Length; + LocalRegionContext->Address = RegionDesc->Region.Address; + + *RegionContext = LocalRegionContext; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIoSpaceRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a IO operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvIoSpaceRegionSetup); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + *RegionContext = NULL; + } + else + { + *RegionContext = HandlerContext; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvPciConfigRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a PCI_Config operation region + * + * MUTEX: Assumes namespace is not locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER PciValue; + ACPI_PCI_ID *PciId = *RegionContext; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *PciRootNode; + ACPI_NAMESPACE_NODE *PciDeviceNode; + ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; + + + ACPI_FUNCTION_TRACE (EvPciConfigRegionSetup); + + + HandlerObj = RegionObj->Region.Handler; + if (!HandlerObj) + { + /* + * No installed handler. This shouldn't happen because the dispatch + * routine checks before we get here, but we check again just in case. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Attempting to init a region %p, with no handler\n", RegionObj)); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + *RegionContext = NULL; + if (Function == ACPI_REGION_DEACTIVATE) + { + if (PciId) + { + ACPI_FREE (PciId); + } + return_ACPI_STATUS (Status); + } + + ParentNode = AcpiNsGetParentNode (RegionObj->Region.Node); + + /* + * Get the _SEG and _BBN values from the device upon which the handler + * is installed. + * + * We need to get the _SEG and _BBN objects relative to the PCI BUS device. + * This is the device the handler has been registered to handle. + */ + + /* + * If the AddressSpace.Node is still pointing to the root, we need + * to scan upward for a PCI Root bridge and re-associate the OpRegion + * handlers with that device. + */ + if (HandlerObj->AddressSpace.Node == AcpiGbl_RootNode) + { + /* Start search from the parent object */ + + PciRootNode = ParentNode; + while (PciRootNode != AcpiGbl_RootNode) + { + /* Get the _HID/_CID in order to detect a RootBridge */ + + if (AcpiEvIsPciRootBridge (PciRootNode)) + { + /* Install a handler for this PCI root bridge */ + + Status = AcpiInstallAddressSpaceHandler ( + (ACPI_HANDLE) PciRootNode, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_SAME_HANDLER) + { + /* + * It is OK if the handler is already installed on the + * root bridge. Still need to return a context object + * for the new PCI_Config operation region, however. + */ + Status = AE_OK; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not install PciConfig handler " + "for Root Bridge %4.4s", + AcpiUtGetNodeName (PciRootNode))); + } + } + break; + } + + PciRootNode = AcpiNsGetParentNode (PciRootNode); + } + + /* PCI root bridge not found, use namespace root node */ + } + else + { + PciRootNode = HandlerObj->AddressSpace.Node; + } + + /* + * If this region is now initialized, we are done. + * (InstallAddressSpaceHandler could have initialized it) + */ + if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) + { + return_ACPI_STATUS (AE_OK); + } + + /* Region is still not initialized. Create a new context */ + + PciId = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PCI_ID)); + if (!PciId) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * For PCI_Config space access, we need the segment, bus, device and + * function numbers. Acquire them here. + * + * Find the parent device object. (This allows the operation region to be + * within a subscope under the device, such as a control method.) + */ + PciDeviceNode = RegionObj->Region.Node; + while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE)) + { + PciDeviceNode = AcpiNsGetParentNode (PciDeviceNode); + } + + if (!PciDeviceNode) + { + ACPI_FREE (PciId); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * Get the PCI device and function numbers from the _ADR object contained + * in the parent's scope. + */ + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, + PciDeviceNode, &PciValue); + + /* + * The default is zero, and since the allocation above zeroed the data, + * just do nothing on failure. + */ + if (ACPI_SUCCESS (Status)) + { + PciId->Device = ACPI_HIWORD (ACPI_LODWORD (PciValue)); + PciId->Function = ACPI_LOWORD (ACPI_LODWORD (PciValue)); + } + + /* The PCI segment number comes from the _SEG method */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, + PciRootNode, &PciValue); + if (ACPI_SUCCESS (Status)) + { + PciId->Segment = ACPI_LOWORD (PciValue); + } + + /* The PCI bus number comes from the _BBN method */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, + PciRootNode, &PciValue); + if (ACPI_SUCCESS (Status)) + { + PciId->Bus = ACPI_LOWORD (PciValue); + } + + /* Complete this device's PciId */ + + AcpiOsDerivePciId (PciRootNode, RegionObj->Region.Node, &PciId); + + *RegionContext = PciId; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIsPciRootBridge + * + * PARAMETERS: Node - Device node being examined + * + * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input device represents a PCI Root Bridge by + * examining the _HID and _CID for the device. + * + ******************************************************************************/ + +static BOOLEAN +AcpiEvIsPciRootBridge ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; + UINT32 i; + BOOLEAN Match; + + + /* Get the _HID and check for a PCI Root Bridge */ + + Status = AcpiUtExecute_HID (Node, &Hid); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + + Match = AcpiUtIsPciRootBridge (Hid->String); + ACPI_FREE (Hid); + + if (Match) + { + return (TRUE); + } + + /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */ + + Status = AcpiUtExecute_CID (Node, &Cid); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + + /* Check all _CIDs in the returned list */ + + for (i = 0; i < Cid->Count; i++) + { + if (AcpiUtIsPciRootBridge (Cid->Ids[i].String)) + { + ACPI_FREE (Cid); + return (TRUE); + } + } + + ACPI_FREE (Cid); + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvPciBarRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a PciBAR operation region + * + * MUTEX: Assumes namespace is not locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvPciBarRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvPciBarRegionSetup); + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvCmosRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a CMOS operation region + * + * MUTEX: Assumes namespace is not locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvCmosRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvCmosRegionSetup); + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDefaultRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Default region initialization + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvDefaultRegionSetup); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + *RegionContext = NULL; + } + else + { + *RegionContext = HandlerContext; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeRegion + * + * PARAMETERS: RegionObj - Region we are initializing + * AcpiNsLocked - Is namespace locked? + * + * RETURN: Status + * + * DESCRIPTION: Initializes the region, finds any _REG methods and saves them + * for execution at a later time + * + * Get the appropriate address space handler for a newly + * created region. + * + * This also performs address space specific initialization. For + * example, PCI regions must have an _ADR object that contains + * a PCI address in the scope of the definition. This address is + * required to perform an access to PCI config space. + * + * MUTEX: Interpreter should be unlocked, because we may run the _REG + * method for this region. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_ADR_SPACE_TYPE SpaceId; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; + ACPI_OPERAND_OBJECT *RegionObj2; + + + ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); + + + if (!RegionObj) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (RegionObj->Common.Flags & AOPOBJ_OBJECT_INITIALIZED) + { + return_ACPI_STATUS (AE_OK); + } + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + Node = AcpiNsGetParentNode (RegionObj->Region.Node); + SpaceId = RegionObj->Region.SpaceId; + + /* Setup defaults */ + + RegionObj->Region.Handler = NULL; + RegionObj2->Extra.Method_REG = NULL; + RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE); + RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; + + /* Find any "_REG" method associated with this region definition */ + + Status = AcpiNsSearchOneScope ( + *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); + if (ACPI_SUCCESS (Status)) + { + /* + * The _REG method is optional and there can be only one per region + * definition. This will be executed when the handler is attached + * or removed + */ + RegionObj2->Extra.Method_REG = MethodNode; + } + + /* + * The following loop depends upon the root Node having no parent + * ie: AcpiGbl_RootNode->ParentEntry being set to NULL + */ + while (Node) + { + /* Check to see if a handler exists */ + + HandlerObj = NULL; + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* Can only be a handler if the object exists */ + + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + + HandlerObj = ObjDesc->Device.Handler; + break; + + case ACPI_TYPE_PROCESSOR: + + HandlerObj = ObjDesc->Processor.Handler; + break; + + case ACPI_TYPE_THERMAL: + + HandlerObj = ObjDesc->ThermalZone.Handler; + break; + + case ACPI_TYPE_METHOD: + /* + * If we are executing module level code, the original + * Node's object was replaced by this Method object and we + * saved the handler in the method object. + * + * See AcpiNsExecModuleCode + */ + if (ObjDesc->Method.Flags & AOPOBJ_MODULE_LEVEL) + { + HandlerObj = ObjDesc->Method.Extra.Handler; + } + break; + + default: + /* Ignore other objects */ + break; + } + + while (HandlerObj) + { + /* Is this handler of the correct type? */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + /* Found correct handler */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Found handler %p for region %p in obj %p\n", + HandlerObj, RegionObj, ObjDesc)); + + Status = AcpiEvAttachRegion (HandlerObj, RegionObj, + AcpiNsLocked); + + /* + * Tell all users that this region is usable by + * running the _REG method + */ + if (AcpiNsLocked) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + Status = AcpiEvExecuteRegMethod (RegionObj, 1); + + if (AcpiNsLocked) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (AE_OK); + } + + /* Try next handler in the list */ + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + + /* This node does not have the handler we need; Pop up one level */ + + Node = AcpiNsGetParentNode (Node); + } + + /* If we get here, there is no handler for this region */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "No handler for RegionType %s(%X) (RegionObj %p)\n", + AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj)); + + return_ACPI_STATUS (AE_NOT_EXIST); +} + diff --git a/drivers/bus/acpi/acpica/events/evsci.c b/drivers/bus/acpi/acpica/events/evsci.c new file mode 100644 index 00000000000..cde433ce3ee --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evsci.c @@ -0,0 +1,280 @@ +/******************************************************************************* + * + * Module Name: evsci - System Control Interrupt configuration and + * legacy to ACPI mode state transition functions + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" + + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evsci") + +/* Local prototypes */ + +static UINT32 ACPI_SYSTEM_XFACE +AcpiEvSciXruptHandler ( + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSciXruptHandler + * + * PARAMETERS: Context - Calling Context + * + * RETURN: Status code indicates whether interrupt was handled. + * + * DESCRIPTION: Interrupt handler that will figure out what function or + * control method to call to deal with a SCI. + * + ******************************************************************************/ + +static UINT32 ACPI_SYSTEM_XFACE +AcpiEvSciXruptHandler ( + void *Context) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptList = Context; + UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; + + + ACPI_FUNCTION_TRACE (EvSciXruptHandler); + + + /* + * We are guaranteed by the ACPI CA initialization/shutdown code that + * if this interrupt handler is installed, ACPI is enabled. + */ + + /* + * Fixed Events: + * Check for and dispatch any Fixed Events that have occurred + */ + InterruptHandled |= AcpiEvFixedEventDetect (); + + /* + * General Purpose Events: + * Check for and dispatch any GPEs that have occurred + */ + InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); + + AcpiSciCount++; + return_UINT32 (InterruptHandled); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeXruptHandler + * + * PARAMETERS: Context - Calling Context + * + * RETURN: Status code indicates whether interrupt was handled. + * + * DESCRIPTION: Handler for GPE Block Device interrupts + * + ******************************************************************************/ + +UINT32 ACPI_SYSTEM_XFACE +AcpiEvGpeXruptHandler ( + void *Context) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptList = Context; + UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; + + + ACPI_FUNCTION_TRACE (EvGpeXruptHandler); + + + /* + * We are guaranteed by the ACPI CA initialization/shutdown code that + * if this interrupt handler is installed, ACPI is enabled. + */ + + /* GPEs: Check for and dispatch any GPEs that have occurred */ + + InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); + + return_UINT32 (InterruptHandled); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvInstallSciHandler + * + * PARAMETERS: none + * + * RETURN: Status + * + * DESCRIPTION: Installs SCI handler. + * + ******************************************************************************/ + +UINT32 +AcpiEvInstallSciHandler ( + void) +{ + UINT32 Status = AE_OK; + + + ACPI_FUNCTION_TRACE (EvInstallSciHandler); + + + Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, + AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvRemoveSciHandler + * + * PARAMETERS: none + * + * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not + * installed to begin with + * + * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be + * taken. + * + * Note: It doesn't seem important to disable all events or set the event + * enable registers to their original values. The OS should disable + * the SCI interrupt level when the handler is removed, so no more + * events will come in. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvRemoveSciHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvRemoveSciHandler); + + + /* Just let the OS remove the handler and disable the level */ + + Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, + AcpiEvSciXruptHandler); + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/events/evxface.c b/drivers/bus/acpi/acpica/events/evxface.c new file mode 100644 index 00000000000..6eb5a14af06 --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evxface.c @@ -0,0 +1,967 @@ +/****************************************************************************** + * + * Module Name: evxface - External interfaces for ACPI events + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acevents.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallExceptionHandler + * + * PARAMETERS: Handler - Pointer to the handler function for the + * event + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallExceptionHandler ( + ACPI_EXCEPTION_HANDLER Handler) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallExceptionHandler); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow two handlers. */ + + if (AcpiGbl_ExceptionHandler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_ExceptionHandler = Handler; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallExceptionHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallFixedEventHandler + * + * PARAMETERS: Event - Event type to enable. + * Handler - Pointer to the handler function for the + * event + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function and then enables the + * event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 Event, + ACPI_EVENT_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallFixedEventHandler); + + + /* Parameter validation */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow two handlers. */ + + if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler before enabling the event */ + + AcpiGbl_FixedEventHandlers[Event].Handler = Handler; + AcpiGbl_FixedEventHandlers[Event].Context = Context; + + Status = AcpiEnableEvent (Event, 0); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Could not enable fixed event %X", Event)); + + /* Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Enabled fixed event %X, Handler=%p\n", Event, Handler)); + } + + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallFixedEventHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveFixedEventHandler + * + * PARAMETERS: Event - Event type to disable. + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Disables the event and unregisters the event handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 Event, + ACPI_EVENT_HANDLER Handler) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiRemoveFixedEventHandler); + + + /* Parameter validation */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Disable the event before removing the handler */ + + Status = AcpiDisableEvent (Event, 0); + + /* Always Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, + "Could not write to fixed event enable register %X", Event)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X\n", Event)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveFixedEventHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device + * Handler - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallNotifyHandler); + + + /* Parameter validation */ + + if ((!Device) || + (!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * Root Object: + * Registering a notify handler on the root object indicates that the + * caller wishes to receive notifications for all objects. Note that + * only one global handler can be regsitered (per notify type). + */ + if (Device == ACPI_ROOT_OBJECT) + { + /* Make sure the handler is not already installed */ + + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && + AcpiGbl_DeviceNotify.Handler)) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + AcpiGbl_SystemNotify.Node = Node; + AcpiGbl_SystemNotify.Handler = Handler; + AcpiGbl_SystemNotify.Context = Context; + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + AcpiGbl_DeviceNotify.Node = Node; + AcpiGbl_DeviceNotify.Handler = Handler; + AcpiGbl_DeviceNotify.Context = Context; + } + + /* Global notify handler installed */ + } + + /* + * All Other Objects: + * Caller will only receive notifications specific to the target object. + * Note that only certain object types can receive notifications. + */ + else + { + /* Notifies allowed on this object? */ + + if (!AcpiEvIsNotifyObject (Node)) + { + Status = AE_TYPE; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* Object exists - make sure there's no handler */ + + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + ObjDesc->CommonNotify.SystemNotify) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && + ObjDesc->CommonNotify.DeviceNotify)) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + } + else + { + /* Create a new object */ + + ObjDesc = AcpiUtCreateInternalObject (Node->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Attach new object to the Node */ + + Status = AcpiNsAttachObject (Device, ObjDesc, Node->Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + /* Install the handler */ + + NotifyObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_NOTIFY); + if (!NotifyObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + NotifyObj->Notify.Node = Node; + NotifyObj->Notify.Handler = Handler; + NotifyObj->Notify.Context = Context; + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + ObjDesc->CommonNotify.SystemNotify = NotifyObj; + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + ObjDesc->CommonNotify.DeviceNotify = NotifyObj; + } + + if (HandlerType == ACPI_ALL_NOTIFY) + { + /* Extra ref if installed in both */ + + AcpiUtAddReference (NotifyObj); + } + } + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallNotifyHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiRemoveNotifyHandler); + + + /* Parameter validation */ + + if ((!Device) || + (!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Root Object */ + + if (Device == ACPI_ROOT_OBJECT) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Removing notify handler for namespace root object\n")); + + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + !AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && + !AcpiGbl_DeviceNotify.Handler)) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + AcpiGbl_SystemNotify.Node = NULL; + AcpiGbl_SystemNotify.Handler = NULL; + AcpiGbl_SystemNotify.Context = NULL; + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + AcpiGbl_DeviceNotify.Node = NULL; + AcpiGbl_DeviceNotify.Handler = NULL; + AcpiGbl_DeviceNotify.Context = NULL; + } + } + + /* All Other Objects */ + + else + { + /* Notifies allowed on this object? */ + + if (!AcpiEvIsNotifyObject (Node)) + { + Status = AE_TYPE; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* Object exists - make sure there's an existing handler */ + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + NotifyObj = ObjDesc->CommonNotify.SystemNotify; + if (!NotifyObj) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (NotifyObj->Notify.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Remove the handler */ + + ObjDesc->CommonNotify.SystemNotify = NULL; + AcpiUtRemoveReference (NotifyObj); + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + NotifyObj = ObjDesc->CommonNotify.DeviceNotify; + if (!NotifyObj) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (NotifyObj->Notify.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Remove the handler */ + + ObjDesc->CommonNotify.DeviceNotify = NULL; + AcpiUtRemoveReference (NotifyObj); + } + } + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveNotifyHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallGpeHandler + * + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The GPE number within the GPE block + * Type - Whether this GPE should be treated as an + * edge- or level-triggered interrupt. + * Address - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for a General Purpose Event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Type, + ACPI_EVENT_HANDLER Address, + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiInstallGpeHandler); + + + /* Parameter validation */ + + if ((!Address) || (Type > ACPI_GPE_XRUPT_TYPE_MASK)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Make sure that there isn't a handler there already */ + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + + /* Allocate and init handler object */ + + Handler = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_HANDLER_INFO)); + if (!Handler) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + Handler->Address = Address; + Handler->Context = Context; + Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode; + + /* Disable the GPE before installing the handler */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Install the handler */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + GpeEventInfo->Dispatch.Handler = Handler; + + /* Setup up dispatch flags to indicate handler (vs. method) */ + + GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); + GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER); + + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallGpeHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveGpeHandler + * + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The event to remove a handler + * Address - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + ACPI_EVENT_HANDLER Address) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiRemoveGpeHandler); + + + /* Parameter validation */ + + if (!Address) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Make sure that a handler is indeed installed */ + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != + ACPI_GPE_DISPATCH_HANDLER) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* Make sure that the installed handler is the same */ + + if (GpeEventInfo->Dispatch.Handler->Address != Address) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Disable the GPE before removing the handler */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Remove the handler */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + Handler = GpeEventInfo->Dispatch.Handler; + + /* Restore Method node (if any), set dispatch flags */ + + GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ + if (Handler->MethodNode) + { + GpeEventInfo->Flags |= ACPI_GPE_DISPATCH_METHOD; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Now we can free the handler object */ + + ACPI_FREE (Handler); + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveGpeHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiAcquireGlobalLock + * + * PARAMETERS: Timeout - How long the caller is willing to wait + * Handle - Where the handle to the lock is returned + * (if acquired) + * + * RETURN: Status + * + * DESCRIPTION: Acquire the ACPI Global Lock + * + * Note: Allows callers with the same thread ID to acquire the global lock + * multiple times. In other words, externally, the behavior of the global lock + * is identical to an AML mutex. On the first acquire, a new handle is + * returned. On any subsequent calls to acquire by the same thread, the same + * handle is returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAcquireGlobalLock ( + UINT16 Timeout, + UINT32 *Handle) +{ + ACPI_STATUS Status; + + + if (!Handle) + { + return (AE_BAD_PARAMETER); + } + + /* Must lock interpreter to prevent race conditions */ + + AcpiExEnterInterpreter (); + + Status = AcpiExAcquireMutexObject (Timeout, + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + + if (ACPI_SUCCESS (Status)) + { + /* Return the global lock handle (updated in AcpiEvAcquireGlobalLock) */ + + *Handle = AcpiGbl_GlobalLockHandle; + } + + AcpiExExitInterpreter (); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiAcquireGlobalLock) + + +/******************************************************************************* + * + * FUNCTION: AcpiReleaseGlobalLock + * + * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock + * + * RETURN: Status + * + * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReleaseGlobalLock ( + UINT32 Handle) +{ + ACPI_STATUS Status; + + + if (!Handle || (Handle != AcpiGbl_GlobalLockHandle)) + { + return (AE_NOT_ACQUIRED); + } + + Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiReleaseGlobalLock) + diff --git a/drivers/bus/acpi/acpica/events/evxfevnt.c b/drivers/bus/acpi/acpica/events/evxfevnt.c new file mode 100644 index 00000000000..27066a39946 --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evxfevnt.c @@ -0,0 +1,1112 @@ +/****************************************************************************** + * + * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVXFEVNT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evxfevnt") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvGetGpeDevice ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiEnable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Transfers the system into ACPI mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnable ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiEnable); + + + /* ACPI tables must be present */ + + if (!AcpiTbTablesLoaded ()) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* Check current mode */ + + if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); + } + else + { + /* Transition to ACPI mode */ + + Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode")); + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Transition to ACPI mode successful\n")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnable) + + +/******************************************************************************* + * + * FUNCTION: AcpiDisable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisable ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiDisable); + + + if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "System is already in legacy (non-ACPI) mode\n")); + } + else + { + /* Transition to LEGACY mode */ + + Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY); + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not exit ACPI mode to legacy mode")); + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDisable) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableEvent + * + * PARAMETERS: Event - The fixed eventto be enabled + * Flags - Reserved + * + * RETURN: Status + * + * DESCRIPTION: Enable an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 Event, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value; + + + ACPI_FUNCTION_TRACE (AcpiEnableEvent); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Enable the requested fixed event (by writing a one to the enable + * register bit) + */ + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_ENABLE_EVENT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Make sure that the hardware responded */ + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Value != 1) + { + ACPI_ERROR ((AE_INFO, + "Could not enable %s event", AcpiUtGetEventName (Event))); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnableEvent) + + +/******************************************************************************* + * + * FUNCTION: AcpiSetGpeType + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Type - New GPE type + * + * RETURN: Status + * + * DESCRIPTION: Set the type of an individual GPE + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetGpeType ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT8 Type) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiSetGpeType); + + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type) + { + return_ACPI_STATUS (AE_OK); + } + + /* Set the new type (will disable GPE if currently enabled) */ + + Status = AcpiEvSetGpeType (GpeEventInfo, Type); + +UnlockAndExit: + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiSetGpeType) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableGpe + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Just enable, or also wake enable? + * Called from ISR or not + * + * RETURN: Status + * + * DESCRIPTION: Enable an ACPI event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiEnableGpe); + + + /* Use semaphore lock if not executing at interrupt level */ + + if (Flags & ACPI_NOT_ISR) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Perform the enable */ + + Status = AcpiEvEnableGpe (GpeEventInfo, TRUE); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + } + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnableGpe) + + +/******************************************************************************* + * + * FUNCTION: AcpiDisableGpe + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Just disable, or also wake disable? + * Called from ISR or not + * + * RETURN: Status + * + * DESCRIPTION: Disable an ACPI event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiDisableGpe); + + + /* Use semaphore lock if not executing at interrupt level */ + + if (Flags & ACPI_NOT_ISR) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiEvDisableGpe (GpeEventInfo); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + } + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDisableGpe) + + +/******************************************************************************* + * + * FUNCTION: AcpiDisableEvent + * + * PARAMETERS: Event - The fixed eventto be enabled + * Flags - Reserved + * + * RETURN: Status + * + * DESCRIPTION: Disable an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 Event, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value; + + + ACPI_FUNCTION_TRACE (AcpiDisableEvent); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Disable the requested fixed event (by writing a zero to the enable + * register bit) + */ + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Value != 0) + { + ACPI_ERROR ((AE_INFO, + "Could not disable %s events", AcpiUtGetEventName (Event))); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDisableEvent) + + +/******************************************************************************* + * + * FUNCTION: AcpiClearEvent + * + * PARAMETERS: Event - The fixed event to be cleared + * + * RETURN: Status + * + * DESCRIPTION: Clear an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiClearEvent ( + UINT32 Event) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiClearEvent); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Clear the requested fixed event (By writing a one to the status + * register bit) + */ + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiClearEvent) + + +/******************************************************************************* + * + * FUNCTION: AcpiClearGpe + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Called from an ISR or not + * + * RETURN: Status + * + * DESCRIPTION: Clear an ACPI event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiClearGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiClearGpe); + + + /* Use semaphore lock if not executing at interrupt level */ + + if (Flags & ACPI_NOT_ISR) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiHwClearGpe (GpeEventInfo); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + } + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiClearGpe) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetEventStatus + * + * PARAMETERS: Event - The fixed event + * EventStatus - Where the current status of the event will + * be returned + * + * RETURN: Status + * + * DESCRIPTION: Obtains and returns the current status of the event + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 Event, + ACPI_EVENT_STATUS *EventStatus) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiGetEventStatus); + + + if (!EventStatus) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the status of the requested fixed event */ + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetEventStatus) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetGpeStatus + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Called from an ISR or not + * EventStatus - Where the current status of the event will + * be returned + * + * RETURN: Status + * + * DESCRIPTION: Get status of an event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetGpeStatus ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags, + ACPI_EVENT_STATUS *EventStatus) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE (AcpiGetGpeStatus); + + + /* Use semaphore lock if not executing at interrupt level */ + + if (Flags & ACPI_NOT_ISR) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Obtain status on the requested GPE number */ + + Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + } + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device + * GpeBlockAddress - Address and SpaceID + * RegisterCount - Number of GPE register pairs in the block + * InterruptNumber - H/W interrupt for the block + * + * RETURN: Status + * + * DESCRIPTION: Create and Install a block of GPE registers + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallGpeBlock ( + ACPI_HANDLE GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT32 InterruptNumber) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_GPE_BLOCK_INFO *GpeBlock; + + + ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock); + + + if ((!GpeDevice) || + (!GpeBlockAddress) || + (!RegisterCount)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (GpeDevice); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * For user-installed GPE Block Devices, the GpeBlockBaseNumber + * is always zero + */ + Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount, + 0, InterruptNumber, &GpeBlock); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Run the _PRW methods and enable the GPEs */ + + Status = AcpiEvInitializeGpeBlock (Node, GpeBlock); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Get the DeviceObject attached to the node */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, create a new one */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + /* Install the GPE block in the DeviceObject */ + + ObjDesc->Device.GpeBlock = GpeBlock; + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device + * + * RETURN: Status + * + * DESCRIPTION: Remove a previously installed block of GPE registers + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveGpeBlock ( + ACPI_HANDLE GpeDevice) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock); + + + if (!GpeDevice) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (GpeDevice); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Get the DeviceObject attached to the node */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc || + !ObjDesc->Device.GpeBlock) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Delete the GPE block (but not the DeviceObject) */ + + Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock); + if (ACPI_SUCCESS (Status)) + { + ObjDesc->Device.GpeBlock = NULL; + } + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetGpeDevice + * + * PARAMETERS: Index - System GPE index (0-CurrentGpeCount) + * GpeDevice - Where the parent GPE Device is returned + * + * RETURN: Status + * + * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL + * gpe device indicates that the gpe number is contained in one of + * the FADT-defined gpe blocks. Otherwise, the GPE block device. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetGpeDevice ( + UINT32 Index, + ACPI_HANDLE *GpeDevice) +{ + ACPI_GPE_DEVICE_INFO Info; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetGpeDevice); + + + if (!GpeDevice) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (Index >= AcpiCurrentGpeCount) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Setup and walk the GPE list */ + + Info.Index = Index; + Info.Status = AE_NOT_EXIST; + Info.GpeDevice = NULL; + Info.NextBlockBaseIndex = 0; + + Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice); + return_ACPI_STATUS (Info.Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice) + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeDevice + * + * PARAMETERS: GPE_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE + * block device. NULL if the GPE is one of the FADT-defined GPEs. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvGetGpeDevice ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + ACPI_GPE_DEVICE_INFO *Info = Context; + + + /* Increment Index by the number of GPEs in this block */ + + Info->NextBlockBaseIndex += + (GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH); + + if (Info->Index < Info->NextBlockBaseIndex) + { + /* + * The GPE index is within this block, get the node. Leave the node + * NULL for the FADT-defined GPEs + */ + if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE) + { + Info->GpeDevice = GpeBlock->Node; + } + + Info->Status = AE_OK; + return (AE_CTRL_END); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiDisableAllGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Disable and clear all GPEs in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableAllGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiDisableAllGpes); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwDisableAllGpes (); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEnableAllRuntimeGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableAllRuntimeGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwEnableAllRuntimeGpes (); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/events/evxfregn.c b/drivers/bus/acpi/acpica/events/evxfregn.c new file mode 100644 index 00000000000..3b60589b71a --- /dev/null +++ b/drivers/bus/acpi/acpica/events/evxfregn.c @@ -0,0 +1,346 @@ +/****************************************************************************** + * + * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and + * Address Spaces. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EVXFREGN_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acevents.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evxfregn") + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallAddressSpaceHandler + * + * PARAMETERS: Device - Handle for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallAddressSpaceHandler); + + + /* Parameter validation */ + + if (!Device) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Install the handler for all Regions for this Space ID */ + + Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Run all _REG methods for this address space */ + + Status = AcpiEvExecuteRegMethods (Node, SpaceId); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallAddressSpaceHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveAddressSpaceHandler + * + * PARAMETERS: Device - Handle for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a previously installed handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *RegionObj; + ACPI_OPERAND_OBJECT **LastObjPtr; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiRemoveAddressSpaceHandler); + + + /* Parameter validation */ + + if (!Device) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node || + ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode))) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Make sure the internal object exists */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* Find the address handler the user requested */ + + HandlerObj = ObjDesc->Device.Handler; + LastObjPtr = &ObjDesc->Device.Handler; + while (HandlerObj) + { + /* We have a handler, see if user requested this one */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + /* Handler must be the same as the installed handler */ + + if (HandlerObj->AddressSpace.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Matched SpaceId, first dereference this in the Regions */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Removing address handler %p(%p) for region %s " + "on Device %p(%p)\n", + HandlerObj, Handler, AcpiUtGetRegionName (SpaceId), + Node, ObjDesc)); + + RegionObj = HandlerObj->AddressSpace.RegionList; + + /* Walk the handler's region list */ + + while (RegionObj) + { + /* + * First disassociate the handler from the region. + * + * NOTE: this doesn't mean that the region goes away + * The region is just inaccessible as indicated to + * the _REG method + */ + AcpiEvDetachRegion (RegionObj, TRUE); + + /* + * Walk the list: Just grab the head because the + * DetachRegion removed the previous head. + */ + RegionObj = HandlerObj->AddressSpace.RegionList; + + } + + /* Remove this Handler object from the list */ + + *LastObjPtr = HandlerObj->AddressSpace.Next; + + /* Now we can delete the handler object */ + + AcpiUtRemoveReference (HandlerObj); + goto UnlockAndExit; + } + + /* Walk the linked list of handlers */ + + LastObjPtr = &HandlerObj->AddressSpace.Next; + HandlerObj = HandlerObj->AddressSpace.Next; + } + + /* The handler does not exist */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Unable to remove address handler %p for %s(%X), DevNode %p, obj %p\n", + Handler, AcpiUtGetRegionName (SpaceId), SpaceId, Node, ObjDesc)); + + Status = AE_NOT_EXIST; + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveAddressSpaceHandler) + diff --git a/drivers/bus/acpi/acpica/executer/exconfig.c b/drivers/bus/acpi/acpica/executer/exconfig.c new file mode 100644 index 00000000000..d0acdd5f803 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exconfig.c @@ -0,0 +1,751 @@ +/****************************************************************************** + * + * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXCONFIG_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acdispat.h" +#include "acevents.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exconfig") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExAddTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle); + +static ACPI_STATUS +AcpiExRegionRead ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Length, + UINT8 *Buffer); + + +/******************************************************************************* + * + * FUNCTION: AcpiExAddTable + * + * PARAMETERS: Table - Pointer to raw table + * ParentNode - Where to load the table (scope) + * DdbHandle - Where to return the table handle. + * + * RETURN: Status + * + * DESCRIPTION: Common function to Install and Load an ACPI table with a + * returned table handle. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExAddTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (ExAddTable); + + + /* Create an object to be the table handle */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init the table handle */ + + ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; + ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE; + *DdbHandle = ObjDesc; + + /* Install the new table into the local data structures */ + + ObjDesc->Reference.Value = TableIndex; + + /* Add the table to the namespace */ + + Status = AcpiNsLoadTable (TableIndex, ParentNode); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + *DdbHandle = NULL; + return_ACPI_STATUS (Status); + } + + /* Execute any module-level code that was found in the table */ + + AcpiExExitInterpreter (); + AcpiNsExecModuleCodeList (); + AcpiExEnterInterpreter (); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExLoadTableOp + * + * PARAMETERS: WalkState - Current state with operands + * ReturnDesc - Where to store the return object + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table from the RSDT/XSDT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExLoadTableOp ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *StartNode; + ACPI_NAMESPACE_NODE *ParameterNode = NULL; + ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *Table; + UINT32 TableIndex; + + + ACPI_FUNCTION_TRACE (ExLoadTableOp); + + + /* Validate lengths for the SignatureString, OEMIDString, OEMTableID */ + + if ((Operand[0]->String.Length > ACPI_NAME_SIZE) || + (Operand[1]->String.Length > ACPI_OEM_ID_SIZE) || + (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Find the ACPI table in the RSDT/XSDT */ + + Status = AcpiTbFindTable (Operand[0]->String.Pointer, + Operand[1]->String.Pointer, + Operand[2]->String.Pointer, &TableIndex); + if (ACPI_FAILURE (Status)) + { + if (Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Table not found, return an Integer=0 and AE_OK */ + + DdbHandle = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!DdbHandle) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + *ReturnDesc = DdbHandle; + return_ACPI_STATUS (AE_OK); + } + + /* Default nodes */ + + StartNode = WalkState->ScopeInfo->Scope.Node; + ParentNode = AcpiGbl_RootNode; + + /* RootPath (optional parameter) */ + + if (Operand[3]->String.Length > 0) + { + /* + * Find the node referenced by the RootPathString. This is the + * location within the namespace where the table will be loaded. + */ + Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer, + ACPI_NS_SEARCH_PARENT, &ParentNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* ParameterPath (optional parameter) */ + + if (Operand[4]->String.Length > 0) + { + if ((Operand[4]->String.Pointer[0] != '\\') && + (Operand[4]->String.Pointer[0] != '^')) + { + /* + * Path is not absolute, so it will be relative to the node + * referenced by the RootPathString (or the NS root if omitted) + */ + StartNode = ParentNode; + } + + /* Find the node referenced by the ParameterPathString */ + + Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer, + ACPI_NS_SEARCH_PARENT, &ParameterNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Load the table into the namespace */ + + Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Parameter Data (optional) */ + + if (ParameterNode) + { + /* Store the parameter data into the optional parameter object */ + + Status = AcpiExStore (Operand[5], + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), + WalkState); + if (ACPI_FAILURE (Status)) + { + (void) AcpiExUnloadTable (DdbHandle); + + AcpiUtRemoveReference (DdbHandle); + return_ACPI_STATUS (Status); + } + } + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + ACPI_INFO ((AE_INFO, + "Dynamic OEM Table Load - [%.4s] OemId [%.6s] OemTableId [%.8s]", + Table->Signature, Table->OemId, Table->OemTableId)); + } + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, + AcpiGbl_TableHandlerContext); + } + + *ReturnDesc = DdbHandle; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRegionRead + * + * PARAMETERS: ObjDesc - Region descriptor + * Length - Number of bytes to read + * Buffer - Pointer to where to put the data + * + * RETURN: Status + * + * DESCRIPTION: Read data from an operation region. The read starts from the + * beginning of the region. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExRegionRead ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Length, + UINT8 *Buffer) +{ + ACPI_STATUS Status; + ACPI_INTEGER Value; + UINT32 RegionOffset = 0; + UINT32 i; + + + /* Bytewise reads */ + + for (i = 0; i < Length; i++) + { + Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, + RegionOffset, 8, &Value); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *Buffer = (UINT8) Value; + Buffer++; + RegionOffset++; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExLoadOp + * + * PARAMETERS: ObjDesc - Region or Buffer/Field where the table will be + * obtained + * Target - Where a handle to the table will be stored + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table from a field or operation region + * + * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer + * objects before this code is reached. + * + * If source is an operation region, it must refer to SystemMemory, as + * per the ACPI specification. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExLoadOp ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *Target, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *Table; + ACPI_TABLE_DESC TableDesc; + UINT32 TableIndex; + ACPI_STATUS Status; + UINT32 Length; + + + ACPI_FUNCTION_TRACE (ExLoadOp); + + + ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC)); + + /* Source Object can be either an OpRegion or a Buffer/Field */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_REGION: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Load table from Region %p\n", ObjDesc)); + + /* Region must be SystemMemory (from ACPI spec) */ + + if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetRegionArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Get the table header first so we can get the table length */ + + Table = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER), + ACPI_CAST_PTR (UINT8, Table)); + Length = Table->Length; + ACPI_FREE (Table); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Must have at least an ACPI table header */ + + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + /* + * The original implementation simply mapped the table, with no copy. + * However, the memory region is not guaranteed to remain stable and + * we must copy the table to a local buffer. For example, the memory + * region is corrupted after suspend on some machines. Dynamically + * loaded tables are usually small, so this overhead is minimal. + * + * The latest implementation (5/2009) does not use a mapping at all. + * We use the low-level operation region interface to read the table + * instead of the obvious optimization of using a direct mapping. + * This maintains a consistent use of operation regions across the + * entire subsystem. This is important if additional processing must + * be performed in the (possibly user-installed) operation region + * handler. For example, AcpiExec and ASLTS depend on this. + */ + + /* Allocate a buffer for the table */ + + TableDesc.Pointer = ACPI_ALLOCATE (Length); + if (!TableDesc.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Read the entire table */ + + Status = AcpiExRegionRead (ObjDesc, Length, + ACPI_CAST_PTR (UINT8, TableDesc.Pointer)); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (TableDesc.Pointer); + return_ACPI_STATUS (Status); + } + + TableDesc.Address = ObjDesc->Region.Address; + break; + + + case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Load table from Buffer or Field %p\n", ObjDesc)); + + /* Must have at least an ACPI table header */ + + if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + /* Get the actual table length from the table header */ + + Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); + Length = Table->Length; + + /* Table cannot extend beyond the buffer */ + + if (Length > ObjDesc->Buffer.Length) + { + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + /* + * Copy the table from the buffer because the buffer could be modified + * or even deleted in the future + */ + TableDesc.Pointer = ACPI_ALLOCATE (Length); + if (!TableDesc.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_MEMCPY (TableDesc.Pointer, Table, Length); + TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer); + break; + + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Validate table checksum (will not get validated in TbAddTable) */ + + Status = AcpiTbVerifyChecksum (TableDesc.Pointer, Length); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (TableDesc.Pointer); + return_ACPI_STATUS (Status); + } + + /* Complete the table descriptor */ + + TableDesc.Length = Length; + TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED; + + /* Install the new table into the local data structures */ + + Status = AcpiTbAddTable (&TableDesc, &TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Add the table to the namespace. + * + * Note: Load the table objects relative to the root of the namespace. + * This appears to go against the ACPI specification, but we do it for + * compatibility with other ACPI implementations. + */ + Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle); + if (ACPI_FAILURE (Status)) + { + /* On error, TablePtr was deallocated above */ + + return_ACPI_STATUS (Status); + } + + /* Store the DdbHandle into the Target operand */ + + Status = AcpiExStore (DdbHandle, Target, WalkState); + if (ACPI_FAILURE (Status)) + { + (void) AcpiExUnloadTable (DdbHandle); + + /* TablePtr was deallocated above */ + + AcpiUtRemoveReference (DdbHandle); + return_ACPI_STATUS (Status); + } + + /* Remove the reference by added by AcpiExStore above */ + + AcpiUtRemoveReference (DdbHandle); + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, TableDesc.Pointer, + AcpiGbl_TableHandlerContext); + } + +Cleanup: + if (ACPI_FAILURE (Status)) + { + /* Delete allocated table buffer */ + + AcpiTbDeleteTable (&TableDesc); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExUnloadTable + * + * PARAMETERS: DdbHandle - Handle to a previously loaded table + * + * RETURN: Status + * + * DESCRIPTION: Unload an ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExUnloadTable ( + ACPI_OPERAND_OBJECT *DdbHandle) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; + UINT32 TableIndex; + ACPI_TABLE_HEADER *Table; + + + ACPI_FUNCTION_TRACE (ExUnloadTable); + + + /* + * Validate the handle + * Although the handle is partially validated in AcpiExReconfiguration() + * when it calls AcpiExResolveOperands(), the handle is more completely + * validated here. + * + * Handle must be a valid operand object of type reference. Also, the + * DdbHandle must still be marked valid (table has not been previously + * unloaded) + */ + if ((!DdbHandle) || + (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) || + (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) || + (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the table index from the DdbHandle */ + + TableIndex = TableDesc->Reference.Value; + + /* Ensure the table is still loaded */ + + if (!AcpiTbIsTableLoaded (TableIndex)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, + AcpiGbl_TableHandlerContext); + } + } + + /* Delete the portion of the namespace owned by this table */ + + Status = AcpiTbDeleteNamespaceByOwner (TableIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + (void) AcpiTbReleaseOwnerId (TableIndex); + AcpiTbSetTableLoadedFlag (TableIndex, FALSE); + + /* + * Invalidate the handle. We do this because the handle may be stored + * in a named object and may not be actually deleted until much later. + */ + DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID; + return_ACPI_STATUS (AE_OK); +} + diff --git a/drivers/bus/acpi/acpica/executer/exconvrt.c b/drivers/bus/acpi/acpica/executer/exconvrt.c new file mode 100644 index 00000000000..fd8fec1c711 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exconvrt.c @@ -0,0 +1,826 @@ +/****************************************************************************** + * + * Module Name: exconvrt - Object conversion routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXCONVRT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exconvrt") + +/* Local prototypes */ + +static UINT32 +AcpiExConvertToAscii ( + ACPI_INTEGER Integer, + UINT16 Base, + UINT8 *String, + UINT8 MaxLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToInteger + * + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the new Integer object is returned + * Flags - Used for string conversion + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to an integer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToInteger ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Flags) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *Pointer; + ACPI_INTEGER Result; + UINT32 i; + UINT32 Count; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc); + + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + + /* Note: Takes advantage of common buffer/string fields */ + + Pointer = ObjDesc->Buffer.Pointer; + Count = ObjDesc->Buffer.Length; + break; + + default: + return_ACPI_STATUS (AE_TYPE); + } + + /* + * Convert the buffer/string to an integer. Note that both buffers and + * strings are treated as raw data - we don't convert ascii to hex for + * strings. + * + * There are two terminating conditions for the loop: + * 1) The size of an integer has been reached, or + * 2) The end of the buffer or string has been reached + */ + Result = 0; + + /* String conversion is different than Buffer conversion */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_STRING: + + /* + * Convert string to an integer - for most cases, the string must be + * hexadecimal as per the ACPI specification. The only exception (as + * of ACPI 3.0) is that the ToInteger() operator allows both decimal + * and hexadecimal strings (hex prefixed with "0x"). + */ + Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + break; + + + case ACPI_TYPE_BUFFER: + + /* Check for zero-length buffer */ + + if (!Count) + { + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + + /* Transfer no more than an integer's worth of data */ + + if (Count > AcpiGbl_IntegerByteWidth) + { + Count = AcpiGbl_IntegerByteWidth; + } + + /* + * Convert buffer to an integer - we simply grab enough raw data + * from the buffer to fill an integer + */ + for (i = 0; i < Count; i++) + { + /* + * Get next byte and shift it into the Result. + * Little endian is used, meaning that the first byte of the buffer + * is the LSB of the integer + */ + Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8)); + } + break; + + + default: + + /* No other types can get here */ + break; + } + + /* Create a new integer */ + + ReturnDesc = AcpiUtCreateIntegerObject (Result); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Result))); + + /* Save the Result */ + + AcpiExTruncateFor32bitTable (ReturnDesc); + *ResultDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToBuffer + * + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the new buffer object is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to a Buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToBuffer ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + + + ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc); + + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + + case ACPI_TYPE_INTEGER: + + /* + * Create a new Buffer object. + * Need enough space for one integer + */ + ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the integer to the buffer, LSB first */ + + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_MEMCPY (NewBuf, + &ObjDesc->Integer.Value, + AcpiGbl_IntegerByteWidth); + break; + + + case ACPI_TYPE_STRING: + + /* + * Create a new Buffer object + * Size will be the string length + * + * NOTE: Add one to the string length to include the null terminator. + * The ACPI spec is unclear on this subject, but there is existing + * ASL/AML code that depends on the null being transferred to the new + * buffer. + */ + ReturnDesc = AcpiUtCreateBufferObject ( + (ACPI_SIZE) ObjDesc->String.Length + 1); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the string to the buffer */ + + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, + ObjDesc->String.Length); + break; + + + default: + return_ACPI_STATUS (AE_TYPE); + } + + /* Mark buffer initialized */ + + ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID; + *ResultDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToAscii + * + * PARAMETERS: Integer - Value to be converted + * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX + * String - Where the string is returned + * DataWidth - Size of data item to be converted, in bytes + * + * RETURN: Actual string length + * + * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string + * + ******************************************************************************/ + +static UINT32 +AcpiExConvertToAscii ( + ACPI_INTEGER Integer, + UINT16 Base, + UINT8 *String, + UINT8 DataWidth) +{ + ACPI_INTEGER Digit; + UINT32 i; + UINT32 j; + UINT32 k = 0; + UINT32 HexLength; + UINT32 DecimalLength; + UINT32 Remainder; + BOOLEAN SupressZeros; + + + ACPI_FUNCTION_ENTRY (); + + + switch (Base) + { + case 10: + + /* Setup max length for the decimal number */ + + switch (DataWidth) + { + case 1: + DecimalLength = ACPI_MAX8_DECIMAL_DIGITS; + break; + + case 4: + DecimalLength = ACPI_MAX32_DECIMAL_DIGITS; + break; + + case 8: + default: + DecimalLength = ACPI_MAX64_DECIMAL_DIGITS; + break; + } + + SupressZeros = TRUE; /* No leading zeros */ + Remainder = 0; + + for (i = DecimalLength; i > 0; i--) + { + /* Divide by nth factor of 10 */ + + Digit = Integer; + for (j = 0; j < i; j++) + { + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder); + } + + /* Handle leading zeros */ + + if (Remainder != 0) + { + SupressZeros = FALSE; + } + + if (!SupressZeros) + { + String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder); + k++; + } + } + break; + + case 16: + + /* HexLength: 2 ascii hex chars per data byte */ + + HexLength = ACPI_MUL_2 (DataWidth); + for (i = 0, j = (HexLength-1); i < HexLength; i++, j--) + { + /* Get one hex digit, most significant digits first */ + + String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); + k++; + } + break; + + default: + return (0); + } + + /* + * Since leading zeros are suppressed, we must check for the case where + * the integer equals 0 + * + * Finally, null terminate the string and return the length + */ + if (!k) + { + String [0] = ACPI_ASCII_ZERO; + k = 1; + } + + String [k] = 0; + return ((UINT32) k); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToString + * + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the string object is returned + * Type - String flags (base and conversion type) + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to a string + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Type) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + UINT32 i; + UINT32 StringLength = 0; + UINT16 Base = 16; + UINT8 Separator = ','; + + + ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc); + + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_STRING: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + + case ACPI_TYPE_INTEGER: + + switch (Type) + { + case ACPI_EXPLICIT_CONVERT_DECIMAL: + + /* Make room for maximum decimal number */ + + StringLength = ACPI_MAX_DECIMAL_DIGITS; + Base = 10; + break; + + default: + + /* Two hex string characters for each integer byte */ + + StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth); + break; + } + + /* + * Create a new String + * Need enough space for one ASCII integer (plus null terminator) + */ + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + NewBuf = ReturnDesc->Buffer.Pointer; + + /* Convert integer to string */ + + StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, + NewBuf, AcpiGbl_IntegerByteWidth); + + /* Null terminate at the correct place */ + + ReturnDesc->String.Length = StringLength; + NewBuf [StringLength] = 0; + break; + + + case ACPI_TYPE_BUFFER: + + /* Setup string length, base, and separator */ + + switch (Type) + { + case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * decimal values separated by commas." + */ + Base = 10; + + /* + * Calculate the final string length. Individual string values + * are variable length (include separator for each) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) + { + if (ObjDesc->Buffer.Pointer[i] >= 100) + { + StringLength += 4; + } + else if (ObjDesc->Buffer.Pointer[i] >= 10) + { + StringLength += 3; + } + else + { + StringLength += 2; + } + } + break; + + case ACPI_IMPLICIT_CONVERT_HEX: + /* + * From the ACPI spec: + *"The entire contents of the buffer are converted to a string of + * two-character hexadecimal numbers, each separated by a space." + */ + Separator = ' '; + StringLength = (ObjDesc->Buffer.Length * 3); + break; + + case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * hexadecimal values separated by commas." + */ + StringLength = (ObjDesc->Buffer.Length * 3); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Create a new string object and string buffer + * (-1 because of extra separator included in StringLength from above) + * Allow creation of zero-length strings from zero-length buffers. + */ + if (StringLength) + { + StringLength--; + } + + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + NewBuf = ReturnDesc->Buffer.Pointer; + + /* + * Convert buffer bytes to hex or decimal values + * (separated by commas or spaces) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) + { + NewBuf += AcpiExConvertToAscii ( + (ACPI_INTEGER) ObjDesc->Buffer.Pointer[i], Base, + NewBuf, 1); + *NewBuf++ = Separator; /* each separated by a comma or space */ + } + + /* + * Null terminate the string + * (overwrites final comma/space from above) + */ + if (ObjDesc->Buffer.Length) + { + NewBuf--; + } + *NewBuf = 0; + break; + + default: + return_ACPI_STATUS (AE_TYPE); + } + + *ResultDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToTargetType + * + * PARAMETERS: DestinationType - Current type of the destination + * SourceDesc - Source object to be converted. + * ResultDesc - Where the converted object is returned + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Implements "implicit conversion" rules for storing an object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToTargetType ( + ACPI_OBJECT_TYPE DestinationType, + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExConvertToTargetType); + + + /* Default behavior */ + + *ResultDesc = SourceDesc; + + /* + * If required by the target, + * perform implicit conversion on the source before we store it. + */ + switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) + { + case ARGI_SIMPLE_TARGET: + case ARGI_FIXED_TARGET: + case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ + + switch (DestinationType) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + /* + * Named field can always handle conversions + */ + break; + + default: + /* No conversion allowed for these types */ + + if (DestinationType != SourceDesc->Common.Type) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Explicit operator, will store (%s) over existing type (%s)\n", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetTypeName (DestinationType))); + Status = AE_TYPE; + } + } + break; + + + case ARGI_TARGETREF: + + switch (DestinationType) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* + * These types require an Integer operand. We can convert + * a Buffer or a String to an Integer if necessary. + */ + Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, + 16); + break; + + + case ACPI_TYPE_STRING: + /* + * The operand must be a String. We can convert an + * Integer or Buffer if necessary + */ + Status = AcpiExConvertToString (SourceDesc, ResultDesc, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + + case ACPI_TYPE_BUFFER: + /* + * The operand must be a Buffer. We can convert an + * Integer or String if necessary + */ + Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc); + break; + + + default: + ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: %X", + DestinationType)); + Status = AE_AML_INTERNAL; + break; + } + break; + + + case ARGI_REFERENCE: + /* + * CreateXxxxField cases - we are storing the field object into the name + */ + break; + + + default: + ACPI_ERROR ((AE_INFO, + "Unknown Target type ID 0x%X AmlOpcode %X DestType %s", + GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs), + WalkState->Opcode, AcpiUtGetTypeName (DestinationType))); + Status = AE_AML_INTERNAL; + } + + /* + * Source-to-Target conversion semantics: + * + * If conversion to the target type cannot be performed, then simply + * overwrite the target with the new object and type. + */ + if (Status == AE_TYPE) + { + Status = AE_OK; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/excreate.c b/drivers/bus/acpi/acpica/executer/excreate.c new file mode 100644 index 00000000000..e5463187a86 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/excreate.c @@ -0,0 +1,636 @@ +/****************************************************************************** + * + * Module Name: excreate - Named object creation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXCREATE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("excreate") + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiExCreateAlias + * + * PARAMETERS: WalkState - Current state, contains operands + * + * RETURN: Status + * + * DESCRIPTION: Create a new named alias + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateAlias ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_NAMESPACE_NODE *TargetNode; + ACPI_NAMESPACE_NODE *AliasNode; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExCreateAlias); + + + /* Get the source/alias operands (both namespace nodes) */ + + AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; + + if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) || + (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) + { + /* + * Dereference an existing alias so that we don't create a chain + * of aliases. With this code, we guarantee that an alias is + * always exactly one level of indirection away from the + * actual aliased name. + */ + TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object); + } + + /* + * For objects that can never change (i.e., the NS node will + * permanently point to the same object), we can simply attach + * the object to the new NS node. For other objects (such as + * Integers, buffers, etc.), we have to point the Alias node + * to the original Node. + */ + switch (TargetNode->Type) + { + + /* For these types, the sub-object can change dynamically via a Store */ + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_BUFFER_FIELD: + + /* + * These types open a new scope, so we need the NS node in order to access + * any children. + */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_LOCAL_SCOPE: + + /* + * The new alias has the type ALIAS and points to the original + * NS node, not the object itself. + */ + AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; + AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); + break; + + case ACPI_TYPE_METHOD: + + /* + * Control method aliases need to be differentiated + */ + AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS; + AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); + break; + + default: + + /* Attach the original source object to the new Alias Node */ + + /* + * The new alias assumes the type of the target, and it points + * to the same object. The reference count of the object has an + * additional reference to prevent deletion out from under either the + * target node or the alias Node + */ + Status = AcpiNsAttachObject (AliasNode, + AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); + break; + } + + /* Since both operands are Nodes, we don't need to delete them */ + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateEvent + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new event object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateEvent ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (ExCreateEvent); + + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Create the actual OS semaphore, with zero initial units -- meaning + * that the event is created in an unsignalled state + */ + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, + &ObjDesc->Event.OsSemaphore); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Attach object to the Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], + ObjDesc, ACPI_TYPE_EVENT); + +Cleanup: + /* + * Remove local reference to the object (on error, will cause deletion + * of both object and semaphore if present.) + */ + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateMutex + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new mutex object + * + * Mutex (Name[0], SyncLevel[1]) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateMutex ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS); + + + /* Create the new mutex object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create the actual OS Mutex */ + + Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Init object and attach to NS node */ + + ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; + ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + + Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); + + +Cleanup: + /* + * Remove local reference to the object (on error, will cause deletion + * of both object and semaphore if present.) + */ + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateRegion + * + * PARAMETERS: AmlStart - Pointer to the region declaration AML + * AmlLength - Max length of the declaration AML + * RegionSpace - SpaceID for the region + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new operation region object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateRegion ( + UINT8 *AmlStart, + UINT32 AmlLength, + UINT8 RegionSpace, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *RegionObj2; + + + ACPI_FUNCTION_TRACE (ExCreateRegion); + + + /* Get the Namespace Node */ + + Node = WalkState->Op->Common.Node; + + /* + * If the region object is already attached to this node, + * just return + */ + if (AcpiNsGetAttachedObject (Node)) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Space ID must be one of the predefined IDs, or in the user-defined + * range + */ + if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) && + (RegionSpace < ACPI_USER_REGION_BEGIN)) + { + ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type %X", RegionSpace)); + return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", + AcpiUtGetRegionName (RegionSpace), RegionSpace)); + + /* Create the region descriptor */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Remember location in AML stream of address & length + * operands since they need to be evaluated at run time. + */ + RegionObj2 = ObjDesc->Common.NextObject; + RegionObj2->Extra.AmlStart = AmlStart; + RegionObj2->Extra.AmlLength = AmlLength; + + /* Init the region from the operands */ + + ObjDesc->Region.SpaceId = RegionSpace; + ObjDesc->Region.Address = 0; + ObjDesc->Region.Length = 0; + ObjDesc->Region.Node = Node; + + /* Install the new region object in the parent Node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); + + +Cleanup: + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateProcessor + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new processor object and populate the fields + * + * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateProcessor ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState); + + + /* Create the processor object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the processor object from the operands */ + + ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; + ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; + ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; + + /* Install the processor object in the parent Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], + ObjDesc, ACPI_TYPE_PROCESSOR); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreatePowerResource + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new PowerResource object and populate the fields + * + * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreatePowerResource ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState); + + + /* Create the power resource object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the power object from the operands */ + + ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; + ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; + + /* Install the power resource object in the parent Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], + ObjDesc, ACPI_TYPE_POWER); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateMethod + * + * PARAMETERS: AmlStart - First byte of the method's AML + * AmlLength - AML byte count for this method + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new method object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateMethod ( + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + UINT8 MethodFlags; + + + ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState); + + + /* Create a new method object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Exit; + } + + /* Save the method's AML pointer and length */ + + ObjDesc->Method.AmlStart = AmlStart; + ObjDesc->Method.AmlLength = AmlLength; + + /* + * Disassemble the method flags. Split off the Arg Count + * for efficiency + */ + MethodFlags = (UINT8) Operand[1]->Integer.Value; + + ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT); + ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT); + + /* + * Get the SyncLevel. If method is serialized, a mutex will be + * created for this method when it is parsed. + */ + if (MethodFlags & AML_METHOD_SERIALIZED) + { + /* + * ACPI 1.0: SyncLevel = 0 + * ACPI 2.0: SyncLevel = SyncLevel in method declaration + */ + ObjDesc->Method.SyncLevel = (UINT8) + ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); + } + + /* Attach the new object to the method Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], + ObjDesc, ACPI_TYPE_METHOD); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + +Exit: + /* Remove a reference to the operand */ + + AcpiUtRemoveReference (Operand[1]); + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exdump.c b/drivers/bus/acpi/acpica/executer/exdump.c new file mode 100644 index 00000000000..5de5a6f6e40 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exdump.c @@ -0,0 +1,1194 @@ +/****************************************************************************** + * + * Module Name: exdump - Interpreter debug output routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXDUMP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exdump") + +/* + * The following routines are used for debug output only + */ +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Local prototypes */ + +static void +AcpiExOutString ( + char *Title, + char *Value); + +static void +AcpiExOutPointer ( + char *Title, + void *Value); + +static void +AcpiExDumpObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_EXDUMP_INFO *Info); + +static void +AcpiExDumpReferenceObj ( + ACPI_OPERAND_OBJECT *ObjDesc); + +static void +AcpiExDumpPackageObj ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Level, + UINT32 Index); + + +/******************************************************************************* + * + * Object Descriptor info tables + * + * Note: The first table entry must be an INIT opcode and must contain + * the table length (number of table entries) + * + ******************************************************************************/ + +static ACPI_EXDUMP_INFO AcpiExDumpInteger[2] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpInteger), NULL}, + {ACPI_EXD_UINT64, ACPI_EXD_OFFSET (Integer.Value), "Value"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpString[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpString), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (String.Length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (String.Pointer), "Pointer"}, + {ACPI_EXD_STRING, 0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpBuffer[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Buffer.Length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Pointer), "Pointer"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"}, + {ACPI_EXD_BUFFER, 0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpPackage[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Package.Flags), "Flags"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Package.Count), "Elements"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Package.Elements), "Element List"}, + {ACPI_EXD_PACKAGE, 0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpDevice[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.Handler), "Handler"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.DeviceNotify), "Device Notify"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.OsSemaphore), "OsSemaphore"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.MethodFlags), "Method Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "Parameter Count"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.OwnerId), "Owner Id"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ThreadCount), "Thread Count"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Method.AmlLength), "Aml Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.AmlStart), "Aml Start"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpMutex[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"}, + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpRegion[7] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.SpaceId), "Space Id"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.Flags), "Flags"}, + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Region.Address), "Address"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Region.Length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Handler), "Handler"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Next), "Next"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpPower[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPower), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.SystemLevel), "System Level"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.ResourceOrder), "Resource Order"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.DeviceNotify), "Device Notify"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpProcessor[7] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Processor.ProcId), "Processor ID"}, + {ACPI_EXD_UINT8 , ACPI_EXD_OFFSET (Processor.Length), "Length"}, + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Processor.Address), "Address"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.DeviceNotify), "Device Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.Handler), "Handler"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpThermal[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.DeviceNotify), "Device Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.Handler), "Handler"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpBufferField[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BufferField.BufferObj), "Buffer Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpRegionField[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.RegionObj), "Region Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpBankField[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (BankField.Value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.RegionObj), "Region Object"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.BankObj), "Bank Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (IndexField.Value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.IndexObj), "Index Object"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpReference[8] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.TargetType), "Target Type"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"}, + {ACPI_EXD_REFERENCE,0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpAddressHandler[6] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (AddressSpace.SpaceId), "Space Id"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Next), "Next"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.RegionList), "Region List"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Context), "Context"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpNotify[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Context), "Context"} +}; + + +/* Miscellaneous tables */ + +static ACPI_EXDUMP_INFO AcpiExDumpCommon[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon), NULL}, + {ACPI_EXD_TYPE , 0, NULL}, + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Common.ReferenceCount), "Reference Count"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.FieldFlags), "Field Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.AccessByteWidth), "Access Byte Width"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BitLength), "Bit Length"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BaseByteOffset), "Base Byte Offset"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpNode[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNode), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (Flags), "Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (OwnerId), "Owner Id"}, + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Child), "Child List"}, + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Peer), "Next Peer"} +}; + + +/* Dispatch table, indexed by object type */ + +static ACPI_EXDUMP_INFO *AcpiExDumpInfo[] = +{ + NULL, + AcpiExDumpInteger, + AcpiExDumpString, + AcpiExDumpBuffer, + AcpiExDumpPackage, + NULL, + AcpiExDumpDevice, + AcpiExDumpEvent, + AcpiExDumpMethod, + AcpiExDumpMutex, + AcpiExDumpRegion, + AcpiExDumpPower, + AcpiExDumpProcessor, + AcpiExDumpThermal, + AcpiExDumpBufferField, + NULL, + NULL, + AcpiExDumpRegionField, + AcpiExDumpBankField, + AcpiExDumpIndexField, + AcpiExDumpReference, + NULL, + NULL, + AcpiExDumpNotify, + AcpiExDumpAddressHandler, + NULL, + NULL, + NULL +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpObject + * + * PARAMETERS: ObjDesc - Descriptor to dump + * Info - Info table corresponding to this object + * type + * + * RETURN: None + * + * DESCRIPTION: Walk the info table for this object + * + ******************************************************************************/ + +static void +AcpiExDumpObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_EXDUMP_INFO *Info) +{ + UINT8 *Target; + char *Name; + UINT8 Count; + + + if (!Info) + { + AcpiOsPrintf ( + "ExDumpObject: Display not implemented for object type %s\n", + AcpiUtGetObjectTypeName (ObjDesc)); + return; + } + + /* First table entry must contain the table length (# of table entries) */ + + Count = Info->Offset; + + while (Count) + { + Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset); + Name = Info->Name; + + switch (Info->Opcode) + { + case ACPI_EXD_INIT: + break; + + case ACPI_EXD_TYPE: + + AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); + break; + + case ACPI_EXD_UINT8: + + AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target); + break; + + case ACPI_EXD_UINT16: + + AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target)); + break; + + case ACPI_EXD_UINT32: + + AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target)); + break; + + case ACPI_EXD_UINT64: + + AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value", + ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); + break; + + case ACPI_EXD_POINTER: + case ACPI_EXD_ADDRESS: + + AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target)); + break; + + case ACPI_EXD_STRING: + + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); + AcpiOsPrintf ("\n"); + break; + + case ACPI_EXD_BUFFER: + + ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); + break; + + case ACPI_EXD_PACKAGE: + + /* Dump the package contents */ + + AcpiOsPrintf ("\nPackage Contents:\n"); + AcpiExDumpPackageObj (ObjDesc, 0, 0); + break; + + case ACPI_EXD_FIELD: + + AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon); + break; + + case ACPI_EXD_REFERENCE: + + AcpiExOutString ("Class Name", + ACPI_CAST_PTR (char, AcpiUtGetReferenceName (ObjDesc))); + AcpiExDumpReferenceObj (ObjDesc); + break; + + default: + + AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", + Info->Opcode); + return; + } + + Info++; + Count--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpOperand + * + * PARAMETERS: *ObjDesc - Pointer to entry to be dumped + * Depth - Current nesting depth + * + * RETURN: None + * + * DESCRIPTION: Dump an operand object + * + ******************************************************************************/ + +void +AcpiExDumpOperand ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth) +{ + UINT32 Length; + UINT32 Index; + + + ACPI_FUNCTION_NAME (ExDumpOperand) + + + if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + + if (!ObjDesc) + { + /* This could be a null element of a package */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); + return; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc)); + ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC); + return; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%p is not a node or operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); + ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)); + return; + } + + /* ObjDesc is a valid object */ + + if (Depth > 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ", + Depth, " ", Depth, ObjDesc)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc)); + } + + /* Decode object type */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc)); + + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_DEBUG: + + AcpiOsPrintf ("\n"); + break; + + + case ACPI_REFCLASS_INDEX: + + AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object); + break; + + + case ACPI_REFCLASS_TABLE: + + AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value); + break; + + + case ACPI_REFCLASS_REFOF: + + AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object, + AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) + ObjDesc->Reference.Object)->Common.Type)); + break; + + + case ACPI_REFCLASS_NAME: + + AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii); + break; + + + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_LOCAL: + + AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value); + break; + + + default: /* Unknown reference class */ + + AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class); + break; + } + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("Buffer length %.2X @ %p\n", + ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer); + + /* Debug only -- dump the buffer contents */ + + if (ObjDesc->Buffer.Pointer) + { + Length = ObjDesc->Buffer.Length; + if (Length > 128) + { + Length = 128; + } + + AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n", + Length); + ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length); + } + break; + + + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("Integer %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("Package [Len %X] ElementArray %p\n", + ObjDesc->Package.Count, ObjDesc->Package.Elements); + + /* + * If elements exist, package element pointer is valid, + * and debug_level exceeds 1, dump package's elements. + */ + if (ObjDesc->Package.Count && + ObjDesc->Package.Elements && + AcpiDbgLevel > 1) + { + for (Index = 0; Index < ObjDesc->Package.Count; Index++) + { + AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1); + } + } + break; + + + case ACPI_TYPE_REGION: + + AcpiOsPrintf ("Region %s (%X)", + AcpiUtGetRegionName (ObjDesc->Region.SpaceId), + ObjDesc->Region.SpaceId); + + /* + * If the address and length have not been evaluated, + * don't print them. + */ + if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)) + { + AcpiOsPrintf ("\n"); + } + else + { + AcpiOsPrintf (" base %8.8X%8.8X Length %X\n", + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length); + } + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("String length %X @ %p ", + ObjDesc->String.Length, + ObjDesc->String.Pointer); + + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + AcpiOsPrintf ("BankField\n"); + break; + + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at " + "byte=%X bit=%X of below:\n", + ObjDesc->Field.BitLength, + ObjDesc->Field.AccessByteWidth, + ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, + ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK, + ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.StartFieldBitOffset); + + AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1); + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + AcpiOsPrintf ("IndexField\n"); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n", + ObjDesc->BufferField.BitLength, + ObjDesc->BufferField.BaseByteOffset, + ObjDesc->BufferField.StartFieldBitOffset); + + if (!ObjDesc->BufferField.BufferObj) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n")); + } + else if ((ObjDesc->BufferField.BufferObj)->Common.Type != + ACPI_TYPE_BUFFER) + { + AcpiOsPrintf ("*not a Buffer*\n"); + } + else + { + AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1); + } + break; + + + case ACPI_TYPE_EVENT: + + AcpiOsPrintf ("Event\n"); + break; + + + case ACPI_TYPE_METHOD: + + AcpiOsPrintf ("Method(%X) @ %p:%X\n", + ObjDesc->Method.ParamCount, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength); + break; + + + case ACPI_TYPE_MUTEX: + + AcpiOsPrintf ("Mutex\n"); + break; + + + case ACPI_TYPE_DEVICE: + + AcpiOsPrintf ("Device\n"); + break; + + + case ACPI_TYPE_POWER: + + AcpiOsPrintf ("Power\n"); + break; + + + case ACPI_TYPE_PROCESSOR: + + AcpiOsPrintf ("Processor\n"); + break; + + + case ACPI_TYPE_THERMAL: + + AcpiOsPrintf ("Thermal\n"); + break; + + + default: + /* Unknown Type */ + + AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type); + break; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpOperands + * + * PARAMETERS: Operands - A list of Operand objects + * OpcodeName - AML opcode name + * NumOperands - Operand count for this opcode + * + * DESCRIPTION: Dump the operands associated with the opcode + * + ******************************************************************************/ + +void +AcpiExDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + const char *OpcodeName, + UINT32 NumOperands) +{ + ACPI_FUNCTION_NAME (ExDumpOperands); + + + if (!OpcodeName) + { + OpcodeName = "UNKNOWN"; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** Start operand dump for opcode [%s], %d operands\n", + OpcodeName, NumOperands)); + + if (NumOperands == 0) + { + NumOperands = 1; + } + + /* Dump the individual operands */ + + while (NumOperands) + { + AcpiExDumpOperand (*Operands, 0); + Operands++; + NumOperands--; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** End operand dump for [%s]\n", OpcodeName)); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOut* functions + * + * PARAMETERS: Title - Descriptive text + * Value - Value to be displayed + * + * DESCRIPTION: Object dump output formatting functions. These functions + * reduce the number of format strings required and keeps them + * all in one place for easy modification. + * + ******************************************************************************/ + +static void +AcpiExOutString ( + char *Title, + char *Value) +{ + AcpiOsPrintf ("%20s : %s\n", Title, Value); +} + +static void +AcpiExOutPointer ( + char *Title, + void *Value) +{ + AcpiOsPrintf ("%20s : %p\n", Title, Value); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpNamespaceNode + * + * PARAMETERS: Node - Descriptor to dump + * Flags - Force display if TRUE + * + * DESCRIPTION: Dumps the members of the given.Node + * + ******************************************************************************/ + +void +AcpiExDumpNamespaceNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags) +{ + + ACPI_FUNCTION_ENTRY (); + + + if (!Flags) + { + if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + } + + AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); + AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); + AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node)); + AcpiExOutPointer ("Parent", AcpiNsGetParentNode (Node)); + + AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node), + AcpiExDumpNode); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpReferenceObj + * + * PARAMETERS: Object - Descriptor to dump + * + * DESCRIPTION: Dumps a reference object + * + ******************************************************************************/ + +static void +AcpiExDumpReferenceObj ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_BUFFER RetBuf; + ACPI_STATUS Status; + + + RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + + if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME) + { + AcpiOsPrintf (" %p ", ObjDesc->Reference.Node); + + Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf (" Could not convert name to pathname\n"); + } + else + { + AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer); + ACPI_FREE (RetBuf.Pointer); + } + } + else if (ObjDesc->Reference.Object) + { + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) + { + AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object); + if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE) + { + AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value); + } + else + { + AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object, + AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) + ObjDesc->Reference.Object)->Common.Type)); + } + } + else + { + AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpPackageObj + * + * PARAMETERS: ObjDesc - Descriptor to dump + * Level - Indentation Level + * Index - Package index for this object + * + * DESCRIPTION: Dumps the elements of the package + * + ******************************************************************************/ + +static void +AcpiExDumpPackageObj ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Level, + UINT32 Index) +{ + UINT32 i; + + + /* Indentation and index output */ + + if (Level > 0) + { + for (i = 0; i < Level; i++) + { + AcpiOsPrintf (" "); + } + + AcpiOsPrintf ("[%.2d] ", Index); + } + + AcpiOsPrintf ("%p ", ObjDesc); + + /* Null package elements are allowed */ + + if (!ObjDesc) + { + AcpiOsPrintf ("[Null Object]\n"); + return; + } + + /* Packages may only contain a few object types */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("[String] Value: "); + for (i = 0; i < ObjDesc->String.Length; i++) + { + AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]); + } + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); + if (ObjDesc->Buffer.Length) + { + AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), + ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); + } + else + { + AcpiOsPrintf ("\n"); + } + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("[Package] Contains %d Elements:\n", + ObjDesc->Package.Count); + + for (i = 0; i < ObjDesc->Package.Count; i++) + { + AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i); + } + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("[Object Reference] Type [%s] %2.2X", + AcpiUtGetReferenceName (ObjDesc), + ObjDesc->Reference.Class); + AcpiExDumpReferenceObj (ObjDesc); + break; + + + default: + + AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Common.Type); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpObjectDescriptor + * + * PARAMETERS: ObjDesc - Descriptor to dump + * Flags - Force display if TRUE + * + * DESCRIPTION: Dumps the members of the object descriptor given. + * + ******************************************************************************/ + +void +AcpiExDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Flags) +{ + ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor); + + + if (!ObjDesc) + { + return_VOID; + } + + if (!Flags) + { + if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return_VOID; + } + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) + { + AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags); + + AcpiOsPrintf ("\nAttached Object (%p):\n", + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object); + + AcpiExDumpObjectDescriptor ( + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags); + return_VOID; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + AcpiOsPrintf ( + "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); + return_VOID; + } + + if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX) + { + return_VOID; + } + + /* Common Fields */ + + AcpiExDumpObject (ObjDesc, AcpiExDumpCommon); + + /* Object-specific fields */ + + AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]); + return_VOID; +} + +#endif + diff --git a/drivers/bus/acpi/acpica/executer/exfield.c b/drivers/bus/acpi/acpica/executer/exfield.c new file mode 100644 index 00000000000..503e8e6b370 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exfield.c @@ -0,0 +1,466 @@ +/****************************************************************************** + * + * Module Name: exfield - ACPI AML (p-code) execution - field manipulation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXFIELD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exfield") + + +/******************************************************************************* + * + * FUNCTION: AcpiExReadDataFromField + * + * PARAMETERS: WalkState - Current execution state + * ObjDesc - The named field + * RetBufferDesc - Where the return data object is stored + * + * RETURN: Status + * + * DESCRIPTION: Read from a named field. Returns either an Integer or a + * Buffer, depending on the size of the field. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReadDataFromField ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **RetBufferDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *BufferDesc; + ACPI_SIZE Length; + void *Buffer; + UINT32 Function; + + + ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc); + + + /* Parameter validation */ + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + if (!RetBufferDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) + { + /* + * If the BufferField arguments have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) + { + /* + * This is an SMBus or IPMI read. We must create a buffer to hold + * the data and then directly access the region handler. + * + * Note: Smbus protocol value is passed in upper 16-bits of Function + */ + if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = ACPI_SMBUS_BUFFER_SIZE; + Function = ACPI_READ | (ObjDesc->Field.Attribute << 16); + } + else /* IPMI */ + { + Length = ACPI_IPMI_BUFFER_SIZE; + Function = ACPI_READ; + } + + BufferDesc = AcpiUtCreateBufferObject (Length); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Call the region handler for the read */ + + Status = AcpiExAccessRegion (ObjDesc, 0, + ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), + Function); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + goto Exit; + } + + /* + * Allocate a buffer for the contents of the field. + * + * If the field is larger than the size of an ACPI_INTEGER, create + * a BUFFER to hold it. Otherwise, use an INTEGER. This allows + * the use of arithmetic operators on the returned value if the + * field size is equal or smaller than an Integer. + * + * Note: Field.length is in bits. + */ + Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength); + if (Length > AcpiGbl_IntegerByteWidth) + { + /* Field is too large for an Integer, create a Buffer instead */ + + BufferDesc = AcpiUtCreateBufferObject (Length); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + Buffer = BufferDesc->Buffer.Pointer; + } + else + { + /* Field will fit within an Integer (normal case) */ + + BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Length = AcpiGbl_IntegerByteWidth; + Buffer = &BufferDesc->Integer.Value; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", + ObjDesc, ObjDesc->Common.Type, Buffer, (UINT32) Length)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n", + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BaseByteOffset)); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Read from the field */ + + Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + + +Exit: + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (BufferDesc); + } + else + { + *RetBufferDesc = BufferDesc; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExWriteDataToField + * + * PARAMETERS: SourceDesc - Contains data to write + * ObjDesc - The named field + * ResultDesc - Where the return value is returned, if any + * + * RETURN: Status + * + * DESCRIPTION: Write to a named field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExWriteDataToField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc) +{ + ACPI_STATUS Status; + UINT32 Length; + void *Buffer; + ACPI_OPERAND_OBJECT *BufferDesc; + UINT32 Function; + + + ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc); + + + /* Parameter validation */ + + if (!SourceDesc || !ObjDesc) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) + { + /* + * If the BufferField arguments have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) + { + /* + * This is an SMBus or IPMI write. We will bypass the entire field + * mechanism and handoff the buffer directly to the handler. For + * these address spaces, the buffer is bi-directional; on a write, + * return data is returned in the same buffer. + * + * Source must be a buffer of sufficient size: + * ACPI_SMBUS_BUFFER_SIZE or ACPI_IPMI_BUFFER_SIZE. + * + * Note: SMBus protocol type is passed in upper 16-bits of Function + */ + if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) + { + ACPI_ERROR ((AE_INFO, + "SMBus or IPMI write requires Buffer, found type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = ACPI_SMBUS_BUFFER_SIZE; + Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); + } + else /* IPMI */ + { + Length = ACPI_IPMI_BUFFER_SIZE; + Function = ACPI_WRITE; + } + + if (SourceDesc->Buffer.Length < Length) + { + ACPI_ERROR ((AE_INFO, + "SMBus or IPMI write requires Buffer of length %X, found length %X", + Length, SourceDesc->Buffer.Length)); + + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + + /* Create the bi-directional buffer */ + + BufferDesc = AcpiUtCreateBufferObject (Length); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Buffer = BufferDesc->Buffer.Pointer; + ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* + * Perform the write (returns status and perhaps data in the + * same buffer) + */ + Status = AcpiExAccessRegion (ObjDesc, 0, + (ACPI_INTEGER *) Buffer, Function); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + + *ResultDesc = BufferDesc; + return_ACPI_STATUS (Status); + } + + /* Get a pointer to the data to be written */ + + switch (SourceDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + Buffer = &SourceDesc->Integer.Value; + Length = sizeof (SourceDesc->Integer.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = SourceDesc->Buffer.Pointer; + Length = SourceDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = SourceDesc->String.Pointer; + Length = SourceDesc->String.Length; + break; + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n", + SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type), + SourceDesc->Common.Type, Buffer, Length)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n", + ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type), + ObjDesc->Common.Type, + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BaseByteOffset)); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Write to the field */ + + Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exfldio.c b/drivers/bus/acpi/acpica/executer/exfldio.c new file mode 100644 index 00000000000..37a67865517 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exfldio.c @@ -0,0 +1,1081 @@ +/****************************************************************************** + * + * Module Name: exfldio - Aml Field I/O + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXFLDIO_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acevents.h" +#include "acdispat.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exfldio") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExFieldDatumIo ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); + +static BOOLEAN +AcpiExRegisterOverflow ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Value); + +static ACPI_STATUS +AcpiExSetupRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset); + + +/******************************************************************************* + * + * FUNCTION: AcpiExSetupRegion + * + * PARAMETERS: ObjDesc - Field to be read or written + * FieldDatumByteOffset - Byte offset of this datum within the + * parent field + * + * RETURN: Status + * + * DESCRIPTION: Common processing for AcpiExExtractFromField and + * AcpiExInsertIntoField. Initialize the Region if necessary and + * validate the request. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExSetupRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *RgnDesc; + + + ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset); + + + RgnDesc = ObjDesc->CommonField.RegionObj; + + /* We must have a valid region */ + + if (RgnDesc->Common.Type != ACPI_TYPE_REGION) + { + ACPI_ERROR ((AE_INFO, "Needed Region, found type %X (%s)", + RgnDesc->Common.Type, + AcpiUtGetObjectTypeName (RgnDesc))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetRegionArguments (RgnDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Exit now for SMBus or IPMI address space, it has a non-linear address space + * and the request cannot be directly validated + */ + if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_IPMI) + { + /* SMBus or IPMI has a non-linear address space */ + + return_ACPI_STATUS (AE_OK); + } + +#ifdef ACPI_UNDER_DEVELOPMENT + /* + * If the Field access is AnyAcc, we can now compute the optimal + * access (because we know know the length of the parent region) + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } +#endif + + /* + * Validate the request. The entire request from the byte offset for a + * length of one field datum (access width) must fit within the region. + * (Region length is specified in bytes) + */ + if (RgnDesc->Region.Length < + (ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset + + ObjDesc->CommonField.AccessByteWidth)) + { + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Slack mode only: We will go ahead and allow access to this + * field if it is within the region length rounded up to the next + * access width boundary. ACPI_SIZE cast for 64-bit compile. + */ + if (ACPI_ROUND_UP (RgnDesc->Region.Length, + ObjDesc->CommonField.AccessByteWidth) >= + ((ACPI_SIZE) ObjDesc->CommonField.BaseByteOffset + + ObjDesc->CommonField.AccessByteWidth + + FieldDatumByteOffset)) + { + return_ACPI_STATUS (AE_OK); + } + } + + if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth) + { + /* + * This is the case where the AccessType (AccWord, etc.) is wider + * than the region itself. For example, a region of length one + * byte, and a field with Dword access specified. + */ + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)", + AcpiUtGetNodeName (ObjDesc->CommonField.Node), + ObjDesc->CommonField.AccessByteWidth, + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); + } + + /* + * Offset rounded up to next multiple of field width + * exceeds region length, indicate an error + */ + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)", + AcpiUtGetNodeName (ObjDesc->CommonField.Node), + ObjDesc->CommonField.BaseByteOffset, + FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); + + return_ACPI_STATUS (AE_AML_REGION_LIMIT); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAccessRegion + * + * PARAMETERS: ObjDesc - Field to be read + * FieldDatumByteOffset - Byte offset of this datum within the + * parent field + * Value - Where to store value (must at least + * the size of ACPI_INTEGER) + * Function - Read or Write flag plus other region- + * dependent flags + * + * RETURN: Status + * + * DESCRIPTION: Read or Write a single field datum to an Operation Region. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAccessRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 Function) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *RgnDesc; + UINT32 RegionOffset; + + + ACPI_FUNCTION_TRACE (ExAccessRegion); + + + /* + * Ensure that the region operands are fully evaluated and verify + * the validity of the request + */ + Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The physical address of this field datum is: + * + * 1) The base of the region, plus + * 2) The base offset of the field, plus + * 3) The current offset into the field + */ + RgnDesc = ObjDesc->CommonField.RegionObj; + RegionOffset = + ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset; + + if ((Function & ACPI_IO_MASK) == ACPI_READ) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]")); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD, + " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n", + AcpiUtGetRegionName (RgnDesc->Region.SpaceId), + RgnDesc->Region.SpaceId, + ObjDesc->CommonField.AccessByteWidth, + ObjDesc->CommonField.BaseByteOffset, + FieldDatumByteOffset, + ACPI_CAST_PTR (void, (RgnDesc->Region.Address + RegionOffset)))); + + /* Invoke the appropriate AddressSpace/OpRegion handler */ + + Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function, RegionOffset, + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_IMPLEMENTED) + { + ACPI_ERROR ((AE_INFO, + "Region %s(%X) not implemented", + AcpiUtGetRegionName (RgnDesc->Region.SpaceId), + RgnDesc->Region.SpaceId)); + } + else if (Status == AE_NOT_EXIST) + { + ACPI_ERROR ((AE_INFO, + "Region %s(%X) has no handler", + AcpiUtGetRegionName (RgnDesc->Region.SpaceId), + RgnDesc->Region.SpaceId)); + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRegisterOverflow + * + * PARAMETERS: ObjDesc - Register(Field) to be written + * Value - Value to be stored + * + * RETURN: TRUE if value overflows the field, FALSE otherwise + * + * DESCRIPTION: Check if a value is out of range of the field being written. + * Used to check if the values written to Index and Bank registers + * are out of range. Normally, the value is simply truncated + * to fit the field, but this case is most likely a serious + * coding error in the ASL. + * + ******************************************************************************/ + +static BOOLEAN +AcpiExRegisterOverflow ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Value) +{ + + if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE) + { + /* + * The field is large enough to hold the maximum integer, so we can + * never overflow it. + */ + return (FALSE); + } + + if (Value >= ((ACPI_INTEGER) 1 << ObjDesc->CommonField.BitLength)) + { + /* + * The Value is larger than the maximum value that can fit into + * the register. + */ + return (TRUE); + } + + /* The Value will fit into the field with no truncation */ + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExFieldDatumIo + * + * PARAMETERS: ObjDesc - Field to be read + * FieldDatumByteOffset - Byte offset of this datum within the + * parent field + * Value - Where to store value (must be 64 bits) + * ReadWrite - Read or Write flag + * + * RETURN: Status + * + * DESCRIPTION: Read or Write a single datum of a field. The FieldType is + * demultiplexed here to handle the different types of fields + * (BufferField, RegionField, IndexField, BankField) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExFieldDatumIo ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite) +{ + ACPI_STATUS Status; + ACPI_INTEGER LocalValue; + + + ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset); + + + if (ReadWrite == ACPI_READ) + { + if (!Value) + { + LocalValue = 0; + + /* To support reads without saving return value */ + Value = &LocalValue; + } + + /* Clear the entire return buffer first, [Very Important!] */ + + *Value = 0; + } + + /* + * The four types of fields are: + * + * BufferField - Read/write from/to a Buffer + * RegionField - Read/write from/to a Operation Region. + * BankField - Write to a Bank Register, then read/write from/to an + * OperationRegion + * IndexField - Write to an Index Register, then read/write from/to a + * Data Register + */ + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER_FIELD: + /* + * If the BufferField arguments have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (ReadWrite == ACPI_READ) + { + /* + * Copy the data from the source buffer. + * Length is the field width in bytes. + */ + ACPI_MEMCPY (Value, + (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, + ObjDesc->CommonField.AccessByteWidth); + } + else + { + /* + * Copy the data to the target buffer. + * Length is the field width in bytes. + */ + ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, + Value, ObjDesc->CommonField.AccessByteWidth); + } + + Status = AE_OK; + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + /* + * Ensure that the BankValue is not beyond the capacity of + * the register + */ + if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj, + (ACPI_INTEGER) ObjDesc->BankField.Value)) + { + return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); + } + + /* + * For BankFields, we must write the BankValue to the BankRegister + * (itself a RegionField) before we can access the data. + */ + Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj, + &ObjDesc->BankField.Value, + sizeof (ObjDesc->BankField.Value)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now that the Bank has been selected, fall through to the + * RegionField case and write the datum to the Operation Region + */ + + /*lint -fallthrough */ + + + case ACPI_TYPE_LOCAL_REGION_FIELD: + /* + * For simple RegionFields, we just directly access the owning + * Operation Region. + */ + Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value, + ReadWrite); + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + + /* + * Ensure that the IndexValue is not beyond the capacity of + * the register + */ + if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj, + (ACPI_INTEGER) ObjDesc->IndexField.Value)) + { + return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); + } + + /* Write the index value to the IndexRegister (itself a RegionField) */ + + FieldDatumByteOffset += ObjDesc->IndexField.Value; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Write to Index Register: Value %8.8X\n", + FieldDatumByteOffset)); + + Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj, + &FieldDatumByteOffset, + sizeof (FieldDatumByteOffset)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (ReadWrite == ACPI_READ) + { + /* Read the datum from the DataRegister */ + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Read from Data Register\n")); + + Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj, + Value, sizeof (ACPI_INTEGER)); + } + else + { + /* Write the datum to the DataRegister */ + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Write to Data Register: Value %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (*Value))); + + Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj, + Value, sizeof (ACPI_INTEGER)); + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %X", + ObjDesc->Common.Type)); + Status = AE_AML_INTERNAL; + break; + } + + if (ACPI_SUCCESS (Status)) + { + if (ReadWrite == ACPI_READ) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Read %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Written %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExWriteWithUpdateRule + * + * PARAMETERS: ObjDesc - Field to be written + * Mask - bitmask within field datum + * FieldValue - Value to write + * FieldDatumByteOffset - Offset of datum within field + * + * RETURN: Status + * + * DESCRIPTION: Apply the field update rule to a field write + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExWriteWithUpdateRule ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Mask, + ACPI_INTEGER FieldValue, + UINT32 FieldDatumByteOffset) +{ + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER MergedValue; + ACPI_INTEGER CurrentValue; + + + ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask); + + + /* Start with the new bits */ + + MergedValue = FieldValue; + + /* If the mask is all ones, we don't need to worry about the update rule */ + + if (Mask != ACPI_INTEGER_MAX) + { + /* Decode the update rule */ + + switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK) + { + case AML_FIELD_UPDATE_PRESERVE: + /* + * Check if update rule needs to be applied (not if mask is all + * ones) The left shift drops the bits we want to ignore. + */ + if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) - + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0) + { + /* + * Read the current contents of the byte/word/dword containing + * the field, and merge with the new field value. + */ + Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, + &CurrentValue, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + MergedValue |= (CurrentValue & ~Mask); + } + break; + + case AML_FIELD_UPDATE_WRITE_AS_ONES: + + /* Set positions outside the field to all ones */ + + MergedValue |= ~Mask; + break; + + case AML_FIELD_UPDATE_WRITE_AS_ZEROS: + + /* Set positions outside the field to all zeros */ + + MergedValue &= Mask; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown UpdateRule value: %X", + (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK))); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Mask), + FieldDatumByteOffset, + ObjDesc->CommonField.AccessByteWidth, + ACPI_FORMAT_UINT64 (FieldValue), + ACPI_FORMAT_UINT64 (MergedValue))); + + /* Write the merged value */ + + Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, + &MergedValue, ACPI_WRITE); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExExtractFromField + * + * PARAMETERS: ObjDesc - Field to be read + * Buffer - Where to store the field data + * BufferLength - Length of Buffer + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the current value of the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExExtractFromField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength) +{ + ACPI_STATUS Status; + ACPI_INTEGER RawDatum; + ACPI_INTEGER MergedDatum; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; + UINT32 DatumCount; + UINT32 FieldDatumCount; + UINT32 i; + + + ACPI_FUNCTION_TRACE (ExExtractFromField); + + + /* Validate target buffer and clear it */ + + if (BufferLength < + ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength)) + { + ACPI_ERROR ((AE_INFO, + "Field size %X (bits) is too large for buffer (%X)", + ObjDesc->CommonField.BitLength, BufferLength)); + + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + ACPI_MEMSET (Buffer, 0, BufferLength); + + /* Compute the number of datums (access width data items) */ + + DatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + FieldDatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); + + /* Priming read from the field */ + + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; + + /* Read the rest of the field */ + + for (i = 1; i < FieldDatumCount; i++) + { + /* Get next input datum from the field */ + + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, + &RawDatum, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Merge with previous datum if necessary. + * + * Note: Before the shift, check if the shift value will be larger than + * the integer size. If so, there is no need to perform the operation. + * This avoids the differences in behavior between different compilers + * concerning shift values larger than the target data width. + */ + if ((ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + { + MergedDatum |= RawDatum << + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + } + + if (i == DatumCount) + { + break; + } + + /* Write merged datum to target buffer */ + + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; + } + + /* Mask off any extra bits in the last datum */ + + BufferTailBits = ObjDesc->CommonField.BitLength % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) + { + MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits); + } + + /* Write the last datum to the buffer */ + + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExInsertIntoField + * + * PARAMETERS: ObjDesc - Field to be written + * Buffer - Data to be written + * BufferLength - Length of Buffer + * + * RETURN: Status + * + * DESCRIPTION: Store the Buffer contents into the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExInsertIntoField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength) +{ + ACPI_STATUS Status; + ACPI_INTEGER Mask; + ACPI_INTEGER WidthMask; + ACPI_INTEGER MergedDatum; + ACPI_INTEGER RawDatum = 0; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; + UINT32 DatumCount; + UINT32 FieldDatumCount; + UINT32 i; + UINT32 RequiredLength; + void *NewBuffer; + + + ACPI_FUNCTION_TRACE (ExInsertIntoField); + + + /* Validate input buffer */ + + NewBuffer = NULL; + RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength); + /* + * We must have a buffer that is at least as long as the field + * we are writing to. This is because individual fields are + * indivisible and partial writes are not supported -- as per + * the ACPI specification. + */ + if (BufferLength < RequiredLength) + { + /* We need to create a new buffer */ + + NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength); + if (!NewBuffer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the original data to the new buffer, starting + * at Byte zero. All unused (upper) bytes of the + * buffer will be 0. + */ + ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength); + Buffer = NewBuffer; + BufferLength = RequiredLength; + } + + /* + * Create the bitmasks used for bit insertion. + * Note: This if/else is used to bypass compiler differences with the + * shift operator + */ + if (ObjDesc->CommonField.AccessBitWidth == ACPI_INTEGER_BIT_SIZE) + { + WidthMask = ACPI_INTEGER_MAX; + } + else + { + WidthMask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.AccessBitWidth); + } + + Mask = WidthMask & + ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); + + /* Compute the number of datums (access width data items) */ + + DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + + FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); + + /* Get initial Datum from the input buffer */ + + ACPI_MEMCPY (&RawDatum, Buffer, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + + MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset; + + /* Write the entire field */ + + for (i = 1; i < FieldDatumCount; i++) + { + /* Write merged datum to the target field */ + + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, + MergedDatum, FieldOffset); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + + /* + * Start new output datum by merging with previous input datum + * if necessary. + * + * Note: Before the shift, check if the shift value will be larger than + * the integer size. If so, there is no need to perform the operation. + * This avoids the differences in behavior between different compilers + * concerning shift values larger than the target data width. + */ + if ((ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + { + MergedDatum = RawDatum >> + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + } + else + { + MergedDatum = 0; + } + + Mask = WidthMask; + + if (i == DatumCount) + { + break; + } + + /* Get the next input datum from the buffer */ + + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset; + } + + /* Mask off any extra bits in the last datum */ + + BufferTailBits = (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset) % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) + { + Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits); + } + + /* Write the last datum to the field */ + + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, + Mask, MergedDatum, FieldOffset); + +Exit: + /* Free temporary buffer if we used one */ + + if (NewBuffer) + { + ACPI_FREE (NewBuffer); + } + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exmisc.c b/drivers/bus/acpi/acpica/executer/exmisc.c new file mode 100644 index 00000000000..41e4a9752ec --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exmisc.c @@ -0,0 +1,873 @@ + +/****************************************************************************** + * + * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXMISC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "amlresrc.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exmisc") + + +/******************************************************************************* + * + * FUNCTION: AcpiExGetObjectReference + * + * PARAMETERS: ObjDesc - Create a reference to this object + * ReturnDesc - Where to store the reference + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Obtain and return a "reference" to the target object + * Common code for the RefOfOp and the CondRefOfOp. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExGetObjectReference ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ReferenceObj; + ACPI_OPERAND_OBJECT *ReferencedObj; + + + ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc); + + + *ReturnDesc = NULL; + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_OPERAND: + + if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * Must be a reference to a Local or Arg + */ + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_DEBUG: + + /* The referenced object is the pseudo-node for the local/arg */ + + ReferencedObj = ObjDesc->Reference.Object; + break; + + default: + + ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + ObjDesc->Reference.Class)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + break; + + + case ACPI_DESC_TYPE_NAMED: + + /* + * A named reference that has already been resolved to a Node + */ + ReferencedObj = ObjDesc; + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid descriptor type %X", + ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))); + return_ACPI_STATUS (AE_TYPE); + } + + + /* Create a new reference object */ + + ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!ReferenceObj) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF; + ReferenceObj->Reference.Object = ReferencedObj; + *ReturnDesc = ReferenceObj; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p Type [%s], returning Reference %p\n", + ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConcatTemplate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two resource templates + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConcatTemplate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + UINT8 *EndTag; + ACPI_SIZE Length0; + ACPI_SIZE Length1; + ACPI_SIZE NewLength; + + + ACPI_FUNCTION_TRACE (ExConcatTemplate); + + + /* + * Find the EndTag descriptor in each resource template. + * Note1: returned pointers point TO the EndTag, not past it. + * Note2: zero-length buffers are allowed; treated like one EndTag + */ + + /* Get the length of the first resource template */ + + Status = AcpiUtGetResourceEndTag (Operand0, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer); + + /* Get the length of the second resource template */ + + Status = AcpiUtGetResourceEndTag (Operand1, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer); + + /* Combine both lengths, minimum size will be 2 for EndTag */ + + NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG); + + /* Create a new buffer object for the result (with one EndTag) */ + + ReturnDesc = AcpiUtCreateBufferObject (NewLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the templates to the new buffer, 0 first, then 1 follows. One + * EndTag descriptor is copied from Operand1. + */ + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0); + ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1); + + /* Insert EndTag and set the checksum to zero, means "ignore checksum" */ + + NewBuf[NewLength - 1] = 0; + NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; + + /* Return the completed resource template */ + + *ActualReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoConcatenate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_OPERAND_OBJECT *ReturnDesc; + char *NewBuf; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExDoConcatenate); + + + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); + break; + + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; + + default: + ACPI_ERROR ((AE_INFO, "Invalid object type: %X", + Operand0->Common.Type)); + Status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Both operands are now known to be the same object type + * (Both are Integer, String, or Buffer), and we can now perform the + * concatenation. + */ + + /* + * There are three cases to handle: + * + * 1) Two Integers concatenated to produce a new Buffer + * 2) Two Strings concatenated to produce a new String + * 3) Two Buffers concatenated to produce a new Buffer + */ + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* Result of two Integers is a Buffer */ + /* Need enough buffer space for two integers */ + + ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) + ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = (char *) ReturnDesc->Buffer.Pointer; + + /* Copy the first integer, LSB first */ + + ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value, + AcpiGbl_IntegerByteWidth); + + /* Copy the second integer (LSB first) after the first */ + + ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth, + &LocalOperand1->Integer.Value, + AcpiGbl_IntegerByteWidth); + break; + + case ACPI_TYPE_STRING: + + /* Result of two Strings is a String */ + + ReturnDesc = AcpiUtCreateStringObject ( + ((ACPI_SIZE) Operand0->String.Length + + LocalOperand1->String.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = ReturnDesc->String.Pointer; + + /* Concatenate the strings */ + + ACPI_STRCPY (NewBuf, Operand0->String.Pointer); + ACPI_STRCPY (NewBuf + Operand0->String.Length, + LocalOperand1->String.Pointer); + break; + + case ACPI_TYPE_BUFFER: + + /* Result of two Buffers is a Buffer */ + + ReturnDesc = AcpiUtCreateBufferObject ( + ((ACPI_SIZE) Operand0->Buffer.Length + + LocalOperand1->Buffer.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = (char *) ReturnDesc->Buffer.Pointer; + + /* Concatenate the buffers */ + + ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, + Operand0->Buffer.Length); + ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length, + LocalOperand1->Buffer.Pointer, + LocalOperand1->Buffer.Length); + break; + + default: + + /* Invalid object type, should not happen here */ + + ACPI_ERROR ((AE_INFO, "Invalid object type: %X", + Operand0->Common.Type)); + Status =AE_AML_INTERNAL; + goto Cleanup; + } + + *ActualReturnDesc = ReturnDesc; + +Cleanup: + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoMathOp + * + * PARAMETERS: Opcode - AML opcode + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 + * + * RETURN: Integer result of the operation + * + * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the + * math functions here is to prevent a lot of pointer dereferencing + * to obtain the operands. + * + ******************************************************************************/ + +ACPI_INTEGER +AcpiExDoMathOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1) +{ + + ACPI_FUNCTION_ENTRY (); + + + switch (Opcode) + { + case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ + + return (Integer0 + Integer1); + + + case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */ + + return (Integer0 & Integer1); + + + case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */ + + return (~(Integer0 & Integer1)); + + + case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */ + + return (Integer0 | Integer1); + + + case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */ + + return (~(Integer0 | Integer1)); + + + case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */ + + return (Integer0 ^ Integer1); + + + case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */ + + return (Integer0 * Integer1); + + + case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/ + + /* + * We need to check if the shiftcount is larger than the integer bit + * width since the behavior of this is not well-defined in the C language. + */ + if (Integer1 >= AcpiGbl_IntegerBitWidth) + { + return (0); + } + return (Integer0 << Integer1); + + + case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ + + /* + * We need to check if the shiftcount is larger than the integer bit + * width since the behavior of this is not well-defined in the C language. + */ + if (Integer1 >= AcpiGbl_IntegerBitWidth) + { + return (0); + } + return (Integer0 >> Integer1); + + + case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */ + + return (Integer0 - Integer1); + + default: + + return (0); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoLogicalNumericOp + * + * PARAMETERS: Opcode - AML opcode + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 + * LogicalResult - TRUE/FALSE result of the operation + * + * RETURN: Status + * + * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric + * operators (LAnd and LOr), both operands must be integers. + * + * Note: cleanest machine code seems to be produced by the code + * below, rather than using statements of the form: + * Result = (Integer0 && Integer1); + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + + + ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp); + + + switch (Opcode) + { + case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ + + if (Integer0 && Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LOR_OP: /* LOr (Integer0, Integer1) */ + + if (Integer0 || Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoLogicalOp + * + * PARAMETERS: Opcode - AML opcode + * Operand0 - operand #0 + * Operand1 - operand #1 + * LogicalResult - TRUE/FALSE result of the operation + * + * RETURN: Status + * + * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the + * functions here is to prevent a lot of pointer dereferencing + * to obtain the operands and to simplify the generation of the + * logical value. For the Numeric operators (LAnd and LOr), both + * operands must be integers. For the other logical operators, + * operands can be any combination of Integer/String/Buffer. The + * first operand determines the type to which the second operand + * will be converted. + * + * Note: cleanest machine code seems to be produced by the code + * below, rather than using statements of the form: + * Result = (Operand0 == Operand1); + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoLogicalOp ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult) +{ + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_INTEGER Integer0; + ACPI_INTEGER Integer1; + UINT32 Length0; + UINT32 Length1; + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + int Compare; + + + ACPI_FUNCTION_TRACE (ExDoLogicalOp); + + + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI 3.0+ specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); + break; + + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Two cases: 1) Both Integers, 2) Both Strings or Buffers + */ + if (Operand0->Common.Type == ACPI_TYPE_INTEGER) + { + /* + * 1) Both operands are of type integer + * Note: LocalOperand1 may have changed above + */ + Integer0 = Operand0->Integer.Value; + Integer1 = LocalOperand1->Integer.Value; + + switch (Opcode) + { + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + + if (Integer0 == Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + + if (Integer0 > Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Integer0 < Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + } + else + { + /* + * 2) Both operands are Strings or both are Buffers + * Note: Code below takes advantage of common Buffer/String + * object fields. LocalOperand1 may have changed above. Use + * memcmp to handle nulls in buffers. + */ + Length0 = Operand0->Buffer.Length; + Length1 = LocalOperand1->Buffer.Length; + + /* Lexicographic compare: compare the data bytes */ + + Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer, + LocalOperand1->Buffer.Pointer, + (Length0 > Length1) ? Length1 : Length0); + + switch (Opcode) + { + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + + /* Length and all bytes must be equal */ + + if ((Length0 == Length1) && + (Compare == 0)) + { + /* Length and all bytes match ==> TRUE */ + + LocalResult = TRUE; + } + break; + + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + + if (Compare > 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + if (Compare < 0) + { + goto Cleanup; /* FALSE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 > Length1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Compare > 0) + { + goto Cleanup; /* FALSE */ + } + if (Compare < 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 < Length1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + } + +Cleanup: + + /* New object was created if implicit conversion performed - delete */ + + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exmutex.c b/drivers/bus/acpi/acpica/executer/exmutex.c new file mode 100644 index 00000000000..8b1bebf1e91 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exmutex.c @@ -0,0 +1,621 @@ + +/****************************************************************************** + * + * Module Name: exmutex - ASL Mutex Acquire/Release functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXMUTEX_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acevents.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exmutex") + +/* Local prototypes */ + +static void +AcpiExLinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_STATE *Thread); + + +/******************************************************************************* + * + * FUNCTION: AcpiExUnlinkMutex + * + * PARAMETERS: ObjDesc - The mutex to be unlinked + * + * RETURN: None + * + * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list + * + ******************************************************************************/ + +void +AcpiExUnlinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread; + + + if (!Thread) + { + return; + } + + /* Doubly linked list */ + + if (ObjDesc->Mutex.Next) + { + (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; + } + + if (ObjDesc->Mutex.Prev) + { + (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next; + + /* + * Migrate the previous sync level associated with this mutex to the + * previous mutex on the list so that it may be preserved. This handles + * the case where several mutexes have been acquired at the same level, + * but are not released in opposite order. + */ + (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel = + ObjDesc->Mutex.OriginalSyncLevel; + } + else + { + Thread->AcquiredMutexList = ObjDesc->Mutex.Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExLinkMutex + * + * PARAMETERS: ObjDesc - The mutex to be linked + * Thread - Current executing thread object + * + * RETURN: None + * + * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk + * + ******************************************************************************/ + +static void +AcpiExLinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_STATE *Thread) +{ + ACPI_OPERAND_OBJECT *ListHead; + + + ListHead = Thread->AcquiredMutexList; + + /* This object will be the first object in the list */ + + ObjDesc->Mutex.Prev = NULL; + ObjDesc->Mutex.Next = ListHead; + + /* Update old first object to point back to this object */ + + if (ListHead) + { + ListHead->Mutex.Prev = ObjDesc; + } + + /* Update list head */ + + Thread->AcquiredMutexList = ObjDesc; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAcquireMutexObject + * + * PARAMETERS: TimeDesc - Timeout in milliseconds + * ObjDesc - Mutex object + * Thread - Current thread state + * + * RETURN: Status + * + * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common + * path that supports multiple acquires by the same thread. + * + * MUTEX: Interpreter must be locked + * + * NOTE: This interface is called from three places: + * 1) From AcpiExAcquireMutex, via an AML Acquire() operator + * 2) From AcpiExAcquireGlobalLock when an AML Field access requires the + * global lock + * 3) From the external interface, AcpiAcquireGlobalLock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAcquireMutexObject ( + UINT16 Timeout, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_ID ThreadId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Support for multiple acquires by the owning thread */ + + if (ObjDesc->Mutex.ThreadId == ThreadId) + { + /* + * The mutex is already owned by this thread, just increment the + * acquisition depth + */ + ObjDesc->Mutex.AcquisitionDepth++; + return_ACPI_STATUS (AE_OK); + } + + /* Acquire the mutex, wait if necessary. Special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + Status = AcpiEvAcquireGlobalLock (Timeout); + } + else + { + Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, + Timeout); + } + + if (ACPI_FAILURE (Status)) + { + /* Includes failure from a timeout on TimeDesc */ + + return_ACPI_STATUS (Status); + } + + /* Acquired the mutex: update mutex object */ + + ObjDesc->Mutex.ThreadId = ThreadId; + ObjDesc->Mutex.AcquisitionDepth = 1; + ObjDesc->Mutex.OriginalSyncLevel = 0; + ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */ + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAcquireMutex + * + * PARAMETERS: TimeDesc - Timeout integer + * ObjDesc - Mutex object + * WalkState - Current method execution state + * + * RETURN: Status + * + * DESCRIPTION: Acquire an AML mutex + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAcquireMutex ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Must have a valid thread ID */ + + if (!WalkState->Thread) + { + ACPI_ERROR ((AE_INFO, "Cannot acquire Mutex [%4.4s], null thread info", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * Current sync level must be less than or equal to the sync level of the + * mutex. This mechanism provides some deadlock prevention + */ + if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) + { + ACPI_ERROR ((AE_INFO, + "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)", + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + WalkState->Thread->CurrentSyncLevel)); + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value, + ObjDesc, WalkState->Thread->ThreadId); + if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1) + { + /* Save Thread object, original/current sync levels */ + + ObjDesc->Mutex.OwnerThread = WalkState->Thread; + ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; + + /* Link the mutex to the current thread for force-unlock at method exit */ + + AcpiExLinkMutex (ObjDesc, WalkState->Thread); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseMutexObject + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Release a previously acquired Mutex, low level interface. + * Provides a common path that supports multiple releases (after + * previous multiple acquires) by the same thread. + * + * MUTEX: Interpreter must be locked + * + * NOTE: This interface is called from three places: + * 1) From AcpiExReleaseMutex, via an AML Acquire() operator + * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the + * global lock + * 3) From the external interface, AcpiReleaseGlobalLock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReleaseMutexObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExReleaseMutexObject); + + + if (ObjDesc->Mutex.AcquisitionDepth == 0) + { + return (AE_NOT_ACQUIRED); + } + + /* Match multiple Acquires with multiple Releases */ + + ObjDesc->Mutex.AcquisitionDepth--; + if (ObjDesc->Mutex.AcquisitionDepth != 0) + { + /* Just decrement the depth and return */ + + return_ACPI_STATUS (AE_OK); + } + + if (ObjDesc->Mutex.OwnerThread) + { + /* Unlink the mutex from the owner's list */ + + AcpiExUnlinkMutex (ObjDesc); + ObjDesc->Mutex.OwnerThread = NULL; + } + + /* Release the mutex, special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + Status = AcpiEvReleaseGlobalLock (); + } + else + { + AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); + } + + /* Clear mutex info */ + + ObjDesc->Mutex.ThreadId = 0; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseMutex + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * WalkState - Current method execution state + * + * RETURN: Status + * + * DESCRIPTION: Release a previously acquired Mutex. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReleaseMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + UINT8 PreviousSyncLevel; + + + ACPI_FUNCTION_TRACE (ExReleaseMutex); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* The mutex must have been previously acquired in order to release it */ + + if (!ObjDesc->Mutex.OwnerThread) + { + ACPI_ERROR ((AE_INFO, "Cannot release Mutex [%4.4s], not acquired", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED); + } + + /* Must have a valid thread ID */ + + if (!WalkState->Thread) + { + ACPI_ERROR ((AE_INFO, "Cannot release Mutex [%4.4s], null thread info", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * The Mutex is owned, but this thread must be the owner. + * Special case for Global Lock, any thread can release + */ + if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) && + (ObjDesc != AcpiGbl_GlobalLockMutex)) + { + ACPI_ERROR ((AE_INFO, + "Thread %p cannot release Mutex [%4.4s] acquired by thread %p", + ACPI_CAST_PTR (void, WalkState->Thread->ThreadId), + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + ACPI_CAST_PTR (void, ObjDesc->Mutex.OwnerThread->ThreadId))); + return_ACPI_STATUS (AE_AML_NOT_OWNER); + } + + /* + * The sync level of the mutex must be equal to the current sync level. In + * other words, the current level means that at least one mutex at that + * level is currently being held. Attempting to release a mutex of a + * different level can only mean that the mutex ordering rule is being + * violated. This behavior is clarified in ACPI 4.0 specification. + */ + if (ObjDesc->Mutex.SyncLevel != WalkState->Thread->CurrentSyncLevel) + { + ACPI_ERROR ((AE_INFO, + "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %d current %d", + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel)); + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + /* + * Get the previous SyncLevel from the head of the acquired mutex list. + * This handles the case where several mutexes at the same level have been + * acquired, but are not released in reverse order. + */ + PreviousSyncLevel = + WalkState->Thread->AcquiredMutexList->Mutex.OriginalSyncLevel; + + Status = AcpiExReleaseMutexObject (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (ObjDesc->Mutex.AcquisitionDepth == 0) + { + /* Restore the previous SyncLevel */ + + WalkState->Thread->CurrentSyncLevel = PreviousSyncLevel; + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseAllMutexes + * + * PARAMETERS: Thread - Current executing thread object + * + * RETURN: Status + * + * DESCRIPTION: Release all mutexes held by this thread + * + * NOTE: This function is called as the thread is exiting the interpreter. + * Mutexes are not released when an individual control method is exited, but + * only when the parent thread actually exits the interpreter. This allows one + * method to acquire a mutex, and a different method to release it, as long as + * this is performed underneath a single parent control method. + * + ******************************************************************************/ + +void +AcpiExReleaseAllMutexes ( + ACPI_THREAD_STATE *Thread) +{ + ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_ENTRY (); + + + /* Traverse the list of owned mutexes, releasing each one */ + + while (Next) + { + ObjDesc = Next; + Next = ObjDesc->Mutex.Next; + + ObjDesc->Mutex.Prev = NULL; + ObjDesc->Mutex.Next = NULL; + ObjDesc->Mutex.AcquisitionDepth = 0; + + /* Release the mutex, special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + /* Ignore errors */ + + (void) AcpiEvReleaseGlobalLock (); + } + else + { + AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); + } + + /* Mark mutex unowned */ + + ObjDesc->Mutex.OwnerThread = NULL; + ObjDesc->Mutex.ThreadId = 0; + + /* Update Thread SyncLevel (Last mutex is the important one) */ + + Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; + } +} + + diff --git a/drivers/bus/acpi/acpica/executer/exnames.c b/drivers/bus/acpi/acpica/executer/exnames.c new file mode 100644 index 00000000000..89fa2d4874d --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exnames.c @@ -0,0 +1,560 @@ + +/****************************************************************************** + * + * Module Name: exnames - interpreter/scanner name load/execute + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXNAMES_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exnames") + +/* Local prototypes */ + +static char * +AcpiExAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs); + +static ACPI_STATUS +AcpiExNameSegment ( + UINT8 **InAmlAddress, + char *NameString); + + +/******************************************************************************* + * + * FUNCTION: AcpiExAllocateNameString + * + * PARAMETERS: PrefixCount - Count of parent levels. Special cases: + * (-1)==root, 0==none + * NumNameSegs - count of 4-character name segments + * + * RETURN: A pointer to the allocated string segment. This segment must + * be deleted by the caller. + * + * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name + * string is long enough, and set up prefix if any. + * + ******************************************************************************/ + +static char * +AcpiExAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs) +{ + char *TempPtr; + char *NameString; + UINT32 SizeNeeded; + + ACPI_FUNCTION_TRACE (ExAllocateNameString); + + + /* + * Allow room for all \ and ^ prefixes, all segments and a MultiNamePrefix. + * Also, one byte for the null terminator. + * This may actually be somewhat longer than needed. + */ + if (PrefixCount == ACPI_UINT32_MAX) + { + /* Special case for root */ + + SizeNeeded = 1 + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; + } + else + { + SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; + } + + /* + * Allocate a buffer for the name. + * This buffer must be deleted by the caller! + */ + NameString = ACPI_ALLOCATE (SizeNeeded); + if (!NameString) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate size %d", SizeNeeded)); + return_PTR (NULL); + } + + TempPtr = NameString; + + /* Set up Root or Parent prefixes if needed */ + + if (PrefixCount == ACPI_UINT32_MAX) + { + *TempPtr++ = AML_ROOT_PREFIX; + } + else + { + while (PrefixCount--) + { + *TempPtr++ = AML_PARENT_PREFIX; + } + } + + + /* Set up Dual or Multi prefixes if needed */ + + if (NumNameSegs > 2) + { + /* Set up multi prefixes */ + + *TempPtr++ = AML_MULTI_NAME_PREFIX_OP; + *TempPtr++ = (char) NumNameSegs; + } + else if (2 == NumNameSegs) + { + /* Set up dual prefixes */ + + *TempPtr++ = AML_DUAL_NAME_PREFIX; + } + + /* + * Terminate string following prefixes. AcpiExNameSegment() will + * append the segment(s) + */ + *TempPtr = 0; + + return_PTR (NameString); +} + +/******************************************************************************* + * + * FUNCTION: AcpiExNameSegment + * + * PARAMETERS: InAmlAddress - Pointer to the name in the AML code + * NameString - Where to return the name. The name is appended + * to any existing string to form a namepath + * + * RETURN: Status + * + * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExNameSegment ( + UINT8 **InAmlAddress, + char *NameString) +{ + char *AmlAddress = (void *) *InAmlAddress; + ACPI_STATUS Status = AE_OK; + UINT32 Index; + char CharBuf[5]; + + + ACPI_FUNCTION_TRACE (ExNameSegment); + + + /* + * If first character is a digit, then we know that we aren't looking at a + * valid name segment + */ + CharBuf[0] = *AmlAddress; + + if ('0' <= CharBuf[0] && CharBuf[0] <= '9') + { + ACPI_ERROR ((AE_INFO, "Invalid leading digit: %c", CharBuf[0])); + return_ACPI_STATUS (AE_CTRL_PENDING); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); + + for (Index = 0; + (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0)); + Index++) + { + CharBuf[Index] = *AmlAddress++; + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", CharBuf[Index])); + } + + + /* Valid name segment */ + + if (Index == 4) + { + /* Found 4 valid characters */ + + CharBuf[4] = '\0'; + + if (NameString) + { + ACPI_STRCAT (NameString, CharBuf); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Appended to - %s\n", NameString)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "No Name string - %s\n", CharBuf)); + } + } + else if (Index == 0) + { + /* + * First character was not a valid name character, + * so we are looking at something other than a name. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Leading character is not alpha: %02Xh (not a name)\n", + CharBuf[0])); + Status = AE_CTRL_PENDING; + } + else + { + /* + * Segment started with one or more valid characters, but fewer than + * the required 4 + */ + Status = AE_AML_BAD_NAME; + ACPI_ERROR ((AE_INFO, + "Bad character %02x in name, at %p", + *AmlAddress, AmlAddress)); + } + + *InAmlAddress = ACPI_CAST_PTR (UINT8, AmlAddress); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExGetNameString + * + * PARAMETERS: DataType - Object type to be associated with this + * name + * InAmlAddress - Pointer to the namestring in the AML code + * OutNameString - Where the namestring is returned + * OutNameLength - Length of the returned string + * + * RETURN: Status, namestring and length + * + * DESCRIPTION: Extract a full namepath from the AML byte stream, + * including any prefixes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExGetNameString ( + ACPI_OBJECT_TYPE DataType, + UINT8 *InAmlAddress, + char **OutNameString, + UINT32 *OutNameLength) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *AmlAddress = InAmlAddress; + char *NameString = NULL; + UINT32 NumSegments; + UINT32 PrefixCount = 0; + BOOLEAN HasPrefix = FALSE; + + + ACPI_FUNCTION_TRACE_PTR (ExGetNameString, AmlAddress); + + + if (ACPI_TYPE_LOCAL_REGION_FIELD == DataType || + ACPI_TYPE_LOCAL_BANK_FIELD == DataType || + ACPI_TYPE_LOCAL_INDEX_FIELD == DataType) + { + /* Disallow prefixes for types associated with FieldUnit names */ + + NameString = AcpiExAllocateNameString (0, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + } + else + { + Status = AcpiExNameSegment (&AmlAddress, NameString); + } + } + else + { + /* + * DataType is not a field name. + * Examine first character of name for root or parent prefix operators + */ + switch (*AmlAddress) + { + case AML_ROOT_PREFIX: + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", + AmlAddress)); + + /* + * Remember that we have a RootPrefix -- + * see comment in AcpiExAllocateNameString() + */ + AmlAddress++; + PrefixCount = ACPI_UINT32_MAX; + HasPrefix = TRUE; + break; + + + case AML_PARENT_PREFIX: + + /* Increment past possibly multiple parent prefixes */ + + do + { + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", + AmlAddress)); + + AmlAddress++; + PrefixCount++; + + } while (*AmlAddress == AML_PARENT_PREFIX); + + HasPrefix = TRUE; + break; + + + default: + + /* Not a prefix character */ + + break; + } + + /* Examine first character of name for name segment prefix operator */ + + switch (*AmlAddress) + { + case AML_DUAL_NAME_PREFIX: + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", + AmlAddress)); + + AmlAddress++; + NameString = AcpiExAllocateNameString (PrefixCount, 2); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + + HasPrefix = TRUE; + + Status = AcpiExNameSegment (&AmlAddress, NameString); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiExNameSegment (&AmlAddress, NameString); + } + break; + + + case AML_MULTI_NAME_PREFIX_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", + AmlAddress)); + + /* Fetch count of segments remaining in name path */ + + AmlAddress++; + NumSegments = *AmlAddress; + + NameString = AcpiExAllocateNameString (PrefixCount, NumSegments); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + + AmlAddress++; + HasPrefix = TRUE; + + while (NumSegments && + (Status = AcpiExNameSegment (&AmlAddress, NameString)) == + AE_OK) + { + NumSegments--; + } + + break; + + + case 0: + + /* NullName valid as of 8-12-98 ASL/AML Grammar Update */ + + if (PrefixCount == ACPI_UINT32_MAX) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "NameSeg is \"\\\" followed by NULL\n")); + } + + /* Consume the NULL byte */ + + AmlAddress++; + NameString = AcpiExAllocateNameString (PrefixCount, 0); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + break; + + + default: + + /* Name segment string */ + + NameString = AcpiExAllocateNameString (PrefixCount, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + Status = AcpiExNameSegment (&AmlAddress, NameString); + break; + } + } + + if (AE_CTRL_PENDING == Status && HasPrefix) + { + /* Ran out of segments after processing a prefix */ + + ACPI_ERROR ((AE_INFO, + "Malformed Name at %p", NameString)); + Status = AE_AML_BAD_NAME; + } + + if (ACPI_FAILURE (Status)) + { + if (NameString) + { + ACPI_FREE (NameString); + } + return_ACPI_STATUS (Status); + } + + *OutNameString = NameString; + *OutNameLength = (UINT32) (AmlAddress - InAmlAddress); + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exoparg1.c b/drivers/bus/acpi/acpica/executer/exoparg1.c new file mode 100644 index 00000000000..4a90b9c9506 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exoparg1.c @@ -0,0 +1,1183 @@ + +/****************************************************************************** + * + * Module Name: exoparg1 - AML execution - opcodes with 1 argument + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXOPARG1_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg1") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (0 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_0A_0T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute operator with no operands, one return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_TIMER_OP: /* Timer () */ + + /* Create a return object of type Integer */ + + ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ()); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + +Cleanup: + + /* Delete return object on error */ + + if ((ACPI_FAILURE (Status)) || WalkState->ResultObj) + { + AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; + } + else + { + /* Save the return value */ + + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_0T_0R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on + * object stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_0T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_RELEASE_OP: /* Release (MutexObject) */ + + Status = AcpiExReleaseMutex (Operand[0], WalkState); + break; + + + case AML_RESET_OP: /* Reset (EventObject) */ + + Status = AcpiExSystemResetEvent (Operand[0]); + break; + + + case AML_SIGNAL_OP: /* Signal (EventObject) */ + + Status = AcpiExSystemSignalEvent (Operand[0]); + break; + + + case AML_SLEEP_OP: /* Sleep (MsecTime) */ + + Status = AcpiExSystemDoSuspend (Operand[0]->Integer.Value); + break; + + + case AML_STALL_OP: /* Stall (UsecTime) */ + + Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value); + break; + + + case AML_UNLOAD_OP: /* Unload (Handle) */ + + Status = AcpiExUnloadTable (Operand[0]); + break; + + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_1T_0R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, one target, and no + * return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_1T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_LOAD_OP: + + Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState); + break; + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_1T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, one target, and a + * return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; + UINT32 Temp32; + UINT32 i; + ACPI_INTEGER PowerOfTen; + ACPI_INTEGER Digit; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_BIT_NOT_OP: + case AML_FIND_SET_LEFT_BIT_OP: + case AML_FIND_SET_RIGHT_BIT_OP: + case AML_FROM_BCD_OP: + case AML_TO_BCD_OP: + case AML_COND_REF_OF_OP: + + /* Create a return object of type Integer for these opcodes */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + switch (WalkState->Opcode) + { + case AML_BIT_NOT_OP: /* Not (Operand, Result) */ + + ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value; + break; + + + case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */ + + ReturnDesc->Integer.Value = Operand[0]->Integer.Value; + + /* + * Acpi specification describes Integer type as a little + * endian unsigned value, so this boundary condition is valid. + */ + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + { + ReturnDesc->Integer.Value >>= 1; + } + + ReturnDesc->Integer.Value = Temp32; + break; + + + case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ + + ReturnDesc->Integer.Value = Operand[0]->Integer.Value; + + /* + * The Acpi specification describes Integer type as a little + * endian unsigned value, so this boundary condition is valid. + */ + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + { + ReturnDesc->Integer.Value <<= 1; + } + + /* Since the bit position is one-based, subtract from 33 (65) */ + + ReturnDesc->Integer.Value = + Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; + break; + + + case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */ + + /* + * The 64-bit ACPI integer can hold 16 4-bit BCD characters + * (if table is 32-bit, integer can hold 8 BCD characters) + * Convert each 4-bit BCD value + */ + PowerOfTen = 1; + ReturnDesc->Integer.Value = 0; + Digit = Operand[0]->Integer.Value; + + /* Convert each BCD digit (each is one nybble wide) */ + + for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) + { + /* Get the least significant 4-bit BCD digit */ + + Temp32 = ((UINT32) Digit) & 0xF; + + /* Check the range of the digit */ + + if (Temp32 > 9) + { + ACPI_ERROR ((AE_INFO, + "BCD digit too large (not decimal): 0x%X", + Temp32)); + + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + /* Sum the digit into the result with the current power of 10 */ + + ReturnDesc->Integer.Value += + (((ACPI_INTEGER) Temp32) * PowerOfTen); + + /* Shift to next BCD digit */ + + Digit >>= 4; + + /* Next power of 10 */ + + PowerOfTen *= 10; + } + break; + + + case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */ + + ReturnDesc->Integer.Value = 0; + Digit = Operand[0]->Integer.Value; + + /* Each BCD digit is one nybble wide */ + + for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) + { + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32); + + /* + * Insert the BCD digit that resides in the + * remainder from above + */ + ReturnDesc->Integer.Value |= + (((ACPI_INTEGER) Temp32) << ACPI_MUL_4 (i)); + } + + /* Overflow if there is any data left in Digit */ + + if (Digit > 0) + { + ACPI_ERROR ((AE_INFO, + "Integer too large to convert to BCD: %8.8X%8.8X", + ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value))); + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + break; + + + case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */ + + /* + * This op is a little strange because the internal return value is + * different than the return value stored in the result descriptor + * (There are really two return values) + */ + if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode) + { + /* + * This means that the object does not exist in the namespace, + * return FALSE + */ + ReturnDesc->Integer.Value = 0; + goto Cleanup; + } + + /* Get the object reference, store it, and remove our reference */ + + Status = AcpiExGetObjectReference (Operand[0], + &ReturnDesc2, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState); + AcpiUtRemoveReference (ReturnDesc2); + + /* The object exists in the namespace, return TRUE */ + + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + goto Cleanup; + + + default: + /* No other opcodes get here */ + break; + } + break; + + + case AML_STORE_OP: /* Store (Source, Target) */ + + /* + * A store operand is typically a number, string, buffer or lvalue + * Be careful about deleting the source object, + * since the object itself may have been stored. + */ + Status = AcpiExStore (Operand[0], Operand[1], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* It is possible that the Store already produced a return object */ + + if (!WalkState->ResultObj) + { + /* + * Normally, we would remove a reference on the Operand[0] + * parameter; But since it is being used as the internal return + * object (meaning we would normally increment it), the two + * cancel out, and we simply don't do anything. + */ + WalkState->ResultObj = Operand[0]; + WalkState->Operands[0] = NULL; /* Prevent deletion */ + } + return_ACPI_STATUS (Status); + + + /* + * ACPI 2.0 Opcodes + */ + case AML_COPY_OP: /* Copy (Source, Target) */ + + Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, + WalkState); + break; + + + case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */ + + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_DECIMAL); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */ + + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_HEX); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ + + Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ + + Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, + ACPI_ANY_BASE); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ + case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ + + /* These are two obsolete opcodes */ + + ACPI_ERROR ((AE_INFO, + "%s is obsolete and not implemented", + AcpiPsGetOpcodeName (WalkState->Opcode))); + Status = AE_SUPPORT; + goto Cleanup; + + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + if (ACPI_SUCCESS (Status)) + { + /* Store the return value computed above into the target object */ + + Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_0T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *TempDesc; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + UINT32 Type; + ACPI_INTEGER Value; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_LNOT_OP: /* LNot (Operand) */ + + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Set result to ONES (TRUE) if Value == 0. Note: + * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above. + */ + if (!Operand[0]->Integer.Value) + { + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + } + break; + + + case AML_DECREMENT_OP: /* Decrement (Operand) */ + case AML_INCREMENT_OP: /* Increment (Operand) */ + + /* + * Create a new integer. Can't just get the base integer and + * increment it because it may be an Arg or Field. + */ + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Since we are expecting a Reference operand, it can be either a + * NS Node or an internal object. + */ + TempDesc = Operand[0]; + if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND) + { + /* Internal reference object - prevent deletion */ + + AcpiUtAddReference (TempDesc); + } + + /* + * Convert the Reference operand to an Integer (This removes a + * reference on the Operand[0] object) + * + * NOTE: We use LNOT_OP here in order to force resolution of the + * reference operand to an actual integer. + */ + Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While resolving operands for [%s]", + AcpiPsGetOpcodeName (WalkState->Opcode))); + + goto Cleanup; + } + + /* + * TempDesc is now guaranteed to be an Integer object -- + * Perform the actual increment or decrement + */ + if (WalkState->Opcode == AML_INCREMENT_OP) + { + ReturnDesc->Integer.Value = TempDesc->Integer.Value +1; + } + else + { + ReturnDesc->Integer.Value = TempDesc->Integer.Value -1; + } + + /* Finished with this Integer object */ + + AcpiUtRemoveReference (TempDesc); + + /* + * Store the result back (indirectly) through the original + * Reference object + */ + Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); + break; + + + case AML_TYPE_OP: /* ObjectType (SourceObject) */ + + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. For example, we don't + * want to resolve a FieldUnit to its value, we want the actual + * FieldUnit object. + */ + + /* Get the type of the base object */ + + Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Allocate a descriptor to hold the type. */ + + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + + case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */ + + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. + */ + + /* Get the base object */ + + Status = AcpiExResolveMultiple (WalkState, + Operand[0], &Type, &TempDesc); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * The type of the base object must be integer, buffer, string, or + * package. All others are not supported. + * + * NOTE: Integer is not specifically supported by the ACPI spec, + * but is supported implicitly via implicit operand conversion. + * rather than bother with conversion, we just use the byte width + * global (4 or 8 bytes). + */ + switch (Type) + { + case ACPI_TYPE_INTEGER: + Value = AcpiGbl_IntegerByteWidth; + break; + + case ACPI_TYPE_STRING: + Value = TempDesc->String.Length; + break; + + case ACPI_TYPE_BUFFER: + + /* Buffer arguments may not be evaluated at this point */ + + Status = AcpiDsGetBufferArguments (TempDesc); + Value = TempDesc->Buffer.Length; + break; + + case ACPI_TYPE_PACKAGE: + + /* Package arguments may not be evaluated at this point */ + + Status = AcpiDsGetPackageArguments (TempDesc); + Value = TempDesc->Package.Count; + break; + + default: + ACPI_ERROR ((AE_INFO, + "Operand must be Buffer/Integer/String/Package - found type %s", + AcpiUtGetTypeName (Type))); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Now that we have the size of the object, create a result + * object to hold the value + */ + ReturnDesc = AcpiUtCreateIntegerObject (Value); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + + case AML_REF_OF_OP: /* RefOf (SourceObject) */ + + Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + break; + + + case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */ + + /* Check for a method local or argument, or standalone String */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) + { + TempDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) Operand[0]); + if (TempDesc && + ((TempDesc->Common.Type == ACPI_TYPE_STRING) || + (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE))) + { + Operand[0] = TempDesc; + AcpiUtAddReference (TempDesc); + } + else + { + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + else + { + switch ((Operand[0])->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * This is a DerefOf (LocalX | ArgX) + * + * Must resolve/dereference the local/arg reference first + */ + switch (Operand[0]->Reference.Class) + { + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + /* Set Operand[0] to the value of the local/arg */ + + Status = AcpiDsMethodDataGetValue ( + Operand[0]->Reference.Class, + Operand[0]->Reference.Value, + WalkState, &TempDesc); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Delete our reference to the input object and + * point to the object just retrieved + */ + AcpiUtRemoveReference (Operand[0]); + Operand[0] = TempDesc; + break; + + case ACPI_REFCLASS_REFOF: + + /* Get the object to which the reference refers */ + + TempDesc = Operand[0]->Reference.Object; + AcpiUtRemoveReference (Operand[0]); + Operand[0] = TempDesc; + break; + + default: + + /* Must be an Index op - handled below */ + break; + } + break; + + case ACPI_TYPE_STRING: + break; + + default: + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED) + { + if ((Operand[0])->Common.Type == ACPI_TYPE_STRING) + { + /* + * This is a DerefOf (String). The string is a reference + * to a named ACPI object. + * + * 1) Find the owning Node + * 2) Dereference the node to an actual object. Could be a + * Field, so we need to resolve the node to a value. + */ + Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node, + Operand[0]->String.Pointer, + ACPI_NS_SEARCH_PARENT, + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc)); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc), + WalkState); + goto Cleanup; + } + } + + /* Operand[0] may have changed from the code above */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) + { + /* + * This is a DerefOf (ObjectReference) + * Get the actual object from the Node (This is the dereference). + * This case may only happen when a LocalX or ArgX is + * dereferenced above. + */ + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) Operand[0]); + AcpiUtAddReference (ReturnDesc); + } + else + { + /* + * This must be a reference object produced by either the + * Index() or RefOf() operator + */ + switch (Operand[0]->Reference.Class) + { + case ACPI_REFCLASS_INDEX: + + /* + * The target type for the Index operator must be + * either a Buffer or a Package + */ + switch (Operand[0]->Reference.TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + + TempDesc = Operand[0]->Reference.Object; + + /* + * Create a new object that contains one element of the + * buffer -- the element pointed to by the index. + * + * NOTE: index into a buffer is NOT a pointer to a + * sub-buffer of the main buffer, it is only a pointer to a + * single element (byte) of the buffer! + * + * Since we are returning the value of the buffer at the + * indexed location, we don't need to add an additional + * reference to the buffer itself. + */ + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) + TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * Return the referenced element of the package. We must + * add another reference to the referenced object, however. + */ + ReturnDesc = *(Operand[0]->Reference.Where); + if (ReturnDesc) + { + AcpiUtAddReference (ReturnDesc); + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Index TargetType %X in reference object %p", + Operand[0]->Reference.TargetType, Operand[0])); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ACPI_REFCLASS_REFOF: + + ReturnDesc = Operand[0]->Reference.Object; + + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == + ACPI_DESC_TYPE_NAMED) + { + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ReturnDesc); + } + + /* Add another reference to the object! */ + + AcpiUtAddReference (ReturnDesc); + break; + + + default: + ACPI_ERROR ((AE_INFO, + "Unknown class in reference(%p) - %2.2X", + Operand[0], Operand[0]->Reference.Class)); + + Status = AE_TYPE; + goto Cleanup; + } + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + diff --git a/drivers/bus/acpi/acpica/executer/exoparg2.c b/drivers/bus/acpi/acpica/executer/exoparg2.c new file mode 100644 index 00000000000..7c42652cc4c --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exoparg2.c @@ -0,0 +1,741 @@ +/****************************************************************************** + * + * Module Name: exoparg2 - AML execution - opcodes with 2 arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXOPARG2_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acinterp.h" +#include "acevents.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg2") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_0T_0R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with two arguments, no target, and no return + * value. + * + * ALLOCATION: Deletes both operands + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_0T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_NAMESPACE_NODE *Node; + UINT32 Value; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the opcode */ + + switch (WalkState->Opcode) + { + case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */ + + /* The first operand is a namespace node */ + + Node = (ACPI_NAMESPACE_NODE *) Operand[0]; + + /* Second value is the notify value */ + + Value = (UINT32) Operand[1]->Integer.Value; + + /* Are notifies allowed on this object? */ + + if (!AcpiEvIsNotifyObject (Node)) + { + ACPI_ERROR ((AE_INFO, + "Unexpected notify object type [%s]", + AcpiUtGetTypeName (Node->Type))); + + Status = AE_AML_OPERAND_TYPE; + break; + } + +#ifdef ACPI_GPE_NOTIFY_CHECK + /* + * GPE method wake/notify check. Here, we want to ensure that we + * don't receive any "DeviceWake" Notifies from a GPE _Lxx or _Exx + * GPE method during system runtime. If we do, the GPE is marked + * as "wake-only" and disabled. + * + * 1) Is the Notify() value == DeviceWake? + * 2) Is this a GPE deferred method? (An _Lxx or _Exx method) + * 3) Did the original GPE happen at system runtime? + * (versus during wake) + * + * If all three cases are true, this is a wake-only GPE that should + * be disabled at runtime. + */ + if (Value == 2) /* DeviceWake */ + { + Status = AcpiEvCheckForWakeOnlyGpe (WalkState->GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + /* AE_WAKE_ONLY_GPE only error, means ignore this notify */ + + return_ACPI_STATUS (AE_OK) + } + } +#endif + + /* + * Dispatch the notify to the appropriate handler + * NOTE: the request is queued for execution after this method + * completes. The notify handlers are NOT invoked synchronously + * from this thread -- because handlers may in turn run other + * control methods. + */ + Status = AcpiEvQueueNotifyRequest (Node, Value); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_2T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets + * and one implicit return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_2T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Execute the opcode */ + + switch (WalkState->Opcode) + { + case AML_DIVIDE_OP: + + /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */ + + ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc1) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc2) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */ + + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + &ReturnDesc1->Integer.Value, + &ReturnDesc2->Integer.Value); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* Store the results to the target reference operands */ + + Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + +Cleanup: + /* + * Since the remainder is not returned indirectly, remove a reference to + * it. Only the quotient is returned indirectly. + */ + AcpiUtRemoveReference (ReturnDesc2); + + if (ACPI_FAILURE (Status)) + { + /* Delete the return object */ + + AcpiUtRemoveReference (ReturnDesc1); + } + + /* Save return object (the remainder) on success */ + + else + { + WalkState->ResultObj = ReturnDesc1; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_1T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with two arguments, one target, and a return + * value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_INTEGER Index; + ACPI_STATUS Status = AE_OK; + ACPI_SIZE Length; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Execute the opcode */ + + if (WalkState->OpInfo->Flags & AML_MATH) + { + /* All simple math opcodes (add, etc.) */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode, + Operand[0]->Integer.Value, + Operand[1]->Integer.Value); + goto StoreResultToTarget; + } + + switch (WalkState->Opcode) + { + case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* ReturnDesc will contain the remainder */ + + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + NULL, + &ReturnDesc->Integer.Value); + break; + + + case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ + + Status = AcpiExDoConcatenate (Operand[0], Operand[1], + &ReturnDesc, WalkState); + break; + + + case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ + + /* + * Input object is guaranteed to be a buffer at this point (it may have + * been converted.) Copy the raw buffer data to a new object of + * type String. + */ + + /* + * Get the length of the new string. It is the smallest of: + * 1) Length of the input buffer + * 2) Max length as specified in the ToString operator + * 3) Length of input buffer up to a zero byte (null terminator) + * + * NOTE: A length of zero is ok, and will create a zero-length, null + * terminated string. + */ + Length = 0; + while ((Length < Operand[0]->Buffer.Length) && + (Length < Operand[1]->Integer.Value) && + (Operand[0]->Buffer.Pointer[Length])) + { + Length++; + } + + /* Allocate a new string object */ + + ReturnDesc = AcpiUtCreateStringObject (Length); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Copy the raw buffer data with no transform. + * (NULL terminated already) + */ + ACPI_MEMCPY (ReturnDesc->String.Pointer, + Operand[0]->Buffer.Pointer, Length); + break; + + + case AML_CONCAT_RES_OP: + + /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ + + Status = AcpiExConcatTemplate (Operand[0], Operand[1], + &ReturnDesc, WalkState); + break; + + + case AML_INDEX_OP: /* Index (Source Index Result) */ + + /* Create the internal return object */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Initialize the Index reference object */ + + Index = Operand[1]->Integer.Value; + ReturnDesc->Reference.Value = (UINT32) Index; + ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX; + + /* + * At this point, the Source operand is a String, Buffer, or Package. + * Verify that the index is within range. + */ + switch ((Operand[0])->Common.Type) + { + case ACPI_TYPE_STRING: + + if (Index >= Operand[0]->String.Length) + { + Status = AE_AML_STRING_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + break; + + case ACPI_TYPE_BUFFER: + + if (Index >= Operand[0]->Buffer.Length) + { + Status = AE_AML_BUFFER_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + break; + + case ACPI_TYPE_PACKAGE: + + if (Index >= Operand[0]->Package.Count) + { + Status = AE_AML_PACKAGE_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; + ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index]; + break; + + default: + + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + /* Failure means that the Index was beyond the end of the object */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Index (%X%8.8X) is beyond end of object", + ACPI_FORMAT_UINT64 (Index))); + goto Cleanup; + } + + /* + * Save the target object and add a reference to it for the life + * of the index + */ + ReturnDesc->Reference.Object = Operand[0]; + AcpiUtAddReference (Operand[0]); + + /* Store the reference to the Target */ + + Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); + + /* Return the reference */ + + WalkState->ResultObj = ReturnDesc; + goto Cleanup; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + + +StoreResultToTarget: + + if (ACPI_SUCCESS (Status)) + { + /* + * Store the result of the operation (which is now in ReturnDesc) into + * the Target descriptor. + */ + Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_0T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + BOOLEAN LogicalResult = FALSE; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Create the internal return object */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Execute the Opcode */ + + if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC) + { + /* LogicalOp (Operand0, Operand1) */ + + Status = AcpiExDoLogicalNumericOp (WalkState->Opcode, + Operand[0]->Integer.Value, Operand[1]->Integer.Value, + &LogicalResult); + goto StoreLogicalResult; + } + else if (WalkState->OpInfo->Flags & AML_LOGICAL) + { + /* LogicalOp (Operand0, Operand1) */ + + Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0], + Operand[1], &LogicalResult); + goto StoreLogicalResult; + } + + switch (WalkState->Opcode) + { + case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */ + + Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState); + if (Status == AE_TIME) + { + LogicalResult = TRUE; /* TRUE = Acquire timed out */ + Status = AE_OK; + } + break; + + + case AML_WAIT_OP: /* Wait (EventObject, Timeout) */ + + Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]); + if (Status == AE_TIME) + { + LogicalResult = TRUE; /* TRUE, Wait timed out */ + Status = AE_OK; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +StoreLogicalResult: + /* + * Set return value to according to LogicalResult. logical TRUE (all ones) + * Default is FALSE (zero) + */ + if (LogicalResult) + { + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + } + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exoparg3.c b/drivers/bus/acpi/acpica/executer/exoparg3.c new file mode 100644 index 00000000000..591d6aceb12 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exoparg3.c @@ -0,0 +1,377 @@ + +/****************************************************************************** + * + * Module Name: exoparg3 - AML execution - opcodes with 3 arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXOPARG3_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg3") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_3A_0T_0R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute Triadic operator (3 operands) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_3A_0T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_SIGNAL_FATAL_INFO *Fatal; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + switch (WalkState->Opcode) + { + case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + (UINT32) Operand[0]->Integer.Value, + (UINT32) Operand[1]->Integer.Value, + (UINT32) Operand[2]->Integer.Value)); + + Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); + if (Fatal) + { + Fatal->Type = (UINT32) Operand[0]->Integer.Value; + Fatal->Code = (UINT32) Operand[1]->Integer.Value; + Fatal->Argument = (UINT32) Operand[2]->Integer.Value; + } + + /* Always signal the OS! */ + + Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); + + /* Might return while OS is shutting down, just continue */ + + ACPI_FREE (Fatal); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_3A_1T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute Triadic operator (3 operands) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_3A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + char *Buffer = NULL; + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Index; + ACPI_SIZE Length; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + switch (WalkState->Opcode) + { + case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ + + /* + * Create the return object. The Source operand is guaranteed to be + * either a String or a Buffer, so just use its type. + */ + ReturnDesc = AcpiUtCreateInternalObject ( + (Operand[0])->Common.Type); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the Integer values from the objects */ + + Index = Operand[1]->Integer.Value; + Length = (ACPI_SIZE) Operand[2]->Integer.Value; + + /* + * If the index is beyond the length of the String/Buffer, or if the + * requested length is zero, return a zero-length String/Buffer + */ + if (Index >= Operand[0]->String.Length) + { + Length = 0; + } + + /* Truncate request if larger than the actual String/Buffer */ + + else if ((Index + Length) > Operand[0]->String.Length) + { + Length = (ACPI_SIZE) Operand[0]->String.Length - + (ACPI_SIZE) Index; + } + + /* Strings always have a sub-pointer, not so for buffers */ + + switch ((Operand[0])->Common.Type) + { + case ACPI_TYPE_STRING: + + /* Always allocate a new buffer for the String */ + + Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1); + if (!Buffer) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + case ACPI_TYPE_BUFFER: + + /* If the requested length is zero, don't allocate a buffer */ + + if (Length > 0) + { + /* Allocate a new buffer for the Buffer */ + + Buffer = ACPI_ALLOCATE_ZEROED (Length); + if (!Buffer) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + } + break; + + default: /* Should not happen */ + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (Buffer) + { + /* We have a buffer, copy the portion requested */ + + ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index, + Length); + } + + /* Set the length of the new String/Buffer */ + + ReturnDesc->String.Pointer = Buffer; + ReturnDesc->String.Length = (UINT32) Length; + + /* Mark buffer initialized */ + + ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* Store the result in the target */ + + Status = AcpiExStore (ReturnDesc, Operand[3], WalkState); + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) || WalkState->ResultObj) + { + AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; + } + + /* Set the return object and exit */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exoparg6.c b/drivers/bus/acpi/acpica/executer/exoparg6.c new file mode 100644 index 00000000000..c2609471dd7 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exoparg6.c @@ -0,0 +1,438 @@ + +/****************************************************************************** + * + * Module Name: exoparg6 - AML execution - opcodes with 6 arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXOPARG6_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg6") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + +/* Local prototypes */ + +static BOOLEAN +AcpiExDoMatch ( + UINT32 MatchOp, + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoMatch + * + * PARAMETERS: MatchOp - The AML match operand + * PackageObj - Object from the target package + * MatchObj - Object to be matched + * + * RETURN: TRUE if the match is successful, FALSE otherwise + * + * DESCRIPTION: Implements the low-level match for the ASL Match operator. + * Package elements will be implicitly converted to the type of + * the match object (Integer/Buffer/String). + * + ******************************************************************************/ + +static BOOLEAN +AcpiExDoMatch ( + UINT32 MatchOp, + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj) +{ + BOOLEAN LogicalResult = TRUE; + ACPI_STATUS Status; + + + /* + * Note: Since the PackageObj/MatchObj ordering is opposite to that of + * the standard logical operators, we have to reverse them when we call + * DoLogicalOp in order to make the implicit conversion rules work + * correctly. However, this means we have to flip the entire equation + * also. A bit ugly perhaps, but overall, better than fussing the + * parameters around at runtime, over and over again. + * + * Below, P[i] refers to the package element, M refers to the Match object. + */ + switch (MatchOp) + { + case MATCH_MTR: + + /* Always true */ + + break; + + case MATCH_MEQ: + + /* + * True if equal: (P[i] == M) + * Change to: (M == P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + break; + + case MATCH_MLE: + + /* + * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M) + * Change to: (M >= P[i]) (M NotLess than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + LogicalResult = (BOOLEAN) !LogicalResult; + break; + + case MATCH_MLT: + + /* + * True if less than: (P[i] < M) + * Change to: (M > P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + break; + + case MATCH_MGE: + + /* + * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M) + * Change to: (M <= P[i]) (M NotGreater than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + LogicalResult = (BOOLEAN)!LogicalResult; + break; + + case MATCH_MGT: + + /* + * True if greater than: (P[i] > M) + * Change to: (M < P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + break; + + default: + + /* Undefined */ + + return (FALSE); + } + + return LogicalResult; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_6A_0T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_6A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Index; + ACPI_OPERAND_OBJECT *ThisElement; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + switch (WalkState->Opcode) + { + case AML_MATCH_OP: + /* + * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2], + * MatchOp2[3], MatchObj2[4], StartIndex[5]) + */ + + /* Validate both Match Term Operators (MTR, MEQ, etc.) */ + + if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) || + (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR)) + { + ACPI_ERROR ((AE_INFO, "Match operator out of range")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + + /* Get the package StartIndex, validate against the package length */ + + Index = Operand[5]->Integer.Value; + if (Index >= Operand[0]->Package.Count) + { + ACPI_ERROR ((AE_INFO, + "Index (%X%8.8X) beyond package end (%X)", + ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); + Status = AE_AML_PACKAGE_LIMIT; + goto Cleanup; + } + + /* Create an integer for the return value */ + /* Default return value is ACPI_INTEGER_MAX if no match found */ + + ReturnDesc = AcpiUtCreateIntegerObject (ACPI_INTEGER_MAX); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + + } + + /* + * Examine each element until a match is found. Both match conditions + * must be satisfied for a match to occur. Within the loop, + * "continue" signifies that the current element does not match + * and the next should be examined. + * + * Upon finding a match, the loop will terminate via "break" at + * the bottom. If it terminates "normally", MatchValue will be + * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no + * match was found. + */ + for ( ; Index < Operand[0]->Package.Count; Index++) + { + /* Get the current package element */ + + ThisElement = Operand[0]->Package.Elements[Index]; + + /* Treat any uninitialized (NULL) elements as non-matching */ + + if (!ThisElement) + { + continue; + } + + /* + * Both match conditions must be satisfied. Execution of a continue + * (proceed to next iteration of enclosing for loop) signifies a + * non-match. + */ + if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, + ThisElement, Operand[2])) + { + continue; + } + + if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, + ThisElement, Operand[4])) + { + continue; + } + + /* Match found: Index is the return value */ + + ReturnDesc->Integer.Value = Index; + break; + } + break; + + + case AML_LOAD_TABLE_OP: + + Status = AcpiExLoadTableOp (WalkState, &ReturnDesc); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} diff --git a/drivers/bus/acpi/acpica/executer/exprep.c b/drivers/bus/acpi/acpica/executer/exprep.c new file mode 100644 index 00000000000..c915361e810 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exprep.c @@ -0,0 +1,686 @@ + +/****************************************************************************** + * + * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXPREP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exprep") + +/* Local prototypes */ + +static UINT32 +AcpiExDecodeFieldAccess ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT32 *ReturnByteAlignment); + + +#ifdef ACPI_UNDER_DEVELOPMENT + +static UINT32 +AcpiExGenerateAccess ( + UINT32 FieldBitOffset, + UINT32 FieldBitLength, + UINT32 RegionLength); + +/******************************************************************************* + * + * FUNCTION: AcpiExGenerateAccess + * + * PARAMETERS: FieldBitOffset - Start of field within parent region/buffer + * FieldBitLength - Length of field in bits + * RegionLength - Length of parent in bytes + * + * RETURN: Field granularity (8, 16, 32 or 64) and + * ByteAlignment (1, 2, 3, or 4) + * + * DESCRIPTION: Generate an optimal access width for fields defined with the + * AnyAcc keyword. + * + * NOTE: Need to have the RegionLength in order to check for boundary + * conditions (end-of-region). However, the RegionLength is a deferred + * operation. Therefore, to complete this implementation, the generation + * of this access width must be deferred until the region length has + * been evaluated. + * + ******************************************************************************/ + +static UINT32 +AcpiExGenerateAccess ( + UINT32 FieldBitOffset, + UINT32 FieldBitLength, + UINT32 RegionLength) +{ + UINT32 FieldByteLength; + UINT32 FieldByteOffset; + UINT32 FieldByteEndOffset; + UINT32 AccessByteWidth; + UINT32 FieldStartOffset; + UINT32 FieldEndOffset; + UINT32 MinimumAccessWidth = 0xFFFFFFFF; + UINT32 MinimumAccesses = 0xFFFFFFFF; + UINT32 Accesses; + + + ACPI_FUNCTION_TRACE (ExGenerateAccess); + + + /* Round Field start offset and length to "minimal" byte boundaries */ + + FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8)); + FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + + FieldBitOffset, 8)); + FieldByteLength = FieldByteEndOffset - FieldByteOffset; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Bit length %d, Bit offset %d\n", + FieldBitLength, FieldBitOffset)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Byte Length %d, Byte Offset %d, End Offset %d\n", + FieldByteLength, FieldByteOffset, FieldByteEndOffset)); + + /* + * Iterative search for the maximum access width that is both aligned + * and does not go beyond the end of the region + * + * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes) + */ + for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1) + { + /* + * 1) Round end offset up to next access boundary and make sure that + * this does not go beyond the end of the parent region. + * 2) When the Access width is greater than the FieldByteLength, we + * are done. (This does not optimize for the perfectly aligned + * case yet). + */ + if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength) + { + FieldStartOffset = + ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / + AccessByteWidth; + + FieldEndOffset = + ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), + AccessByteWidth) / AccessByteWidth; + + Accesses = FieldEndOffset - FieldStartOffset; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "AccessWidth %d end is within region\n", AccessByteWidth)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Field Start %d, Field End %d -- requires %d accesses\n", + FieldStartOffset, FieldEndOffset, Accesses)); + + /* Single access is optimal */ + + if (Accesses <= 1) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Entire field can be accessed with one operation of size %d\n", + AccessByteWidth)); + return_VALUE (AccessByteWidth); + } + + /* + * Fits in the region, but requires more than one read/write. + * try the next wider access on next iteration + */ + if (Accesses < MinimumAccesses) + { + MinimumAccesses = Accesses; + MinimumAccessWidth = AccessByteWidth; + } + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "AccessWidth %d end is NOT within region\n", AccessByteWidth)); + if (AccessByteWidth == 1) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Field goes beyond end-of-region!\n")); + + /* Field does not fit in the region at all */ + + return_VALUE (0); + } + + /* + * This width goes beyond the end-of-region, back off to + * previous access + */ + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Backing off to previous optimal access width of %d\n", + MinimumAccessWidth)); + return_VALUE (MinimumAccessWidth); + } + } + + /* + * Could not read/write field with one operation, + * just use max access width + */ + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Cannot access field in one operation, using width 8\n")); + return_VALUE (8); +} +#endif /* ACPI_UNDER_DEVELOPMENT */ + + +/******************************************************************************* + * + * FUNCTION: AcpiExDecodeFieldAccess + * + * PARAMETERS: ObjDesc - Field object + * FieldFlags - Encoded fieldflags (contains access bits) + * ReturnByteAlignment - Where the byte alignment is returned + * + * RETURN: Field granularity (8, 16, 32 or 64) and + * ByteAlignment (1, 2, 3, or 4) + * + * DESCRIPTION: Decode the AccessType bits of a field definition. + * + ******************************************************************************/ + +static UINT32 +AcpiExDecodeFieldAccess ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT32 *ReturnByteAlignment) +{ + UINT32 Access; + UINT32 ByteAlignment; + UINT32 BitLength; + + + ACPI_FUNCTION_TRACE (ExDecodeFieldAccess); + + + Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK); + + switch (Access) + { + case AML_FIELD_ACCESS_ANY: + +#ifdef ACPI_UNDER_DEVELOPMENT + ByteAlignment = + AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */); + BitLength = ByteAlignment * 8; +#endif + + ByteAlignment = 1; + BitLength = 8; + break; + + case AML_FIELD_ACCESS_BYTE: + case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ + ByteAlignment = 1; + BitLength = 8; + break; + + case AML_FIELD_ACCESS_WORD: + ByteAlignment = 2; + BitLength = 16; + break; + + case AML_FIELD_ACCESS_DWORD: + ByteAlignment = 4; + BitLength = 32; + break; + + case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ + ByteAlignment = 8; + BitLength = 64; + break; + + default: + /* Invalid field access type */ + + ACPI_ERROR ((AE_INFO, + "Unknown field access type %X", + Access)); + return_UINT32 (0); + } + + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) + { + /* + * BufferField access can be on any byte boundary, so the + * ByteAlignment is always 1 byte -- regardless of any ByteAlignment + * implied by the field access type. + */ + ByteAlignment = 1; + } + + *ReturnByteAlignment = ByteAlignment; + return_UINT32 (BitLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPrepCommonFieldObject + * + * PARAMETERS: ObjDesc - The field object + * FieldFlags - Access, LockRule, and UpdateRule. + * The format of a FieldFlag is described + * in the ACPI specification + * FieldAttribute - Special attributes (not used) + * FieldBitPosition - Field start position + * FieldBitLength - Field length in number of bits + * + * RETURN: Status + * + * DESCRIPTION: Initialize the areas of the field object that are common + * to the various types of fields. Note: This is very "sensitive" + * code because we are solving the general case for field + * alignment. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPrepCommonFieldObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldBitPosition, + UINT32 FieldBitLength) +{ + UINT32 AccessBitWidth; + UINT32 ByteAlignment; + UINT32 NearestByteAddress; + + + ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject); + + + /* + * Note: the structure being initialized is the + * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common + * area are initialized by this procedure. + */ + ObjDesc->CommonField.FieldFlags = FieldFlags; + ObjDesc->CommonField.Attribute = FieldAttribute; + ObjDesc->CommonField.BitLength = FieldBitLength; + + /* + * Decode the access type so we can compute offsets. The access type gives + * two pieces of information - the width of each field access and the + * necessary ByteAlignment (address granularity) of the access. + * + * For AnyAcc, the AccessBitWidth is the largest width that is both + * necessary and possible in an attempt to access the whole field in one + * I/O operation. However, for AnyAcc, the ByteAlignment is always one + * byte. + * + * For all Buffer Fields, the ByteAlignment is always one byte. + * + * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is + * the same (equivalent) as the ByteAlignment. + */ + AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags, + &ByteAlignment); + if (!AccessBitWidth) + { + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + /* Setup width (access granularity) fields */ + + ObjDesc->CommonField.AccessByteWidth = (UINT8) + ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */ + + ObjDesc->CommonField.AccessBitWidth = (UINT8) AccessBitWidth; + + /* + * BaseByteOffset is the address of the start of the field within the + * region. It is the byte address of the first *datum* (field-width data + * unit) of the field. (i.e., the first datum that contains at least the + * first *bit* of the field.) + * + * Note: ByteAlignment is always either equal to the AccessBitWidth or 8 + * (Byte access), and it defines the addressing granularity of the parent + * region or buffer. + */ + NearestByteAddress = + ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition); + ObjDesc->CommonField.BaseByteOffset = (UINT32) + ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment); + + /* + * StartFieldBitOffset is the offset of the first bit of the field within + * a field datum. + */ + ObjDesc->CommonField.StartFieldBitOffset = (UINT8) + (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset)); + + /* + * Does the entire field fit within a single field access element? (datum) + * (i.e., without crossing a datum boundary) + */ + if ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) <= + (UINT16) AccessBitWidth) + { + ObjDesc->Common.Flags |= AOPOBJ_SINGLE_DATUM; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPrepFieldValue + * + * PARAMETERS: Info - Contains all field creation info + * + * RETURN: Status + * + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and + * connect it to the parent Node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPrepFieldValue ( + ACPI_CREATE_FIELD_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *SecondDesc = NULL; + UINT32 Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExPrepFieldValue); + + + /* Parameter validation */ + + if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD) + { + if (!Info->RegionNode) + { + ACPI_ERROR ((AE_INFO, "Null RegionNode")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + Type = AcpiNsGetType (Info->RegionNode); + if (Type != ACPI_TYPE_REGION) + { + ACPI_ERROR ((AE_INFO, + "Needed Region, found type %X (%s)", + Type, AcpiUtGetTypeName (Type))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + } + + /* Allocate a new field object */ + + ObjDesc = AcpiUtCreateInternalObject (Info->FieldType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize areas of the object that are common to all fields */ + + ObjDesc->CommonField.Node = Info->FieldNode; + Status = AcpiExPrepCommonFieldObject (ObjDesc, Info->FieldFlags, + Info->Attribute, Info->FieldBitPosition, Info->FieldBitLength); + if (ACPI_FAILURE (Status)) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (Status); + } + + /* Initialize areas of the object that are specific to the field type */ + + switch (Info->FieldType) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + + ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); + + /* An additional reference for the container */ + + AcpiUtAddReference (ObjDesc->Field.RegionObj); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", + ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj)); + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + ObjDesc->BankField.Value = Info->BankValue; + ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject ( + Info->RegionNode); + ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); + + /* An additional reference for the attached objects */ + + AcpiUtAddReference (ObjDesc->BankField.RegionObj); + AcpiUtAddReference (ObjDesc->BankField.BankObj); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n", + ObjDesc->BankField.StartFieldBitOffset, + ObjDesc->BankField.BaseByteOffset, + ObjDesc->Field.AccessByteWidth, + ObjDesc->BankField.RegionObj, + ObjDesc->BankField.BankObj)); + + /* + * Remember location in AML stream of the field unit + * opcode and operands -- since the BankValue + * operands must be evaluated. + */ + SecondDesc = ObjDesc->Common.NextObject; + SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Data; + SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Length; + + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + /* Get the Index and Data registers */ + + ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); + ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject ( + Info->DataRegisterNode); + + if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) + { + ACPI_ERROR ((AE_INFO, "Null Index Object during field prep")); + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* An additional reference for the attached objects */ + + AcpiUtAddReference (ObjDesc->IndexField.DataObj); + AcpiUtAddReference (ObjDesc->IndexField.IndexObj); + + /* + * April 2006: Changed to match MS behavior + * + * The value written to the Index register is the byte offset of the + * target field in units of the granularity of the IndexField + * + * Previously, the value was calculated as an index in terms of the + * width of the Data register, as below: + * + * ObjDesc->IndexField.Value = (UINT32) + * (Info->FieldBitPosition / ACPI_MUL_8 ( + * ObjDesc->Field.AccessByteWidth)); + * + * February 2006: Tried value as a byte offset: + * ObjDesc->IndexField.Value = (UINT32) + * ACPI_DIV_8 (Info->FieldBitPosition); + */ + ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN ( + ACPI_DIV_8 (Info->FieldBitPosition), + ObjDesc->IndexField.AccessByteWidth); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", + ObjDesc->IndexField.StartFieldBitOffset, + ObjDesc->IndexField.BaseByteOffset, + ObjDesc->IndexField.Value, + ObjDesc->Field.AccessByteWidth, + ObjDesc->IndexField.IndexObj, + ObjDesc->IndexField.DataObj)); + break; + + default: + /* No other types should get here */ + break; + } + + /* + * Store the constructed descriptor (ObjDesc) into the parent Node, + * preserving the current type of that NamedObj. + */ + Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc, + AcpiNsGetType (Info->FieldNode)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n", + Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc)); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + diff --git a/drivers/bus/acpi/acpica/executer/exregion.c b/drivers/bus/acpi/acpica/executer/exregion.c new file mode 100644 index 00000000000..5a37be25950 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exregion.c @@ -0,0 +1,630 @@ + +/****************************************************************************** + * + * Module Name: exregion - ACPI default OpRegion (address space) handlers + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EXREGION_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exregion") + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemMemorySpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the System Memory address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + void *LogicalAddrPtr = NULL; + ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext; + UINT32 Length; + ACPI_SIZE MapLength; + ACPI_SIZE PageBoundaryMapLength; +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED + UINT32 Remainder; +#endif + + + ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler); + + + /* Validate and translate the bit width */ + + switch (BitWidth) + { + case 8: + Length = 1; + break; + + case 16: + Length = 2; + break; + + case 32: + Length = 4; + break; + + case 64: + Length = 8; + break; + + default: + ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %d", + BitWidth)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED + /* + * Hardware does not support non-aligned data transfers, we must verify + * the request. + */ + (void) AcpiUtShortDivide ((ACPI_INTEGER) Address, Length, NULL, &Remainder); + if (Remainder != 0) + { + return_ACPI_STATUS (AE_AML_ALIGNMENT); + } +#endif + + /* + * Does the request fit into the cached memory mapping? + * Is 1) Address below the current mapping? OR + * 2) Address beyond the current mapping? + */ + if ((Address < MemInfo->MappedPhysicalAddress) || + (((ACPI_INTEGER) Address + Length) > + ((ACPI_INTEGER) + MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) + { + /* + * The request cannot be resolved by the current memory mapping; + * Delete the existing mapping and create a new one. + */ + if (MemInfo->MappedLength) + { + /* Valid mapping, delete it */ + + AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress, + MemInfo->MappedLength); + } + + /* + * October 2009: Attempt to map from the requested address to the + * end of the region. However, we will never map more than one + * page, nor will we cross a page boundary. + */ + MapLength = (ACPI_SIZE) + ((MemInfo->Address + MemInfo->Length) - Address); + + /* + * If mapping the entire remaining portion of the region will cross + * a page boundary, just map up to the page boundary, do not cross. + * On some systems, crossing a page boundary while mapping regions + * can cause warnings if the pages have different attributes + * due to resource management. + * + * This has the added benefit of constraining a single mapping to + * one page, which is similar to the original code that used a 4k + * maximum window. + */ + PageBoundaryMapLength = + ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address; + if (PageBoundaryMapLength == 0) + { + PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE; + } + + if (MapLength > PageBoundaryMapLength) + { + MapLength = PageBoundaryMapLength; + } + + /* Create a new mapping starting at the address given */ + + MemInfo->MappedLogicalAddress = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) Address, MapLength); + if (!MemInfo->MappedLogicalAddress) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X%8.8X, size %X", + ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) MapLength)); + MemInfo->MappedLength = 0; + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save the physical address and mapping size */ + + MemInfo->MappedPhysicalAddress = Address; + MemInfo->MappedLength = MapLength; + } + + /* + * Generate a logical pointer corresponding to the address we want to + * access + */ + LogicalAddrPtr = MemInfo->MappedLogicalAddress + + ((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", + BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address))); + + /* + * Perform the memory read or write + * + * Note: For machines that do not support non-aligned transfers, the target + * address was checked for alignment above. We do not attempt to break the + * transfer up into smaller (byte-size) chunks because the AML specifically + * asked for a transfer width that the hardware may require. + */ + switch (Function) + { + case ACPI_READ: + + *Value = 0; + switch (BitWidth) + { + case 8: + *Value = (ACPI_INTEGER) ACPI_GET8 (LogicalAddrPtr); + break; + + case 16: + *Value = (ACPI_INTEGER) ACPI_GET16 (LogicalAddrPtr); + break; + + case 32: + *Value = (ACPI_INTEGER) ACPI_GET32 (LogicalAddrPtr); + break; + + case 64: + *Value = (ACPI_INTEGER) ACPI_GET64 (LogicalAddrPtr); + break; + + default: + /* BitWidth was already validated */ + break; + } + break; + + case ACPI_WRITE: + + switch (BitWidth) + { + case 8: + ACPI_SET8 (LogicalAddrPtr) = (UINT8) *Value; + break; + + case 16: + ACPI_SET16 (LogicalAddrPtr) = (UINT16) *Value; + break; + + case 32: + ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value; + break; + + case 64: + ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value; + break; + + default: + /* BitWidth was already validated */ + break; + } + break; + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemIoSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the System IO address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemIoSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value32; + + + ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "System-IO (width %d) R/W %d Address=%8.8X%8.8X\n", + BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address))); + + /* Decode the function parameter */ + + switch (Function) + { + case ACPI_READ: + + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address, + &Value32, BitWidth); + *Value = Value32; + break; + + case ACPI_WRITE: + + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address, + (UINT32) *Value, BitWidth); + break; + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPciConfigSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the PCI Config address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPciConfigSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PCI_ID *PciId; + UINT16 PciRegister; + + + ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler); + + + /* + * The arguments to AcpiOs(Read|Write)PciConfiguration are: + * + * PciSegment is the PCI bus segment range 0-31 + * PciBus is the PCI bus number range 0-255 + * PciDevice is the PCI device number range 0-31 + * PciFunction is the PCI device function number + * PciRegister is the Config space register range 0-255 bytes + * + * Value - input value for write, output address for read + * + */ + PciId = (ACPI_PCI_ID *) RegionContext; + PciRegister = (UINT16) (UINT32) Address; + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Pci-Config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", + Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device, + PciId->Function, PciRegister)); + + switch (Function) + { + case ACPI_READ: + + *Value = 0; + Status = AcpiOsReadPciConfiguration (PciId, PciRegister, + Value, BitWidth); + break; + + case ACPI_WRITE: + + Status = AcpiOsWritePciConfiguration (PciId, PciRegister, + *Value, BitWidth); + break; + + default: + + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCmosSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the CMOS address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCmosSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExCmosSpaceHandler); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPciBarSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPciBarSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDataTableSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the Data Table address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDataTableSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler); + + + /* Perform the memory read or write */ + + switch (Function) + { + case ACPI_READ: + + ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address), + ACPI_DIV_8 (BitWidth)); + break; + + case ACPI_WRITE: + default: + + return_ACPI_STATUS (AE_SUPPORT); + } + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exresnte.c b/drivers/bus/acpi/acpica/executer/exresnte.c new file mode 100644 index 00000000000..5481bc899a8 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exresnte.c @@ -0,0 +1,374 @@ + +/****************************************************************************** + * + * Module Name: exresnte - AML Interpreter object resolution + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXRESNTE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exresnte") + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveNodeToValue + * + * PARAMETERS: ObjectPtr - Pointer to a location that contains + * a pointer to a NS node, and will receive a + * pointer to the resolved object. + * WalkState - Current state. Valid only if executing AML + * code. NULL if simply resolving an object + * + * RETURN: Status + * + * DESCRIPTION: Resolve a Namespace node to a valued object + * + * Note: for some of the data types, the pointer attached to the Node + * can be either a pointer to an actual internal object or a pointer into the + * AML stream itself. These types are currently: + * + * ACPI_TYPE_INTEGER + * ACPI_TYPE_STRING + * ACPI_TYPE_BUFFER + * ACPI_TYPE_MUTEX + * ACPI_TYPE_PACKAGE + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveNodeToValue ( + ACPI_NAMESPACE_NODE **ObjectPtr, + ACPI_WALK_STATE *WalkState) + +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *SourceDesc; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_OBJECT_TYPE EntryType; + + + ACPI_FUNCTION_TRACE (ExResolveNodeToValue); + + + /* + * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the + * object that is attached to the Node. + */ + Node = *ObjectPtr; + SourceDesc = AcpiNsGetAttachedObject (Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n", + Node, SourceDesc, AcpiUtGetTypeName (EntryType))); + + if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) || + (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS)) + { + /* There is always exactly one level of indirection */ + + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); + SourceDesc = AcpiNsGetAttachedObject (Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + *ObjectPtr = Node; + } + + /* + * Several object types require no further processing: + * 1) Device/Thermal objects don't have a "real" subobject, return the Node + * 2) Method locals and arguments have a pseudo-Node + * 3) 10/2007: Added method type to assist with Package construction. + */ + if ((EntryType == ACPI_TYPE_DEVICE) || + (EntryType == ACPI_TYPE_THERMAL) || + (EntryType == ACPI_TYPE_METHOD) || + (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) + { + return_ACPI_STATUS (AE_OK); + } + + if (!SourceDesc) + { + ACPI_ERROR ((AE_INFO, "No object attached to node %p", + Node)); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * Action is based on the type of the Node, which indicates the type + * of the attached object or pointer + */ + switch (EntryType) + { + case ACPI_TYPE_PACKAGE: + + if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, "Object not a Package, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + Status = AcpiDsGetPackageArguments (SourceDesc); + if (ACPI_SUCCESS (Status)) + { + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + } + break; + + + case ACPI_TYPE_BUFFER: + + if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) + { + ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + Status = AcpiDsGetBufferArguments (SourceDesc); + if (ACPI_SUCCESS (Status)) + { + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + } + break; + + + case ACPI_TYPE_STRING: + + if (SourceDesc->Common.Type != ACPI_TYPE_STRING) + { + ACPI_ERROR ((AE_INFO, "Object not a String, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + + case ACPI_TYPE_INTEGER: + + if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "FieldRead Node=%p SourceDesc=%p Type=%X\n", + Node, SourceDesc, EntryType)); + + Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc); + break; + + /* For these objects, just return the object attached to the Node */ + + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_REGION: + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + /* TYPE_ANY is untyped, and thus there is no object associated with it */ + + case ACPI_TYPE_ANY: + + ACPI_ERROR ((AE_INFO, + "Untyped entry %p, no attached object!", Node)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ + + + case ACPI_TYPE_LOCAL_REFERENCE: + + switch (SourceDesc->Reference.Class) + { + case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */ + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_INDEX: + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + default: + /* No named references are allowed here */ + + ACPI_ERROR ((AE_INFO, + "Unsupported Reference type %X", + SourceDesc->Reference.Class)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + break; + + + default: + + /* Default case is for unknown types */ + + ACPI_ERROR ((AE_INFO, + "Node %p - Unknown object type %X", + Node, EntryType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + + } /* switch (EntryType) */ + + + /* Return the object descriptor */ + + *ObjectPtr = (void *) ObjDesc; + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exresolv.c b/drivers/bus/acpi/acpica/executer/exresolv.c new file mode 100644 index 00000000000..a3c8ab9b5ce --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exresolv.c @@ -0,0 +1,652 @@ + +/****************************************************************************** + * + * Module Name: exresolv - AML Interpreter object resolution + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXRESOLV_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exresolv") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveToValue + * + * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can + * be either an (ACPI_OPERAND_OBJECT *) + * or an ACPI_HANDLE. + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Convert Reference objects to values + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr); + + + if (!StackPtr || !*StackPtr) + { + ACPI_ERROR ((AE_INFO, "Internal - null pointer")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * The entity pointed to by the StackPtr can be either + * 1) A valid ACPI_OPERAND_OBJECT, or + * 2) A ACPI_NAMESPACE_NODE (NamedObj) + */ + if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND) + { + Status = AcpiExResolveObjectToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!*StackPtr) + { + ACPI_ERROR ((AE_INFO, "Internal - null pointer")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + } + + /* + * Object on the stack may have changed if AcpiExResolveObjectToValue() + * was called (i.e., we can't use an _else_ here.) + */ + if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) + { + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveObjectToValue + * + * PARAMETERS: StackPtr - Pointer to an internal object + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value from an internal object. The Reference type + * uses the associated AML opcode to determine the value. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *StackDesc; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + UINT8 RefType; + + + ACPI_FUNCTION_TRACE (ExResolveObjectToValue); + + + StackDesc = *StackPtr; + + /* This is an ACPI_OPERAND_OBJECT */ + + switch (StackDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + RefType = StackDesc->Reference.Class; + + switch (RefType) + { + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + /* + * Get the local from the method's state info + * Note: this increments the local's object reference count + */ + Status = AcpiDsMethodDataGetValue (RefType, + StackDesc->Reference.Value, WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", + StackDesc->Reference.Value, ObjDesc)); + + /* + * Now we can delete the original Reference Object and + * replace it with the resolved value + */ + AcpiUtRemoveReference (StackDesc); + *StackPtr = ObjDesc; + break; + + + case ACPI_REFCLASS_INDEX: + + switch (StackDesc->Reference.TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + + /* Just return - do not dereference */ + break; + + + case ACPI_TYPE_PACKAGE: + + /* If method call or CopyObject - do not dereference */ + + if ((WalkState->Opcode == AML_INT_METHODCALL_OP) || + (WalkState->Opcode == AML_COPY_OP)) + { + break; + } + + /* Otherwise, dereference the PackageIndex to a package element */ + + ObjDesc = *StackDesc->Reference.Where; + if (ObjDesc) + { + /* + * Valid object descriptor, copy pointer to return value + * (i.e., dereference the package index) + * Delete the ref object, increment the returned object + */ + AcpiUtRemoveReference (StackDesc); + AcpiUtAddReference (ObjDesc); + *StackPtr = ObjDesc; + } + else + { + /* + * A NULL object descriptor means an uninitialized element of + * the package, can't dereference it + */ + ACPI_ERROR ((AE_INFO, + "Attempt to dereference an Index to NULL package element Idx=%p", + StackDesc)); + Status = AE_AML_UNINITIALIZED_ELEMENT; + } + break; + + + default: + + /* Invalid reference object */ + + ACPI_ERROR ((AE_INFO, + "Unknown TargetType %X in Index/Reference object %p", + StackDesc->Reference.TargetType, StackDesc)); + Status = AE_AML_INTERNAL; + break; + } + break; + + + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_DEBUG: + case ACPI_REFCLASS_TABLE: + + /* Just leave the object as-is, do not dereference */ + + break; + + case ACPI_REFCLASS_NAME: /* Reference to a named object */ + + /* Dereference the name */ + + if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) || + (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL)) + { + /* These node types do not have 'real' subobjects */ + + *StackPtr = (void *) StackDesc->Reference.Node; + } + else + { + /* Get the object pointed to by the namespace node */ + + *StackPtr = (StackDesc->Reference.Node)->Object; + AcpiUtAddReference (*StackPtr); + } + + AcpiUtRemoveReference (StackDesc); + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Reference type %X in %p", RefType, StackDesc)); + Status = AE_AML_INTERNAL; + break; + } + break; + + + case ACPI_TYPE_BUFFER: + + Status = AcpiDsGetBufferArguments (StackDesc); + break; + + + case ACPI_TYPE_PACKAGE: + + Status = AcpiDsGetPackageArguments (StackDesc); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", + StackDesc, StackDesc->Common.Type)); + + Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); + + /* Remove a reference to the original operand, then override */ + + AcpiUtRemoveReference (*StackPtr); + *StackPtr = (void *) ObjDesc; + break; + + default: + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveMultiple + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * Operand - Starting point for resolution + * ReturnType - Where the object type is returned + * ReturnDesc - Where the resolved object is returned + * + * RETURN: Status + * + * DESCRIPTION: Return the base object and type. Traverse a reference list if + * necessary to get to the base object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveMultiple ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *Operand, + ACPI_OBJECT_TYPE *ReturnType, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; + ACPI_NAMESPACE_NODE *Node; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiExResolveMultiple); + + + /* Operand can be either a namespace node or an operand descriptor */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_OPERAND: + Type = ObjDesc->Common.Type; + break; + + case ACPI_DESC_TYPE_NAMED: + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + + /* If we had an Alias node, use the attached object for type info */ + + if (Type == ACPI_TYPE_LOCAL_ALIAS) + { + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + } + break; + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* If type is anything other than a reference, we are done */ + + if (Type != ACPI_TYPE_LOCAL_REFERENCE) + { + goto Exit; + } + + /* + * For reference objects created via the RefOf, Index, or Load/LoadTable + * operators, we need to get to the base object (as per the ACPI + * specification of the ObjectType and SizeOf operators). This means + * traversing the list of possibly many nested references. + */ + while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_NAME: + + /* Dereference the reference pointer */ + + if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) + { + Node = ObjDesc->Reference.Object; + } + else /* AML_INT_NAMEPATH_OP */ + { + Node = ObjDesc->Reference.Node; + } + + /* All "References" point to a NS node */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, + "Not a NS node %p [%s]", + Node, AcpiUtGetDescriptorName (Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Get the attached object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, use the NS node type */ + + Type = AcpiNsGetType (Node); + goto Exit; + } + + /* Check for circular references */ + + if (ObjDesc == Operand) + { + return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); + } + break; + + + case ACPI_REFCLASS_INDEX: + + /* Get the type of this reference (index into another object) */ + + Type = ObjDesc->Reference.TargetType; + if (Type != ACPI_TYPE_PACKAGE) + { + goto Exit; + } + + /* + * The main object is a package, we want to get the type + * of the individual package element that is referenced by + * the index. + * + * This could of course in turn be another reference object. + */ + ObjDesc = *(ObjDesc->Reference.Where); + if (!ObjDesc) + { + /* NULL package elements are allowed */ + + Type = 0; /* Uninitialized */ + goto Exit; + } + break; + + + case ACPI_REFCLASS_TABLE: + + Type = ACPI_TYPE_DDB_HANDLE; + goto Exit; + + + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + if (ReturnDesc) + { + Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, + ObjDesc->Reference.Value, WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiUtRemoveReference (ObjDesc); + } + else + { + Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, + ObjDesc->Reference.Value, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Type = ACPI_TYPE_ANY; + goto Exit; + } + } + break; + + + case ACPI_REFCLASS_DEBUG: + + /* The Debug Object is of type "DebugObject" */ + + Type = ACPI_TYPE_DEBUG_OBJECT; + goto Exit; + + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Reference Class %2.2X", ObjDesc->Reference.Class)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + } + + /* + * Now we are guaranteed to have an object that has not been created + * via the RefOf or Index operators. + */ + Type = ObjDesc->Common.Type; + + +Exit: + /* Convert internal types to external types */ + + switch (Type) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + Type = ACPI_TYPE_FIELD_UNIT; + break; + + case ACPI_TYPE_LOCAL_SCOPE: + + /* Per ACPI Specification, Scope is untyped */ + + Type = ACPI_TYPE_ANY; + break; + + default: + /* No change to Type required */ + break; + } + + *ReturnType = Type; + if (ReturnDesc) + { + *ReturnDesc = ObjDesc; + } + return_ACPI_STATUS (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exresop.c b/drivers/bus/acpi/acpica/executer/exresop.c new file mode 100644 index 00000000000..ecc63f61357 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exresop.c @@ -0,0 +1,810 @@ + +/****************************************************************************** + * + * Module Name: exresop - AML Interpreter operand/object resolution + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXRESOP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exresop") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExCheckObjectType ( + ACPI_OBJECT_TYPE TypeNeeded, + ACPI_OBJECT_TYPE ThisType, + void *Object); + + +/******************************************************************************* + * + * FUNCTION: AcpiExCheckObjectType + * + * PARAMETERS: TypeNeeded Object type needed + * ThisType Actual object type + * Object Object pointer + * + * RETURN: Status + * + * DESCRIPTION: Check required type against actual type + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExCheckObjectType ( + ACPI_OBJECT_TYPE TypeNeeded, + ACPI_OBJECT_TYPE ThisType, + void *Object) +{ + ACPI_FUNCTION_ENTRY (); + + + if (TypeNeeded == ACPI_TYPE_ANY) + { + /* All types OK, so we don't perform any typechecks */ + + return (AE_OK); + } + + if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE) + { + /* + * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference + * objects and thus allow them to be targets. (As per the ACPI + * specification, a store to a constant is a noop.) + */ + if ((ThisType == ACPI_TYPE_INTEGER) && + (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT)) + { + return (AE_OK); + } + } + + if (TypeNeeded != ThisType) + { + ACPI_ERROR ((AE_INFO, + "Needed type [%s], found [%s] %p", + AcpiUtGetTypeName (TypeNeeded), + AcpiUtGetTypeName (ThisType), Object)); + + return (AE_AML_OPERAND_TYPE); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveOperands + * + * PARAMETERS: Opcode - Opcode being interpreted + * StackPtr - Pointer to the operand stack to be + * resolved + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Convert multiple input operands to the types required by the + * target operator. + * + * Each 5-bit group in ArgTypes represents one required + * operand and indicates the required Type. The corresponding operand + * will be converted to the required type if possible, otherwise we + * abort with an exception. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + UINT8 ObjectType; + UINT32 ArgTypes; + const ACPI_OPCODE_INFO *OpInfo; + UINT32 ThisArgType; + ACPI_OBJECT_TYPE TypeNeeded; + UINT16 TargetOp = 0; + + + ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode); + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + ArgTypes = OpInfo->RuntimeArgs; + if (ArgTypes == ARGI_INVALID_OPCODE) + { + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + Opcode)); + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", + Opcode, OpInfo->Name, ArgTypes)); + + /* + * Normal exit is with (ArgTypes == 0) at end of argument list. + * Function will return an exception from within the loop upon + * finding an entry which is not (or cannot be converted + * to) the required type; if stack underflows; or upon + * finding a NULL stack entry (which should not happen). + */ + while (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + if (!StackPtr || !*StackPtr) + { + ACPI_ERROR ((AE_INFO, "Null stack entry at %p", + StackPtr)); + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Extract useful items */ + + ObjDesc = *StackPtr; + + /* Decode the descriptor type */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_NAMED: + + /* Namespace Node */ + + ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + + /* + * Resolve an alias object. The construction of these objects + * guarantees that there is only one level of alias indirection; + * thus, the attached object is always the aliased namespace node + */ + if (ObjectType == ACPI_TYPE_LOCAL_ALIAS) + { + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + *StackPtr = ObjDesc; + ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + } + break; + + + case ACPI_DESC_TYPE_OPERAND: + + /* ACPI internal object */ + + ObjectType = ObjDesc->Common.Type; + + /* Check for bad ACPI_OBJECT_TYPE */ + + if (!AcpiUtValidObjectType (ObjectType)) + { + ACPI_ERROR ((AE_INFO, + "Bad operand object type [%X]", ObjectType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) + { + /* Validate the Reference */ + + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_DEBUG: + + TargetOp = AML_DEBUG_OP; + + /*lint -fallthrough */ + + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_INDEX: + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ + case ACPI_REFCLASS_NAME: /* Reference to a named object */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Operand is a Reference, Class [%s] %2.2X\n", + AcpiUtGetReferenceName (ObjDesc), + ObjDesc->Reference.Class)); + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Reference Class %2.2X in %p", + ObjDesc->Reference.Class, ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + } + break; + + + default: + + /* Invalid descriptor */ + + ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Get one argument type, point to the next */ + + ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); + INCREMENT_ARG_LIST (ArgTypes); + + /* + * Handle cases where the object does not need to be + * resolved to a value + */ + switch (ThisArgType) + { + case ARGI_REF_OR_STRING: /* Can be a String or Reference */ + + if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) && + (ObjDesc->Common.Type == ACPI_TYPE_STRING)) + { + /* + * String found - the string references a named object and + * must be resolved to a node + */ + goto NextOperand; + } + + /* + * Else not a string - fall through to the normal Reference + * case below + */ + /*lint -fallthrough */ + + case ARGI_REFERENCE: /* References: */ + case ARGI_INTEGER_REF: + case ARGI_OBJECT_REF: + case ARGI_DEVICE_REF: + case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ + case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ + case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ + + /* + * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE + * A Namespace Node is OK as-is + */ + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) + { + goto NextOperand; + } + + Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE, + ObjectType, ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + goto NextOperand; + + + case ARGI_DATAREFOBJ: /* Store operator only */ + + /* + * We don't want to resolve IndexOp reference objects during + * a store because this would be an implicit DeRefOf operation. + * Instead, we just want to store the reference object. + * -- All others must be resolved below. + */ + if ((Opcode == AML_STORE_OP) && + ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX)) + { + goto NextOperand; + } + break; + + default: + /* All cases covered above */ + break; + } + + /* + * Resolve this object to a value + */ + Status = AcpiExResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the resolved object */ + + ObjDesc = *StackPtr; + + /* + * Check the resulting object (value) type + */ + switch (ThisArgType) + { + /* + * For the simple cases, only one type of resolved object + * is allowed + */ + case ARGI_MUTEX: + + /* Need an operand of type ACPI_TYPE_MUTEX */ + + TypeNeeded = ACPI_TYPE_MUTEX; + break; + + case ARGI_EVENT: + + /* Need an operand of type ACPI_TYPE_EVENT */ + + TypeNeeded = ACPI_TYPE_EVENT; + break; + + case ARGI_PACKAGE: /* Package */ + + /* Need an operand of type ACPI_TYPE_PACKAGE */ + + TypeNeeded = ACPI_TYPE_PACKAGE; + break; + + case ARGI_ANYTYPE: + + /* Any operand type will do */ + + TypeNeeded = ACPI_TYPE_ANY; + break; + + case ARGI_DDBHANDLE: + + /* Need an operand of type ACPI_TYPE_DDB_HANDLE */ + + TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE; + break; + + + /* + * The more complex cases allow multiple resolved object types + */ + case ARGI_INTEGER: + + /* + * Need an operand of type ACPI_TYPE_INTEGER, + * But we can implicitly convert from a STRING or BUFFER + * Aka - "Implicit Source Operand Conversion" + */ + Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + goto NextOperand; + + + case ARGI_BUFFER: + + /* + * Need an operand of type ACPI_TYPE_BUFFER, + * But we can implicitly convert from a STRING or INTEGER + * Aka - "Implicit Source Operand Conversion" + */ + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + goto NextOperand; + + + case ARGI_STRING: + + /* + * Need an operand of type ACPI_TYPE_STRING, + * But we can implicitly convert from a BUFFER or INTEGER + * Aka - "Implicit Source Operand Conversion" + */ + Status = AcpiExConvertToString (ObjDesc, StackPtr, + ACPI_IMPLICIT_CONVERT_HEX); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + goto NextOperand; + + + case ARGI_COMPUTEDATA: + + /* Need an operand of type INTEGER, STRING or BUFFER */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_BUFFER_OR_STRING: + + /* Need an operand of type STRING or BUFFER */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Valid operand */ + break; + + case ACPI_TYPE_INTEGER: + + /* Highest priority conversion is to type Buffer */ + + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_DATAOBJECT: + /* + * ARGI_DATAOBJECT is only used by the SizeOf operator. + * Need a buffer, string, package, or RefOf reference. + * + * The only reference allowed here is a direct reference to + * a namespace node. + */ + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_LOCAL_REFERENCE: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Buffer/String/Package/Reference], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_COMPLEXOBJ: + + /* Need a buffer or package or (ACPI 2.0) String */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Buffer/String/Package], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ + + /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_REGION: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Region/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_DATAREFOBJ: + + /* Used by the Store() operator only */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REFERENCE: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + case ACPI_TYPE_DDB_HANDLE: + + /* Valid operand */ + break; + + default: + + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Enable original behavior of Store(), allowing any and all + * objects as the source operand. The ACPI spec does not + * allow this, however. + */ + break; + } + + if (TargetOp == AML_DEBUG_OP) + { + /* Allow store of any object to the Debug object */ + + break; + } + + ACPI_ERROR ((AE_INFO, + "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + default: + + /* Unknown type */ + + ACPI_ERROR ((AE_INFO, + "Internal - Unknown ARGI (required operand) type %X", + ThisArgType)); + + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Make sure that the original object was resolved to the + * required object type (Simple cases only). + */ + Status = AcpiExCheckObjectType (TypeNeeded, + (*StackPtr)->Common.Type, *StackPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + +NextOperand: + /* + * If more operands needed, decrement StackPtr to point + * to next operand on stack + */ + if (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + StackPtr--; + } + } + + ACPI_DUMP_OPERANDS (WalkState->Operands, + AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands); + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exstore.c b/drivers/bus/acpi/acpica/executer/exstore.c new file mode 100644 index 00000000000..8ec8a23cffd --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exstore.c @@ -0,0 +1,822 @@ + +/****************************************************************************** + * + * Module Name: exstore - AML Interpreter object store support + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXSTORE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exstore") + +/* Local prototypes */ + +static void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index); + +static ACPI_STATUS +AcpiExStoreObjectToIndex ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoDebugObject + * + * PARAMETERS: SourceDesc - Value to be stored + * Level - Indentation level (used for packages) + * Index - Current package element, zero if not pkg + * + * RETURN: None + * + * DESCRIPTION: Handles stores to the Debug Object. + * + ******************************************************************************/ + +static void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); + + + /* Print line header as long as we are not in the middle of an object display */ + + if (!((Level > 0) && Index == 0)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", + Level, " ")); + } + + /* Display index for package output only */ + + if (Index > 0) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + "(%.2u) ", Index -1)); + } + + if (!SourceDesc) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Null Object]\n")); + return_VOID; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s ", + AcpiUtGetObjectTypeName (SourceDesc))); + + if (!AcpiUtValidInternalObject (SourceDesc)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + "%p, Invalid Internal Object!\n", SourceDesc)); + return_VOID; + } + } + else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", + AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), + SourceDesc)); + return_VOID; + } + else + { + return_VOID; + } + + /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */ + + switch (SourceDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* Output correct integer width */ + + if (AcpiGbl_IntegerByteWidth == 4) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", + (UINT32) SourceDesc->Integer.Value)); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value))); + } + break; + + case ACPI_TYPE_BUFFER: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", + (UINT32) SourceDesc->Buffer.Length)); + ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, + (SourceDesc->Buffer.Length < 256) ? SourceDesc->Buffer.Length : 256); + break; + + case ACPI_TYPE_STRING: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", + SourceDesc->String.Length, SourceDesc->String.Pointer)); + break; + + case ACPI_TYPE_PACKAGE: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[Contains 0x%.2X Elements]\n", + SourceDesc->Package.Count)); + + /* Output the entire contents of the package */ + + for (i = 0; i < SourceDesc->Package.Count; i++) + { + AcpiExDoDebugObject (SourceDesc->Package.Elements[i], + Level+4, i+1); + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s] ", + AcpiUtGetReferenceName (SourceDesc))); + + /* Decode the reference */ + + switch (SourceDesc->Reference.Class) + { + case ACPI_REFCLASS_INDEX: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X\n", + SourceDesc->Reference.Value)); + break; + + case ACPI_REFCLASS_TABLE: + + /* Case for DdbHandle */ + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Table Index 0x%X\n", + SourceDesc->Reference.Value)); + return; + + default: + break; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, " ")); + + /* Check for valid node first, then valid object */ + + if (SourceDesc->Reference.Node) + { + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) != + ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + " %p - Not a valid namespace node\n", + SourceDesc->Reference.Node)); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Node %p [%4.4s] ", + SourceDesc->Reference.Node, (SourceDesc->Reference.Node)->Name.Ascii)); + + switch ((SourceDesc->Reference.Node)->Type) + { + /* These types have no attached object */ + + case ACPI_TYPE_DEVICE: + AcpiOsPrintf ("Device\n"); + break; + + case ACPI_TYPE_THERMAL: + AcpiOsPrintf ("Thermal Zone\n"); + break; + + default: + AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, + Level+4, 0); + break; + } + } + } + else if (SourceDesc->Reference.Object) + { + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == + ACPI_DESC_TYPE_NAMED) + { + AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) + SourceDesc->Reference.Object)->Object, + Level+4, 0); + } + else + { + AcpiExDoDebugObject (SourceDesc->Reference.Object, Level+4, 0); + } + } + break; + + default: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n", + SourceDesc)); + break; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStore + * + * PARAMETERS: *SourceDesc - Value to be stored + * *DestDesc - Where to store it. Must be an NS node + * or an ACPI_OPERAND_OBJECT of type + * Reference; + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Store the value described by SourceDesc into the location + * described by DestDesc. Called by various interpreter + * functions to store the result of an operation into + * the destination operand -- not just simply the actual "Store" + * ASL operator. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStore ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *RefDesc = DestDesc; + + + ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); + + + /* Validate parameters */ + + if (!SourceDesc || !DestDesc) + { + ACPI_ERROR ((AE_INFO, "Null parameter")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* DestDesc can be either a namespace node or an ACPI object */ + + if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) + { + /* + * Dest is a namespace node, + * Storing an object into a Named node. + */ + Status = AcpiExStoreObjectToNode (SourceDesc, + (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, + ACPI_IMPLICIT_CONVERSION); + + return_ACPI_STATUS (Status); + } + + /* Destination object must be a Reference or a Constant object */ + + switch (DestDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + break; + + case ACPI_TYPE_INTEGER: + + /* Allow stores to Constants -- a Noop as per ACPI spec */ + + if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) + { + return_ACPI_STATUS (AE_OK); + } + + /*lint -fallthrough */ + + default: + + /* Destination is not a Reference object */ + + ACPI_ERROR ((AE_INFO, + "Target is not a Reference or Constant object - %s [%p]", + AcpiUtGetObjectTypeName (DestDesc), DestDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * Examine the Reference class. These cases are handled: + * + * 1) Store to Name (Change the object associated with a name) + * 2) Store to an indexed area of a Buffer or Package + * 3) Store to a Method Local or Arg + * 4) Store to the debug object + */ + switch (RefDesc->Reference.Class) + { + case ACPI_REFCLASS_REFOF: + + /* Storing an object into a Name "container" */ + + Status = AcpiExStoreObjectToNode (SourceDesc, + RefDesc->Reference.Object, + WalkState, ACPI_IMPLICIT_CONVERSION); + break; + + + case ACPI_REFCLASS_INDEX: + + /* Storing to an Index (pointer into a packager or buffer) */ + + Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); + break; + + + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + /* Store to a method local/arg */ + + Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, + RefDesc->Reference.Value, SourceDesc, WalkState); + break; + + + case ACPI_REFCLASS_DEBUG: + + /* + * Storing to the Debug object causes the value stored to be + * displayed and otherwise has no effect -- see ACPI Specification + */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** Write to Debug Object: Object %p %s ****:\n\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); + + AcpiExDoDebugObject (SourceDesc, 0, 0); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + RefDesc->Reference.Class)); + ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); + + Status = AE_AML_INTERNAL; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreObjectToIndex + * + * PARAMETERS: *SourceDesc - Value to be stored + * *DestDesc - Named object to receive the value + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Store the object to indexed Buffer or Package element + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExStoreObjectToIndex ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *IndexDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NewDesc; + UINT8 Value = 0; + UINT32 i; + + + ACPI_FUNCTION_TRACE (ExStoreObjectToIndex); + + + /* + * Destination must be a reference pointer, and + * must point to either a buffer or a package + */ + switch (IndexDesc->Reference.TargetType) + { + case ACPI_TYPE_PACKAGE: + /* + * Storing to a package element. Copy the object and replace + * any existing object with the new object. No implicit + * conversion is performed. + * + * The object at *(IndexDesc->Reference.Where) is the + * element within the package that is to be modified. + * The parent package object is at IndexDesc->Reference.Object + */ + ObjDesc = *(IndexDesc->Reference.Where); + + if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE && + SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) + { + /* This is a DDBHandle, just add a reference to it */ + + AcpiUtAddReference (SourceDesc); + NewDesc = SourceDesc; + } + else + { + /* Normal object, copy it */ + + Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (ObjDesc) + { + /* Decrement reference count by the ref count of the parent package */ + + for (i = 0; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) + { + AcpiUtRemoveReference (ObjDesc); + } + } + + *(IndexDesc->Reference.Where) = NewDesc; + + /* Increment ref count by the ref count of the parent package-1 */ + + for (i = 1; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) + { + AcpiUtAddReference (NewDesc); + } + + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + /* + * Store into a Buffer or String (not actually a real BufferField) + * at a location defined by an Index. + * + * The first 8-bit element of the source object is written to the + * 8-bit Buffer location defined by the Index destination object, + * according to the ACPI 2.0 specification. + */ + + /* + * Make sure the target is a Buffer or String. An error should + * not happen here, since the ReferenceObject was constructed + * by the INDEX_OP code. + */ + ObjDesc = IndexDesc->Reference.Object; + if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ObjDesc->Common.Type != ACPI_TYPE_STRING)) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * The assignment of the individual elements will be slightly + * different for each source type. + */ + switch (SourceDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* Use the least-significant byte of the integer */ + + Value = (UINT8) (SourceDesc->Integer.Value); + break; + + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + + /* Note: Takes advantage of common string/buffer fields */ + + Value = SourceDesc->Buffer.Pointer[0]; + break; + + default: + + /* All other types are invalid */ + + ACPI_ERROR ((AE_INFO, + "Source must be Integer/Buffer/String type, not %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Store the source value into the target buffer byte */ + + ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value; + break; + + + default: + ACPI_ERROR ((AE_INFO, + "Target is not a Package or BufferField")); + Status = AE_AML_OPERAND_TYPE; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreObjectToNode + * + * PARAMETERS: SourceDesc - Value to be stored + * Node - Named object to receive the value + * WalkState - Current walk state + * ImplicitConversion - Perform implicit conversion (yes/no) + * + * RETURN: Status + * + * DESCRIPTION: Store the object to the named object. + * + * The Assignment of an object to a named object is handled here + * The value passed in will replace the current value (if any) + * with the input value. + * + * When storing into an object the data is converted to the + * target object type then stored in the object. This means + * that the target object type (for an initialized target) will + * not be changed by a store operation. + * + * Assumes parameters are already validated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreObjectToNode ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState, + UINT8 ImplicitConversion) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *TargetDesc; + ACPI_OPERAND_OBJECT *NewDesc; + ACPI_OBJECT_TYPE TargetType; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc); + + + /* Get current type of the node, and object attached to Node */ + + TargetType = AcpiNsGetType (Node); + TargetDesc = AcpiNsGetAttachedObject (Node); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), + Node, AcpiUtGetTypeName (TargetType))); + + /* + * Resolve the source object to an actual value + * (If it is a reference object) + */ + Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* If no implicit conversion, drop into the default case below */ + + if ((!ImplicitConversion) || + ((WalkState->Opcode == AML_COPY_OP) && + (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) && + (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) && + (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD))) + { + /* + * Force execution of default (no implicit conversion). Note: + * CopyObject does not perform an implicit conversion, as per the ACPI + * spec -- except in case of region/bank/index fields -- because these + * objects must retain their original type permanently. + */ + TargetType = ACPI_TYPE_ANY; + } + + /* Do the actual store operation */ + + switch (TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + /* For fields, copy the source data to the target field. */ + + Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, + &WalkState->ResultObj); + break; + + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * These target types are all of type Integer/String/Buffer, and + * therefore support implicit conversion before the store. + * + * Copy and/or convert the source object to a new target object + */ + Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, + &NewDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (NewDesc != TargetDesc) + { + /* + * Store the new NewDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * SourceDesc reference count is incremented by AttachObject. + * + * Note: This may change the type of the node if an explicit store + * has been performed such that the node/object type has been + * changed. + */ + Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Store %s into %s via Convert/Attach\n", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetObjectTypeName (NewDesc))); + } + break; + + + default: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Storing %s (%p) directly into node (%p) with no implicit conversion\n", + AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); + + /* No conversions for all other types. Just attach the source object */ + + Status = AcpiNsAttachObject (Node, SourceDesc, + SourceDesc->Common.Type); + break; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exstoren.c b/drivers/bus/acpi/acpica/executer/exstoren.c new file mode 100644 index 00000000000..0810560d39c --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exstoren.c @@ -0,0 +1,386 @@ + +/****************************************************************************** + * + * Module Name: exstoren - AML Interpreter object store support, + * Store to Node (namespace object) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXSTOREN_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exstoren") + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveObject + * + * PARAMETERS: SourceDescPtr - Pointer to the source object + * TargetType - Current type of the target + * WalkState - Current walk state + * + * RETURN: Status, resolved object in SourceDescPtr. + * + * DESCRIPTION: Resolve an object. If the object is a reference, dereference + * it and return the actual object in the SourceDescPtr. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveObject ( + ACPI_OPERAND_OBJECT **SourceDescPtr, + ACPI_OBJECT_TYPE TargetType, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExResolveObject); + + + /* Ensure we have a Target that can be stored to */ + + switch (TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* + * These cases all require only Integers or values that + * can be converted to Integers (Strings or Buffers) + */ + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * Stores into a Field/Region or into a Integer/Buffer/String + * are all essentially the same. This case handles the + * "interchangeable" types Integer, String, and Buffer. + */ + if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + /* Resolve a reference object first */ + + Status = AcpiExResolveToValue (SourceDescPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + } + + /* For CopyObject, no further validation necessary */ + + if (WalkState->Opcode == AML_COPY_OP) + { + break; + } + + /* Must have a Integer, Buffer, or String */ + + if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && + (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && + (SourceDesc->Common.Type != ACPI_TYPE_STRING) && + !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE))) + { + /* Conversion successful but still not a valid type */ + + ACPI_ERROR ((AE_INFO, + "Cannot assign type %s to %s (must be type Int/Str/Buf)", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetTypeName (TargetType))); + Status = AE_AML_OPERAND_TYPE; + } + break; + + + case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_METHOD_ALIAS: + + /* + * All aliases should have been resolved earlier, during the + * operand resolution phase. + */ + ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object")); + Status = AE_AML_INTERNAL; + break; + + + case ACPI_TYPE_PACKAGE: + default: + + /* + * All other types than Alias and the various Fields come here, + * including the untyped case - ACPI_TYPE_ANY. + */ + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreObjectToObject + * + * PARAMETERS: SourceDesc - Object to store + * DestDesc - Object to receive a copy of the source + * NewDesc - New object if DestDesc is obsoleted + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: "Store" an object to another object. This may include + * converting the source type to the target type (implicit + * conversion), and a copy of the value of the source to + * the target. + * + * The Assignment of an object to another (not named) object + * is handled here. + * The Source passed in will replace the current value (if any) + * with the input value. + * + * When storing into an object the data is converted to the + * target object type then stored in the object. This means + * that the target object type (for an initialized target) will + * not be changed by a store operation. + * + * This module allows destination types of Number, String, + * Buffer, and Package. + * + * Assumes parameters are already validated. NOTE: SourceDesc + * resolution (from a reference object) must be performed by + * the caller if necessary. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreObjectToObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_OPERAND_OBJECT **NewDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ActualSrcDesc; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc); + + + ActualSrcDesc = SourceDesc; + if (!DestDesc) + { + /* + * There is no destination object (An uninitialized node or + * package element), so we can simply copy the source object + * creating a new destination object + */ + Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState); + return_ACPI_STATUS (Status); + } + + if (SourceDesc->Common.Type != DestDesc->Common.Type) + { + /* + * The source type does not match the type of the destination. + * Perform the "implicit conversion" of the source to the current type + * of the target as per the ACPI specification. + * + * If no conversion performed, ActualSrcDesc = SourceDesc. + * Otherwise, ActualSrcDesc is a temporary object to hold the + * converted object. + */ + Status = AcpiExConvertToTargetType (DestDesc->Common.Type, + SourceDesc, &ActualSrcDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (SourceDesc == ActualSrcDesc) + { + /* + * No conversion was performed. Return the SourceDesc as the + * new object. + */ + *NewDesc = SourceDesc; + return_ACPI_STATUS (AE_OK); + } + } + + /* + * We now have two objects of identical types, and we can perform a + * copy of the *value* of the source object. + */ + switch (DestDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + DestDesc->Integer.Value = ActualSrcDesc->Integer.Value; + + /* Truncate value if we are executing from a 32-bit ACPI table */ + + AcpiExTruncateFor32bitTable (DestDesc); + break; + + case ACPI_TYPE_STRING: + + Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc); + break; + + case ACPI_TYPE_BUFFER: + + Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc); + break; + + case ACPI_TYPE_PACKAGE: + + Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, + WalkState); + break; + + default: + /* + * All other types come here. + */ + ACPI_WARNING ((AE_INFO, "Store into type %s not implemented", + AcpiUtGetObjectTypeName (DestDesc))); + + Status = AE_NOT_IMPLEMENTED; + break; + } + + if (ActualSrcDesc != SourceDesc) + { + /* Delete the intermediate (temporary) source object */ + + AcpiUtRemoveReference (ActualSrcDesc); + } + + *NewDesc = DestDesc; + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exstorob.c b/drivers/bus/acpi/acpica/executer/exstorob.c new file mode 100644 index 00000000000..b2f125d01fb --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exstorob.c @@ -0,0 +1,316 @@ + +/****************************************************************************** + * + * Module Name: exstorob - AML Interpreter object store support, store to object + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXSTOROB_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exstorob") + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreBufferToBuffer + * + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy + * + * RETURN: Status + * + * DESCRIPTION: Copy a buffer object to another buffer object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreBufferToBuffer ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + UINT32 Length; + UINT8 *Buffer; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc); + + + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* We know that SourceDesc is a buffer by now */ + + Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer); + Length = SourceDesc->Buffer.Length; + + /* + * If target is a buffer of length zero or is a static buffer, + * allocate a new buffer of the proper length + */ + if ((TargetDesc->Buffer.Length == 0) || + (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)) + { + TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length); + if (!TargetDesc->Buffer.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + TargetDesc->Buffer.Length = Length; + } + + /* Copy source buffer to target buffer */ + + if (Length <= TargetDesc->Buffer.Length) + { + /* Clear existing buffer and copy in the new one */ + + ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); + ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length); + +#ifdef ACPI_OBSOLETE_BEHAVIOR + /* + * NOTE: ACPI versions up to 3.0 specified that the buffer must be + * truncated if the string is smaller than the buffer. However, "other" + * implementations of ACPI never did this and thus became the defacto + * standard. ACPI 3.0A changes this behavior such that the buffer + * is no longer truncated. + */ + + /* + * OBSOLETE BEHAVIOR: + * If the original source was a string, we must truncate the buffer, + * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer + * copy must not truncate the original buffer. + */ + if (OriginalSrcType == ACPI_TYPE_STRING) + { + /* Set the new length of the target */ + + TargetDesc->Buffer.Length = Length; + } +#endif + } + else + { + /* Truncate the source, copy only what will fit */ + + ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, + TargetDesc->Buffer.Length); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Truncating source buffer from %X to %X\n", + Length, TargetDesc->Buffer.Length)); + } + + /* Copy flags */ + + TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags; + TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreStringToString + * + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy + * + * RETURN: Status + * + * DESCRIPTION: Copy a String object to another String object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreStringToString ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + UINT32 Length; + UINT8 *Buffer; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc); + + + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* We know that SourceDesc is a string by now */ + + Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer); + Length = SourceDesc->String.Length; + + /* + * Replace existing string value if it will fit and the string + * pointer is not a static pointer (part of an ACPI table) + */ + if ((Length < TargetDesc->String.Length) && + (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) + { + /* + * String will fit in existing non-static buffer. + * Clear old string and copy in the new one + */ + ACPI_MEMSET (TargetDesc->String.Pointer, 0, + (ACPI_SIZE) TargetDesc->String.Length + 1); + ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + } + else + { + /* + * Free the current buffer, then allocate a new buffer + * large enough to hold the value + */ + if (TargetDesc->String.Pointer && + (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) + { + /* Only free if not a pointer into the DSDT */ + + ACPI_FREE (TargetDesc->String.Pointer); + } + + TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED ( + (ACPI_SIZE) Length + 1); + if (!TargetDesc->String.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + } + + /* Set the new target length */ + + TargetDesc->String.Length = Length; + return_ACPI_STATUS (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/executer/exsystem.c b/drivers/bus/acpi/acpica/executer/exsystem.c new file mode 100644 index 00000000000..19674606a60 --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exsystem.c @@ -0,0 +1,418 @@ + +/****************************************************************************** + * + * Module Name: exsystem - Interface to OS services + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXSYSTEM_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exsystem") + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitSemaphore + * + * PARAMETERS: Semaphore - Semaphore to wait on + * Timeout - Max time to wait + * + * RETURN: Status + * + * DESCRIPTION: Implements a semaphore wait with a check to see if the + * semaphore is available immediately. If it is not, the + * interpreter is released before waiting. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitSemaphore ( + ACPI_SEMAPHORE Semaphore, + UINT16 Timeout) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore); + + + Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Status == AE_TIME) + { + /* We must wait, so unlock the interpreter */ + + AcpiExRelinquishInterpreter (); + + Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", + AcpiFormatException (Status))); + + /* Reacquire the interpreter */ + + AcpiExReacquireInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitMutex + * + * PARAMETERS: Mutex - Mutex to wait on + * Timeout - Max time to wait + * + * RETURN: Status + * + * DESCRIPTION: Implements a mutex wait with a check to see if the + * mutex is available immediately. If it is not, the + * interpreter is released before waiting. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitMutex ( + ACPI_MUTEX Mutex, + UINT16 Timeout) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExSystemWaitMutex); + + + Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Status == AE_TIME) + { + /* We must wait, so unlock the interpreter */ + + AcpiExRelinquishInterpreter (); + + Status = AcpiOsAcquireMutex (Mutex, Timeout); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", + AcpiFormatException (Status))); + + /* Reacquire the interpreter */ + + AcpiExReacquireInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemDoStall + * + * PARAMETERS: HowLong - The amount of time to stall, + * in microseconds + * + * RETURN: Status + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * Note: ACPI specification requires that Stall() does not + * relinquish the processor, and delays longer than 100 usec + * should use Sleep() instead. We allow stalls up to 255 usec + * for compatibility with other interpreters and existing BIOSs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemDoStall ( + UINT32 HowLong) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_ENTRY (); + + + if (HowLong > 255) /* 255 microseconds */ + { + /* + * Longer than 255 usec, this is an error + * + * (ACPI specifies 100 usec as max, but this gives some slack in + * order to support existing BIOSs) + */ + ACPI_ERROR ((AE_INFO, "Time parameter is too large (%d)", + HowLong)); + Status = AE_AML_OPERAND_VALUE; + } + else + { + AcpiOsStall (HowLong); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemDoSuspend + * + * PARAMETERS: HowLong - The amount of time to suspend, + * in milliseconds + * + * RETURN: None + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemDoSuspend ( + ACPI_INTEGER HowLong) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Since this thread will sleep, we must release the interpreter */ + + AcpiExRelinquishInterpreter (); + + AcpiOsSleep (HowLong); + + /* And now we must get the interpreter again */ + + AcpiExReacquireInterpreter (); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemSignalEvent + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemSignalEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExSystemSignalEvent); + + + if (ObjDesc) + { + Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitEvent + * + * PARAMETERS: TimeDesc - The 'time to delay' object descriptor + * ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. This operation is a request to wait for an + * event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitEvent ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExSystemWaitEvent); + + + if (ObjDesc) + { + Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore, + (UINT16) TimeDesc->Integer.Value); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemResetEvent + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Reset an event to a known state. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemResetEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + ACPI_SEMAPHORE TempSemaphore; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * We are going to simply delete the existing semaphore and + * create a new one! + */ + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore); + if (ACPI_SUCCESS (Status)) + { + (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore); + ObjDesc->Event.OsSemaphore = TempSemaphore; + } + + return (Status); +} + diff --git a/drivers/bus/acpi/acpica/executer/exutils.c b/drivers/bus/acpi/acpica/executer/exutils.c new file mode 100644 index 00000000000..1f5e861b68c --- /dev/null +++ b/drivers/bus/acpi/acpica/executer/exutils.c @@ -0,0 +1,574 @@ + +/****************************************************************************** + * + * Module Name: exutils - interpreter/scanner utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EXUTILS_C__ + +/* + * DEFINE_AML_GLOBALS is tested in amlcode.h + * to determine whether certain global names should be "defined" or only + * "declared" in the current compilation. This enhances maintainability + * by enabling a single header file to embody all knowledge of the names + * in question. + * + * Exactly one module of any executable should #define DEFINE_GLOBALS + * before #including the header files which use this convention. The + * names in question will be defined and initialized in that module, + * and declared as extern in all other modules which #include those + * header files. + */ + +#define DEFINE_AML_GLOBALS + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exutils") + +/* Local prototypes */ + +static UINT32 +AcpiExDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base); + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiExEnterInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Enter the interpreter execution region. Failure to enter + * the interpreter region is a fatal system error. Used in + * conjunction with ExitInterpreter. + * + ******************************************************************************/ + +void +AcpiExEnterInterpreter ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExEnterInterpreter); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReacquireInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Reacquire the interpreter execution region from within the + * interpreter code. Failure to enter the interpreter region is a + * fatal system error. Used in conjuction with + * RelinquishInterpreter + * + ******************************************************************************/ + +void +AcpiExReacquireInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExReacquireInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter, + * since it was not actually released by AcpiExRelinquishInterpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExEnterInterpreter (); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExExitInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Exit the interpreter execution region. This is the top level + * routine used to exit the interpreter when all processing has + * been completed. + * + ******************************************************************************/ + +void +AcpiExExitInterpreter ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExExitInterpreter); + + + Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRelinquishInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Exit the interpreter execution region, from within the + * interpreter - before attempting an operation that will possibly + * block the running thread. + * + * Cases where the interpreter is unlocked internally + * 1) Method to be blocked on a Sleep() AML opcode + * 2) Method to be blocked on an Acquire() AML opcode + * 3) Method to be blocked on a Wait() AML opcode + * 4) Method to be blocked to acquire the global lock + * 5) Method to be blocked waiting to execute a serialized control method + * that is currently executing + * 6) About to invoke a user-installed opregion handler + * + ******************************************************************************/ + +void +AcpiExRelinquishInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExRelinquishInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExExitInterpreter (); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExTruncateFor32bitTable + * + * PARAMETERS: ObjDesc - Object to be truncated + * + * RETURN: none + * + * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is + * 32-bit, as determined by the revision of the DSDT. + * + ******************************************************************************/ + +void +AcpiExTruncateFor32bitTable ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* + * Object must be a valid number and we must be executing + * a control method. NS node could be there for AML_INT_NAMEPATH_OP. + */ + if ((!ObjDesc) || + (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) || + (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) + { + return; + } + + if (AcpiGbl_IntegerByteWidth == 4) + { + /* + * We are running a method that exists in a 32-bit ACPI table. + * Truncate the value to 32 bits by zeroing out the upper 32-bit field + */ + ObjDesc->Integer.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAcquireGlobalLock + * + * PARAMETERS: FieldFlags - Flags with Lock rule: + * AlwaysLock or NeverLock + * + * RETURN: None + * + * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field + * flags specifiy that it is to be obtained before field access. + * + ******************************************************************************/ + +void +AcpiExAcquireGlobalLock ( + UINT32 FieldFlags) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExAcquireGlobalLock); + + + /* Only use the lock if the AlwaysLock bit is set */ + + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) + { + return_VOID; + } + + /* Attempt to get the global lock, wait forever */ + + Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER, + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not acquire Global Lock")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseGlobalLock + * + * PARAMETERS: FieldFlags - Flags with Lock rule: + * AlwaysLock or NeverLock + * + * RETURN: None + * + * DESCRIPTION: Release the ACPI hardware Global Lock + * + ******************************************************************************/ + +void +AcpiExReleaseGlobalLock ( + UINT32 FieldFlags) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExReleaseGlobalLock); + + + /* Only use the lock if the AlwaysLock bit is set */ + + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) + { + return_VOID; + } + + /* Release the global lock */ + + Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); + if (ACPI_FAILURE (Status)) + { + /* Report the error, but there isn't much else we can do */ + + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not release Global Lock")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDigitsNeeded + * + * PARAMETERS: Value - Value to be represented + * Base - Base of representation + * + * RETURN: The number of digits. + * + * DESCRIPTION: Calculate the number of digits needed to represent the Value + * in the given Base (Radix) + * + ******************************************************************************/ + +static UINT32 +AcpiExDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base) +{ + UINT32 NumDigits; + ACPI_INTEGER CurrentValue; + + + ACPI_FUNCTION_TRACE (ExDigitsNeeded); + + + /* ACPI_INTEGER is unsigned, so we don't worry about a '-' prefix */ + + if (Value == 0) + { + return_UINT32 (1); + } + + CurrentValue = Value; + NumDigits = 0; + + /* Count the digits in the requested base */ + + while (CurrentValue) + { + (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL); + NumDigits++; + } + + return_UINT32 (NumDigits); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExEisaIdToString + * + * PARAMETERS: CompressedId - EISAID to be converted + * OutString - Where to put the converted string (8 bytes) + * + * RETURN: None + * + * DESCRIPTION: Convert a numeric EISAID to string representation. Return + * buffer must be large enough to hold the string. The string + * returned is always exactly of length ACPI_EISAID_STRING_SIZE + * (includes null terminator). The EISAID is always 32 bits. + * + ******************************************************************************/ + +void +AcpiExEisaIdToString ( + char *OutString, + ACPI_INTEGER CompressedId) +{ + UINT32 SwappedId; + + + ACPI_FUNCTION_ENTRY (); + + + /* The EISAID should be a 32-bit integer */ + + if (CompressedId > ACPI_UINT32_MAX) + { + ACPI_WARNING ((AE_INFO, + "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating", + ACPI_FORMAT_UINT64 (CompressedId))); + } + + /* Swap ID to big-endian to get contiguous bits */ + + SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId); + + /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */ + + OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F)); + OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F)); + OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F)); + OutString[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 12); + OutString[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 8); + OutString[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 4); + OutString[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 0); + OutString[7] = 0; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExIntegerToString + * + * PARAMETERS: OutString - Where to put the converted string. At least + * 21 bytes are needed to hold the largest + * possible 64-bit integer. + * Value - Value to be converted + * + * RETURN: None, string + * + * DESCRIPTION: Convert a 64-bit integer to decimal string representation. + * Assumes string buffer is large enough to hold the string. The + * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1). + * + ******************************************************************************/ + +void +AcpiExIntegerToString ( + char *OutString, + ACPI_INTEGER Value) +{ + UINT32 Count; + UINT32 DigitsNeeded; + UINT32 Remainder; + + + ACPI_FUNCTION_ENTRY (); + + + DigitsNeeded = AcpiExDigitsNeeded (Value, 10); + OutString[DigitsNeeded] = 0; + + for (Count = DigitsNeeded; Count > 0; Count--) + { + (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder); + OutString[Count-1] = (char) ('0' + Remainder);\ + } +} + +#endif diff --git a/drivers/bus/acpi/acpica/hardware/hwacpi.c b/drivers/bus/acpi/acpica/hardware/hwacpi.c new file mode 100644 index 00000000000..6b6d90ee02e --- /dev/null +++ b/drivers/bus/acpi/acpica/hardware/hwacpi.c @@ -0,0 +1,278 @@ + +/****************************************************************************** + * + * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWACPI_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwacpi") + + +/****************************************************************************** + * + * FUNCTION: AcpiHwSetMode + * + * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * RETURN: Status + * + * DESCRIPTION: Transitions the system into the requested mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode) +{ + + ACPI_STATUS Status; + UINT32 Retry; + + + ACPI_FUNCTION_TRACE (HwSetMode); + + /* + * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, + * system does not support mode transition. + */ + if (!AcpiGbl_FADT.SmiCommand) + { + ACPI_ERROR ((AE_INFO, "No SMI_CMD in FADT, mode transition failed")); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + } + + /* + * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE + * in FADT: If it is zero, enabling or disabling is not supported. + * As old systems may have used zero for mode transition, + * we make sure both the numbers are zero to determine these + * transitions are not supported. + */ + if (!AcpiGbl_FADT.AcpiEnable && !AcpiGbl_FADT.AcpiDisable) + { + ACPI_ERROR ((AE_INFO, + "No ACPI mode transition supported in this system " + "(enable/disable both zero)")); + return_ACPI_STATUS (AE_OK); + } + + switch (Mode) + { + case ACPI_SYS_MODE_ACPI: + + /* BIOS should have disabled ALL fixed and GP events */ + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.AcpiEnable, 8); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); + break; + + case ACPI_SYS_MODE_LEGACY: + + /* + * BIOS should clear all fixed status bits and restore fixed event + * enable bits to default + */ + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.AcpiDisable, 8); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Attempting to enable Legacy (non-ACPI) mode\n")); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not write ACPI mode change")); + return_ACPI_STATUS (Status); + } + + /* + * Some hardware takes a LONG time to switch modes. Give them 3 sec to + * do so, but allow faster systems to proceed more quickly. + */ + Retry = 3000; + while (Retry) + { + if (AcpiHwGetMode() == Mode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", + Mode)); + return_ACPI_STATUS (AE_OK); + } + AcpiOsStall(1000); + Retry--; + } + + ACPI_ERROR ((AE_INFO, "Hardware did not change modes")); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwGetMode + * + * PARAMETERS: none + * + * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * DESCRIPTION: Return current operating state of system. Determined by + * querying the SCI_EN bit. + * + ******************************************************************************/ + +UINT32 +AcpiHwGetMode ( + void) +{ + ACPI_STATUS Status; + UINT32 Value; + + + ACPI_FUNCTION_TRACE (HwGetMode); + + + /* + * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, + * system does not support mode transition. + */ + if (!AcpiGbl_FADT.SmiCommand) + { + return_UINT32 (ACPI_SYS_MODE_ACPI); + } + + Status = AcpiReadBitRegister (ACPI_BITREG_SCI_ENABLE, &Value); + if (ACPI_FAILURE (Status)) + { + return_UINT32 (ACPI_SYS_MODE_LEGACY); + } + + if (Value) + { + return_UINT32 (ACPI_SYS_MODE_ACPI); + } + else + { + return_UINT32 (ACPI_SYS_MODE_LEGACY); + } +} diff --git a/drivers/bus/acpi/acpica/hardware/hwgpe.c b/drivers/bus/acpi/acpica/hardware/hwgpe.c new file mode 100644 index 00000000000..a45603d9d5f --- /dev/null +++ b/drivers/bus/acpi/acpica/hardware/hwgpe.c @@ -0,0 +1,597 @@ + +/****************************************************************************** + * + * Module Name: hwgpe - Low level GPE enable/disable/clear functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwgpe") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/****************************************************************************** + * + * FUNCTION: AcpiHwLowDisableGpe + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled + * + * RETURN: Status + * + * DESCRIPTION: Disable a single GPE in the enable register. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwLowDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_STATUS Status; + UINT32 EnableMask; + + + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return (AE_NOT_EXIST); + } + + /* Get current value of the enable register that contains this GPE */ + + Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Clear just the bit that corresponds to this GPE */ + + ACPI_CLEAR_BIT (EnableMask, ((UINT32) 1 << + (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber))); + + + /* Write the updated enable mask */ + + Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWriteGpeEnableReg + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled + * + * RETURN: Status + * + * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must + * already be cleared or set in the parent register + * EnableForRun mask. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWriteGpeEnableReg ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return (AE_NOT_EXIST); + } + + /* Write the entire GPE (runtime) enable register */ + + Status = AcpiHwWrite (GpeRegisterInfo->EnableForRun, + &GpeRegisterInfo->EnableAddress); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwClearGpe + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared + * + * RETURN: Status + * + * DESCRIPTION: Clear the status bit for a single GPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwClearGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + UINT8 RegisterBit; + + + ACPI_FUNCTION_ENTRY (); + + + RegisterBit = (UINT8) (1 << + (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + + /* + * Write a one to the appropriate bit in the status register to + * clear this GPE. + */ + Status = AcpiHwWrite (RegisterBit, + &GpeEventInfo->RegisterInfo->StatusAddress); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwGetGpeStatus + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to queried + * EventStatus - Where the GPE status is returned + * + * RETURN: Status + * + * DESCRIPTION: Return the status of a single GPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwGetGpeStatus ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + ACPI_EVENT_STATUS *EventStatus) +{ + UINT32 InByte; + UINT8 RegisterBit; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_STATUS Status; + ACPI_EVENT_STATUS LocalEventStatus = 0; + + + ACPI_FUNCTION_ENTRY (); + + + if (!EventStatus) + { + return (AE_BAD_PARAMETER); + } + + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + + /* Get the register bitmask for this GPE */ + + RegisterBit = (UINT8) (1 << + (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + + /* GPE currently enabled? (enabled for runtime?) */ + + if (RegisterBit & GpeRegisterInfo->EnableForRun) + { + LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; + } + + /* GPE enabled for wake? */ + + if (RegisterBit & GpeRegisterInfo->EnableForWake) + { + LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED; + } + + /* GPE currently active (status bit == 1)? */ + + Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + if (RegisterBit & InByte) + { + LocalEventStatus |= ACPI_EVENT_FLAG_SET; + } + + /* Set return value */ + + (*EventStatus) = LocalEventStatus; + + +UnlockAndExit: + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwDisableGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Disable all GPEs within a single GPE block + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwDisableGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Disable all GPEs in this register */ + + Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwClearGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Clear status bits for all GPEs within a single GPE block + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwClearGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Clear status on all GPEs in this register */ + + Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableRuntimeGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes + * combination wake/run GPEs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* NOTE: assumes that all GPEs are currently disabled */ + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + if (!GpeBlock->RegisterInfo[i].EnableForRun) + { + continue; + } + + /* Enable all "runtime" GPEs in this register */ + + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun, + &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableWakeupGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes + * combination wake/run GPEs. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + if (!GpeBlock->RegisterInfo[i].EnableForWake) + { + continue; + } + + /* Enable all "wake" GPEs in this register */ + + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake, + &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwDisableAllGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Disable and clear all GPEs in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwDisableAllGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwDisableAllGpes); + + + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableAllRuntimeGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableAllRuntimeGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes); + + + Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableAllWakeupGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableAllWakeupGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes); + + + Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL); + return_ACPI_STATUS (Status); +} + diff --git a/drivers/bus/acpi/acpica/hardware/hwregs.c b/drivers/bus/acpi/acpica/hardware/hwregs.c new file mode 100644 index 00000000000..163840d7f4a --- /dev/null +++ b/drivers/bus/acpi/acpica/hardware/hwregs.c @@ -0,0 +1,805 @@ + +/******************************************************************************* + * + * Module Name: hwregs - Read/write access functions for the various ACPI + * control and status registers. + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWREGS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwregs") + + +/* Local Prototypes */ + +static ACPI_STATUS +AcpiHwReadMultiple ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB); + +static ACPI_STATUS +AcpiHwWriteMultiple ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB); + + +/****************************************************************************** + * + * FUNCTION: AcpiHwValidateRegister + * + * PARAMETERS: Reg - GAS register structure + * MaxBitWidth - Max BitWidth supported (32 or 64) + * Address - Pointer to where the gas->address + * is returned + * + * RETURN: Status + * + * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS + * pointer, Address, SpaceId, BitWidth, and BitOffset. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwValidateRegister ( + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth, + UINT64 *Address) +{ + + /* Must have a valid pointer to a GAS structure */ + + if (!Reg) + { + return (AE_BAD_PARAMETER); + } + + /* + * Copy the target address. This handles possible alignment issues. + * Address must not be null. A null address also indicates an optional + * ACPI register that is not supported, so no error message. + */ + ACPI_MOVE_64_TO_64 (Address, &Reg->Address); + if (!(*Address)) + { + return (AE_BAD_ADDRESS); + } + + /* Validate the SpaceID */ + + if ((Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && + (Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported address space: 0x%X", Reg->SpaceId)); + return (AE_SUPPORT); + } + + /* Validate the BitWidth */ + + if ((Reg->BitWidth != 8) && + (Reg->BitWidth != 16) && + (Reg->BitWidth != 32) && + (Reg->BitWidth != MaxBitWidth)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported register bit width: 0x%X", Reg->BitWidth)); + return (AE_SUPPORT); + } + + /* Validate the BitOffset. Just a warning for now. */ + + if (Reg->BitOffset != 0) + { + ACPI_WARNING ((AE_INFO, + "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRead + * + * PARAMETERS: Value - Where the value is returned + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max + * version of AcpiRead, used internally since the overhead of + * 64-bit values is not needed. + * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, or 32. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRead ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwRead); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Initialize entire 32-bit return value to zero */ + + *Value = 0; + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", + *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWrite + * + * PARAMETERS: Value - Value to be written + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max + * version of AcpiWrite, used internally since the overhead of + * 64-bit values is not needed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWrite ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwWrite); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", + Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwClearAcpiStatus + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Clears all fixed and general purpose status bits + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwClearAcpiStatus ( + void) +{ + ACPI_STATUS Status; + ACPI_CPU_FLAGS LockFlags = 0; + + + ACPI_FUNCTION_TRACE (HwClearAcpiStatus); + + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n", + ACPI_BITMASK_ALL_FIXED_STATUS, + ACPI_FORMAT_UINT64 (AcpiGbl_XPm1aStatus.Address))); + + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); + + /* Clear the fixed events in PM1 A/B */ + + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, + ACPI_BITMASK_ALL_FIXED_STATUS); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Clear the GPE Bits in all GPE registers in all GPE blocks */ + + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); + +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwGetRegisterBitMask + * + * PARAMETERS: RegisterId - Index of ACPI Register to access + * + * RETURN: The bitmask to be used when accessing the register + * + * DESCRIPTION: Map RegisterId into a register bitmask. + * + ******************************************************************************/ + +ACPI_BIT_REGISTER_INFO * +AcpiHwGetBitRegisterInfo ( + UINT32 RegisterId) +{ + ACPI_FUNCTION_ENTRY (); + + + if (RegisterId > ACPI_BITREG_MAX) + { + ACPI_ERROR ((AE_INFO, "Invalid BitRegister ID: %X", RegisterId)); + return (NULL); + } + + return (&AcpiGbl_BitRegisterInfo[RegisterId]); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWritePm1Control + * + * PARAMETERS: Pm1aControl - Value to be written to PM1A control + * Pm1bControl - Value to be written to PM1B control + * + * RETURN: Status + * + * DESCRIPTION: Write the PM1 A/B control registers. These registers are + * different than than the PM1 A/B status and enable registers + * in that different values can be written to the A/B registers. + * Most notably, the SLP_TYP bits can be different, as per the + * values returned from the _Sx predefined methods. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWritePm1Control ( + UINT32 Pm1aControl, + UINT32 Pm1bControl) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwWritePm1Control); + + + Status = AcpiHwWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (AcpiGbl_FADT.XPm1bControlBlock.Address) + { + Status = AcpiHwWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock); + } + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRegisterRead + * + * PARAMETERS: RegisterId - ACPI Register ID + * ReturnValue - Where the register value is returned + * + * RETURN: Status and the value read. + * + * DESCRIPTION: Read from the specified ACPI register + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRegisterRead ( + UINT32 RegisterId, + UINT32 *ReturnValue) +{ + UINT32 Value = 0; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwRegisterRead); + + + switch (RegisterId) + { + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); + break; + + + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); + break; + + + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); + + /* + * Zero the write-only bits. From the ACPI specification, "Hardware + * Write-Only Bits": "Upon reads to registers with write-only bits, + * software masks out all write-only bits." + */ + Value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS; + break; + + + case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ + + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock); + break; + + + case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ + + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock); + break; + + + case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ + + Status = AcpiHwReadPort (AcpiGbl_FADT.SmiCommand, &Value, 8); + break; + + + default: + ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", + RegisterId)); + Status = AE_BAD_PARAMETER; + break; + } + + if (ACPI_SUCCESS (Status)) + { + *ReturnValue = Value; + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRegisterWrite + * + * PARAMETERS: RegisterId - ACPI Register ID + * Value - The value to write + * + * RETURN: Status + * + * DESCRIPTION: Write to the specified ACPI register + * + * NOTE: In accordance with the ACPI specification, this function automatically + * preserves the value of the following bits, meaning that these bits cannot be + * changed via this interface: + * + * PM1_CONTROL[0] = SCI_EN + * PM1_CONTROL[9] + * PM1_STATUS[11] + * + * ACPI References: + * 1) Hardware Ignored Bits: When software writes to a register with ignored + * bit fields, it preserves the ignored bit fields + * 2) SCI_EN: OSPM always preserves this bit position + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRegisterWrite ( + UINT32 RegisterId, + UINT32 Value) +{ + ACPI_STATUS Status; + UINT32 ReadValue; + + + ACPI_FUNCTION_TRACE (HwRegisterWrite); + + + switch (RegisterId) + { + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ + /* + * Handle the "ignored" bit in PM1 Status. According to the ACPI + * specification, ignored bits are to be preserved when writing. + * Normally, this would mean a read/modify/write sequence. However, + * preserving a bit in the status register is different. Writing a + * one clears the status, and writing a zero preserves the status. + * Therefore, we must always write zero to the ignored bit. + * + * This behavior is clarified in the ACPI 4.0 specification. + */ + Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS; + + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); + break; + + + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); + break; + + + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ + + /* + * Perform a read first to preserve certain bits (per ACPI spec) + * Note: This includes SCI_EN, we never want to change this bit + */ + Status = AcpiHwReadMultiple (&ReadValue, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS (Value, ACPI_PM1_CONTROL_PRESERVED_BITS, ReadValue); + + /* Now we can write the data */ + + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); + break; + + + case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ + + /* + * For control registers, all reserved bits must be preserved, + * as per the ACPI spec. + */ + Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS (Value, ACPI_PM2_CONTROL_PRESERVED_BITS, ReadValue); + + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock); + break; + + + case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ + + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock); + break; + + + case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ + + /* SMI_CMD is currently always in IO space */ + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, Value, 8); + break; + + + default: + ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", + RegisterId)); + Status = AE_BAD_PARAMETER; + break; + } + +Exit: + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwReadMultiple + * + * PARAMETERS: Value - Where the register value is returned + * RegisterA - First ACPI register (required) + * RegisterB - Second ACPI register (optional) + * + * RETURN: Status + * + * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwReadMultiple ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB) +{ + UINT32 ValueA = 0; + UINT32 ValueB = 0; + ACPI_STATUS Status; + + + /* The first register is always required */ + + Status = AcpiHwRead (&ValueA, RegisterA); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Second register is optional */ + + if (RegisterB->Address) + { + Status = AcpiHwRead (&ValueB, RegisterB); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* + * OR the two return values together. No shifting or masking is necessary, + * because of how the PM1 registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" + */ + *Value = (ValueA | ValueB); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWriteMultiple + * + * PARAMETERS: Value - The value to write + * RegisterA - First ACPI register (required) + * RegisterB - Second ACPI register (optional) + * + * RETURN: Status + * + * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwWriteMultiple ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB) +{ + ACPI_STATUS Status; + + + /* The first register is always required */ + + Status = AcpiHwWrite (Value, RegisterA); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Second register is optional + * + * No bit shifting or clearing is necessary, because of how the PM1 + * registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" + */ + if (RegisterB->Address) + { + Status = AcpiHwWrite (Value, RegisterB); + } + + return (Status); +} + diff --git a/drivers/bus/acpi/acpica/hardware/hwsleep.c b/drivers/bus/acpi/acpica/hardware/hwsleep.c new file mode 100644 index 00000000000..fed4f1ddbf7 --- /dev/null +++ b/drivers/bus/acpi/acpica/hardware/hwsleep.c @@ -0,0 +1,711 @@ + +/****************************************************************************** + * + * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwsleep") + + +/******************************************************************************* + * + * FUNCTION: AcpiSetFirmwareWakingVector + * + * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode + * entry point. + * + * RETURN: Status + * + * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + UINT32 PhysicalAddress) +{ + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); + + + /* Set the 32-bit vector */ + + AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; + + /* Clear the 64-bit vector if it exists */ + + if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1)) + { + AcpiGbl_FACS->XFirmwareWakingVector = 0; + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) + + +#if ACPI_MACHINE_WIDTH == 64 +/******************************************************************************* + * + * FUNCTION: AcpiSetFirmwareWakingVector64 + * + * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected + * mode entry point. + * + * RETURN: Status + * + * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if + * it exists in the table. This function is intended for use with + * 64-bit host operating systems. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetFirmwareWakingVector64 ( + UINT64 PhysicalAddress) +{ + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64); + + + /* Determine if the 64-bit vector actually exists */ + + if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Clear 32-bit vector, set the 64-bit X_ vector */ + + AcpiGbl_FACS->FirmwareWakingVector = 0; + AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress; + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64) +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepStatePrep + * + * PARAMETERS: SleepState - Which sleep state to enter + * + * RETURN: Status + * + * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) + * This function must execute with interrupts enabled. + * We break sleeping into 2 stages so that OSPM can handle + * various OS-specific tasks between the two steps. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepStatePrep ( + UINT8 SleepState) +{ + ACPI_STATUS Status; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); + + + /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ + + Status = AcpiGetSleepTypeData (SleepState, + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Execute the _PTS method (Prepare To Sleep) */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = SleepState; + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Setup the argument to the _SST method (System STatus) */ + + switch (SleepState) + { + case ACPI_STATE_S0: + Arg.Integer.Value = ACPI_SST_WORKING; + break; + + case ACPI_STATE_S1: + case ACPI_STATE_S2: + case ACPI_STATE_S3: + Arg.Integer.Value = ACPI_SST_SLEEPING; + break; + + case ACPI_STATE_S4: + Arg.Integer.Value = ACPI_SST_SLEEP_CONTEXT; + break; + + default: + Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */ + break; + } + + /* + * Set the system indicators to show the desired sleep state. + * _SST is an optional method (return no error if not found) + */ + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "While executing method _SST")); + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepState + * + * PARAMETERS: SleepState - Which sleep state to enter + * + * RETURN: Status + * + * DESCRIPTION: Enter a system sleep state + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepState ( + UINT8 SleepState) +{ + UINT32 Pm1aControl; + UINT32 Pm1bControl; + ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; + ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; + UINT32 InValue; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepState); + + + if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || + (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) + { + ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=%X B=%X", + AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); + SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); + + /* Clear wake status */ + + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Clear all fixed and general purpose status bits */ + + Status = AcpiHwClearAcpiStatus (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (SleepState != ACPI_STATE_S5) + { + /* + * Disable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ + Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * 1) Disable/Clear all GPEs + * 2) Enable all wakeup GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Execute the _GTS method (Going To Sleep) */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = SleepState; + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__GTS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Get current value of PM1A control */ + + Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, + &Pm1aControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Entering sleep state [S%d]\n", SleepState)); + + /* Clear the SLP_EN and SLP_TYP fields */ + + Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); + Pm1bControl = Pm1aControl; + + /* Insert the SLP_TYP bits */ + + Pm1aControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition); + Pm1bControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition); + + /* + * We split the writes of SLP_TYP and SLP_EN to workaround + * poorly implemented hardware. + */ + + /* Write #1: write the SLP_TYP data to the PM1 Control registers */ + + Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Insert the sleep enable (SLP_EN) bit */ + + Pm1aControl |= SleepEnableRegInfo->AccessBitMask; + Pm1bControl |= SleepEnableRegInfo->AccessBitMask; + + /* Flush caches, as per ACPI specification */ + + ACPI_FLUSH_CPU_CACHE (); + + /* Write #2: Write both SLP_TYP + SLP_EN */ + + Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (SleepState > ACPI_STATE_S3) + { + /* + * We wanted to sleep > S3, but it didn't happen (by virtue of the + * fact that we are still executing!) + * + * Wait ten seconds, then try again. This is to get S4/S5 to work on + * all machines. + * + * We wait so long to allow chipsets that poll this reg very slowly + * to still read the right value. Ideally, this block would go + * away entirely. + */ + AcpiOsStall (10000000); + + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_CONTROL, + SleepEnableRegInfo->AccessBitMask); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Wait until we enter sleep state */ + + do + { + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Spin until we wake */ + + } while (!InValue); + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepState) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepStateS4bios + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Perform a S4 bios request. + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepStateS4bios ( + void) +{ + UINT32 InValue; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); + + + /* Clear the wake status bit (PM1) */ + + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwClearAcpiStatus (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * 1) Disable/Clear all GPEs + * 2) Enable all wakeup GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_FLUSH_CPU_CACHE (); + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); + + do { + AcpiOsStall(1000); + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } while (!InValue); + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios) + + +/******************************************************************************* + * + * FUNCTION: AcpiLeaveSleepState + * + * PARAMETERS: SleepState - Which sleep state we just exited + * + * RETURN: Status + * + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep + * Called with interrupts ENABLED. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLeaveSleepState ( + UINT8 SleepState) +{ + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + ACPI_STATUS Status; + ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; + ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; + UINT32 Pm1aControl; + UINT32 Pm1bControl; + + + ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); + + + /* + * Set SLP_TYPE and SLP_EN to state S0. + * This is unclear from the ACPI Spec, but it is required + * by some machines. + */ + Status = AcpiGetSleepTypeData (ACPI_STATE_S0, + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + if (ACPI_SUCCESS (Status)) + { + SleepTypeRegInfo = + AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); + SleepEnableRegInfo = + AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); + + /* Get current value of PM1A control */ + + Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, + &Pm1aControl); + if (ACPI_SUCCESS (Status)) + { + /* Clear the SLP_EN and SLP_TYP fields */ + + Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); + Pm1bControl = Pm1aControl; + + /* Insert the SLP_TYP bits */ + + Pm1aControl |= (AcpiGbl_SleepTypeA << + SleepTypeRegInfo->BitPosition); + Pm1bControl |= (AcpiGbl_SleepTypeB << + SleepTypeRegInfo->BitPosition); + + /* Write the control registers and ignore any errors */ + + (void) AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); + } + } + + /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */ + + AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID; + + /* Setup parameter object */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + + /* Ignore any errors from these methods */ + + Arg.Integer.Value = ACPI_SST_WAKING; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); + } + + Arg.Integer.Value = SleepState; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _BFS")); + } + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _WAK")); + } + /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ + + /* + * Restore the GPEs: + * 1) Disable/Clear all GPEs + * 2) Enable all runtime GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = TRUE; + + Status = AcpiHwEnableAllRuntimeGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Enable power button */ + + (void) AcpiWriteBitRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, + ACPI_ENABLE_EVENT); + + (void) AcpiWriteBitRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, + ACPI_CLEAR_STATUS); + + /* + * Enable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ + Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 0); + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) + { + return_ACPI_STATUS (Status); + } + + Arg.Integer.Value = ACPI_SST_WORKING; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState) + diff --git a/drivers/bus/acpi/acpica/hardware/hwtimer.c b/drivers/bus/acpi/acpica/hardware/hwtimer.c new file mode 100644 index 00000000000..f86fb7f865e --- /dev/null +++ b/drivers/bus/acpi/acpica/hardware/hwtimer.c @@ -0,0 +1,288 @@ + +/****************************************************************************** + * + * Name: hwtimer.c - ACPI Power Management Timer Interface + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwtimer") + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimerResolution + * + * PARAMETERS: Resolution - Where the resolution is returned + * + * RETURN: Status and timer resolution + * + * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimerResolution ( + UINT32 *Resolution) +{ + ACPI_FUNCTION_TRACE (AcpiGetTimerResolution); + + + if (!Resolution) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0) + { + *Resolution = 24; + } + else + { + *Resolution = 32; + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTimerResolution) + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimer + * + * PARAMETERS: Ticks - Where the timer value is returned + * + * RETURN: Status and current timer value (ticks) + * + * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimer ( + UINT32 *Ticks) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetTimer); + + + if (!Ticks) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTimer) + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimerDuration + * + * PARAMETERS: StartTicks - Starting timestamp + * EndTicks - End timestamp + * TimeElapsed - Where the elapsed time is returned + * + * RETURN: Status and TimeElapsed + * + * DESCRIPTION: Computes the time elapsed (in microseconds) between two + * PM Timer time stamps, taking into account the possibility of + * rollovers, the timer resolution, and timer frequency. + * + * The PM Timer's clock ticks at roughly 3.6 times per + * _microsecond_, and its clock continues through Cx state + * transitions (unlike many CPU timestamp counters) -- making it + * a versatile and accurate timer. + * + * Note that this function accommodates only a single timer + * rollover. Thus for 24-bit timers, this function should only + * be used for calculating durations less than ~4.6 seconds + * (~20 minutes for 32-bit timers) -- calculations below: + * + * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec + * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimerDuration ( + UINT32 StartTicks, + UINT32 EndTicks, + UINT32 *TimeElapsed) +{ + ACPI_STATUS Status; + UINT32 DeltaTicks; + ACPI_INTEGER Quotient; + + + ACPI_FUNCTION_TRACE (AcpiGetTimerDuration); + + + if (!TimeElapsed) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Compute Tick Delta: + * Handle (max one) timer rollovers on 24-bit versus 32-bit timers. + */ + if (StartTicks < EndTicks) + { + DeltaTicks = EndTicks - StartTicks; + } + else if (StartTicks > EndTicks) + { + if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0) + { + /* 24-bit Timer */ + + DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF); + } + else + { + /* 32-bit Timer */ + + DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks; + } + } + else /* StartTicks == EndTicks */ + { + *TimeElapsed = 0; + return_ACPI_STATUS (AE_OK); + } + + /* + * Compute Duration (Requires a 64-bit multiply and divide): + * + * TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY; + */ + Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * 1000000, + PM_TIMER_FREQUENCY, &Quotient, NULL); + + *TimeElapsed = (UINT32) Quotient; + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTimerDuration) + diff --git a/drivers/bus/acpi/acpica/hardware/hwvalid.c b/drivers/bus/acpi/acpica/hardware/hwvalid.c new file mode 100644 index 00000000000..650b695b2cc --- /dev/null +++ b/drivers/bus/acpi/acpica/hardware/hwvalid.c @@ -0,0 +1,424 @@ + +/****************************************************************************** + * + * Module Name: hwvalid - I/O request validation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWVALID_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwvalid") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwValidateIoRequest ( + ACPI_IO_ADDRESS Address, + UINT32 BitWidth); + + +/* + * Protected I/O ports. Some ports are always illegal, and some are + * conditionally illegal. This table must remain ordered by port address. + * + * The table is used to implement the Microsoft port access rules that + * first appeared in Windows XP. Some ports are always illegal, and some + * ports are only illegal if the BIOS calls _OSI with a WinXP string or + * later (meaning that the BIOS itelf is post-XP.) + * + * This provides ACPICA with the desired port protections and + * Microsoft compatibility. + * + * Description of port entries: + * DMA: DMA controller + * PIC0: Programmable Interrupt Controller (8259A) + * PIT1: System Timer 1 + * PIT2: System Timer 2 failsafe + * RTC: Real-time clock + * CMOS: Extended CMOS + * DMA1: DMA 1 page registers + * DMA1L: DMA 1 Ch 0 low page + * DMA2: DMA 2 page registers + * DMA2L: DMA 2 low page refresh + * ARBC: Arbitration control + * SETUP: Reserved system board setup + * POS: POS channel select + * PIC1: Cascaded PIC + * IDMA: ISA DMA + * ELCR: PIC edge/level registers + * PCI: PCI configuration space + */ +static const ACPI_PORT_INFO AcpiProtectedPorts[] = +{ + {"DMA", 0x0000, 0x000F, ACPI_OSI_WIN_XP}, + {"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL}, + {"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP}, + {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP}, + {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP}, + {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP}, + {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP}, + {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP}, + {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP}, + {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP}, + {"ARBC", 0x0090, 0x0091, ACPI_OSI_WIN_XP}, + {"SETUP", 0x0093, 0x0094, ACPI_OSI_WIN_XP}, + {"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP}, + {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL}, + {"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP}, + {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL}, + {"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP} +}; + +#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (AcpiProtectedPorts) + + +/****************************************************************************** + * + * FUNCTION: AcpiHwValidateIoRequest + * + * PARAMETERS: Address Address of I/O port/register + * BitWidth Number of bits (8,16,32) + * + * RETURN: Status + * + * DESCRIPTION: Validates an I/O request (address/length). Certain ports are + * always illegal and some ports are only illegal depending on + * the requests the BIOS AML code makes to the predefined + * _OSI method. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwValidateIoRequest ( + ACPI_IO_ADDRESS Address, + UINT32 BitWidth) +{ + UINT32 i; + UINT32 ByteWidth; + ACPI_IO_ADDRESS LastAddress; + const ACPI_PORT_INFO *PortInfo; + + + ACPI_FUNCTION_TRACE (HwValidateIoRequest); + + + /* Supported widths are 8/16/32 */ + + if ((BitWidth != 8) && + (BitWidth != 16) && + (BitWidth != 32)) + { + return (AE_BAD_PARAMETER); + } + + PortInfo = AcpiProtectedPorts; + ByteWidth = ACPI_DIV_8 (BitWidth); + LastAddress = Address + ByteWidth - 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %p LastAddress %p Length %X", + ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, LastAddress), + ByteWidth)); + + /* Maximum 16-bit address in I/O space */ + + if (LastAddress > ACPI_UINT16_MAX) + { + ACPI_ERROR ((AE_INFO, + "Illegal I/O port address/length above 64K: 0x%p/%X", + ACPI_CAST_PTR (void, Address), ByteWidth)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* Exit if requested address is not within the protected port table */ + + if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End) + { + return_ACPI_STATUS (AE_OK); + } + + /* Check request against the list of protected I/O ports */ + + for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, PortInfo++) + { + /* + * Check if the requested address range will write to a reserved + * port. Four cases to consider: + * + * 1) Address range is contained completely in the port address range + * 2) Address range overlaps port range at the port range start + * 3) Address range overlaps port range at the port range end + * 4) Address range completely encompasses the port range + */ + if ((Address <= PortInfo->End) && (LastAddress >= PortInfo->Start)) + { + /* Port illegality may depend on the _OSI calls made by the BIOS */ + + if (AcpiGbl_OsiData >= PortInfo->OsiDependency) + { + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)", + ACPI_CAST_PTR (void, Address), ByteWidth, PortInfo->Name, + PortInfo->Start, PortInfo->End)); + + return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS); + } + } + + /* Finished if address range ends before the end of this port */ + + if (LastAddress <= PortInfo->End) + { + break; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwReadPort + * + * PARAMETERS: Address Address of I/O port/register to read + * Value Where value is placed + * Width Number of bits + * + * RETURN: Status and value read from port + * + * DESCRIPTION: Read data from an I/O port or register. This is a front-end + * to AcpiOsReadPort that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + ACPI_STATUS Status; + UINT32 OneByte; + UINT32 i; + + + /* Validate the entire request and perform the I/O */ + + Status = AcpiHwValidateIoRequest (Address, Width); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiOsReadPort (Address, Value, Width); + return (Status); + } + + if (Status != AE_AML_ILLEGAL_ADDRESS) + { + return (Status); + } + + /* + * There has been a protection violation within the request. Fall + * back to byte granularity port I/O and ignore the failing bytes. + * This provides Windows compatibility. + */ + for (i = 0, *Value = 0; i < Width; i += 8) + { + /* Validate and read one byte */ + + if (AcpiHwValidateIoRequest (Address, 8) == AE_OK) + { + Status = AcpiOsReadPort (Address, &OneByte, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *Value |= (OneByte << i); + } + + Address++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWritePort + * + * PARAMETERS: Address Address of I/O port/register to write + * Value Value to write + * Width Number of bits + * + * RETURN: Status + * + * DESCRIPTION: Write data to an I/O port or register. This is a front-end + * to AcpiOsWritePort that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + ACPI_STATUS Status; + UINT32 i; + + + /* Validate the entire request and perform the I/O */ + + Status = AcpiHwValidateIoRequest (Address, Width); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiOsWritePort (Address, Value, Width); + return (Status); + } + + if (Status != AE_AML_ILLEGAL_ADDRESS) + { + return (Status); + } + + /* + * There has been a protection violation within the request. Fall + * back to byte granularity port I/O and ignore the failing bytes. + * This provides Windows compatibility. + */ + for (i = 0; i < Width; i += 8) + { + /* Validate and write one byte */ + + if (AcpiHwValidateIoRequest (Address, 8) == AE_OK) + { + Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + Address++; + } + + return (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/hardware/hwxface.c b/drivers/bus/acpi/acpica/hardware/hwxface.c new file mode 100644 index 00000000000..6c345a593e1 --- /dev/null +++ b/drivers/bus/acpi/acpica/hardware/hwxface.c @@ -0,0 +1,710 @@ + +/****************************************************************************** + * + * Module Name: hwxface - Public ACPICA hardware interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwxface") + + +/****************************************************************************** + * + * FUNCTION: AcpiReset + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Set reset register in memory or IO space. Note: Does not + * support reset register in PCI config space, this must be + * handled separately. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReset ( + void) +{ + ACPI_GENERIC_ADDRESS *ResetReg; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiReset); + + + ResetReg = &AcpiGbl_FADT.ResetRegister; + + /* Check if the reset register is supported */ + + if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) || + !ResetReg->Address) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) + { + /* + * For I/O space, write directly to the OSL. This bypasses the port + * validation mechanism, which may block a valid write to the reset + * register. + */ + Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address, + AcpiGbl_FADT.ResetValue, ResetReg->BitWidth); + } + else + { + /* Write the reset value to the reset register */ + + Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiReset) + + +/****************************************************************************** + * + * FUNCTION: AcpiRead + * + * PARAMETERS: Value - Where the value is returned + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Read from either memory or IO space. + * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, 32, or 64. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRead ( + UINT64 *ReturnValue, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT32 Value; + UINT32 Width; + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (AcpiRead); + + + if (!ReturnValue) + { + return (AE_BAD_PARAMETER); + } + + /* Validate contents of the GAS register. Allow 64-bit transfers */ + + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Width = Reg->BitWidth; + if (Width == 64) + { + Width = 32; /* Break into two 32-bit transfers */ + } + + /* Initialize entire 64-bit return value to zero */ + + *ReturnValue = 0; + Value = 0; + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; + + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; + + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRead) + + +/****************************************************************************** + * + * FUNCTION: AcpiWrite + * + * PARAMETERS: Value - Value to be written + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Write to either memory or IO space. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWrite ( + UINT64 Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT32 Width; + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (AcpiWrite); + + + /* Validate contents of the GAS register. Allow 64-bit transfers */ + + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Width = Reg->BitWidth; + if (Width == 64) + { + Width = 32; /* Break into two 32-bit transfers */ + } + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Reg->BitWidth == 64) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Reg->BitWidth == 64) + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (Value), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWrite) + + +/******************************************************************************* + * + * FUNCTION: AcpiReadBitRegister + * + * PARAMETERS: RegisterId - ID of ACPI Bit Register to access + * ReturnValue - Value that was read from the register, + * normalized to bit position zero. + * + * RETURN: Status and the value read from the specified Register. Value + * returned is normalized to bit0 (is shifted all the way right) + * + * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock. + * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. + * + * Note: The hardware lock is not required when reading the ACPI bit registers + * since almost all of them are single bit and it does not matter that + * the parent hardware register can be split across two physical + * registers. The only multi-bit field is SLP_TYP in the PM1 control + * register, but this field does not cross an 8-bit boundary (nor does + * it make much sense to actually read this field.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReadBitRegister ( + UINT32 RegisterId, + UINT32 *ReturnValue) +{ + ACPI_BIT_REGISTER_INFO *BitRegInfo; + UINT32 RegisterValue; + UINT32 Value; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId); + + + /* Get the info structure corresponding to the requested ACPI Register */ + + BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); + if (!BitRegInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Read the entire parent register */ + + Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, + &RegisterValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Normalize the value that was read, mask off other bits */ + + Value = ((RegisterValue & BitRegInfo->AccessBitMask) + >> BitRegInfo->BitPosition); + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n", + RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value)); + + *ReturnValue = Value; + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiReadBitRegister) + + +/******************************************************************************* + * + * FUNCTION: AcpiWriteBitRegister + * + * PARAMETERS: RegisterId - ID of ACPI Bit Register to access + * Value - Value to write to the register, in bit + * position zero. The bit is automaticallly + * shifted to the correct position. + * + * RETURN: Status + * + * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock + * since most operations require a read/modify/write sequence. + * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. + * + * Note that at this level, the fact that there may be actually two + * hardware registers (A and B - and B may not exist) is abstracted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWriteBitRegister ( + UINT32 RegisterId, + UINT32 Value) +{ + ACPI_BIT_REGISTER_INFO *BitRegInfo; + ACPI_CPU_FLAGS LockFlags; + UINT32 RegisterValue; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId); + + + /* Get the info structure corresponding to the requested ACPI Register */ + + BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); + if (!BitRegInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); + + /* + * At this point, we know that the parent register is one of the + * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control + */ + if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS) + { + /* + * 1) Case for PM1 Enable, PM1 Control, and PM2 Control + * + * Perform a register read to preserve the bits that we are not + * interested in + */ + Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, + &RegisterValue); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* + * Insert the input bit into the value that was just read + * and write the register + */ + ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, + BitRegInfo->AccessBitMask, Value); + + Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister, + RegisterValue); + } + else + { + /* + * 2) Case for PM1 Status + * + * The Status register is different from the rest. Clear an event + * by writing 1, writing 0 has no effect. So, the only relevant + * information is the single bit we're interested in, all others + * should be written as 0 so they will be left unchanged. + */ + RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value, + BitRegInfo->BitPosition, BitRegInfo->AccessBitMask); + + /* No need to write the register if value is all zeros */ + + if (RegisterValue) + { + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, + RegisterValue); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n", + RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue)); + + +UnlockAndExit: + + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetSleepTypeData + * + * PARAMETERS: SleepState - Numeric sleep state + * *SleepTypeA - Where SLP_TYPa is returned + * *SleepTypeB - Where SLP_TYPb is returned + * + * RETURN: Status - ACPI status + * + * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep + * state. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetSleepTypeData ( + UINT8 SleepState, + UINT8 *SleepTypeA, + UINT8 *SleepTypeB) +{ + ACPI_STATUS Status = AE_OK; + ACPI_EVALUATE_INFO *Info; + + + ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData); + + + /* Validate parameters */ + + if ((SleepState > ACPI_S_STATES_MAX) || + !SleepTypeA || + !SleepTypeB) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Pathname = ACPI_CAST_PTR (char, AcpiGbl_SleepStateNames[SleepState]); + + /* Evaluate the namespace object containing the values for this state */ + + Status = AcpiNsEvaluate (Info); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%s while evaluating SleepState [%s]\n", + AcpiFormatException (Status), Info->Pathname)); + + goto Cleanup; + } + + /* Must have a return object */ + + if (!Info->ReturnObject) + { + ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]", + Info->Pathname)); + Status = AE_NOT_EXIST; + } + + /* It must be of type Package */ + + else if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package")); + Status = AE_AML_OPERAND_TYPE; + } + + /* + * The package must have at least two elements. NOTE (March 2005): This + * goes against the current ACPI spec which defines this object as a + * package with one encoded DWORD element. However, existing practice + * by BIOS vendors seems to be to have 2 or more elements, at least + * one per sleep type (A/B). + */ + else if (Info->ReturnObject->Package.Count < 2) + { + ACPI_ERROR ((AE_INFO, + "Sleep State return package does not have at least two elements")); + Status = AE_AML_NO_OPERAND; + } + + /* The first two elements must both be of type Integer */ + + else if (((Info->ReturnObject->Package.Elements[0])->Common.Type + != ACPI_TYPE_INTEGER) || + ((Info->ReturnObject->Package.Elements[1])->Common.Type + != ACPI_TYPE_INTEGER)) + { + ACPI_ERROR ((AE_INFO, + "Sleep State return package elements are not both Integers " + "(%s, %s)", + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[0]), + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[1]))); + Status = AE_AML_OPERAND_TYPE; + } + else + { + /* Valid _Sx_ package size, type, and value */ + + *SleepTypeA = (UINT8) + (Info->ReturnObject->Package.Elements[0])->Integer.Value; + *SleepTypeB = (UINT8) + (Info->ReturnObject->Package.Elements[1])->Integer.Value; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While evaluating SleepState [%s], bad Sleep object %p type %s", + Info->Pathname, Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); + } + + AcpiUtRemoveReference (Info->ReturnObject); + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData) diff --git a/drivers/bus/acpi/acpica/include/acapps.h b/drivers/bus/acpi/acpica/include/acapps.h new file mode 100644 index 00000000000..c5ebef1d4af --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acapps.h @@ -0,0 +1,252 @@ +/****************************************************************************** + * + * Module Name: acapps - common include for ACPI applications/tools + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACAPPS +#define _ACAPPS + + +#ifdef _MSC_VER /* disable some level-4 warnings */ +#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ +#endif + +#define FILE_SUFFIX_DISASSEMBLY "dsl" +#define ACPI_TABLE_FILE_SUFFIX ".dat" + + +/* + * getopt + */ +int +AcpiGetopt( + int argc, + char **argv, + char *opts); + +extern int AcpiGbl_Optind; +extern char *AcpiGbl_Optarg; + + +/* + * adisasm + */ +ACPI_STATUS +AdAmlDisassemble ( + BOOLEAN OutToFile, + char *Filename, + char *Prefix, + char **OutFilename, + BOOLEAN GetAllTables); + +void +AdPrintStatistics ( + void); + +ACPI_STATUS +AdFindDsdt( + UINT8 **DsdtPtr, + UINT32 *DsdtLength); + +void +AdDumpTables ( + void); + +ACPI_STATUS +AdGetLocalTables ( + char *Filename, + BOOLEAN GetAllTables); + +ACPI_STATUS +AdParseTable ( + ACPI_TABLE_HEADER *Table, + ACPI_OWNER_ID *OwnerId, + BOOLEAN LoadTable, + BOOLEAN External); + +ACPI_STATUS +AdDisplayTables ( + char *Filename, + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AdDisplayStatistics ( + void); + + +/* + * adwalk + */ +void +AcpiDmCrossReferenceNamespace ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId); + +void +AcpiDmDumpTree ( + ACPI_PARSE_OBJECT *Origin); + +void +AcpiDmFindOrphanMethods ( + ACPI_PARSE_OBJECT *Origin); + +void +AcpiDmFinishNamespaceLoad ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId); + +void +AcpiDmConvertResourceIndexes ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot); + + +/* + * adfile + */ +ACPI_STATUS +AdInitialize ( + void); + +char * +FlGenerateFilename ( + char *InputFilename, + char *Suffix); + +ACPI_STATUS +FlSplitInputPathname ( + char *InputPath, + char **OutDirectoryPath, + char **OutFilename); + +char * +FlGenerateFilename ( + char *InputFilename, + char *Suffix); + +char * +AdGenerateFilename ( + char *Prefix, + char *TableId); + +void +AdWriteTable ( + ACPI_TABLE_HEADER *Table, + UINT32 Length, + char *TableName, + char *OemTableId); + +#endif /* _ACAPPS */ + diff --git a/drivers/bus/acpi/acpica/include/accommon.h b/drivers/bus/acpi/acpica/include/accommon.h new file mode 100644 index 00000000000..690d3cdba95 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/accommon.h @@ -0,0 +1,136 @@ +/****************************************************************************** + * + * Name: accommon.h - Common include files for generation of ACPICA source + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACCOMMON_H__ +#define __ACCOMMON_H__ + +/* + * Common set of includes for all ACPICA source files. + * We put them here because we don't want to duplicate them + * in the the source code again and again. + * + * Note: The order of these include files is important. + */ +#include "acconfig.h" /* Global configuration constants */ +#include "acmacros.h" /* C macros */ +#include "aclocal.h" /* Internal data types */ +#include "acobject.h" /* ACPI internal object */ +#include "acstruct.h" /* Common structures */ +#include "acglobal.h" /* All global variables */ +#include "achware.h" /* Hardware defines and interfaces */ +#include "acutils.h" /* Utility interfaces */ + + +#endif /* __ACCOMMON_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acconfig.h b/drivers/bus/acpi/acpica/include/acconfig.h new file mode 100644 index 00000000000..8fbe0e371b2 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acconfig.h @@ -0,0 +1,279 @@ +/****************************************************************************** + * + * Name: acconfig.h - Global configuration constants + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACCONFIG_H +#define _ACCONFIG_H + + +/****************************************************************************** + * + * Configuration options + * + *****************************************************************************/ + +/* + * ACPI_DEBUG_OUTPUT - This switch enables all the debug facilities of the + * ACPI subsystem. This includes the DEBUG_PRINT output + * statements. When disabled, all DEBUG_PRINT + * statements are compiled out. + * + * ACPI_APPLICATION - Use this switch if the subsystem is going to be run + * at the application level. + * + */ + +/* + * OS name, used for the _OS object. The _OS object is essentially obsolete, + * but there is a large base of ASL/AML code in existing machines that check + * for the string below. The use of this string usually guarantees that + * the ASL will execute down the most tested code path. Also, there is some + * code that will not execute the _OSI method unless _OS matches the string + * below. Therefore, change this string at your own risk. + */ +#define ACPI_OS_NAME "Microsoft Windows NT" + +/* Maximum objects in the various object caches */ + +#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */ +#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ +#define ACPI_MAX_NAMESPACE_CACHE_DEPTH 96 /* Namespace objects */ + +/* + * Should the subsystem abort the loading of an ACPI table if the + * table checksum is incorrect? + */ +#define ACPI_CHECKSUM_ABORT FALSE + + +/****************************************************************************** + * + * Subsystem Constants + * + *****************************************************************************/ + +/* Version of ACPI supported */ + +#define ACPI_CA_SUPPORT_LEVEL 3 + +/* Maximum count for a semaphore object */ + +#define ACPI_MAX_SEMAPHORE_COUNT 256 + +/* Maximum object reference count (detects object deletion issues) */ + +#define ACPI_MAX_REFERENCE_COUNT 0x800 + +/* Default page size for use in mapping memory for operation regions */ + +#define ACPI_DEFAULT_PAGE_SIZE 4096 /* Must be power of 2 */ + +/* OwnerId tracking. 8 entries allows for 255 OwnerIds */ + +#define ACPI_NUM_OWNERID_MASKS 8 + +/* Size of the root table array is increased by this increment */ + +#define ACPI_ROOT_TABLE_SIZE_INCREMENT 4 + +/* Maximum number of While() loop iterations before forced abort */ + +#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* Method info (in WALK_STATE), containing local variables and argumetns */ + +#define ACPI_METHOD_NUM_LOCALS 8 +#define ACPI_METHOD_MAX_LOCAL 7 + +#define ACPI_METHOD_NUM_ARGS 7 +#define ACPI_METHOD_MAX_ARG 6 + +/* + * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG + */ +#define ACPI_OBJ_NUM_OPERANDS 8 +#define ACPI_OBJ_MAX_OPERAND 7 + +/* Number of elements in the Result Stack frame, can be an arbitrary value */ + +#define ACPI_RESULTS_FRAME_OBJ_NUM 8 + +/* + * Maximal number of elements the Result Stack can contain, + * it may be an arbitray value not exceeding the types of + * ResultSize and ResultCount (now UINT8). + */ +#define ACPI_RESULTS_OBJ_NUM_MAX 255 + +/* Constants used in searching for the RSDP in low memory */ + +#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ +#define ACPI_EBDA_PTR_LENGTH 2 +#define ACPI_EBDA_WINDOW_SIZE 1024 +#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */ +#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000 +#define ACPI_RSDP_SCAN_STEP 16 + +/* Operation regions */ + +#define ACPI_NUM_PREDEFINED_REGIONS 9 +#define ACPI_USER_REGION_BEGIN 0x80 + +/* Maximum SpaceIds for Operation Regions */ + +#define ACPI_MAX_ADDRESS_SPACE 255 + +/* Array sizes. Used for range checking also */ + +#define ACPI_MAX_MATCH_OPCODE 5 + +/* RSDP checksums */ + +#define ACPI_RSDP_CHECKSUM_LENGTH 20 +#define ACPI_RSDP_XCHECKSUM_LENGTH 36 + +/* SMBus and IPMI bidirectional buffer size */ + +#define ACPI_SMBUS_BUFFER_SIZE 34 +#define ACPI_IPMI_BUFFER_SIZE 66 + +/* _SxD and _SxW control methods */ + +#define ACPI_NUM_SxD_METHODS 4 +#define ACPI_NUM_SxW_METHODS 5 + + +/****************************************************************************** + * + * ACPI AML Debugger + * + *****************************************************************************/ + +#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */ + +#define ACPI_DEBUGGER_COMMAND_PROMPT '-' +#define ACPI_DEBUGGER_EXECUTE_PROMPT '%' + + +#endif /* _ACCONFIG_H */ + diff --git a/drivers/bus/acpi/acpica/include/acdebug.h b/drivers/bus/acpi/acpica/include/acdebug.h new file mode 100644 index 00000000000..82f2b6d49c1 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acdebug.h @@ -0,0 +1,449 @@ +/****************************************************************************** + * + * Name: acdebug.h - ACPI/AML debugger + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACDEBUG_H__ +#define __ACDEBUG_H__ + + +#define ACPI_DEBUG_BUFFER_SIZE 4196 + +typedef struct CommandInfo +{ + char *Name; /* Command Name */ + UINT8 MinArgs; /* Minimum arguments required */ + +} COMMAND_INFO; + +typedef struct ArgumentInfo +{ + char *Name; /* Argument Name */ + +} ARGUMENT_INFO; + +typedef struct acpi_execute_walk +{ + UINT32 Count; + UINT32 MaxCount; + +} ACPI_EXECUTE_WALK; + + +#define PARAM_LIST(pl) pl +#define DBTEST_OUTPUT_LEVEL(lvl) if (AcpiGbl_DbOpt_verbose) +#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ + AcpiOsPrintf PARAM_LIST(fp);} + +#define EX_NO_SINGLE_STEP 1 +#define EX_SINGLE_STEP 2 + + +/* + * dbxface - external debugger interfaces + */ +ACPI_STATUS +AcpiDbInitialize ( + void); + +void +AcpiDbTerminate ( + void); + +ACPI_STATUS +AcpiDbSingleStep ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 OpType); + + +/* + * dbcmds - debug commands and output routines + */ +ACPI_STATUS +AcpiDbDisassembleMethod ( + char *Name); + +void +AcpiDbDisplayTableInfo ( + char *TableArg); + +void +AcpiDbUnloadAcpiTable ( + char *TableArg, + char *InstanceArg); + +void +AcpiDbSetMethodBreakpoint ( + char *Location, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbSetMethodCallBreakpoint ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbGetBusInfo ( + void); + +void +AcpiDbDisassembleAml ( + char *Statements, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDumpNamespace ( + char *StartArg, + char *DepthArg); + +void +AcpiDbDumpNamespaceByOwner ( + char *OwnerArg, + char *DepthArg); + +void +AcpiDbSendNotify ( + char *Name, + UINT32 Value); + +void +AcpiDbSetMethodData ( + char *TypeArg, + char *IndexArg, + char *ValueArg); + +ACPI_STATUS +AcpiDbDisplayObjects ( + char *ObjTypeArg, + char *DisplayCountArg); + +ACPI_STATUS +AcpiDbFindNameInNamespace ( + char *NameArg); + +void +AcpiDbSetScope ( + char *Name); + +ACPI_STATUS +AcpiDbSleep ( + char *ObjectArg); + +void +AcpiDbFindReferences ( + char *ObjectArg); + +void +AcpiDbDisplayLocks ( + void); + +void +AcpiDbDisplayResources ( + char *ObjectArg); + +void +AcpiDbDisplayGpes ( + void); + +void +AcpiDbCheckIntegrity ( + void); + +void +AcpiDbGenerateGpe ( + char *GpeArg, + char *BlockArg); + +void +AcpiDbCheckPredefinedNames ( + void); + +void +AcpiDbBatchExecute ( + char *CountArg); + +/* + * dbdisply - debug display commands + */ +void +AcpiDbDisplayMethodInfo ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDecodeAndDisplayObject ( + char *Target, + char *OutputType); + +void +AcpiDbDisplayResultObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDbDisplayAllMethods ( + char *DisplayCountArg); + +void +AcpiDbDisplayArguments ( + void); + +void +AcpiDbDisplayLocals ( + void); + +void +AcpiDbDisplayResults ( + void); + +void +AcpiDbDisplayCallingTree ( + void); + +void +AcpiDbDisplayObjectType ( + char *ObjectArg); + +void +AcpiDbDisplayArgumentObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * dbexec - debugger control method execution + */ +void +AcpiDbExecute ( + char *Name, + char **Args, + UINT32 Flags); + +void +AcpiDbCreateExecutionThreads ( + char *NumThreadsArg, + char *NumLoopsArg, + char *MethodNameArg); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +UINT32 +AcpiDbGetCacheInfo ( + ACPI_MEMORY_LIST *Cache); +#endif + + +/* + * dbfileio - Debugger file I/O commands + */ +ACPI_OBJECT_TYPE +AcpiDbMatchArgument ( + char *UserArgument, + ARGUMENT_INFO *Arguments); + +void +AcpiDbCloseDebugFile ( + void); + +void +AcpiDbOpenDebugFile ( + char *Name); + +ACPI_STATUS +AcpiDbLoadAcpiTable ( + char *Filename); + +ACPI_STATUS +AcpiDbGetTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table); + +ACPI_STATUS +AcpiDbReadTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table); + + +/* + * dbhistry - debugger HISTORY command + */ +void +AcpiDbAddToHistory ( + char *CommandLine); + +void +AcpiDbDisplayHistory ( + void); + +char * +AcpiDbGetFromHistory ( + char *CommandNumArg); + + +/* + * dbinput - user front-end to the AML debugger + */ +ACPI_STATUS +AcpiDbCommandDispatch ( + char *InputBuffer, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void ACPI_SYSTEM_XFACE +AcpiDbExecuteThread ( + void *Context); + +ACPI_STATUS +AcpiDbUserCommands ( + char Prompt, + ACPI_PARSE_OBJECT *Op); + + +/* + * dbstats - Generation and display of ACPI table statistics + */ +void +AcpiDbGenerateStatistics ( + ACPI_PARSE_OBJECT *Root, + BOOLEAN IsMethod); + +ACPI_STATUS +AcpiDbDisplayStatistics ( + char *TypeArg); + + +/* + * dbutils - AML debugger utilities + */ +void +AcpiDbSetOutputDestination ( + UINT32 Where); + +void +AcpiDbDumpExternalObject ( + ACPI_OBJECT *ObjDesc, + UINT32 Level); + +void +AcpiDbPrepNamestring ( + char *Name); + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + char *Name); + +void +AcpiDbUInt32ToHexString ( + UINT32 Value, + char *Buffer); + +#endif /* __ACDEBUG_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acdisasm.h b/drivers/bus/acpi/acpica/include/acdisasm.h new file mode 100644 index 00000000000..de198ff5742 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acdisasm.h @@ -0,0 +1,757 @@ +/****************************************************************************** + * + * Name: acdisasm.h - AML disassembler + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACDISASM_H__ +#define __ACDISASM_H__ + +#include "amlresrc.h" + + +#define BLOCK_NONE 0 +#define BLOCK_PAREN 1 +#define BLOCK_BRACE 2 +#define BLOCK_COMMA_LIST 4 +#define ACPI_DEFAULT_RESNAME *(UINT32 *) "__RD" + + +typedef const struct acpi_dmtable_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + +} ACPI_DMTABLE_INFO; + +/* + * Values for Opcode above. + * Note: 0-7 must not change, used as a flag shift value + */ +#define ACPI_DMT_FLAG0 0 +#define ACPI_DMT_FLAG1 1 +#define ACPI_DMT_FLAG2 2 +#define ACPI_DMT_FLAG3 3 +#define ACPI_DMT_FLAG4 4 +#define ACPI_DMT_FLAG5 5 +#define ACPI_DMT_FLAG6 6 +#define ACPI_DMT_FLAG7 7 +#define ACPI_DMT_FLAGS0 8 +#define ACPI_DMT_FLAGS2 9 +#define ACPI_DMT_UINT8 10 +#define ACPI_DMT_UINT16 11 +#define ACPI_DMT_UINT24 12 +#define ACPI_DMT_UINT32 13 +#define ACPI_DMT_UINT56 14 +#define ACPI_DMT_UINT64 15 +#define ACPI_DMT_STRING 16 +#define ACPI_DMT_NAME4 17 +#define ACPI_DMT_NAME6 18 +#define ACPI_DMT_NAME8 19 +#define ACPI_DMT_CHKSUM 20 +#define ACPI_DMT_SPACEID 21 +#define ACPI_DMT_GAS 22 +#define ACPI_DMT_ASF 23 +#define ACPI_DMT_DMAR 24 +#define ACPI_DMT_HEST 25 +#define ACPI_DMT_HESTNTFY 26 +#define ACPI_DMT_HESTNTYP 27 +#define ACPI_DMT_MADT 28 +#define ACPI_DMT_SRAT 29 +#define ACPI_DMT_EXIT 30 +#define ACPI_DMT_SIG 31 +#define ACPI_DMT_FADTPM 32 +#define ACPI_DMT_BUF16 33 +#define ACPI_DMT_IVRS 34 + + +typedef +void (*ACPI_DMTABLE_HANDLER) ( + ACPI_TABLE_HEADER *Table); + +typedef struct acpi_dmtable_data +{ + char *Signature; + ACPI_DMTABLE_INFO *TableInfo; + ACPI_DMTABLE_HANDLER TableHandler; + char *Name; + +} ACPI_DMTABLE_DATA; + + +typedef struct acpi_op_walk_info +{ + UINT32 Level; + UINT32 LastLevel; + UINT32 Count; + UINT32 BitOffset; + UINT32 Flags; + ACPI_WALK_STATE *WalkState; + +} ACPI_OP_WALK_INFO; + +typedef +ACPI_STATUS (*ASL_WALK_CALLBACK) ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +typedef struct acpi_resource_tag +{ + UINT32 BitIndex; + char *Tag; + +} ACPI_RESOURCE_TAG; + +/* Strings used for decoding flags to ASL keywords */ + +extern const char *AcpiGbl_WordDecode[]; +extern const char *AcpiGbl_IrqDecode[]; +extern const char *AcpiGbl_LockRule[]; +extern const char *AcpiGbl_AccessTypes[]; +extern const char *AcpiGbl_UpdateRules[]; +extern const char *AcpiGbl_MatchOps[]; + +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsfHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoBoot[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoBert[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCpep[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCpep0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbgp[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGas[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest6[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest7[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest8[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest9[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestBank[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8b[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8c[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrsHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt5[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt6[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt7[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt8[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt9[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSbst[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlic[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlit[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWaet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[]; + + +/* + * dmtable + */ +void +AcpiDmDumpDataTable ( + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AcpiDmDumpTable ( + UINT32 TableLength, + UINT32 TableOffset, + void *Table, + UINT32 SubTableLength, + ACPI_DMTABLE_INFO *Info); + +void +AcpiDmLineHeader ( + UINT32 Offset, + UINT32 ByteLength, + char *Name); + +void +AcpiDmLineHeader2 ( + UINT32 Offset, + UINT32 ByteLength, + char *Name, + UINT32 Value); + + +/* + * dmtbdump + */ +void +AcpiDmDumpAsf ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpCpep ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpDmar ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpEinj ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpErst ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpFadt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpHest ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpIvrs ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMcfg ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMadt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMsct ( + ACPI_TABLE_HEADER *Table); + +UINT32 +AcpiDmDumpRsdp ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpRsdt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpSlit ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpSrat ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpWdat ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpXsdt ( + ACPI_TABLE_HEADER *Table); + + +/* + * dmwalk + */ +void +AcpiDmDisassemble ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Origin, + UINT32 NumOpcodes); + +void +AcpiDmWalkParseTree ( + ACPI_PARSE_OBJECT *Op, + ASL_WALK_CALLBACK DescendingCallback, + ASL_WALK_CALLBACK AscendingCallback, + void *Context); + + +/* + * dmopcode + */ +void +AcpiDmDisassembleOneOp ( + ACPI_WALK_STATE *WalkState, + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +UINT32 +AcpiDmListType ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmMethodFlags ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmFieldFlags ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmAddressSpace ( + UINT8 SpaceId); + +void +AcpiDmRegionFlags ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmMatchOp ( + ACPI_PARSE_OBJECT *Op); + + +/* + * dmnames + */ +UINT32 +AcpiDmDumpName ( + UINT32 Name); + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmNamestring ( + char *Name); + + +/* + * dmobject + */ +void +AcpiDmDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +void +AcpiDmDisplayArguments ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDmDisplayLocals ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDmDumpMethodInfo ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + + +/* + * dmbuffer + */ +void +AcpiDmDisasmByteList ( + UINT32 Level, + UINT8 *ByteData, + UINT32 ByteCount); + +void +AcpiDmByteList ( + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmIsEisaId ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmEisaId ( + UINT32 EncodedId); + +BOOLEAN +AcpiDmIsUnicodeBuffer ( + ACPI_PARSE_OBJECT *Op); + +BOOLEAN +AcpiDmIsStringBuffer ( + ACPI_PARSE_OBJECT *Op); + + +/* + * dmextern + */ +void +AcpiDmAddToExternalList ( + ACPI_PARSE_OBJECT *Op, + char *Path, + UINT8 Type, + UINT32 Value); + +void +AcpiDmAddExternalsToNamespace ( + void); + +UINT32 +AcpiDmGetExternalMethodCount ( + void); + +void +AcpiDmClearExternalList ( + void); + +void +AcpiDmEmitExternals ( + void); + + +/* + * dmresrc + */ +void +AcpiDmDumpInteger8 ( + UINT8 Value, + char *Name); + +void +AcpiDmDumpInteger16 ( + UINT16 Value, + char *Name); + +void +AcpiDmDumpInteger32 ( + UINT32 Value, + char *Name); + +void +AcpiDmDumpInteger64 ( + UINT64 Value, + char *Name); + +void +AcpiDmResourceTemplate ( + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op, + UINT8 *ByteData, + UINT32 ByteCount); + +ACPI_STATUS +AcpiDmIsResourceTemplate ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmBitList ( + UINT16 Mask); + +void +AcpiDmDescriptorName ( + void); + + +/* + * dmresrcl + */ +void +AcpiDmWordDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmDwordDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmExtendedDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmQwordDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmMemory24Descriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmMemory32Descriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmFixedMemory32Descriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmGenericRegisterDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmInterruptDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorLargeDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorCommon ( + char *Name, + UINT8 *ByteData, + UINT32 Length, + UINT32 Level); + + +/* + * dmresrcs + */ +void +AcpiDmIrqDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmDmaDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmIoDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmFixedIoDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmStartDependentDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmEndDependentDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorSmallDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + + +/* + * dmutils + */ +void +AcpiDmDecodeAttribute ( + UINT8 Attribute); + +void +AcpiDmIndent ( + UINT32 Level); + +BOOLEAN +AcpiDmCommaIfListMember ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmCommaIfFieldMember ( + ACPI_PARSE_OBJECT *Op); + + +/* + * dmrestag + */ +void +AcpiDmFindResources ( + ACPI_PARSE_OBJECT *Root); + +void +AcpiDmCheckResourceReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +#endif /* __ACDISASM_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acdispat.h b/drivers/bus/acpi/acpica/include/acdispat.h new file mode 100644 index 00000000000..2aa86232b2f --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acdispat.h @@ -0,0 +1,527 @@ +/****************************************************************************** + * + * Name: acdispat.h - dispatcher (parser to interpreter interface) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef _ACDISPAT_H_ +#define _ACDISPAT_H_ + + +#define NAMEOF_LOCAL_NTE "__L0" +#define NAMEOF_ARG_NTE "__A0" + + +/* + * dsopcode - support for late evaluation + */ +ACPI_STATUS +AcpiDsGetBufferFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetBankFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetRegionArguments ( + ACPI_OPERAND_OBJECT *RgnDesc); + +ACPI_STATUS +AcpiDsGetBufferArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetPackageArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsEvalBufferFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalTableRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalDataObjectOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsEvalBankFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsInitializeRegion ( + ACPI_HANDLE ObjHandle); + + +/* + * dsctrl - Parser/Interpreter interface, control stack routines + */ +ACPI_STATUS +AcpiDsExecBeginControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsExecEndControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + + +/* + * dsexec - Parser/Interpreter interface, method execution callbacks + */ +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ResultObj); + +ACPI_STATUS +AcpiDsExecBeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *State); + + +/* + * dsfield - Parser/Interpreter interface for AML fields + */ +ACPI_STATUS +AcpiDsCreateField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateBankField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateBufferField ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsInitFieldObjects ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + + +/* + * dsload - Parser/Interpreter interface, namespace load callbacks + */ +ACPI_STATUS +AcpiDsLoad1BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsInitCallbacks ( + ACPI_WALK_STATE *WalkState, + UINT32 PassNumber); + + +/* + * dsmthdat - method data (locals/args) + */ +ACPI_STATUS +AcpiDsStoreObjectToLocal ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *SrcDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataGetEntry ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT ***Node); + +void +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsIsMethodValue ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc); + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataGetNode ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **Node); + +void +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState); + + +/* + * dsmethod - Parser/Interpreter interface - control method parsing + */ +ACPI_STATUS +AcpiDsParseMethod ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_THREAD_STATE *Thread, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc); + +void +AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodError ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState); + +/* + * dsinit + */ +ACPI_STATUS +AcpiDsInitializeObjects ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + + +/* + * dsobject - Parser/Interpreter interface - object initialization and conversion + */ +ACPI_STATUS +AcpiDsBuildInternalBufferObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 BufferLength, + ACPI_OPERAND_OBJECT **ObjDescPtr); + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *op, + UINT32 PackageLength, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsInitObjectFromOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); + + +/* + * dsutils - Parser/Interpreter interface utility routines + */ +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference); + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg, + UINT32 ArgsRemaining); + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg); + +ACPI_STATUS +AcpiDsResolveOperands ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDsClearOperands ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsEvaluateNamePath ( + ACPI_WALK_STATE *WalkState); + + +/* + * dswscope - Scope Stack manipulation + */ +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_WALK_STATE *WalkState); + + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState); + + +/* + * dswstate - parser WALK_STATE management routines + */ +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_THREAD_STATE *Thread); + +ACPI_STATUS +AcpiDsInitAmlWalk ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *MethodNode, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_EVALUATE_INFO *Info, + UINT8 PassNumber); + +void +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteWalkState ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_THREAD_STATE *Thread); + +void +AcpiDsPushWalkState ( + ACPI_WALK_STATE *WalkState, + ACPI_THREAD_STATE *Thread); + +ACPI_STATUS +AcpiDsResultStackClear ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsGetCurrentWalkState ( + ACPI_THREAD_STATE *Thread); + +ACPI_STATUS +AcpiDsResultPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsResultPush ( + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + +#endif /* _ACDISPAT_H_ */ diff --git a/drivers/bus/acpi/acpica/include/acevents.h b/drivers/bus/acpi/acpica/include/acevents.h new file mode 100644 index 00000000000..0cd5e2e2869 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acevents.h @@ -0,0 +1,375 @@ +/****************************************************************************** + * + * Name: acevents.h - Event subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEVENTS_H__ +#define __ACEVENTS_H__ + + +/* + * evevent + */ +ACPI_STATUS +AcpiEvInitializeEvents ( + void); + +ACPI_STATUS +AcpiEvInstallXruptHandlers ( + void); + +ACPI_STATUS +AcpiEvInstallFadtGpes ( + void); + +UINT32 +AcpiEvFixedEventDetect ( + void); + + +/* + * evmisc + */ +BOOLEAN +AcpiEvIsNotifyObject ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiEvAcquireGlobalLock( + UINT16 Timeout); + +ACPI_STATUS +AcpiEvReleaseGlobalLock( + void); + +ACPI_STATUS +AcpiEvInitGlobalLockHandler ( + void); + +UINT32 +AcpiEvGetGpeNumberIndex ( + UINT32 GpeNumber); + +ACPI_STATUS +AcpiEvQueueNotifyRequest ( + ACPI_NAMESPACE_NODE *Node, + UINT32 NotifyValue); + + +/* + * evgpe - GPE handling and dispatch + */ +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); + +ACPI_STATUS +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware); + +ACPI_STATUS +AcpiEvDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_GPE_EVENT_INFO * +AcpiEvGetGpeEventInfo ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber); + + +/* + * evgpeblk + */ +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context); + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_STATUS +AcpiEvCreateGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT8 GpeBlockBaseNumber, + UINT32 InterruptNumber, + ACPI_GPE_BLOCK_INFO **ReturnGpeBlock); + +ACPI_STATUS +AcpiEvInitializeGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GPE_BLOCK_INFO *GpeBlock); + +ACPI_STATUS +AcpiEvDeleteGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock); + +UINT32 +AcpiEvGpeDispatch ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT32 GpeNumber); + +UINT32 +AcpiEvGpeDetect ( + ACPI_GPE_XRUPT_INFO *GpeXruptList); + +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); + +ACPI_STATUS +AcpiEvCheckForWakeOnlyGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiEvGpeInitialize ( + void); + + +/* + * evregion - Address Space handling + */ +ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void); + +ACPI_STATUS +AcpiEvInitializeOpRegions ( + void); + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + UINT32 RegionOffset, + UINT32 BitWidth, + ACPI_INTEGER *Value); + +ACPI_STATUS +AcpiEvAttachRegion ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked); + +void +AcpiEvDetachRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked); + +ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId); + +ACPI_STATUS +AcpiEvExecuteRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function); + + +/* + * evregini - Region initialization and setup + */ +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvCmosRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvPciBarRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked); + + +/* + * evsci - SCI (System Control Interrupt) handling/dispatch + */ +UINT32 ACPI_SYSTEM_XFACE +AcpiEvGpeXruptHandler ( + void *Context); + +UINT32 +AcpiEvInstallSciHandler ( + void); + +ACPI_STATUS +AcpiEvRemoveSciHandler ( + void); + +UINT32 +AcpiEvInitializeSCI ( + UINT32 ProgramSCI); + +void +AcpiEvTerminate ( + void); + + +#endif /* __ACEVENTS_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acexcep.h b/drivers/bus/acpi/acpica/include/acexcep.h new file mode 100644 index 00000000000..dfe2e2ee734 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acexcep.h @@ -0,0 +1,382 @@ +/****************************************************************************** + * + * Name: acexcep.h - Exception codes returned by the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEXCEP_H__ +#define __ACEXCEP_H__ + + +/* + * Exceptions returned by external ACPI interfaces + */ +#define AE_CODE_ENVIRONMENTAL 0x0000 +#define AE_CODE_PROGRAMMER 0x1000 +#define AE_CODE_ACPI_TABLES 0x2000 +#define AE_CODE_AML 0x3000 +#define AE_CODE_CONTROL 0x4000 +#define AE_CODE_MASK 0xF000 + + +#define ACPI_SUCCESS(a) (!(a)) +#define ACPI_FAILURE(a) (a) + + +#define AE_OK (ACPI_STATUS) 0x0000 + +/* + * Environmental exceptions + */ +#define AE_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_ACPI_TABLES (ACPI_STATUS) (0x0002 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_NAMESPACE (ACPI_STATUS) (0x0003 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_MEMORY (ACPI_STATUS) (0x0004 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_FOUND (ACPI_STATUS) (0x0005 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_EXIST (ACPI_STATUS) (0x0006 | AE_CODE_ENVIRONMENTAL) +#define AE_ALREADY_EXISTS (ACPI_STATUS) (0x0007 | AE_CODE_ENVIRONMENTAL) +#define AE_TYPE (ACPI_STATUS) (0x0008 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_OBJECT (ACPI_STATUS) (0x0009 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_ENTRY (ACPI_STATUS) (0x000A | AE_CODE_ENVIRONMENTAL) +#define AE_BUFFER_OVERFLOW (ACPI_STATUS) (0x000B | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_OVERFLOW (ACPI_STATUS) (0x000C | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_UNDERFLOW (ACPI_STATUS) (0x000D | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_IMPLEMENTED (ACPI_STATUS) (0x000E | AE_CODE_ENVIRONMENTAL) +#define AE_SUPPORT (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL) +#define AE_LIMIT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL) +#define AE_TIME (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL) +#define AE_ACQUIRE_DEADLOCK (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL) +#define AE_RELEASE_DEADLOCK (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_ACQUIRED (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL) +#define AE_ALREADY_ACQUIRED (ACPI_STATUS) (0x0015 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_HARDWARE_RESPONSE (ACPI_STATUS) (0x0016 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_GLOBAL_LOCK (ACPI_STATUS) (0x0017 | AE_CODE_ENVIRONMENTAL) +#define AE_ABORT_METHOD (ACPI_STATUS) (0x0018 | AE_CODE_ENVIRONMENTAL) +#define AE_SAME_HANDLER (ACPI_STATUS) (0x0019 | AE_CODE_ENVIRONMENTAL) +#define AE_WAKE_ONLY_GPE (ACPI_STATUS) (0x001A | AE_CODE_ENVIRONMENTAL) +#define AE_OWNER_ID_LIMIT (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL) + +#define AE_CODE_ENV_MAX 0x001B + + +/* + * Programmer exceptions + */ +#define AE_BAD_PARAMETER (ACPI_STATUS) (0x0001 | AE_CODE_PROGRAMMER) +#define AE_BAD_CHARACTER (ACPI_STATUS) (0x0002 | AE_CODE_PROGRAMMER) +#define AE_BAD_PATHNAME (ACPI_STATUS) (0x0003 | AE_CODE_PROGRAMMER) +#define AE_BAD_DATA (ACPI_STATUS) (0x0004 | AE_CODE_PROGRAMMER) +#define AE_BAD_HEX_CONSTANT (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER) +#define AE_BAD_OCTAL_CONSTANT (ACPI_STATUS) (0x0006 | AE_CODE_PROGRAMMER) +#define AE_BAD_DECIMAL_CONSTANT (ACPI_STATUS) (0x0007 | AE_CODE_PROGRAMMER) +#define AE_MISSING_ARGUMENTS (ACPI_STATUS) (0x0008 | AE_CODE_PROGRAMMER) +#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0009 | AE_CODE_PROGRAMMER) + +#define AE_CODE_PGM_MAX 0x0009 + + +/* + * Acpi table exceptions + */ +#define AE_BAD_SIGNATURE (ACPI_STATUS) (0x0001 | AE_CODE_ACPI_TABLES) +#define AE_BAD_HEADER (ACPI_STATUS) (0x0002 | AE_CODE_ACPI_TABLES) +#define AE_BAD_CHECKSUM (ACPI_STATUS) (0x0003 | AE_CODE_ACPI_TABLES) +#define AE_BAD_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_ACPI_TABLES) +#define AE_INVALID_TABLE_LENGTH (ACPI_STATUS) (0x0005 | AE_CODE_ACPI_TABLES) + +#define AE_CODE_TBL_MAX 0x0005 + + +/* + * AML exceptions. These are caused by problems with + * the actual AML byte stream + */ +#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0001 | AE_CODE_AML) +#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0002 | AE_CODE_AML) +#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0003 | AE_CODE_AML) +#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0005 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0006 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0007 | AE_CODE_AML) +#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x0008 | AE_CODE_AML) +#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x0009 | AE_CODE_AML) +#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000A | AE_CODE_AML) +#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML) +#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000C | AE_CODE_AML) +#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000D | AE_CODE_AML) +#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x000E | AE_CODE_AML) +#define AE_AML_INTERNAL (ACPI_STATUS) (0x000F | AE_CODE_AML) +#define AE_AML_INVALID_SPACE_ID (ACPI_STATUS) (0x0010 | AE_CODE_AML) +#define AE_AML_STRING_LIMIT (ACPI_STATUS) (0x0011 | AE_CODE_AML) +#define AE_AML_NO_RETURN_VALUE (ACPI_STATUS) (0x0012 | AE_CODE_AML) +#define AE_AML_METHOD_LIMIT (ACPI_STATUS) (0x0013 | AE_CODE_AML) +#define AE_AML_NOT_OWNER (ACPI_STATUS) (0x0014 | AE_CODE_AML) +#define AE_AML_MUTEX_ORDER (ACPI_STATUS) (0x0015 | AE_CODE_AML) +#define AE_AML_MUTEX_NOT_ACQUIRED (ACPI_STATUS) (0x0016 | AE_CODE_AML) +#define AE_AML_INVALID_RESOURCE_TYPE (ACPI_STATUS) (0x0017 | AE_CODE_AML) +#define AE_AML_INVALID_INDEX (ACPI_STATUS) (0x0018 | AE_CODE_AML) +#define AE_AML_REGISTER_LIMIT (ACPI_STATUS) (0x0019 | AE_CODE_AML) +#define AE_AML_NO_WHILE (ACPI_STATUS) (0x001A | AE_CODE_AML) +#define AE_AML_ALIGNMENT (ACPI_STATUS) (0x001B | AE_CODE_AML) +#define AE_AML_NO_RESOURCE_END_TAG (ACPI_STATUS) (0x001C | AE_CODE_AML) +#define AE_AML_BAD_RESOURCE_VALUE (ACPI_STATUS) (0x001D | AE_CODE_AML) +#define AE_AML_CIRCULAR_REFERENCE (ACPI_STATUS) (0x001E | AE_CODE_AML) +#define AE_AML_BAD_RESOURCE_LENGTH (ACPI_STATUS) (0x001F | AE_CODE_AML) +#define AE_AML_ILLEGAL_ADDRESS (ACPI_STATUS) (0x0020 | AE_CODE_AML) +#define AE_AML_INFINITE_LOOP (ACPI_STATUS) (0x0021 | AE_CODE_AML) + +#define AE_CODE_AML_MAX 0x0021 + + +/* + * Internal exceptions used for control + */ +#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) (0x0001 | AE_CODE_CONTROL) +#define AE_CTRL_PENDING (ACPI_STATUS) (0x0002 | AE_CODE_CONTROL) +#define AE_CTRL_TERMINATE (ACPI_STATUS) (0x0003 | AE_CODE_CONTROL) +#define AE_CTRL_TRUE (ACPI_STATUS) (0x0004 | AE_CODE_CONTROL) +#define AE_CTRL_FALSE (ACPI_STATUS) (0x0005 | AE_CODE_CONTROL) +#define AE_CTRL_DEPTH (ACPI_STATUS) (0x0006 | AE_CODE_CONTROL) +#define AE_CTRL_END (ACPI_STATUS) (0x0007 | AE_CODE_CONTROL) +#define AE_CTRL_TRANSFER (ACPI_STATUS) (0x0008 | AE_CODE_CONTROL) +#define AE_CTRL_BREAK (ACPI_STATUS) (0x0009 | AE_CODE_CONTROL) +#define AE_CTRL_CONTINUE (ACPI_STATUS) (0x000A | AE_CODE_CONTROL) +#define AE_CTRL_SKIP (ACPI_STATUS) (0x000B | AE_CODE_CONTROL) +#define AE_CTRL_PARSE_CONTINUE (ACPI_STATUS) (0x000C | AE_CODE_CONTROL) +#define AE_CTRL_PARSE_PENDING (ACPI_STATUS) (0x000D | AE_CODE_CONTROL) + +#define AE_CODE_CTRL_MAX 0x000D + + +/* Exception strings for AcpiFormatException */ + +#ifdef DEFINE_ACPI_GLOBALS + +/* + * String versions of the exception codes above + * These strings must match the corresponding defines exactly + */ +char const *AcpiGbl_ExceptionNames_Env[] = +{ + "AE_OK", + "AE_ERROR", + "AE_NO_ACPI_TABLES", + "AE_NO_NAMESPACE", + "AE_NO_MEMORY", + "AE_NOT_FOUND", + "AE_NOT_EXIST", + "AE_ALREADY_EXISTS", + "AE_TYPE", + "AE_NULL_OBJECT", + "AE_NULL_ENTRY", + "AE_BUFFER_OVERFLOW", + "AE_STACK_OVERFLOW", + "AE_STACK_UNDERFLOW", + "AE_NOT_IMPLEMENTED", + "AE_SUPPORT", + "AE_LIMIT", + "AE_TIME", + "AE_ACQUIRE_DEADLOCK", + "AE_RELEASE_DEADLOCK", + "AE_NOT_ACQUIRED", + "AE_ALREADY_ACQUIRED", + "AE_NO_HARDWARE_RESPONSE", + "AE_NO_GLOBAL_LOCK", + "AE_ABORT_METHOD", + "AE_SAME_HANDLER", + "AE_WAKE_ONLY_GPE", + "AE_OWNER_ID_LIMIT" +}; + +char const *AcpiGbl_ExceptionNames_Pgm[] = +{ + NULL, + "AE_BAD_PARAMETER", + "AE_BAD_CHARACTER", + "AE_BAD_PATHNAME", + "AE_BAD_DATA", + "AE_BAD_HEX_CONSTANT", + "AE_BAD_OCTAL_CONSTANT", + "AE_BAD_DECIMAL_CONSTANT", + "AE_MISSING_ARGUMENTS", + "AE_BAD_ADDRESS" +}; + +char const *AcpiGbl_ExceptionNames_Tbl[] = +{ + NULL, + "AE_BAD_SIGNATURE", + "AE_BAD_HEADER", + "AE_BAD_CHECKSUM", + "AE_BAD_VALUE", + "AE_INVALID_TABLE_LENGTH" +}; + +char const *AcpiGbl_ExceptionNames_Aml[] = +{ + NULL, + "AE_AML_BAD_OPCODE", + "AE_AML_NO_OPERAND", + "AE_AML_OPERAND_TYPE", + "AE_AML_OPERAND_VALUE", + "AE_AML_UNINITIALIZED_LOCAL", + "AE_AML_UNINITIALIZED_ARG", + "AE_AML_UNINITIALIZED_ELEMENT", + "AE_AML_NUMERIC_OVERFLOW", + "AE_AML_REGION_LIMIT", + "AE_AML_BUFFER_LIMIT", + "AE_AML_PACKAGE_LIMIT", + "AE_AML_DIVIDE_BY_ZERO", + "AE_AML_BAD_NAME", + "AE_AML_NAME_NOT_FOUND", + "AE_AML_INTERNAL", + "AE_AML_INVALID_SPACE_ID", + "AE_AML_STRING_LIMIT", + "AE_AML_NO_RETURN_VALUE", + "AE_AML_METHOD_LIMIT", + "AE_AML_NOT_OWNER", + "AE_AML_MUTEX_ORDER", + "AE_AML_MUTEX_NOT_ACQUIRED", + "AE_AML_INVALID_RESOURCE_TYPE", + "AE_AML_INVALID_INDEX", + "AE_AML_REGISTER_LIMIT", + "AE_AML_NO_WHILE", + "AE_AML_ALIGNMENT", + "AE_AML_NO_RESOURCE_END_TAG", + "AE_AML_BAD_RESOURCE_VALUE", + "AE_AML_CIRCULAR_REFERENCE", + "AE_AML_BAD_RESOURCE_LENGTH", + "AE_AML_ILLEGAL_ADDRESS", + "AE_AML_INFINITE_LOOP" +}; + +char const *AcpiGbl_ExceptionNames_Ctrl[] = +{ + NULL, + "AE_CTRL_RETURN_VALUE", + "AE_CTRL_PENDING", + "AE_CTRL_TERMINATE", + "AE_CTRL_TRUE", + "AE_CTRL_FALSE", + "AE_CTRL_DEPTH", + "AE_CTRL_END", + "AE_CTRL_TRANSFER", + "AE_CTRL_BREAK", + "AE_CTRL_CONTINUE", + "AE_CTRL_SKIP", + "AE_CTRL_PARSE_CONTINUE", + "AE_CTRL_PARSE_PENDING" +}; + +#endif /* ACPI GLOBALS */ + +#endif /* __ACEXCEP_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acglobal.h b/drivers/bus/acpi/acpica/include/acglobal.h new file mode 100644 index 00000000000..82fe445169d --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acglobal.h @@ -0,0 +1,494 @@ +/****************************************************************************** + * + * Name: acglobal.h - Declarations for global variables + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACGLOBAL_H__ +#define __ACGLOBAL_H__ + + +/* + * Ensure that the globals are actually defined and initialized only once. + * + * The use of these macros allows a single list of globals (here) in order + * to simplify maintenance of the code. + */ +#ifdef DEFINE_ACPI_GLOBALS +#define ACPI_EXTERN +#define ACPI_INIT_GLOBAL(a,b) a=b +#else +#define ACPI_EXTERN extern +#define ACPI_INIT_GLOBAL(a,b) a +#endif + + +#ifdef DEFINE_ACPI_GLOBALS + +/* Public globals, available from outside ACPICA subsystem */ + +/***************************************************************************** + * + * Runtime configuration (static defaults that can be overriden at runtime) + * + ****************************************************************************/ + +/* + * Enable "slack" in the AML interpreter? Default is FALSE, and the + * interpreter strictly follows the ACPI specification. Setting to TRUE + * allows the interpreter to ignore certain errors and/or bad AML constructs. + * + * Currently, these features are enabled by this flag: + * + * 1) Allow "implicit return" of last value in a control method + * 2) Allow access beyond the end of an operation region + * 3) Allow access to uninitialized locals/args (auto-init to integer 0) + * 4) Allow ANY object type to be a source operand for the Store() operator + * 5) Allow unresolved references (invalid target name) in package objects + * 6) Enable warning messages for behavior that is not ACPI spec compliant + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); + +/* + * Automatically serialize ALL control methods? Default is FALSE, meaning + * to use the Serialized/NotSerialized method flags on a per method basis. + * Only change this if the ASL code is poorly written and cannot handle + * reentrancy even though methods are marked "NotSerialized". + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE); + +/* + * Create the predefined _OSI method in the namespace? Default is TRUE + * because ACPI CA is fully compatible with other ACPI implementations. + * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); + +/* + * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and + * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only + * be enabled just before going to sleep. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE); + +/* + * Optionally use default values for the ACPI register widths. Set this to + * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_UseDefaultRegisterWidths, TRUE); + + +/* AcpiGbl_FADT is a local copy of the FADT, converted to a common format. */ + +ACPI_TABLE_FADT AcpiGbl_FADT; +UINT32 AcpiCurrentGpeCount; +UINT32 AcpiGbl_TraceFlags; +ACPI_NAME AcpiGbl_TraceMethodName; + +#endif + +/***************************************************************************** + * + * ACPI Table globals + * + ****************************************************************************/ + +/* + * AcpiGbl_RootTableList is the master list of ACPI tables found in the + * RSDT/XSDT. + * + */ +ACPI_EXTERN ACPI_INTERNAL_RSDT AcpiGbl_RootTableList; +ACPI_EXTERN ACPI_TABLE_FACS *AcpiGbl_FACS; + +/* These addresses are calculated from the FADT Event Block addresses */ + +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aStatus; +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; + +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bStatus; +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; + +/* + * Handle both ACPI 1.0 and ACPI 2.0 Integer widths. The integer width is + * determined by the revision of the DSDT: If the DSDT revision is less than + * 2, use only the lower 32 bits of the internal 64-bit Integer. + */ +ACPI_EXTERN UINT8 AcpiGbl_IntegerBitWidth; +ACPI_EXTERN UINT8 AcpiGbl_IntegerByteWidth; +ACPI_EXTERN UINT8 AcpiGbl_IntegerNybbleWidth; + + +/***************************************************************************** + * + * Mutual exlusion within ACPICA subsystem + * + ****************************************************************************/ + +/* + * Predefined mutex objects. This array contains the + * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. + * (The table maps local handles to the real OS handles) + */ +ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[ACPI_NUM_MUTEX]; + +/* + * Global lock mutex is an actual AML mutex object + * Global lock semaphore works in conjunction with the HW global lock + */ +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_GlobalLockMutex; +ACPI_EXTERN ACPI_SEMAPHORE AcpiGbl_GlobalLockSemaphore; +ACPI_EXTERN UINT16 AcpiGbl_GlobalLockHandle; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockAcquired; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; + +/* + * Spinlocks are used for interfaces that can be possibly called at + * interrupt level + */ +ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_GpeLock; /* For GPE data structs and registers */ +ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_HardwareLock; /* For ACPI H/W except GPE registers */ + +/* Reader/Writer lock is used for namespace walk and dynamic table unload */ + +ACPI_EXTERN ACPI_RW_LOCK AcpiGbl_NamespaceRwLock; + + +/***************************************************************************** + * + * Miscellaneous globals + * + ****************************************************************************/ + +/* Object caches */ + +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_NamespaceCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_StateCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeExtCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_OperandCache; + +/* Global handlers */ + +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_DeviceNotify; +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_SystemNotify; +ACPI_EXTERN ACPI_EXCEPTION_HANDLER AcpiGbl_ExceptionHandler; +ACPI_EXTERN ACPI_INIT_HANDLER AcpiGbl_InitHandler; +ACPI_EXTERN ACPI_TABLE_HANDLER AcpiGbl_TableHandler; +ACPI_EXTERN void *AcpiGbl_TableHandlerContext; +ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; + + +/* Owner ID support */ + +ACPI_EXTERN UINT32 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS]; +ACPI_EXTERN UINT8 AcpiGbl_LastOwnerIdIndex; +ACPI_EXTERN UINT8 AcpiGbl_NextOwnerIdOffset; + +/* Misc */ + +ACPI_EXTERN UINT32 AcpiGbl_OriginalMode; +ACPI_EXTERN UINT32 AcpiGbl_RsdpOriginalLocation; +ACPI_EXTERN UINT32 AcpiGbl_NsLookupCount; +ACPI_EXTERN UINT32 AcpiGbl_PsFindCount; +ACPI_EXTERN UINT16 AcpiGbl_Pm1EnableRegisterSave; +ACPI_EXTERN UINT8 AcpiGbl_DebuggerConfiguration; +ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; +ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; +ACPI_EXTERN BOOLEAN AcpiGbl_EventsInitialized; +ACPI_EXTERN BOOLEAN AcpiGbl_SystemAwakeAndRunning; +ACPI_EXTERN UINT8 AcpiGbl_OsiData; + + +#ifndef DEFINE_ACPI_GLOBALS + +/* Exception codes */ + +extern char const *AcpiGbl_ExceptionNames_Env[]; +extern char const *AcpiGbl_ExceptionNames_Pgm[]; +extern char const *AcpiGbl_ExceptionNames_Tbl[]; +extern char const *AcpiGbl_ExceptionNames_Aml[]; +extern char const *AcpiGbl_ExceptionNames_Ctrl[]; + +/* Other miscellaneous */ + +extern BOOLEAN AcpiGbl_Shutdown; +extern UINT32 AcpiGbl_StartupFlags; +extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]; +extern const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS]; +extern const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS]; +extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; +extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; +#endif + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +/* Lists for tracking memory allocations */ + +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_GlobalList; +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_NsNodeList; +ACPI_EXTERN BOOLEAN AcpiGbl_DisplayFinalMemStats; +#endif + + +/***************************************************************************** + * + * Namespace globals + * + ****************************************************************************/ + +#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) +#define NUM_PREDEFINED_NAMES 10 +#else +#define NUM_PREDEFINED_NAMES 9 +#endif + +ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_FadtGpeDevice; +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_ModuleCodeList; + + +extern const UINT8 AcpiGbl_NsProperties [ACPI_NUM_NS_TYPES]; +extern const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; + +#ifdef ACPI_DEBUG_OUTPUT +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeCount; +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeSize; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentNodeCount; +ACPI_EXTERN ACPI_SIZE *AcpiGbl_EntryStackPointer; +ACPI_EXTERN ACPI_SIZE *AcpiGbl_LowestStackPointer; +ACPI_EXTERN UINT32 AcpiGbl_DeepestNesting; +#endif + + +/***************************************************************************** + * + * Interpreter globals + * + ****************************************************************************/ + + +ACPI_EXTERN ACPI_THREAD_STATE *AcpiGbl_CurrentWalkList; + +/* Control method single step flag */ + +ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; + + +/***************************************************************************** + * + * Hardware globals + * + ****************************************************************************/ + +extern ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG]; +ACPI_EXTERN UINT8 AcpiGbl_SleepTypeA; +ACPI_EXTERN UINT8 AcpiGbl_SleepTypeB; + + +/***************************************************************************** + * + * Event and GPE globals + * + ****************************************************************************/ + +extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]; +ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]; +ACPI_EXTERN ACPI_GPE_XRUPT_INFO *AcpiGbl_GpeXruptListHead; +ACPI_EXTERN ACPI_GPE_BLOCK_INFO *AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCKS]; + + +/***************************************************************************** + * + * Debug support + * + ****************************************************************************/ + +/* Procedure nesting level for debug output */ + +extern UINT32 AcpiGbl_NestingLevel; + +/* Event counters */ + +ACPI_EXTERN UINT32 AcpiMethodCount; +ACPI_EXTERN UINT32 AcpiGpeCount; +ACPI_EXTERN UINT32 AcpiSciCount; +ACPI_EXTERN UINT32 AcpiFixedEventCount[ACPI_NUM_FIXED_EVENTS]; + +/* Support for dynamic control method tracing mechanism */ + +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLayer; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; + + +/***************************************************************************** + * + * Debugger globals + * + ****************************************************************************/ + +ACPI_EXTERN UINT8 AcpiGbl_DbOutputFlags; + +#ifdef ACPI_DISASSEMBLER + +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_disasm; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_verbose; +ACPI_EXTERN ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList; +#endif + + +#ifdef ACPI_DEBUGGER + +extern BOOLEAN AcpiGbl_MethodExecuting; +extern BOOLEAN AcpiGbl_AbortMethod; +extern BOOLEAN AcpiGbl_DbTerminateThreads; + +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_tables; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_stats; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_ini_methods; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_NoRegionSupport; + +ACPI_EXTERN char *AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS]; +ACPI_EXTERN char AcpiGbl_DbLineBuf[80]; +ACPI_EXTERN char AcpiGbl_DbParsedBuf[80]; +ACPI_EXTERN char AcpiGbl_DbScopeBuf[40]; +ACPI_EXTERN char AcpiGbl_DbDebugFilename[40]; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOutputToFile; +ACPI_EXTERN char *AcpiGbl_DbBuffer; +ACPI_EXTERN char *AcpiGbl_DbFilename; +ACPI_EXTERN UINT32 AcpiGbl_DbDebugLevel; +ACPI_EXTERN UINT32 AcpiGbl_DbConsoleDebugLevel; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_DbScopeNode; + +/* + * Statistic globals + */ +ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; +ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; +ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCountMisc; +ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCountMisc; +ACPI_EXTERN UINT32 AcpiGbl_NumNodes; +ACPI_EXTERN UINT32 AcpiGbl_NumObjects; + + +ACPI_EXTERN UINT32 AcpiGbl_SizeOfParseTree; +ACPI_EXTERN UINT32 AcpiGbl_SizeOfMethodTrees; +ACPI_EXTERN UINT32 AcpiGbl_SizeOfNodeEntries; +ACPI_EXTERN UINT32 AcpiGbl_SizeOfAcpiObjects; + +#endif /* ACPI_DEBUGGER */ + +#endif /* __ACGLOBAL_H__ */ diff --git a/drivers/bus/acpi/acpica/include/achware.h b/drivers/bus/acpi/acpica/include/achware.h new file mode 100644 index 00000000000..c171a5fc1df --- /dev/null +++ b/drivers/bus/acpi/acpica/include/achware.h @@ -0,0 +1,269 @@ +/****************************************************************************** + * + * Name: achware.h -- hardware specific interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACHWARE_H__ +#define __ACHWARE_H__ + + +/* Values for the _SST predefined method */ + +#define ACPI_SST_INDICATOR_OFF 0 +#define ACPI_SST_WORKING 1 +#define ACPI_SST_WAKING 2 +#define ACPI_SST_SLEEPING 3 +#define ACPI_SST_SLEEP_CONTEXT 4 + + +/* + * hwacpi - high level functions + */ +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode); + +UINT32 +AcpiHwGetMode ( + void); + + +/* + * hwregs - ACPI Register I/O + */ +ACPI_STATUS +AcpiHwValidateRegister ( + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth, + UINT64 *Address); + +ACPI_STATUS +AcpiHwRead ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiHwWrite ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_BIT_REGISTER_INFO * +AcpiHwGetBitRegisterInfo ( + UINT32 RegisterId); + +ACPI_STATUS +AcpiHwWritePm1Control ( + UINT32 Pm1aControl, + UINT32 Pm1bControl); + +ACPI_STATUS +AcpiHwRegisterRead ( + UINT32 RegisterId, + UINT32 *ReturnValue); + +ACPI_STATUS +AcpiHwRegisterWrite ( + UINT32 RegisterId, + UINT32 Value); + +ACPI_STATUS +AcpiHwClearAcpiStatus ( + void); + + +/* + * hwvalid - Port I/O with validation + */ +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + +/* + * hwgpe - GPE support + */ +ACPI_STATUS +AcpiHwLowDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiHwWriteGpeEnableReg ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiHwDisableGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_STATUS +AcpiHwClearGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiHwClearGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_STATUS +AcpiHwGetGpeStatus ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + ACPI_EVENT_STATUS *EventStatus); + +ACPI_STATUS +AcpiHwDisableAllGpes ( + void); + +ACPI_STATUS +AcpiHwEnableAllRuntimeGpes ( + void); + +ACPI_STATUS +AcpiHwEnableAllWakeupGpes ( + void); + +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/* + * hwtimer - ACPI Timer prototypes + */ +ACPI_STATUS +AcpiGetTimerResolution ( + UINT32 *Resolution); + +ACPI_STATUS +AcpiGetTimer ( + UINT32 *Ticks); + +ACPI_STATUS +AcpiGetTimerDuration ( + UINT32 StartTicks, + UINT32 EndTicks, + UINT32 *TimeElapsed); + + +#endif /* __ACHWARE_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acinterp.h b/drivers/bus/acpi/acpica/include/acinterp.h new file mode 100644 index 00000000000..74c5f0b4eba --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acinterp.h @@ -0,0 +1,784 @@ +/****************************************************************************** + * + * Name: acinterp.h - Interpreter subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACINTERP_H__ +#define __ACINTERP_H__ + + +#define ACPI_WALK_OPERANDS (&(WalkState->Operands [WalkState->NumOperands -1])) + +/* Macros for tables used for debug output */ + +#define ACPI_EXD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_OPERAND_OBJECT,f) +#define ACPI_EXD_NSOFFSET(f) (UINT8) ACPI_OFFSET (ACPI_NAMESPACE_NODE,f) +#define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_EXDUMP_INFO)) + +/* + * If possible, pack the following structures to byte alignment, since we + * don't care about performance for debug output. Two cases where we cannot + * pack the structures: + * + * 1) Hardware does not support misaligned memory transfers + * 2) Compiler does not support pointers within packed structures + */ +#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) +#pragma pack(1) +#endif + +typedef const struct acpi_exdump_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + +} ACPI_EXDUMP_INFO; + +/* Values for the Opcode field above */ + +#define ACPI_EXD_INIT 0 +#define ACPI_EXD_TYPE 1 +#define ACPI_EXD_UINT8 2 +#define ACPI_EXD_UINT16 3 +#define ACPI_EXD_UINT32 4 +#define ACPI_EXD_UINT64 5 +#define ACPI_EXD_LITERAL 6 +#define ACPI_EXD_POINTER 7 +#define ACPI_EXD_ADDRESS 8 +#define ACPI_EXD_STRING 9 +#define ACPI_EXD_BUFFER 10 +#define ACPI_EXD_PACKAGE 11 +#define ACPI_EXD_FIELD 12 +#define ACPI_EXD_REFERENCE 13 + +/* restore default alignment */ + +#pragma pack() + + +/* + * exconvrt - object conversion + */ +ACPI_STATUS +AcpiExConvertToInteger ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Flags); + +ACPI_STATUS +AcpiExConvertToBuffer ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); + +ACPI_STATUS +AcpiExConvertToString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Type); + +/* Types for ->String conversion */ + +#define ACPI_EXPLICIT_BYTE_COPY 0x00000000 +#define ACPI_EXPLICIT_CONVERT_HEX 0x00000001 +#define ACPI_IMPLICIT_CONVERT_HEX 0x00000002 +#define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003 + +ACPI_STATUS +AcpiExConvertToTargetType ( + ACPI_OBJECT_TYPE DestinationType, + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * exfield - ACPI AML (p-code) execution - field manipulation + */ +ACPI_STATUS +AcpiExCommonBufferSetup ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 BufferLength, + UINT32 *DatumCount); + +ACPI_STATUS +AcpiExWriteWithUpdateRule ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Mask, + ACPI_INTEGER FieldValue, + UINT32 FieldDatumByteOffset); + +void +AcpiExGetBufferDatum( + ACPI_INTEGER *Datum, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteGranularity, + UINT32 BufferOffset); + +void +AcpiExSetBufferDatum ( + ACPI_INTEGER MergedDatum, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteGranularity, + UINT32 BufferOffset); + +ACPI_STATUS +AcpiExReadDataFromField ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **RetBufferDesc); + +ACPI_STATUS +AcpiExWriteDataToField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); + + +/* + * exfldio - low level field I/O + */ +ACPI_STATUS +AcpiExExtractFromField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); + +ACPI_STATUS +AcpiExInsertIntoField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); + +ACPI_STATUS +AcpiExAccessRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); + + +/* + * exmisc - misc support routines + */ +ACPI_STATUS +AcpiExGetObjectReference ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ReturnDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExConcatTemplate ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult); + +ACPI_STATUS +AcpiExDoLogicalOp ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult); + +ACPI_INTEGER +AcpiExDoMathOp ( + UINT16 Opcode, + ACPI_INTEGER Operand0, + ACPI_INTEGER Operand1); + +ACPI_STATUS +AcpiExCreateMutex ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateProcessor ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreatePowerResource ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateRegion ( + UINT8 *AmlStart, + UINT32 AmlLength, + UINT8 RegionSpace, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateEvent ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateAlias ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateMethod ( + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_WALK_STATE *WalkState); + + +/* + * exconfig - dynamic table load/unload + */ +ACPI_STATUS +AcpiExLoadOp ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *Target, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExLoadTableOp ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiExUnloadTable ( + ACPI_OPERAND_OBJECT *DdbHandle); + + +/* + * exmutex - mutex support + */ +ACPI_STATUS +AcpiExAcquireMutex ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExAcquireMutexObject ( + UINT16 Timeout, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_ID ThreadId); + +ACPI_STATUS +AcpiExReleaseMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExReleaseMutexObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +void +AcpiExReleaseAllMutexes ( + ACPI_THREAD_STATE *Thread); + +void +AcpiExUnlinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* + * exprep - ACPI AML execution - prep utilities + */ +ACPI_STATUS +AcpiExPrepCommonFieldObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldBitPosition, + UINT32 FieldBitLength); + +ACPI_STATUS +AcpiExPrepFieldValue ( + ACPI_CREATE_FIELD_INFO *Info); + + +/* + * exsystem - Interface to OS services + */ +ACPI_STATUS +AcpiExSystemDoNotifyOp ( + ACPI_OPERAND_OBJECT *Value, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemDoSuspend( + ACPI_INTEGER Time); + +ACPI_STATUS +AcpiExSystemDoStall ( + UINT32 Time); + +ACPI_STATUS +AcpiExSystemSignalEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemWaitEvent( + ACPI_OPERAND_OBJECT *Time, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemResetEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemWaitSemaphore ( + ACPI_SEMAPHORE Semaphore, + UINT16 Timeout); + +ACPI_STATUS +AcpiExSystemWaitMutex ( + ACPI_MUTEX Mutex, + UINT16 Timeout); + +/* + * exoparg1 - ACPI AML execution, 1 operand + */ +ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_1T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_1T_0R ( + ACPI_WALK_STATE *WalkState); + +/* + * exoparg2 - ACPI AML execution, 2 operands + */ +ACPI_STATUS +AcpiExOpcode_2A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_2A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_2A_1T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_2A_2T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exoparg3 - ACPI AML execution, 3 operands + */ +ACPI_STATUS +AcpiExOpcode_3A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_3A_1T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exoparg6 - ACPI AML execution, 6 operands + */ +ACPI_STATUS +AcpiExOpcode_6A_0T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exresolv - Object resolution and get value functions + */ +ACPI_STATUS +AcpiExResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExResolveMultiple ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *Operand, + ACPI_OBJECT_TYPE *ReturnType, + ACPI_OPERAND_OBJECT **ReturnDesc); + + +/* + * exresnte - resolve namespace node + */ +ACPI_STATUS +AcpiExResolveNodeToValue ( + ACPI_NAMESPACE_NODE **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/* + * exresop - resolve operand to value + */ +ACPI_STATUS +AcpiExResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/* + * exdump - Interpreter debug output routines + */ +void +AcpiExDumpOperand ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth); + +void +AcpiExDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + const char *OpcodeName, + UINT32 NumOpcodes); + +void +AcpiExDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Flags); + +void +AcpiExDumpNamespaceNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags); + + +/* + * exnames - AML namestring support + */ +ACPI_STATUS +AcpiExGetNameString ( + ACPI_OBJECT_TYPE DataType, + UINT8 *InAmlAddress, + char **OutNameString, + UINT32 *OutNameLength); + + +/* + * exstore - Object store support + */ +ACPI_STATUS +AcpiExStore ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExStoreObjectToNode ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState, + UINT8 ImplicitConversion); + +#define ACPI_IMPLICIT_CONVERSION TRUE +#define ACPI_NO_IMPLICIT_CONVERSION FALSE + + +/* + * exstoren - resolve/store object + */ +ACPI_STATUS +AcpiExResolveObject ( + ACPI_OPERAND_OBJECT **SourceDescPtr, + ACPI_OBJECT_TYPE TargetType, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExStoreObjectToObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_OPERAND_OBJECT **NewDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * exstorob - store object - buffer/string + */ +ACPI_STATUS +AcpiExStoreBufferToBuffer ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + +ACPI_STATUS +AcpiExStoreStringToString ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + + +/* + * excopy - object copy + */ +ACPI_STATUS +AcpiExCopyIntegerToIndexField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + +ACPI_STATUS +AcpiExCopyIntegerToBankField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + +ACPI_STATUS +AcpiExCopyDataToNamedField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiExCopyIntegerToBufferField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + + +/* + * exutils - interpreter/scanner utilities + */ +void +AcpiExEnterInterpreter ( + void); + +void +AcpiExExitInterpreter ( + void); + +void +AcpiExReacquireInterpreter ( + void); + +void +AcpiExRelinquishInterpreter ( + void); + +void +AcpiExTruncateFor32bitTable ( + ACPI_OPERAND_OBJECT *ObjDesc); + +void +AcpiExAcquireGlobalLock ( + UINT32 Rule); + +void +AcpiExReleaseGlobalLock ( + UINT32 Rule); + +void +AcpiExEisaIdToString ( + char *Dest, + ACPI_INTEGER CompressedId); + +void +AcpiExIntegerToString ( + char *Dest, + ACPI_INTEGER Value); + + +/* + * exregion - default OpRegion handlers + */ +ACPI_STATUS +AcpiExSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExSystemIoSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExPciConfigSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExCmosSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExPciBarSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExEmbeddedControllerSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExSmBusSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + + +ACPI_STATUS +AcpiExDataTableSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +#endif /* __INTERP_H__ */ diff --git a/drivers/bus/acpi/acpica/include/aclocal.h b/drivers/bus/acpi/acpica/include/aclocal.h new file mode 100644 index 00000000000..52dbec3a6dc --- /dev/null +++ b/drivers/bus/acpi/acpica/include/aclocal.h @@ -0,0 +1,1332 @@ +/****************************************************************************** + * + * Name: aclocal.h - Internal data types used across the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACLOCAL_H__ +#define __ACLOCAL_H__ + + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +#define ACPI_SERIALIZED 0xFF + +typedef UINT32 ACPI_MUTEX_HANDLE; +#define ACPI_GLOBAL_LOCK (ACPI_SEMAPHORE) (-1) + +/* Total number of aml opcodes defined */ + +#define AML_NUM_OPCODES 0x7F + + +/* Forward declarations */ + +struct acpi_walk_state; +struct acpi_obj_mutex; +union acpi_parse_object; + + +/***************************************************************************** + * + * Mutex typedefs and structs + * + ****************************************************************************/ + + +/* + * Predefined handles for the mutex objects used within the subsystem + * All mutex objects are automatically created by AcpiUtMutexInitialize. + * + * The acquire/release ordering protocol is implied via this list. Mutexes + * with a lower value must be acquired before mutexes with a higher value. + * + * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames + * table below also! + */ +#define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */ +#define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */ +#define ACPI_MTX_TABLES 2 /* Data for ACPI tables */ +#define ACPI_MTX_EVENTS 3 /* Data for ACPI events */ +#define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */ +#define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */ +#define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */ +#define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */ + +#define ACPI_MAX_MUTEX 7 +#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +#ifdef DEFINE_ACPI_GLOBALS + +/* Debug names for the mutexes above */ + +static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = +{ + "ACPI_MTX_Interpreter", + "ACPI_MTX_Namespace", + "ACPI_MTX_Tables", + "ACPI_MTX_Events", + "ACPI_MTX_Caches", + "ACPI_MTX_Memory", + "ACPI_MTX_CommandComplete", + "ACPI_MTX_CommandReady" +}; + +#endif +#endif + +/* Lock structure for reader/writer interfaces */ + +typedef struct acpi_rw_lock +{ + ACPI_MUTEX WriterMutex; + ACPI_MUTEX ReaderMutex; + UINT32 NumReaders; + +} ACPI_RW_LOCK; + + +/* + * Predefined handles for spinlocks used within the subsystem. + * These spinlocks are created by AcpiUtMutexInitialize + */ +#define ACPI_LOCK_GPES 0 +#define ACPI_LOCK_HARDWARE 1 + +#define ACPI_MAX_LOCK 1 +#define ACPI_NUM_LOCK ACPI_MAX_LOCK+1 + + +/* This Thread ID means that the mutex is not in use (unlocked) */ + +#define ACPI_MUTEX_NOT_ACQUIRED (ACPI_THREAD_ID) -1 + +/* Table for the global mutexes */ + +typedef struct acpi_mutex_info +{ + ACPI_MUTEX Mutex; + UINT32 UseCount; + ACPI_THREAD_ID ThreadId; + +} ACPI_MUTEX_INFO; + + +/* Lock flag parameter for various interfaces */ + +#define ACPI_MTX_DO_NOT_LOCK 0 +#define ACPI_MTX_LOCK 1 + + +/* Field access granularities */ + +#define ACPI_FIELD_BYTE_GRANULARITY 1 +#define ACPI_FIELD_WORD_GRANULARITY 2 +#define ACPI_FIELD_DWORD_GRANULARITY 4 +#define ACPI_FIELD_QWORD_GRANULARITY 8 + + +#define ACPI_ENTRY_NOT_FOUND NULL + + +/***************************************************************************** + * + * Namespace typedefs and structs + * + ****************************************************************************/ + +/* Operational modes of the AML interpreter/scanner */ + +typedef enum +{ + ACPI_IMODE_LOAD_PASS1 = 0x01, + ACPI_IMODE_LOAD_PASS2 = 0x02, + ACPI_IMODE_EXECUTE = 0x03 + +} ACPI_INTERPRETER_MODE; + + +/* + * The Namespace Node describes a named object that appears in the AML. + * DescriptorType is used to differentiate between internal descriptors. + * + * The node is optimized for both 32-bit and 64-bit platforms: + * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case. + * + * Note: The DescriptorType and Type fields must appear in the identical + * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT + * structures. + */ +typedef struct acpi_namespace_node +{ + union acpi_operand_object *Object; /* Interpreter object */ + UINT8 DescriptorType; /* Differentiate object descriptor types */ + UINT8 Type; /* ACPI Type associated with this name */ + UINT8 Flags; /* Miscellaneous flags */ + ACPI_OWNER_ID OwnerId; /* Node creator */ + ACPI_NAME_UNION Name; /* ACPI Name, always 4 chars per ACPI spec */ + struct acpi_namespace_node *Child; /* First child */ + struct acpi_namespace_node *Peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */ + + /* + * The following fields are used by the ASL compiler and disassembler only + */ +#ifdef ACPI_LARGE_NAMESPACE_NODE + union acpi_parse_object *Op; + UINT32 Value; + UINT32 Length; +#endif + +} ACPI_NAMESPACE_NODE; + + +/* Namespace Node flags */ + +#define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */ +#define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */ +#define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ +#define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ +#define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */ +#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ +#define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (InstallMethod) */ + +#define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */ +#define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */ +#define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* iASL only: Method has at least one return value */ +#define ANOBJ_IS_BIT_OFFSET 0x40 /* iASL only: Reference is a bit offset */ +#define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */ + + +/* One internal RSDT for table management */ + +typedef struct acpi_internal_rsdt +{ + ACPI_TABLE_DESC *Tables; + UINT32 Count; + UINT32 Size; + UINT8 Flags; + +} ACPI_INTERNAL_RSDT; + +/* Flags for above */ + +#define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */ +#define ACPI_ROOT_ORIGIN_ALLOCATED (1) +#define ACPI_ROOT_ALLOW_RESIZE (2) + + +/* Predefined (fixed) table indexes */ + +#define ACPI_TABLE_INDEX_DSDT (0) +#define ACPI_TABLE_INDEX_FACS (1) + + +typedef struct acpi_find_context +{ + char *SearchFor; + ACPI_HANDLE *List; + UINT32 *Count; + +} ACPI_FIND_CONTEXT; + + +typedef struct acpi_ns_search_data +{ + ACPI_NAMESPACE_NODE *Node; + +} ACPI_NS_SEARCH_DATA; + + +/* Object types used during package copies */ + +#define ACPI_COPY_TYPE_SIMPLE 0 +#define ACPI_COPY_TYPE_PACKAGE 1 + + +/* Info structure used to convert external<->internal namestrings */ + +typedef struct acpi_namestring_info +{ + const char *ExternalName; + const char *NextExternalChar; + char *InternalName; + UINT32 Length; + UINT32 NumSegments; + UINT32 NumCarats; + BOOLEAN FullyQualified; + +} ACPI_NAMESTRING_INFO; + + +/* Field creation info */ + +typedef struct acpi_create_field_info +{ + ACPI_NAMESPACE_NODE *RegionNode; + ACPI_NAMESPACE_NODE *FieldNode; + ACPI_NAMESPACE_NODE *RegisterNode; + ACPI_NAMESPACE_NODE *DataRegisterNode; + UINT32 BankValue; + UINT32 FieldBitPosition; + UINT32 FieldBitLength; + UINT8 FieldFlags; + UINT8 Attribute; + UINT8 FieldType; + +} ACPI_CREATE_FIELD_INFO; + + +typedef +ACPI_STATUS (*ACPI_INTERNAL_METHOD) ( + struct acpi_walk_state *WalkState); + + +/* + * Bitmapped ACPI types. Used internally only + */ +#define ACPI_BTYPE_ANY 0x00000000 +#define ACPI_BTYPE_INTEGER 0x00000001 +#define ACPI_BTYPE_STRING 0x00000002 +#define ACPI_BTYPE_BUFFER 0x00000004 +#define ACPI_BTYPE_PACKAGE 0x00000008 +#define ACPI_BTYPE_FIELD_UNIT 0x00000010 +#define ACPI_BTYPE_DEVICE 0x00000020 +#define ACPI_BTYPE_EVENT 0x00000040 +#define ACPI_BTYPE_METHOD 0x00000080 +#define ACPI_BTYPE_MUTEX 0x00000100 +#define ACPI_BTYPE_REGION 0x00000200 +#define ACPI_BTYPE_POWER 0x00000400 +#define ACPI_BTYPE_PROCESSOR 0x00000800 +#define ACPI_BTYPE_THERMAL 0x00001000 +#define ACPI_BTYPE_BUFFER_FIELD 0x00002000 +#define ACPI_BTYPE_DDB_HANDLE 0x00004000 +#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 +#define ACPI_BTYPE_REFERENCE 0x00010000 +#define ACPI_BTYPE_RESOURCE 0x00020000 + +#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) + +#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) +#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) +#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) +#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ +#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF + + +/* + * Information structure for ACPI predefined names. + * Each entry in the table contains the following items: + * + * Name - The ACPI reserved name + * ParamCount - Number of arguments to the method + * ExpectedReturnBtypes - Allowed type(s) for the return value + */ +typedef struct acpi_name_info +{ + char Name[ACPI_NAME_SIZE]; + UINT8 ParamCount; + UINT8 ExpectedBtypes; + +} ACPI_NAME_INFO; + +/* + * Secondary information structures for ACPI predefined objects that return + * package objects. This structure appears as the next entry in the table + * after the NAME_INFO structure above. + * + * The reason for this is to minimize the size of the predefined name table. + */ + +/* + * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2, + * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT + */ +typedef struct acpi_package_info +{ + UINT8 Type; + UINT8 ObjectType1; + UINT8 Count1; + UINT8 ObjectType2; + UINT8 Count2; + UINT8 Reserved; + +} ACPI_PACKAGE_INFO; + +/* Used for ACPI_PTYPE2_FIXED */ + +typedef struct acpi_package_info2 +{ + UINT8 Type; + UINT8 Count; + UINT8 ObjectType[4]; + +} ACPI_PACKAGE_INFO2; + +/* Used for ACPI_PTYPE1_OPTION */ + +typedef struct acpi_package_info3 +{ + UINT8 Type; + UINT8 Count; + UINT8 ObjectType[2]; + UINT8 TailObjectType; + UINT8 Reserved; + +} ACPI_PACKAGE_INFO3; + +typedef union acpi_predefined_info +{ + ACPI_NAME_INFO Info; + ACPI_PACKAGE_INFO RetInfo; + ACPI_PACKAGE_INFO2 RetInfo2; + ACPI_PACKAGE_INFO3 RetInfo3; + +} ACPI_PREDEFINED_INFO; + + +/* Data block used during object validation */ + +typedef struct acpi_predefined_data +{ + char *Pathname; + const ACPI_PREDEFINED_INFO *Predefined; + UINT32 Flags; + UINT8 NodeFlags; + +} ACPI_PREDEFINED_DATA; + +/* Defines for Flags field above */ + +#define ACPI_OBJECT_REPAIRED 1 + + +/* + * Bitmapped return value types + * Note: the actual data types must be contiguous, a loop in nspredef.c + * depends on this. + */ +#define ACPI_RTYPE_ANY 0x00 +#define ACPI_RTYPE_NONE 0x01 +#define ACPI_RTYPE_INTEGER 0x02 +#define ACPI_RTYPE_STRING 0x04 +#define ACPI_RTYPE_BUFFER 0x08 +#define ACPI_RTYPE_PACKAGE 0x10 +#define ACPI_RTYPE_REFERENCE 0x20 +#define ACPI_RTYPE_ALL 0x3F + +#define ACPI_NUM_RTYPES 5 /* Number of actual object types */ + + +/***************************************************************************** + * + * Event typedefs and structs + * + ****************************************************************************/ + +/* Dispatch info for each GPE -- either a method or handler, cannot be both */ + +typedef struct acpi_handler_info +{ + ACPI_EVENT_HANDLER Address; /* Address of handler, if any */ + void *Context; /* Context to be passed to handler */ + ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level (saved) */ + +} ACPI_HANDLER_INFO; + +typedef union acpi_gpe_dispatch_info +{ + ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level */ + struct acpi_handler_info *Handler; + +} ACPI_GPE_DISPATCH_INFO; + +/* + * Information about a GPE, one per each GPE in an array. + * NOTE: Important to keep this struct as small as possible. + */ +typedef struct acpi_gpe_event_info +{ + union acpi_gpe_dispatch_info Dispatch; /* Either Method or Handler */ + struct acpi_gpe_register_info *RegisterInfo; /* Backpointer to register info */ + UINT8 Flags; /* Misc info about this GPE */ + UINT8 GpeNumber; /* This GPE */ + +} ACPI_GPE_EVENT_INFO; + +/* Information about a GPE register pair, one per each status/enable pair in an array */ + +typedef struct acpi_gpe_register_info +{ + ACPI_GENERIC_ADDRESS StatusAddress; /* Address of status reg */ + ACPI_GENERIC_ADDRESS EnableAddress; /* Address of enable reg */ + UINT8 EnableForWake; /* GPEs to keep enabled when sleeping */ + UINT8 EnableForRun; /* GPEs to keep enabled when running */ + UINT8 BaseGpeNumber; /* Base GPE number for this register */ + +} ACPI_GPE_REGISTER_INFO; + +/* + * Information about a GPE register block, one per each installed block -- + * GPE0, GPE1, and one per each installed GPE Block Device. + */ +typedef struct acpi_gpe_block_info +{ + ACPI_NAMESPACE_NODE *Node; + struct acpi_gpe_block_info *Previous; + struct acpi_gpe_block_info *Next; + struct acpi_gpe_xrupt_info *XruptBlock; /* Backpointer to interrupt block */ + ACPI_GPE_REGISTER_INFO *RegisterInfo; /* One per GPE register pair */ + ACPI_GPE_EVENT_INFO *EventInfo; /* One for each GPE */ + ACPI_GENERIC_ADDRESS BlockAddress; /* Base address of the block */ + UINT32 RegisterCount; /* Number of register pairs in block */ + UINT8 BlockBaseNumber;/* Base GPE number for this block */ + +} ACPI_GPE_BLOCK_INFO; + +/* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */ + +typedef struct acpi_gpe_xrupt_info +{ + struct acpi_gpe_xrupt_info *Previous; + struct acpi_gpe_xrupt_info *Next; + ACPI_GPE_BLOCK_INFO *GpeBlockListHead; /* List of GPE blocks for this xrupt */ + UINT32 InterruptNumber; /* System interrupt number */ + +} ACPI_GPE_XRUPT_INFO; + +typedef struct acpi_gpe_walk_info +{ + ACPI_NAMESPACE_NODE *GpeDevice; + ACPI_GPE_BLOCK_INFO *GpeBlock; + +} ACPI_GPE_WALK_INFO; + +typedef struct acpi_gpe_device_info +{ + UINT32 Index; + UINT32 NextBlockBaseIndex; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *GpeDevice; + +} ACPI_GPE_DEVICE_INFO; + +typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/* Information about each particular fixed event */ + +typedef struct acpi_fixed_event_handler +{ + ACPI_EVENT_HANDLER Handler; /* Address of handler. */ + void *Context; /* Context to be passed to handler */ + +} ACPI_FIXED_EVENT_HANDLER; + +typedef struct acpi_fixed_event_info +{ + UINT8 StatusRegisterId; + UINT8 EnableRegisterId; + UINT16 StatusBitMask; + UINT16 EnableBitMask; + +} ACPI_FIXED_EVENT_INFO; + +/* Information used during field processing */ + +typedef struct acpi_field_info +{ + UINT8 SkipField; + UINT8 FieldFlag; + UINT32 PkgLength; + +} ACPI_FIELD_INFO; + + +/***************************************************************************** + * + * Generic "state" object for stacks + * + ****************************************************************************/ + +#define ACPI_CONTROL_NORMAL 0xC0 +#define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1 +#define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2 +#define ACPI_CONTROL_PREDICATE_FALSE 0xC3 +#define ACPI_CONTROL_PREDICATE_TRUE 0xC4 + + +#define ACPI_STATE_COMMON \ + void *Next; \ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Flags; \ + UINT16 Value; \ + UINT16 State; + + /* There are 2 bytes available here until the next natural alignment boundary */ + +typedef struct acpi_common_state +{ + ACPI_STATE_COMMON +} ACPI_COMMON_STATE; + + +/* + * Update state - used to traverse complex objects such as packages + */ +typedef struct acpi_update_state +{ + ACPI_STATE_COMMON + union acpi_operand_object *Object; + +} ACPI_UPDATE_STATE; + + +/* + * Pkg state - used to traverse nested package structures + */ +typedef struct acpi_pkg_state +{ + ACPI_STATE_COMMON + UINT16 Index; + union acpi_operand_object *SourceObject; + union acpi_operand_object *DestObject; + struct acpi_walk_state *WalkState; + void *ThisTargetObj; + UINT32 NumPackages; + +} ACPI_PKG_STATE; + + +/* + * Control state - one per if/else and while constructs. + * Allows nesting of these constructs + */ +typedef struct acpi_control_state +{ + ACPI_STATE_COMMON + UINT16 Opcode; + union acpi_parse_object *PredicateOp; + UINT8 *AmlPredicateStart; /* Start of if/while predicate */ + UINT8 *PackageEnd; /* End of if/while block */ + UINT32 LoopCount; /* While() loop counter */ + +} ACPI_CONTROL_STATE; + + +/* + * Scope state - current scope during namespace lookups + */ +typedef struct acpi_scope_state +{ + ACPI_STATE_COMMON + ACPI_NAMESPACE_NODE *Node; + +} ACPI_SCOPE_STATE; + + +typedef struct acpi_pscope_state +{ + ACPI_STATE_COMMON + UINT32 ArgCount; /* Number of fixed arguments */ + union acpi_parse_object *Op; /* Current op being parsed */ + UINT8 *ArgEnd; /* Current argument end */ + UINT8 *PkgEnd; /* Current package end */ + UINT32 ArgList; /* Next argument to parse */ + +} ACPI_PSCOPE_STATE; + + +/* + * Thread state - one per thread across multiple walk states. Multiple walk + * states are created when there are nested control methods executing. + */ +typedef struct acpi_thread_state +{ + ACPI_STATE_COMMON + UINT8 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ + struct acpi_walk_state *WalkStateList; /* Head of list of WalkStates for this thread */ + union acpi_operand_object *AcquiredMutexList; /* List of all currently acquired mutexes */ + ACPI_THREAD_ID ThreadId; /* Running thread ID */ + +} ACPI_THREAD_STATE; + + +/* + * Result values - used to accumulate the results of nested + * AML arguments + */ +typedef struct acpi_result_values +{ + ACPI_STATE_COMMON + union acpi_operand_object *ObjDesc [ACPI_RESULTS_FRAME_OBJ_NUM]; + +} ACPI_RESULT_VALUES; + + +typedef +ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) ( + struct acpi_walk_state *WalkState, + union acpi_parse_object **OutOp); + +typedef +ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( + struct acpi_walk_state *WalkState); + + +/* + * Notify info - used to pass info to the deferred notify + * handler/dispatcher. + */ +typedef struct acpi_notify_info +{ + ACPI_STATE_COMMON + ACPI_NAMESPACE_NODE *Node; + union acpi_operand_object *HandlerObj; + +} ACPI_NOTIFY_INFO; + + +/* Generic state is union of structs above */ + +typedef union acpi_generic_state +{ + ACPI_COMMON_STATE Common; + ACPI_CONTROL_STATE Control; + ACPI_UPDATE_STATE Update; + ACPI_SCOPE_STATE Scope; + ACPI_PSCOPE_STATE ParseScope; + ACPI_PKG_STATE Pkg; + ACPI_THREAD_STATE Thread; + ACPI_RESULT_VALUES Results; + ACPI_NOTIFY_INFO Notify; + +} ACPI_GENERIC_STATE; + + +/***************************************************************************** + * + * Interpreter typedefs and structs + * + ****************************************************************************/ + +typedef +ACPI_STATUS (*ACPI_EXECUTE_OP) ( + struct acpi_walk_state *WalkState); + + +/***************************************************************************** + * + * Parser typedefs and structs + * + ****************************************************************************/ + +/* + * AML opcode, name, and argument layout + */ +typedef struct acpi_opcode_info +{ +#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) + char *Name; /* Opcode name (disassembler/debug only) */ +#endif + UINT32 ParseArgs; /* Grammar/Parse time arguments */ + UINT32 RuntimeArgs; /* Interpret time arguments */ + UINT16 Flags; /* Misc flags */ + UINT8 ObjectType; /* Corresponding internal object type */ + UINT8 Class; /* Opcode class */ + UINT8 Type; /* Opcode type */ + +} ACPI_OPCODE_INFO; + +typedef union acpi_parse_value +{ + ACPI_INTEGER Integer; /* Integer constant (Up to 64 bits) */ + UINT64_STRUCT Integer64; /* Structure overlay for 2 32-bit Dwords */ + UINT32 Size; /* bytelist or field size */ + char *String; /* NULL terminated string */ + UINT8 *Buffer; /* buffer or string */ + char *Name; /* NULL terminated string */ + union acpi_parse_object *Arg; /* arguments and contained ops */ + +} ACPI_PARSE_VALUE; + + +#ifdef ACPI_DISASSEMBLER +#define ACPI_DISASM_ONLY_MEMBERS(a) a; +#else +#define ACPI_DISASM_ONLY_MEMBERS(a) +#endif + +#define ACPI_PARSE_COMMON \ + union acpi_parse_object *Parent; /* Parent op */\ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Flags; /* Type of Op */\ + UINT16 AmlOpcode; /* AML opcode */\ + UINT32 AmlOffset; /* Offset of declaration in AML */\ + union acpi_parse_object *Next; /* Next op */\ + ACPI_NAMESPACE_NODE *Node; /* For use by interpreter */\ + ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ + UINT8 ArgListLength; /* Number of elements in the arg list */\ + ACPI_DISASM_ONLY_MEMBERS (\ + UINT8 DisasmFlags; /* Used during AML disassembly */\ + UINT8 DisasmOpcode; /* Subtype used for disassembly */\ + char AmlOpName[16]) /* Op name (debug only) */ + + +#define ACPI_DASM_BUFFER 0x00 +#define ACPI_DASM_RESOURCE 0x01 +#define ACPI_DASM_STRING 0x02 +#define ACPI_DASM_UNICODE 0x03 +#define ACPI_DASM_EISAID 0x04 +#define ACPI_DASM_MATCHOP 0x05 +#define ACPI_DASM_LNOT_PREFIX 0x06 +#define ACPI_DASM_LNOT_SUFFIX 0x07 +#define ACPI_DASM_IGNORE 0x08 + +/* + * Generic operation (for example: If, While, Store) + */ +typedef struct acpi_parse_obj_common +{ + ACPI_PARSE_COMMON +} ACPI_PARSE_OBJ_COMMON; + + +/* + * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions), + * and bytelists. + */ +typedef struct acpi_parse_obj_named +{ + ACPI_PARSE_COMMON + UINT8 *Path; + UINT8 *Data; /* AML body or bytelist data */ + UINT32 Length; /* AML length */ + UINT32 Name; /* 4-byte name or zero if no name */ + +} ACPI_PARSE_OBJ_NAMED; + + +/* This version is used by the iASL compiler only */ + +#define ACPI_MAX_PARSEOP_NAME 20 + +typedef struct acpi_parse_obj_asl +{ + ACPI_PARSE_COMMON + union acpi_parse_object *Child; + union acpi_parse_object *ParentMethod; + char *Filename; + char *ExternalName; + char *Namepath; + char NameSeg[4]; + UINT32 ExtraValue; + UINT32 Column; + UINT32 LineNumber; + UINT32 LogicalLineNumber; + UINT32 LogicalByteOffset; + UINT32 EndLine; + UINT32 EndLogicalLine; + UINT32 AcpiBtype; + UINT32 AmlLength; + UINT32 AmlSubtreeLength; + UINT32 FinalAmlLength; + UINT32 FinalAmlOffset; + UINT32 CompileFlags; + UINT16 ParseOpcode; + UINT8 AmlOpcodeLength; + UINT8 AmlPkgLenBytes; + UINT8 Extra; + char ParseOpName[ACPI_MAX_PARSEOP_NAME]; + +} ACPI_PARSE_OBJ_ASL; + +typedef union acpi_parse_object +{ + ACPI_PARSE_OBJ_COMMON Common; + ACPI_PARSE_OBJ_NAMED Named; + ACPI_PARSE_OBJ_ASL Asl; + +} ACPI_PARSE_OBJECT; + + +/* + * Parse state - one state per parser invocation and each control + * method. + */ +typedef struct acpi_parse_state +{ + UINT8 *AmlStart; /* First AML byte */ + UINT8 *Aml; /* Next AML byte */ + UINT8 *AmlEnd; /* (last + 1) AML byte */ + UINT8 *PkgStart; /* Current package begin */ + UINT8 *PkgEnd; /* Current package end */ + union acpi_parse_object *StartOp; /* Root of parse tree */ + struct acpi_namespace_node *StartNode; + union acpi_generic_state *Scope; /* Current scope */ + union acpi_parse_object *StartScope; + UINT32 AmlSize; + +} ACPI_PARSE_STATE; + + +/* Parse object flags */ + +#define ACPI_PARSEOP_GENERIC 0x01 +#define ACPI_PARSEOP_NAMED 0x02 +#define ACPI_PARSEOP_DEFERRED 0x04 +#define ACPI_PARSEOP_BYTELIST 0x08 +#define ACPI_PARSEOP_IN_STACK 0x10 +#define ACPI_PARSEOP_TARGET 0x20 +#define ACPI_PARSEOP_IN_CACHE 0x80 + +/* Parse object DisasmFlags */ + +#define ACPI_PARSEOP_IGNORE 0x01 +#define ACPI_PARSEOP_PARAMLIST 0x02 +#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 +#define ACPI_PARSEOP_SPECIAL 0x10 + + +/***************************************************************************** + * + * Hardware (ACPI registers) and PNP + * + ****************************************************************************/ + +typedef struct acpi_bit_register_info +{ + UINT8 ParentRegister; + UINT8 BitPosition; + UINT16 AccessBitMask; + +} ACPI_BIT_REGISTER_INFO; + + +/* + * Some ACPI registers have bits that must be ignored -- meaning that they + * must be preserved. + */ +#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ + +/* Write-only bits must be zeroed by software */ + +#define ACPI_PM1_CONTROL_WRITEONLY_BITS 0x2004 /* Bits 13, 2 */ + +/* For control registers, both ignored and reserved bits must be preserved */ + +/* + * For PM1 control, the SCI enable bit (bit 0, SCI_EN) is defined by the + * ACPI specification to be a "preserved" bit - "OSPM always preserves this + * bit position", section 4.7.3.2.1. However, on some machines the OS must + * write a one to this bit after resume for the machine to work properly. + * To enable this, we no longer attempt to preserve this bit. No machines + * are known to fail if the bit is not preserved. (May 2009) + */ +#define ACPI_PM1_CONTROL_IGNORED_BITS 0x0200 /* Bit 9 */ +#define ACPI_PM1_CONTROL_RESERVED_BITS 0xC1F8 /* Bits 14-15, 3-8 */ +#define ACPI_PM1_CONTROL_PRESERVED_BITS \ + (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS) + +#define ACPI_PM2_CONTROL_PRESERVED_BITS 0xFFFFFFFE /* All except bit 0 */ + +/* + * Register IDs + * These are the full ACPI registers + */ +#define ACPI_REGISTER_PM1_STATUS 0x01 +#define ACPI_REGISTER_PM1_ENABLE 0x02 +#define ACPI_REGISTER_PM1_CONTROL 0x03 +#define ACPI_REGISTER_PM2_CONTROL 0x04 +#define ACPI_REGISTER_PM_TIMER 0x05 +#define ACPI_REGISTER_PROCESSOR_BLOCK 0x06 +#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x07 + + +/* Masks used to access the BitRegisters */ + +#define ACPI_BITMASK_TIMER_STATUS 0x0001 +#define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010 +#define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020 +#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 +#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 +#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ +#define ACPI_BITMASK_WAKE_STATUS 0x8000 + +#define ACPI_BITMASK_ALL_FIXED_STATUS (\ + ACPI_BITMASK_TIMER_STATUS | \ + ACPI_BITMASK_BUS_MASTER_STATUS | \ + ACPI_BITMASK_GLOBAL_LOCK_STATUS | \ + ACPI_BITMASK_POWER_BUTTON_STATUS | \ + ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ + ACPI_BITMASK_RT_CLOCK_STATUS | \ + ACPI_BITMASK_WAKE_STATUS) + +#define ACPI_BITMASK_TIMER_ENABLE 0x0001 +#define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020 +#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 +#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 +#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ + +#define ACPI_BITMASK_SCI_ENABLE 0x0001 +#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 +#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 +#define ACPI_BITMASK_SLEEP_TYPE 0x1C00 +#define ACPI_BITMASK_SLEEP_ENABLE 0x2000 + +#define ACPI_BITMASK_ARB_DISABLE 0x0001 + + +/* Raw bit position of each BitRegister */ + +#define ACPI_BITPOSITION_TIMER_STATUS 0x00 +#define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04 +#define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05 +#define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 +#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 +#define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ +#define ACPI_BITPOSITION_WAKE_STATUS 0x0F + +#define ACPI_BITPOSITION_TIMER_ENABLE 0x00 +#define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05 +#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 +#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 +#define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ + +#define ACPI_BITPOSITION_SCI_ENABLE 0x00 +#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 +#define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02 +#define ACPI_BITPOSITION_SLEEP_TYPE 0x0A +#define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D + +#define ACPI_BITPOSITION_ARB_DISABLE 0x00 + + +/* Structs and definitions for _OSI support and I/O port validation */ + +#define ACPI_OSI_WIN_2000 0x01 +#define ACPI_OSI_WIN_XP 0x02 +#define ACPI_OSI_WIN_XP_SP1 0x03 +#define ACPI_OSI_WINSRV_2003 0x04 +#define ACPI_OSI_WIN_XP_SP2 0x05 +#define ACPI_OSI_WINSRV_2003_SP1 0x06 +#define ACPI_OSI_WIN_VISTA 0x07 +#define ACPI_OSI_WINSRV_2008 0x08 +#define ACPI_OSI_WIN_VISTA_SP1 0x09 +#define ACPI_OSI_WIN_7 0x0A + +#define ACPI_ALWAYS_ILLEGAL 0x00 + +typedef struct acpi_interface_info +{ + char *Name; + UINT8 Value; + +} ACPI_INTERFACE_INFO; + +typedef struct acpi_port_info +{ + char *Name; + UINT16 Start; + UINT16 End; + UINT8 OsiDependency; + +} ACPI_PORT_INFO; + + +/***************************************************************************** + * + * Resource descriptors + * + ****************************************************************************/ + +/* ResourceType values */ + +#define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0 +#define ACPI_ADDRESS_TYPE_IO_RANGE 1 +#define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2 + +/* Resource descriptor types and masks */ + +#define ACPI_RESOURCE_NAME_LARGE 0x80 +#define ACPI_RESOURCE_NAME_SMALL 0x00 + +#define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ +#define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ +#define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ + + +/* + * Small resource descriptor "names" as defined by the ACPI specification. + * Note: Bits 2:0 are used for the descriptor length + */ +#define ACPI_RESOURCE_NAME_IRQ 0x20 +#define ACPI_RESOURCE_NAME_DMA 0x28 +#define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30 +#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 +#define ACPI_RESOURCE_NAME_IO 0x40 +#define ACPI_RESOURCE_NAME_FIXED_IO 0x48 +#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50 +#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 +#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 +#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 +#define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70 +#define ACPI_RESOURCE_NAME_END_TAG 0x78 + +/* + * Large resource descriptor "names" as defined by the ACPI specification. + * Note: includes the Large Descriptor bit in bit[7] + */ +#define ACPI_RESOURCE_NAME_MEMORY24 0x81 +#define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82 +#define ACPI_RESOURCE_NAME_RESERVED_L1 0x83 +#define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84 +#define ACPI_RESOURCE_NAME_MEMORY32 0x85 +#define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86 +#define ACPI_RESOURCE_NAME_ADDRESS32 0x87 +#define ACPI_RESOURCE_NAME_ADDRESS16 0x88 +#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 +#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A +#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B +#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B + + +/***************************************************************************** + * + * Miscellaneous + * + ****************************************************************************/ + +#define ACPI_ASCII_ZERO 0x30 + + +/***************************************************************************** + * + * Disassembler + * + ****************************************************************************/ + +typedef struct acpi_external_list +{ + char *Path; + char *InternalPath; + struct acpi_external_list *Next; + UINT32 Value; + UINT16 Length; + UINT8 Type; + UINT8 Flags; + +} ACPI_EXTERNAL_LIST; + +/* Values for Flags field above */ + +#define ACPI_IPATH_ALLOCATED 0x01 + + +/***************************************************************************** + * + * Debugger + * + ****************************************************************************/ + +typedef struct acpi_db_method_info +{ + ACPI_HANDLE MainThreadGate; + ACPI_HANDLE ThreadCompleteGate; + ACPI_HANDLE InfoGate; + UINT32 *Threads; + UINT32 NumThreads; + UINT32 NumCreated; + UINT32 NumCompleted; + + char *Name; + UINT32 Flags; + UINT32 NumLoops; + char Pathname[128]; + char **Args; + + /* + * Arguments to be passed to method for the command + * Threads - + * the Number of threads, ID of current thread and + * Index of current thread inside all them created. + */ + char InitArgs; + char *Arguments[4]; + char NumThreadsStr[11]; + char IdOfThreadStr[11]; + char IndexOfThreadStr[11]; + +} ACPI_DB_METHOD_INFO; + +typedef struct acpi_integrity_info +{ + UINT32 Nodes; + UINT32 Objects; + +} ACPI_INTEGRITY_INFO; + + +#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 +#define ACPI_DB_CONSOLE_OUTPUT 0x02 +#define ACPI_DB_DUPLICATE_OUTPUT 0x03 + + +/***************************************************************************** + * + * Debug + * + ****************************************************************************/ + +/* Entry for a memory allocation (debug only) */ + +#define ACPI_MEM_MALLOC 0 +#define ACPI_MEM_CALLOC 1 +#define ACPI_MAX_MODULE_NAME 16 + +#define ACPI_COMMON_DEBUG_MEM_HEADER \ + struct acpi_debug_mem_block *Previous; \ + struct acpi_debug_mem_block *Next; \ + UINT32 Size; \ + UINT32 Component; \ + UINT32 Line; \ + char Module[ACPI_MAX_MODULE_NAME]; \ + UINT8 AllocType; + +typedef struct acpi_debug_mem_header +{ + ACPI_COMMON_DEBUG_MEM_HEADER + +} ACPI_DEBUG_MEM_HEADER; + +typedef struct acpi_debug_mem_block +{ + ACPI_COMMON_DEBUG_MEM_HEADER + UINT64 UserSpace; + +} ACPI_DEBUG_MEM_BLOCK; + + +#define ACPI_MEM_LIST_GLOBAL 0 +#define ACPI_MEM_LIST_NSNODE 1 +#define ACPI_MEM_LIST_MAX 1 +#define ACPI_NUM_MEM_LISTS 2 + + +#endif /* __ACLOCAL_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acmacros.h b/drivers/bus/acpi/acpica/include/acmacros.h new file mode 100644 index 00000000000..3d351f9fc85 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acmacros.h @@ -0,0 +1,605 @@ +/****************************************************************************** + * + * Name: acmacros.h - C macros for the entire subsystem. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACMACROS_H__ +#define __ACMACROS_H__ + + +/* + * Extract data using a pointer. Any more than a byte and we + * get into potential aligment issues -- see the STORE macros below. + * Use with care. + */ +#define ACPI_GET8(ptr) *ACPI_CAST_PTR (UINT8, ptr) +#define ACPI_GET16(ptr) *ACPI_CAST_PTR (UINT16, ptr) +#define ACPI_GET32(ptr) *ACPI_CAST_PTR (UINT32, ptr) +#define ACPI_GET64(ptr) *ACPI_CAST_PTR (UINT64, ptr) +#define ACPI_SET8(ptr) *ACPI_CAST_PTR (UINT8, ptr) +#define ACPI_SET16(ptr) *ACPI_CAST_PTR (UINT16, ptr) +#define ACPI_SET32(ptr) *ACPI_CAST_PTR (UINT32, ptr) +#define ACPI_SET64(ptr) *ACPI_CAST_PTR (UINT64, ptr) + +/* + * printf() format helpers + */ + +/* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */ + +#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i) + +#if ACPI_MACHINE_WIDTH == 64 +#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i) +#else +#define ACPI_FORMAT_NATIVE_UINT(i) 0, (i) +#endif + + +/* + * Macros for moving data around to/from buffers that are possibly unaligned. + * If the hardware supports the transfer of unaligned data, just do the store. + * Otherwise, we have to move one byte at a time. + */ +#ifdef ACPI_BIG_ENDIAN +/* + * Macros for big-endian machines + */ + +/* These macros reverse the bytes during the move, converting little-endian to big endian */ + + /* Big Endian <== Little Endian */ + /* Hi...Lo Lo...Hi */ +/* 16-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_16_TO_16(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[0];} + +#define ACPI_MOVE_16_TO_32(d, s) {(*(UINT32 *)(void *)(d))=0;\ + ((UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[0];} + +#define ACPI_MOVE_16_TO_64(d, s) {(*(UINT64 *)(void *)(d))=0;\ + ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} + +/* 32-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ + +#define ACPI_MOVE_32_TO_32(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[0];} + +#define ACPI_MOVE_32_TO_64(d, s) {(*(UINT64 *)(void *)(d))=0;\ + ((UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[3];\ + ((UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[2];\ + ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} + +/* 64-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ + +#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */ + +#define ACPI_MOVE_64_TO_64(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[5];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[4];\ + (( UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} +#else +/* + * Macros for little-endian machines + */ + +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED + +/* The hardware supports unaligned transfers, just do the little-endian move */ + +/* 16-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_16_TO_16(d, s) *(UINT16 *)(void *)(d) = *(UINT16 *)(void *)(s) +#define ACPI_MOVE_16_TO_32(d, s) *(UINT32 *)(void *)(d) = *(UINT16 *)(void *)(s) +#define ACPI_MOVE_16_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT16 *)(void *)(s) + +/* 32-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ +#define ACPI_MOVE_32_TO_32(d, s) *(UINT32 *)(void *)(d) = *(UINT32 *)(void *)(s) +#define ACPI_MOVE_32_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT32 *)(void *)(s) + +/* 64-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT64 *)(void *)(s) + +#else +/* + * The hardware does not support unaligned transfers. We must move the + * data one byte at a time. These macros work whether the source or + * the destination (or both) is/are unaligned. (Little-endian move) + */ + +/* 16-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_16_TO_16(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];} + +#define ACPI_MOVE_16_TO_32(d, s) {(*(UINT32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);} +#define ACPI_MOVE_16_TO_64(d, s) {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);} + +/* 32-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ + +#define ACPI_MOVE_32_TO_32(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];} + +#define ACPI_MOVE_32_TO_64(d, s) {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d, s);} + +/* 64-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_64(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[4];\ + (( UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[5];\ + (( UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[6];\ + (( UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[7];} +#endif +#endif + + +/* + * Fast power-of-two math macros for non-optimized compilers + */ +#define _ACPI_DIV(value, PowerOf2) ((UINT32) ((value) >> (PowerOf2))) +#define _ACPI_MUL(value, PowerOf2) ((UINT32) ((value) << (PowerOf2))) +#define _ACPI_MOD(value, Divisor) ((UINT32) ((value) & ((Divisor) -1))) + +#define ACPI_DIV_2(a) _ACPI_DIV(a, 1) +#define ACPI_MUL_2(a) _ACPI_MUL(a, 1) +#define ACPI_MOD_2(a) _ACPI_MOD(a, 2) + +#define ACPI_DIV_4(a) _ACPI_DIV(a, 2) +#define ACPI_MUL_4(a) _ACPI_MUL(a, 2) +#define ACPI_MOD_4(a) _ACPI_MOD(a, 4) + +#define ACPI_DIV_8(a) _ACPI_DIV(a, 3) +#define ACPI_MUL_8(a) _ACPI_MUL(a, 3) +#define ACPI_MOD_8(a) _ACPI_MOD(a, 8) + +#define ACPI_DIV_16(a) _ACPI_DIV(a, 4) +#define ACPI_MUL_16(a) _ACPI_MUL(a, 4) +#define ACPI_MOD_16(a) _ACPI_MOD(a, 16) + +#define ACPI_DIV_32(a) _ACPI_DIV(a, 5) +#define ACPI_MUL_32(a) _ACPI_MUL(a, 5) +#define ACPI_MOD_32(a) _ACPI_MOD(a, 32) + +/* + * Rounding macros (Power of two boundaries only) + */ +#define ACPI_ROUND_DOWN(value, boundary) (((ACPI_SIZE)(value)) & \ + (~(((ACPI_SIZE) boundary)-1))) + +#define ACPI_ROUND_UP(value, boundary) ((((ACPI_SIZE)(value)) + \ + (((ACPI_SIZE) boundary)-1)) & \ + (~(((ACPI_SIZE) boundary)-1))) + +/* Note: sizeof(ACPI_SIZE) evaluates to either 4 or 8 (32- vs 64-bit mode) */ + +#define ACPI_ROUND_DOWN_TO_32BIT(a) ACPI_ROUND_DOWN(a, 4) +#define ACPI_ROUND_DOWN_TO_64BIT(a) ACPI_ROUND_DOWN(a, 8) +#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a, sizeof(ACPI_SIZE)) + +#define ACPI_ROUND_UP_TO_32BIT(a) ACPI_ROUND_UP(a, 4) +#define ACPI_ROUND_UP_TO_64BIT(a) ACPI_ROUND_UP(a, 8) +#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a, sizeof(ACPI_SIZE)) + +#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) +#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) + +#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10) + +/* Generic (non-power-of-two) rounding */ + +#define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary)) + +#define ACPI_IS_MISALIGNED(value) (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1)) + +/* + * Bitmask creation + * Bit positions start at zero. + * MASK_BITS_ABOVE creates a mask starting AT the position and above + * MASK_BITS_BELOW creates a mask starting one bit BELOW the position + */ +#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((UINT32) (position)))) +#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((UINT32) (position))) + +/* Bitfields within ACPI registers */ + +#define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) ((Val << Pos) & Mask) +#define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val) Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) + +#define ACPI_INSERT_BITS(Target, Mask, Source) Target = ((Target & (~(Mask))) | (Source & Mask)) + +/* + * An ACPI_NAMESPACE_NODE can appear in some contexts + * where a pointer to an ACPI_OPERAND_OBJECT can also + * appear. This macro is used to distinguish them. + * + * The "Descriptor" field is the first field in both structures. + */ +#define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType) +#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType = t) + +/* + * Macros for the master AML opcode table + */ +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) +#define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \ + {Name, (UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type} +#else +#define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \ + {(UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type} +#endif + +#define ARG_TYPE_WIDTH 5 +#define ARG_1(x) ((UINT32)(x)) +#define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH)) +#define ARG_3(x) ((UINT32)(x) << (2 * ARG_TYPE_WIDTH)) +#define ARG_4(x) ((UINT32)(x) << (3 * ARG_TYPE_WIDTH)) +#define ARG_5(x) ((UINT32)(x) << (4 * ARG_TYPE_WIDTH)) +#define ARG_6(x) ((UINT32)(x) << (5 * ARG_TYPE_WIDTH)) + +#define ARGI_LIST1(a) (ARG_1(a)) +#define ARGI_LIST2(a, b) (ARG_1(b)|ARG_2(a)) +#define ARGI_LIST3(a, b, c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) +#define ARGI_LIST4(a, b, c, d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) +#define ARGI_LIST5(a, b, c, d, e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) +#define ARGI_LIST6(a, b, c, d, e, f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) + +#define ARGP_LIST1(a) (ARG_1(a)) +#define ARGP_LIST2(a, b) (ARG_1(a)|ARG_2(b)) +#define ARGP_LIST3(a, b, c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) +#define ARGP_LIST4(a, b, c, d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) +#define ARGP_LIST5(a, b, c, d, e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) +#define ARGP_LIST6(a, b, c, d, e, f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) + +#define GET_CURRENT_ARG_TYPE(List) (List & ((UINT32) 0x1F)) +#define INCREMENT_ARG_LIST(List) (List >>= ((UINT32) ARG_TYPE_WIDTH)) + +/* + * Ascii error messages can be configured out + */ +#ifndef ACPI_NO_ERROR_MESSAGES +/* + * Error reporting. Callers module and line number are inserted by AE_INFO, + * the plist contains a set of parens to allow variable-length lists. + * These macros are used for both the debug and non-debug versions of the code. + */ +#define ACPI_ERROR_NAMESPACE(s, e) AcpiNsReportError (AE_INFO, s, e); +#define ACPI_ERROR_METHOD(s, n, p, e) AcpiNsReportMethodError (AE_INFO, s, n, p, e); +#define ACPI_WARN_PREDEFINED(plist) AcpiUtPredefinedWarning plist +#define ACPI_INFO_PREDEFINED(plist) AcpiUtPredefinedInfo plist + +#else + +/* No error messages */ + +#define ACPI_ERROR_NAMESPACE(s, e) +#define ACPI_ERROR_METHOD(s, n, p, e) +#define ACPI_WARN_PREDEFINED(plist) +#define ACPI_INFO_PREDEFINED(plist) + +#endif /* ACPI_NO_ERROR_MESSAGES */ + +/* + * Debug macros that are conditionally compiled + */ +#ifdef ACPI_DEBUG_OUTPUT +/* + * Function entry tracing + */ +#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ + AcpiUtTrace(ACPI_DEBUG_PARAMETERS) +#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTracePtr(ACPI_DEBUG_PARAMETERS, (void *)b) +#define ACPI_FUNCTION_TRACE_U32(a, b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTraceU32(ACPI_DEBUG_PARAMETERS, (UINT32)b) +#define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTraceStr(ACPI_DEBUG_PARAMETERS, (char *)b) + +#define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr() + +/* + * Function exit tracing. + * WARNING: These macros include a return statement. This is usually considered + * bad form, but having a separate exit macro is very ugly and difficult to maintain. + * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros + * so that "_AcpiFunctionName" is defined. + * + * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining + * about these constructs. + */ +#ifdef ACPI_USE_DO_WHILE_0 +#define ACPI_DO_WHILE0(a) do a while(0) +#else +#define ACPI_DO_WHILE0(a) a +#endif + +#define return_VOID ACPI_DO_WHILE0 ({ \ + AcpiUtExit (ACPI_DEBUG_PARAMETERS); \ + return;}) +/* + * There are two versions of most of the return macros. The default version is + * safer, since it avoids side-effects by guaranteeing that the argument will + * not be evaluated twice. + * + * A less-safe version of the macros is provided for optional use if the + * compiler uses excessive CPU stack (for example, this may happen in the + * debug case if code optimzation is disabled.) + */ +#ifndef ACPI_SIMPLE_RETURN_MACROS + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + register ACPI_STATUS _s = (s); \ + AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + register void *_s = (void *) (s); \ + AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) _s); \ + return (_s); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + register ACPI_INTEGER _s = (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_UINT8(s) ACPI_DO_WHILE0 ({ \ + register UINT8 _s = (UINT8) (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \ + return (_s); }) +#define return_UINT32(s) ACPI_DO_WHILE0 ({ \ + register UINT32 _s = (UINT32) (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \ + return (_s); }) +#else /* Use original less-safe macros */ + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, (s)); \ + return((s)); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) (s)); \ + return((s)); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) (s)); \ + return((s)); }) +#define return_UINT8(s) return_VALUE(s) +#define return_UINT32(s) return_VALUE(s) + +#endif /* ACPI_SIMPLE_RETURN_MACROS */ + + +/* Conditional execution */ + +#define ACPI_DEBUG_EXEC(a) a +#define ACPI_DEBUG_ONLY_MEMBERS(a) a; +#define _VERBOSE_STRUCTURES + + +/* Various object display routines for debug */ + +#define ACPI_DUMP_STACK_ENTRY(a) AcpiExDumpOperand((a), 0) +#define ACPI_DUMP_OPERANDS(a, b ,c) AcpiExDumpOperands(a, b, c) +#define ACPI_DUMP_ENTRY(a, b) AcpiNsDumpEntry (a, b) +#define ACPI_DUMP_PATHNAME(a, b, c, d) AcpiNsDumpPathname(a, b, c, d) +#define ACPI_DUMP_BUFFER(a, b) AcpiUtDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ +#define ACPI_DEBUG_EXEC(a) +#define ACPI_DEBUG_ONLY_MEMBERS(a) +#define ACPI_FUNCTION_TRACE(a) +#define ACPI_FUNCTION_TRACE_PTR(a, b) +#define ACPI_FUNCTION_TRACE_U32(a, b) +#define ACPI_FUNCTION_TRACE_STR(a, b) +#define ACPI_FUNCTION_EXIT +#define ACPI_FUNCTION_STATUS_EXIT(s) +#define ACPI_FUNCTION_VALUE_EXIT(s) +#define ACPI_FUNCTION_ENTRY() +#define ACPI_DUMP_STACK_ENTRY(a) +#define ACPI_DUMP_OPERANDS(a, b, c) +#define ACPI_DUMP_ENTRY(a, b) +#define ACPI_DUMP_TABLES(a, b) +#define ACPI_DUMP_PATHNAME(a, b, c, d) +#define ACPI_DUMP_BUFFER(a, b) +#define ACPI_DEBUG_PRINT(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) + +#define return_VOID return +#define return_ACPI_STATUS(s) return(s) +#define return_VALUE(s) return(s) +#define return_UINT8(s) return(s) +#define return_UINT32(s) return(s) +#define return_PTR(s) return(s) + +#endif /* ACPI_DEBUG_OUTPUT */ + +/* + * Some code only gets executed when the debugger is built in. + * Note that this is entirely independent of whether the + * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not. + */ +#ifdef ACPI_DEBUGGER +#define ACPI_DEBUGGER_EXEC(a) a +#else +#define ACPI_DEBUGGER_EXEC(a) +#endif + + +/* + * Memory allocation tracking (DEBUG ONLY) + */ +#define ACPI_MEM_PARAMETERS _COMPONENT, _AcpiModuleName, __LINE__ + +#ifndef ACPI_DBG_TRACK_ALLOCATIONS + +/* Memory allocation */ + +#define ACPI_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroed((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_FREE(a) AcpiOsFree(a) +#define ACPI_MEM_TRACKING(a) + +#else + +/* Memory allocation */ + +#define ACPI_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroedAndTrack((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_FREE(a) AcpiUtFreeAndTrack(a, ACPI_MEM_PARAMETERS) +#define ACPI_MEM_TRACKING(a) a + +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + + +/* + * Macros used for ACPICA utilities only + */ + +/* Generate a UUID */ + +#define ACPI_INIT_UUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ + (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \ + (b) & 0xFF, ((b) >> 8) & 0xFF, \ + (c) & 0xFF, ((c) >> 8) & 0xFF, \ + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) + +#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) + + +#endif /* ACMACROS_H */ diff --git a/drivers/bus/acpi/acpica/include/acnames.h b/drivers/bus/acpi/acpica/include/acnames.h new file mode 100644 index 00000000000..eb9944aa16e --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acnames.h @@ -0,0 +1,157 @@ +/****************************************************************************** + * + * Name: acnames.h - Global names and strings + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACNAMES_H__ +#define __ACNAMES_H__ + +/* Method names - these methods can appear anywhere in the namespace */ + +#define METHOD_NAME__HID "_HID" +#define METHOD_NAME__CID "_CID" +#define METHOD_NAME__UID "_UID" +#define METHOD_NAME__ADR "_ADR" +#define METHOD_NAME__INI "_INI" +#define METHOD_NAME__STA "_STA" +#define METHOD_NAME__REG "_REG" +#define METHOD_NAME__SEG "_SEG" +#define METHOD_NAME__BBN "_BBN" +#define METHOD_NAME__PRT "_PRT" +#define METHOD_NAME__CRS "_CRS" +#define METHOD_NAME__PRS "_PRS" +#define METHOD_NAME__PRW "_PRW" +#define METHOD_NAME__SRS "_SRS" + +/* Method names - these methods must appear at the namespace root */ + +#define METHOD_NAME__BFS "\\_BFS" +#define METHOD_NAME__GTS "\\_GTS" +#define METHOD_NAME__PTS "\\_PTS" +#define METHOD_NAME__SST "\\_SI._SST" +#define METHOD_NAME__WAK "\\_WAK" + +/* Definitions of the predefined namespace names */ + +#define ACPI_UNKNOWN_NAME (UINT32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (UINT32) 0x5F5F5F5C /* Root name is "\___" */ + +#define ACPI_PREFIX_MIXED (UINT32) 0x69706341 /* "Acpi" */ +#define ACPI_PREFIX_LOWER (UINT32) 0x69706361 /* "acpi" */ + +#define ACPI_NS_ROOT_PATH "\\" +#define ACPI_NS_SYSTEM_BUS "_SB_" + +#endif /* __ACNAMES_H__ */ + + diff --git a/drivers/bus/acpi/acpica/include/acnamesp.h b/drivers/bus/acpi/acpica/include/acnamesp.h new file mode 100644 index 00000000000..65798662d59 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acnamesp.h @@ -0,0 +1,566 @@ +/****************************************************************************** + * + * Name: acnamesp.h - Namespace subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACNAMESP_H__ +#define __ACNAMESP_H__ + + +/* To search the entire name space, pass this as SearchBase */ + +#define ACPI_NS_ALL ((ACPI_HANDLE)0) + +/* + * Elements of AcpiNsProperties are bit significant + * and should be one-to-one with values of ACPI_OBJECT_TYPE + */ +#define ACPI_NS_NORMAL 0 +#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ +#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ + +/* Flags for AcpiNsLookup, AcpiNsSearchAndEnter */ + +#define ACPI_NS_NO_UPSEARCH 0 +#define ACPI_NS_SEARCH_PARENT 0x01 +#define ACPI_NS_DONT_OPEN_SCOPE 0x02 +#define ACPI_NS_NO_PEER_SEARCH 0x04 +#define ACPI_NS_ERROR_IF_FOUND 0x08 +#define ACPI_NS_PREFIX_IS_SCOPE 0x10 +#define ACPI_NS_EXTERNAL 0x20 +#define ACPI_NS_TEMPORARY 0x40 + +/* Flags for AcpiNsWalkNamespace */ + +#define ACPI_NS_WALK_NO_UNLOCK 0 +#define ACPI_NS_WALK_UNLOCK 0x01 +#define ACPI_NS_WALK_TEMP_NODES 0x02 + +/* Object is not a package element */ + +#define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX + +/* Always emit warning message, not dependent on node flags */ + +#define ACPI_WARN_ALWAYS 0 + + +/* + * nsinit - Namespace initialization + */ +ACPI_STATUS +AcpiNsInitializeObjects ( + void); + +ACPI_STATUS +AcpiNsInitializeDevices ( + void); + + +/* + * nsload - Namespace loading + */ +ACPI_STATUS +AcpiNsLoadNamespace ( + void); + +ACPI_STATUS +AcpiNsLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *Node); + + +/* + * nswalk - walk the namespace + */ +ACPI_STATUS +AcpiNsWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + UINT32 Flags, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue); + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNode ( + ACPI_NAMESPACE_NODE *Parent, + ACPI_NAMESPACE_NODE *Child); + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNodeTyped ( + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE *Parent, + ACPI_NAMESPACE_NODE *Child); + +/* + * nsparse - table parsing + */ +ACPI_STATUS +AcpiNsParseTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + + +/* + * nsaccess - Top-level namespace access + */ +ACPI_STATUS +AcpiNsRootInitialize ( + void); + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + char *Name, + ACPI_OBJECT_TYPE Type, + ACPI_INTERPRETER_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **RetNode); + + +/* + * nsalloc - Named object allocation/deallocation + */ +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 Name); + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentHandle); + +void +AcpiNsDeleteNamespaceByOwner ( + ACPI_OWNER_ID OwnerId); + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *Parent); + +int +AcpiNsCompareNames ( + char *Name1, + char *Name2); + + +/* + * nsdump - Namespace dump/print utilities + */ +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth); + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel); + +void +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + char *Msg, + UINT32 Level, + UINT32 Component); + +void +AcpiNsPrintPathname ( + UINT32 NumSegments, + char *Pathname); + +ACPI_STATUS +AcpiNsDumpOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +void +AcpiNsDumpObjects ( + ACPI_OBJECT_TYPE Type, + UINT8 DisplayType, + UINT32 MaxDepth, + ACPI_OWNER_ID OwnerId, + ACPI_HANDLE StartHandle); + + +/* + * nseval - Namespace evaluation functions + */ +ACPI_STATUS +AcpiNsEvaluate ( + ACPI_EVALUATE_INFO *Info); + +void +AcpiNsExecModuleCodeList ( + void); + + +/* + * nspredef - Support for predefined/reserved names + */ +ACPI_STATUS +AcpiNsCheckPredefinedNames ( + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + ACPI_STATUS ReturnStatus, + ACPI_OPERAND_OBJECT **ReturnObject); + +const ACPI_PREDEFINED_INFO * +AcpiNsCheckForPredefinedName ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsCheckParameterCount ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + const ACPI_PREDEFINED_INFO *Info); + + +/* + * nsnames - Name and Scope manipulation + */ +UINT32 +AcpiNsOpensScope ( + ACPI_OBJECT_TYPE Type); + +ACPI_STATUS +AcpiNsBuildExternalPath ( + ACPI_NAMESPACE_NODE *Node, + ACPI_SIZE Size, + char *NameBuffer); + +char * +AcpiNsGetExternalPathname ( + ACPI_NAMESPACE_NODE *Node); + +char * +AcpiNsNameOfCurrentScope ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer); + +BOOLEAN +AcpiNsPatternMatch ( + ACPI_NAMESPACE_NODE *ObjNode, + char *SearchFor); + +ACPI_STATUS +AcpiNsGetNode ( + ACPI_NAMESPACE_NODE *PrefixNode, + const char *ExternalPathname, + UINT32 Flags, + ACPI_NAMESPACE_NODE **OutNode); + +ACPI_SIZE +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node); + + +/* + * nsobject - Object management for namespace nodes + */ +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + ACPI_OBJECT_TYPE Type); + +ACPI_OPERAND_OBJECT * +AcpiNsGetAttachedObject ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_OPERAND_OBJECT * +AcpiNsGetSecondaryObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiNsAttachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void *Data); + +ACPI_STATUS +AcpiNsDetachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler); + +ACPI_STATUS +AcpiNsGetAttachedData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void **Data); + + +/* + * nsrepair - General return object repair for all + * predefined methods/objects + */ +ACPI_STATUS +AcpiNsRepairObject ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +ACPI_STATUS +AcpiNsRepairPackageList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ObjDescPtr); + + +/* + * nsrepair2 - Return object repair for specific + * predefined methods/objects + */ +ACPI_STATUS +AcpiNsComplexRepairs ( + ACPI_PREDEFINED_DATA *Data, + ACPI_NAMESPACE_NODE *Node, + ACPI_STATUS ValidateStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +void +AcpiNsRemoveNullElements ( + ACPI_PREDEFINED_DATA *Data, + UINT8 PackageType, + ACPI_OPERAND_OBJECT *ObjDesc); + +/* + * nssearch - Namespace searching and entry + */ +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 EntryName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_INTERPRETER_MODE InterpreterMode, + ACPI_OBJECT_TYPE Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **RetNode); + +ACPI_STATUS +AcpiNsSearchOneScope ( + UINT32 EntryName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **RetNode); + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type); + + +/* + * nsutils - Utility functions + */ +BOOLEAN +AcpiNsValidRootPrefix ( + char Prefix); + +ACPI_OBJECT_TYPE +AcpiNsGetType ( + ACPI_NAMESPACE_NODE *Node); + +UINT32 +AcpiNsLocal ( + ACPI_OBJECT_TYPE Type); + +void +AcpiNsReportError ( + const char *ModuleName, + UINT32 LineNumber, + const char *InternalName, + ACPI_STATUS LookupStatus); + +void +AcpiNsReportMethodError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Message, + ACPI_NAMESPACE_NODE *Node, + const char *Path, + ACPI_STATUS LookupStatus); + +void +AcpiNsPrintNodePathname ( + ACPI_NAMESPACE_NODE *Node, + const char *Msg); + +ACPI_STATUS +AcpiNsBuildInternalName ( + ACPI_NAMESTRING_INFO *Info); + +void +AcpiNsGetInternalNameLength ( + ACPI_NAMESTRING_INFO *Info); + +ACPI_STATUS +AcpiNsInternalizeName ( + const char *DottedName, + char **ConvertedName); + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + const char *InternalName, + UINT32 *ConvertedNameLength, + char **ConvertedName); + +ACPI_NAMESPACE_NODE * +AcpiNsValidateHandle ( + ACPI_HANDLE Handle); + +void +AcpiNsTerminate ( + void); + +ACPI_NAMESPACE_NODE * +AcpiNsGetParentNode ( + ACPI_NAMESPACE_NODE *Node); + + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextValidNode ( + ACPI_NAMESPACE_NODE *Node); + +#endif /* __ACNAMESP_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acobject.h b/drivers/bus/acpi/acpica/include/acobject.h new file mode 100644 index 00000000000..76f623c83db --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acobject.h @@ -0,0 +1,648 @@ + +/****************************************************************************** + * + * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACOBJECT_H +#define _ACOBJECT_H + +/* acpisrc:StructDefs -- for acpisrc conversion */ + + +/* + * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher + * to the interpreter, and to keep track of the various handlers such as + * address space handlers and notify handlers. The object is a constant + * size in order to allow it to be cached and reused. + * + * Note: The object is optimized to be aligned and will not work if it is + * byte-packed. + */ +#if ACPI_MACHINE_WIDTH == 64 +#pragma pack(8) +#else +#pragma pack(4) +#endif + +/******************************************************************************* + * + * Common Descriptors + * + ******************************************************************************/ + +/* + * Common area for all objects. + * + * DescriptorType is used to differentiate between internal descriptors, and + * must be in the same place across all descriptors + * + * Note: The DescriptorType and Type fields must appear in the identical + * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT + * structures. + */ +#define ACPI_OBJECT_COMMON_HEADER \ + union acpi_operand_object *NextObject; /* Objects linked to parent NS node */\ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Type; /* ACPI_OBJECT_TYPE */\ + UINT16 ReferenceCount; /* For object deletion management */\ + UINT8 Flags; + /* + * Note: There are 3 bytes available here before the + * next natural alignment boundary (for both 32/64 cases) + */ + +/* Values for Flag byte above */ + +#define AOPOBJ_AML_CONSTANT 0x01 +#define AOPOBJ_STATIC_POINTER 0x02 +#define AOPOBJ_DATA_VALID 0x04 +#define AOPOBJ_OBJECT_INITIALIZED 0x08 +#define AOPOBJ_SETUP_COMPLETE 0x10 +#define AOPOBJ_SINGLE_DATUM 0x20 +#define AOPOBJ_MODULE_LEVEL 0x40 + + +/****************************************************************************** + * + * Basic data types + * + *****************************************************************************/ + +typedef struct acpi_object_common +{ + ACPI_OBJECT_COMMON_HEADER + +} ACPI_OBJECT_COMMON; + + +typedef struct acpi_object_integer +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 Fill[3]; /* Prevent warning on some compilers */ + ACPI_INTEGER Value; + +} ACPI_OBJECT_INTEGER; + + +/* + * Note: The String and Buffer object must be identical through the Pointer + * and length elements. There is code that depends on this. + * + * Fields common to both Strings and Buffers + */ +#define ACPI_COMMON_BUFFER_INFO(_Type) \ + _Type *Pointer; \ + UINT32 Length; + + +typedef struct acpi_object_string /* Null terminated, ASCII characters only */ +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_BUFFER_INFO (char) /* String in AML stream or allocated string */ + +} ACPI_OBJECT_STRING; + + +typedef struct acpi_object_buffer +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_BUFFER_INFO (UINT8) /* Buffer in AML stream or allocated buffer */ + UINT32 AmlLength; + UINT8 *AmlStart; + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ + +} ACPI_OBJECT_BUFFER; + + +typedef struct acpi_object_package +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ + union acpi_operand_object **Elements; /* Array of pointers to AcpiObjects */ + UINT8 *AmlStart; + UINT32 AmlLength; + UINT32 Count; /* # of elements in package */ + +} ACPI_OBJECT_PACKAGE; + + +/****************************************************************************** + * + * Complex data types + * + *****************************************************************************/ + +typedef struct acpi_object_event +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_SEMAPHORE OsSemaphore; /* Actual OS synchronization object */ + +} ACPI_OBJECT_EVENT; + + +typedef struct acpi_object_mutex +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 SyncLevel; /* 0-15, specified in Mutex() call */ + UINT16 AcquisitionDepth; /* Allow multiple Acquires, same thread */ + ACPI_MUTEX OsMutex; /* Actual OS synchronization object */ + ACPI_THREAD_ID ThreadId; /* Current owner of the mutex */ + struct acpi_thread_state *OwnerThread; /* Current owner of the mutex */ + union acpi_operand_object *Prev; /* Link for list of acquired mutexes */ + union acpi_operand_object *Next; /* Link for list of acquired mutexes */ + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ + UINT8 OriginalSyncLevel; /* Owner's original sync level (0-15) */ + +} ACPI_OBJECT_MUTEX; + + +typedef struct acpi_object_region +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 SpaceId; + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ + union acpi_operand_object *Handler; /* Handler for region access */ + union acpi_operand_object *Next; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + +} ACPI_OBJECT_REGION; + + +typedef struct acpi_object_method +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 MethodFlags; + UINT8 ParamCount; + UINT8 SyncLevel; + union acpi_operand_object *Mutex; + UINT8 *AmlStart; + union + { + ACPI_INTERNAL_METHOD Implementation; + union acpi_operand_object *Handler; + } Extra; + + UINT32 AmlLength; + UINT8 ThreadCount; + ACPI_OWNER_ID OwnerId; + +} ACPI_OBJECT_METHOD; + + +/****************************************************************************** + * + * Objects that can be notified. All share a common NotifyInfo area. + * + *****************************************************************************/ + +/* + * Common fields for objects that support ASL notifications + */ +#define ACPI_COMMON_NOTIFY_INFO \ + union acpi_operand_object *SystemNotify; /* Handler for system notifies */\ + union acpi_operand_object *DeviceNotify; /* Handler for driver notifies */\ + union acpi_operand_object *Handler; /* Handler for Address space */ + + +typedef struct acpi_object_notify_common /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + +} ACPI_OBJECT_NOTIFY_COMMON; + + +typedef struct acpi_object_device +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + ACPI_GPE_BLOCK_INFO *GpeBlock; + +} ACPI_OBJECT_DEVICE; + + +typedef struct acpi_object_power_resource +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + UINT32 SystemLevel; + UINT32 ResourceOrder; + +} ACPI_OBJECT_POWER_RESOURCE; + + +typedef struct acpi_object_processor +{ + ACPI_OBJECT_COMMON_HEADER + + /* The next two fields take advantage of the 3-byte space before NOTIFY_INFO */ + + UINT8 ProcId; + UINT8 Length; + ACPI_COMMON_NOTIFY_INFO + ACPI_IO_ADDRESS Address; + +} ACPI_OBJECT_PROCESSOR; + + +typedef struct acpi_object_thermal_zone +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + +} ACPI_OBJECT_THERMAL_ZONE; + + +/****************************************************************************** + * + * Fields. All share a common header/info field. + * + *****************************************************************************/ + +/* + * Common bitfield for the field objects + * "Field Datum" -- a datum from the actual field object + * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field + */ +#define ACPI_COMMON_FIELD_INFO \ + UINT8 FieldFlags; /* Access, update, and lock bits */\ + UINT8 Attribute; /* From AccessAs keyword */\ + UINT8 AccessByteWidth; /* Read/Write size in bytes */\ + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */\ + UINT32 BitLength; /* Length of field in bits */\ + UINT32 BaseByteOffset; /* Byte offset within containing object */\ + UINT32 Value; /* Value to store into the Bank or Index register */\ + UINT8 StartFieldBitOffset;/* Bit offset within first field datum (0-63) */\ + UINT8 AccessBitWidth; /* Read/Write size in bits (8-64) */ + + +typedef struct acpi_object_field_common /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *RegionObj; /* Parent Operation Region object (REGION/BANK fields only) */ + +} ACPI_OBJECT_FIELD_COMMON; + + +typedef struct acpi_object_region_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *RegionObj; /* Containing OpRegion object */ + +} ACPI_OBJECT_REGION_FIELD; + + +typedef struct acpi_object_bank_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *RegionObj; /* Containing OpRegion object */ + union acpi_operand_object *BankObj; /* BankSelect Register object */ + +} ACPI_OBJECT_BANK_FIELD; + + +typedef struct acpi_object_index_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + + /* + * No "RegionObj" pointer needed since the Index and Data registers + * are each field definitions unto themselves. + */ + union acpi_operand_object *IndexObj; /* Index register */ + union acpi_operand_object *DataObj; /* Data register */ + +} ACPI_OBJECT_INDEX_FIELD; + + +/* The BufferField is different in that it is part of a Buffer, not an OpRegion */ + +typedef struct acpi_object_buffer_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *BufferObj; /* Containing Buffer object */ + +} ACPI_OBJECT_BUFFER_FIELD; + + +/****************************************************************************** + * + * Objects for handlers + * + *****************************************************************************/ + +typedef struct acpi_object_notify_handler +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + ACPI_NOTIFY_HANDLER Handler; + void *Context; + +} ACPI_OBJECT_NOTIFY_HANDLER; + + +typedef struct acpi_object_addr_handler +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 SpaceId; + UINT8 HandlerFlags; + ACPI_ADR_SPACE_HANDLER Handler; + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + void *Context; + ACPI_ADR_SPACE_SETUP Setup; + union acpi_operand_object *RegionList; /* regions using this handler */ + union acpi_operand_object *Next; + +} ACPI_OBJECT_ADDR_HANDLER; + +/* Flags for address handler (HandlerFlags) */ + +#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x01 + + +/****************************************************************************** + * + * Special internal objects + * + *****************************************************************************/ + +/* + * The Reference object is used for these opcodes: + * Arg[0-6], Local[0-7], IndexOp, NameOp, RefOfOp, LoadOp, LoadTableOp, DebugOp + * The Reference.Class differentiates these types. + */ +typedef struct acpi_object_reference +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 Class; /* Reference Class */ + UINT8 TargetType; /* Used for Index Op */ + UINT8 Reserved; + void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ + ACPI_NAMESPACE_NODE *Node; /* RefOf or Namepath */ + union acpi_operand_object **Where; /* Target of Index */ + UINT32 Value; /* Used for Local/Arg/Index/DdbHandle */ + +} ACPI_OBJECT_REFERENCE; + +/* Values for Reference.Class above */ + +typedef enum +{ + ACPI_REFCLASS_LOCAL = 0, /* Method local */ + ACPI_REFCLASS_ARG = 1, /* Method argument */ + ACPI_REFCLASS_REFOF = 2, /* Result of RefOf() TBD: Split to Ref/Node and Ref/OperandObj? */ + ACPI_REFCLASS_INDEX = 3, /* Result of Index() */ + ACPI_REFCLASS_TABLE = 4, /* DdbHandle - Load(), LoadTable() */ + ACPI_REFCLASS_NAME = 5, /* Reference to a named object */ + ACPI_REFCLASS_DEBUG = 6, /* Debug object */ + + ACPI_REFCLASS_MAX = 6 + +} ACPI_REFERENCE_CLASSES; + + +/* + * Extra object is used as additional storage for types that + * have AML code in their declarations (TermArgs) that must be + * evaluated at run time. + * + * Currently: Region and FieldUnit types + */ +typedef struct acpi_object_extra +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_NAMESPACE_NODE *Method_REG; /* _REG method for this region (if any) */ + void *RegionContext; /* Region-specific data */ + UINT8 *AmlStart; + UINT32 AmlLength; + +} ACPI_OBJECT_EXTRA; + + +/* Additional data that can be attached to namespace nodes */ + +typedef struct acpi_object_data +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_OBJECT_HANDLER Handler; + void *Pointer; + +} ACPI_OBJECT_DATA; + + +/* Structure used when objects are cached for reuse */ + +typedef struct acpi_object_cache_list +{ + ACPI_OBJECT_COMMON_HEADER + union acpi_operand_object *Next; /* Link for object cache and internal lists*/ + +} ACPI_OBJECT_CACHE_LIST; + + +/****************************************************************************** + * + * ACPI_OPERAND_OBJECT Descriptor - a giant union of all of the above + * + *****************************************************************************/ + +typedef union acpi_operand_object +{ + ACPI_OBJECT_COMMON Common; + ACPI_OBJECT_INTEGER Integer; + ACPI_OBJECT_STRING String; + ACPI_OBJECT_BUFFER Buffer; + ACPI_OBJECT_PACKAGE Package; + ACPI_OBJECT_EVENT Event; + ACPI_OBJECT_METHOD Method; + ACPI_OBJECT_MUTEX Mutex; + ACPI_OBJECT_REGION Region; + ACPI_OBJECT_NOTIFY_COMMON CommonNotify; + ACPI_OBJECT_DEVICE Device; + ACPI_OBJECT_POWER_RESOURCE PowerResource; + ACPI_OBJECT_PROCESSOR Processor; + ACPI_OBJECT_THERMAL_ZONE ThermalZone; + ACPI_OBJECT_FIELD_COMMON CommonField; + ACPI_OBJECT_REGION_FIELD Field; + ACPI_OBJECT_BUFFER_FIELD BufferField; + ACPI_OBJECT_BANK_FIELD BankField; + ACPI_OBJECT_INDEX_FIELD IndexField; + ACPI_OBJECT_NOTIFY_HANDLER Notify; + ACPI_OBJECT_ADDR_HANDLER AddressSpace; + ACPI_OBJECT_REFERENCE Reference; + ACPI_OBJECT_EXTRA Extra; + ACPI_OBJECT_DATA Data; + ACPI_OBJECT_CACHE_LIST Cache; + + /* + * Add namespace node to union in order to simplify code that accepts both + * ACPI_OPERAND_OBJECTs and ACPI_NAMESPACE_NODEs. The structures share + * a common DescriptorType field in order to differentiate them. + */ + ACPI_NAMESPACE_NODE Node; + +} ACPI_OPERAND_OBJECT; + + +/****************************************************************************** + * + * ACPI_DESCRIPTOR - objects that share a common descriptor identifier + * + *****************************************************************************/ + +/* Object descriptor types */ + +#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */ +#define ACPI_DESC_TYPE_STATE 0x02 +#define ACPI_DESC_TYPE_STATE_UPDATE 0x03 +#define ACPI_DESC_TYPE_STATE_PACKAGE 0x04 +#define ACPI_DESC_TYPE_STATE_CONTROL 0x05 +#define ACPI_DESC_TYPE_STATE_RPSCOPE 0x06 +#define ACPI_DESC_TYPE_STATE_PSCOPE 0x07 +#define ACPI_DESC_TYPE_STATE_WSCOPE 0x08 +#define ACPI_DESC_TYPE_STATE_RESULT 0x09 +#define ACPI_DESC_TYPE_STATE_NOTIFY 0x0A +#define ACPI_DESC_TYPE_STATE_THREAD 0x0B +#define ACPI_DESC_TYPE_WALK 0x0C +#define ACPI_DESC_TYPE_PARSER 0x0D +#define ACPI_DESC_TYPE_OPERAND 0x0E +#define ACPI_DESC_TYPE_NAMED 0x0F +#define ACPI_DESC_TYPE_MAX 0x0F + + +typedef struct acpi_common_descriptor +{ + void *CommonPointer; + UINT8 DescriptorType; /* To differentiate various internal objs */ + +} ACPI_COMMON_DESCRIPTOR; + +typedef union acpi_descriptor +{ + ACPI_COMMON_DESCRIPTOR Common; + ACPI_OPERAND_OBJECT Object; + ACPI_NAMESPACE_NODE Node; + ACPI_PARSE_OBJECT Op; + +} ACPI_DESCRIPTOR; + +#pragma pack() + +#endif /* _ACOBJECT_H */ diff --git a/drivers/bus/acpi/acpica/include/acopcode.h b/drivers/bus/acpi/acpica/include/acopcode.h new file mode 100644 index 00000000000..bb309c78d3f --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acopcode.h @@ -0,0 +1,397 @@ +/****************************************************************************** + * + * Name: acopcode.h - AML opcode information for the AML parser and interpreter + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOPCODE_H__ +#define __ACOPCODE_H__ + +#define MAX_EXTENDED_OPCODE 0x88 +#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1) +#define MAX_INTERNAL_OPCODE +#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1) + +/* Used for non-assigned opcodes */ + +#define _UNK 0x6B + +/* + * Reserved ASCII characters. Do not use any of these for + * internal opcodes, since they are used to differentiate + * name strings from AML opcodes + */ +#define _ASC 0x6C +#define _NAM 0x6C +#define _PFX 0x6D + + +/* + * All AML opcodes and the parse-time arguments for each. Used by the AML + * parser Each list is compressed into a 32-bit number and stored in the + * master opcode table (in psopcode.c). + */ +#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) +#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) +#define ARGP_ARG0 ARG_NONE +#define ARGP_ARG1 ARG_NONE +#define ARGP_ARG2 ARG_NONE +#define ARGP_ARG3 ARG_NONE +#define ARGP_ARG4 ARG_NONE +#define ARGP_ARG5 ARG_NONE +#define ARGP_ARG6 ARG_NONE +#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BREAK_OP ARG_NONE +#define ARGP_BREAK_POINT_OP ARG_NONE +#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) +#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) +#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) +#define ARGP_CONTINUE_OP ARG_NONE +#define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME) +#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DEBUG_OP ARG_NONE +#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) +#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) +#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) +#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) +#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) +#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) +#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOCAL0 ARG_NONE +#define ARGP_LOCAL1 ARG_NONE +#define ARGP_LOCAL2 ARG_NONE +#define ARGP_LOCAL3 ARG_NONE +#define ARGP_LOCAL4 ARG_NONE +#define ARGP_LOCAL5 ARG_NONE +#define ARGP_LOCAL6 ARG_NONE +#define ARGP_LOCAL7 ARG_NONE +#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) +#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) +#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) +#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NOOP_OP ARG_NONE +#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_ONE_OP ARG_NONE +#define ARGP_ONES_OP ARG_NONE +#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) +#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) +#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) +#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_REVISION_OP ARG_NONE +#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) +#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) +#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST) +#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_TIMER_OP ARG_NONE +#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST) +#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) +#define ARGP_ZERO_OP ARG_NONE + + +/* + * All AML opcodes and the runtime arguments for each. Used by the AML + * interpreter Each list is compressed into a 32-bit number and stored + * in the master opcode table (in psopcode.c). + * + * (Used by PrepOperands procedure and the ASL Compiler) + */ +#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER) +#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE +#define ARGI_ARG0 ARG_NONE +#define ARGI_ARG1 ARG_NONE +#define ARGI_ARG2 ARG_NONE +#define ARGI_ARG3 ARG_NONE +#define ARGI_ARG4 ARG_NONE +#define ARGI_ARG5 ARG_NONE +#define ARGI_ARG6 ARG_NONE +#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BREAK_OP ARG_NONE +#define ARGI_BREAK_POINT_OP ARG_NONE +#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_BYTE_OP ARGI_INVALID_OPCODE +#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE +#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF) +#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF) +#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF) +#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE +#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET) +#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING) +#define ARGI_DEBUG_OP ARG_NONE +#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_TARGETREF) +#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING) +#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE +#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF) +#define ARGI_DWORD_OP ARGI_INVALID_OPCODE +#define ARGI_ELSE_OP ARGI_INVALID_OPCODE +#define ARGI_EVENT_OP ARGI_INVALID_OPCODE +#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_IF_OP ARGI_INVALID_OPCODE +#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_TARGETREF) +#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_BUFFER,ARGI_TARGETREF) +#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE) +#define ARGI_LOCAL0 ARG_NONE +#define ARGI_LOCAL1 ARG_NONE +#define ARGI_LOCAL2 ARG_NONE +#define ARGI_LOCAL3 ARG_NONE +#define ARGI_LOCAL4 ARG_NONE +#define ARGI_LOCAL5 ARG_NONE +#define ARGI_LOCAL6 ARG_NONE +#define ARGI_LOCAL7 ARG_NONE +#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER) +#define ARGI_METHOD_OP ARGI_INVALID_OPCODE +#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE +#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE +#define ARGI_NAME_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE +#define ARGI_NOOP_OP ARG_NONE +#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER) +#define ARGI_ONE_OP ARG_NONE +#define ARGI_ONES_OP ARG_NONE +#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE +#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE +#define ARGI_QWORD_OP ARGI_INVALID_OPCODE +#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF) +#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) +#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_RETURN_OP ARGI_INVALID_OPCODE +#define ARGI_REVISION_OP ARG_NONE +#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE +#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT) +#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE +#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF) +#define ARGI_STRING_OP ARGI_INVALID_OPCODE +#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE +#define ARGI_TIMER_OP ARG_NONE +#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) +#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) +#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER) +#define ARGI_WHILE_OP ARGI_INVALID_OPCODE +#define ARGI_WORD_OP ARGI_INVALID_OPCODE +#define ARGI_ZERO_OP ARG_NONE + +#endif /* __ACOPCODE_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acoutput.h b/drivers/bus/acpi/acpica/include/acoutput.h new file mode 100644 index 00000000000..4f4b1d9c69d --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acoutput.h @@ -0,0 +1,351 @@ +/****************************************************************************** + * + * Name: acoutput.h -- debug output + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOUTPUT_H__ +#define __ACOUTPUT_H__ + +/* + * Debug levels and component IDs. These are used to control the + * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a + * per-component basis and a per-exception-type basis. + */ + +/* Component IDs are used in the global "DebugLayer" */ + +#define ACPI_UTILITIES 0x00000001 +#define ACPI_HARDWARE 0x00000002 +#define ACPI_EVENTS 0x00000004 +#define ACPI_TABLES 0x00000008 +#define ACPI_NAMESPACE 0x00000010 +#define ACPI_PARSER 0x00000020 +#define ACPI_DISPATCHER 0x00000040 +#define ACPI_EXECUTER 0x00000080 +#define ACPI_RESOURCES 0x00000100 +#define ACPI_CA_DEBUGGER 0x00000200 +#define ACPI_OS_SERVICES 0x00000400 +#define ACPI_CA_DISASSEMBLER 0x00000800 + +/* Component IDs for ACPI tools and utilities */ + +#define ACPI_COMPILER 0x00001000 +#define ACPI_TOOLS 0x00002000 +#define ACPI_EXAMPLE 0x00004000 +#define ACPI_DRIVER 0x00008000 + +#define ACPI_ALL_COMPONENTS 0x0000FFFF +#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) + +/* Component IDs reserved for ACPI drivers */ + +#define ACPI_ALL_DRIVERS 0xFFFF0000 + + +/* + * Raw debug output levels, do not use these in the ACPI_DEBUG_PRINT macros + */ +#define ACPI_LV_INIT 0x00000001 +#define ACPI_LV_DEBUG_OBJECT 0x00000002 +#define ACPI_LV_INFO 0x00000004 +#define ACPI_LV_REPAIR 0x00000008 +#define ACPI_LV_ALL_EXCEPTIONS 0x0000000F + +/* Trace verbosity level 1 [Standard Trace Level] */ + +#define ACPI_LV_INIT_NAMES 0x00000020 +#define ACPI_LV_PARSE 0x00000040 +#define ACPI_LV_LOAD 0x00000080 +#define ACPI_LV_DISPATCH 0x00000100 +#define ACPI_LV_EXEC 0x00000200 +#define ACPI_LV_NAMES 0x00000400 +#define ACPI_LV_OPREGION 0x00000800 +#define ACPI_LV_BFIELD 0x00001000 +#define ACPI_LV_TABLES 0x00002000 +#define ACPI_LV_VALUES 0x00004000 +#define ACPI_LV_OBJECTS 0x00008000 +#define ACPI_LV_RESOURCES 0x00010000 +#define ACPI_LV_USER_REQUESTS 0x00020000 +#define ACPI_LV_PACKAGE 0x00040000 +#define ACPI_LV_VERBOSITY1 0x0007FF40 | ACPI_LV_ALL_EXCEPTIONS + +/* Trace verbosity level 2 [Function tracing and memory allocation] */ + +#define ACPI_LV_ALLOCATIONS 0x00100000 +#define ACPI_LV_FUNCTIONS 0x00200000 +#define ACPI_LV_OPTIMIZATIONS 0x00400000 +#define ACPI_LV_VERBOSITY2 0x00700000 | ACPI_LV_VERBOSITY1 +#define ACPI_LV_ALL ACPI_LV_VERBOSITY2 + +/* Trace verbosity level 3 [Threading, I/O, and Interrupts] */ + +#define ACPI_LV_MUTEX 0x01000000 +#define ACPI_LV_THREADS 0x02000000 +#define ACPI_LV_IO 0x04000000 +#define ACPI_LV_INTERRUPTS 0x08000000 +#define ACPI_LV_VERBOSITY3 0x0F000000 | ACPI_LV_VERBOSITY2 + +/* Exceptionally verbose output -- also used in the global "DebugLevel" */ + +#define ACPI_LV_AML_DISASSEMBLE 0x10000000 +#define ACPI_LV_VERBOSE_INFO 0x20000000 +#define ACPI_LV_FULL_TABLES 0x40000000 +#define ACPI_LV_EVENTS 0x80000000 +#define ACPI_LV_VERBOSE 0xF0000000 + + +/* + * Debug level macros that are used in the DEBUG_PRINT macros + */ +#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,ACPI_DEBUG_PARAMETERS + +/* + * Exception level -- used in the global "DebugLevel" + * + * Note: For errors, use the ACPI_ERROR or ACPI_EXCEPTION interfaces. + * For warnings, use ACPI_WARNING. + */ +#define ACPI_DB_INIT ACPI_DEBUG_LEVEL (ACPI_LV_INIT) +#define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT) +#define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) +#define ACPI_DB_REPAIR ACPI_DEBUG_LEVEL (ACPI_LV_REPAIR) +#define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) + +/* Trace level -- also used in the global "DebugLevel" */ + +#define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES) +#define ACPI_DB_THREADS ACPI_DEBUG_LEVEL (ACPI_LV_THREADS) +#define ACPI_DB_PARSE ACPI_DEBUG_LEVEL (ACPI_LV_PARSE) +#define ACPI_DB_DISPATCH ACPI_DEBUG_LEVEL (ACPI_LV_DISPATCH) +#define ACPI_DB_LOAD ACPI_DEBUG_LEVEL (ACPI_LV_LOAD) +#define ACPI_DB_EXEC ACPI_DEBUG_LEVEL (ACPI_LV_EXEC) +#define ACPI_DB_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_NAMES) +#define ACPI_DB_OPREGION ACPI_DEBUG_LEVEL (ACPI_LV_OPREGION) +#define ACPI_DB_BFIELD ACPI_DEBUG_LEVEL (ACPI_LV_BFIELD) +#define ACPI_DB_TABLES ACPI_DEBUG_LEVEL (ACPI_LV_TABLES) +#define ACPI_DB_FUNCTIONS ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS) +#define ACPI_DB_OPTIMIZATIONS ACPI_DEBUG_LEVEL (ACPI_LV_OPTIMIZATIONS) +#define ACPI_DB_VALUES ACPI_DEBUG_LEVEL (ACPI_LV_VALUES) +#define ACPI_DB_OBJECTS ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS) +#define ACPI_DB_ALLOCATIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS) +#define ACPI_DB_RESOURCES ACPI_DEBUG_LEVEL (ACPI_LV_RESOURCES) +#define ACPI_DB_IO ACPI_DEBUG_LEVEL (ACPI_LV_IO) +#define ACPI_DB_INTERRUPTS ACPI_DEBUG_LEVEL (ACPI_LV_INTERRUPTS) +#define ACPI_DB_USER_REQUESTS ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS) +#define ACPI_DB_PACKAGE ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE) +#define ACPI_DB_MUTEX ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX) +#define ACPI_DB_EVENTS ACPI_DEBUG_LEVEL (ACPI_LV_EVENTS) + +#define ACPI_DB_ALL ACPI_DEBUG_LEVEL (ACPI_LV_ALL) + +/* Defaults for DebugLevel, debug and normal */ + +#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR) +#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR) +#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) + + +#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) +/* + * Module name is included in both debug and non-debug versions primarily for + * error messages. The __FILE__ macro is not very useful for this, because it + * often includes the entire pathname to the module + */ +#define ACPI_MODULE_NAME(Name) static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name; +#else +#define ACPI_MODULE_NAME(Name) +#endif + +/* + * Ascii error messages can be configured out + */ +#ifndef ACPI_NO_ERROR_MESSAGES +#define AE_INFO _AcpiModuleName, __LINE__ + +/* + * Error reporting. Callers module and line number are inserted by AE_INFO, + * the plist contains a set of parens to allow variable-length lists. + * These macros are used for both the debug and non-debug versions of the code. + */ +#define ACPI_INFO(plist) AcpiInfo plist +#define ACPI_WARNING(plist) AcpiWarning plist +#define ACPI_EXCEPTION(plist) AcpiException plist +#define ACPI_ERROR(plist) AcpiError plist + +#else + +/* No error messages */ + +#define ACPI_INFO(plist) +#define ACPI_WARNING(plist) +#define ACPI_EXCEPTION(plist) +#define ACPI_ERROR(plist) + +#endif /* ACPI_NO_ERROR_MESSAGES */ + + +/* + * Debug macros that are conditionally compiled + */ +#ifdef ACPI_DEBUG_OUTPUT + +/* + * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header, + * define it now. This is the case where there the compiler does not support + * a __FUNCTION__ macro or equivalent. + */ +#ifndef ACPI_GET_FUNCTION_NAME +#define ACPI_GET_FUNCTION_NAME _AcpiFunctionName + +/* + * The Name parameter should be the procedure name as a quoted string. + * The function name is also used by the function exit macros below. + * Note: (const char) is used to be compatible with the debug interfaces + * and macros such as __FUNCTION__. + */ +#define ACPI_FUNCTION_NAME(Name) static const char _AcpiFunctionName[] = #Name; + +#else +/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ + +#define ACPI_FUNCTION_NAME(Name) +#endif /* ACPI_GET_FUNCTION_NAME */ + +/* + * Common parameters used for debug output functions: + * line number, function name, module(file) name, component ID + */ +#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT + +/* + * Master debug print macros + * Print message if and only if: + * 1) Debug print for the current component is enabled + * 2) Debug error level or trace level for the print statement is enabled + */ +#define ACPI_DEBUG_PRINT(plist) AcpiDebugPrint plist +#define ACPI_DEBUG_PRINT_RAW(plist) AcpiDebugPrintRaw plist + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ +#define ACPI_FUNCTION_NAME(a) +#define ACPI_DEBUG_PRINT(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) + +#endif /* ACPI_DEBUG_OUTPUT */ + + +#endif /* __ACOUTPUT_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acparser.h b/drivers/bus/acpi/acpica/include/acparser.h new file mode 100644 index 00000000000..086688e3224 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acparser.h @@ -0,0 +1,403 @@ +/****************************************************************************** + * + * Module Name: acparser.h - AML Parser subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef __ACPARSER_H__ +#define __ACPARSER_H__ + + +#define OP_HAS_RETURN_VALUE 1 + +/* Variable number of arguments. This field must be 32 bits */ + +#define ACPI_VAR_ARGS ACPI_UINT32_MAX + + +#define ACPI_PARSE_DELETE_TREE 0x0001 +#define ACPI_PARSE_NO_TREE_DELETE 0x0000 +#define ACPI_PARSE_TREE_MASK 0x0001 + +#define ACPI_PARSE_LOAD_PASS1 0x0010 +#define ACPI_PARSE_LOAD_PASS2 0x0020 +#define ACPI_PARSE_EXECUTE 0x0030 +#define ACPI_PARSE_MODE_MASK 0x0030 + +#define ACPI_PARSE_DEFERRED_OP 0x0100 +#define ACPI_PARSE_DISASSEMBLE 0x0200 + +#define ACPI_PARSE_MODULE_LEVEL 0x0400 + +/****************************************************************************** + * + * Parser interfaces + * + *****************************************************************************/ + + +/* + * psxface - Parser external interfaces + */ +ACPI_STATUS +AcpiPsExecuteMethod ( + ACPI_EVALUATE_INFO *Info); + + +/* + * psargs - Parse AML opcode arguments + */ +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState); + +char * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsGetNextSimpleArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT *Arg); + +ACPI_STATUS +AcpiPsGetNextNamepath ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + BOOLEAN MethodCall); + +ACPI_STATUS +AcpiPsGetNextArg ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT **ReturnArg); + + +/* + * psfind + */ +ACPI_PARSE_OBJECT * +AcpiPsFindName ( + ACPI_PARSE_OBJECT *Scope, + UINT32 Name, + UINT32 Opcode); + +ACPI_PARSE_OBJECT* +AcpiPsGetParent ( + ACPI_PARSE_OBJECT *Op); + + +/* + * psopcode - AML Opcode information + */ +const ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode); + +char * +AcpiPsGetOpcodeName ( + UINT16 Opcode); + +UINT8 +AcpiPsGetArgumentCount ( + UINT32 OpType); + + +/* + * psparse - top level parsing routines + */ +ACPI_STATUS +AcpiPsParseAml ( + ACPI_WALK_STATE *WalkState); + +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode); + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *state); + +ACPI_STATUS +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiPsNextParseState ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS CallbackStatus); + + +/* + * psloop - main parse loop + */ +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState); + + +/* + * psscope - Scope stack management routines + */ +ACPI_STATUS +AcpiPsInitScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Root); + +ACPI_PARSE_OBJECT * +AcpiPsGetParentScope ( + ACPI_PARSE_STATE *state); + +BOOLEAN +AcpiPsHasCompletedScope ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsPopScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT **Op, + UINT32 *ArgList, + UINT32 *ArgCount); + +ACPI_STATUS +AcpiPsPushScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Op, + UINT32 RemainingArgs, + UINT32 ArgCount); + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *state); + + +/* + * pstree - parse tree manipulation routines + */ +void +AcpiPsAppendArg( + ACPI_PARSE_OBJECT *op, + ACPI_PARSE_OBJECT *arg); + +ACPI_PARSE_OBJECT* +AcpiPsFind ( + ACPI_PARSE_OBJECT *Scope, + char *Path, + UINT16 Opcode, + UINT32 Create); + +ACPI_PARSE_OBJECT * +AcpiPsGetArg( + ACPI_PARSE_OBJECT *op, + UINT32 argn); + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op); + + +/* + * pswalk - parse tree walk routines + */ +ACPI_STATUS +AcpiPsWalkParsedAml ( + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_OBJECT *EndOp, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsGetNextWalkOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsDeleteCompletedOp ( + ACPI_WALK_STATE *WalkState); + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *root); + + +/* + * psutils - parser utilities + */ +ACPI_PARSE_OBJECT * +AcpiPsCreateScopeOp ( + void); + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *op, + UINT16 opcode); + +ACPI_PARSE_OBJECT * +AcpiPsAllocOp ( + UINT16 opcode); + +void +AcpiPsFreeOp ( + ACPI_PARSE_OBJECT *Op); + +BOOLEAN +AcpiPsIsLeadingChar ( + UINT32 c); + +BOOLEAN +AcpiPsIsPrefixChar ( + UINT32 c); + +UINT32 +AcpiPsGetName( + ACPI_PARSE_OBJECT *op); + +void +AcpiPsSetName( + ACPI_PARSE_OBJECT *op, + UINT32 name); + + +/* + * psdump - display parser tree + */ +UINT32 +AcpiPsSprintPath ( + char *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +UINT32 +AcpiPsSprintOp ( + char *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +void +AcpiPsShow ( + ACPI_PARSE_OBJECT *op); + + +#endif /* __ACPARSER_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acpi.h b/drivers/bus/acpi/acpica/include/acpi.h new file mode 100644 index 00000000000..db552836627 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acpi.h @@ -0,0 +1,144 @@ +/****************************************************************************** + * + * Name: acpi.h - Master public include file used to interface to ACPICA + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPI_H__ +#define __ACPI_H__ + +/* + * Public include files for use by code that will interface to ACPICA. + * + * Information includes the ACPICA data types, names, exceptions, and + * external interface prototypes. Also included are the definitions for + * all ACPI tables (FADT, MADT, etc.) + * + * Note: The order of these include files is important. + */ +#include +#include + +#include "platform/acenv.h" /* Environment-specific items */ +#include "acnames.h" /* Common ACPI names and strings */ +#include "actypes.h" /* ACPICA data types and structures */ +#include "acexcep.h" /* ACPICA exceptions */ +#include "actbl.h" /* ACPI table definitions */ +#include "acoutput.h" /* Error output and Debug macros */ +#include "acrestyp.h" /* Resource Descriptor structs */ +#include "acpiosxf.h" /* OSL interfaces (ACPICA-to-OS) */ +#include "acpixf.h" /* ACPI core subsystem external interfaces */ + +#include "acconfig.h" +#include "acmacros.h" + +#endif /* __ACPI_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acpiosxf.h b/drivers/bus/acpi/acpica/include/acpiosxf.h new file mode 100644 index 00000000000..730057d1efa --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acpiosxf.h @@ -0,0 +1,495 @@ + +/****************************************************************************** + * + * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These + * interfaces must be implemented by OSL to interface the + * ACPI components to the host operating system. + * + *****************************************************************************/ + + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exer + se the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPIOSXF_H__ +#define __ACPIOSXF_H__ + +#include "platform/acenv.h" +#include "actypes.h" + + +/* Types for AcpiOsExecute */ + +typedef enum +{ + OSL_GLOBAL_LOCK_HANDLER, + OSL_NOTIFY_HANDLER, + OSL_GPE_HANDLER, + OSL_DEBUGGER_THREAD, + OSL_EC_POLL_HANDLER, + OSL_EC_BURST_HANDLER + +} ACPI_EXECUTE_TYPE; + +#define ACPI_NO_UNIT_LIMIT ((UINT32) -1) +#define ACPI_MUTEX_SEM 1 + + +/* Functions for AcpiOsSignal */ + +#define ACPI_SIGNAL_FATAL 0 +#define ACPI_SIGNAL_BREAKPOINT 1 + +typedef struct acpi_signal_fatal_info +{ + UINT32 Type; + UINT32 Code; + UINT32 Argument; + +} ACPI_SIGNAL_FATAL_INFO; + + +/* + * OSL Initialization and shutdown primitives + */ +ACPI_STATUS +AcpiOsInitialize ( + void); + +ACPI_STATUS +AcpiOsTerminate ( + void); + + +/* + * ACPI Table interfaces + */ +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void); + +ACPI_STATUS +AcpiOsPredefinedOverride ( + const ACPI_PREDEFINED_NAMES *InitVal, + ACPI_STRING *NewVal); + +ACPI_STATUS +AcpiOsTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable); + + +/* + * Spinlock primitives + */ +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle); + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle); + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_SPINLOCK Handle); + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags); + + +/* + * Semaphore primitives + */ +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_SEMAPHORE *OutHandle); + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_SEMAPHORE Handle); + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_SEMAPHORE Handle, + UINT32 Units, + UINT16 Timeout); + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_SEMAPHORE Handle, + UINT32 Units); + + +/* + * Mutex primitives. May be configured to use semaphores instead via + * ACPI_MUTEX_TYPE (see platform/acenv.h) + */ +#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) + +ACPI_STATUS +AcpiOsCreateMutex ( + ACPI_MUTEX *OutHandle); + +void +AcpiOsDeleteMutex ( + ACPI_MUTEX Handle); + +ACPI_STATUS +AcpiOsAcquireMutex ( + ACPI_MUTEX Handle, + UINT16 Timeout); + +void +AcpiOsReleaseMutex ( + ACPI_MUTEX Handle); +#endif + + +/* + * Memory allocation and mapping + */ +void * +AcpiOsAllocate ( + ACPI_SIZE Size); + +void +AcpiOsFree ( + void * Memory); + +void * +AcpiOsMapMemory ( + ACPI_PHYSICAL_ADDRESS Where, + ACPI_SIZE Length); + +void +AcpiOsUnmapMemory ( + void *LogicalAddress, + ACPI_SIZE Size); + +ACPI_STATUS +AcpiOsGetPhysicalAddress ( + void *LogicalAddress, + ACPI_PHYSICAL_ADDRESS *PhysicalAddress); + + +/* + * Memory/Object Cache + */ +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache); + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache); + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache); + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache); + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object); + + +/* + * Interrupt handlers + */ +ACPI_STATUS +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine, + void *Context); + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine); + + +/* + * Threads and Scheduling + */ +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void); + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context); + +void +AcpiOsWaitEventsComplete ( + void *Context); + +void +AcpiOsSleep ( + ACPI_INTEGER Milliseconds); + +void +AcpiOsStall ( + UINT32 Microseconds); + + +/* + * Platform and hardware-independent I/O interfaces + */ +ACPI_STATUS +AcpiOsReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiOsWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + +/* + * Platform and hardware-independent physical memory interfaces + */ +ACPI_STATUS +AcpiOsReadMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiOsWriteMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + +/* + * Platform and hardware-independent PCI configuration space access + * Note: Can't use "Register" as a parameter, changed to "Reg" -- + * certain compilers complain. + */ +ACPI_STATUS +AcpiOsReadPciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Reg, + void *Value, + UINT32 Width); + +ACPI_STATUS +AcpiOsWritePciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Reg, + ACPI_INTEGER Value, + UINT32 Width); + + +/* + * Interim function needed for PCI IRQ routing + */ +void +AcpiOsDerivePciId( + ACPI_HANDLE Rhandle, + ACPI_HANDLE Chandle, + ACPI_PCI_ID **PciId); + + +/* + * Miscellaneous + */ +ACPI_STATUS +AcpiOsValidateInterface ( + char *Interface); + +BOOLEAN +AcpiOsReadable ( + void *Pointer, + ACPI_SIZE Length); + +BOOLEAN +AcpiOsWritable ( + void *Pointer, + ACPI_SIZE Length); + +UINT64 +AcpiOsGetTimer ( + void); + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info); + + +/* + * Debug print routines + */ +void ACPI_INTERNAL_VAR_XFACE +AcpiOsPrintf ( + const char *Format, + ...); + +void +AcpiOsVprintf ( + const char *Format, + va_list Args); + +void +AcpiOsRedirectOutput ( + void *Destination); + + +/* + * Debug input + */ +UINT32 +AcpiOsGetLine ( + char *Buffer); + + +/* + * Directory manipulation + */ +void * +AcpiOsOpenDirectory ( + char *Pathname, + char *WildcardSpec, + char RequestedFileType); + +/* RequesteFileType values */ + +#define REQUEST_FILE_ONLY 0 +#define REQUEST_DIR_ONLY 1 + + +char * +AcpiOsGetNextFilename ( + void *DirHandle); + +void +AcpiOsCloseDirectory ( + void *DirHandle); + + +#endif /* __ACPIOSXF_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acpixf.h b/drivers/bus/acpi/acpica/include/acpixf.h new file mode 100644 index 00000000000..a961009465a --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acpixf.h @@ -0,0 +1,687 @@ + +/****************************************************************************** + * + * Name: acpixf.h - External interfaces to the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef __ACXFACE_H__ +#define __ACXFACE_H__ + +/* Current ACPICA subsystem version in YYYYMMDD format */ + +#define ACPI_CA_VERSION 0x20091214 + +#include "actypes.h" +#include "actbl.h" + +/* + * Globals that are publically available + */ +extern UINT32 AcpiCurrentGpeCount; +extern ACPI_TABLE_FADT AcpiGbl_FADT; + +/* Runtime configuration of debug print levels */ + +extern UINT32 AcpiDbgLevel; +extern UINT32 AcpiDbgLayer; + +/* ACPICA runtime options */ + +extern UINT8 AcpiGbl_EnableInterpreterSlack; +extern UINT8 AcpiGbl_AllMethodsSerialized; +extern UINT8 AcpiGbl_CreateOsiMethod; +extern UINT8 AcpiGbl_LeaveWakeGpesDisabled; +extern UINT8 AcpiGbl_UseDefaultRegisterWidths; +extern ACPI_NAME AcpiGbl_TraceMethodName; +extern UINT32 AcpiGbl_TraceFlags; + + +/* + * Global interfaces + */ +ACPI_STATUS +AcpiInitializeTables ( + ACPI_TABLE_DESC *InitialStorage, + UINT32 InitialTableCount, + BOOLEAN AllowResize); + +ACPI_STATUS +AcpiInitializeSubsystem ( + void); + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags); + +ACPI_STATUS +AcpiInitializeObjects ( + UINT32 Flags); + +ACPI_STATUS +AcpiTerminate ( + void); + +ACPI_STATUS +AcpiSubsystemStatus ( + void); + +ACPI_STATUS +AcpiEnable ( + void); + +ACPI_STATUS +AcpiDisable ( + void); + +ACPI_STATUS +AcpiGetSystemInfo ( + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetStatistics ( + ACPI_STATISTICS *Stats); + +const char * +AcpiFormatException ( + ACPI_STATUS Exception); + +ACPI_STATUS +AcpiPurgeCachedObjects ( + void); + + +/* + * ACPI Memory managment + */ +void * +AcpiAllocate ( + UINT32 Size); + +void * +AcpiCallocate ( + UINT32 Size); + +void +AcpiFree ( + void *Address); + + +/* + * ACPI table manipulation interfaces + */ +ACPI_STATUS +AcpiReallocateRootTable ( + void); + +ACPI_STATUS +AcpiFindRootPointer ( + ACPI_SIZE *RsdpAddress); + +ACPI_STATUS +AcpiLoadTables ( + void); + +ACPI_STATUS +AcpiGetTableHeader ( + ACPI_STRING Signature, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader); + +ACPI_STATUS +AcpiGetTable ( + ACPI_STRING Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **OutTable); + +ACPI_STATUS +AcpiGetTableByIndex ( + UINT32 TableIndex, + ACPI_TABLE_HEADER **OutTable); + +ACPI_STATUS +AcpiInstallTableHandler ( + ACPI_TABLE_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveTableHandler ( + ACPI_TABLE_HANDLER Handler); + + +/* + * Namespace and name interfaces + */ +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiGetDevices ( + char *HID, + ACPI_WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiGetName ( + ACPI_HANDLE Handle, + UINT32 NameType, + ACPI_BUFFER *RetPathPtr); + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle); + +ACPI_STATUS +AcpiAttachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void *Data); + +ACPI_STATUS +AcpiDetachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler); + +ACPI_STATUS +AcpiGetData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void **Data); + +ACPI_STATUS +AcpiDebugTrace ( + char *Name, + UINT32 DebugLevel, + UINT32 DebugLayer, + UINT32 Flags); + + +/* + * Object manipulation and enumeration + */ +ACPI_STATUS +AcpiEvaluateObject ( + ACPI_HANDLE Object, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ParameterObjects, + ACPI_BUFFER *ReturnObjectBuffer); + +ACPI_STATUS +AcpiEvaluateObjectTyped ( + ACPI_HANDLE Object, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ExternalParams, + ACPI_BUFFER *ReturnBuffer, + ACPI_OBJECT_TYPE ReturnType); + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Handle, + ACPI_DEVICE_INFO **ReturnBuffer); + +ACPI_STATUS +AcpiInstallMethod ( + UINT8 *Buffer); + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *OutHandle); + +ACPI_STATUS +AcpiGetType ( + ACPI_HANDLE Object, + ACPI_OBJECT_TYPE *OutType); + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Object, + ACPI_HANDLE *OutHandle); + + +/* + * Handler interfaces + */ +ACPI_STATUS +AcpiInstallInitializationHandler ( + ACPI_INIT_HANDLER Handler, + UINT32 Function); + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 AcpiEvent, + ACPI_EVENT_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 AcpiEvent, + ACPI_EVENT_HANDLER Handler); + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler); + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler); + +ACPI_STATUS +AcpiInstallGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Type, + ACPI_EVENT_HANDLER Address, + void *Context); + +ACPI_STATUS +AcpiRemoveGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + ACPI_EVENT_HANDLER Address); + +ACPI_STATUS +AcpiInstallExceptionHandler ( + ACPI_EXCEPTION_HANDLER Handler); + + +/* + * Event interfaces + */ +ACPI_STATUS +AcpiAcquireGlobalLock ( + UINT16 Timeout, + UINT32 *Handle); + +ACPI_STATUS +AcpiReleaseGlobalLock ( + UINT32 Handle); + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 Event, + UINT32 Flags); + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 Event, + UINT32 Flags); + +ACPI_STATUS +AcpiClearEvent ( + UINT32 Event); + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 Event, + ACPI_EVENT_STATUS *EventStatus); + + +/* + * GPE Interfaces + */ +ACPI_STATUS +AcpiSetGpeType ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT8 Type); + +ACPI_STATUS +AcpiEnableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags); + +ACPI_STATUS +AcpiDisableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags); + +ACPI_STATUS +AcpiClearGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags); + +ACPI_STATUS +AcpiGetGpeStatus ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags, + ACPI_EVENT_STATUS *EventStatus); + +ACPI_STATUS +AcpiDisableAllGpes ( + void); + +ACPI_STATUS +AcpiEnableAllRuntimeGpes ( + void); + +ACPI_STATUS +AcpiGetGpeDevice ( + UINT32 GpeIndex, + ACPI_HANDLE *GpeDevice); + +ACPI_STATUS +AcpiInstallGpeBlock ( + ACPI_HANDLE GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT32 InterruptNumber); + +ACPI_STATUS +AcpiRemoveGpeBlock ( + ACPI_HANDLE GpeDevice); + + +/* + * Resource interfaces + */ +typedef +ACPI_STATUS (*ACPI_WALK_RESOURCE_CALLBACK) ( + ACPI_RESOURCE *Resource, + void *Context); + +ACPI_STATUS +AcpiGetVendorResource ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_VENDOR_UUID *Uuid, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetCurrentResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetPossibleResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiWalkResources ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_WALK_RESOURCE_CALLBACK UserFunction, + void *Context); + +ACPI_STATUS +AcpiSetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *InBuffer); + +ACPI_STATUS +AcpiGetIrqRoutingTable ( + ACPI_HANDLE BusDeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiResourceToAddress64 ( + ACPI_RESOURCE *Resource, + ACPI_RESOURCE_ADDRESS64 *Out); + + +/* + * Hardware (ACPI device) interfaces + */ +ACPI_STATUS +AcpiReset ( + void); + +ACPI_STATUS +AcpiRead ( + UINT64 *Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiWrite ( + UINT64 Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiReadBitRegister ( + UINT32 RegisterId, + UINT32 *ReturnValue); + +ACPI_STATUS +AcpiWriteBitRegister ( + UINT32 RegisterId, + UINT32 Value); + +ACPI_STATUS +AcpiGetSleepTypeData ( + UINT8 SleepState, + UINT8 *Slp_TypA, + UINT8 *Slp_TypB); + +ACPI_STATUS +AcpiEnterSleepStatePrep ( + UINT8 SleepState); + +ACPI_STATUS +AcpiEnterSleepState ( + UINT8 SleepState); + +ACPI_STATUS +AcpiEnterSleepStateS4bios ( + void); + +ACPI_STATUS +AcpiLeaveSleepState ( + UINT8 SleepState) + ; +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + UINT32 PhysicalAddress); + +#if ACPI_MACHINE_WIDTH == 64 +ACPI_STATUS +AcpiSetFirmwareWakingVector64 ( + UINT64 PhysicalAddress); +#endif + + +/* + * Error/Warning output + */ +void ACPI_INTERNAL_VAR_XFACE +AcpiError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +AcpiException ( + const char *ModuleName, + UINT32 LineNumber, + ACPI_STATUS Status, + const char *Format, + ...) ACPI_PRINTF_LIKE(4); + +void ACPI_INTERNAL_VAR_XFACE +AcpiWarning ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +AcpiInfo ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + + +/* + * Debug output + */ +#ifdef ACPI_DEBUG_OUTPUT + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrint ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) ACPI_PRINTF_LIKE(6); + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrintRaw ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) ACPI_PRINTF_LIKE(6); +#endif + +#endif /* __ACXFACE_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acpredef.h b/drivers/bus/acpi/acpica/include/acpredef.h new file mode 100644 index 00000000000..2be401520b3 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acpredef.h @@ -0,0 +1,598 @@ +/****************************************************************************** + * + * Name: acpredef - Information table for ACPI predefined methods and objects + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPREDEF_H__ +#define __ACPREDEF_H__ + + +/****************************************************************************** + * + * Return Package types + * + * 1) PTYPE1 packages do not contain sub-packages. + * + * ACPI_PTYPE1_FIXED: Fixed-length length, 1 or 2 object types: + * object type + * count + * object type + * count + * + * ACPI_PTYPE1_VAR: Variable-length length: + * object type (Int/Buf/Ref) + * + * ACPI_PTYPE1_OPTION: Package has some required and some optional elements + * (Used for _PRW) + * + * + * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each + * of the different types describe the contents of each of the sub-packages. + * + * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types: + * object type + * count + * object type + * count + * (Used for _ALR,_MLS,_PSS,_TRT,_TSS) + * + * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element: + * object type + * (Used for _CSD,_PSD,_TSD) + * + * ACPI_PTYPE2_PKG_COUNT: Count of subpackages at start, 1 or 2 object types: + * object type + * count + * object type + * count + * (Used for _CST) + * + * ACPI_PTYPE2_FIXED: Each subpackage is of Fixed-length + * (Used for _PRT) + * + * ACPI_PTYPE2_MIN: Each subpackage has a Variable-length but minimum length + * (Used for _HPX) + * + * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length + * (Used for _ART, _FPS) + * + *****************************************************************************/ + +enum AcpiReturnPackageTypes +{ + ACPI_PTYPE1_FIXED = 1, + ACPI_PTYPE1_VAR = 2, + ACPI_PTYPE1_OPTION = 3, + ACPI_PTYPE2 = 4, + ACPI_PTYPE2_COUNT = 5, + ACPI_PTYPE2_PKG_COUNT = 6, + ACPI_PTYPE2_FIXED = 7, + ACPI_PTYPE2_MIN = 8, + ACPI_PTYPE2_REV_FIXED = 9 +}; + + +#ifdef ACPI_CREATE_PREDEFINED_TABLE +/* + * Predefined method/object information table. + * + * These are the names that can actually be evaluated via AcpiEvaluateObject. + * Not present in this table are the following: + * + * 1) Predefined/Reserved names that are never evaluated via + * AcpiEvaluateObject: + * _Lxx and _Exx GPE methods + * _Qxx EC methods + * _T_x compiler temporary variables + * + * 2) Predefined names that never actually exist within the AML code: + * Predefined resource descriptor field names + * + * 3) Predefined names that are implemented within ACPICA: + * _OSI + * + * 4) Some predefined names that are not documented within the ACPI spec. + * _WDG, _WED + * + * The main entries in the table each contain the following items: + * + * Name - The ACPI reserved name + * ParamCount - Number of arguments to the method + * ExpectedBtypes - Allowed type(s) for the return value. + * 0 means that no return value is expected. + * + * For methods that return packages, the next entry in the table contains + * information about the expected structure of the package. This information + * is saved here (rather than in a separate table) in order to minimize the + * overall size of the stored data. + * + * Note: The additional braces are intended to promote portability. + */ +static const ACPI_PREDEFINED_INFO PredefinedNames[] = +{ + {{"_AC0", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC1", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC2", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC3", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC4", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC5", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC6", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC7", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC8", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC9", 0, ACPI_RTYPE_INTEGER}}, + {{"_ADR", 0, ACPI_RTYPE_INTEGER}}, + {{"_AL0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL4", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL5", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL6", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL7", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL8", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL9", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_ALC", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALI", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALP", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALR", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2 (Ints) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, + + {{"_ALT", 0, ACPI_RTYPE_INTEGER}}, + {{"_ART", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (2 Ref/11 Int) */ + {{{ACPI_PTYPE2_REV_FIXED,ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 11,0}}, + + {{"_BBN", 0, ACPI_RTYPE_INTEGER}}, + {{"_BCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_BCM", 1, 0}}, + {{"_BCT", 1, ACPI_RTYPE_INTEGER}}, + {{"_BDN", 0, ACPI_RTYPE_INTEGER}}, + {{"_BFS", 1, 0}}, + {{"_BIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (9 Int),(4 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, ACPI_RTYPE_STRING}, 4,0}}, + + {{"_BIX", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int),(4 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING}, 4,0}}, + + {{"_BLT", 3, 0}}, + {{"_BMA", 1, ACPI_RTYPE_INTEGER}}, + {{"_BMC", 1, 0}}, + {{"_BMD", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (5 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_BMS", 1, ACPI_RTYPE_INTEGER}}, + {{"_BQC", 0, ACPI_RTYPE_INTEGER}}, + {{"_BST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_BTM", 1, ACPI_RTYPE_INTEGER}}, + {{"_BTP", 1, 0}}, + {{"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* See PCI firmware spec 3.0 */ + {{"_CDM", 0, ACPI_RTYPE_INTEGER}}, + {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0,0}, 0,0}}, + + {{"_CRS", 0, ACPI_RTYPE_BUFFER}}, + {{"_CRT", 0, ACPI_RTYPE_INTEGER}}, + {{"_CSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n-1 Int) */ + {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */ + {{{ACPI_PTYPE2_PKG_COUNT,ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3,0}}, + + {{"_DCK", 1, ACPI_RTYPE_INTEGER}}, + {{"_DCS", 0, ACPI_RTYPE_INTEGER}}, + {{"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}}, + {{"_DDN", 0, ACPI_RTYPE_STRING}}, + {{"_DGS", 0, ACPI_RTYPE_INTEGER}}, + {{"_DIS", 0, 0}}, + {{"_DMA", 0, ACPI_RTYPE_BUFFER}}, + {{"_DOD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_DOS", 1, 0}}, + {{"_DSM", 4, ACPI_RTYPE_ALL}}, /* Must return a type, but it can be of any type */ + {{"_DSS", 1, 0}}, + {{"_DSW", 3, 0}}, + {{"_DTI", 1, 0}}, + {{"_EC_", 0, ACPI_RTYPE_INTEGER}}, + {{"_EDL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs)*/ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_EJ0", 1, 0}}, + {{"_EJ1", 1, 0}}, + {{"_EJ2", 1, 0}}, + {{"_EJ3", 1, 0}}, + {{"_EJ4", 1, 0}}, + {{"_EJD", 0, ACPI_RTYPE_STRING}}, + {{"_FDE", 0, ACPI_RTYPE_BUFFER}}, + {{"_FDI", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16,0}, 0,0}}, + + {{"_FDM", 1, 0}}, + {{"_FIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_FIX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_FPS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (5 Int) */ + {{{ACPI_PTYPE2_REV_FIXED,ACPI_RTYPE_INTEGER, 5, 0}, 0,0}}, + + {{"_FSL", 1, 0}}, + {{"_FST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3,0}, 0,0}}, + + + {{"_GAI", 0, ACPI_RTYPE_INTEGER}}, + {{"_GHL", 0, ACPI_RTYPE_INTEGER}}, + {{"_GLK", 0, ACPI_RTYPE_INTEGER}}, + {{"_GPD", 0, ACPI_RTYPE_INTEGER}}, + {{"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */ + {{"_GSB", 0, ACPI_RTYPE_INTEGER}}, + {{"_GTF", 0, ACPI_RTYPE_BUFFER}}, + {{"_GTM", 0, ACPI_RTYPE_BUFFER}}, + {{"_GTS", 1, 0}}, + {{"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, + {{"_HOT", 0, ACPI_RTYPE_INTEGER}}, + {{"_HPP", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + /* + * For _HPX, a single package is returned, containing a Variable-length number + * of sub-packages. Each sub-package contains a PCI record setting. + * There are several different type of record settings, of different + * lengths, but all elements of all settings are Integers. + */ + {{"_HPX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (var Ints) */ + {{{ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ + {{"_INI", 0, 0}}, + {{"_IRC", 0, 0}}, + {{"_LCK", 1, 0}}, + {{"_LID", 0, ACPI_RTYPE_INTEGER}}, + {{"_MAT", 0, ACPI_RTYPE_BUFFER}}, + {{"_MBM", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (8 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8,0}, 0,0}}, + + {{"_MLS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (2 Str) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_STRING, 2,0}, 0,0}}, + + {{"_MSG", 1, 0}}, + {{"_MSM", 4, ACPI_RTYPE_INTEGER}}, + {{"_NTT", 0, ACPI_RTYPE_INTEGER}}, + {{"_OFF", 0, 0}}, + {{"_ON_", 0, 0}}, + {{"_OS_", 0, ACPI_RTYPE_STRING}}, + {{"_OSC", 4, ACPI_RTYPE_BUFFER}}, + {{"_OST", 3, 0}}, + {{"_PAI", 1, ACPI_RTYPE_INTEGER}}, + {{"_PCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PCT", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, + + {{"_PDC", 1, 0}}, + {{"_PDL", 0, ACPI_RTYPE_INTEGER}}, + {{"_PIC", 1, 0}}, + {{"_PIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int),(3 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, ACPI_RTYPE_STRING}, 3,0}}, + + {{"_PLD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Bufs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0,0}, 0,0}}, + + {{"_PMC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (11 Int),(3 Str) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 11, ACPI_RTYPE_STRING}, 3,0}}, + + {{"_PMD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PMM", 0, ACPI_RTYPE_INTEGER}}, + {{"_PPC", 0, ACPI_RTYPE_INTEGER}}, + {{"_PPE", 0, ACPI_RTYPE_INTEGER}}, /* See dig64 spec */ + {{"_PR0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PRL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PRS", 0, ACPI_RTYPE_BUFFER}}, + + /* + * For _PRT, many BIOSs reverse the 3rd and 4th Package elements (Source + * and SourceIndex). This bug is so prevalent that there is code in the + * ACPICA Resource Manager to detect this and switch them back. For now, + * do not allow and issue a warning. To allow this and eliminate the + * warning, add the ACPI_RTYPE_REFERENCE type to the 4th element (index 3) + * in the statement below. + */ + {{"_PRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (4): Int,Int,Int/Ref,Int */ + {{{ACPI_PTYPE2_FIXED, 4, ACPI_RTYPE_INTEGER,ACPI_RTYPE_INTEGER}, + ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, + ACPI_RTYPE_INTEGER}}, + + {{"_PRW", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each: Pkg/Int,Int,[Variable-length Refs] (Pkg is Ref/Int) */ + {{{ACPI_PTYPE1_OPTION, 2, ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE, + ACPI_RTYPE_INTEGER}, ACPI_RTYPE_REFERENCE,0}}, + + {{"_PS0", 0, 0}}, + {{"_PS1", 0, 0}}, + {{"_PS2", 0, 0}}, + {{"_PS3", 0, 0}}, + {{"_PSC", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (5 Int) with count */ + {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER,0,0}, 0,0}}, + + {{"_PSL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PSR", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (6 Int) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6,0}, 0,0}}, + + {{"_PSV", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSW", 1, 0}}, + {{"_PTC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, + + {{"_PTP", 2, ACPI_RTYPE_INTEGER}}, + {{"_PTS", 1, 0}}, + {{"_PUR", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, + + {{"_PXM", 0, ACPI_RTYPE_INTEGER}}, + {{"_REG", 2, 0}}, + {{"_REV", 0, ACPI_RTYPE_INTEGER}}, + {{"_RMV", 0, ACPI_RTYPE_INTEGER}}, + {{"_ROM", 2, ACPI_RTYPE_BUFFER}}, + {{"_RTV", 0, ACPI_RTYPE_INTEGER}}, + + /* + * For _S0_ through _S5_, the ACPI spec defines a return Package + * containing 1 Integer, but most DSDTs have it wrong - 2,3, or 4 integers. + * Allow this by making the objects "Variable-length length", but all elements + * must be Integers. + */ + {{"_S0_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S1_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S2_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S3_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S4_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S5_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S1D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S2D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S3D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S4D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S0W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S1W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S2W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S3W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S4W", 0, ACPI_RTYPE_INTEGER}}, + {{"_SBS", 0, ACPI_RTYPE_INTEGER}}, + {{"_SCP", 0x13, 0}}, /* Acpi 1.0 allowed 1 arg. Acpi 3.0 expanded to 3 args. Allow both. */ + /* Note: the 3-arg definition may be removed for ACPI 4.0 */ + {{"_SDD", 1, 0}}, + {{"_SEG", 0, ACPI_RTYPE_INTEGER}}, + {{"_SHL", 1, ACPI_RTYPE_INTEGER}}, + {{"_SLI", 0, ACPI_RTYPE_BUFFER}}, + {{"_SPD", 1, ACPI_RTYPE_INTEGER}}, + {{"_SRS", 1, 0}}, + {{"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ + {{"_SST", 1, 0}}, + {{"_STA", 0, ACPI_RTYPE_INTEGER}}, + {{"_STM", 3, 0}}, + {{"_STP", 2, ACPI_RTYPE_INTEGER}}, + {{"_STR", 0, ACPI_RTYPE_BUFFER}}, + {{"_STV", 2, ACPI_RTYPE_INTEGER}}, + {{"_SUN", 0, ACPI_RTYPE_INTEGER}}, + {{"_SWS", 0, ACPI_RTYPE_INTEGER}}, + {{"_TC1", 0, ACPI_RTYPE_INTEGER}}, + {{"_TC2", 0, ACPI_RTYPE_INTEGER}}, + {{"_TIP", 1, ACPI_RTYPE_INTEGER}}, + {{"_TIV", 1, ACPI_RTYPE_INTEGER}}, + {{"_TMP", 0, ACPI_RTYPE_INTEGER}}, + {{"_TPC", 0, ACPI_RTYPE_INTEGER}}, + {{"_TPT", 1, 0}}, + {{"_TRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2Ref/6Int */ + {{{ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 6, 0}}, + + {{"_TSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5Int with count */ + {{{ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_TSP", 0, ACPI_RTYPE_INTEGER}}, + {{"_TSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5Int */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_TST", 0, ACPI_RTYPE_INTEGER}}, + {{"_TTS", 1, 0}}, + {{"_TZD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_TZM", 0, ACPI_RTYPE_REFERENCE}}, + {{"_TZP", 0, ACPI_RTYPE_INTEGER}}, + {{"_UID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, + {{"_UPC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_UPD", 0, ACPI_RTYPE_INTEGER}}, + {{"_UPP", 0, ACPI_RTYPE_INTEGER}}, + {{"_VPO", 0, ACPI_RTYPE_INTEGER}}, + + /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ + + {{"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}}, + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */ + + {{{0,0,0,0}, 0,0}} /* Table terminator */ +}; + +#if 0 + /* Not implemented */ + + {{"_WDG", 0, ACPI_RTYPE_BUFFER}}, /* MS Extension */ + {{"_WED", 1, ACPI_RTYPE_PACKAGE}}, /* MS Extension */ + + /* This is an internally implemented control method, no need to check */ + {{"_OSI", 1, ACPI_RTYPE_INTEGER}}, + + /* TBD: */ + + _PRT - currently ignore reversed entries. Attempt to fix here? + Think about possibly fixing package elements like _BIF, etc. +#endif +#endif +#endif diff --git a/drivers/bus/acpi/acpica/include/acresrc.h b/drivers/bus/acpi/acpica/include/acresrc.h new file mode 100644 index 00000000000..c70aa5e23d4 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acresrc.h @@ -0,0 +1,465 @@ +/****************************************************************************** + * + * Name: acresrc.h - Resource Manager function prototypes + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACRESRC_H__ +#define __ACRESRC_H__ + +/* Need the AML resource descriptor structs */ + +#include "amlresrc.h" + + +/* + * If possible, pack the following structures to byte alignment, since we + * don't care about performance for debug output. Two cases where we cannot + * pack the structures: + * + * 1) Hardware does not support misaligned memory transfers + * 2) Compiler does not support pointers within packed structures + */ +#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) +#pragma pack(1) +#endif + +/* + * Individual entry for the resource conversion tables + */ +typedef const struct acpi_rsconvert_info +{ + UINT8 Opcode; + UINT8 ResourceOffset; + UINT8 AmlOffset; + UINT8 Value; + +} ACPI_RSCONVERT_INFO; + +/* Resource conversion opcodes */ + +#define ACPI_RSC_INITGET 0 +#define ACPI_RSC_INITSET 1 +#define ACPI_RSC_FLAGINIT 2 +#define ACPI_RSC_1BITFLAG 3 +#define ACPI_RSC_2BITFLAG 4 +#define ACPI_RSC_COUNT 5 +#define ACPI_RSC_COUNT16 6 +#define ACPI_RSC_LENGTH 7 +#define ACPI_RSC_MOVE8 8 +#define ACPI_RSC_MOVE16 9 +#define ACPI_RSC_MOVE32 10 +#define ACPI_RSC_MOVE64 11 +#define ACPI_RSC_SET8 12 +#define ACPI_RSC_DATA8 13 +#define ACPI_RSC_ADDRESS 14 +#define ACPI_RSC_SOURCE 15 +#define ACPI_RSC_SOURCEX 16 +#define ACPI_RSC_BITMASK 17 +#define ACPI_RSC_BITMASK16 18 +#define ACPI_RSC_EXIT_NE 19 +#define ACPI_RSC_EXIT_LE 20 +#define ACPI_RSC_EXIT_EQ 21 + +/* Resource Conversion sub-opcodes */ + +#define ACPI_RSC_COMPARE_AML_LENGTH 0 +#define ACPI_RSC_COMPARE_VALUE 1 + +#define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO)) + +#define ACPI_RS_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f) +#define AML_OFFSET(f) (UINT8) ACPI_OFFSET (AML_RESOURCE,f) + + +typedef const struct acpi_rsdump_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + const char **Pointer; + +} ACPI_RSDUMP_INFO; + +/* Values for the Opcode field above */ + +#define ACPI_RSD_TITLE 0 +#define ACPI_RSD_LITERAL 1 +#define ACPI_RSD_STRING 2 +#define ACPI_RSD_UINT8 3 +#define ACPI_RSD_UINT16 4 +#define ACPI_RSD_UINT32 5 +#define ACPI_RSD_UINT64 6 +#define ACPI_RSD_1BITFLAG 7 +#define ACPI_RSD_2BITFLAG 8 +#define ACPI_RSD_SHORTLIST 9 +#define ACPI_RSD_LONGLIST 10 +#define ACPI_RSD_DWORDLIST 11 +#define ACPI_RSD_ADDRESS 12 +#define ACPI_RSD_SOURCE 13 + +/* restore default alignment */ + +#pragma pack() + + +/* Resource tables indexed by internal resource type */ + +extern const UINT8 AcpiGbl_AmlResourceSizes[]; +extern ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[]; + +/* Resource tables indexed by raw AML resource descriptor type */ + +extern const UINT8 AcpiGbl_ResourceStructSizes[]; +extern ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[]; + + +typedef struct acpi_vendor_walk_info +{ + ACPI_VENDOR_UUID *Uuid; + ACPI_BUFFER *Buffer; + ACPI_STATUS Status; + +} ACPI_VENDOR_WALK_INFO; + + +/* + * rscreate + */ +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *AmlBuffer, + ACPI_BUFFER *OutputBuffer); + +ACPI_STATUS +AcpiRsCreateAmlResources ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_BUFFER *OutputBuffer); + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_BUFFER *OutputBuffer); + + +/* + * rsutils + */ +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetMethodData ( + ACPI_HANDLE Handle, + char *Path, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + + +/* + * rscalc + */ +ACPI_STATUS +AcpiRsGetListLength ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, + ACPI_SIZE *SizeNeeded); + +ACPI_STATUS +AcpiRsGetAmlLength ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_SIZE *SizeNeeded); + +ACPI_STATUS +AcpiRsGetPciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_SIZE *BufferSizeNeeded); + +ACPI_STATUS +AcpiRsConvertAmlToResources ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context); + +ACPI_STATUS +AcpiRsConvertResourcesToAml ( + ACPI_RESOURCE *Resource, + ACPI_SIZE AmlSizeNeeded, + UINT8 *OutputBuffer); + + +/* + * rsaddr + */ +void +AcpiRsSetAddressCommon ( + AML_RESOURCE *Aml, + ACPI_RESOURCE *Resource); + +BOOLEAN +AcpiRsGetAddressCommon ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml); + + +/* + * rsmisc + */ +ACPI_STATUS +AcpiRsConvertAmlToResource ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info); + +ACPI_STATUS +AcpiRsConvertResourceToAml ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info); + + +/* + * rsutils + */ +void +AcpiRsMoveData ( + void *Destination, + void *Source, + UINT16 ItemCount, + UINT8 MoveType); + +UINT8 +AcpiRsDecodeBitmask ( + UINT16 Mask, + UINT8 *List); + +UINT16 +AcpiRsEncodeBitmask ( + UINT8 *List, + UINT8 Count); + +ACPI_RS_LENGTH +AcpiRsGetResourceSource ( + ACPI_RS_LENGTH ResourceLength, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource, + AML_RESOURCE *Aml, + char *StringPtr); + +ACPI_RSDESC_SIZE +AcpiRsSetResourceSource ( + AML_RESOURCE *Aml, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource); + +void +AcpiRsSetResourceHeader ( + UINT8 DescriptorType, + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml); + +void +AcpiRsSetResourceLength ( + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml); + + +/* + * rsdump + */ +void +AcpiRsDumpResourceList ( + ACPI_RESOURCE *Resource); + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable); + + +/* + * Resource conversion tables + */ +extern ACPI_RSCONVERT_INFO AcpiRsConvertDma[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertIo[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[]; + +/* These resources require separate get/set tables */ + +extern ACPI_RSCONVERT_INFO AcpiRsGetIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[]; + +extern ACPI_RSCONVERT_INFO AcpiRsSetIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsSetVendor[]; + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/* + * rsinfo + */ +extern ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[]; + +/* + * rsdump + */ +extern ACPI_RSDUMP_INFO AcpiRsDumpIrq[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpDma[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpIo[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpVendor[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpEndTag[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpMemory24[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpMemory32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress16[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress64[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[]; +#endif + +#endif /* __ACRESRC_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acrestyp.h b/drivers/bus/acpi/acpica/include/acrestyp.h new file mode 100644 index 00000000000..7eb7600d982 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acrestyp.h @@ -0,0 +1,544 @@ +/****************************************************************************** + * + * Name: acrestyp.h - Defines, types, and structures for resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACRESTYP_H__ +#define __ACRESTYP_H__ + + +/* + * Definitions for Resource Attributes + */ +typedef UINT16 ACPI_RS_LENGTH; /* Resource Length field is fixed at 16 bits */ +typedef UINT32 ACPI_RSDESC_SIZE; /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */ + +/* + * Memory Attributes + */ +#define ACPI_READ_ONLY_MEMORY (UINT8) 0x00 +#define ACPI_READ_WRITE_MEMORY (UINT8) 0x01 + +#define ACPI_NON_CACHEABLE_MEMORY (UINT8) 0x00 +#define ACPI_CACHABLE_MEMORY (UINT8) 0x01 +#define ACPI_WRITE_COMBINING_MEMORY (UINT8) 0x02 +#define ACPI_PREFETCHABLE_MEMORY (UINT8) 0x03 + +/* + * IO Attributes + * The ISA IO ranges are: n000-n0FFh, n400-n4FFh, n800-n8FFh, nC00-nCFFh. + * The non-ISA IO ranges are: n100-n3FFh, n500-n7FFh, n900-nBFFh, nCD0-nFFFh. + */ +#define ACPI_NON_ISA_ONLY_RANGES (UINT8) 0x01 +#define ACPI_ISA_ONLY_RANGES (UINT8) 0x02 +#define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES) + +/* Type of translation - 1=Sparse, 0=Dense */ + +#define ACPI_SPARSE_TRANSLATION (UINT8) 0x01 + +/* + * IO Port Descriptor Decode + */ +#define ACPI_DECODE_10 (UINT8) 0x00 /* 10-bit IO address decode */ +#define ACPI_DECODE_16 (UINT8) 0x01 /* 16-bit IO address decode */ + +/* + * IRQ Attributes + */ +#define ACPI_LEVEL_SENSITIVE (UINT8) 0x00 +#define ACPI_EDGE_SENSITIVE (UINT8) 0x01 + +#define ACPI_ACTIVE_HIGH (UINT8) 0x00 +#define ACPI_ACTIVE_LOW (UINT8) 0x01 + +#define ACPI_EXCLUSIVE (UINT8) 0x00 +#define ACPI_SHARED (UINT8) 0x01 + +/* + * DMA Attributes + */ +#define ACPI_COMPATIBILITY (UINT8) 0x00 +#define ACPI_TYPE_A (UINT8) 0x01 +#define ACPI_TYPE_B (UINT8) 0x02 +#define ACPI_TYPE_F (UINT8) 0x03 + +#define ACPI_NOT_BUS_MASTER (UINT8) 0x00 +#define ACPI_BUS_MASTER (UINT8) 0x01 + +#define ACPI_TRANSFER_8 (UINT8) 0x00 +#define ACPI_TRANSFER_8_16 (UINT8) 0x01 +#define ACPI_TRANSFER_16 (UINT8) 0x02 + +/* + * Start Dependent Functions Priority definitions + */ +#define ACPI_GOOD_CONFIGURATION (UINT8) 0x00 +#define ACPI_ACCEPTABLE_CONFIGURATION (UINT8) 0x01 +#define ACPI_SUB_OPTIMAL_CONFIGURATION (UINT8) 0x02 + +/* + * 16, 32 and 64-bit Address Descriptor resource types + */ +#define ACPI_MEMORY_RANGE (UINT8) 0x00 +#define ACPI_IO_RANGE (UINT8) 0x01 +#define ACPI_BUS_NUMBER_RANGE (UINT8) 0x02 + +#define ACPI_ADDRESS_NOT_FIXED (UINT8) 0x00 +#define ACPI_ADDRESS_FIXED (UINT8) 0x01 + +#define ACPI_POS_DECODE (UINT8) 0x00 +#define ACPI_SUB_DECODE (UINT8) 0x01 + +#define ACPI_PRODUCER (UINT8) 0x00 +#define ACPI_CONSUMER (UINT8) 0x01 + + +/* + * If possible, pack the following structures to byte alignment + */ +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#pragma pack(1) +#endif + +/* UUID data structures for use in vendor-defined resource descriptors */ + +typedef struct acpi_uuid +{ + UINT8 Data[ACPI_UUID_LENGTH]; +} ACPI_UUID; + +typedef struct acpi_vendor_uuid +{ + UINT8 Subtype; + UINT8 Data[ACPI_UUID_LENGTH]; + +} ACPI_VENDOR_UUID; + +/* + * Structures used to describe device resources + */ +typedef struct acpi_resource_irq +{ + UINT8 DescriptorLength; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + UINT8 Interrupts[1]; + +} ACPI_RESOURCE_IRQ; + +typedef struct ACPI_RESOURCE_DMA +{ + UINT8 Type; + UINT8 BusMaster; + UINT8 Transfer; + UINT8 ChannelCount; + UINT8 Channels[1]; + +} ACPI_RESOURCE_DMA; + +typedef struct acpi_resource_start_dependent +{ + UINT8 DescriptorLength; + UINT8 CompatibilityPriority; + UINT8 PerformanceRobustness; + +} ACPI_RESOURCE_START_DEPENDENT; + + +/* + * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not + * needed because it has no fields + */ + + +typedef struct acpi_resource_io +{ + UINT8 IoDecode; + UINT8 Alignment; + UINT8 AddressLength; + UINT16 Minimum; + UINT16 Maximum; + +} ACPI_RESOURCE_IO; + +typedef struct acpi_resource_fixed_io +{ + UINT16 Address; + UINT8 AddressLength; + +} ACPI_RESOURCE_FIXED_IO; + +typedef struct acpi_resource_vendor +{ + UINT16 ByteLength; + UINT8 ByteData[1]; + +} ACPI_RESOURCE_VENDOR; + +/* Vendor resource with UUID info (introduced in ACPI 3.0) */ + +typedef struct acpi_resource_vendor_typed +{ + UINT16 ByteLength; + UINT8 UuidSubtype; + UINT8 Uuid[ACPI_UUID_LENGTH]; + UINT8 ByteData[1]; + +} ACPI_RESOURCE_VENDOR_TYPED; + +typedef struct acpi_resource_end_tag +{ + UINT8 Checksum; + +} ACPI_RESOURCE_END_TAG; + +typedef struct acpi_resource_memory24 +{ + UINT8 WriteProtect; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; + +} ACPI_RESOURCE_MEMORY24; + +typedef struct acpi_resource_memory32 +{ + UINT8 WriteProtect; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; + +} ACPI_RESOURCE_MEMORY32; + +typedef struct acpi_resource_fixed_memory32 +{ + UINT8 WriteProtect; + UINT32 Address; + UINT32 AddressLength; + +} ACPI_RESOURCE_FIXED_MEMORY32; + +typedef struct acpi_memory_attribute +{ + UINT8 WriteProtect; + UINT8 Caching; + UINT8 RangeType; + UINT8 Translation; + +} ACPI_MEMORY_ATTRIBUTE; + +typedef struct acpi_io_attribute +{ + UINT8 RangeType; + UINT8 Translation; + UINT8 TranslationType; + UINT8 Reserved1; + +} ACPI_IO_ATTRIBUTE; + +typedef union acpi_resource_attribute +{ + ACPI_MEMORY_ATTRIBUTE Mem; + ACPI_IO_ATTRIBUTE Io; + + /* Used for the *WordSpace macros */ + + UINT8 TypeSpecific; + +} ACPI_RESOURCE_ATTRIBUTE; + +typedef struct acpi_resource_source +{ + UINT8 Index; + UINT16 StringLength; + char *StringPtr; + +} ACPI_RESOURCE_SOURCE; + +/* Fields common to all address descriptors, 16/32/64 bit */ + +#define ACPI_RESOURCE_ADDRESS_COMMON \ + UINT8 ResourceType; \ + UINT8 ProducerConsumer; \ + UINT8 Decode; \ + UINT8 MinAddressFixed; \ + UINT8 MaxAddressFixed; \ + ACPI_RESOURCE_ATTRIBUTE Info; + +typedef struct acpi_resource_address +{ + ACPI_RESOURCE_ADDRESS_COMMON + +} ACPI_RESOURCE_ADDRESS; + +typedef struct acpi_resource_address16 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS16; + +typedef struct acpi_resource_address32 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT32 Granularity; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; + UINT32 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS32; + +typedef struct acpi_resource_address64 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS64; + +typedef struct acpi_resource_extended_address64 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT8 RevisionID; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; + +} ACPI_RESOURCE_EXTENDED_ADDRESS64; + +typedef struct acpi_resource_extended_irq +{ + UINT8 ProducerConsumer; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + ACPI_RESOURCE_SOURCE ResourceSource; + UINT32 Interrupts[1]; + +} ACPI_RESOURCE_EXTENDED_IRQ; + +typedef struct acpi_resource_generic_register +{ + UINT8 SpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; + UINT64 Address; + +} ACPI_RESOURCE_GENERIC_REGISTER; + + +/* ACPI_RESOURCE_TYPEs */ + +#define ACPI_RESOURCE_TYPE_IRQ 0 +#define ACPI_RESOURCE_TYPE_DMA 1 +#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2 +#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3 +#define ACPI_RESOURCE_TYPE_IO 4 +#define ACPI_RESOURCE_TYPE_FIXED_IO 5 +#define ACPI_RESOURCE_TYPE_VENDOR 6 +#define ACPI_RESOURCE_TYPE_END_TAG 7 +#define ACPI_RESOURCE_TYPE_MEMORY24 8 +#define ACPI_RESOURCE_TYPE_MEMORY32 9 +#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10 +#define ACPI_RESOURCE_TYPE_ADDRESS16 11 +#define ACPI_RESOURCE_TYPE_ADDRESS32 12 +#define ACPI_RESOURCE_TYPE_ADDRESS64 13 +#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */ +#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15 +#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16 +#define ACPI_RESOURCE_TYPE_MAX 16 + +/* Master union for resource descriptors */ + +typedef union acpi_resource_data +{ + ACPI_RESOURCE_IRQ Irq; + ACPI_RESOURCE_DMA Dma; + ACPI_RESOURCE_START_DEPENDENT StartDpf; + ACPI_RESOURCE_IO Io; + ACPI_RESOURCE_FIXED_IO FixedIo; + ACPI_RESOURCE_VENDOR Vendor; + ACPI_RESOURCE_VENDOR_TYPED VendorTyped; + ACPI_RESOURCE_END_TAG EndTag; + ACPI_RESOURCE_MEMORY24 Memory24; + ACPI_RESOURCE_MEMORY32 Memory32; + ACPI_RESOURCE_FIXED_MEMORY32 FixedMemory32; + ACPI_RESOURCE_ADDRESS16 Address16; + ACPI_RESOURCE_ADDRESS32 Address32; + ACPI_RESOURCE_ADDRESS64 Address64; + ACPI_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + ACPI_RESOURCE_EXTENDED_IRQ ExtendedIrq; + ACPI_RESOURCE_GENERIC_REGISTER GenericReg; + + /* Common fields */ + + ACPI_RESOURCE_ADDRESS Address; /* Common 16/32/64 address fields */ + +} ACPI_RESOURCE_DATA; + + +/* Common resource header */ + +typedef struct acpi_resource +{ + UINT32 Type; + UINT32 Length; + ACPI_RESOURCE_DATA Data; + +} ACPI_RESOURCE; + +/* restore default alignment */ + +#pragma pack() + + +#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */ +#define ACPI_RS_SIZE_MIN (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (12) +#define ACPI_RS_SIZE(Type) (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type)) + +#define ACPI_NEXT_RESOURCE(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length) + + +typedef struct acpi_pci_routing_table +{ + UINT32 Length; + UINT32 Pin; + ACPI_INTEGER Address; /* here for 64-bit alignment */ + UINT32 SourceIndex; + char Source[4]; /* pad to 64 bits so sizeof() works in all cases */ + +} ACPI_PCI_ROUTING_TABLE; + +#endif /* __ACRESTYP_H__ */ + diff --git a/drivers/bus/acpi/acpica/include/acstruct.h b/drivers/bus/acpi/acpica/include/acstruct.h new file mode 100644 index 00000000000..45c85fe0b2f --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acstruct.h @@ -0,0 +1,326 @@ +/****************************************************************************** + * + * Name: acstruct.h - Internal structs + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACSTRUCT_H__ +#define __ACSTRUCT_H__ + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +/***************************************************************************** + * + * Tree walking typedefs and structs + * + ****************************************************************************/ + + +/* + * Walk state - current state of a parse tree walk. Used for both a leisurely + * stroll through the tree (for whatever reason), and for control method + * execution. + */ +#define ACPI_NEXT_OP_DOWNWARD 1 +#define ACPI_NEXT_OP_UPWARD 2 + +/* + * Groups of definitions for WalkType used for different implementations of + * walkers (never simultaneously) - flags for interpreter: + */ +#define ACPI_WALK_NON_METHOD 0 +#define ACPI_WALK_METHOD 0x01 +#define ACPI_WALK_METHOD_RESTART 0x02 + +/* Flags for iASL compiler only */ + +#define ACPI_WALK_CONST_REQUIRED 0x10 +#define ACPI_WALK_CONST_OPTIONAL 0x20 + + +typedef struct acpi_walk_state +{ + struct acpi_walk_state *Next; /* Next WalkState in list */ + UINT8 DescriptorType; /* To differentiate various internal objs */ + UINT8 WalkType; + UINT16 Opcode; /* Current AML opcode */ + UINT8 NextOpInfo; /* Info about NextOp */ + UINT8 NumOperands; /* Stack pointer for Operands[] array */ + UINT8 OperandIndex; /* Index into operand stack, to be used by AcpiDsObjStackPush */ + ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ + BOOLEAN LastPredicate; /* Result of last predicate */ + UINT8 CurrentResult; + UINT8 ReturnUsed; + UINT8 ScopeDepth; + UINT8 PassNumber; /* Parse pass during table load */ + UINT8 ResultSize; /* Total elements for the result stack */ + UINT8 ResultCount; /* Current number of occupied elements of result stack */ + UINT32 AmlOffset; + UINT32 ArgTypes; + UINT32 MethodBreakpoint; /* For single stepping */ + UINT32 UserBreakpoint; /* User AML breakpoint */ + UINT32 ParseFlags; + + ACPI_PARSE_STATE ParserState; /* Current state of parser */ + UINT32 PrevArgTypes; + UINT32 ArgCount; /* push for fixed or var args */ + + struct acpi_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ + struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ + union acpi_operand_object *Operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ + union acpi_operand_object **Params; + + UINT8 *AmlLastWhile; + union acpi_operand_object **CallerReturnDesc; + ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ + struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ + union acpi_operand_object *ImplicitReturnObj; + struct acpi_namespace_node *MethodCallNode; /* Called method Node*/ + ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ + union acpi_operand_object *MethodDesc; /* Method descriptor if running a method */ + struct acpi_namespace_node *MethodNode; /* Method node if running a method. */ + ACPI_PARSE_OBJECT *Op; /* Current parser op */ + const ACPI_OPCODE_INFO *OpInfo; /* Info on current opcode */ + ACPI_PARSE_OBJECT *Origin; /* Start of walk [Obsolete] */ + union acpi_operand_object *ResultObj; + ACPI_GENERIC_STATE *Results; /* Stack of accumulated results */ + union acpi_operand_object *ReturnDesc; /* Return object, if any */ + ACPI_GENERIC_STATE *ScopeInfo; /* Stack of nested scopes */ + ACPI_PARSE_OBJECT *PrevOp; /* Last op that was processed */ + ACPI_PARSE_OBJECT *NextOp; /* next op to be processed */ + ACPI_THREAD_STATE *Thread; + ACPI_PARSE_DOWNWARDS DescendingCallback; + ACPI_PARSE_UPWARDS AscendingCallback; + +} ACPI_WALK_STATE; + + +/* Info used by AcpiPsInitObjects */ + +typedef struct acpi_init_walk_info +{ + UINT16 MethodCount; + UINT16 DeviceCount; + UINT16 OpRegionCount; + UINT16 FieldCount; + UINT16 BufferCount; + UINT16 PackageCount; + UINT16 OpRegionInit; + UINT16 FieldInit; + UINT16 BufferInit; + UINT16 PackageInit; + UINT16 ObjectCount; + ACPI_OWNER_ID OwnerId; + UINT32 TableIndex; + +} ACPI_INIT_WALK_INFO; + + +typedef struct acpi_get_devices_info +{ + ACPI_WALK_CALLBACK UserFunction; + void *Context; + char *Hid; + +} ACPI_GET_DEVICES_INFO; + + +typedef union acpi_aml_operands +{ + ACPI_OPERAND_OBJECT *Operands[7]; + + struct + { + ACPI_OBJECT_INTEGER *Type; + ACPI_OBJECT_INTEGER *Code; + ACPI_OBJECT_INTEGER *Argument; + + } Fatal; + + struct + { + ACPI_OPERAND_OBJECT *Source; + ACPI_OBJECT_INTEGER *Index; + ACPI_OPERAND_OBJECT *Target; + + } Index; + + struct + { + ACPI_OPERAND_OBJECT *Source; + ACPI_OBJECT_INTEGER *Index; + ACPI_OBJECT_INTEGER *Length; + ACPI_OPERAND_OBJECT *Target; + + } Mid; + +} ACPI_AML_OPERANDS; + + +/* + * Structure used to pass object evaluation parameters. + * Purpose is to reduce CPU stack use. + */ +typedef struct acpi_evaluate_info +{ + ACPI_NAMESPACE_NODE *PrefixNode; + char *Pathname; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **Parameters; + ACPI_NAMESPACE_NODE *ResolvedNode; + ACPI_OPERAND_OBJECT *ReturnObject; + UINT8 ParamCount; + UINT8 PassNumber; + UINT8 ReturnObjectType; + UINT8 Flags; + +} ACPI_EVALUATE_INFO; + +/* Values for Flags above */ + +#define ACPI_IGNORE_RETURN_VALUE 1 + + +/* Info used by AcpiNsInitializeDevices */ + +typedef struct acpi_device_walk_info +{ + UINT16 DeviceCount; + UINT16 Num_STA; + UINT16 Num_INI; + ACPI_TABLE_DESC *TableDesc; + ACPI_EVALUATE_INFO *EvaluateInfo; + +} ACPI_DEVICE_WALK_INFO; + + +/* TBD: [Restructure] Merge with struct above */ + +typedef struct acpi_walk_info +{ + UINT32 DebugLevel; + UINT32 Count; + ACPI_OWNER_ID OwnerId; + UINT8 DisplayType; + +} ACPI_WALK_INFO; + +/* Display Types */ + +#define ACPI_DISPLAY_SUMMARY (UINT8) 0 +#define ACPI_DISPLAY_OBJECTS (UINT8) 1 +#define ACPI_DISPLAY_MASK (UINT8) 1 + +#define ACPI_DISPLAY_SHORT (UINT8) 2 + + +#endif diff --git a/drivers/bus/acpi/acpica/include/actables.h b/drivers/bus/acpi/acpica/include/actables.h new file mode 100644 index 00000000000..e4428e64155 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/actables.h @@ -0,0 +1,243 @@ +/****************************************************************************** + * + * Name: actables.h - ACPI table management + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTABLES_H__ +#define __ACTABLES_H__ + + +ACPI_STATUS +AcpiAllocateRootTable ( + UINT32 InitialTableCount); + +/* + * tbfadt - FADT parse/convert/validate + */ +void +AcpiTbParseFadt ( + UINT32 TableIndex); + +void +AcpiTbCreateLocalFadt ( + ACPI_TABLE_HEADER *Table, + UINT32 Length); + + +/* + * tbfind - find ACPI table + */ +ACPI_STATUS +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + UINT32 *TableIndex); + + +/* + * tbinstal - Table removal and deletion + */ +ACPI_STATUS +AcpiTbResizeRootTableList ( + void); + +ACPI_STATUS +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc); + +ACPI_STATUS +AcpiTbAddTable ( + ACPI_TABLE_DESC *TableDesc, + UINT32 *TableIndex); + +ACPI_STATUS +AcpiTbStoreTable ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Table, + UINT32 Length, + UINT8 Flags, + UINT32 *TableIndex); + +void +AcpiTbDeleteTable ( + ACPI_TABLE_DESC *TableDesc); + +void +AcpiTbTerminate ( + void); + +ACPI_STATUS +AcpiTbDeleteNamespaceByOwner ( + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbAllocateOwnerId ( + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbReleaseOwnerId ( + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbGetOwnerId ( + UINT32 TableIndex, + ACPI_OWNER_ID *OwnerId); + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex); + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded); + + +/* + * tbutils - table manager utilities + */ +ACPI_STATUS +AcpiTbInitializeFacs ( + void); + +BOOLEAN +AcpiTbTablesLoaded ( + void); + +void +AcpiTbPrintTableHeader( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Header); + +UINT8 +AcpiTbChecksum ( + UINT8 *Buffer, + UINT32 Length); + +ACPI_STATUS +AcpiTbVerifyChecksum ( + ACPI_TABLE_HEADER *Table, + UINT32 Length); + +void +AcpiTbInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + char *Signature, + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbParseRootTable ( + ACPI_PHYSICAL_ADDRESS RsdpAddress); + +#endif /* __ACTABLES_H__ */ diff --git a/drivers/bus/acpi/acpica/include/actbl.h b/drivers/bus/acpi/acpica/include/actbl.h new file mode 100644 index 00000000000..caa3bdbe3b5 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/actbl.h @@ -0,0 +1,451 @@ +/****************************************************************************** + * + * Name: actbl.h - Basic ACPI Table Definitions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL_H__ +#define __ACTBL_H__ + + +/******************************************************************************* + * + * Fundamental ACPI tables + * + * This file contains definitions for the ACPI tables that are directly consumed + * by ACPICA. All other tables are consumed by the OS-dependent ACPI-related + * device drivers and other OS support code. + * + * The RSDP and FACS do not use the common ACPI table header. All other ACPI + * tables use the header. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_DSDT "DSDT" /* Differentiated System Description Table */ +#define ACPI_SIG_FADT "FACP" /* Fixed ACPI Description Table */ +#define ACPI_SIG_FACS "FACS" /* Firmware ACPI Control Structure */ +#define ACPI_SIG_PSDT "PSDT" /* Persistent System Description Table */ +#define ACPI_SIG_RSDP "RSD PTR " /* Root System Description Pointer */ +#define ACPI_SIG_RSDT "RSDT" /* Root System Description Table */ +#define ACPI_SIG_XSDT "XSDT" /* Extended System Description Table */ +#define ACPI_SIG_SSDT "SSDT" /* Secondary System Description Table */ +#define ACPI_RSDP_NAME "RSDP" /* Short name for RSDP, not signature */ + + +/* + * All tables and structures must be byte-packed to match the ACPI + * specification, since the tables are provided by the system BIOS + */ +#pragma pack(1) + +/* + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + + +/******************************************************************************* + * + * Master ACPI Table Header. This common header is used by all ACPI tables + * except the RSDP and FACS. + * + ******************************************************************************/ + +typedef struct acpi_table_header +{ + char Signature[ACPI_NAME_SIZE]; /* ASCII table signature */ + UINT32 Length; /* Length of table in bytes, including this header */ + UINT8 Revision; /* ACPI Specification minor version # */ + UINT8 Checksum; /* To make sum of entire table == 0 */ + char OemId[ACPI_OEM_ID_SIZE]; /* ASCII OEM identification */ + char OemTableId[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */ + UINT32 OemRevision; /* OEM revision number */ + char AslCompilerId[ACPI_NAME_SIZE]; /* ASCII ASL compiler vendor ID */ + UINT32 AslCompilerRevision; /* ASL compiler version */ + +} ACPI_TABLE_HEADER; + + +/******************************************************************************* + * + * GAS - Generic Address Structure (ACPI 2.0+) + * + * Note: Since this structure is used in the ACPI tables, it is byte aligned. + * If misaliged access is not supported by the hardware, accesses to the + * 64-bit Address field must be performed with care. + * + ******************************************************************************/ + +typedef struct acpi_generic_address +{ + UINT8 SpaceId; /* Address space where struct or register exists */ + UINT8 BitWidth; /* Size in bits of given register */ + UINT8 BitOffset; /* Bit offset within the register */ + UINT8 AccessWidth; /* Minimum Access size (ACPI 3.0) */ + UINT64 Address; /* 64-bit address of struct or register */ + +} ACPI_GENERIC_ADDRESS; + + +/******************************************************************************* + * + * RSDP - Root System Description Pointer (Signature is "RSD PTR ") + * Version 2 + * + ******************************************************************************/ + +typedef struct acpi_table_rsdp +{ + char Signature[8]; /* ACPI signature, contains "RSD PTR " */ + UINT8 Checksum; /* ACPI 1.0 checksum */ + char OemId[ACPI_OEM_ID_SIZE]; /* OEM identification */ + UINT8 Revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */ + UINT32 RsdtPhysicalAddress; /* 32-bit physical address of the RSDT */ + UINT32 Length; /* Table length in bytes, including header (ACPI 2.0+) */ + UINT64 XsdtPhysicalAddress; /* 64-bit physical address of the XSDT (ACPI 2.0+) */ + UINT8 ExtendedChecksum; /* Checksum of entire table (ACPI 2.0+) */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + +} ACPI_TABLE_RSDP; + +#define ACPI_RSDP_REV0_SIZE 20 /* Size of original ACPI 1.0 RSDP */ + + +/******************************************************************************* + * + * RSDT/XSDT - Root System Description Tables + * Version 1 (both) + * + ******************************************************************************/ + +typedef struct acpi_table_rsdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + +} ACPI_TABLE_RSDT; + +typedef struct acpi_table_xsdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + +} ACPI_TABLE_XSDT; + + +/******************************************************************************* + * + * FACS - Firmware ACPI Control Structure (FACS) + * + ******************************************************************************/ + +typedef struct acpi_table_facs +{ + char Signature[4]; /* ASCII table signature */ + UINT32 Length; /* Length of structure, in bytes */ + UINT32 HardwareSignature; /* Hardware configuration signature */ + UINT32 FirmwareWakingVector; /* 32-bit physical address of the Firmware Waking Vector */ + UINT32 GlobalLock; /* Global Lock for shared hardware resources */ + UINT32 Flags; + UINT64 XFirmwareWakingVector; /* 64-bit version of the Firmware Waking Vector (ACPI 2.0+) */ + UINT8 Version; /* Version of this table (ACPI 2.0+) */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + UINT32 OspmFlags; /* Flags to be set by OSPM (ACPI 4.0) */ + UINT8 Reserved1[24]; /* Reserved, must be zero */ + +} ACPI_TABLE_FACS; + +/* Masks for GlobalLock flag field above */ + +#define ACPI_GLOCK_PENDING (1) /* 00: Pending global lock ownership */ +#define ACPI_GLOCK_OWNED (1<<1) /* 01: Global lock is owned */ + +/* Masks for Flags field above */ + +#define ACPI_FACS_S4_BIOS_PRESENT (1) /* 00: S4BIOS support is present */ +#define ACPI_FACS_64BIT_WAKE (1<<1) /* 01: 64-bit wake vector supported (ACPI 4.0) */ + +/* Masks for OspmFlags field above */ + +#define ACPI_FACS_64BIT_ENVIRONMENT (1) /* 00: 64-bit wake environment is required (ACPI 4.0) */ + + +/******************************************************************************* + * + * FADT - Fixed ACPI Description Table (Signature "FACP") + * Version 4 + * + ******************************************************************************/ + +/* Fields common to all versions of the FADT */ + +typedef struct acpi_table_fadt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Facs; /* 32-bit physical address of FACS */ + UINT32 Dsdt; /* 32-bit physical address of DSDT */ + UINT8 Model; /* System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ + UINT8 PreferredProfile; /* Conveys preferred power management profile to OSPM. */ + UINT16 SciInterrupt; /* System vector of SCI interrupt */ + UINT32 SmiCommand; /* 32-bit Port address of SMI command port */ + UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */ + UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */ + UINT8 S4BiosRequest; /* Value to write to SMI CMD to enter S4BIOS state */ + UINT8 PstateControl; /* Processor performance state control*/ + UINT32 Pm1aEventBlock; /* 32-bit Port address of Power Mgt 1a Event Reg Blk */ + UINT32 Pm1bEventBlock; /* 32-bit Port address of Power Mgt 1b Event Reg Blk */ + UINT32 Pm1aControlBlock; /* 32-bit Port address of Power Mgt 1a Control Reg Blk */ + UINT32 Pm1bControlBlock; /* 32-bit Port address of Power Mgt 1b Control Reg Blk */ + UINT32 Pm2ControlBlock; /* 32-bit Port address of Power Mgt 2 Control Reg Blk */ + UINT32 PmTimerBlock; /* 32-bit Port address of Power Mgt Timer Ctrl Reg Blk */ + UINT32 Gpe0Block; /* 32-bit Port address of General Purpose Event 0 Reg Blk */ + UINT32 Gpe1Block; /* 32-bit Port address of General Purpose Event 1 Reg Blk */ + UINT8 Pm1EventLength; /* Byte Length of ports at Pm1xEventBlock */ + UINT8 Pm1ControlLength; /* Byte Length of ports at Pm1xControlBlock */ + UINT8 Pm2ControlLength; /* Byte Length of ports at Pm2ControlBlock */ + UINT8 PmTimerLength; /* Byte Length of ports at PmTimerBlock */ + UINT8 Gpe0BlockLength; /* Byte Length of ports at Gpe0Block */ + UINT8 Gpe1BlockLength; /* Byte Length of ports at Gpe1Block */ + UINT8 Gpe1Base; /* Offset in GPE number space where GPE1 events start */ + UINT8 CstControl; /* Support for the _CST object and C States change notification */ + UINT16 C2Latency; /* Worst case HW latency to enter/exit C2 state */ + UINT16 C3Latency; /* Worst case HW latency to enter/exit C3 state */ + UINT16 FlushSize; /* Processor's memory cache line width, in bytes */ + UINT16 FlushStride; /* Number of flush strides that need to be read */ + UINT8 DutyOffset; /* Processor duty cycle index in processor's P_CNT reg */ + UINT8 DutyWidth; /* Processor duty cycle value bit width in P_CNT register */ + UINT8 DayAlarm; /* Index to day-of-month alarm in RTC CMOS RAM */ + UINT8 MonthAlarm; /* Index to month-of-year alarm in RTC CMOS RAM */ + UINT8 Century; /* Index to century in RTC CMOS RAM */ + UINT16 BootFlags; /* IA-PC Boot Architecture Flags (see below for individual flags) */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ + ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ + UINT8 Reserved4[3]; /* Reserved, must be zero */ + UINT64 XFacs; /* 64-bit physical address of FACS */ + UINT64 XDsdt; /* 64-bit physical address of DSDT */ + ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPmTimerBlock; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe0Block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe1Block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */ + +} ACPI_TABLE_FADT; + + +/* Masks for FADT Boot Architecture Flags (BootFlags) */ + +#define ACPI_FADT_LEGACY_DEVICES (1) /* 00: [V2] System has LPC or ISA bus devices */ +#define ACPI_FADT_8042 (1<<1) /* 01: [V3] System has an 8042 controller on port 60/64 */ +#define ACPI_FADT_NO_VGA (1<<2) /* 02: [V4] It is not safe to probe for VGA hardware */ +#define ACPI_FADT_NO_MSI (1<<3) /* 03: [V4] Message Signaled Interrupts (MSI) must not be enabled */ +#define ACPI_FADT_NO_ASPM (1<<4) /* 04: [V4] PCIe ASPM control must not be enabled */ + +/* Masks for FADT flags */ + +#define ACPI_FADT_WBINVD (1) /* 00: [V1] The wbinvd instruction works properly */ +#define ACPI_FADT_WBINVD_FLUSH (1<<1) /* 01: [V1] wbinvd flushes but does not invalidate caches */ +#define ACPI_FADT_C1_SUPPORTED (1<<2) /* 02: [V1] All processors support C1 state */ +#define ACPI_FADT_C2_MP_SUPPORTED (1<<3) /* 03: [V1] C2 state works on MP system */ +#define ACPI_FADT_POWER_BUTTON (1<<4) /* 04: [V1] Power button is handled as a control method device */ +#define ACPI_FADT_SLEEP_BUTTON (1<<5) /* 05: [V1] Sleep button is handled as a control method device */ +#define ACPI_FADT_FIXED_RTC (1<<6) /* 06: [V1] RTC wakeup status not in fixed register space */ +#define ACPI_FADT_S4_RTC_WAKE (1<<7) /* 07: [V1] RTC alarm can wake system from S4 */ +#define ACPI_FADT_32BIT_TIMER (1<<8) /* 08: [V1] ACPI timer width is 32-bit (0=24-bit) */ +#define ACPI_FADT_DOCKING_SUPPORTED (1<<9) /* 09: [V1] Docking supported */ +#define ACPI_FADT_RESET_REGISTER (1<<10) /* 10: [V2] System reset via the FADT RESET_REG supported */ +#define ACPI_FADT_SEALED_CASE (1<<11) /* 11: [V3] No internal expansion capabilities and case is sealed */ +#define ACPI_FADT_HEADLESS (1<<12) /* 12: [V3] No local video capabilities or local input devices */ +#define ACPI_FADT_SLEEP_TYPE (1<<13) /* 13: [V3] Must execute native instruction after writing SLP_TYPx register */ +#define ACPI_FADT_PCI_EXPRESS_WAKE (1<<14) /* 14: [V4] System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ +#define ACPI_FADT_PLATFORM_CLOCK (1<<15) /* 15: [V4] OSPM should use platform-provided timer (ACPI 3.0) */ +#define ACPI_FADT_S4_RTC_VALID (1<<16) /* 16: [V4] Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ +#define ACPI_FADT_REMOTE_POWER_ON (1<<17) /* 17: [V4] System is compatible with remote power on (ACPI 3.0) */ +#define ACPI_FADT_APIC_CLUSTER (1<<18) /* 18: [V4] All local APICs must use cluster model (ACPI 3.0) */ +#define ACPI_FADT_APIC_PHYSICAL (1<<19) /* 19: [V4] All local xAPICs must use physical dest mode (ACPI 3.0) */ + + +/* Values for PreferredProfile (Prefered Power Management Profiles) */ + +enum AcpiPreferedPmProfiles +{ + PM_UNSPECIFIED = 0, + PM_DESKTOP = 1, + PM_MOBILE = 2, + PM_WORKSTATION = 3, + PM_ENTERPRISE_SERVER = 4, + PM_SOHO_SERVER = 5, + PM_APPLIANCE_PC = 6 +}; + + +/* Reset to default packing */ + +#pragma pack() + + +/* + * Internal table-related structures + */ +typedef union acpi_name_union +{ + UINT32 Integer; + char Ascii[4]; + +} ACPI_NAME_UNION; + + +/* Internal ACPI Table Descriptor. One per ACPI table. */ + +typedef struct acpi_table_desc +{ + ACPI_PHYSICAL_ADDRESS Address; + ACPI_TABLE_HEADER *Pointer; + UINT32 Length; /* Length fixed at 32 bits */ + ACPI_NAME_UNION Signature; + ACPI_OWNER_ID OwnerId; + UINT8 Flags; + +} ACPI_TABLE_DESC; + +/* Masks for Flags field above */ + +#define ACPI_TABLE_ORIGIN_UNKNOWN (0) +#define ACPI_TABLE_ORIGIN_MAPPED (1) +#define ACPI_TABLE_ORIGIN_ALLOCATED (2) +#define ACPI_TABLE_ORIGIN_OVERRIDE (4) +#define ACPI_TABLE_ORIGIN_MASK (7) +#define ACPI_TABLE_IS_LOADED (8) + + +/* + * Get the remaining ACPI tables + */ +#include "actbl1.h" +#include "actbl2.h" + +/* Macros used to generate offsets to specific table fields */ + +#define ACPI_FADT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_FADT, f) + +#endif /* __ACTBL_H__ */ diff --git a/drivers/bus/acpi/acpica/include/actbl1.h b/drivers/bus/acpi/acpica/include/actbl1.h new file mode 100644 index 00000000000..8af7a183808 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/actbl1.h @@ -0,0 +1,1145 @@ +/****************************************************************************** + * + * Name: actbl1.h - Additional ACPI table definitions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL1_H__ +#define __ACTBL1_H__ + + +/******************************************************************************* + * + * Additional ACPI Tables (1) + * + * These tables are not consumed directly by the ACPICA subsystem, but are + * included here to support device drivers and the AML disassembler. + * + * The tables in this file are fully defined within the ACPI specification. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */ +#define ACPI_SIG_CPEP "CPEP" /* Corrected Platform Error Polling table */ +#define ACPI_SIG_ECDT "ECDT" /* Embedded Controller Boot Resources Table */ +#define ACPI_SIG_EINJ "EINJ" /* Error Injection table */ +#define ACPI_SIG_ERST "ERST" /* Error Record Serialization Table */ +#define ACPI_SIG_HEST "HEST" /* Hardware Error Source Table */ +#define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */ +#define ACPI_SIG_MSCT "MSCT" /* Maximum System Characteristics Table */ +#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */ +#define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */ +#define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */ + + +/* + * All tables must be byte-packed to match the ACPI specification, since + * the tables are provided by the system BIOS. + */ +#pragma pack(1) + +/* + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + + +/******************************************************************************* + * + * Common subtable headers + * + ******************************************************************************/ + +/* Generic subtable header (used in MADT, SRAT, etc.) */ + +typedef struct acpi_subtable_header +{ + UINT8 Type; + UINT8 Length; + +} ACPI_SUBTABLE_HEADER; + + +/* Subtable header for WHEA tables (EINJ, ERST, WDAT) */ + +typedef struct acpi_whea_header +{ + UINT8 Action; + UINT8 Instruction; + UINT8 Flags; + UINT8 Reserved; + ACPI_GENERIC_ADDRESS RegisterRegion; + UINT64 Value; /* Value used with Read/Write register */ + UINT64 Mask; /* Bitmask required for this register instruction */ + +} ACPI_WHEA_HEADER; + + +/******************************************************************************* + * + * BERT - Boot Error Record Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_bert +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 RegionLength; /* Length of the boot error region */ + UINT64 Address; /* Physical addresss of the error region */ + +} ACPI_TABLE_BERT; + + +/* Boot Error Region (not a subtable, pointed to by Address field above) */ + +typedef struct acpi_bert_region +{ + UINT32 BlockStatus; /* Type of error information */ + UINT32 RawDataOffset; /* Offset to raw error data */ + UINT32 RawDataLength; /* Length of raw error data */ + UINT32 DataLength; /* Length of generic error data */ + UINT32 ErrorSeverity; /* Severity code */ + +} ACPI_BERT_REGION; + +/* Values for BlockStatus flags above */ + +#define ACPI_BERT_UNCORRECTABLE (1) +#define ACPI_BERT_CORRECTABLE (1<<1) +#define ACPI_BERT_MULTIPLE_UNCORRECTABLE (1<<2) +#define ACPI_BERT_MULTIPLE_CORRECTABLE (1<<3) +#define ACPI_BERT_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ + +/* Values for ErrorSeverity above */ + +enum AcpiBertErrorSeverity +{ + ACPI_BERT_ERROR_CORRECTABLE = 0, + ACPI_BERT_ERROR_FATAL = 1, + ACPI_BERT_ERROR_CORRECTED = 2, + ACPI_BERT_ERROR_NONE = 3, + ACPI_BERT_ERROR_RESERVED = 4 /* 4 and greater are reserved */ +}; + +/* + * Note: The generic error data that follows the ErrorSeverity field above + * uses the ACPI_HEST_GENERIC_DATA defined under the HEST table below + */ + + +/******************************************************************************* + * + * CPEP - Corrected Platform Error Polling table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_cpep +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 Reserved; + +} ACPI_TABLE_CPEP; + + +/* Subtable */ + +typedef struct acpi_cpep_polling +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* Processor ID */ + UINT8 Eid; /* Processor EID */ + UINT32 Interval; /* Polling interval (msec) */ + +} ACPI_CPEP_POLLING; + + +/******************************************************************************* + * + * ECDT - Embedded Controller Boot Resources Table + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_ecdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + ACPI_GENERIC_ADDRESS Control; /* Address of EC command/status register */ + ACPI_GENERIC_ADDRESS Data; /* Address of EC data register */ + UINT32 Uid; /* Unique ID - must be same as the EC _UID method */ + UINT8 Gpe; /* The GPE for the EC */ + UINT8 Id[1]; /* Full namepath of the EC in the ACPI namespace */ + +} ACPI_TABLE_ECDT; + + +/******************************************************************************* + * + * EINJ - Error Injection Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_einj +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; + UINT8 Flags; + UINT8 Reserved[3]; + UINT32 Entries; + +} ACPI_TABLE_EINJ; + + +/* EINJ Injection Instruction Entries (actions) */ + +typedef struct acpi_einj_entry +{ + ACPI_WHEA_HEADER WheaHeader; /* Common header for WHEA tables */ + +} ACPI_EINJ_ENTRY; + +/* Masks for Flags field above */ + +#define ACPI_EINJ_PRESERVE (1) + +/* Values for Action field above */ + +enum AcpiEinjActions +{ + ACPI_EINJ_BEGIN_OPERATION = 0, + ACPI_EINJ_GET_TRIGGER_TABLE = 1, + ACPI_EINJ_SET_ERROR_TYPE = 2, + ACPI_EINJ_GET_ERROR_TYPE = 3, + ACPI_EINJ_END_OPERATION = 4, + ACPI_EINJ_EXECUTE_OPERATION = 5, + ACPI_EINJ_CHECK_BUSY_STATUS = 6, + ACPI_EINJ_GET_COMMAND_STATUS = 7, + ACPI_EINJ_ACTION_RESERVED = 8, /* 8 and greater are reserved */ + ACPI_EINJ_TRIGGER_ERROR = 0xFF /* Except for this value */ +}; + +/* Values for Instruction field above */ + +enum AcpiEinjInstructions +{ + ACPI_EINJ_READ_REGISTER = 0, + ACPI_EINJ_READ_REGISTER_VALUE = 1, + ACPI_EINJ_WRITE_REGISTER = 2, + ACPI_EINJ_WRITE_REGISTER_VALUE = 3, + ACPI_EINJ_NOOP = 4, + ACPI_EINJ_INSTRUCTION_RESERVED = 5 /* 5 and greater are reserved */ +}; + + +/* EINJ Trigger Error Action Table */ + +typedef struct acpi_einj_trigger +{ + UINT32 HeaderSize; + UINT32 Revision; + UINT32 TableSize; + UINT32 EntryCount; + +} ACPI_EINJ_TRIGGER; + +/* Command status return values */ + +enum AcpiEinjCommandStatus +{ + ACPI_EINJ_SUCCESS = 0, + ACPI_EINJ_FAILURE = 1, + ACPI_EINJ_INVALID_ACCESS = 2, + ACPI_EINJ_STATUS_RESERVED = 3 /* 3 and greater are reserved */ +}; + + +/* Error types returned from ACPI_EINJ_GET_ERROR_TYPE (bitfield) */ + +#define ACPI_EINJ_PROCESSOR_CORRECTABLE (1) +#define ACPI_EINJ_PROCESSOR_UNCORRECTABLE (1<<1) +#define ACPI_EINJ_PROCESSOR_FATAL (1<<2) +#define ACPI_EINJ_MEMORY_CORRECTABLE (1<<3) +#define ACPI_EINJ_MEMORY_UNCORRECTABLE (1<<4) +#define ACPI_EINJ_MEMORY_FATAL (1<<5) +#define ACPI_EINJ_PCIX_CORRECTABLE (1<<6) +#define ACPI_EINJ_PCIX_UNCORRECTABLE (1<<7) +#define ACPI_EINJ_PCIX_FATAL (1<<8) +#define ACPI_EINJ_PLATFORM_CORRECTABLE (1<<9) +#define ACPI_EINJ_PLATFORM_UNCORRECTABLE (1<<10) +#define ACPI_EINJ_PLATFORM_FATAL (1<<11) + + +/******************************************************************************* + * + * ERST - Error Record Serialization Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_erst +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; + UINT32 Reserved; + UINT32 Entries; + +} ACPI_TABLE_ERST; + + +/* ERST Serialization Entries (actions) */ + +typedef struct acpi_erst_entry +{ + ACPI_WHEA_HEADER WheaHeader; /* Common header for WHEA tables */ + +} ACPI_ERST_ENTRY; + +/* Masks for Flags field above */ + +#define ACPI_ERST_PRESERVE (1) + +/* Values for Action field above */ + +enum AcpiErstActions +{ + ACPI_ERST_BEGIN_WRITE = 0, + ACPI_ERST_BEGIN_READ = 1, + ACPI_ERST_BEGIN_CLEAR = 2, + ACPI_ERST_END = 3, + ACPI_ERST_SET_RECORD_OFFSET = 4, + ACPI_ERST_EXECUTE_OPERATION = 5, + ACPI_ERST_CHECK_BUSY_STATUS = 6, + ACPI_ERST_GET_COMMAND_STATUS = 7, + ACPI_ERST_GET_RECORD_ID = 8, + ACPI_ERST_SET_RECORD_ID = 9, + ACPI_ERST_GET_RECORD_COUNT = 10, + ACPI_ERST_BEGIN_DUMMY_WRIITE = 11, + ACPI_ERST_NOT_USED = 12, + ACPI_ERST_GET_ERROR_RANGE = 13, + ACPI_ERST_GET_ERROR_LENGTH = 14, + ACPI_ERST_GET_ERROR_ATTRIBUTES = 15, + ACPI_ERST_ACTION_RESERVED = 16 /* 16 and greater are reserved */ +}; + +/* Values for Instruction field above */ + +enum AcpiErstInstructions +{ + ACPI_ERST_READ_REGISTER = 0, + ACPI_ERST_READ_REGISTER_VALUE = 1, + ACPI_ERST_WRITE_REGISTER = 2, + ACPI_ERST_WRITE_REGISTER_VALUE = 3, + ACPI_ERST_NOOP = 4, + ACPI_ERST_LOAD_VAR1 = 5, + ACPI_ERST_LOAD_VAR2 = 6, + ACPI_ERST_STORE_VAR1 = 7, + ACPI_ERST_ADD = 8, + ACPI_ERST_SUBTRACT = 9, + ACPI_ERST_ADD_VALUE = 10, + ACPI_ERST_SUBTRACT_VALUE = 11, + ACPI_ERST_STALL = 12, + ACPI_ERST_STALL_WHILE_TRUE = 13, + ACPI_ERST_SKIP_NEXT_IF_TRUE = 14, + ACPI_ERST_GOTO = 15, + ACPI_ERST_SET_SRC_ADDRESS_BASE = 16, + ACPI_ERST_SET_DST_ADDRESS_BASE = 17, + ACPI_ERST_MOVE_DATA = 18, + ACPI_ERST_INSTRUCTION_RESERVED = 19 /* 19 and greater are reserved */ +}; + +/* Command status return values */ + +enum AcpiErstCommandStatus +{ + ACPI_ERST_SUCESS = 0, + ACPI_ERST_NO_SPACE = 1, + ACPI_ERST_NOT_AVAILABLE = 2, + ACPI_ERST_FAILURE = 3, + ACPI_ERST_RECORD_EMPTY = 4, + ACPI_ERST_NOT_FOUND = 5, + ACPI_ERST_STATUS_RESERVED = 6 /* 6 and greater are reserved */ +}; + + +/* Error Record Serialization Information */ + +typedef struct acpi_erst_info +{ + UINT16 Signature; /* Should be "ER" */ + UINT8 Data[48]; + +} ACPI_ERST_INFO; + + +/******************************************************************************* + * + * HEST - Hardware Error Source Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_hest +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 ErrorSourceCount; + +} ACPI_TABLE_HEST; + + +/* HEST subtable header */ + +typedef struct acpi_hest_header +{ + UINT16 Type; + UINT16 SourceId; + +} ACPI_HEST_HEADER; + + +/* Values for Type field above for subtables */ + +enum AcpiHestTypes +{ + ACPI_HEST_TYPE_IA32_CHECK = 0, + ACPI_HEST_TYPE_IA32_CORRECTED_CHECK = 1, + ACPI_HEST_TYPE_IA32_NMI = 2, + ACPI_HEST_TYPE_NOT_USED3 = 3, + ACPI_HEST_TYPE_NOT_USED4 = 4, + ACPI_HEST_TYPE_NOT_USED5 = 5, + ACPI_HEST_TYPE_AER_ROOT_PORT = 6, + ACPI_HEST_TYPE_AER_ENDPOINT = 7, + ACPI_HEST_TYPE_AER_BRIDGE = 8, + ACPI_HEST_TYPE_GENERIC_ERROR = 9, + ACPI_HEST_TYPE_RESERVED = 10 /* 10 and greater are reserved */ +}; + + +/* + * HEST substructures contained in subtables + */ + +/* + * IA32 Error Bank(s) - Follows the ACPI_HEST_IA_MACHINE_CHECK and + * ACPI_HEST_IA_CORRECTED structures. + */ +typedef struct acpi_hest_ia_error_bank +{ + UINT8 BankNumber; + UINT8 ClearStatusOnInit; + UINT8 StatusFormat; + UINT8 Reserved; + UINT32 ControlRegister; + UINT64 ControlData; + UINT32 StatusRegister; + UINT32 AddressRegister; + UINT32 MiscRegister; + +} ACPI_HEST_IA_ERROR_BANK; + + +/* Common HEST sub-structure for PCI/AER structures below (6,7,8) */ + +typedef struct acpi_hest_aer_common +{ + UINT16 Reserved1; + UINT8 Flags; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 Bus; + UINT16 Device; + UINT16 Function; + UINT16 DeviceControl; + UINT16 Reserved2; + UINT32 UncorrectableMask; + UINT32 UncorrectableSeverity; + UINT32 CorrectableMask; + UINT32 AdvancedCapabilities; + +} ACPI_HEST_AER_COMMON; + +/* Masks for HEST Flags fields */ + +#define ACPI_HEST_FIRMWARE_FIRST (1) +#define ACPI_HEST_GLOBAL (1<<1) + + +/* Hardware Error Notification */ + +typedef struct acpi_hest_notify +{ + UINT8 Type; + UINT8 Length; + UINT16 ConfigWriteEnable; + UINT32 PollInterval; + UINT32 Vector; + UINT32 PollingThresholdValue; + UINT32 PollingThresholdWindow; + UINT32 ErrorThresholdValue; + UINT32 ErrorThresholdWindow; + +} ACPI_HEST_NOTIFY; + +/* Values for Notify Type field above */ + +enum AcpiHestNotifyTypes +{ + ACPI_HEST_NOTIFY_POLLED = 0, + ACPI_HEST_NOTIFY_EXTERNAL = 1, + ACPI_HEST_NOTIFY_LOCAL = 2, + ACPI_HEST_NOTIFY_SCI = 3, + ACPI_HEST_NOTIFY_NMI = 4, + ACPI_HEST_NOTIFY_RESERVED = 5 /* 5 and greater are reserved */ +}; + +/* Values for ConfigWriteEnable bitfield above */ + +#define ACPI_HEST_TYPE (1) +#define ACPI_HEST_POLL_INTERVAL (1<<1) +#define ACPI_HEST_POLL_THRESHOLD_VALUE (1<<2) +#define ACPI_HEST_POLL_THRESHOLD_WINDOW (1<<3) +#define ACPI_HEST_ERR_THRESHOLD_VALUE (1<<4) +#define ACPI_HEST_ERR_THRESHOLD_WINDOW (1<<5) + + +/* + * HEST subtables + */ + +/* 0: IA32 Machine Check Exception */ + +typedef struct acpi_hest_ia_machine_check +{ + ACPI_HEST_HEADER Header; + UINT16 Reserved1; + UINT8 Flags; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT64 GlobalCapabilityData; + UINT64 GlobalControlData; + UINT8 NumHardwareBanks; + UINT8 Reserved3[7]; + +} ACPI_HEST_IA_MACHINE_CHECK; + + +/* 1: IA32 Corrected Machine Check */ + +typedef struct acpi_hest_ia_corrected +{ + ACPI_HEST_HEADER Header; + UINT16 Reserved1; + UINT8 Flags; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + ACPI_HEST_NOTIFY Notify; + UINT8 NumHardwareBanks; + UINT8 Reserved2[3]; + +} ACPI_HEST_IA_CORRECTED; + + +/* 2: IA32 Non-Maskable Interrupt */ + +typedef struct acpi_hest_ia_nmi +{ + ACPI_HEST_HEADER Header; + UINT32 Reserved; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 MaxRawDataLength; + +} ACPI_HEST_IA_NMI; + + +/* 3,4,5: Not used */ + +/* 6: PCI Express Root Port AER */ + +typedef struct acpi_hest_aer_root +{ + ACPI_HEST_HEADER Header; + ACPI_HEST_AER_COMMON Aer; + UINT32 RootErrorCommand; + +} ACPI_HEST_AER_ROOT; + + +/* 7: PCI Express AER (AER Endpoint) */ + +typedef struct acpi_hest_aer +{ + ACPI_HEST_HEADER Header; + ACPI_HEST_AER_COMMON Aer; + +} ACPI_HEST_AER; + + +/* 8: PCI Express/PCI-X Bridge AER */ + +typedef struct acpi_hest_aer_bridge +{ + ACPI_HEST_HEADER Header; + ACPI_HEST_AER_COMMON Aer; + UINT32 UncorrectableMask2; + UINT32 UncorrectableSeverity2; + UINT32 AdvancedCapabilities2; + +} ACPI_HEST_AER_BRIDGE; + + +/* 9: Generic Hardware Error Source */ + +typedef struct acpi_hest_generic +{ + ACPI_HEST_HEADER Header; + UINT16 RelatedSourceId; + UINT8 Reserved; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 MaxRawDataLength; + ACPI_GENERIC_ADDRESS ErrorStatusAddress; + ACPI_HEST_NOTIFY Notify; + UINT32 ErrorBlockLength; + +} ACPI_HEST_GENERIC; + + +/* Generic Error Status block */ + +typedef struct acpi_hest_generic_status +{ + UINT32 BlockStatus; + UINT32 RawDataOffset; + UINT32 RawDataLength; + UINT32 DataLength; + UINT32 ErrorSeverity; + +} ACPI_HEST_GENERIC_STATUS; + +/* Values for BlockStatus flags above */ + +#define ACPI_HEST_UNCORRECTABLE (1) +#define ACPI_HEST_CORRECTABLE (1<<1) +#define ACPI_HEST_MULTIPLE_UNCORRECTABLE (1<<2) +#define ACPI_HEST_MULTIPLE_CORRECTABLE (1<<3) +#define ACPI_HEST_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ + + +/* Generic Error Data entry */ + +typedef struct acpi_hest_generic_data +{ + UINT8 SectionType[16]; + UINT32 ErrorSeverity; + UINT16 Revision; + UINT8 ValidationBits; + UINT8 Flags; + UINT32 ErrorDataLength; + UINT8 FruId[16]; + UINT8 FruText[20]; + +} ACPI_HEST_GENERIC_DATA; + + +/******************************************************************************* + * + * MADT - Multiple APIC Description Table + * Version 3 + * + ******************************************************************************/ + +typedef struct acpi_table_madt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Address; /* Physical address of local APIC */ + UINT32 Flags; + +} ACPI_TABLE_MADT; + +/* Masks for Flags field above */ + +#define ACPI_MADT_PCAT_COMPAT (1) /* 00: System also has dual 8259s */ + +/* Values for PCATCompat flag */ + +#define ACPI_MADT_DUAL_PIC 0 +#define ACPI_MADT_MULTIPLE_APIC 1 + + +/* Values for MADT subtable type in ACPI_SUBTABLE_HEADER */ + +enum AcpiMadtType +{ + ACPI_MADT_TYPE_LOCAL_APIC = 0, + ACPI_MADT_TYPE_IO_APIC = 1, + ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, + ACPI_MADT_TYPE_NMI_SOURCE = 3, + ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, + ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, + ACPI_MADT_TYPE_IO_SAPIC = 6, + ACPI_MADT_TYPE_LOCAL_SAPIC = 7, + ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, + ACPI_MADT_TYPE_LOCAL_X2APIC = 9, + ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, + ACPI_MADT_TYPE_RESERVED = 11 /* 11 and greater are reserved */ +}; + + +/* + * MADT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + */ + +/* 0: Processor Local APIC */ + +typedef struct acpi_madt_local_apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT8 Id; /* Processor's local APIC id */ + UINT32 LapicFlags; + +} ACPI_MADT_LOCAL_APIC; + + +/* 1: IO APIC */ + +typedef struct acpi_madt_io_apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* I/O APIC ID */ + UINT8 Reserved; /* Reserved - must be zero */ + UINT32 Address; /* APIC physical address */ + UINT32 GlobalIrqBase; /* Global system interrupt where INTI lines start */ + +} ACPI_MADT_IO_APIC; + + +/* 2: Interrupt Override */ + +typedef struct acpi_madt_interrupt_override +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Bus; /* 0 - ISA */ + UINT8 SourceIrq; /* Interrupt source (IRQ) */ + UINT32 GlobalIrq; /* Global system interrupt */ + UINT16 IntiFlags; + +} ACPI_MADT_INTERRUPT_OVERRIDE; + + +/* 3: NMI Source */ + +typedef struct acpi_madt_nmi_source +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT32 GlobalIrq; /* Global system interrupt */ + +} ACPI_MADT_NMI_SOURCE; + + +/* 4: Local APIC NMI */ + +typedef struct acpi_madt_local_apic_nmi +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT16 IntiFlags; + UINT8 Lint; /* LINTn to which NMI is connected */ + +} ACPI_MADT_LOCAL_APIC_NMI; + + +/* 5: Address Override */ + +typedef struct acpi_madt_local_apic_override +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved, must be zero */ + UINT64 Address; /* APIC physical address */ + +} ACPI_MADT_LOCAL_APIC_OVERRIDE; + + +/* 6: I/O Sapic */ + +typedef struct acpi_madt_io_sapic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* I/O SAPIC ID */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 GlobalIrqBase; /* Global interrupt for SAPIC start */ + UINT64 Address; /* SAPIC physical address */ + +} ACPI_MADT_IO_SAPIC; + + +/* 7: Local Sapic */ + +typedef struct acpi_madt_local_sapic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT8 Id; /* SAPIC ID */ + UINT8 Eid; /* SAPIC EID */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + UINT32 LapicFlags; + UINT32 Uid; /* Numeric UID - ACPI 3.0 */ + char UidString[1]; /* String UID - ACPI 3.0 */ + +} ACPI_MADT_LOCAL_SAPIC; + + +/* 8: Platform Interrupt Source */ + +typedef struct acpi_madt_interrupt_source +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT8 Type; /* 1=PMI, 2=INIT, 3=corrected */ + UINT8 Id; /* Processor ID */ + UINT8 Eid; /* Processor EID */ + UINT8 IoSapicVector; /* Vector value for PMI interrupts */ + UINT32 GlobalIrq; /* Global system interrupt */ + UINT32 Flags; /* Interrupt Source Flags */ + +} ACPI_MADT_INTERRUPT_SOURCE; + +/* Masks for Flags field above */ + +#define ACPI_MADT_CPEI_OVERRIDE (1) + + +/* 9: Processor Local X2APIC (ACPI 4.0) */ + +typedef struct acpi_madt_local_x2apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved - must be zero */ + UINT32 LocalApicId; /* Processor x2APIC ID */ + UINT32 LapicFlags; + UINT32 Uid; /* ACPI processor UID */ + +} ACPI_MADT_LOCAL_X2APIC; + + +/* 10: Local X2APIC NMI (ACPI 4.0) */ + +typedef struct acpi_madt_local_x2apic_nmi +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT32 Uid; /* ACPI processor UID */ + UINT8 Lint; /* LINTn to which NMI is connected */ + UINT8 Reserved[3]; /* Reserved - must be zero */ + +} ACPI_MADT_LOCAL_X2APIC_NMI; + + +/* + * Common flags fields for MADT subtables + */ + +/* MADT Local APIC flags (LapicFlags) */ + +#define ACPI_MADT_ENABLED (1) /* 00: Processor is usable if set */ + +/* MADT MPS INTI flags (IntiFlags) */ + +#define ACPI_MADT_POLARITY_MASK (3) /* 00-01: Polarity of APIC I/O input signals */ +#define ACPI_MADT_TRIGGER_MASK (3<<2) /* 02-03: Trigger mode of APIC input signals */ + +/* Values for MPS INTI flags */ + +#define ACPI_MADT_POLARITY_CONFORMS 0 +#define ACPI_MADT_POLARITY_ACTIVE_HIGH 1 +#define ACPI_MADT_POLARITY_RESERVED 2 +#define ACPI_MADT_POLARITY_ACTIVE_LOW 3 + +#define ACPI_MADT_TRIGGER_CONFORMS (0) +#define ACPI_MADT_TRIGGER_EDGE (1<<2) +#define ACPI_MADT_TRIGGER_RESERVED (2<<2) +#define ACPI_MADT_TRIGGER_LEVEL (3<<2) + + +/******************************************************************************* + * + * MSCT - Maximum System Characteristics Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_msct +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 ProximityOffset; /* Location of proximity info struct(s) */ + UINT32 MaxProximityDomains;/* Max number of proximity domains */ + UINT32 MaxClockDomains; /* Max number of clock domains */ + UINT64 MaxAddress; /* Max physical address in system */ + +} ACPI_TABLE_MSCT; + + +/* Subtable - Maximum Proximity Domain Information. Version 1 */ + +typedef struct acpi_msct_proximity +{ + UINT8 Revision; + UINT8 Length; + UINT32 RangeStart; /* Start of domain range */ + UINT32 RangeEnd; /* End of domain range */ + UINT32 ProcessorCapacity; + UINT64 MemoryCapacity; /* In bytes */ + +} ACPI_MSCT_PROXIMITY; + + +/******************************************************************************* + * + * SBST - Smart Battery Specification Table + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_sbst +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 WarningLevel; + UINT32 LowLevel; + UINT32 CriticalLevel; + +} ACPI_TABLE_SBST; + + +/******************************************************************************* + * + * SLIT - System Locality Distance Information Table + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_slit +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 LocalityCount; + UINT8 Entry[1]; /* Real size = localities^2 */ + +} ACPI_TABLE_SLIT; + + +/******************************************************************************* + * + * SRAT - System Resource Affinity Table + * Version 3 + * + ******************************************************************************/ + +typedef struct acpi_table_srat +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 TableRevision; /* Must be value '1' */ + UINT64 Reserved; /* Reserved, must be zero */ + +} ACPI_TABLE_SRAT; + +/* Values for subtable type in ACPI_SUBTABLE_HEADER */ + +enum AcpiSratType +{ + ACPI_SRAT_TYPE_CPU_AFFINITY = 0, + ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, + ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY = 2, + ACPI_SRAT_TYPE_RESERVED = 3 /* 3 and greater are reserved */ +}; + +/* + * SRAT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + */ + +/* 0: Processor Local APIC/SAPIC Affinity */ + +typedef struct acpi_srat_cpu_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProximityDomainLo; + UINT8 ApicId; + UINT32 Flags; + UINT8 LocalSapicEid; + UINT8 ProximityDomainHi[3]; + UINT32 Reserved; /* Reserved, must be zero */ + +} ACPI_SRAT_CPU_AFFINITY; + +/* Flags */ + +#define ACPI_SRAT_CPU_USE_AFFINITY (1) /* 00: Use affinity structure */ + + +/* 1: Memory Affinity */ + +typedef struct acpi_srat_mem_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 ProximityDomain; + UINT16 Reserved; /* Reserved, must be zero */ + UINT64 BaseAddress; + UINT64 Length; + UINT32 Reserved1; + UINT32 Flags; + UINT64 Reserved2; /* Reserved, must be zero */ + +} ACPI_SRAT_MEM_AFFINITY; + +/* Flags */ + +#define ACPI_SRAT_MEM_ENABLED (1) /* 00: Use affinity structure */ +#define ACPI_SRAT_MEM_HOT_PLUGGABLE (1<<1) /* 01: Memory region is hot pluggable */ +#define ACPI_SRAT_MEM_NON_VOLATILE (1<<2) /* 02: Memory region is non-volatile */ + + +/* 2: Processor Local X2_APIC Affinity (ACPI 4.0) */ + +typedef struct acpi_srat_x2apic_cpu_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved, must be zero */ + UINT32 ProximityDomain; + UINT32 ApicId; + UINT32 Flags; + UINT32 ClockDomain; + UINT32 Reserved2; + +} ACPI_SRAT_X2APIC_CPU_AFFINITY; + +/* Flags for ACPI_SRAT_CPU_AFFINITY and ACPI_SRAT_X2APIC_CPU_AFFINITY */ + +#define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ + + +/* Reset to default packing */ + +#pragma pack() + +#endif /* __ACTBL1_H__ */ diff --git a/drivers/bus/acpi/acpica/include/actbl2.h b/drivers/bus/acpi/acpica/include/actbl2.h new file mode 100644 index 00000000000..e57c02356cc --- /dev/null +++ b/drivers/bus/acpi/acpica/include/actbl2.h @@ -0,0 +1,1124 @@ +/****************************************************************************** + * + * Name: actbl2.h - ACPI Specification Revision 2.0 Tables + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL2_H__ +#define __ACTBL2_H__ + + +/******************************************************************************* + * + * Additional ACPI Tables (2) + * + * These tables are not consumed directly by the ACPICA subsystem, but are + * included here to support device drivers and the AML disassembler. + * + * The tables in this file are defined by third-party specifications, and are + * not defined directly by the ACPI specification itself. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ +#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */ +#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ +#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ +#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ +#define ACPI_SIG_IBFT "IBFT" /* iSCSI Boot Firmware Table */ +#define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */ +#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ +#define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */ +#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ +#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ +#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ +#define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */ +#define ACPI_SIG_WAET "WAET" /* Windows ACPI Emulated devices Table */ +#define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */ +#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */ + + +/* + * All tables must be byte-packed to match the ACPI specification, since + * the tables are provided by the system BIOS. + */ +#pragma pack(1) + +/* + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + + +/******************************************************************************* + * + * ASF - Alert Standard Format table (Signature "ASF!") + * Revision 0x10 + * + * Conforms to the Alert Standard Format Specification V2.0, 23 April 2003 + * + ******************************************************************************/ + +typedef struct acpi_table_asf +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + +} ACPI_TABLE_ASF; + + +/* ASF subtable header */ + +typedef struct acpi_asf_header +{ + UINT8 Type; + UINT8 Reserved; + UINT16 Length; + +} ACPI_ASF_HEADER; + + +/* Values for Type field above */ + +enum AcpiAsfType +{ + ACPI_ASF_TYPE_INFO = 0, + ACPI_ASF_TYPE_ALERT = 1, + ACPI_ASF_TYPE_CONTROL = 2, + ACPI_ASF_TYPE_BOOT = 3, + ACPI_ASF_TYPE_ADDRESS = 4, + ACPI_ASF_TYPE_RESERVED = 5 +}; + +/* + * ASF subtables + */ + +/* 0: ASF Information */ + +typedef struct acpi_asf_info +{ + ACPI_ASF_HEADER Header; + UINT8 MinResetValue; + UINT8 MinPollInterval; + UINT16 SystemId; + UINT32 MfgId; + UINT8 Flags; + UINT8 Reserved2[3]; + +} ACPI_ASF_INFO; + +/* Masks for Flags field above */ + +#define ACPI_ASF_SMBUS_PROTOCOLS (1) + + +/* 1: ASF Alerts */ + +typedef struct acpi_asf_alert +{ + ACPI_ASF_HEADER Header; + UINT8 AssertMask; + UINT8 DeassertMask; + UINT8 Alerts; + UINT8 DataLength; + +} ACPI_ASF_ALERT; + +typedef struct acpi_asf_alert_data +{ + UINT8 Address; + UINT8 Command; + UINT8 Mask; + UINT8 Value; + UINT8 SensorType; + UINT8 Type; + UINT8 Offset; + UINT8 SourceType; + UINT8 Severity; + UINT8 SensorNumber; + UINT8 Entity; + UINT8 Instance; + +} ACPI_ASF_ALERT_DATA; + + +/* 2: ASF Remote Control */ + +typedef struct acpi_asf_remote +{ + ACPI_ASF_HEADER Header; + UINT8 Controls; + UINT8 DataLength; + UINT16 Reserved2; + +} ACPI_ASF_REMOTE; + +typedef struct acpi_asf_control_data +{ + UINT8 Function; + UINT8 Address; + UINT8 Command; + UINT8 Value; + +} ACPI_ASF_CONTROL_DATA; + + +/* 3: ASF RMCP Boot Options */ + +typedef struct acpi_asf_rmcp +{ + ACPI_ASF_HEADER Header; + UINT8 Capabilities[7]; + UINT8 CompletionCode; + UINT32 EnterpriseId; + UINT8 Command; + UINT16 Parameter; + UINT16 BootOptions; + UINT16 OemParameters; + +} ACPI_ASF_RMCP; + + +/* 4: ASF Address */ + +typedef struct acpi_asf_address +{ + ACPI_ASF_HEADER Header; + UINT8 EpromAddress; + UINT8 Devices; + +} ACPI_ASF_ADDRESS; + + +/******************************************************************************* + * + * BOOT - Simple Boot Flag Table + * Version 1 + * + * Conforms to the "Simple Boot Flag Specification", Version 2.1 + * + ******************************************************************************/ + +typedef struct acpi_table_boot +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 CmosIndex; /* Index in CMOS RAM for the boot register */ + UINT8 Reserved[3]; + +} ACPI_TABLE_BOOT; + + +/******************************************************************************* + * + * DBGP - Debug Port table + * Version 1 + * + * Conforms to the "Debug Port Specification", Version 1.00, 2/9/2000 + * + ******************************************************************************/ + +typedef struct acpi_table_dbgp +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Type; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS DebugPort; + +} ACPI_TABLE_DBGP; + + +/******************************************************************************* + * + * DMAR - DMA Remapping table + * Version 1 + * + * Conforms to "Intel Virtualization Technology for Directed I/O", + * Version 1.2, Sept. 2008 + * + ******************************************************************************/ + +typedef struct acpi_table_dmar +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Width; /* Host Address Width */ + UINT8 Flags; + UINT8 Reserved[10]; + +} ACPI_TABLE_DMAR; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_INTR_REMAP (1) + + +/* DMAR subtable header */ + +typedef struct acpi_dmar_header +{ + UINT16 Type; + UINT16 Length; + +} ACPI_DMAR_HEADER; + +/* Values for subtable type in ACPI_DMAR_HEADER */ + +enum AcpiDmarType +{ + ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, + ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, + ACPI_DMAR_TYPE_ATSR = 2, + ACPI_DMAR_HARDWARE_AFFINITY = 3, + ACPI_DMAR_TYPE_RESERVED = 4 /* 4 and greater are reserved */ +}; + + +/* DMAR Device Scope structure */ + +typedef struct acpi_dmar_device_scope +{ + UINT8 EntryType; + UINT8 Length; + UINT16 Reserved; + UINT8 EnumerationId; + UINT8 Bus; + +} ACPI_DMAR_DEVICE_SCOPE; + +/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ + +enum AcpiDmarScopeType +{ + ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, + ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, + ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, + ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, + ACPI_DMAR_SCOPE_TYPE_HPET = 4, + ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ +}; + +typedef struct acpi_dmar_pci_path +{ + UINT8 Device; + UINT8 Function; + +} ACPI_DMAR_PCI_PATH; + + +/* + * DMAR Sub-tables, correspond to Type in ACPI_DMAR_HEADER + */ + +/* 0: Hardware Unit Definition */ + +typedef struct acpi_dmar_hardware_unit +{ + ACPI_DMAR_HEADER Header; + UINT8 Flags; + UINT8 Reserved; + UINT16 Segment; + UINT64 Address; /* Register Base Address */ + +} ACPI_DMAR_HARDWARE_UNIT; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_INCLUDE_ALL (1) + + +/* 1: Reserved Memory Defininition */ + +typedef struct acpi_dmar_reserved_memory +{ + ACPI_DMAR_HEADER Header; + UINT16 Reserved; + UINT16 Segment; + UINT64 BaseAddress; /* 4K aligned base address */ + UINT64 EndAddress; /* 4K aligned limit address */ + +} ACPI_DMAR_RESERVED_MEMORY; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_ALLOW_ALL (1) + + +/* 2: Root Port ATS Capability Reporting Structure */ + +typedef struct acpi_dmar_atsr +{ + ACPI_DMAR_HEADER Header; + UINT8 Flags; + UINT8 Reserved; + UINT16 Segment; + +} ACPI_DMAR_ATSR; + +/* Masks for Flags field above */ + +#define ACPI_DMAR_ALL_PORTS (1) + + +/* 3: Remapping Hardware Static Affinity Structure */ + +typedef struct acpi_dmar_rhsa +{ + ACPI_DMAR_HEADER Header; + UINT32 Reserved; + UINT64 BaseAddress; + UINT32 ProximityDomain; + +} ACPI_DMAR_RHSA; + + +/******************************************************************************* + * + * HPET - High Precision Event Timer table + * Version 1 + * + * Conforms to "IA-PC HPET (High Precision Event Timers) Specification", + * Version 1.0a, October 2004 + * + ******************************************************************************/ + +typedef struct acpi_table_hpet +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Id; /* Hardware ID of event timer block */ + ACPI_GENERIC_ADDRESS Address; /* Address of event timer block */ + UINT8 Sequence; /* HPET sequence number */ + UINT16 MinimumTick; /* Main counter min tick, periodic mode */ + UINT8 Flags; + +} ACPI_TABLE_HPET; + +/* Masks for Flags field above */ + +#define ACPI_HPET_PAGE_PROTECT_MASK (3) + +/* Values for Page Protect flags */ + +enum AcpiHpetPageProtect +{ + ACPI_HPET_NO_PAGE_PROTECT = 0, + ACPI_HPET_PAGE_PROTECT4 = 1, + ACPI_HPET_PAGE_PROTECT64 = 2 +}; + + +/******************************************************************************* + * + * IBFT - Boot Firmware Table + * Version 1 + * + * Conforms to "iSCSI Boot Firmware Table (iBFT) as Defined in ACPI 3.0b + * Specification", Version 1.01, March 1, 2007 + * + * Note: It appears that this table is not intended to appear in the RSDT/XSDT. + * Therefore, it is not currently supported by the disassembler. + * + ******************************************************************************/ + +typedef struct acpi_table_ibft +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved[12]; + +} ACPI_TABLE_IBFT; + + +/* IBFT common subtable header */ + +typedef struct acpi_ibft_header +{ + UINT8 Type; + UINT8 Version; + UINT16 Length; + UINT8 Index; + UINT8 Flags; + +} ACPI_IBFT_HEADER; + +/* Values for Type field above */ + +enum AcpiIbftType +{ + ACPI_IBFT_TYPE_NOT_USED = 0, + ACPI_IBFT_TYPE_CONTROL = 1, + ACPI_IBFT_TYPE_INITIATOR = 2, + ACPI_IBFT_TYPE_NIC = 3, + ACPI_IBFT_TYPE_TARGET = 4, + ACPI_IBFT_TYPE_EXTENSIONS = 5, + ACPI_IBFT_TYPE_RESERVED = 6 /* 6 and greater are reserved */ +}; + + +/* IBFT subtables */ + +typedef struct acpi_ibft_control +{ + ACPI_IBFT_HEADER Header; + UINT16 Extensions; + UINT16 InitiatorOffset; + UINT16 Nic0Offset; + UINT16 Target0Offset; + UINT16 Nic1Offset; + UINT16 Target1Offset; + +} ACPI_IBFT_CONTROL; + +typedef struct acpi_ibft_initiator +{ + ACPI_IBFT_HEADER Header; + UINT8 SnsServer[16]; + UINT8 SlpServer[16]; + UINT8 PrimaryServer[16]; + UINT8 SecondaryServer[16]; + UINT16 NameLength; + UINT16 NameOffset; + +} ACPI_IBFT_INITIATOR; + +typedef struct acpi_ibft_nic +{ + ACPI_IBFT_HEADER Header; + UINT8 IpAddress[16]; + UINT8 SubnetMaskPrefix; + UINT8 Origin; + UINT8 Gateway[16]; + UINT8 PrimaryDns[16]; + UINT8 SecondaryDns[16]; + UINT8 Dhcp[16]; + UINT16 Vlan; + UINT8 MacAddress[6]; + UINT16 PciAddress; + UINT16 NameLength; + UINT16 NameOffset; + +} ACPI_IBFT_NIC; + +typedef struct acpi_ibft_target +{ + ACPI_IBFT_HEADER Header; + UINT8 TargetIpAddress[16]; + UINT16 TargetIpSocket; + UINT8 TargetBootLun[8]; + UINT8 ChapType; + UINT8 NicAssociation; + UINT16 TargetNameLength; + UINT16 TargetNameOffset; + UINT16 ChapNameLength; + UINT16 ChapNameOffset; + UINT16 ChapSecretLength; + UINT16 ChapSecretOffset; + UINT16 ReverseChapNameLength; + UINT16 ReverseChapNameOffset; + UINT16 ReverseChapSecretLength; + UINT16 ReverseChapSecretOffset; + +} ACPI_IBFT_TARGET; + + +/******************************************************************************* + * + * IVRS - I/O Virtualization Reporting Structure + * Version 1 + * + * Conforms to "AMD I/O Virtualization Technology (IOMMU) Specification", + * Revision 1.26, February 2009. + * + ******************************************************************************/ + +typedef struct acpi_table_ivrs +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Info; /* Common virtualization info */ + UINT64 Reserved; + +} ACPI_TABLE_IVRS; + +/* Values for Info field above */ + +#define ACPI_IVRS_PHYSICAL_SIZE 0x00007F00 /* 7 bits, physical address size */ +#define ACPI_IVRS_VIRTUAL_SIZE 0x003F8000 /* 7 bits, virtual address size */ +#define ACPI_IVRS_ATS_RESERVED 0x00400000 /* ATS address translation range reserved */ + + +/* IVRS subtable header */ + +typedef struct acpi_ivrs_header +{ + UINT8 Type; /* Subtable type */ + UINT8 Flags; + UINT16 Length; /* Subtable length */ + UINT16 DeviceId; /* ID of IOMMU */ + +} ACPI_IVRS_HEADER; + +/* Values for subtable Type above */ + +enum AcpiIvrsType +{ + ACPI_IVRS_TYPE_HARDWARE = 0x10, + ACPI_IVRS_TYPE_MEMORY1 = 0x20, + ACPI_IVRS_TYPE_MEMORY2 = 0x21, + ACPI_IVRS_TYPE_MEMORY3 = 0x22 +}; + +/* Masks for Flags field above for IVHD subtable */ + +#define ACPI_IVHD_TT_ENABLE (1) +#define ACPI_IVHD_PASS_PW (1<<1) +#define ACPI_IVHD_RES_PASS_PW (1<<2) +#define ACPI_IVHD_ISOC (1<<3) +#define ACPI_IVHD_IOTLB (1<<4) + +/* Masks for Flags field above for IVMD subtable */ + +#define ACPI_IVMD_UNITY (1) +#define ACPI_IVMD_READ (1<<1) +#define ACPI_IVMD_WRITE (1<<2) +#define ACPI_IVMD_EXCLUSION_RANGE (1<<3) + + +/* + * IVRS subtables, correspond to Type in ACPI_IVRS_HEADER + */ + +/* 0x10: I/O Virtualization Hardware Definition Block (IVHD) */ + +typedef struct acpi_ivrs_hardware +{ + ACPI_IVRS_HEADER Header; + UINT16 CapabilityOffset; /* Offset for IOMMU control fields */ + UINT64 BaseAddress; /* IOMMU control registers */ + UINT16 PciSegmentGroup; + UINT16 Info; /* MSI number and unit ID */ + UINT32 Reserved; + +} ACPI_IVRS_HARDWARE; + +/* Masks for Info field above */ + +#define ACPI_IVHD_MSI_NUMBER_MASK 0x001F /* 5 bits, MSI message number */ +#define ACPI_IVHD_UNIT_ID_MASK 0x1F00 /* 5 bits, UnitID */ + + +/* + * Device Entries for IVHD subtable, appear after ACPI_IVRS_HARDWARE structure. + * Upper two bits of the Type field are the (encoded) length of the structure. + * Currently, only 4 and 8 byte entries are defined. 16 and 32 byte entries + * are reserved for future use but not defined. + */ +typedef struct acpi_ivrs_de_header +{ + UINT8 Type; + UINT16 Id; + UINT8 DataSetting; + +} ACPI_IVRS_DE_HEADER; + +/* Length of device entry is in the top two bits of Type field above */ + +#define ACPI_IVHD_ENTRY_LENGTH 0xC0 + +/* Values for device entry Type field above */ + +enum AcpiIvrsDeviceEntryType +{ + /* 4-byte device entries, all use ACPI_IVRS_DEVICE4 */ + + ACPI_IVRS_TYPE_PAD4 = 0, + ACPI_IVRS_TYPE_ALL = 1, + ACPI_IVRS_TYPE_SELECT = 2, + ACPI_IVRS_TYPE_START = 3, + ACPI_IVRS_TYPE_END = 4, + + /* 8-byte device entries */ + + ACPI_IVRS_TYPE_PAD8 = 64, + ACPI_IVRS_TYPE_NOT_USED = 65, + ACPI_IVRS_TYPE_ALIAS_SELECT = 66, /* Uses ACPI_IVRS_DEVICE8A */ + ACPI_IVRS_TYPE_ALIAS_START = 67, /* Uses ACPI_IVRS_DEVICE8A */ + ACPI_IVRS_TYPE_EXT_SELECT = 70, /* Uses ACPI_IVRS_DEVICE8B */ + ACPI_IVRS_TYPE_EXT_START = 71, /* Uses ACPI_IVRS_DEVICE8B */ + ACPI_IVRS_TYPE_SPECIAL = 72 /* Uses ACPI_IVRS_DEVICE8C */ +}; + +/* Values for Data field above */ + +#define ACPI_IVHD_INIT_PASS (1) +#define ACPI_IVHD_EINT_PASS (1<<1) +#define ACPI_IVHD_NMI_PASS (1<<2) +#define ACPI_IVHD_SYSTEM_MGMT (3<<4) +#define ACPI_IVHD_LINT0_PASS (1<<6) +#define ACPI_IVHD_LINT1_PASS (1<<7) + + +/* Types 0-4: 4-byte device entry */ + +typedef struct acpi_ivrs_device4 +{ + ACPI_IVRS_DE_HEADER Header; + +} ACPI_IVRS_DEVICE4; + +/* Types 66-67: 8-byte device entry */ + +typedef struct acpi_ivrs_device8a +{ + ACPI_IVRS_DE_HEADER Header; + UINT8 Reserved1; + UINT16 UsedId; + UINT8 Reserved2; + +} ACPI_IVRS_DEVICE8A; + +/* Types 70-71: 8-byte device entry */ + +typedef struct acpi_ivrs_device8b +{ + ACPI_IVRS_DE_HEADER Header; + UINT32 ExtendedData; + +} ACPI_IVRS_DEVICE8B; + +/* Values for ExtendedData above */ + +#define ACPI_IVHD_ATS_DISABLED (1<<31) + +/* Type 72: 8-byte device entry */ + +typedef struct acpi_ivrs_device8c +{ + ACPI_IVRS_DE_HEADER Header; + UINT8 Handle; + UINT16 UsedId; + UINT8 Variety; + +} ACPI_IVRS_DEVICE8C; + +/* Values for Variety field above */ + +#define ACPI_IVHD_IOAPIC 1 +#define ACPI_IVHD_HPET 2 + + +/* 0x20, 0x21, 0x22: I/O Virtualization Memory Definition Block (IVMD) */ + +typedef struct acpi_ivrs_memory +{ + ACPI_IVRS_HEADER Header; + UINT16 AuxData; + UINT64 Reserved; + UINT64 StartAddress; + UINT64 MemoryLength; + +} ACPI_IVRS_MEMORY; + + +/******************************************************************************* + * + * MCFG - PCI Memory Mapped Configuration table and sub-table + * Version 1 + * + * Conforms to "PCI Firmware Specification", Revision 3.0, June 20, 2005 + * + ******************************************************************************/ + +typedef struct acpi_table_mcfg +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved[8]; + +} ACPI_TABLE_MCFG; + + +/* Subtable */ + +typedef struct acpi_mcfg_allocation +{ + UINT64 Address; /* Base address, processor-relative */ + UINT16 PciSegment; /* PCI segment group number */ + UINT8 StartBusNumber; /* Starting PCI Bus number */ + UINT8 EndBusNumber; /* Final PCI Bus number */ + UINT32 Reserved; + +} ACPI_MCFG_ALLOCATION; + + +/******************************************************************************* + * + * SPCR - Serial Port Console Redirection table + * Version 1 + * + * Conforms to "Serial Port Console Redirection Table", + * Version 1.00, January 11, 2002 + * + ******************************************************************************/ + +typedef struct acpi_table_spcr +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS SerialPort; + UINT8 InterruptType; + UINT8 PcInterrupt; + UINT32 Interrupt; + UINT8 BaudRate; + UINT8 Parity; + UINT8 StopBits; + UINT8 FlowControl; + UINT8 TerminalType; + UINT8 Reserved1; + UINT16 PciDeviceId; + UINT16 PciVendorId; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + UINT32 PciFlags; + UINT8 PciSegment; + UINT32 Reserved2; + +} ACPI_TABLE_SPCR; + +/* Masks for PciFlags field above */ + +#define ACPI_SPCR_DO_NOT_DISABLE (1) + + +/******************************************************************************* + * + * SPMI - Server Platform Management Interface table + * Version 5 + * + * Conforms to "Intelligent Platform Management Interface Specification + * Second Generation v2.0", Document Revision 1.0, February 12, 2004 with + * June 12, 2009 markup. + * + ******************************************************************************/ + +typedef struct acpi_table_spmi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; + UINT8 Reserved; /* Must be 1 */ + UINT16 SpecRevision; /* Version of IPMI */ + UINT8 InterruptType; + UINT8 GpeNumber; /* GPE assigned */ + UINT8 Reserved1; + UINT8 PciDeviceFlag; + UINT32 Interrupt; + ACPI_GENERIC_ADDRESS IpmiRegister; + UINT8 PciSegment; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + UINT8 Reserved2; + +} ACPI_TABLE_SPMI; + +/* Values for InterfaceType above */ + +enum AcpiSpmiInterfaceTypes +{ + ACPI_SPMI_NOT_USED = 0, + ACPI_SPMI_KEYBOARD = 1, + ACPI_SPMI_SMI = 2, + ACPI_SPMI_BLOCK_TRANSFER = 3, + ACPI_SPMI_SMBUS = 4, + ACPI_SPMI_RESERVED = 5 /* 5 and above are reserved */ +}; + + +/******************************************************************************* + * + * TCPA - Trusted Computing Platform Alliance table + * Version 1 + * + * Conforms to "TCG PC Specific Implementation Specification", + * Version 1.1, August 18, 2003 + * + ******************************************************************************/ + +typedef struct acpi_table_tcpa +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT16 Reserved; + UINT32 MaxLogLength; /* Maximum length for the event log area */ + UINT64 LogAddress; /* Address of the event log area */ + +} ACPI_TABLE_TCPA; + + +/******************************************************************************* + * + * UEFI - UEFI Boot optimization Table + * Version 1 + * + * Conforms to "Unified Extensible Firmware Interface Specification", + * Version 2.3, May 8, 2009 + * + ******************************************************************************/ + +typedef struct acpi_table_uefi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Identifier[16]; /* UUID identifier */ + UINT16 DataOffset; /* Offset of remaining data in table */ + +} ACPI_TABLE_UEFI; + + +/******************************************************************************* + * + * WAET - Windows ACPI Emulated devices Table + * Version 1 + * + * Conforms to "Windows ACPI Emulated Devices Table", version 1.0, April 6, 2009 + * + ******************************************************************************/ + +typedef struct acpi_table_waet +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Flags; + +} ACPI_TABLE_WAET; + +/* Masks for Flags field above */ + +#define ACPI_WAET_RTC_NO_ACK (1) /* RTC requires no int acknowledge */ +#define ACPI_WAET_TIMER_ONE_READ (1<<1) /* PM timer requires only one read */ + + +/******************************************************************************* + * + * WDAT - Watchdog Action Table + * Version 1 + * + * Conforms to "Hardware Watchdog Timers Design Specification", + * Copyright 2006 Microsoft Corporation. + * + ******************************************************************************/ + +typedef struct acpi_table_wdat +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; /* Watchdog Header Length */ + UINT16 PciSegment; /* PCI Segment number */ + UINT8 PciBus; /* PCI Bus number */ + UINT8 PciDevice; /* PCI Device number */ + UINT8 PciFunction; /* PCI Function number */ + UINT8 Reserved[3]; + UINT32 TimerPeriod; /* Period of one timer count (msec) */ + UINT32 MaxCount; /* Maximum counter value supported */ + UINT32 MinCount; /* Minimum counter value */ + UINT8 Flags; + UINT8 Reserved2[3]; + UINT32 Entries; /* Number of watchdog entries that follow */ + +} ACPI_TABLE_WDAT; + +/* Masks for Flags field above */ + +#define ACPI_WDAT_ENABLED (1) +#define ACPI_WDAT_STOPPED 0x80 + + +/* WDAT Instruction Entries (actions) */ + +typedef struct acpi_wdat_entry +{ + UINT8 Action; + UINT8 Instruction; + UINT16 Reserved; + ACPI_GENERIC_ADDRESS RegisterRegion; + UINT32 Value; /* Value used with Read/Write register */ + UINT32 Mask; /* Bitmask required for this register instruction */ + +} ACPI_WDAT_ENTRY; + +/* Values for Action field above */ + +enum AcpiWdatActions +{ + ACPI_WDAT_RESET = 1, + ACPI_WDAT_GET_CURRENT_COUNTDOWN = 4, + ACPI_WDAT_GET_COUNTDOWN = 5, + ACPI_WDAT_SET_COUNTDOWN = 6, + ACPI_WDAT_GET_RUNNING_STATE = 8, + ACPI_WDAT_SET_RUNNING_STATE = 9, + ACPI_WDAT_GET_STOPPED_STATE = 10, + ACPI_WDAT_SET_STOPPED_STATE = 11, + ACPI_WDAT_GET_REBOOT = 16, + ACPI_WDAT_SET_REBOOT = 17, + ACPI_WDAT_GET_SHUTDOWN = 18, + ACPI_WDAT_SET_SHUTDOWN = 19, + ACPI_WDAT_GET_STATUS = 32, + ACPI_WDAT_SET_STATUS = 33, + ACPI_WDAT_ACTION_RESERVED = 34 /* 34 and greater are reserved */ +}; + +/* Values for Instruction field above */ + +enum AcpiWdatInstructions +{ + ACPI_WDAT_READ_VALUE = 0, + ACPI_WDAT_READ_COUNTDOWN = 1, + ACPI_WDAT_WRITE_VALUE = 2, + ACPI_WDAT_WRITE_COUNTDOWN = 3, + ACPI_WDAT_INSTRUCTION_RESERVED = 4, /* 4 and greater are reserved */ + ACPI_WDAT_PRESERVE_REGISTER = 0x80 /* Except for this value */ +}; + + +/******************************************************************************* + * + * WDRT - Watchdog Resource Table + * Version 1 + * + * Conforms to "Watchdog Timer Hardware Requirements for Windows Server 2003", + * Version 1.01, August 28, 2006 + * + ******************************************************************************/ + +typedef struct acpi_table_wdrt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + ACPI_GENERIC_ADDRESS ControlRegister; + ACPI_GENERIC_ADDRESS CountRegister; + UINT16 PciDeviceId; + UINT16 PciVendorId; + UINT8 PciBus; /* PCI Bus number */ + UINT8 PciDevice; /* PCI Device number */ + UINT8 PciFunction; /* PCI Function number */ + UINT8 PciSegment; /* PCI Segment number */ + UINT16 MaxCount; /* Maximum counter value supported */ + UINT8 Units; + +} ACPI_TABLE_WDRT; + + +/* Reset to default packing */ + +#pragma pack() + +#endif /* __ACTBL2_H__ */ + diff --git a/drivers/bus/acpi/acpica/include/actbl71.h b/drivers/bus/acpi/acpica/include/actbl71.h new file mode 100644 index 00000000000..0390d6f8de6 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/actbl71.h @@ -0,0 +1,144 @@ +/****************************************************************************** + * + * Name: actbl71.h - IA-64 Extensions to the ACPI Spec Rev. 0.71 + * This file includes tables specific to this + * specification revision. + * $Revision: 1.1 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000, 2001 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACTBL71_H__ +#define __ACTBL71_H__ + +/* 0.71 FADT Address_space data item bitmasks defines */ +/* If the associated bit is zero then it is in memory space else in io space */ +#define SMI_CMD_ADDRESS_SPACE 0x01 +#define PM1_BLK_ADDRESS_SPACE 0x02 +#define PM2_CNT_BLK_ADDRESS_SPACE 0x04 +#define PM_TMR_BLK_ADDRESS_SPACE 0x08 +#define GPE0_BLK_ADDRESS_SPACE 0x10 +#define GPE1_BLK_ADDRESS_SPACE 0x20 + +/* Only for clarity in declarations */ +typedef UINT64 IO_ADDRESS; + +#pragma pack(1) + +typedef struct /* Root System Descriptor Pointer */ +{ + NATIVE_CHAR signature [8]; /* contains "RSD PTR " */ + u8 checksum; /* to make sum of struct == 0 */ + NATIVE_CHAR oem_id [6]; /* OEM identification */ + u8 reserved; /* Must be 0 for 1.0, 2 for 2.0 */ + UINT64 rsdt_physical_address; /* 64-bit physical address of RSDT */ +} RSDP_DESCRIPTOR_REV071; + + +/*****************************************/ +/* IA64 Extensions to ACPI Spec Rev 0.71 */ +/* for the Root System Description Table */ +/*****************************************/ +typedef struct +{ + ACPI_TABLE_HEADER header; /* Table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + UINT64 table_offset_entry [1]; /* Array of pointers to other */ + /* tables' headers */ +} RSDT_DESCRIPTOR_REV071; + + +/*******************************************/ +/* IA64 Extensions to ACPI Spec Rev 0.71 */ +/* for the Firmware ACPI Control Structure */ +/*******************************************/ +typedef struct +{ + NATIVE_CHAR signature[4]; /* signature "FACS" */ + u32 length; /* length of structure, in bytes */ + u32 hardware_signature; /* hardware configuration signature */ + u32 reserved4; /* must be 0 */ + UINT64 firmware_waking_vector; /* ACPI OS waking vector */ + UINT64 global_lock; /* Global Lock */ + u32 S4_bios_f : 1; /* Indicates if S4_bIOS support is present */ + u32 reserved1 : 31; /* must be 0 */ + u8 reserved3 [28]; /* reserved - must be zero */ + +} FACS_DESCRIPTOR_REV071; + + +/******************************************/ +/* IA64 Extensions to ACPI Spec Rev 0.71 */ +/* for the Fixed ACPI Description Table */ +/******************************************/ +typedef struct +{ + ACPI_TABLE_HEADER header; /* table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + UINT64 firmware_ctrl; /* 64-bit Physical address of FACS */ + UINT64 dsdt; /* 64-bit Physical address of DSDT */ + u8 model; /* System Interrupt Model */ + u8 address_space; /* Address Space Bitmask */ + u16 sci_int; /* System vector of SCI interrupt */ + u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ + u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ + u8 S4_bios_req; /* Value to write to SMI CMD to enter S4_bIOS state */ + u8 reserved2; /* reserved - must be zero */ + UINT64 smi_cmd; /* Port address of SMI command port */ + UINT64 pm1a_evt_blk; /* Port address of Power Mgt 1a Acpi_event Reg Blk */ + UINT64 pm1b_evt_blk; /* Port address of Power Mgt 1b Acpi_event Reg Blk */ + UINT64 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ + UINT64 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ + UINT64 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ + UINT64 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ + UINT64 gpe0blk; /* Port addr of General Purpose Acpi_event 0 Reg Blk */ + UINT64 gpe1_blk; /* Port addr of General Purpose Acpi_event 1 Reg Blk */ + u8 pm1_evt_len; /* Byte Length of ports at pm1_x_evt_blk */ + u8 pm1_cnt_len; /* Byte Length of ports at pm1_x_cnt_blk */ + u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ + u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ + u8 gpe0blk_len; /* Byte Length of ports at gpe0_blk */ + u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ + u8 gpe1_base; /* offset in gpe model where gpe1 events start */ + u8 reserved3; /* reserved */ + u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ + u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ + u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ + u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ + u8 century; /* index to century in RTC CMOS RAM */ + u8 reserved4; /* reserved */ + u32 flush_cash : 1; /* PAL_FLUSH_CACHE is correctly supported */ + u32 reserved5 : 1; /* reserved - must be zero */ + u32 proc_c1 : 1; /* all processors support C1 state */ + u32 plvl2_up : 1; /* C2 state works on MP system */ + u32 pwr_button : 1; /* Power button is handled as a generic feature */ + u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ + u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ + u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ + u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ + u32 dock_cap : 1; /* Supports Docking */ + u32 reserved6 : 22; /* reserved - must be zero */ + +} FADT_DESCRIPTOR_REV071; + +#pragma pack() + +#endif /* __ACTBL71_H__ */ + diff --git a/drivers/bus/acpi/acpica/include/actypes.h b/drivers/bus/acpi/acpica/include/actypes.h new file mode 100644 index 00000000000..ef8d48bd29d --- /dev/null +++ b/drivers/bus/acpi/acpica/include/actypes.h @@ -0,0 +1,1248 @@ +/****************************************************************************** + * + * Name: actypes.h - Common data types for the entire ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTYPES_H__ +#define __ACTYPES_H__ + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +/* + * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent header + * and must be either 32 or 64. 16-bit ACPICA is no longer supported, as of + * 12/2006. + */ +#ifndef ACPI_MACHINE_WIDTH +#error ACPI_MACHINE_WIDTH not defined +#endif + +/*! [Begin] no source code translation */ + +/* + * Data type ranges + * Note: These macros are designed to be compiler independent as well as + * working around problems that some 32-bit compilers have with 64-bit + * constants. + */ +#define ACPI_UINT8_MAX (UINT8) (~((UINT8) 0)) /* 0xFF */ +#define ACPI_UINT16_MAX (UINT16)(~((UINT16) 0)) /* 0xFFFF */ +#define ACPI_UINT32_MAX (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF */ +#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ +#define ACPI_ASCII_MAX 0x7F + + +/* + * Architecture-specific ACPICA Subsystem Data Types + * + * The goal of these types is to provide source code portability across + * 16-bit, 32-bit, and 64-bit targets. + * + * 1) The following types are of fixed size for all targets (16/32/64): + * + * BOOLEAN Logical boolean + * + * UINT8 8-bit (1 byte) unsigned value + * UINT16 16-bit (2 byte) unsigned value + * UINT32 32-bit (4 byte) unsigned value + * UINT64 64-bit (8 byte) unsigned value + * + * INT16 16-bit (2 byte) signed value + * INT32 32-bit (4 byte) signed value + * INT64 64-bit (8 byte) signed value + * + * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the + * compiler-dependent header(s) and were introduced because there is no common + * 64-bit integer type across the various compilation models, as shown in + * the table below. + * + * Datatype LP64 ILP64 LLP64 ILP32 LP32 16bit + * char 8 8 8 8 8 8 + * short 16 16 16 16 16 16 + * _int32 32 + * int 32 64 32 32 16 16 + * long 64 64 32 32 32 32 + * long long 64 64 + * pointer 64 64 64 32 32 32 + * + * Note: ILP64 and LP32 are currently not supported. + * + * + * 2) These types represent the native word size of the target mode of the + * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are + * usually used for memory allocation, efficient loop counters, and array + * indexes. The types are similar to the size_t type in the C library and are + * required because there is no C type that consistently represents the native + * data width. ACPI_SIZE is needed because there is no guarantee that a + * kernel-level C library is present. + * + * ACPI_SIZE 16/32/64-bit unsigned value + * ACPI_NATIVE_INT 16/32/64-bit signed value + * + */ + +/******************************************************************************* + * + * Common types for all compilers, all targets + * + ******************************************************************************/ + +//typedef unsigned char BOOLEAN; +//typedef unsigned char UINT8; +//typedef unsigned short UINT16; +//typedef COMPILER_DEPENDENT_UINT64 UINT64; +//typedef COMPILER_DEPENDENT_INT64 INT64; + +/*! [End] no source code translation !*/ + + +/******************************************************************************* + * + * Types specific to 64-bit targets + * + ******************************************************************************/ + +#if ACPI_MACHINE_WIDTH == 64 + +/*! [Begin] no source code translation (keep the typedefs as-is) */ + +typedef unsigned int UINT32; +typedef int INT32; + +/*! [End] no source code translation !*/ + + +typedef INT64 ACPI_NATIVE_INT; +typedef UINT64 ACPI_SIZE; +typedef UINT64 ACPI_IO_ADDRESS; +typedef UINT64 ACPI_PHYSICAL_ADDRESS; + +#define ACPI_MAX_PTR ACPI_UINT64_MAX +#define ACPI_SIZE_MAX ACPI_UINT64_MAX +#define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ + +/* + * In the case of the Itanium Processor Family (IPF), the hardware does not + * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag + * to indicate that special precautions must be taken to avoid alignment faults. + * (IA64 or ia64 is currently used by existing compilers to indicate IPF.) + * + * Note: EM64T and other X86-64 processors support misaligned transfers, + * so there is no need to define this flag. + */ +#if defined (__IA64__) || defined (__ia64__) +#define ACPI_MISALIGNMENT_NOT_SUPPORTED +#endif + + +/******************************************************************************* + * + * Types specific to 32-bit targets + * + ******************************************************************************/ + +#elif ACPI_MACHINE_WIDTH == 32 + +/*! [Begin] no source code translation (keep the typedefs as-is) */ + +//typedef unsigned int UINT32; +//typedef int INT32; + +/*! [End] no source code translation !*/ + + +typedef INT32 ACPI_NATIVE_INT; +typedef UINT32 ACPI_SIZE; +typedef UINT32 ACPI_IO_ADDRESS; +typedef UINT32 ACPI_PHYSICAL_ADDRESS; + +#define ACPI_MAX_PTR ACPI_UINT32_MAX +#define ACPI_SIZE_MAX ACPI_UINT32_MAX + +#else + +/* ACPI_MACHINE_WIDTH must be either 64 or 32 */ + +#error unknown ACPI_MACHINE_WIDTH +#endif + + +/******************************************************************************* + * + * OS-dependent types + * + * If the defaults below are not appropriate for the host system, they can + * be defined in the OS-specific header, and this will take precedence. + * + ******************************************************************************/ + +/* Value returned by AcpiOsGetThreadId */ + +#ifndef ACPI_THREAD_ID +#define ACPI_THREAD_ID ACPI_SIZE +#endif + +/* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */ + +#ifndef ACPI_CPU_FLAGS +#define ACPI_CPU_FLAGS ACPI_SIZE +#endif + +/* Object returned from AcpiOsCreateCache */ + +#ifndef ACPI_CACHE_T +#ifdef ACPI_USE_LOCAL_CACHE +#define ACPI_CACHE_T ACPI_MEMORY_LIST +#else +#define ACPI_CACHE_T void * +#endif +#endif + +/* + * Synchronization objects - Mutexes, Semaphores, and SpinLocks + */ +#if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE) +/* + * These macros are used if the host OS does not support a mutex object. + * Map the OSL Mutex interfaces to binary semaphores. + */ +#define ACPI_MUTEX ACPI_SEMAPHORE +#define AcpiOsCreateMutex(OutHandle) AcpiOsCreateSemaphore (1, 1, OutHandle) +#define AcpiOsDeleteMutex(Handle) (void) AcpiOsDeleteSemaphore (Handle) +#define AcpiOsAcquireMutex(Handle,Time) AcpiOsWaitSemaphore (Handle, 1, Time) +#define AcpiOsReleaseMutex(Handle) (void) AcpiOsSignalSemaphore (Handle, 1) +#endif + +/* Configurable types for synchronization objects */ + +#ifndef ACPI_SPINLOCK +#define ACPI_SPINLOCK void * +#endif + +#ifndef ACPI_SEMAPHORE +#define ACPI_SEMAPHORE void * +#endif + +#ifndef ACPI_MUTEX +#define ACPI_MUTEX void * +#endif + + +/******************************************************************************* + * + * Compiler-dependent types + * + * If the defaults below are not appropriate for the host compiler, they can + * be defined in the compiler-specific header, and this will take precedence. + * + ******************************************************************************/ + +/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ + +#ifndef ACPI_UINTPTR_T +#define ACPI_UINTPTR_T void * +#endif + +/* + * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because + * some compilers can catch printf format string problems + */ +#ifndef ACPI_PRINTF_LIKE +#define ACPI_PRINTF_LIKE(c) +#endif + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (for example, _AcpiModuleName). This allows us + * to to tell the compiler in a per-variable manner that a variable + * is unused + */ +#ifndef ACPI_UNUSED_VAR +#define ACPI_UNUSED_VAR +#endif + +/* + * All ACPICA functions that are available to the rest of the kernel are + * tagged with this macro which can be defined as appropriate for the host. + */ +#ifndef ACPI_EXPORT_SYMBOL +#define ACPI_EXPORT_SYMBOL(Symbol) +#endif + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */ + +#define ACPI_MAX_GPE_BLOCKS 2 + +/* Default ACPI register widths */ + +#define ACPI_GPE_REGISTER_WIDTH 8 +#define ACPI_PM1_REGISTER_WIDTH 16 +#define ACPI_PM2_REGISTER_WIDTH 8 +#define ACPI_PM_TIMER_WIDTH 32 + +/* Names within the namespace are 4 bytes long */ + +#define ACPI_NAME_SIZE 4 +#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ +#define ACPI_PATH_SEPARATOR '.' + +/* Sizes for ACPI table headers */ + +#define ACPI_OEM_ID_SIZE 6 +#define ACPI_OEM_TABLE_ID_SIZE 8 + +/* ACPI/PNP hardware IDs */ + +#define PCI_ROOT_HID_STRING "PNP0A03" +#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" + +/* PM Timer ticks per second (HZ) */ + +#define PM_TIMER_FREQUENCY 3579545 + + +/******************************************************************************* + * + * Independent types + * + ******************************************************************************/ + +/* Logical defines and NULL */ + +#ifdef FALSE +#undef FALSE +#endif +#define FALSE (1 == 0) + +#ifdef TRUE +#undef TRUE +#endif +#define TRUE (1 == 1) + +#ifndef NULL +#define NULL (void *) 0 +#endif + + +/* + * Miscellaneous types + */ +typedef UINT32 ACPI_STATUS; /* All ACPI Exceptions */ +typedef UINT32 ACPI_NAME; /* 4-byte ACPI name */ +typedef char * ACPI_STRING; /* Null terminated ASCII string */ +typedef void * ACPI_HANDLE; /* Actually a ptr to a NS Node */ + + +/* Owner IDs are used to track namespace nodes for selective deletion */ + +typedef UINT8 ACPI_OWNER_ID; +#define ACPI_OWNER_ID_MAX 0xFF + + +typedef struct uint64_struct +{ + UINT32 Lo; + UINT32 Hi; + +} UINT64_STRUCT; + +typedef union uint64_overlay +{ + UINT64 Full; + UINT64_STRUCT Part; + +} UINT64_OVERLAY; + +typedef struct uint32_struct +{ + UINT32 Lo; + UINT32 Hi; + +} UINT32_STRUCT; + + +/* + * Acpi integer width. In ACPI version 1, integers are 32 bits. In ACPI + * version 2, integers are 64 bits. Note that this pertains to the ACPI integer + * type only, not other integers used in the implementation of the ACPI CA + * subsystem. + */ +typedef UINT64 ACPI_INTEGER; +#define ACPI_INTEGER_MAX ACPI_UINT64_MAX +#define ACPI_INTEGER_BIT_SIZE 64 +#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ +#define ACPI_MAX64_DECIMAL_DIGITS 20 +#define ACPI_MAX32_DECIMAL_DIGITS 10 +#define ACPI_MAX16_DECIMAL_DIGITS 5 +#define ACPI_MAX8_DECIMAL_DIGITS 3 + +/* + * Constants with special meanings + */ +#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (ACPI_HANDLE, NULL, ACPI_MAX_PTR) +#define ACPI_WAIT_FOREVER 0xFFFF /* UINT16, as per ACPI spec */ +#define ACPI_DO_NOT_WAIT 0 + + +/******************************************************************************* + * + * Commonly used macros + * + ******************************************************************************/ + +/* Data manipulation */ + +#define ACPI_LOBYTE(Integer) ((UINT8) (UINT16)(Integer)) +#define ACPI_HIBYTE(Integer) ((UINT8) (((UINT16)(Integer)) >> 8)) +#define ACPI_LOWORD(Integer) ((UINT16) (UINT32)(Integer)) +#define ACPI_HIWORD(Integer) ((UINT16)(((UINT32)(Integer)) >> 16)) +#define ACPI_LODWORD(Integer64) ((UINT32) (UINT64)(Integer64)) +#define ACPI_HIDWORD(Integer64) ((UINT32)(((UINT64)(Integer64)) >> 32)) + +#define ACPI_SET_BIT(target,bit) ((target) |= (bit)) +#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) +#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) +#define ACPI_MAX(a,b) (((a)>(b))?(a):(b)) + +/* Size calculation */ + +#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) + +/* Pointer manipulation */ + +#define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (p)) +#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (ACPI_UINTPTR_T) (p)) +#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b))) +#define ACPI_PTR_DIFF(a, b) (ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b))) + +/* Pointer/Integer type conversions */ + +#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(ACPI_SIZE) i) +#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL) +#define ACPI_OFFSET(d, f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL) +#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) +#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) + +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b))) +#else +#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE)) +#endif + + +/******************************************************************************* + * + * Miscellaneous constants + * + ******************************************************************************/ + +/* + * Initialization sequence + */ +#define ACPI_FULL_INITIALIZATION 0x00 +#define ACPI_NO_ADDRESS_SPACE_INIT 0x01 +#define ACPI_NO_HARDWARE_INIT 0x02 +#define ACPI_NO_EVENT_INIT 0x04 +#define ACPI_NO_HANDLER_INIT 0x08 +#define ACPI_NO_ACPI_ENABLE 0x10 +#define ACPI_NO_DEVICE_INIT 0x20 +#define ACPI_NO_OBJECT_INIT 0x40 + +/* + * Initialization state + */ +#define ACPI_SUBSYSTEM_INITIALIZE 0x01 +#define ACPI_INITIALIZED_OK 0x02 + +/* + * Power state values + */ +#define ACPI_STATE_UNKNOWN (UINT8) 0xFF + +#define ACPI_STATE_S0 (UINT8) 0 +#define ACPI_STATE_S1 (UINT8) 1 +#define ACPI_STATE_S2 (UINT8) 2 +#define ACPI_STATE_S3 (UINT8) 3 +#define ACPI_STATE_S4 (UINT8) 4 +#define ACPI_STATE_S5 (UINT8) 5 +#define ACPI_S_STATES_MAX ACPI_STATE_S5 +#define ACPI_S_STATE_COUNT 6 + +#define ACPI_STATE_D0 (UINT8) 0 +#define ACPI_STATE_D1 (UINT8) 1 +#define ACPI_STATE_D2 (UINT8) 2 +#define ACPI_STATE_D3 (UINT8) 3 +#define ACPI_D_STATES_MAX ACPI_STATE_D3 +#define ACPI_D_STATE_COUNT 4 + +#define ACPI_STATE_C0 (UINT8) 0 +#define ACPI_STATE_C1 (UINT8) 1 +#define ACPI_STATE_C2 (UINT8) 2 +#define ACPI_STATE_C3 (UINT8) 3 +#define ACPI_C_STATES_MAX ACPI_STATE_C3 +#define ACPI_C_STATE_COUNT 4 + +/* + * Sleep type invalid value + */ +#define ACPI_SLEEP_TYPE_MAX 0x7 +#define ACPI_SLEEP_TYPE_INVALID 0xFF + +/* + * Standard notify values + */ +#define ACPI_NOTIFY_BUS_CHECK (UINT8) 0x00 +#define ACPI_NOTIFY_DEVICE_CHECK (UINT8) 0x01 +#define ACPI_NOTIFY_DEVICE_WAKE (UINT8) 0x02 +#define ACPI_NOTIFY_EJECT_REQUEST (UINT8) 0x03 +#define ACPI_NOTIFY_DEVICE_CHECK_LIGHT (UINT8) 0x04 +#define ACPI_NOTIFY_FREQUENCY_MISMATCH (UINT8) 0x05 +#define ACPI_NOTIFY_BUS_MODE_MISMATCH (UINT8) 0x06 +#define ACPI_NOTIFY_POWER_FAULT (UINT8) 0x07 +#define ACPI_NOTIFY_CAPABILITIES_CHECK (UINT8) 0x08 +#define ACPI_NOTIFY_DEVICE_PLD_CHECK (UINT8) 0x09 +#define ACPI_NOTIFY_RESERVED (UINT8) 0x0A +#define ACPI_NOTIFY_LOCALITY_UPDATE (UINT8) 0x0B + +#define ACPI_NOTIFY_MAX 0x0B + +/* + * Types associated with ACPI names and objects. The first group of + * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition + * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore, + * only add to the first group if the spec changes. + * + * NOTE: Types must be kept in sync with the global AcpiNsProperties + * and AcpiNsTypeNames arrays. + */ +typedef UINT32 ACPI_OBJECT_TYPE; + +#define ACPI_TYPE_ANY 0x00 +#define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */ +#define ACPI_TYPE_STRING 0x02 +#define ACPI_TYPE_BUFFER 0x03 +#define ACPI_TYPE_PACKAGE 0x04 /* ByteConst, multiple DataTerm/Constant/SuperName */ +#define ACPI_TYPE_FIELD_UNIT 0x05 +#define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */ +#define ACPI_TYPE_EVENT 0x07 +#define ACPI_TYPE_METHOD 0x08 /* Name, ByteConst, multiple Code */ +#define ACPI_TYPE_MUTEX 0x09 +#define ACPI_TYPE_REGION 0x0A +#define ACPI_TYPE_POWER 0x0B /* Name,ByteConst,WordConst,multi Node */ +#define ACPI_TYPE_PROCESSOR 0x0C /* Name,ByteConst,DWordConst,ByteConst,multi NmO */ +#define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */ +#define ACPI_TYPE_BUFFER_FIELD 0x0E +#define ACPI_TYPE_DDB_HANDLE 0x0F +#define ACPI_TYPE_DEBUG_OBJECT 0x10 + +#define ACPI_TYPE_EXTERNAL_MAX 0x10 + +/* + * These are object types that do not map directly to the ACPI + * ObjectType() operator. They are used for various internal purposes only. + * If new predefined ACPI_TYPEs are added (via the ACPI specification), these + * internal types must move upwards. (There is code that depends on these + * values being contiguous with the external types above.) + */ +#define ACPI_TYPE_LOCAL_REGION_FIELD 0x11 +#define ACPI_TYPE_LOCAL_BANK_FIELD 0x12 +#define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13 +#define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, RefOf, Index */ +#define ACPI_TYPE_LOCAL_ALIAS 0x15 +#define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16 +#define ACPI_TYPE_LOCAL_NOTIFY 0x17 +#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18 +#define ACPI_TYPE_LOCAL_RESOURCE 0x19 +#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A +#define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple ObjectList Nodes */ + +#define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */ + +/* + * These are special object types that never appear in + * a Namespace node, only in an ACPI_OPERAND_OBJECT + */ +#define ACPI_TYPE_LOCAL_EXTRA 0x1C +#define ACPI_TYPE_LOCAL_DATA 0x1D + +#define ACPI_TYPE_LOCAL_MAX 0x1D + +/* All types above here are invalid */ + +#define ACPI_TYPE_INVALID 0x1E +#define ACPI_TYPE_NOT_FOUND 0xFF + +#define ACPI_NUM_NS_TYPES (ACPI_TYPE_INVALID + 1) + + +/* + * All I/O + */ +#define ACPI_READ 0 +#define ACPI_WRITE 1 +#define ACPI_IO_MASK 1 + +/* + * Event Types: Fixed & General Purpose + */ +typedef UINT32 ACPI_EVENT_TYPE; + +/* + * Fixed events + */ +#define ACPI_EVENT_PMTIMER 0 +#define ACPI_EVENT_GLOBAL 1 +#define ACPI_EVENT_POWER_BUTTON 2 +#define ACPI_EVENT_SLEEP_BUTTON 3 +#define ACPI_EVENT_RTC 4 +#define ACPI_EVENT_MAX 4 +#define ACPI_NUM_FIXED_EVENTS ACPI_EVENT_MAX + 1 + +/* + * Event Status - Per event + * ------------- + * The encoding of ACPI_EVENT_STATUS is illustrated below. + * Note that a set bit (1) indicates the property is TRUE + * (e.g. if bit 0 is set then the event is enabled). + * +-------------+-+-+-+ + * | Bits 31:3 |2|1|0| + * +-------------+-+-+-+ + * | | | | + * | | | +- Enabled? + * | | +--- Enabled for wake? + * | +----- Set? + * +----------- + */ +typedef UINT32 ACPI_EVENT_STATUS; + +#define ACPI_EVENT_FLAG_DISABLED (ACPI_EVENT_STATUS) 0x00 +#define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 +#define ACPI_EVENT_FLAG_WAKE_ENABLED (ACPI_EVENT_STATUS) 0x02 +#define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x04 + +/* + * General Purpose Events (GPE) + */ +#define ACPI_GPE_INVALID 0xFF +#define ACPI_GPE_MAX 0xFF +#define ACPI_NUM_GPE 256 + +#define ACPI_GPE_ENABLE 0 +#define ACPI_GPE_DISABLE 1 + + +/* + * GPE info flags - Per GPE + * +-+-+-+---+---+-+ + * |7|6|5|4:3|2:1|0| + * +-+-+-+---+---+-+ + * | | | | | | + * | | | | | +--- Interrupt type: Edge or Level Triggered + * | | | | +--- Type: Wake-only, Runtime-only, or wake/runtime + * | | | +--- Type of dispatch -- to method, handler, or none + * | | +--- Enabled for runtime? + * | +--- Enabled for wake? + * +--- Unused + */ +#define ACPI_GPE_XRUPT_TYPE_MASK (UINT8) 0x01 +#define ACPI_GPE_LEVEL_TRIGGERED (UINT8) 0x01 +#define ACPI_GPE_EDGE_TRIGGERED (UINT8) 0x00 + +#define ACPI_GPE_TYPE_MASK (UINT8) 0x06 +#define ACPI_GPE_TYPE_WAKE_RUN (UINT8) 0x06 +#define ACPI_GPE_TYPE_WAKE (UINT8) 0x02 +#define ACPI_GPE_TYPE_RUNTIME (UINT8) 0x04 /* Default */ + +#define ACPI_GPE_DISPATCH_MASK (UINT8) 0x18 +#define ACPI_GPE_DISPATCH_HANDLER (UINT8) 0x08 +#define ACPI_GPE_DISPATCH_METHOD (UINT8) 0x10 +#define ACPI_GPE_DISPATCH_NOT_USED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_RUN_ENABLE_MASK (UINT8) 0x20 +#define ACPI_GPE_RUN_ENABLED (UINT8) 0x20 +#define ACPI_GPE_RUN_DISABLED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_WAKE_ENABLE_MASK (UINT8) 0x40 +#define ACPI_GPE_WAKE_ENABLED (UINT8) 0x40 +#define ACPI_GPE_WAKE_DISABLED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_ENABLE_MASK (UINT8) 0x60 /* Both run/wake */ + +/* + * Flags for GPE and Lock interfaces + */ +#define ACPI_EVENT_WAKE_ENABLE 0x2 /* AcpiGpeEnable */ +#define ACPI_EVENT_WAKE_DISABLE 0x2 /* AcpiGpeDisable */ + +#define ACPI_NOT_ISR 0x1 +#define ACPI_ISR 0x0 + + +/* Notify types */ + +#define ACPI_SYSTEM_NOTIFY 0x1 +#define ACPI_DEVICE_NOTIFY 0x2 +#define ACPI_ALL_NOTIFY (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY) +#define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3 + +#define ACPI_MAX_SYS_NOTIFY 0x7f + + +/* Address Space (Operation Region) Types */ + +typedef UINT8 ACPI_ADR_SPACE_TYPE; + +#define ACPI_ADR_SPACE_SYSTEM_MEMORY (ACPI_ADR_SPACE_TYPE) 0 +#define ACPI_ADR_SPACE_SYSTEM_IO (ACPI_ADR_SPACE_TYPE) 1 +#define ACPI_ADR_SPACE_PCI_CONFIG (ACPI_ADR_SPACE_TYPE) 2 +#define ACPI_ADR_SPACE_EC (ACPI_ADR_SPACE_TYPE) 3 +#define ACPI_ADR_SPACE_SMBUS (ACPI_ADR_SPACE_TYPE) 4 +#define ACPI_ADR_SPACE_CMOS (ACPI_ADR_SPACE_TYPE) 5 +#define ACPI_ADR_SPACE_PCI_BAR_TARGET (ACPI_ADR_SPACE_TYPE) 6 +#define ACPI_ADR_SPACE_IPMI (ACPI_ADR_SPACE_TYPE) 7 +#define ACPI_ADR_SPACE_DATA_TABLE (ACPI_ADR_SPACE_TYPE) 8 +#define ACPI_ADR_SPACE_FIXED_HARDWARE (ACPI_ADR_SPACE_TYPE) 127 + + +/* + * BitRegister IDs + * + * These values are intended to be used by the hardware interfaces + * and are mapped to individual bitfields defined within the ACPI + * registers. See the AcpiGbl_BitRegisterInfo global table in utglobal.c + * for this mapping. + */ + +/* PM1 Status register */ + +#define ACPI_BITREG_TIMER_STATUS 0x00 +#define ACPI_BITREG_BUS_MASTER_STATUS 0x01 +#define ACPI_BITREG_GLOBAL_LOCK_STATUS 0x02 +#define ACPI_BITREG_POWER_BUTTON_STATUS 0x03 +#define ACPI_BITREG_SLEEP_BUTTON_STATUS 0x04 +#define ACPI_BITREG_RT_CLOCK_STATUS 0x05 +#define ACPI_BITREG_WAKE_STATUS 0x06 +#define ACPI_BITREG_PCIEXP_WAKE_STATUS 0x07 + +/* PM1 Enable register */ + +#define ACPI_BITREG_TIMER_ENABLE 0x08 +#define ACPI_BITREG_GLOBAL_LOCK_ENABLE 0x09 +#define ACPI_BITREG_POWER_BUTTON_ENABLE 0x0A +#define ACPI_BITREG_SLEEP_BUTTON_ENABLE 0x0B +#define ACPI_BITREG_RT_CLOCK_ENABLE 0x0C +#define ACPI_BITREG_PCIEXP_WAKE_DISABLE 0x0D + +/* PM1 Control register */ + +#define ACPI_BITREG_SCI_ENABLE 0x0E +#define ACPI_BITREG_BUS_MASTER_RLD 0x0F +#define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x10 +#define ACPI_BITREG_SLEEP_TYPE 0x11 +#define ACPI_BITREG_SLEEP_ENABLE 0x12 + +/* PM2 Control register */ + +#define ACPI_BITREG_ARB_DISABLE 0x13 + +#define ACPI_BITREG_MAX 0x13 +#define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 + + +/* Status register values. A 1 clears a status bit. 0 = no effect */ + +#define ACPI_CLEAR_STATUS 1 + +/* Enable and Control register values */ + +#define ACPI_ENABLE_EVENT 1 +#define ACPI_DISABLE_EVENT 0 + + +/* + * External ACPI object definition + */ + +/* + * Note: Type == ACPI_TYPE_ANY (0) is used to indicate a NULL package element + * or an unresolved named reference. + */ +typedef union acpi_object +{ + ACPI_OBJECT_TYPE Type; /* See definition of AcpiNsType for values */ + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_INTEGER */ + ACPI_INTEGER Value; /* The actual number */ + } Integer; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_STRING */ + UINT32 Length; /* # of bytes in string, excluding trailing null */ + char *Pointer; /* points to the string value */ + } String; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_BUFFER */ + UINT32 Length; /* # of bytes in buffer */ + UINT8 *Pointer; /* points to the buffer */ + } Buffer; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_PACKAGE */ + UINT32 Count; /* # of elements in package */ + union acpi_object *Elements; /* Pointer to an array of ACPI_OBJECTs */ + } Package; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_LOCAL_REFERENCE */ + ACPI_OBJECT_TYPE ActualType; /* Type associated with the Handle */ + ACPI_HANDLE Handle; /* object reference */ + } Reference; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_PROCESSOR */ + UINT32 ProcId; + ACPI_IO_ADDRESS PblkAddress; + UINT32 PblkLength; + } Processor; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_POWER */ + UINT32 SystemLevel; + UINT32 ResourceOrder; + } PowerResource; + +} ACPI_OBJECT; + + +/* + * List of objects, used as a parameter list for control method evaluation + */ +typedef struct acpi_object_list +{ + UINT32 Count; + ACPI_OBJECT *Pointer; + +} ACPI_OBJECT_LIST; + + +/* + * Miscellaneous common Data Structures used by the interfaces + */ +#define ACPI_NO_BUFFER 0 +#define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (-1) +#define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (-2) + +typedef struct acpi_buffer +{ + ACPI_SIZE Length; /* Length in bytes of the buffer */ + void *Pointer; /* pointer to buffer */ + +} ACPI_BUFFER; + + +/* + * NameType for AcpiGetName + */ +#define ACPI_FULL_PATHNAME 0 +#define ACPI_SINGLE_NAME 1 +#define ACPI_NAME_TYPE_MAX 1 + + +/* + * Predefined Namespace items + */ +typedef struct acpi_predefined_names +{ + char *Name; + UINT8 Type; + char *Val; + +} ACPI_PREDEFINED_NAMES; + + +/* + * Structure and flags for AcpiGetSystemInfo + */ +#define ACPI_SYS_MODE_UNKNOWN 0x0000 +#define ACPI_SYS_MODE_ACPI 0x0001 +#define ACPI_SYS_MODE_LEGACY 0x0002 +#define ACPI_SYS_MODES_MASK 0x0003 + + +/* + * System info returned by AcpiGetSystemInfo() + */ +typedef struct acpi_system_info +{ + UINT32 AcpiCaVersion; + UINT32 Flags; + UINT32 TimerResolution; + UINT32 Reserved1; + UINT32 Reserved2; + UINT32 DebugLevel; + UINT32 DebugLayer; + +} ACPI_SYSTEM_INFO; + + +/* + * System statistics returned by AcpiGetStatistics() + */ +typedef struct acpi_statistics +{ + UINT32 SciCount; + UINT32 GpeCount; + UINT32 FixedEventCount[ACPI_NUM_FIXED_EVENTS]; + UINT32 MethodCount; + +} ACPI_STATISTICS; + + +/* Table Event Types */ + +#define ACPI_TABLE_EVENT_LOAD 0x0 +#define ACPI_TABLE_EVENT_UNLOAD 0x1 +#define ACPI_NUM_TABLE_EVENTS 2 + + +/* + * Types specific to the OS service interfaces + */ +typedef UINT32 +(ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) ( + void *Context); + +typedef void +(ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) ( + void *Context); + +/* + * Various handlers and callback procedures + */ +typedef +UINT32 (*ACPI_EVENT_HANDLER) ( + void *Context); + +typedef +void (*ACPI_NOTIFY_HANDLER) ( + ACPI_HANDLE Device, + UINT32 Value, + void *Context); + +typedef +void (*ACPI_OBJECT_HANDLER) ( + ACPI_HANDLE Object, + void *Data); + +typedef +ACPI_STATUS (*ACPI_INIT_HANDLER) ( + ACPI_HANDLE Object, + UINT32 Function); + +#define ACPI_INIT_DEVICE_INI 1 + +typedef +ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) ( + ACPI_STATUS AmlStatus, + ACPI_NAME Name, + UINT16 Opcode, + UINT32 AmlOffset, + void *Context); + +/* Table Event handler (Load, LoadTable, etc.) and types */ + +typedef +ACPI_STATUS (*ACPI_TABLE_HANDLER) ( + UINT32 Event, + void *Table, + void *Context); + +#define ACPI_TABLE_LOAD 0x0 +#define ACPI_TABLE_UNLOAD 0x1 +#define ACPI_NUM_TABLE_EVENTS 2 + + +/* Address Spaces (For Operation Regions) */ + +typedef +ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +#define ACPI_DEFAULT_HANDLER NULL + +typedef +ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) ( + ACPI_HANDLE RegionHandle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +#define ACPI_REGION_ACTIVATE 0 +#define ACPI_REGION_DEACTIVATE 1 + +typedef +ACPI_STATUS (*ACPI_WALK_CALLBACK) ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + +/* Interrupt handler return values */ + +#define ACPI_INTERRUPT_NOT_HANDLED 0x00 +#define ACPI_INTERRUPT_HANDLED 0x01 + +/* Length of 32-bit EISAID values when converted back to a string */ + +#define ACPI_EISAID_STRING_SIZE 8 /* Includes null terminator */ + +/* Length of UUID (string) values */ + +#define ACPI_UUID_LENGTH 16 + + +/* Structures used for device/processor HID, UID, CID */ + +typedef struct acpi_device_id +{ + UINT32 Length; /* Length of string + null */ + char *String; + +} ACPI_DEVICE_ID; + +typedef struct acpi_device_id_list +{ + UINT32 Count; /* Number of IDs in Ids array */ + UINT32 ListSize; /* Size of list, including ID strings */ + ACPI_DEVICE_ID Ids[1]; /* ID array */ + +} ACPI_DEVICE_ID_LIST; + +/* + * Structure returned from AcpiGetObjectInfo. + * Optimized for both 32- and 64-bit builds + */ +typedef struct acpi_device_info +{ + UINT32 InfoSize; /* Size of info, including ID strings */ + UINT32 Name; /* ACPI object Name */ + ACPI_OBJECT_TYPE Type; /* ACPI object Type */ + UINT8 ParamCount; /* If a method, required parameter count */ + UINT8 Valid; /* Indicates which optional fields are valid */ + UINT8 Flags; /* Miscellaneous info */ + UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ + UINT8 LowestDstates[5]; /* _SxW values: 0xFF indicates not valid */ + UINT32 CurrentStatus; /* _STA value */ + ACPI_INTEGER Address; /* _ADR value */ + ACPI_DEVICE_ID HardwareId; /* _HID value */ + ACPI_DEVICE_ID UniqueId; /* _UID value */ + ACPI_DEVICE_ID_LIST CompatibleIdList; /* _CID list */ + +} ACPI_DEVICE_INFO; + +/* Values for Flags field above (AcpiGetObjectInfo) */ + +#define ACPI_PCI_ROOT_BRIDGE 0x01 + +/* Flags for Valid field above (AcpiGetObjectInfo) */ + +#define ACPI_VALID_STA 0x01 +#define ACPI_VALID_ADR 0x02 +#define ACPI_VALID_HID 0x04 +#define ACPI_VALID_UID 0x08 +#define ACPI_VALID_CID 0x10 +#define ACPI_VALID_SXDS 0x20 +#define ACPI_VALID_SXWS 0x40 + +/* Flags for _STA method */ + +#define ACPI_STA_DEVICE_PRESENT 0x01 +#define ACPI_STA_DEVICE_ENABLED 0x02 +#define ACPI_STA_DEVICE_UI 0x04 +#define ACPI_STA_DEVICE_FUNCTIONING 0x08 +#define ACPI_STA_DEVICE_OK 0x08 /* Synonym */ +#define ACPI_STA_BATTERY_PRESENT 0x10 + + +/* Context structs for address space handlers */ + +typedef struct acpi_pci_id +{ + UINT16 Segment; + UINT16 Bus; + UINT16 Device; + UINT16 Function; + +} ACPI_PCI_ID; + +typedef struct acpi_mem_space_context +{ + UINT32 Length; + ACPI_PHYSICAL_ADDRESS Address; + ACPI_PHYSICAL_ADDRESS MappedPhysicalAddress; + UINT8 *MappedLogicalAddress; + ACPI_SIZE MappedLength; + +} ACPI_MEM_SPACE_CONTEXT; + + +/* + * ACPI_MEMORY_LIST is used only if the ACPICA local cache is enabled + */ +typedef struct acpi_memory_list +{ + char *ListName; + void *ListHead; + UINT16 ObjectSize; + UINT16 MaxDepth; + UINT16 CurrentDepth; + UINT16 LinkOffset; + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Statistics for debug memory tracking only */ + + UINT32 TotalAllocated; + UINT32 TotalFreed; + UINT32 MaxOccupied; + UINT32 TotalSize; + UINT32 CurrentTotalSize; + UINT32 Requests; + UINT32 Hits; +#endif + +} ACPI_MEMORY_LIST; + + +#endif /* __ACTYPES_H__ */ diff --git a/drivers/bus/acpi/acpica/include/acutils.h b/drivers/bus/acpi/acpica/include/acutils.h new file mode 100644 index 00000000000..3e12b7ca361 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/acutils.h @@ -0,0 +1,963 @@ +/****************************************************************************** + * + * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACUTILS_H +#define _ACUTILS_H + + +extern const UINT8 AcpiGbl_ResourceAmlSizes[]; + +/* Strings used by the disassembler and debugger resource dump routines */ + +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) + +extern const char *AcpiGbl_BmDecode[]; +extern const char *AcpiGbl_ConfigDecode[]; +extern const char *AcpiGbl_ConsumeDecode[]; +extern const char *AcpiGbl_DecDecode[]; +extern const char *AcpiGbl_HeDecode[]; +extern const char *AcpiGbl_IoDecode[]; +extern const char *AcpiGbl_LlDecode[]; +extern const char *AcpiGbl_MaxDecode[]; +extern const char *AcpiGbl_MemDecode[]; +extern const char *AcpiGbl_MinDecode[]; +extern const char *AcpiGbl_MtpDecode[]; +extern const char *AcpiGbl_RngDecode[]; +extern const char *AcpiGbl_RwDecode[]; +extern const char *AcpiGbl_ShrDecode[]; +extern const char *AcpiGbl_SizDecode[]; +extern const char *AcpiGbl_TrsDecode[]; +extern const char *AcpiGbl_TtpDecode[]; +extern const char *AcpiGbl_TypDecode[]; +#endif + +/* Types for Resource descriptor entries */ + +#define ACPI_INVALID_RESOURCE 0 +#define ACPI_FIXED_LENGTH 1 +#define ACPI_VARIABLE_LENGTH 2 +#define ACPI_SMALL_VARIABLE_LENGTH 3 + +typedef +ACPI_STATUS (*ACPI_WALK_AML_CALLBACK) ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context); + +typedef +ACPI_STATUS (*ACPI_PKG_CALLBACK) ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +typedef struct acpi_pkg_info +{ + UINT8 *FreeSpace; + ACPI_SIZE Length; + UINT32 ObjectSpace; + UINT32 NumPackages; + +} ACPI_PKG_INFO; + +#define REF_INCREMENT (UINT16) 0 +#define REF_DECREMENT (UINT16) 1 +#define REF_FORCE_DELETE (UINT16) 2 + +/* AcpiUtDumpBuffer */ + +#define DB_BYTE_DISPLAY 1 +#define DB_WORD_DISPLAY 2 +#define DB_DWORD_DISPLAY 4 +#define DB_QWORD_DISPLAY 8 + + +/* + * utglobal - Global data structures and procedures + */ +ACPI_STATUS +AcpiUtInitGlobals ( + void); + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +char * +AcpiUtGetMutexName ( + UINT32 MutexId); + +const char * +AcpiUtGetNotifyName ( + UINT32 NotifyValue); + +#endif + +char * +AcpiUtGetTypeName ( + ACPI_OBJECT_TYPE Type); + +char * +AcpiUtGetNodeName ( + void *Object); + +char * +AcpiUtGetDescriptorName ( + void *Object); + +const char * +AcpiUtGetReferenceName ( + ACPI_OPERAND_OBJECT *Object); + +char * +AcpiUtGetObjectTypeName ( + ACPI_OPERAND_OBJECT *ObjDesc); + +char * +AcpiUtGetRegionName ( + UINT8 SpaceId); + +char * +AcpiUtGetEventName ( + UINT32 EventId); + +char +AcpiUtHexToAsciiChar ( + ACPI_INTEGER Integer, + UINT32 Position); + +BOOLEAN +AcpiUtValidObjectType ( + ACPI_OBJECT_TYPE Type); + + +/* + * utinit - miscellaneous initialization and shutdown + */ +ACPI_STATUS +AcpiUtHardwareInitialize ( + void); + +void +AcpiUtSubsystemShutdown ( + void); + + +/* + * utclib - Local implementations of C library functions + */ +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +ACPI_SIZE +AcpiUtStrlen ( + const char *String); + +char * +AcpiUtStrcpy ( + char *DstString, + const char *SrcString); + +char * +AcpiUtStrncpy ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count); + +int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count); + +int +AcpiUtStrncmp ( + const char *String1, + const char *String2, + ACPI_SIZE Count); + +int +AcpiUtStrcmp ( + const char *String1, + const char *String2); + +char * +AcpiUtStrcat ( + char *DstString, + const char *SrcString); + +char * +AcpiUtStrncat ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count); + +UINT32 +AcpiUtStrtoul ( + const char *String, + char **Terminator, + UINT32 Base); + +char * +AcpiUtStrstr ( + char *String1, + char *String2); + +void * +AcpiUtMemcpy ( + void *Dest, + const void *Src, + ACPI_SIZE Count); + +void * +AcpiUtMemset ( + void *Dest, + UINT8 Value, + ACPI_SIZE Count); + +int +AcpiUtToUpper ( + int c); + +int +AcpiUtToLower ( + int c); + +extern const UINT8 _acpi_ctype[]; + +#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ +#define _ACPI_XS 0x40 /* extra space */ +#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ +#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ +#define _ACPI_DI 0x04 /* '0'-'9' */ +#define _ACPI_LO 0x02 /* 'a'-'z' */ +#define _ACPI_PU 0x10 /* punctuation */ +#define _ACPI_SP 0x08 /* space */ +#define _ACPI_UP 0x01 /* 'A'-'Z' */ +#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ + +#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) +#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) +#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) +#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) +#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) +#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) +#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) + +#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ + +#define ACPI_IS_ASCII(c) ((c) < 0x80) + + +/* + * utcopy - Object construction and conversion interfaces + */ +ACPI_STATUS +AcpiUtBuildSimpleObject( + ACPI_OPERAND_OBJECT *Obj, + ACPI_OBJECT *UserObj, + UINT8 *DataSpace, + UINT32 *BufferSpaceUsed); + +ACPI_STATUS +AcpiUtBuildPackageObject ( + ACPI_OPERAND_OBJECT *Obj, + UINT8 *Buffer, + UINT32 *SpaceUsed); + +ACPI_STATUS +AcpiUtCopyIobjectToEobject ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiUtCopyEobjectToIobject ( + ACPI_OBJECT *Obj, + ACPI_OPERAND_OBJECT **InternalObj); + +ACPI_STATUS +AcpiUtCopyISimpleToIsimple ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj); + +ACPI_STATUS +AcpiUtCopyIobjectToIobject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **DestDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * utcreate - Object creation + */ +ACPI_STATUS +AcpiUtUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + + +/* + * utdebug - Debug interfaces + */ +void +AcpiUtInitStackPtrTrace ( + void); + +void +AcpiUtTrackStackPtr ( + void); + +void +AcpiUtTrace ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId); + +void +AcpiUtTracePtr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + void *Pointer); + +void +AcpiUtTraceU32 ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT32 Integer); + +void +AcpiUtTraceStr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + char *String); + +void +AcpiUtExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId); + +void +AcpiUtStatusExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_STATUS Status); + +void +AcpiUtValueExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_INTEGER Value); + +void +AcpiUtPtrExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT8 *Ptr); + +void +AcpiUtDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 componentId); + +void +AcpiUtDumpBuffer2 ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display); + +void +AcpiUtReportError ( + char *ModuleName, + UINT32 LineNumber); + +void +AcpiUtReportInfo ( + char *ModuleName, + UINT32 LineNumber); + +void +AcpiUtReportWarning ( + char *ModuleName, + UINT32 LineNumber); + +/* + * utdelete - Object deletion and reference counts + */ +void +AcpiUtAddReference ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtRemoveReference ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtDeleteInternalPackageObject ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtDeleteInternalSimpleObject ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList); + + +/* + * uteval - object evaluation + */ +ACPI_STATUS +AcpiUtOsiImplementation ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiUtEvaluateObject ( + ACPI_NAMESPACE_NODE *PrefixNode, + char *Path, + UINT32 ExpectedReturnBtypes, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiUtEvaluateNumericObject ( + char *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Value); + +ACPI_STATUS +AcpiUtExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *StatusFlags); + +ACPI_STATUS +AcpiUtExecutePowerMethods ( + ACPI_NAMESPACE_NODE *DeviceNode, + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues); + + +/* + * utids - device ID support + */ +ACPI_STATUS +AcpiUtExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId); + +ACPI_STATUS +AcpiUtExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId); + +ACPI_STATUS +AcpiUtExecute_CID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID_LIST **ReturnCidList); + + +/* + * utlock - reader/writer locks + */ +ACPI_STATUS +AcpiUtCreateRwLock ( + ACPI_RW_LOCK *Lock); + +void +AcpiUtDeleteRwLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtAcquireReadLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtReleaseReadLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtAcquireWriteLock ( + ACPI_RW_LOCK *Lock); + +void +AcpiUtReleaseWriteLock ( + ACPI_RW_LOCK *Lock); + + +/* + * utobject - internal object create/delete/cache routines + */ +ACPI_OPERAND_OBJECT * +AcpiUtCreateInternalObjectDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + ACPI_OBJECT_TYPE Type); + +void * +AcpiUtAllocateObjectDescDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +#define AcpiUtCreateInternalObject(t) AcpiUtCreateInternalObjectDbg (_AcpiModuleName,__LINE__,_COMPONENT,t) +#define AcpiUtAllocateObjectDesc() AcpiUtAllocateObjectDescDbg (_AcpiModuleName,__LINE__,_COMPONENT) + +void +AcpiUtDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object); + +BOOLEAN +AcpiUtValidInternalObject ( + void *Object); + +ACPI_OPERAND_OBJECT * +AcpiUtCreatePackageObject ( + UINT32 Count); + +ACPI_OPERAND_OBJECT * +AcpiUtCreateIntegerObject ( + UINT64 Value); + +ACPI_OPERAND_OBJECT * +AcpiUtCreateBufferObject ( + ACPI_SIZE BufferSize); + +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize); + +ACPI_STATUS +AcpiUtGetObjectSize( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + + +/* + * utstate - Generic state creation/cache routines + */ +void +AcpiUtPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State); + +ACPI_GENERIC_STATE * +AcpiUtPopGenericState ( + ACPI_GENERIC_STATE **ListHead); + + +ACPI_GENERIC_STATE * +AcpiUtCreateGenericState ( + void); + +ACPI_THREAD_STATE * +AcpiUtCreateThreadState ( + void); + +ACPI_GENERIC_STATE * +AcpiUtCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + +ACPI_GENERIC_STATE * +AcpiUtCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index); + +ACPI_STATUS +AcpiUtCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList); + +ACPI_STATUS +AcpiUtCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList); + +ACPI_GENERIC_STATE * +AcpiUtCreateControlState ( + void); + +void +AcpiUtDeleteGenericState ( + ACPI_GENERIC_STATE *State); + + +/* + * utmath + */ +ACPI_STATUS +AcpiUtDivide ( + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, + ACPI_INTEGER *OutQuotient, + ACPI_INTEGER *OutRemainder); + +ACPI_STATUS +AcpiUtShortDivide ( + ACPI_INTEGER InDividend, + UINT32 Divisor, + ACPI_INTEGER *OutQuotient, + UINT32 *OutRemainder); + +/* + * utmisc + */ +const char * +AcpiUtValidateException ( + ACPI_STATUS Status); + +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id); + +BOOLEAN +AcpiUtIsAmlTable ( + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AcpiUtAllocateOwnerId ( + ACPI_OWNER_ID *OwnerId); + +void +AcpiUtReleaseOwnerId ( + ACPI_OWNER_ID *OwnerId); + +ACPI_STATUS +AcpiUtWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context); + +void +AcpiUtStrupr ( + char *SrcString); + +void +AcpiUtPrintString ( + char *String, + UINT8 MaxLength); + +BOOLEAN +AcpiUtValidAcpiName ( + UINT32 Name); + +void +AcpiUtRepairName ( + char *Name); + +BOOLEAN +AcpiUtValidAcpiChar ( + char Character, + UINT32 Position); + +ACPI_STATUS +AcpiUtStrtoul64 ( + char *String, + UINT32 Base, + ACPI_INTEGER *RetInteger); + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedWarning ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...); + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedInfo ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...); + +/* Values for Base above (16=Hex, 10=Decimal) */ + +#define ACPI_ANY_BASE 0 + +UINT32 +AcpiUtDwordByteSwap ( + UINT32 Value); + +void +AcpiUtSetIntegerWidth ( + UINT8 Revision); + +#ifdef ACPI_DEBUG_OUTPUT +void +AcpiUtDisplayInitPathname ( + UINT8 Type, + ACPI_NAMESPACE_NODE *ObjHandle, + char *Path); +#endif + + +/* + * utresrc + */ +ACPI_STATUS +AcpiUtWalkAmlResources ( + UINT8 *Aml, + ACPI_SIZE AmlLength, + ACPI_WALK_AML_CALLBACK UserFunction, + void *Context); + +ACPI_STATUS +AcpiUtValidateResource ( + void *Aml, + UINT8 *ReturnIndex); + +UINT32 +AcpiUtGetDescriptorLength ( + void *Aml); + +UINT16 +AcpiUtGetResourceLength ( + void *Aml); + +UINT8 +AcpiUtGetResourceHeaderLength ( + void *Aml); + +UINT8 +AcpiUtGetResourceType ( + void *Aml); + +ACPI_STATUS +AcpiUtGetResourceEndTag ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 **EndTag); + + +/* + * utmutex - mutex support + */ +ACPI_STATUS +AcpiUtMutexInitialize ( + void); + +void +AcpiUtMutexTerminate ( + void); + +ACPI_STATUS +AcpiUtAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiUtReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/* + * utalloc - memory allocation and object caching + */ +ACPI_STATUS +AcpiUtCreateCaches ( + void); + +ACPI_STATUS +AcpiUtDeleteCaches ( + void); + +ACPI_STATUS +AcpiUtValidateBuffer ( + ACPI_BUFFER *Buffer); + +ACPI_STATUS +AcpiUtInitializeBuffer ( + ACPI_BUFFER *Buffer, + ACPI_SIZE RequiredLength); + +void * +AcpiUtAllocate ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +void * +AcpiUtAllocateZeroed ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +void * +AcpiUtAllocateAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +void * +AcpiUtAllocateZeroedAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +void +AcpiUtFreeAndTrack ( + void *Address, + UINT32 Component, + const char *Module, + UINT32 Line); + +void +AcpiUtDumpAllocationInfo ( + void); + +void +AcpiUtDumpAllocations ( + UINT32 Component, + const char *Module); + +ACPI_STATUS +AcpiUtCreateList ( + char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache); + + +#endif + +#endif /* _ACUTILS_H */ diff --git a/drivers/bus/acpi/acpica/include/amlcode.h b/drivers/bus/acpi/acpica/include/amlcode.h new file mode 100644 index 00000000000..19740d9083c --- /dev/null +++ b/drivers/bus/acpi/acpica/include/amlcode.h @@ -0,0 +1,595 @@ +/****************************************************************************** + * + * Name: amlcode.h - Definitions for AML, as included in "definition blocks" + * Declarations and definitions contained herein are derived + * directly from the ACPI specification. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __AMLCODE_H__ +#define __AMLCODE_H__ + +/* primary opcodes */ + +#define AML_NULL_CHAR (UINT16) 0x00 + +#define AML_ZERO_OP (UINT16) 0x00 +#define AML_ONE_OP (UINT16) 0x01 +#define AML_UNASSIGNED (UINT16) 0x02 +#define AML_ALIAS_OP (UINT16) 0x06 +#define AML_NAME_OP (UINT16) 0x08 +#define AML_BYTE_OP (UINT16) 0x0a +#define AML_WORD_OP (UINT16) 0x0b +#define AML_DWORD_OP (UINT16) 0x0c +#define AML_STRING_OP (UINT16) 0x0d +#define AML_QWORD_OP (UINT16) 0x0e /* ACPI 2.0 */ +#define AML_SCOPE_OP (UINT16) 0x10 +#define AML_BUFFER_OP (UINT16) 0x11 +#define AML_PACKAGE_OP (UINT16) 0x12 +#define AML_VAR_PACKAGE_OP (UINT16) 0x13 /* ACPI 2.0 */ +#define AML_METHOD_OP (UINT16) 0x14 +#define AML_DUAL_NAME_PREFIX (UINT16) 0x2e +#define AML_MULTI_NAME_PREFIX_OP (UINT16) 0x2f +#define AML_NAME_CHAR_SUBSEQ (UINT16) 0x30 +#define AML_NAME_CHAR_FIRST (UINT16) 0x41 +#define AML_EXTENDED_OP_PREFIX (UINT16) 0x5b +#define AML_ROOT_PREFIX (UINT16) 0x5c +#define AML_PARENT_PREFIX (UINT16) 0x5e +#define AML_LOCAL_OP (UINT16) 0x60 +#define AML_LOCAL0 (UINT16) 0x60 +#define AML_LOCAL1 (UINT16) 0x61 +#define AML_LOCAL2 (UINT16) 0x62 +#define AML_LOCAL3 (UINT16) 0x63 +#define AML_LOCAL4 (UINT16) 0x64 +#define AML_LOCAL5 (UINT16) 0x65 +#define AML_LOCAL6 (UINT16) 0x66 +#define AML_LOCAL7 (UINT16) 0x67 +#define AML_ARG_OP (UINT16) 0x68 +#define AML_ARG0 (UINT16) 0x68 +#define AML_ARG1 (UINT16) 0x69 +#define AML_ARG2 (UINT16) 0x6a +#define AML_ARG3 (UINT16) 0x6b +#define AML_ARG4 (UINT16) 0x6c +#define AML_ARG5 (UINT16) 0x6d +#define AML_ARG6 (UINT16) 0x6e +#define AML_STORE_OP (UINT16) 0x70 +#define AML_REF_OF_OP (UINT16) 0x71 +#define AML_ADD_OP (UINT16) 0x72 +#define AML_CONCAT_OP (UINT16) 0x73 +#define AML_SUBTRACT_OP (UINT16) 0x74 +#define AML_INCREMENT_OP (UINT16) 0x75 +#define AML_DECREMENT_OP (UINT16) 0x76 +#define AML_MULTIPLY_OP (UINT16) 0x77 +#define AML_DIVIDE_OP (UINT16) 0x78 +#define AML_SHIFT_LEFT_OP (UINT16) 0x79 +#define AML_SHIFT_RIGHT_OP (UINT16) 0x7a +#define AML_BIT_AND_OP (UINT16) 0x7b +#define AML_BIT_NAND_OP (UINT16) 0x7c +#define AML_BIT_OR_OP (UINT16) 0x7d +#define AML_BIT_NOR_OP (UINT16) 0x7e +#define AML_BIT_XOR_OP (UINT16) 0x7f +#define AML_BIT_NOT_OP (UINT16) 0x80 +#define AML_FIND_SET_LEFT_BIT_OP (UINT16) 0x81 +#define AML_FIND_SET_RIGHT_BIT_OP (UINT16) 0x82 +#define AML_DEREF_OF_OP (UINT16) 0x83 +#define AML_CONCAT_RES_OP (UINT16) 0x84 /* ACPI 2.0 */ +#define AML_MOD_OP (UINT16) 0x85 /* ACPI 2.0 */ +#define AML_NOTIFY_OP (UINT16) 0x86 +#define AML_SIZE_OF_OP (UINT16) 0x87 +#define AML_INDEX_OP (UINT16) 0x88 +#define AML_MATCH_OP (UINT16) 0x89 +#define AML_CREATE_DWORD_FIELD_OP (UINT16) 0x8a +#define AML_CREATE_WORD_FIELD_OP (UINT16) 0x8b +#define AML_CREATE_BYTE_FIELD_OP (UINT16) 0x8c +#define AML_CREATE_BIT_FIELD_OP (UINT16) 0x8d +#define AML_TYPE_OP (UINT16) 0x8e +#define AML_CREATE_QWORD_FIELD_OP (UINT16) 0x8f /* ACPI 2.0 */ +#define AML_LAND_OP (UINT16) 0x90 +#define AML_LOR_OP (UINT16) 0x91 +#define AML_LNOT_OP (UINT16) 0x92 +#define AML_LEQUAL_OP (UINT16) 0x93 +#define AML_LGREATER_OP (UINT16) 0x94 +#define AML_LLESS_OP (UINT16) 0x95 +#define AML_TO_BUFFER_OP (UINT16) 0x96 /* ACPI 2.0 */ +#define AML_TO_DECSTRING_OP (UINT16) 0x97 /* ACPI 2.0 */ +#define AML_TO_HEXSTRING_OP (UINT16) 0x98 /* ACPI 2.0 */ +#define AML_TO_INTEGER_OP (UINT16) 0x99 /* ACPI 2.0 */ +#define AML_TO_STRING_OP (UINT16) 0x9c /* ACPI 2.0 */ +#define AML_COPY_OP (UINT16) 0x9d /* ACPI 2.0 */ +#define AML_MID_OP (UINT16) 0x9e /* ACPI 2.0 */ +#define AML_CONTINUE_OP (UINT16) 0x9f /* ACPI 2.0 */ +#define AML_IF_OP (UINT16) 0xa0 +#define AML_ELSE_OP (UINT16) 0xa1 +#define AML_WHILE_OP (UINT16) 0xa2 +#define AML_NOOP_OP (UINT16) 0xa3 +#define AML_RETURN_OP (UINT16) 0xa4 +#define AML_BREAK_OP (UINT16) 0xa5 +#define AML_BREAK_POINT_OP (UINT16) 0xcc +#define AML_ONES_OP (UINT16) 0xff + +/* prefixed opcodes */ + +#define AML_EXTENDED_OPCODE (UINT16) 0x5b00 /* prefix for 2-byte opcodes */ + +#define AML_MUTEX_OP (UINT16) 0x5b01 +#define AML_EVENT_OP (UINT16) 0x5b02 +#define AML_SHIFT_RIGHT_BIT_OP (UINT16) 0x5b10 +#define AML_SHIFT_LEFT_BIT_OP (UINT16) 0x5b11 +#define AML_COND_REF_OF_OP (UINT16) 0x5b12 +#define AML_CREATE_FIELD_OP (UINT16) 0x5b13 +#define AML_LOAD_TABLE_OP (UINT16) 0x5b1f /* ACPI 2.0 */ +#define AML_LOAD_OP (UINT16) 0x5b20 +#define AML_STALL_OP (UINT16) 0x5b21 +#define AML_SLEEP_OP (UINT16) 0x5b22 +#define AML_ACQUIRE_OP (UINT16) 0x5b23 +#define AML_SIGNAL_OP (UINT16) 0x5b24 +#define AML_WAIT_OP (UINT16) 0x5b25 +#define AML_RESET_OP (UINT16) 0x5b26 +#define AML_RELEASE_OP (UINT16) 0x5b27 +#define AML_FROM_BCD_OP (UINT16) 0x5b28 +#define AML_TO_BCD_OP (UINT16) 0x5b29 +#define AML_UNLOAD_OP (UINT16) 0x5b2a +#define AML_REVISION_OP (UINT16) 0x5b30 +#define AML_DEBUG_OP (UINT16) 0x5b31 +#define AML_FATAL_OP (UINT16) 0x5b32 +#define AML_TIMER_OP (UINT16) 0x5b33 /* ACPI 3.0 */ +#define AML_REGION_OP (UINT16) 0x5b80 +#define AML_FIELD_OP (UINT16) 0x5b81 +#define AML_DEVICE_OP (UINT16) 0x5b82 +#define AML_PROCESSOR_OP (UINT16) 0x5b83 +#define AML_POWER_RES_OP (UINT16) 0x5b84 +#define AML_THERMAL_ZONE_OP (UINT16) 0x5b85 +#define AML_INDEX_FIELD_OP (UINT16) 0x5b86 +#define AML_BANK_FIELD_OP (UINT16) 0x5b87 +#define AML_DATA_REGION_OP (UINT16) 0x5b88 /* ACPI 2.0 */ + + +/* + * Combination opcodes (actually two one-byte opcodes) + * Used by the disassembler and iASL compiler + */ +#define AML_LGREATEREQUAL_OP (UINT16) 0x9295 +#define AML_LLESSEQUAL_OP (UINT16) 0x9294 +#define AML_LNOTEQUAL_OP (UINT16) 0x9293 + + +/* + * Internal opcodes + * Use only "Unknown" AML opcodes, don't attempt to use + * any valid ACPI ASCII values (A-Z, 0-9, '-') + */ +#define AML_INT_NAMEPATH_OP (UINT16) 0x002d +#define AML_INT_NAMEDFIELD_OP (UINT16) 0x0030 +#define AML_INT_RESERVEDFIELD_OP (UINT16) 0x0031 +#define AML_INT_ACCESSFIELD_OP (UINT16) 0x0032 +#define AML_INT_BYTELIST_OP (UINT16) 0x0033 +#define AML_INT_STATICSTRING_OP (UINT16) 0x0034 +#define AML_INT_METHODCALL_OP (UINT16) 0x0035 +#define AML_INT_RETURN_VALUE_OP (UINT16) 0x0036 +#define AML_INT_EVAL_SUBTREE_OP (UINT16) 0x0037 + + +#define ARG_NONE 0x0 + +/* + * Argument types for the AML Parser + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types + * Zero is reserved as end-of-list indicator + */ +#define ARGP_BYTEDATA 0x01 +#define ARGP_BYTELIST 0x02 +#define ARGP_CHARLIST 0x03 +#define ARGP_DATAOBJ 0x04 +#define ARGP_DATAOBJLIST 0x05 +#define ARGP_DWORDDATA 0x06 +#define ARGP_FIELDLIST 0x07 +#define ARGP_NAME 0x08 +#define ARGP_NAMESTRING 0x09 +#define ARGP_OBJLIST 0x0A +#define ARGP_PKGLENGTH 0x0B +#define ARGP_SUPERNAME 0x0C +#define ARGP_TARGET 0x0D +#define ARGP_TERMARG 0x0E +#define ARGP_TERMLIST 0x0F +#define ARGP_WORDDATA 0x10 +#define ARGP_QWORDDATA 0x11 +#define ARGP_SIMPLENAME 0x12 + +/* + * Resolved argument types for the AML Interpreter + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types (0 is end-of-arg-list indicator) + * + * Note1: These values are completely independent from the ACPI_TYPEs + * i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER + * + * Note2: If and when 5 bits becomes insufficient, it would probably be best + * to convert to a 6-byte array of argument types, allowing 8 bits per argument. + */ + +/* Single, simple types */ + +#define ARGI_ANYTYPE 0x01 /* Don't care */ +#define ARGI_PACKAGE 0x02 +#define ARGI_EVENT 0x03 +#define ARGI_MUTEX 0x04 +#define ARGI_DDBHANDLE 0x05 + +/* Interchangeable types (via implicit conversion) */ + +#define ARGI_INTEGER 0x06 +#define ARGI_STRING 0x07 +#define ARGI_BUFFER 0x08 +#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */ +#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */ + +/* Reference objects */ + +#define ARGI_INTEGER_REF 0x0B +#define ARGI_OBJECT_REF 0x0C +#define ARGI_DEVICE_REF 0x0D +#define ARGI_REFERENCE 0x0E +#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ +#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ +#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ + +/* Multiple/complex types */ + +#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/ +#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ +#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ +#define ARGI_REGION_OR_BUFFER 0x15 /* Used by LOAD op only */ +#define ARGI_DATAREFOBJ 0x16 + +/* Note: types above can expand to 0x1F maximum */ + +#define ARGI_INVALID_OPCODE 0xFFFFFFFF + + +/* + * hash offsets + */ +#define AML_EXTOP_HASH_OFFSET 22 +#define AML_LNOT_HASH_OFFSET 19 + + +/* + * opcode groups and types + */ +#define OPGRP_NAMED 0x01 +#define OPGRP_FIELD 0x02 +#define OPGRP_BYTELIST 0x04 + + +/* + * Opcode information + */ + +/* Opcode flags */ + +#define AML_LOGICAL 0x0001 +#define AML_LOGICAL_NUMERIC 0x0002 +#define AML_MATH 0x0004 +#define AML_CREATE 0x0008 +#define AML_FIELD 0x0010 +#define AML_DEFER 0x0020 +#define AML_NAMED 0x0040 +#define AML_NSNODE 0x0080 +#define AML_NSOPCODE 0x0100 +#define AML_NSOBJECT 0x0200 +#define AML_HAS_RETVAL 0x0400 +#define AML_HAS_TARGET 0x0800 +#define AML_HAS_ARGS 0x1000 +#define AML_CONSTANT 0x2000 +#define AML_NO_OPERAND_RESOLVE 0x4000 + +/* Convenient flag groupings */ + +#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL +#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ +#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ +#define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET +#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Monadic2R */ +#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */ +#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */ +#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Dyadic2R */ +#define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL +#define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS +#define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL +#define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL + + +/* + * The opcode Type is used in a dispatch table, do not change + * without updating the table. + */ +#define AML_TYPE_EXEC_0A_0T_1R 0x00 +#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */ +#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */ +#define AML_TYPE_EXEC_1A_1T_0R 0x03 +#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* Monadic2R */ +#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */ +#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */ +#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* Dyadic2R */ +#define AML_TYPE_EXEC_2A_2T_1R 0x08 +#define AML_TYPE_EXEC_3A_0T_0R 0x09 +#define AML_TYPE_EXEC_3A_1T_1R 0x0A +#define AML_TYPE_EXEC_6A_0T_1R 0x0B +/* End of types used in dispatch table */ + +#define AML_TYPE_LITERAL 0x0B +#define AML_TYPE_CONSTANT 0x0C +#define AML_TYPE_METHOD_ARGUMENT 0x0D +#define AML_TYPE_LOCAL_VARIABLE 0x0E +#define AML_TYPE_DATA_TERM 0x0F + +/* Generic for an op that returns a value */ + +#define AML_TYPE_METHOD_CALL 0x10 + +/* Misc */ + +#define AML_TYPE_CREATE_FIELD 0x11 +#define AML_TYPE_CREATE_OBJECT 0x12 +#define AML_TYPE_CONTROL 0x13 +#define AML_TYPE_NAMED_NO_OBJ 0x14 +#define AML_TYPE_NAMED_FIELD 0x15 +#define AML_TYPE_NAMED_SIMPLE 0x16 +#define AML_TYPE_NAMED_COMPLEX 0x17 +#define AML_TYPE_RETURN 0x18 + +#define AML_TYPE_UNDEFINED 0x19 +#define AML_TYPE_BOGUS 0x1A + +/* AML Package Length encodings */ + +#define ACPI_AML_PACKAGE_TYPE1 0x40 +#define ACPI_AML_PACKAGE_TYPE2 0x4000 +#define ACPI_AML_PACKAGE_TYPE3 0x400000 +#define ACPI_AML_PACKAGE_TYPE4 0x40000000 + +/* + * Opcode classes + */ +#define AML_CLASS_EXECUTE 0x00 +#define AML_CLASS_CREATE 0x01 +#define AML_CLASS_ARGUMENT 0x02 +#define AML_CLASS_NAMED_OBJECT 0x03 +#define AML_CLASS_CONTROL 0x04 +#define AML_CLASS_ASCII 0x05 +#define AML_CLASS_PREFIX 0x06 +#define AML_CLASS_INTERNAL 0x07 +#define AML_CLASS_RETURN_VALUE 0x08 +#define AML_CLASS_METHOD_CALL 0x09 +#define AML_CLASS_UNKNOWN 0x0A + + +/* Predefined Operation Region SpaceIDs */ + +typedef enum +{ + REGION_MEMORY = 0, + REGION_IO, + REGION_PCI_CONFIG, + REGION_EC, + REGION_SMBUS, + REGION_CMOS, + REGION_PCI_BAR, + REGION_IPMI, + REGION_DATA_TABLE, /* Internal use only */ + REGION_FIXED_HW = 0x7F + +} AML_REGION_TYPES; + + +/* Comparison operation codes for MatchOp operator */ + +typedef enum +{ + MATCH_MTR = 0, + MATCH_MEQ = 1, + MATCH_MLE = 2, + MATCH_MLT = 3, + MATCH_MGE = 4, + MATCH_MGT = 5 + +} AML_MATCH_OPERATOR; + +#define MAX_MATCH_OPERATOR 5 + + +/* + * FieldFlags + * + * This byte is extracted from the AML and includes three separate + * pieces of information about the field: + * 1) The field access type + * 2) The field update rule + * 3) The lock rule for the field + * + * Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.) + * 04 : LockRule (1 == Lock) + * 05 - 06 : UpdateRule + */ +#define AML_FIELD_ACCESS_TYPE_MASK 0x0F +#define AML_FIELD_LOCK_RULE_MASK 0x10 +#define AML_FIELD_UPDATE_RULE_MASK 0x60 + + +/* 1) Field Access Types */ + +typedef enum +{ + AML_FIELD_ACCESS_ANY = 0x00, + AML_FIELD_ACCESS_BYTE = 0x01, + AML_FIELD_ACCESS_WORD = 0x02, + AML_FIELD_ACCESS_DWORD = 0x03, + AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */ + AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */ + +} AML_ACCESS_TYPE; + + +/* 2) Field Lock Rules */ + +typedef enum +{ + AML_FIELD_LOCK_NEVER = 0x00, + AML_FIELD_LOCK_ALWAYS = 0x10 + +} AML_LOCK_RULE; + + +/* 3) Field Update Rules */ + +typedef enum +{ + AML_FIELD_UPDATE_PRESERVE = 0x00, + AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20, + AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40 + +} AML_UPDATE_RULE; + + +/* + * Field Access Attributes. + * This byte is extracted from the AML via the + * AccessAs keyword + */ +typedef enum +{ + AML_FIELD_ATTRIB_SMB_QUICK = 0x02, + AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04, + AML_FIELD_ATTRIB_SMB_BYTE = 0x06, + AML_FIELD_ATTRIB_SMB_WORD = 0x08, + AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A, + AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C, + AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D + +} AML_ACCESS_ATTRIBUTE; + + +/* Bit fields in MethodFlags byte */ + +#define AML_METHOD_ARG_COUNT 0x07 +#define AML_METHOD_SERIALIZED 0x08 +#define AML_METHOD_SYNC_LEVEL 0xF0 + +/* METHOD_FLAGS_ARG_COUNT is not used internally, define additional flags */ + +#define AML_METHOD_INTERNAL_ONLY 0x01 +#define AML_METHOD_RESERVED1 0x02 +#define AML_METHOD_RESERVED2 0x04 + + +#endif /* __AMLCODE_H__ */ diff --git a/drivers/bus/acpi/acpica/include/amlresrc.h b/drivers/bus/acpi/acpica/include/amlresrc.h new file mode 100644 index 00000000000..689564c6289 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/amlresrc.h @@ -0,0 +1,485 @@ + +/****************************************************************************** + * + * Module Name: amlresrc.h - AML resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +#ifndef __AMLRESRC_H +#define __AMLRESRC_H + + +/* + * Resource descriptor tags, as defined in the ACPI specification. + * Used to symbolically reference fields within a descriptor. + */ +#define ACPI_RESTAG_ADDRESS "_ADR" +#define ACPI_RESTAG_ALIGNMENT "_ALN" +#define ACPI_RESTAG_ADDRESSSPACE "_ASI" +#define ACPI_RESTAG_ACCESSSIZE "_ASZ" +#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT" +#define ACPI_RESTAG_BASEADDRESS "_BAS" +#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */ +#define ACPI_RESTAG_DECODE "_DEC" +#define ACPI_RESTAG_DMA "_DMA" +#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ +#define ACPI_RESTAG_GRANULARITY "_GRA" +#define ACPI_RESTAG_INTERRUPT "_INT" +#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* ActiveLo(1), ActiveHi(0) */ +#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), NoShare(0) */ +#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ +#define ACPI_RESTAG_LENGTH "_LEN" +#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ +#define ACPI_RESTAG_MEMTYPE "_MEM" /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ +#define ACPI_RESTAG_MAXADDR "_MAX" +#define ACPI_RESTAG_MINADDR "_MIN" +#define ACPI_RESTAG_MAXTYPE "_MAF" +#define ACPI_RESTAG_MINTYPE "_MIF" +#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO" +#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW" +#define ACPI_RESTAG_RANGETYPE "_RNG" +#define ACPI_RESTAG_READWRITETYPE "_RW_" /* ReadOnly(0), Writeable (1) */ +#define ACPI_RESTAG_TRANSLATION "_TRA" +#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ +#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */ +#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */ + + +/* Default sizes for "small" resource descriptors */ + +#define ASL_RDESC_IRQ_SIZE 0x02 +#define ASL_RDESC_DMA_SIZE 0x02 +#define ASL_RDESC_ST_DEPEND_SIZE 0x00 +#define ASL_RDESC_END_DEPEND_SIZE 0x00 +#define ASL_RDESC_IO_SIZE 0x07 +#define ASL_RDESC_FIXED_IO_SIZE 0x03 +#define ASL_RDESC_END_TAG_SIZE 0x01 + + +typedef struct asl_resource_node +{ + UINT32 BufferLength; + void *Buffer; + struct asl_resource_node *Next; + +} ASL_RESOURCE_NODE; + + +/* Macros used to generate AML resource length fields */ + +#define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (AML_RESOURCE_LARGE_HEADER)) +#define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (AML_RESOURCE_SMALL_HEADER)) + +/* + * Resource descriptors defined in the ACPI specification. + * + * Packing/alignment must be BYTE because these descriptors + * are used to overlay the raw AML byte stream. + */ +#pragma pack(1) + +/* + * SMALL descriptors + */ +#define AML_RESOURCE_SMALL_HEADER_COMMON \ + UINT8 DescriptorType; + +typedef struct aml_resource_small_header +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_SMALL_HEADER; + + +typedef struct aml_resource_irq +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 IrqMask; + UINT8 Flags; + +} AML_RESOURCE_IRQ; + + +typedef struct aml_resource_irq_noflags +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 IrqMask; + +} AML_RESOURCE_IRQ_NOFLAGS; + + +typedef struct aml_resource_dma +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 DmaChannelMask; + UINT8 Flags; + +} AML_RESOURCE_DMA; + + +typedef struct aml_resource_start_dependent +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Flags; + +} AML_RESOURCE_START_DEPENDENT; + + +typedef struct aml_resource_start_dependent_noprio +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_START_DEPENDENT_NOPRIO; + + +typedef struct aml_resource_end_dependent +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_END_DEPENDENT; + + +typedef struct aml_resource_io +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; + UINT8 Alignment; + UINT8 AddressLength; + +} AML_RESOURCE_IO; + + +typedef struct aml_resource_fixed_io +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 Address; + UINT8 AddressLength; + +} AML_RESOURCE_FIXED_IO; + + +typedef struct aml_resource_vendor_small +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_VENDOR_SMALL; + + +typedef struct aml_resource_end_tag +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Checksum; + +} AML_RESOURCE_END_TAG; + + +/* + * LARGE descriptors + */ +#define AML_RESOURCE_LARGE_HEADER_COMMON \ + UINT8 DescriptorType;\ + UINT16 ResourceLength; + +typedef struct aml_resource_large_header +{ + AML_RESOURCE_LARGE_HEADER_COMMON + +} AML_RESOURCE_LARGE_HEADER; + + +typedef struct aml_resource_memory24 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; + +} AML_RESOURCE_MEMORY24; + + +typedef struct aml_resource_vendor_large +{ + AML_RESOURCE_LARGE_HEADER_COMMON + +} AML_RESOURCE_VENDOR_LARGE; + + +typedef struct aml_resource_memory32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; + +} AML_RESOURCE_MEMORY32; + + +typedef struct aml_resource_fixed_memory32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT32 Address; + UINT32 AddressLength; + +} AML_RESOURCE_FIXED_MEMORY32; + + +#define AML_RESOURCE_ADDRESS_COMMON \ + UINT8 ResourceType; \ + UINT8 Flags; \ + UINT8 SpecificFlags; + + +typedef struct aml_resource_address +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + +} AML_RESOURCE_ADDRESS; + + +typedef struct aml_resource_extended_address64 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT8 RevisionID; + UINT8 Reserved; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; + +} AML_RESOURCE_EXTENDED_ADDRESS64; + +#define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */ + + +typedef struct aml_resource_address64 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + +} AML_RESOURCE_ADDRESS64; + + +typedef struct aml_resource_address32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT32 Granularity; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; + UINT32 AddressLength; + +} AML_RESOURCE_ADDRESS32; + + +typedef struct aml_resource_address16 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; + +} AML_RESOURCE_ADDRESS16; + + +typedef struct aml_resource_extended_irq +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT8 InterruptCount; + UINT32 Interrupts[1]; + /* ResSourceIndex, ResSource optional fields follow */ + +} AML_RESOURCE_EXTENDED_IRQ; + + +typedef struct aml_resource_generic_register +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 AddressSpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; /* ACPI 3.0, was previously Reserved */ + UINT64 Address; + +} AML_RESOURCE_GENERIC_REGISTER; + +/* restore default alignment */ + +#pragma pack() + +/* Union of all resource descriptors, so we can allocate the worst case */ + +typedef union aml_resource +{ + /* Descriptor headers */ + + UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER SmallHeader; + AML_RESOURCE_LARGE_HEADER LargeHeader; + + /* Small resource descriptors */ + + AML_RESOURCE_IRQ Irq; + AML_RESOURCE_DMA Dma; + AML_RESOURCE_START_DEPENDENT StartDpf; + AML_RESOURCE_END_DEPENDENT EndDpf; + AML_RESOURCE_IO Io; + AML_RESOURCE_FIXED_IO FixedIo; + AML_RESOURCE_VENDOR_SMALL VendorSmall; + AML_RESOURCE_END_TAG EndTag; + + /* Large resource descriptors */ + + AML_RESOURCE_MEMORY24 Memory24; + AML_RESOURCE_GENERIC_REGISTER GenericReg; + AML_RESOURCE_VENDOR_LARGE VendorLarge; + AML_RESOURCE_MEMORY32 Memory32; + AML_RESOURCE_FIXED_MEMORY32 FixedMemory32; + AML_RESOURCE_ADDRESS16 Address16; + AML_RESOURCE_ADDRESS32 Address32; + AML_RESOURCE_ADDRESS64 Address64; + AML_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + AML_RESOURCE_EXTENDED_IRQ ExtendedIrq; + + /* Utility overlays */ + + AML_RESOURCE_ADDRESS Address; + UINT32 DwordItem; + UINT16 WordItem; + UINT8 ByteItem; + +} AML_RESOURCE; + +#endif + diff --git a/drivers/bus/acpi/acpica/include/platform/accygwin.h b/drivers/bus/acpi/acpica/include/platform/accygwin.h new file mode 100644 index 00000000000..e9585b44b10 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/accygwin.h @@ -0,0 +1,163 @@ +/****************************************************************************** + * + * Name: accygwin.h - OS specific defines, etc. for cygwin environment + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACCYGWIN_H__ +#define __ACCYGWIN_H__ + +/* + * ACPICA configuration + */ +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_DO_WHILE_0 +#define ACPI_THREAD_ID pthread_t +#define ACPI_FLUSH_CPU_CACHE() +/* + * This is needed since sem_timedwait does not appear to work properly + * on cygwin (always hangs forever). + */ +#define ACPI_USE_ALTERNATE_TIMEOUT + + +#include +#include +#include +#include +#include + +#if defined(__ia64__) || defined(__x86_64__) +#define ACPI_MACHINE_WIDTH 64 +#define COMPILER_DEPENDENT_INT64 long +#define COMPILER_DEPENDENT_UINT64 unsigned long +#else +#define ACPI_MACHINE_WIDTH 32 +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE +#endif + +#ifndef __cdecl +#define __cdecl +#endif + +#ifdef _ANSI +#define inline +#endif + + +/* Cygwin uses GCC */ + +#include "acgcc.h" + +#endif /* __ACCYGWIN_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acdos16.h b/drivers/bus/acpi/acpica/include/platform/acdos16.h new file mode 100644 index 00000000000..f3aead6084b --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acdos16.h @@ -0,0 +1,164 @@ +/****************************************************************************** + * + * Name: acdos16.h - DOS specific defines, etc. + * $Revision: 1.18 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACDOS16_H__ +#define __ACDOS16_H__ + + +/* NOTE: 16-bit ACPICA is no longer supported, December 2006 */ + +#define ACPI_USE_STANDARD_HEADERS +#define ACPI_MACHINE_WIDTH 16 + +/* Use a struct for 64-bit integers */ + +typedef struct +{ + unsigned long Lo; + unsigned long Hi; + +} COMPILER_DEPENDENT_UINT64; + +typedef struct +{ + long Lo; + long Hi; + +} COMPILER_DEPENDENT_INT64; + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE __cdecl +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE __cdecl + +#define ACPI_ASM_MACROS +#define BREAKPOINT3 +#define ACPI_DISABLE_IRQS() +#define ACPI_ENABLE_IRQS() +#define halt() +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) + + +#endif /* __ACDOS16_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acefi.h b/drivers/bus/acpi/acpica/include/platform/acefi.h new file mode 100644 index 00000000000..40afaa401cf --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acefi.h @@ -0,0 +1,147 @@ +/****************************************************************************** + * + * Name: acefi.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEFI_H__ +#define __ACEFI_H__ + +#include +#include +#include + + +/* _int64 works for both IA32 and IA64 */ + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +/* warn C4142: redefinition of type */ + +#pragma warning(disable:4142) + + +#endif /* __ACEFI_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acenv.h b/drivers/bus/acpi/acpica/include/platform/acenv.h new file mode 100644 index 00000000000..58cb03bfc1a --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acenv.h @@ -0,0 +1,432 @@ +/****************************************************************************** + * + * Name: acenv.h - Host and compiler configuration + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACENV_H__ +#define __ACENV_H__ + +/* + * Environment configuration. The purpose of this file is to interface ACPICA + * to the local environment. This includes compiler-specific, OS-specific, + * and machine-specific configuration. + */ + +/* Types for ACPI_MUTEX_TYPE */ + +#define ACPI_BINARY_SEMAPHORE 0 +#define ACPI_OSL_MUTEX 1 + +/* Types for DEBUGGER_THREADING */ + +#define DEBUGGER_SINGLE_THREADED 0 +#define DEBUGGER_MULTI_THREADED 1 + + +/****************************************************************************** + * + * Configuration for ACPI tools and utilities + * + *****************************************************************************/ + +/* iASL configuration */ + +#ifdef ACPI_ASL_COMPILER +#define ACPI_APPLICATION +#define ACPI_DISASSEMBLER +#define ACPI_DEBUG_OUTPUT +#define ACPI_CONSTANT_EVAL_ONLY +#define ACPI_LARGE_NAMESPACE_NODE +#define ACPI_DATA_TABLE_DISASSEMBLY +#endif + +/* AcpiExec configuration */ + +#ifdef ACPI_EXEC_APP +#define ACPI_APPLICATION +#define ACPI_FULL_DEBUG +#define ACPI_MUTEX_DEBUG +#define ACPI_DBG_TRACK_ALLOCATIONS +#endif + +/* Linkable ACPICA library */ + +#ifdef ACPI_LIBRARY +#define ACPI_USE_LOCAL_CACHE +#endif + +/* Common for all ACPICA applications */ + +#ifdef ACPI_APPLICATION +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_LOCAL_CACHE +#endif + +/* Common debug support */ + +#ifdef ACPI_FULL_DEBUG +#define ACPI_DEBUGGER +#define ACPI_DEBUG_OUTPUT +#define ACPI_DISASSEMBLER +#endif + + +/*! [Begin] no source code translation */ + +/****************************************************************************** + * + * Host configuration files. The compiler configuration files are included + * by the host files. + * + *****************************************************************************/ + +#if defined(_LINUX) || defined(__linux__) +#include "aclinux.h" + +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include "acfreebsd.h" + +#elif defined(__NetBSD__) +#include "acnetbsd.h" + +#elif defined(__sun) +#include "acsolaris.h" + +#elif defined(MODESTO) +#include "acmodesto.h" + +#elif defined(NETWARE) +#include "acnetware.h" + +#elif defined(_CYGWIN) +#include "accygwin.h" + +#elif defined(WIN32) +#include "acwin.h" + +#elif defined(WIN64) +#include "acwin64.h" + +#elif defined(_WRS_LIB_BUILD) +#include "acvxworks.h" + +#elif defined(__OS2__) +#include "acos2.h" + +#elif defined(_AED_EFI) +#include "acefi.h" + +#else + +/* Unknown environment */ + +#error Unknown target environment +#endif + +/*! [End] no source code translation !*/ + + +/****************************************************************************** + * + * Setup defaults for the required symbols that were not defined in one of + * the host/compiler files above. + * + *****************************************************************************/ + +/* 64-bit data types */ + +#ifndef COMPILER_DEPENDENT_INT64 +#define COMPILER_DEPENDENT_INT64 long long +#endif + +#ifndef COMPILER_DEPENDENT_UINT64 +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#endif + +/* Type of mutex supported by host. Default is binary semaphores. */ + +#ifndef ACPI_MUTEX_TYPE +#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE +#endif + +/* Global Lock acquire/release */ + +#ifndef ACPI_ACQUIRE_GLOBAL_LOCK +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) Acq = 1 +#endif + +#ifndef ACPI_RELEASE_GLOBAL_LOCK +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) Acq = 0 +#endif + +/* Flush CPU cache - used when going to sleep. Wbinvd or similar. */ + +#ifndef ACPI_FLUSH_CPU_CACHE +#define ACPI_FLUSH_CPU_CACHE() +#endif + +/* + * Configurable calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#ifndef ACPI_SYSTEM_XFACE +#define ACPI_SYSTEM_XFACE +#endif + +#ifndef ACPI_EXTERNAL_XFACE +#define ACPI_EXTERNAL_XFACE +#endif + +#ifndef ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#endif + +#ifndef ACPI_INTERNAL_VAR_XFACE +#define ACPI_INTERNAL_VAR_XFACE +#endif + +/* + * Debugger threading model + * Use single threaded if the entire subsystem is contained in an application + * Use multiple threaded when the subsystem is running in the kernel. + * + * By default the model is single threaded if ACPI_APPLICATION is set, + * multi-threaded if ACPI_APPLICATION is not set. + */ +#ifndef DEBUGGER_THREADING +#ifdef ACPI_APPLICATION +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED + +#else +#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED +#endif +#endif /* !DEBUGGER_THREADING */ + + +/****************************************************************************** + * + * C library configuration + * + *****************************************************************************/ + +/* + * ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library. + * Otherwise, local versions of string/memory functions will be used. + * ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and + * the standard header files may be used. + * + * The ACPICA subsystem only uses low level C library functions that do not call + * operating system services and may therefore be inlined in the code. + * + * It may be necessary to tailor these include files to the target + * generation environment. + */ +#ifdef ACPI_USE_SYSTEM_CLIBRARY + +/* Use the standard C library headers. We want to keep these to a minimum */ + +#ifdef ACPI_USE_STANDARD_HEADERS + +/* Use the standard headers from the standard locations */ + +#include +#include +#include +#include + +#endif /* ACPI_USE_STANDARD_HEADERS */ + +/* We will be linking to the standard Clib functions */ + +#define ACPI_STRSTR(s1,s2) strstr((s1), (s2)) +#define ACPI_STRCHR(s1,c) strchr((s1), (c)) +#define ACPI_STRLEN(s) (ACPI_SIZE) strlen((s)) +#define ACPI_STRCPY(d,s) (void) strcpy((d), (s)) +#define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRNCMP(d,s,n) strncmp((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRCMP(d,s) strcmp((d), (s)) +#define ACPI_STRCAT(d,s) (void) strcat((d), (s)) +#define ACPI_STRNCAT(d,s,n) strncat((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n)) +#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (ACPI_SIZE)(n)) +#define ACPI_TOUPPER(i) toupper((int) (i)) +#define ACPI_TOLOWER(i) tolower((int) (i)) +#define ACPI_IS_XDIGIT(i) isxdigit((int) (i)) +#define ACPI_IS_DIGIT(i) isdigit((int) (i)) +#define ACPI_IS_SPACE(i) isspace((int) (i)) +#define ACPI_IS_UPPER(i) isupper((int) (i)) +#define ACPI_IS_PRINT(i) isprint((int) (i)) +#define ACPI_IS_ALPHA(i) isalpha((int) (i)) + +#else + +/****************************************************************************** + * + * Not using native C library, use local implementations + * + *****************************************************************************/ + +/* + * Use local definitions of C library macros and functions. These function + * implementations may not be as efficient as an inline or assembly code + * implementation provided by a native C library, but they are functionally + * equivalent. + */ +#ifndef va_arg + +#ifndef _VALIST +#define _VALIST +typedef char *va_list; +#endif /* _VALIST */ + +/* Storage alignment properties */ + +#define _AUPBND (sizeof (ACPI_NATIVE_INT) - 1) +#define _ADNBND (sizeof (ACPI_NATIVE_INT) - 1) + +/* Variable argument list macro definitions */ + +#define _Bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) +#define va_arg(ap, T) (*(T *)(((ap) += (_Bnd (T, _AUPBND))) - (_Bnd (T,_ADNBND)))) +#define va_end(ap) (void) 0 +#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_Bnd (A,_AUPBND)))) + +#endif /* va_arg */ + +/* Use the local (ACPICA) definitions of the clib functions */ + +#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2)) +#define ACPI_STRCHR(s1,c) AcpiUtStrchr ((s1), (c)) +#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s)) +#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s)) +#define ACPI_STRNCPY(d,s,n) (void) AcpiUtStrncpy ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRNCMP(d,s,n) AcpiUtStrncmp ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s)) +#define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s)) +#define ACPI_STRNCAT(d,s,n) AcpiUtStrncat ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRTOUL(d,s,n) AcpiUtStrtoul ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMCMP(s1,s2,n) AcpiUtMemcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n)) +#define ACPI_MEMCPY(d,s,n) (void) AcpiUtMemcpy ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMSET(d,v,n) (void) AcpiUtMemset ((d), (v), (ACPI_SIZE)(n)) +#define ACPI_TOUPPER AcpiUtToUpper +#define ACPI_TOLOWER AcpiUtToLower + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + +#endif /* __ACENV_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acfreebsd.h b/drivers/bus/acpi/acpica/include/platform/acfreebsd.h new file mode 100644 index 00000000000..20c5687c20b --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acfreebsd.h @@ -0,0 +1,180 @@ +/****************************************************************************** + * + * Name: acfreebsd.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACFREEBSD_H__ +#define __ACFREEBSD_H__ + + +/* FreeBSD uses GCC */ + +#include "acgcc.h" +#include +#include + +#define ACPI_UINTPTR_T uintptr_t + +#define ACPI_USE_LOCAL_CACHE +#define ACPI_USE_SYSTEM_CLIBRARY + +#define __cdecl + +#ifdef _KERNEL + +#include +#include +#include +#include +#include + +#include "opt_acpi.h" + +#define ACPI_THREAD_ID lwpid_t + +#ifdef ACPI_DEBUG +#define ACPI_DEBUG_OUTPUT /* for backward compatibility */ +#define ACPI_DISASSEMBLER +#endif + +#ifdef ACPI_DEBUG_OUTPUT +#include "opt_ddb.h" +#ifdef DDB +#define ACPI_DEBUGGER +#endif /* DDB */ +#endif /* ACPI_DEBUG_OUTPUT */ + +#ifdef DEBUGGER_THREADING +#undef DEBUGGER_THREADING +#endif /* DEBUGGER_THREADING */ + +#define DEBUGGER_THREADING 0 /* integrated with DDB */ + +#else /* _KERNEL */ + +#if __STDC_HOSTED__ +#include +#endif + +#define ACPI_THREAD_ID pthread_t + +/* Not building kernel code, so use libc */ +#define ACPI_USE_STANDARD_HEADERS +#define ACPI_FLUSH_CPU_CACHE() + +#define __cli() +#define __sti() + +#endif /* _KERNEL */ + +#endif /* __ACFREEBSD_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acgcc.h b/drivers/bus/acpi/acpica/include/platform/acgcc.h new file mode 100644 index 00000000000..e517a23ae22 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acgcc.h @@ -0,0 +1,179 @@ +/****************************************************************************** + * + * Name: acgcc.h - GCC specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACGCC_H__ +#define __ACGCC_H__ + +/* Function name is used for debug output. Non-ANSI, compiler-dependent */ + +#define ACPI_GET_FUNCTION_NAME __FUNCTION__ + +/* + * This macro is used to tag functions as "printf-like" because + * some compilers (like GCC) can catch printf format string problems. + */ +#define ACPI_PRINTF_LIKE(c) __attribute__ ((__format__ (__printf__, c, c+1))) + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (for example, _AcpiModuleName). This allows us + * to to tell the compiler warning in a per-variable manner that a variable + * is unused. + */ +#define ACPI_UNUSED_VAR __attribute__ ((unused)) + +#define COMPILER_DEPENDENT_INT64 long long int +#define COMPILER_DEPENDENT_UINT64 unsigned long long int + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "btsl $0x1,%%edx;" \ + "adcl $0x0,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "cmpb $0x3,%%dl;" \ + "sbbl %%eax,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ + } while(0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "andl $0x1,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ + } while(0) + +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ +{ \ + q32 = n_hi / d32; \ + r32 = n_lo / d32; \ +} + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + n_hi >>= 1; \ + n_lo >>= 1; \ +} + +#endif /* __ACGCC_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acintel.h b/drivers/bus/acpi/acpica/include/platform/acintel.h new file mode 100644 index 00000000000..44197a09946 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acintel.h @@ -0,0 +1,168 @@ +/****************************************************************************** + * + * Name: acintel.h - VC specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACINTEL_H__ +#define __ACINTEL_H__ + + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +#define inline __inline + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +/* + * Math helper functions + */ +#define ACPI_DIV_64_BY_32(n, n_hi, n_lo, d32, q32, r32) \ +{ \ + q32 = n / d32; \ + r32 = n % d32; \ +} + +#define ACPI_SHIFT_RIGHT_64(n, n_hi, n_lo) \ +{ \ + n <<= 1; \ +} + +/* remark 981 - operands evaluated in no particular order */ +#pragma warning(disable:981) + +/* warn C4100: unreferenced formal parameter */ +#pragma warning(disable:4100) + +/* warn C4127: conditional expression is constant */ +#pragma warning(disable:4127) + +/* warn C4706: assignment within conditional expression */ +#pragma warning(disable:4706) + +/* warn C4214: bit field types other than int */ +#pragma warning(disable:4214) + + +#endif /* __ACINTEL_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/aclinux.h b/drivers/bus/acpi/acpica/include/platform/aclinux.h new file mode 100644 index 00000000000..c6f868cdbf9 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/aclinux.h @@ -0,0 +1,233 @@ +/****************************************************************************** + * + * Name: aclinux.h - OS specific defines, etc. for Linux + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACLINUX_H__ +#define __ACLINUX_H__ + +/* Common (in-kernel/user-space) ACPICA configuration */ + +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_DO_WHILE_0 +#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE + + +#ifdef __KERNEL__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Host-dependent types and defines for in-kernel ACPICA */ + +#define ACPI_MACHINE_WIDTH BITS_PER_LONG +#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); +#define strtoul simple_strtoul + +#define ACPI_CACHE_T struct kmem_cache +#define ACPI_SPINLOCK spinlock_t * +#define ACPI_CPU_FLAGS unsigned long +#define ACPI_THREAD_ID struct task_struct * + +#else /* !__KERNEL__ */ + +#include +#include +#include +#include +#include + +/* Host-dependent types and defines for user-space ACPICA */ + +#define ACPI_FLUSH_CPU_CACHE() +#define ACPI_THREAD_ID pthread_t + +#if defined(__ia64__) || defined(__x86_64__) +#define ACPI_MACHINE_WIDTH 64 +#define COMPILER_DEPENDENT_INT64 long +#define COMPILER_DEPENDENT_UINT64 unsigned long +#else +#define ACPI_MACHINE_WIDTH 32 +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE +#endif + +#ifndef __cdecl +#define __cdecl +#endif + +#endif /* __KERNEL__ */ + +/* Linux uses GCC */ + +#include "acgcc.h" + + +#ifdef __KERNEL__ +/* + * Overrides for in-kernel ACPICA + */ +static inline acpi_thread_id acpi_os_get_thread_id(void) +{ + return current; +} + +/* + * The irqs_disabled() check is for resume from RAM. + * Interrupts are off during resume, just like they are for boot. + * However, boot has (system_state != SYSTEM_RUNNING) + * to quiet __might_sleep() in kmalloc() and resume does not. + */ +#include +static inline void *acpi_os_allocate(acpi_size size) +{ + return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void *acpi_os_allocate_zeroed(acpi_size size) +{ + return kzalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void *acpi_os_acquire_object(acpi_cache_t * cache) +{ + return kmem_cache_zalloc(cache, + irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +#define ACPI_ALLOCATE(a) acpi_os_allocate(a) +#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a) +#define ACPI_FREE(a) kfree(a) + +/* Used within ACPICA to show where it is safe to preempt execution */ + +#define ACPI_PREEMPTION_POINT() \ + do { \ + if (!irqs_disabled()) \ + cond_resched(); \ + } while (0) + +#endif /* __KERNEL__ */ + +#endif /* __ACLINUX_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acmsvc.h b/drivers/bus/acpi/acpica/include/platform/acmsvc.h new file mode 100644 index 00000000000..ab9e75a88a8 --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acmsvc.h @@ -0,0 +1,249 @@ +/****************************************************************************** + * + * Name: acmsvc.h - VC specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACMSVC_H__ +#define __ACMSVC_H__ + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE __cdecl +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE __cdecl + +#ifndef _LINT +/* + * Math helper functions + */ +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ +{ \ + __asm mov edx, n_hi \ + __asm mov eax, n_lo \ + __asm div d32 \ + __asm mov q32, eax \ + __asm mov r32, edx \ +} + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + __asm shr n_hi, 1 \ + __asm rcr n_lo, 1 \ +} +#else + +/* Fake versions to make lint happy */ + +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ +{ \ + q32 = n_hi / d32; \ + r32 = n_lo / d32; \ +} + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + n_hi >>= 1; \ + n_lo >>= 1; \ +} +#endif + +/*! [Begin] no source code translation */ + +#ifdef ACPI_APPLICATION +#define ACPI_FLUSH_CPU_CACHE() +#else +#define ACPI_FLUSH_CPU_CACHE() __asm {WBINVD} +#endif + +#ifdef _DEBUG +#define ACPI_SIMPLE_RETURN_MACROS +#endif + +/*! [End] no source code translation !*/ + +/* + * Global Lock acquire/release code + * + * Note: Handles case where the FACS pointer is null + */ +#define ACPI_ACQUIRE_GLOBAL_LOCK(FacsPtr, Acq) __asm \ +{ \ + __asm mov eax, 0xFF \ + __asm mov ecx, FacsPtr \ + __asm or ecx, ecx \ + __asm jz exit_acq \ + __asm lea ecx, [ecx].GlobalLock \ + \ + __asm acq10: \ + __asm mov eax, [ecx] \ + __asm mov edx, eax \ + __asm and edx, 0xFFFFFFFE \ + __asm bts edx, 1 \ + __asm adc edx, 0 \ + __asm lock cmpxchg dword ptr [ecx], edx \ + __asm jnz acq10 \ + \ + __asm cmp dl, 3 \ + __asm sbb eax, eax \ + \ + __asm exit_acq: \ + __asm mov Acq, al \ +} + +#define ACPI_RELEASE_GLOBAL_LOCK(FacsPtr, Pnd) __asm \ +{ \ + __asm xor eax, eax \ + __asm mov ecx, FacsPtr \ + __asm or ecx, ecx \ + __asm jz exit_rel \ + __asm lea ecx, [ecx].GlobalLock \ + \ + __asm Rel10: \ + __asm mov eax, [ecx] \ + __asm mov edx, eax \ + __asm and edx, 0xFFFFFFFC \ + __asm lock cmpxchg dword ptr [ecx], edx \ + __asm jnz Rel10 \ + \ + __asm cmp dl, 3 \ + __asm and eax, 1 \ + \ + __asm exit_rel: \ + __asm mov Pnd, al \ +} + + +/* warn C4100: unreferenced formal parameter */ +#pragma warning(disable:4100) + +/* warn C4127: conditional expression is constant */ +#pragma warning(disable:4127) + +/* warn C4706: assignment within conditional expression */ +#pragma warning(disable:4706) + +/* warn C4131: uses old-style declarator (iASL compiler only) */ +#pragma warning(disable:4131) + + +#endif /* __ACMSVC_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acnetbsd.h b/drivers/bus/acpi/acpica/include/platform/acnetbsd.h new file mode 100644 index 00000000000..c04851b926a --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acnetbsd.h @@ -0,0 +1,188 @@ +/****************************************************************************** + * + * Name: acnetbsd.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACNETBSD_H__ +#define __ACNETBSD_H__ + +/* NetBSD uses GCC */ + +#include "acgcc.h" + +#ifdef _LP64 +#define ACPI_MACHINE_WIDTH 64 +#else +#define ACPI_MACHINE_WIDTH 32 +#endif + +#define COMPILER_DEPENDENT_INT64 int64_t +#define COMPILER_DEPENDENT_UINT64 uint64_t + +#ifdef _KERNEL +#include "opt_acpi.h" /* collect build-time options here */ + +#include +#include +#include +#include + +#define asm __asm + +#define ACPI_USE_NATIVE_DIVIDE + +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +#ifdef ACPI_DEBUG +#define ACPI_DEBUG_OUTPUT +#define ACPI_DBG_TRACK_ALLOCATIONS +#ifdef DEBUGGER_THREADING +#undef DEBUGGER_THREADING +#endif /* DEBUGGER_THREADING */ +#define DEBUGGER_THREADING 0 /* integrated with DDB */ +#include "opt_ddb.h" +#ifdef DDB +#define ACPI_DISASSEMBLER +#define ACPI_DEBUGGER +#endif /* DDB */ +#endif /* ACPI_DEBUG */ + +static __inline int +isprint(int ch) +{ + return(isspace(ch) || isascii(ch)); +} + +#else /* _KERNEL */ + +#include + +/* Not building kernel code, so use libc */ +#define ACPI_USE_STANDARD_HEADERS + +#define __cli() +#define __sti() + +/* XXX */ +#define __inline inline + +#endif /* _KERNEL */ + +/* Always use NetBSD code over our local versions */ +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_NATIVE_DIVIDE + +#endif /* __ACNETBSD_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acos2.h b/drivers/bus/acpi/acpica/include/platform/acos2.h new file mode 100644 index 00000000000..21e3373c24d --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acos2.h @@ -0,0 +1,172 @@ +/****************************************************************************** + * + * Name: acos2.h - OS/2 specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOS2_H__ +#define __ACOS2_H__ +#define INCL_LONGLONG +#include + + +#define ACPI_MACHINE_WIDTH 32 + +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE + +#define ACPI_SYSTEM_XFACE APIENTRY +#define ACPI_EXTERNAL_XFACE APIENTRY +#define ACPI_INTERNAL_XFACE APIENTRY +#define ACPI_INTERNAL_VAR_XFACE APIENTRY + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (most specifically for _THIS_MODULE). This allow us + * to to tell the compiler warning in a per-variable manner that a variable + * is unused. + */ +#define ACPI_UNUSED_VAR + +#define ACPI_USE_STANDARD_HEADERS +#include + +#define ACPI_FLUSH_CPU_CACHE() Wbinvd() +void Wbinvd(void); + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) Acq = OSPMAcquireGlobalLock(GLptr) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) Pnd = OSPMReleaseGlobalLock(GLptr) +unsigned short OSPMAcquireGlobalLock (void *); +unsigned short OSPMReleaseGlobalLock (void *); + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + unsigned long long val = 0LL; \ + val = n_lo | ( ((unsigned long long)h_hi) << 32 ); \ + __llrotr (val,1); \ + n_hi = (unsigned long)((val >> 32 ) & 0xffffffff ); \ + n_lo = (unsigned long)(val & 0xffffffff); \ +} + +/* IBM VAC does not have inline */ + +#if __IBMC__ || __IBMCPP__ +#define inline +#endif + +#ifndef ACPI_ASL_COMPILER +#define ACPI_USE_LOCAL_CACHE +#undef ACPI_DEBUGGER +#endif + +#endif /* __ACOS2_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acwin.h b/drivers/bus/acpi/acpica/include/platform/acwin.h new file mode 100644 index 00000000000..a1f6e856e6d --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acwin.h @@ -0,0 +1,157 @@ +/****************************************************************************** + * + * Name: acwin.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACWIN_H__ +#define __ACWIN_H__ + +/*! [Begin] no source code translation (Keep the include) */ + +/* Windows uses VC */ +#ifdef _MSC_VER +#include "acmsvc.h" +#elif __GNUC__ +#include "acgcc.h" +#endif + +/*! [End] no source code translation !*/ + +#define ACPI_MACHINE_WIDTH 32 + +#define inline __inline + +#define ACPI_USE_STANDARD_HEADERS + +#ifdef ACPI_DEFINE_ALTERNATE_TYPES +/* + * Types used only in (Linux) translated source, defined here to enable + * cross-platform compilation (i.e., generate the Linux code on Windows, + * for test purposes only) + */ +typedef int s32; +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef COMPILER_DEPENDENT_UINT64 u64; +#endif + +/* + * Handle platform- and compiler-specific assembly language differences. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + +#endif /* __ACWIN_H__ */ diff --git a/drivers/bus/acpi/acpica/include/platform/acwin64.h b/drivers/bus/acpi/acpica/include/platform/acwin64.h new file mode 100644 index 00000000000..faec855e22d --- /dev/null +++ b/drivers/bus/acpi/acpica/include/platform/acwin64.h @@ -0,0 +1,155 @@ +/****************************************************************************** + * + * Name: acwin.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACWIN64_H__ +#define __ACWIN64_H__ + +/*! [Begin] no source code translation (Keep the include) */ + +#include "acintel.h" +/*! [End] no source code translation !*/ + +#define ACPI_MACHINE_WIDTH 64 + +#define ACPI_USE_STANDARD_HEADERS + +/* + * Handle platform- and compiler-specific assembly language differences. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + +/*! [Begin] no source code translation */ + +#define ACPI_FLUSH_CPU_CACHE() + +/* + * For Acpi applications, we don't want to try to access the global lock + */ +#ifdef ACPI_APPLICATION +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) if (AcpiGbl_GlobalLockPresent) {Acq = 0xFF;} else {Acq = 0;} +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) if (AcpiGbl_GlobalLockPresent) {Pnd = 0xFF;} else {Pnd = 0;} +#else + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) + +#endif + + +#endif /* __ACWIN_H__ */ diff --git a/drivers/bus/acpi/acpica/namespace/nsaccess.c b/drivers/bus/acpi/acpica/namespace/nsaccess.c new file mode 100644 index 00000000000..2bc7d8d7118 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsaccess.c @@ -0,0 +1,772 @@ +/******************************************************************************* + * + * Module Name: nsaccess - Top-level functions for accessing ACPI namespace + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSACCESS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdispat.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsaccess") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRootInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Allocate and initialize the default root named objects + * + * MUTEX: Locks namespace for entire execution + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRootInitialize ( + void) +{ + ACPI_STATUS Status; + const ACPI_PREDEFINED_NAMES *InitVal = NULL; + ACPI_NAMESPACE_NODE *NewNode; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STRING Val = NULL; + + + ACPI_FUNCTION_TRACE (NsRootInitialize); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The global root ptr is initially NULL, so a non-NULL value indicates + * that AcpiNsRootInitialize() has already been called; just return. + */ + if (AcpiGbl_RootNode) + { + Status = AE_OK; + goto UnlockAndExit; + } + + /* + * Tell the rest of the subsystem that the root is initialized + * (This is OK because the namespace is locked) + */ + AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct; + + /* Enter the pre-defined names in the name table */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Entering predefined entries into namespace\n")); + + for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) + { + /* _OSI is optional for now, will be permanent later */ + + if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) + { + continue; + } + + Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, + ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, + NULL, &NewNode); + + if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create predefined name %s", + InitVal->Name)); + } + + /* + * Name entered successfully. If entry in PreDefinedNames[] specifies + * an initial value, create the initial value. + */ + if (InitVal->Val) + { + Status = AcpiOsPredefinedOverride (InitVal, &Val); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not override predefined %s", + InitVal->Name)); + } + + if (!Val) + { + Val = InitVal->Val; + } + + /* + * Entry requests an initial value, allocate a + * descriptor for it. + */ + ObjDesc = AcpiUtCreateInternalObject (InitVal->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* + * Convert value string from table entry to + * internal representation. Only types actually + * used for initial values are implemented here. + */ + switch (InitVal->Type) + { + case ACPI_TYPE_METHOD: + ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val); + ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; + +#if defined (ACPI_ASL_COMPILER) + + /* Save the parameter count for the iASL compiler */ + + NewNode->Value = ObjDesc->Method.ParamCount; +#else + /* Mark this as a very SPECIAL method */ + + ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY; + ObjDesc->Method.Extra.Implementation = AcpiUtOsiImplementation; +#endif + break; + + case ACPI_TYPE_INTEGER: + + ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val); + break; + + + case ACPI_TYPE_STRING: + + /* Build an object around the static string */ + + ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val); + ObjDesc->String.Pointer = Val; + ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; + break; + + + case ACPI_TYPE_MUTEX: + + ObjDesc->Mutex.Node = NewNode; + ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1); + + /* Create a mutex */ + + Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + goto UnlockAndExit; + } + + /* Special case for ACPI Global Lock */ + + if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) + { + AcpiGbl_GlobalLockMutex = ObjDesc; + + /* Create additional counting semaphore for global lock */ + + Status = AcpiOsCreateSemaphore ( + 1, 0, &AcpiGbl_GlobalLockSemaphore); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + goto UnlockAndExit; + } + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unsupported initial type value %X", + InitVal->Type)); + AcpiUtRemoveReference (ObjDesc); + ObjDesc = NULL; + continue; + } + + /* Store pointer to value descriptor in the Node */ + + Status = AcpiNsAttachObject (NewNode, ObjDesc, + ObjDesc->Common.Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + } + } + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Save a handle to "_GPE", it is always present */ + + if (ACPI_SUCCESS (Status)) + { + Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH, + &AcpiGbl_FadtGpeDevice); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsLookup + * + * PARAMETERS: ScopeInfo - Current scope info block + * Pathname - Search pathname, in internal format + * (as represented in the AML stream) + * Type - Type associated with name + * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found + * Flags - Flags describing the search restrictions + * WalkState - Current state of the walk + * ReturnNode - Where the Node is placed (if found + * or created successfully) + * + * RETURN: Status + * + * DESCRIPTION: Find or enter the passed name in the name space. + * Log an error if name not found in Exec mode. + * + * MUTEX: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + char *Pathname, + ACPI_OBJECT_TYPE Type, + ACPI_INTERPRETER_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + char *Path = Pathname; + ACPI_NAMESPACE_NODE *PrefixNode; + ACPI_NAMESPACE_NODE *CurrentNode = NULL; + ACPI_NAMESPACE_NODE *ThisNode = NULL; + UINT32 NumSegments; + UINT32 NumCarats; + ACPI_NAME SimpleName; + ACPI_OBJECT_TYPE TypeToCheckFor; + ACPI_OBJECT_TYPE ThisSearchType; + UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT; + UINT32 LocalFlags; + + + ACPI_FUNCTION_TRACE (NsLookup); + + + if (!ReturnNode) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT); + *ReturnNode = ACPI_ENTRY_NOT_FOUND; + AcpiGbl_NsLookupCount++; + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + /* Get the prefix scope. A null scope means use the root scope */ + + if ((!ScopeInfo) || + (!ScopeInfo->Scope.Node)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Null scope prefix, using root node (%p)\n", + AcpiGbl_RootNode)); + + PrefixNode = AcpiGbl_RootNode; + } + else + { + PrefixNode = ScopeInfo->Scope.Node; + if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]", + PrefixNode, AcpiUtGetDescriptorName (PrefixNode))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE)) + { + /* + * This node might not be a actual "scope" node (such as a + * Device/Method, etc.) It could be a Package or other object + * node. Backup up the tree to find the containing scope node. + */ + while (!AcpiNsOpensScope (PrefixNode->Type) && + PrefixNode->Type != ACPI_TYPE_ANY) + { + PrefixNode = AcpiNsGetParentNode (PrefixNode); + } + } + } + + /* Save type. TBD: may be no longer necessary */ + + TypeToCheckFor = Type; + + /* + * Begin examination of the actual pathname + */ + if (!Pathname) + { + /* A Null NamePath is allowed and refers to the root */ + + NumSegments = 0; + ThisNode = AcpiGbl_RootNode; + Path = ""; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Null Pathname (Zero segments), Flags=%X\n", Flags)); + } + else + { + /* + * Name pointer is valid (and must be in internal name format) + * + * Check for scope prefixes: + * + * As represented in the AML stream, a namepath consists of an + * optional scope prefix followed by a name segment part. + * + * If present, the scope prefix is either a Root Prefix (in + * which case the name is fully qualified), or one or more + * Parent Prefixes (in which case the name's scope is relative + * to the current scope). + */ + if (*Path == (UINT8) AML_ROOT_PREFIX) + { + /* Pathname is fully qualified, start from the root */ + + ThisNode = AcpiGbl_RootNode; + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* Point to name segment part */ + + Path++; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Path is absolute from root [%p]\n", ThisNode)); + } + else + { + /* Pathname is relative to current scope, start there */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching relative to prefix scope [%4.4s] (%p)\n", + AcpiUtGetNodeName (PrefixNode), PrefixNode)); + + /* + * Handle multiple Parent Prefixes (carat) by just getting + * the parent node for each prefix instance. + */ + ThisNode = PrefixNode; + NumCarats = 0; + while (*Path == (UINT8) AML_PARENT_PREFIX) + { + /* Name is fully qualified, no search rules apply */ + + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* + * Point past this prefix to the name segment + * part or the next Parent Prefix + */ + Path++; + + /* Backup to the parent node */ + + NumCarats++; + ThisNode = AcpiNsGetParentNode (ThisNode); + if (!ThisNode) + { + /* Current scope has no parent scope */ + + ACPI_ERROR ((AE_INFO, + "ACPI path has too many parent prefixes (^) " + "- reached beyond root node")); + return_ACPI_STATUS (AE_NOT_FOUND); + } + } + + if (SearchParentFlag == ACPI_NS_NO_UPSEARCH) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Search scope is [%4.4s], path has %d carat(s)\n", + AcpiUtGetNodeName (ThisNode), NumCarats)); + } + } + + /* + * Determine the number of ACPI name segments in this pathname. + * + * The segment part consists of either: + * - A Null name segment (0) + * - A DualNamePrefix followed by two 4-byte name segments + * - A MultiNamePrefix followed by a byte indicating the + * number of segments and the segments themselves. + * - A single 4-byte name segment + * + * Examine the name prefix opcode, if any, to determine the number of + * segments. + */ + switch (*Path) + { + case 0: + /* + * Null name after a root or parent prefixes. We already + * have the correct target node and there are no name segments. + */ + NumSegments = 0; + Type = ThisNode->Type; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Prefix-only Pathname (Zero name segments), Flags=%X\n", + Flags)); + break; + + case AML_DUAL_NAME_PREFIX: + + /* More than one NameSeg, search rules do not apply */ + + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* Two segments, point to first name segment */ + + NumSegments = 2; + Path++; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Dual Pathname (2 segments, Flags=%X)\n", Flags)); + break; + + case AML_MULTI_NAME_PREFIX_OP: + + /* More than one NameSeg, search rules do not apply */ + + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* Extract segment count, point to first name segment */ + + Path++; + NumSegments = (UINT32) (UINT8) *Path; + Path++; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Multi Pathname (%d Segments, Flags=%X)\n", + NumSegments, Flags)); + break; + + default: + /* + * Not a Null name, no Dual or Multi prefix, hence there is + * only one name segment and Pathname is already pointing to it. + */ + NumSegments = 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Simple Pathname (1 segment, Flags=%X)\n", Flags)); + break; + } + + ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path)); + } + + + /* + * Search namespace for each segment of the name. Loop through and + * verify (or add to the namespace) each name segment. + * + * The object type is significant only at the last name + * segment. (We don't care about the types along the path, only + * the type of the final target object.) + */ + ThisSearchType = ACPI_TYPE_ANY; + CurrentNode = ThisNode; + while (NumSegments && CurrentNode) + { + NumSegments--; + if (!NumSegments) + { + /* This is the last segment, enable typechecking */ + + ThisSearchType = Type; + + /* + * Only allow automatic parent search (search rules) if the caller + * requested it AND we have a single, non-fully-qualified NameSeg + */ + if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) && + (Flags & ACPI_NS_SEARCH_PARENT)) + { + LocalFlags |= ACPI_NS_SEARCH_PARENT; + } + + /* Set error flag according to caller */ + + if (Flags & ACPI_NS_ERROR_IF_FOUND) + { + LocalFlags |= ACPI_NS_ERROR_IF_FOUND; + } + } + + /* Extract one ACPI name from the front of the pathname */ + + ACPI_MOVE_32_TO_32 (&SimpleName, Path); + + /* Try to find the single (4 character) ACPI name */ + + Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, + InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + /* Name not found in ACPI namespace */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Name [%4.4s] not found in scope [%4.4s] %p\n", + (char *) &SimpleName, (char *) &CurrentNode->Name, + CurrentNode)); + } + + *ReturnNode = ThisNode; + return_ACPI_STATUS (Status); + } + + /* More segments to follow? */ + + if (NumSegments > 0) + { + /* + * If we have an alias to an object that opens a scope (such as a + * device or processor), we need to dereference the alias here so + * that we can access any children of the original node (via the + * remaining segments). + */ + if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS) + { + if (!ThisNode->Object) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *) + ThisNode->Object)->Type)) + { + ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object; + } + } + } + + /* Special handling for the last segment (NumSegments == 0) */ + + else + { + /* + * Sanity typecheck of the target object: + * + * If 1) This is the last segment (NumSegments == 0) + * 2) And we are looking for a specific type + * (Not checking for TYPE_ANY) + * 3) Which is not an alias + * 4) Which is not a local type (TYPE_SCOPE) + * 5) And the type of target object is known (not TYPE_ANY) + * 6) And target object does not match what we are looking for + * + * Then we have a type mismatch. Just warn and ignore it. + */ + if ((TypeToCheckFor != ACPI_TYPE_ANY) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) && + (ThisNode->Type != ACPI_TYPE_ANY) && + (ThisNode->Type != TypeToCheckFor)) + { + /* Complain about a type mismatch */ + + ACPI_WARNING ((AE_INFO, + "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)", + ACPI_CAST_PTR (char, &SimpleName), + AcpiUtGetTypeName (ThisNode->Type), + AcpiUtGetTypeName (TypeToCheckFor))); + } + + /* + * If this is the last name segment and we are not looking for a + * specific type, but the type of found object is known, use that + * type to (later) see if it opens a scope. + */ + if (Type == ACPI_TYPE_ANY) + { + Type = ThisNode->Type; + } + } + + /* Point to next name segment and make this node current */ + + Path += ACPI_NAME_SIZE; + CurrentNode = ThisNode; + } + + /* Always check if we need to open a new scope */ + + if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState)) + { + /* + * If entry is a type which opens a scope, push the new scope on the + * scope stack. + */ + if (AcpiNsOpensScope (Type)) + { + Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + *ReturnNode = ThisNode; + return_ACPI_STATUS (AE_OK); +} + diff --git a/drivers/bus/acpi/acpica/namespace/nsalloc.c b/drivers/bus/acpi/acpica/namespace/nsalloc.c new file mode 100644 index 00000000000..9693cb7835a --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsalloc.c @@ -0,0 +1,666 @@ +/******************************************************************************* + * + * Module Name: nsalloc - Namespace allocation and deletion utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSALLOC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsalloc") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCreateNode + * + * PARAMETERS: Name - Name of the new node (4 char ACPI name) + * + * RETURN: New namespace node (Null on failure) + * + * DESCRIPTION: Create a namespace node + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 Name) +{ + ACPI_NAMESPACE_NODE *Node; +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + UINT32 Temp; +#endif + + + ACPI_FUNCTION_TRACE (NsCreateNode); + + + Node = AcpiOsAcquireObject (AcpiGbl_NamespaceCache); + if (!Node) + { + return_PTR (NULL); + } + + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + Temp = AcpiGbl_NsNodeList->TotalAllocated - + AcpiGbl_NsNodeList->TotalFreed; + if (Temp > AcpiGbl_NsNodeList->MaxOccupied) + { + AcpiGbl_NsNodeList->MaxOccupied = Temp; + } +#endif + + Node->Name.Integer = Name; + ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED); + return_PTR (Node); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNode + * + * PARAMETERS: Node - Node to be deleted + * + * RETURN: None + * + * DESCRIPTION: Delete a namespace node. All node deletions must come through + * here. Detaches any attached objects, including any attached + * data. If a handler is associated with attached data, it is + * invoked before the node is deleted. + * + ******************************************************************************/ + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (NsDeleteNode); + + + /* Detach an object if there is one */ + + AcpiNsDetachObject (Node); + + /* + * Delete an attached data object if present (an object that was created + * and attached via AcpiAttachData). Note: After any normal object is + * detached above, the only possible remaining object is a data object. + */ + ObjDesc = Node->Object; + if (ObjDesc && + (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + /* Invoke the attached data deletion handler if present */ + + if (ObjDesc->Data.Handler) + { + ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer); + } + + AcpiUtRemoveReference (ObjDesc); + } + + /* Now we can delete the node */ + + (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node); + + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n", + Node, AcpiGbl_CurrentNodeCount)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRemoveNode + * + * PARAMETERS: Node - Node to be removed/deleted + * + * RETURN: None + * + * DESCRIPTION: Remove (unlink) and delete a namespace node + * + ******************************************************************************/ + +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *PrevNode; + ACPI_NAMESPACE_NODE *NextNode; + + + ACPI_FUNCTION_TRACE_PTR (NsRemoveNode, Node); + + + ParentNode = AcpiNsGetParentNode (Node); + + PrevNode = NULL; + NextNode = ParentNode->Child; + + /* Find the node that is the previous peer in the parent's child list */ + + while (NextNode != Node) + { + PrevNode = NextNode; + NextNode = PrevNode->Peer; + } + + if (PrevNode) + { + /* Node is not first child, unlink it */ + + PrevNode->Peer = NextNode->Peer; + if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + PrevNode->Flags |= ANOBJ_END_OF_PEER_LIST; + } + } + else + { + /* Node is first child (has no previous peer) */ + + if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + /* No peers at all */ + + ParentNode->Child = NULL; + } + else + { /* Link peer list to parent */ + + ParentNode->Child = NextNode->Peer; + } + } + + /* Delete the node and any attached objects */ + + AcpiNsDeleteNode (Node); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInstallNode + * + * PARAMETERS: WalkState - Current state of the walk + * ParentNode - The parent of the new Node + * Node - The new Node to install + * Type - ACPI object type of the new Node + * + * RETURN: None + * + * DESCRIPTION: Initialize a new namespace node and install it amongst + * its peers. + * + * Note: Current namespace lookup is linear search. This appears + * to be sufficient as namespace searches consume only a small + * fraction of the execution time of the ACPI subsystem. + * + ******************************************************************************/ + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ + ACPI_NAMESPACE_NODE *Node, /* New Child*/ + ACPI_OBJECT_TYPE Type) +{ + ACPI_OWNER_ID OwnerId = 0; + ACPI_NAMESPACE_NODE *ChildNode; + + + ACPI_FUNCTION_TRACE (NsInstallNode); + + + /* + * Get the owner ID from the Walk state. The owner ID is used to track + * table deletion and deletion of objects created by methods. + */ + if (WalkState) + { + OwnerId = WalkState->OwnerId; + } + + /* Link the new entry into the parent and existing children */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + ParentNode->Child = Node; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; + } + else + { + while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)) + { + ChildNode = ChildNode->Peer; + } + + ChildNode->Peer = Node; + + /* Clear end-of-list flag */ + + ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; + } + + /* Init the new entry */ + + Node->OwnerId = OwnerId; + Node->Type = (UINT8) Type; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId, + AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type), + ParentNode)); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteChildren + * + * PARAMETERS: ParentNode - Delete this objects children + * + * RETURN: None. + * + * DESCRIPTION: Delete all children of the parent object. In other words, + * deletes a "scope". + * + ******************************************************************************/ + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *NextNode; + UINT8 Flags; + + + ACPI_FUNCTION_TRACE_PTR (NsDeleteChildren, ParentNode); + + + if (!ParentNode) + { + return_VOID; + } + + /* If no children, all done! */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + return_VOID; + } + + /* Deallocate all children at this level */ + + do + { + /* Get the things we need */ + + NextNode = ChildNode->Peer; + Flags = ChildNode->Flags; + + /* Grandchildren should have all been deleted already */ + + if (ChildNode->Child) + { + ACPI_ERROR ((AE_INFO, "Found a grandchild! P=%p C=%p", + ParentNode, ChildNode)); + } + + /* + * Delete this child node and move on to the next child in the list. + * No need to unlink the node since we are deleting the entire branch. + */ + AcpiNsDeleteNode (ChildNode); + ChildNode = NextNode; + + } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); + + /* Clear the parent's child pointer */ + + ParentNode->Child = NULL; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceSubtree + * + * PARAMETERS: ParentNode - Root of the subtree to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Delete a subtree of the namespace. This includes all objects + * stored within the subtree. + * + ******************************************************************************/ + +void +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode = NULL; + UINT32 Level = 1; + + + ACPI_FUNCTION_TRACE (NsDeleteNamespaceSubtree); + + + if (!ParentNode) + { + return_VOID; + } + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + while (Level > 0) + { + /* Get the next node in this scope (NULL if none) */ + + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + if (ChildNode) + { + /* Found a child node - detach any attached object */ + + AcpiNsDetachObject (ChildNode); + + /* Check if this node has any children */ + + if (ChildNode->Child) + { + /* + * There is at least one child of this node, + * visit the node + */ + Level++; + ParentNode = ChildNode; + ChildNode = NULL; + } + } + else + { + /* + * No more children of this parent node. + * Move up to the grandparent. + */ + Level--; + + /* + * Now delete all of the children of this parent + * all at the same time. + */ + AcpiNsDeleteChildren (ParentNode); + + /* New "last child" is this parent node */ + + ChildNode = ParentNode; + + /* Move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentNode (ParentNode); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceByOwner + * + * PARAMETERS: OwnerId - All nodes with this owner will be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete entries within the namespace that are owned by a + * specific ID. Used to delete entire ACPI tables. All + * reference counts are updated. + * + * MUTEX: Locks namespace during deletion walk. + * + ******************************************************************************/ + +void +AcpiNsDeleteNamespaceByOwner ( + ACPI_OWNER_ID OwnerId) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *DeletionNode; + ACPI_NAMESPACE_NODE *ParentNode; + UINT32 Level; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_U32 (NsDeleteNamespaceByOwner, OwnerId); + + + if (OwnerId == 0) + { + return_VOID; + } + + /* Lock namespace for possible update */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + DeletionNode = NULL; + ParentNode = AcpiGbl_RootNode; + ChildNode = NULL; + Level = 1; + + /* + * Traverse the tree of nodes until we bubble back up + * to where we started. + */ + while (Level > 0) + { + /* + * Get the next child of this parent node. When ChildNode is NULL, + * the first child of the parent is returned + */ + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + + if (DeletionNode) + { + AcpiNsDeleteChildren (DeletionNode); + AcpiNsRemoveNode (DeletionNode); + DeletionNode = NULL; + } + + if (ChildNode) + { + if (ChildNode->OwnerId == OwnerId) + { + /* Found a matching child node - detach any attached object */ + + AcpiNsDetachObject (ChildNode); + } + + /* Check if this node has any children */ + + if (ChildNode->Child) + { + /* + * There is at least one child of this node, + * visit the node + */ + Level++; + ParentNode = ChildNode; + ChildNode = NULL; + } + else if (ChildNode->OwnerId == OwnerId) + { + DeletionNode = ChildNode; + } + } + else + { + /* + * No more children of this parent node. + * Move up to the grandparent. + */ + Level--; + if (Level != 0) + { + if (ParentNode->OwnerId == OwnerId) + { + DeletionNode = ParentNode; + } + } + + /* New "last child" is this parent node */ + + ChildNode = ParentNode; + + /* Move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentNode (ParentNode); + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_VOID; +} + + diff --git a/drivers/bus/acpi/acpica/namespace/nsdump.c b/drivers/bus/acpi/acpica/namespace/nsdump.c new file mode 100644 index 00000000000..d799f7c64ce --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsdump.c @@ -0,0 +1,826 @@ +/****************************************************************************** + * + * Module Name: nsdump - table dumping routines for debug + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSDUMP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsdump") + +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +void +AcpiNsDumpRootDevices ( + void); + +static ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); +#endif + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/******************************************************************************* + * + * FUNCTION: AcpiNsPrintPathname + * + * PARAMETERS: NumSegments - Number of ACPI name segments + * Pathname - The compressed (internal) path + * + * RETURN: None + * + * DESCRIPTION: Print an object's full namespace pathname + * + ******************************************************************************/ + +void +AcpiNsPrintPathname ( + UINT32 NumSegments, + char *Pathname) +{ + UINT32 i; + + + ACPI_FUNCTION_NAME (NsPrintPathname); + + + if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE)) + { + return; + } + + /* Print the entire name */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); + + while (NumSegments) + { + for (i = 0; i < 4; i++) + { + ACPI_IS_PRINT (Pathname[i]) ? + AcpiOsPrintf ("%c", Pathname[i]) : + AcpiOsPrintf ("?"); + } + + Pathname += ACPI_NAME_SIZE; + NumSegments--; + if (NumSegments) + { + AcpiOsPrintf ("."); + } + } + + AcpiOsPrintf ("]\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpPathname + * + * PARAMETERS: Handle - Object + * Msg - Prefix message + * Level - Desired debug level + * Component - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Print an object's full namespace pathname + * Manages allocation/freeing of a pathname buffer + * + ******************************************************************************/ + +void +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + char *Msg, + UINT32 Level, + UINT32 Component) +{ + + ACPI_FUNCTION_TRACE (NsDumpPathname); + + + /* Do this only if the requested debug level and component are enabled */ + + if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) + { + return_VOID; + } + + /* Convert handle to a full pathname and print it (with supplied message) */ + + AcpiNsPrintNodePathname (Handle, Msg); + AcpiOsPrintf ("\n"); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpOneObject + * + * PARAMETERS: ObjHandle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Dump a single Node + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDumpOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *ThisNode; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_OBJECT_TYPE ObjType; + ACPI_OBJECT_TYPE Type; + UINT32 BytesToDump; + UINT32 DbgLevel; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsDumpOneObject); + + + /* Is output enabled? */ + + if (!(AcpiDbgLevel & Info->DebugLevel)) + { + return (AE_OK); + } + + if (!ObjHandle) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); + return (AE_OK); + } + + ThisNode = AcpiNsValidateHandle (ObjHandle); + if (!ThisNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n", + ObjHandle)); + return (AE_OK); + } + + Type = ThisNode->Type; + + /* Check if the owner matches */ + + if ((Info->OwnerId != ACPI_OWNER_ID_MAX) && + (Info->OwnerId != ThisNode->OwnerId)) + { + return (AE_OK); + } + + if (!(Info->DisplayType & ACPI_DISPLAY_SHORT)) + { + /* Indent the object according to the level */ + + AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " "); + + /* Check the node type and name */ + + if (Type > ACPI_TYPE_LOCAL_MAX) + { + ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type %08X", Type)); + } + + AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode)); + } + + /* Now we can print out the pertinent information */ + + AcpiOsPrintf (" %-12s %p %2.2X ", + AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId); + + DbgLevel = AcpiDbgLevel; + AcpiDbgLevel = 0; + ObjDesc = AcpiNsGetAttachedObject (ThisNode); + AcpiDbgLevel = DbgLevel; + + /* Temp nodes are those nodes created by a control method */ + + if (ThisNode->Flags & ANOBJ_TEMPORARY) + { + AcpiOsPrintf ("(T) "); + } + + switch (Info->DisplayType & ACPI_DISPLAY_MASK) + { + case ACPI_DISPLAY_SUMMARY: + + if (!ObjDesc) + { + /* No attached object, we are done */ + + AcpiOsPrintf ("\n"); + return (AE_OK); + } + + switch (Type) + { + case ACPI_TYPE_PROCESSOR: + + AcpiOsPrintf ("ID %X Len %.4X Addr %p\n", + ObjDesc->Processor.ProcId, ObjDesc->Processor.Length, + ACPI_CAST_PTR (void, ObjDesc->Processor.Address)); + break; + + + case ACPI_TYPE_DEVICE: + + AcpiOsPrintf ("Notify Object: %p\n", ObjDesc); + break; + + + case ACPI_TYPE_METHOD: + + AcpiOsPrintf ("Args %X Len %.4X Aml %p\n", + (UINT32) ObjDesc->Method.ParamCount, + ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart); + break; + + + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("= %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_PACKAGE: + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + AcpiOsPrintf ("Elements %.2X\n", + ObjDesc->Package.Count); + } + else + { + AcpiOsPrintf ("[Length not yet evaluated]\n"); + } + break; + + + case ACPI_TYPE_BUFFER: + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + AcpiOsPrintf ("Len %.2X", + ObjDesc->Buffer.Length); + + /* Dump some of the buffer */ + + if (ObjDesc->Buffer.Length > 0) + { + AcpiOsPrintf (" ="); + for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++) + { + AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]); + } + } + AcpiOsPrintf ("\n"); + } + else + { + AcpiOsPrintf ("[Length not yet evaluated]\n"); + } + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length); + AcpiUtPrintString (ObjDesc->String.Pointer, 32); + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_REGION: + + AcpiOsPrintf ("[%s]", + AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); + if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) + { + AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n", + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length); + } + else + { + AcpiOsPrintf (" [Address/Length not yet evaluated]\n"); + } + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc)); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + if (ObjDesc->BufferField.BufferObj && + ObjDesc->BufferField.BufferObj->Buffer.Node) + { + AcpiOsPrintf ("Buf [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->BufferField.BufferObj->Buffer.Node)); + } + break; + + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + AcpiOsPrintf ("Rgn [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->CommonField.RegionObj->Region.Node)); + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->CommonField.RegionObj->Region.Node), + AcpiUtGetNodeName ( + ObjDesc->BankField.BankObj->CommonField.Node)); + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->IndexField.IndexObj->CommonField.Node), + AcpiUtGetNodeName ( + ObjDesc->IndexField.DataObj->CommonField.Node)); + break; + + + case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_METHOD_ALIAS: + + AcpiOsPrintf ("Target %4.4s (%p)\n", + AcpiUtGetNodeName (ObjDesc), ObjDesc); + break; + + default: + + AcpiOsPrintf ("Object %p\n", ObjDesc); + break; + } + + /* Common field handling */ + + switch (Type) + { + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n", + (ObjDesc->CommonField.BaseByteOffset * 8) + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessByteWidth); + break; + + default: + break; + } + break; + + + case ACPI_DISPLAY_OBJECTS: + + AcpiOsPrintf ("O:%p", ObjDesc); + if (!ObjDesc) + { + /* No attached object, we are done */ + + AcpiOsPrintf ("\n"); + return (AE_OK); + } + + AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount); + + switch (Type) + { + case ACPI_TYPE_METHOD: + + /* Name is a Method and its AML offset/length are set */ + + AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength); + break; + + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf (" I:%8.8X8.8%X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + case ACPI_TYPE_STRING: + + AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer, + ObjDesc->String.Length); + break; + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length); + break; + + default: + + AcpiOsPrintf ("\n"); + break; + } + break; + + + default: + AcpiOsPrintf ("\n"); + break; + } + + /* If debug turned off, done */ + + if (!(AcpiDbgLevel & ACPI_LV_VALUES)) + { + return (AE_OK); + } + + /* If there is an attached object, display it */ + + DbgLevel = AcpiDbgLevel; + AcpiDbgLevel = 0; + ObjDesc = AcpiNsGetAttachedObject (ThisNode); + AcpiDbgLevel = DbgLevel; + + /* Dump attached objects */ + + while (ObjDesc) + { + ObjType = ACPI_TYPE_INVALID; + AcpiOsPrintf ("Attached Object %p: ", ObjDesc); + + /* Decode the type of attached object and dump the contents */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_NAMED: + + AcpiOsPrintf ("(Ptr to Node)\n"); + BytesToDump = sizeof (ACPI_NAMESPACE_NODE); + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + break; + + case ACPI_DESC_TYPE_OPERAND: + + ObjType = ObjDesc->Common.Type; + + if (ObjType > ACPI_TYPE_LOCAL_MAX) + { + AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n", + ObjType); + BytesToDump = 32; + } + else + { + AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n", + ObjType, AcpiUtGetTypeName (ObjType)); + BytesToDump = sizeof (ACPI_OPERAND_OBJECT); + } + + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + break; + + default: + + break; + } + + /* If value is NOT an internal object, we are done */ + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + goto Cleanup; + } + + /* Valid object, get the pointer to next level, if any */ + + switch (ObjType) + { + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + /* + * NOTE: takes advantage of common fields between string/buffer + */ + BytesToDump = ObjDesc->String.Length; + ObjDesc = (void *) ObjDesc->String.Pointer; + AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n", + ObjDesc, BytesToDump); + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + goto Cleanup; + + case ACPI_TYPE_BUFFER_FIELD: + ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj; + break; + + case ACPI_TYPE_PACKAGE: + ObjDesc = (void *) ObjDesc->Package.Elements; + break; + + case ACPI_TYPE_METHOD: + ObjDesc = (void *) ObjDesc->Method.AmlStart; + break; + + case ACPI_TYPE_LOCAL_REGION_FIELD: + ObjDesc = (void *) ObjDesc->Field.RegionObj; + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + ObjDesc = (void *) ObjDesc->BankField.RegionObj; + break; + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + ObjDesc = (void *) ObjDesc->IndexField.IndexObj; + break; + + default: + goto Cleanup; + } + + ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ + } + +Cleanup: + AcpiOsPrintf ("\n"); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpObjects + * + * PARAMETERS: Type - Object type to be dumped + * DisplayType - 0 or ACPI_DISPLAY_SUMMARY + * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX + * for an effectively unlimited depth. + * OwnerId - Dump only objects owned by this ID. Use + * ACPI_UINT32_MAX to match all owners. + * StartHandle - Where in namespace to start/end search + * + * RETURN: None + * + * DESCRIPTION: Dump typed objects within the loaded namespace. Uses + * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. + * + ******************************************************************************/ + +void +AcpiNsDumpObjects ( + ACPI_OBJECT_TYPE Type, + UINT8 DisplayType, + UINT32 MaxDepth, + ACPI_OWNER_ID OwnerId, + ACPI_HANDLE StartHandle) +{ + ACPI_WALK_INFO Info; + + + ACPI_FUNCTION_ENTRY (); + + + Info.DebugLevel = ACPI_LV_TABLES; + Info.OwnerId = OwnerId; + Info.DisplayType = DisplayType; + + (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsDumpOneObject, NULL, (void *) &Info, NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpEntry + * + * PARAMETERS: Handle - Node to be dumped + * DebugLevel - Output level + * + * RETURN: None + * + * DESCRIPTION: Dump a single Node + * + ******************************************************************************/ + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel) +{ + ACPI_WALK_INFO Info; + + + ACPI_FUNCTION_ENTRY (); + + + Info.DebugLevel = DebugLevel; + Info.OwnerId = ACPI_OWNER_ID_MAX; + Info.DisplayType = ACPI_DISPLAY_SUMMARY; + + (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL); +} + + +#ifdef ACPI_ASL_COMPILER +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpTables + * + * PARAMETERS: SearchBase - Root of subtree to be dumped, or + * NS_ALL to dump the entire namespace + * MaxDepth - Maximum depth of dump. Use INT_MAX + * for an effectively unlimited depth. + * + * RETURN: None + * + * DESCRIPTION: Dump the name space, or a portion of it. + * + ******************************************************************************/ + +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth) +{ + ACPI_HANDLE SearchHandle = SearchBase; + + + ACPI_FUNCTION_TRACE (NsDumpTables); + + + if (!AcpiGbl_RootNode) + { + /* + * If the name space has not been initialized, + * there is nothing to dump. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); + return_VOID; + } + + if (ACPI_NS_ALL == SearchBase) + { + /* Entire namespace */ + + SearchHandle = AcpiGbl_RootNode; + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); + } + + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth, + ACPI_OWNER_ID_MAX, SearchHandle); + return_VOID; +} +#endif +#endif + diff --git a/drivers/bus/acpi/acpica/namespace/nsdumpdv.c b/drivers/bus/acpi/acpica/namespace/nsdumpdv.c new file mode 100644 index 00000000000..fbb66a61675 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsdumpdv.c @@ -0,0 +1,234 @@ +/****************************************************************************** + * + * Module Name: nsdump - table dumping routines for debug + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSDUMPDV_C__ + +#include "acpi.h" + + +/* TBD: This entire module is apparently obsolete and should be removed */ + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsdumpdv") + +#ifdef ACPI_OBSOLETE_FUNCTIONS +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +#include "acnamesp.h" + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpOneDevice + * + * PARAMETERS: Handle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Dump a single Node that represents a device + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_BUFFER Buffer; + ACPI_DEVICE_INFO *Info; + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsDumpOneDevice); + + + Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiGetObjectInfo (ObjHandle, &Buffer); + if (ACPI_SUCCESS (Status)) + { + Info = Buffer.Pointer; + for (i = 0; i < Level; i++) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, + " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", + Info->HardwareId.Value, ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus)); + ACPI_FREE (Info); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpRootDevices + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Dump all objects of type "device" + * + ******************************************************************************/ + +void +AcpiNsDumpRootDevices ( + void) +{ + ACPI_HANDLE SysBusHandle; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (NsDumpRootDevices); + + + /* Only dump the table if tracing is enabled */ + + if (!(ACPI_LV_TABLES & AcpiDbgLevel)) + { + return; + } + + Status = AcpiGetHandle (NULL, ACPI_NS_SYSTEM_BUS, &SysBusHandle); + if (ACPI_FAILURE (Status)) + { + return; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "Display of all devices in the namespace:\n")); + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiNsDumpOneDevice, NULL, NULL, NULL); +} + +#endif +#endif + + diff --git a/drivers/bus/acpi/acpica/namespace/nseval.c b/drivers/bus/acpi/acpica/namespace/nseval.c new file mode 100644 index 00000000000..07af96ed93d --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nseval.c @@ -0,0 +1,558 @@ +/******************************************************************************* + * + * Module Name: nseval - Object evaluation, includes control method execution + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSEVAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nseval") + +/* Local prototypes */ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsEvaluate + * + * PARAMETERS: Info - Evaluation info block, contains: + * PrefixNode - Prefix or Method/Object Node to execute + * Pathname - Name of method to execute, If NULL, the + * Node is the object to execute + * Parameters - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * Flags - ACPI_IGNORE_RETURN_VALUE to delete return + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method or return the current value of an + * ACPI namespace object. + * + * MUTEX: Locks interpreter + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsEvaluate ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (NsEvaluate); + + + if (!Info) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Initialize the return value to an invalid object */ + + Info->ReturnObject = NULL; + Info->ParamCount = 0; + + /* + * Get the actual namespace node for the target object. Handles these cases: + * + * 1) Null node, Pathname (absolute path) + * 2) Node, Pathname (path relative to Node) + * 3) Node, Null Pathname + */ + Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname, + ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * For a method alias, we must grab the actual method node so that proper + * scoping context will be established before execution. + */ + if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + { + Info->ResolvedNode = + ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname, + Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode))); + + Node = Info->ResolvedNode; + + /* + * Two major cases here: + * + * 1) The object is a control method -- execute it + * 2) The object is not a method -- just return it's current value + */ + if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD) + { + /* + * 1) Object is a control method - execute it + */ + + /* Verify that there is a method object associated with this node */ + + Info->ObjDesc = AcpiNsGetAttachedObject (Info->ResolvedNode); + if (!Info->ObjDesc) + { + ACPI_ERROR ((AE_INFO, "Control method has no attached sub-object")); + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Count the number of arguments being passed to the method */ + + if (Info->Parameters) + { + while (Info->Parameters[Info->ParamCount]) + { + if (Info->ParamCount > ACPI_METHOD_MAX_ARG) + { + return_ACPI_STATUS (AE_LIMIT); + } + Info->ParamCount++; + } + } + + ACPI_DUMP_PATHNAME (Info->ResolvedNode, "ACPI: Execute Method", + ACPI_LV_INFO, _COMPONENT); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Method at AML address %p Length %X\n", + Info->ObjDesc->Method.AmlStart + 1, + Info->ObjDesc->Method.AmlLength - 1)); + + /* + * Any namespace deletion must acquire both the namespace and + * interpreter locks to ensure that no thread is using the portion of + * the namespace that is being deleted. + * + * Execute the method via the interpreter. The interpreter is locked + * here before calling into the AML parser + */ + AcpiExEnterInterpreter (); + Status = AcpiPsExecuteMethod (Info); + AcpiExExitInterpreter (); + } + else + { + /* + * 2) Object is not a method, return its current value + * + * Disallow certain object types. For these, "evaluation" is undefined. + */ + switch (Info->ResolvedNode->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_REGION: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_LOCAL_SCOPE: + + ACPI_ERROR ((AE_INFO, + "[%4.4s] Evaluation of object type [%s] is not supported", + Info->ResolvedNode->Name.Ascii, + AcpiUtGetTypeName (Info->ResolvedNode->Type))); + + return_ACPI_STATUS (AE_TYPE); + + default: + break; + } + + /* + * Objects require additional resolution steps (e.g., the Node may be + * a field that must be read, etc.) -- we can't just grab the object + * out of the node. + * + * Use ResolveNodeToValue() to get the associated value. + * + * NOTE: we can get away with passing in NULL for a walk state because + * ResolvedNode is guaranteed to not be a reference to either a method + * local or a method argument (because this interface is never called + * from a running method.) + * + * Even though we do not directly invoke the interpreter for object + * resolution, we must lock it because we could access an opregion. + * The opregion access code assumes that the interpreter is locked. + */ + AcpiExEnterInterpreter (); + + /* Function has a strange interface */ + + Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL); + AcpiExExitInterpreter (); + + /* + * If AcpiExResolveNodeToValue() succeeded, the return value was placed + * in ResolvedNode. + */ + if (ACPI_SUCCESS (Status)) + { + Status = AE_CTRL_RETURN_VALUE; + Info->ReturnObject = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->ResolvedNode); + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", + Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); + } + } + + /* + * Check input argument count against the ASL-defined count for a method. + * Also check predefined names: argument count and return value against + * the ACPI specification. Some incorrect return value types are repaired. + */ + (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount, + Status, &Info->ReturnObject); + + /* Check if there is a return value that must be dealt with */ + + if (Status == AE_CTRL_RETURN_VALUE) + { + /* If caller does not want the return value, delete it */ + + if (Info->Flags & ACPI_IGNORE_RETURN_VALUE) + { + AcpiUtRemoveReference (Info->ReturnObject); + Info->ReturnObject = NULL; + } + + /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ + + Status = AE_OK; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "*** Completed evaluation of object %s ***\n", Info->Pathname)); + + /* + * Namespace was unlocked by the handling AcpiNs* function, so we + * just return + */ + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCodeList + * + * PARAMETERS: None + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute all elements of the global module-level code list. + * Each element is executed as a single control method. + * + ******************************************************************************/ + +void +AcpiNsExecModuleCodeList ( + void) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_EVALUATE_INFO *Info; + UINT32 MethodCount = 0; + + + ACPI_FUNCTION_TRACE (NsExecModuleCodeList); + + + /* Exit now if the list is empty */ + + Next = AcpiGbl_ModuleCodeList; + if (!Next) + { + return_VOID; + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_VOID; + } + + /* Walk the list, executing each "method" */ + + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + + /* Clear the link field and execute the method */ + + Prev->Method.Mutex = NULL; + AcpiNsExecModuleCode (Prev, Info); + MethodCount++; + + /* Delete the (temporary) method object */ + + AcpiUtRemoveReference (Prev); + } + + ACPI_INFO ((AE_INFO, + "Executed %u blocks of module-level executable AML code", + MethodCount)); + + ACPI_FREE (Info); + AcpiGbl_ModuleCodeList = NULL; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCode + * + * PARAMETERS: MethodObj - Object container for the module-level code + * Info - Info block for method evaluation + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute a control method containing a block of module-level + * executable AML code. The control method is temporarily + * installed to the root node, then evaluated. + * + ******************************************************************************/ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ParentObj; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsExecModuleCode); + + + /* + * Get the parent node. We cheat by using the NextObject field + * of the method object descriptor. + */ + ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + MethodObj->Method.NextObject); + Type = AcpiNsGetType (ParentNode); + + /* + * Get the region handler and save it in the method object. We may need + * this if an operation region declaration causes a _REG method to be run. + * + * We can't do this in AcpiPsLinkModuleCode because + * AcpiGbl_RootNode->Object is NULL at PASS1. + */ + if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object) + { + MethodObj->Method.Extra.Handler = + ParentNode->Object->Device.Handler; + } + + /* Must clear NextObject (AcpiNsAttachObject needs the field) */ + + MethodObj->Method.NextObject = NULL; + + /* Initialize the evaluation information block */ + + ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + Info->PrefixNode = ParentNode; + + /* + * Get the currently attached parent object. Add a reference, because the + * ref count will be decreased when the method object is installed to + * the parent node. + */ + ParentObj = AcpiNsGetAttachedObject (ParentNode); + if (ParentObj) + { + AcpiUtAddReference (ParentObj); + } + + /* Install the method (module-level code) in the parent node */ + + Status = AcpiNsAttachObject (ParentNode, MethodObj, + ACPI_TYPE_METHOD); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Execute the parent node as a control method */ + + Status = AcpiNsEvaluate (Info); + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n", + MethodObj->Method.AmlStart)); + + /* Delete a possible implicit return value (in slack mode) */ + + if (Info->ReturnObject) + { + AcpiUtRemoveReference (Info->ReturnObject); + } + + /* Detach the temporary method object */ + + AcpiNsDetachObject (ParentNode); + + /* Restore the original parent object */ + + if (ParentObj) + { + Status = AcpiNsAttachObject (ParentNode, ParentObj, Type); + } + else + { + ParentNode->Type = (UINT8) Type; + } + +Exit: + if (ParentObj) + { + AcpiUtRemoveReference (ParentObj); + } + return_VOID; +} + diff --git a/drivers/bus/acpi/acpica/namespace/nsinit.c b/drivers/bus/acpi/acpica/namespace/nsinit.c new file mode 100644 index 00000000000..b36fa6c7ea9 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsinit.c @@ -0,0 +1,727 @@ +/****************************************************************************** + * + * Module Name: nsinit - namespace initialization + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFINIT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acdispat.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsinit") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiNsFindIniMethods ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitializeObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Walk the entire namespace and perform any necessary + * initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeObjects ( + void) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + + + ACPI_FUNCTION_TRACE (NsInitializeObjects); + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "**** Starting initialization of namespace objects ****\n")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Completing Region/Field/Buffer/Package initialization:")); + + /* Set all init info to zero */ + + ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); + + /* Walk entire namespace from the supplied root */ + + Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, + &Info, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd " + "Buffers %hd/%hd Packages (%hd nodes)\n", + Info.OpRegionInit, Info.OpRegionCount, + Info.FieldInit, Info.FieldCount, + Info.BufferInit, Info.BufferCount, + Info.PackageInit, Info.PackageCount, Info.ObjectCount)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "%hd Control Methods found\n", Info.MethodCount)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "%hd Op Regions found\n", Info.OpRegionCount)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitializeDevices + * + * PARAMETERS: None + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices. + * This means running _INI on all present devices. + * + * Note: We install PCI config space handler on region access, + * not here. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeDevices ( + void) +{ + ACPI_STATUS Status; + ACPI_DEVICE_WALK_INFO Info; + + + ACPI_FUNCTION_TRACE (NsInitializeDevices); + + + /* Init counters */ + + Info.DeviceCount = 0; + Info.Num_STA = 0; + Info.Num_INI = 0; + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Initializing Device/Processor/Thermal objects " + "by executing _INI methods:")); + + /* Tree analysis: find all subtrees that contain _INI methods */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Allocate the evaluation information block */ + + Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info.EvaluateInfo) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } + + /* + * Execute the "global" _INI method that may appear at the root. This + * support is provided for Windows compatibility (Vista+) and is not + * part of the ACPI specification. + */ + Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; + Info.EvaluateInfo->Pathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } + + /* Walk namespace to execute all _INIs on present devices */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); + + ACPI_FREE (Info.EvaluateInfo); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nExecuted %hd _INI methods requiring %hd _STA executions " + "(examined %hd objects)\n", + Info.Num_INI, Info.Num_STA, Info.DeviceCount)); + + return_ACPI_STATUS (Status); + + +ErrorExit: + ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization")); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitOneObject + * + * PARAMETERS: ObjHandle - Node + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Op Regions + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status = AE_OK; + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (NsInitOneObject); + + + Info->ObjectCount++; + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return (AE_OK); + } + + /* Increment counters for object types we are looking for */ + + switch (Type) + { + case ACPI_TYPE_REGION: + Info->OpRegionCount++; + break; + + case ACPI_TYPE_BUFFER_FIELD: + Info->FieldCount++; + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + Info->FieldCount++; + break; + + case ACPI_TYPE_BUFFER: + Info->BufferCount++; + break; + + case ACPI_TYPE_PACKAGE: + Info->PackageCount++; + break; + + default: + + /* No init required, just exit now */ + return (AE_OK); + } + + /* If the object is already initialized, nothing else to do */ + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return (AE_OK); + } + + /* Must lock the interpreter before executing AML code */ + + AcpiExEnterInterpreter (); + + /* + * Each of these types can contain executable AML code within the + * declaration. + */ + switch (Type) + { + case ACPI_TYPE_REGION: + + Info->OpRegionInit++; + Status = AcpiDsGetRegionArguments (ObjDesc); + break; + + case ACPI_TYPE_BUFFER_FIELD: + + Info->FieldInit++; + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + Info->FieldInit++; + Status = AcpiDsGetBankFieldArguments (ObjDesc); + break; + + case ACPI_TYPE_BUFFER: + + Info->BufferInit++; + Status = AcpiDsGetBufferArguments (ObjDesc); + break; + + case ACPI_TYPE_PACKAGE: + + Info->PackageInit++; + Status = AcpiDsGetPackageArguments (ObjDesc); + break; + + default: + /* No other types can get here */ + break; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not execute arguments for [%4.4s] (%s)", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type))); + } + + /* + * Print a dot for each object unless we are going to print the entire + * pathname + */ + if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); + } + + /* + * We ignore errors from above, and always return OK, since we don't want + * to abort the walk on any single error. + */ + AcpiExExitInterpreter (); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsFindIniMethods + * + * PARAMETERS: ACPI_WALK_CALLBACK + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Called during namespace walk. Finds objects named _INI under + * device/processor/thermal objects, and marks the entire subtree + * with a SUBTREE_HAS_INI flag. This flag is used during the + * subsequent device initialization walk to avoid entire subtrees + * that do not contain an _INI. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsFindIniMethods ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode; + + + /* Keep count of device/processor/thermal objects */ + + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + if ((Node->Type == ACPI_TYPE_DEVICE) || + (Node->Type == ACPI_TYPE_PROCESSOR) || + (Node->Type == ACPI_TYPE_THERMAL)) + { + Info->DeviceCount++; + return (AE_OK); + } + + /* We are only looking for methods named _INI */ + + if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI)) + { + return (AE_OK); + } + + /* + * The only _INI methods that we care about are those that are + * present under Device, Processor, and Thermal objects. + */ + ParentNode = AcpiNsGetParentNode (Node); + switch (ParentNode->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* Mark parent and bubble up the INI present flag to the root */ + + while (ParentNode) + { + ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI; + ParentNode = AcpiNsGetParentNode (ParentNode); + } + break; + + default: + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitOneDevice + * + * PARAMETERS: ACPI_WALK_CALLBACK + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: This is called once per device soon after ACPI is enabled + * to initialize each device. It determines if the device is + * present, and if so, calls _INI. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); + ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo; + UINT32 Flags; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *DeviceNode; + + + ACPI_FUNCTION_TRACE (NsInitOneDevice); + + + /* We are interested in Devices, Processors and ThermalZones only */ + + DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && + (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && + (DeviceNode->Type != ACPI_TYPE_THERMAL)) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Because of an earlier namespace analysis, all subtrees that contain an + * _INI method are tagged. + * + * If this device subtree does not contain any _INI methods, we + * can exit now and stop traversing this entire subtree. + */ + if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI)) + { + return_ACPI_STATUS (AE_CTRL_DEPTH); + } + + /* + * Run _STA to determine if this device is present and functioning. We + * must know this information for two important reasons (from ACPI spec): + * + * 1) We can only run _INI if the device is present. + * 2) We must abort the device tree walk on this subtree if the device is + * not present and is not functional (we will not examine the children) + * + * The _STA method is not required to be present under the device, we + * assume the device is present if _STA does not exist. + */ + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA)); + + Status = AcpiUtExecute_STA (DeviceNode, &Flags); + if (ACPI_FAILURE (Status)) + { + /* Ignore error and move on to next device */ + + return_ACPI_STATUS (AE_OK); + } + + /* + * Flags == -1 means that _STA was not found. In this case, we assume that + * the device is both present and functional. + * + * From the ACPI spec, description of _STA: + * + * "If a device object (including the processor object) does not have an + * _STA object, then OSPM assumes that all of the above bits are set (in + * other words, the device is present, ..., and functioning)" + */ + if (Flags != ACPI_UINT32_MAX) + { + WalkInfo->Num_STA++; + } + + /* + * Examine the PRESENT and FUNCTIONING status bits + * + * Note: ACPI spec does not seem to specify behavior for the present but + * not functioning case, so we assume functioning if present. + */ + if (!(Flags & ACPI_STA_DEVICE_PRESENT)) + { + /* Device is not present, we must examine the Functioning bit */ + + if (Flags & ACPI_STA_DEVICE_FUNCTIONING) + { + /* + * Device is not present but is "functioning". In this case, + * we will not run _INI, but we continue to examine the children + * of this device. + * + * From the ACPI spec, description of _STA: (Note - no mention + * of whether to run _INI or not on the device in question) + * + * "_STA may return bit 0 clear (not present) with bit 3 set + * (device is functional). This case is used to indicate a valid + * device for which no device driver should be loaded (for example, + * a bridge device.) Children of this device may be present and + * valid. OSPM should continue enumeration below a device whose + * _STA returns this bit combination" + */ + return_ACPI_STATUS (AE_OK); + } + else + { + /* + * Device is not present and is not functioning. We must abort the + * walk of this subtree immediately -- don't look at the children + * of such a device. + * + * From the ACPI spec, description of _INI: + * + * "If the _STA method indicates that the device is not present, + * OSPM will not run the _INI and will not examine the children + * of the device for _INI methods" + */ + return_ACPI_STATUS (AE_CTRL_DEPTH); + } + } + + /* + * The device is present or is assumed present if no _STA exists. + * Run the _INI if it exists (not required to exist) + * + * Note: We know there is an _INI within this subtree, but it may not be + * under this particular device, it may be lower in the branch. + */ + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); + + Info->PrefixNode = DeviceNode; + Info->Pathname = METHOD_NAME__INI; + Info->Parameters = NULL; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info); + if (ACPI_SUCCESS (Status)) + { + WalkInfo->Num_INI++; + + if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && + (!(AcpiDbgLevel & ACPI_LV_INFO))) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); + } + } + +#ifdef ACPI_DEBUG_OUTPUT + else if (Status != AE_NOT_FOUND) + { + /* Ignore error and move on to next device */ + + char *ScopeName = AcpiNsGetExternalPathname (Info->ResolvedNode); + + ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", + ScopeName)); + ACPI_FREE (ScopeName); + } +#endif + + /* Ignore errors from above */ + + Status = AE_OK; + + /* + * The _INI method has been run if present; call the Global Initialization + * Handler for this device. + */ + if (AcpiGbl_InitHandler) + { + Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI); + } + + return_ACPI_STATUS (Status); +} diff --git a/drivers/bus/acpi/acpica/namespace/nsload.c b/drivers/bus/acpi/acpica/namespace/nsload.c new file mode 100644 index 00000000000..a9f3824718b --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsload.c @@ -0,0 +1,428 @@ +/****************************************************************************** + * + * Module Name: nsload - namespace loading/expanding/contracting procedures + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSLOAD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acdispat.h" +#include "actables.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsload") + +/* Local prototypes */ + +#ifdef ACPI_FUTURE_IMPLEMENTATION +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle); + +static ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle); +#endif + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiNsLoadTable + * + * PARAMETERS: TableIndex - Index for table to be loaded + * Node - Owning NS node + * + * RETURN: Status + * + * DESCRIPTION: Load one ACPI table into the namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsLoadTable); + + + /* + * Parse the table and load the namespace with all named + * objects found within. Control methods are NOT parsed + * at this time. In fact, the control methods cannot be + * parsed until the entire namespace is loaded, because + * if a control method makes a forward reference (call) + * to another control method, we can't continue parsing + * because we don't know how many arguments to parse next! + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* If table already loaded into namespace, just return */ + + if (AcpiTbIsTableLoaded (TableIndex)) + { + Status = AE_ALREADY_EXISTS; + goto Unlock; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Loading table into namespace ****\n")); + + Status = AcpiTbAllocateOwnerId (TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Unlock; + } + + Status = AcpiNsParseTable (TableIndex, Node); + if (ACPI_SUCCESS (Status)) + { + AcpiTbSetTableLoadedFlag (TableIndex, TRUE); + } + else + { + (void) AcpiTbReleaseOwnerId (TableIndex); + } + +Unlock: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now we can parse the control methods. We always parse + * them here for a sanity check, and if configured for + * just-in-time parsing, we delete the control method + * parse trees. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Begin Table Method Parsing and Object Initialization\n")); + + Status = AcpiDsInitializeObjects (TableIndex, Node); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Completed Table Method Parsing and Object Initialization\n")); + + return_ACPI_STATUS (Status); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiLoadNamespace + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the name space from what ever is pointed to by DSDT. + * (DSDT points to either the BIOS or a buffer.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLoadNamespace ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiLoadNameSpace); + + + /* There must be at least a DSDT installed */ + + if (AcpiGbl_DSDT == NULL) + { + ACPI_ERROR ((AE_INFO, "DSDT is not in memory")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* + * Load the namespace. The DSDT is required, + * but the SSDT and PSDT tables are optional. + */ + Status = AcpiNsLoadTableByType (ACPI_TABLE_ID_DSDT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ignore exceptions from these */ + + (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_SSDT); + (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_PSDT); + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "ACPI Namespace successfully loaded at root %p\n", + AcpiGbl_RootNode)); + + return_ACPI_STATUS (Status); +} +#endif + +#ifdef ACPI_FUTURE_IMPLEMENTATION +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteSubtree + * + * PARAMETERS: StartHandle - Handle in namespace where search begins + * + * RETURNS Status + * + * DESCRIPTION: Walks the namespace starting at the given handle and deletes + * all objects, entries, and scopes in the entire subtree. + * + * Namespace/Interpreter should be locked or the subsystem should + * be in shutdown before this routine is called. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle) +{ + ACPI_STATUS Status; + ACPI_HANDLE ChildHandle; + ACPI_HANDLE ParentHandle; + ACPI_HANDLE NextChildHandle; + ACPI_HANDLE Dummy; + UINT32 Level; + + + ACPI_FUNCTION_TRACE (NsDeleteSubtree); + + + ParentHandle = StartHandle; + ChildHandle = NULL; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + while (Level > 0) + { + /* Attempt to get the next object in this scope */ + + Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle, + ChildHandle, &NextChildHandle); + + ChildHandle = NextChildHandle; + + /* Did we get a new object? */ + + if (ACPI_SUCCESS (Status)) + { + /* Check if this object has any children */ + + if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle, + NULL, &Dummy))) + { + /* + * There is at least one child of this object, + * visit the object + */ + Level++; + ParentHandle = ChildHandle; + ChildHandle = NULL; + } + } + else + { + /* + * No more children in this object, go back up to + * the object's parent + */ + Level--; + + /* Delete all children now */ + + AcpiNsDeleteChildren (ChildHandle); + + ChildHandle = ParentHandle; + Status = AcpiGetParent (ParentHandle, &ParentHandle); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + /* Now delete the starting object, and we are done */ + + AcpiNsRemoveNode (ChildHandle); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsUnloadNameSpace + * + * PARAMETERS: Handle - Root of namespace subtree to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Shrinks the namespace, typically in response to an undocking + * event. Deletes an entire subtree starting from (and + * including) the given handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsUnloadNameSpace); + + + /* Parameter validation */ + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + if (!Handle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* This function does the real work */ + + Status = AcpiNsDeleteSubtree (Handle); + + return_ACPI_STATUS (Status); +} +#endif +#endif + diff --git a/drivers/bus/acpi/acpica/namespace/nsnames.c b/drivers/bus/acpi/acpica/namespace/nsnames.c new file mode 100644 index 00000000000..c00a4457b2a --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsnames.c @@ -0,0 +1,375 @@ +/******************************************************************************* + * + * Module Name: nsnames - Name manipulation and search + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSNAMES_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsnames") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsBuildExternalPath + * + * PARAMETERS: Node - NS node whose pathname is needed + * Size - Size of the pathname + * *NameBuffer - Where to return the pathname + * + * RETURN: Status + * Places the pathname into the NameBuffer, in external format + * (name segments separated by path separators) + * + * DESCRIPTION: Generate a full pathaname + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsBuildExternalPath ( + ACPI_NAMESPACE_NODE *Node, + ACPI_SIZE Size, + char *NameBuffer) +{ + ACPI_SIZE Index; + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_ENTRY (); + + + /* Special case for root */ + + Index = Size - 1; + if (Index < ACPI_NAME_SIZE) + { + NameBuffer[0] = AML_ROOT_PREFIX; + NameBuffer[1] = 0; + return (AE_OK); + } + + /* Store terminator byte, then build name backwards */ + + ParentNode = Node; + NameBuffer[Index] = 0; + + while ((Index > ACPI_NAME_SIZE) && (ParentNode != AcpiGbl_RootNode)) + { + Index -= ACPI_NAME_SIZE; + + /* Put the name into the buffer */ + + ACPI_MOVE_32_TO_32 ((NameBuffer + Index), &ParentNode->Name); + ParentNode = AcpiNsGetParentNode (ParentNode); + + /* Prefix name with the path separator */ + + Index--; + NameBuffer[Index] = ACPI_PATH_SEPARATOR; + } + + /* Overwrite final separator with the root prefix character */ + + NameBuffer[Index] = AML_ROOT_PREFIX; + + if (Index != 0) + { + ACPI_ERROR ((AE_INFO, + "Could not construct external pathname; index=%X, size=%X, Path=%s", + (UINT32) Index, (UINT32) Size, &NameBuffer[Size])); + + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetExternalPathname + * + * PARAMETERS: Node - Namespace node whose pathname is needed + * + * RETURN: Pointer to storage containing the fully qualified name of + * the node, In external format (name segments separated by path + * separators.) + * + * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually + * for error and debug statements. + * + ******************************************************************************/ + +char * +AcpiNsGetExternalPathname ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + char *NameBuffer; + ACPI_SIZE Size; + + + ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node); + + + /* Calculate required buffer size based on depth below root */ + + Size = AcpiNsGetPathnameLength (Node); + if (!Size) + { + return_PTR (NULL); + } + + /* Allocate a buffer to be returned to caller */ + + NameBuffer = ACPI_ALLOCATE_ZEROED (Size); + if (!NameBuffer) + { + ACPI_ERROR ((AE_INFO, "Could not allocate %u bytes", (UINT32) Size)); + return_PTR (NULL); + } + + /* Build the path in the allocated buffer */ + + Status = AcpiNsBuildExternalPath (Node, Size, NameBuffer); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (NameBuffer); + return_PTR (NULL); + } + + return_PTR (NameBuffer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetPathnameLength + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Length of path, including prefix + * + * DESCRIPTION: Get the length of the pathname string for this node + * + ******************************************************************************/ + +ACPI_SIZE +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_SIZE Size; + ACPI_NAMESPACE_NODE *NextNode; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Compute length of pathname as 5 * number of name segments. + * Go back up the parent tree to the root + */ + Size = 0; + NextNode = Node; + + while (NextNode && (NextNode != AcpiGbl_RootNode)) + { + if (ACPI_GET_DESCRIPTOR_TYPE (NextNode) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, + "Invalid Namespace Node (%p) while traversing namespace", + NextNode)); + return 0; + } + Size += ACPI_PATH_SEGMENT_LENGTH; + NextNode = AcpiNsGetParentNode (NextNode); + } + + if (!Size) + { + Size = 1; /* Root node case */ + } + + return (Size + 1); /* +1 for null string terminator */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsHandleToPathname + * + * PARAMETERS: TargetHandle - Handle of named object whose name is + * to be found + * Buffer - Where the pathname is returned + * + * RETURN: Status, Buffer is filled with pathname if status is AE_OK + * + * DESCRIPTION: Build and return a full namespace pathname + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_SIZE RequiredSize; + + + ACPI_FUNCTION_TRACE_PTR (NsHandleToPathname, TargetHandle); + + + Node = AcpiNsValidateHandle (TargetHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Determine size required for the caller buffer */ + + RequiredSize = AcpiNsGetPathnameLength (Node); + if (!RequiredSize) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (Buffer, RequiredSize); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Build the path in the caller buffer */ + + Status = AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n", + (char *) Buffer->Pointer, (UINT32) RequiredSize)); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/namespace/nsobject.c b/drivers/bus/acpi/acpica/namespace/nsobject.c new file mode 100644 index 00000000000..c0163f4ea24 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsobject.c @@ -0,0 +1,577 @@ +/******************************************************************************* + * + * Module Name: nsobject - Utilities for objects attached to namespace + * table entries + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSOBJECT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsobject") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsAttachObject + * + * PARAMETERS: Node - Parent Node + * Object - Object to be attached + * Type - Type of object, or ACPI_TYPE_ANY if not + * known + * + * RETURN: Status + * + * DESCRIPTION: Record the given object as the value associated with the + * name whose ACPI_HANDLE is passed. If Object is NULL + * and Type is ACPI_TYPE_ANY, set the name as having no value. + * Note: Future may require that the Node->Flags field be passed + * as a parameter. + * + * MUTEX: Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + ACPI_OBJECT_TYPE Type) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *LastObjDesc; + ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY; + + + ACPI_FUNCTION_TRACE (NsAttachObject); + + + /* + * Parameter validation + */ + if (!Node) + { + /* Invalid handle */ + + ACPI_ERROR ((AE_INFO, "Null NamedObj handle")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!Object && (ACPI_TYPE_ANY != Type)) + { + /* Null object */ + + ACPI_ERROR ((AE_INFO, + "Null object, but type not ACPI_TYPE_ANY")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + /* Not a name handle */ + + ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]", + Node, AcpiUtGetDescriptorName (Node))); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check if this object is already attached */ + + if (Node->Object == Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj %p already installed in NameObj %p\n", + Object, Node)); + + return_ACPI_STATUS (AE_OK); + } + + /* If null object, we will just install it */ + + if (!Object) + { + ObjDesc = NULL; + ObjectType = ACPI_TYPE_ANY; + } + + /* + * If the source object is a namespace Node with an attached object, + * we will use that (attached) object + */ + else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) && + ((ACPI_NAMESPACE_NODE *) Object)->Object) + { + /* + * Value passed is a name handle and that name has a + * non-null value. Use that name's value and type. + */ + ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; + ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type; + } + + /* + * Otherwise, we will use the parameter object, but we must type + * it first + */ + else + { + ObjDesc = (ACPI_OPERAND_OBJECT *) Object; + + /* Use the given type */ + + ObjectType = Type; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", + ObjDesc, Node, AcpiUtGetNodeName (Node))); + + /* Detach an existing attached object if present */ + + if (Node->Object) + { + AcpiNsDetachObject (Node); + } + + if (ObjDesc) + { + /* + * Must increment the new value's reference count + * (if it is an internal object) + */ + AcpiUtAddReference (ObjDesc); + + /* + * Handle objects with multiple descriptors - walk + * to the end of the descriptor list + */ + LastObjDesc = ObjDesc; + while (LastObjDesc->Common.NextObject) + { + LastObjDesc = LastObjDesc->Common.NextObject; + } + + /* Install the object at the front of the object list */ + + LastObjDesc->Common.NextObject = Node->Object; + } + + Node->Type = (UINT8) ObjectType; + Node->Object = ObjDesc; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDetachObject + * + * PARAMETERS: Node - A Namespace node whose object will be detached + * + * RETURN: None. + * + * DESCRIPTION: Detach/delete an object associated with a namespace node. + * if the object is an allocated object, it is freed. + * Otherwise, the field is simply cleared. + * + ******************************************************************************/ + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (NsDetachObject); + + + ObjDesc = Node->Object; + + if (!ObjDesc || + (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + return_VOID; + } + + if (Node->Flags & ANOBJ_ALLOCATED_BUFFER) + { + /* Free the dynamic aml buffer */ + + if (ObjDesc->Common.Type == ACPI_TYPE_METHOD) + { + ACPI_FREE (ObjDesc->Method.AmlStart); + } + } + + /* Clear the entry in all cases */ + + Node->Object = NULL; + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) + { + Node->Object = ObjDesc->Common.NextObject; + if (Node->Object && + ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA)) + { + Node->Object = Node->Object->Common.NextObject; + } + } + + /* Reset the node type to untyped */ + + Node->Type = ACPI_TYPE_ANY; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", + Node, AcpiUtGetNodeName (Node), ObjDesc)); + + /* Remove one reference on the object (and all subobjects) */ + + AcpiUtRemoveReference (ObjDesc); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetAttachedObject + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Current value of the object field from the Node whose + * handle is passed + * + * DESCRIPTION: Obtain the object attached to a namespace node. + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiNsGetAttachedObject ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node); + + + if (!Node) + { + ACPI_WARNING ((AE_INFO, "Null Node ptr")); + return_PTR (NULL); + } + + if (!Node->Object || + ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) && + (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) || + ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + return_PTR (NULL); + } + + return_PTR (Node->Object); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetSecondaryObject + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Current value of the object field from the Node whose + * handle is passed. + * + * DESCRIPTION: Obtain a secondary object associated with a namespace node. + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiNsGetSecondaryObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc); + + + if ((!ObjDesc) || + (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) || + (!ObjDesc->Common.NextObject) || + ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + return_PTR (NULL); + } + + return_PTR (ObjDesc->Common.NextObject); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsAttachData + * + * PARAMETERS: Node - Namespace node + * Handler - Handler to be associated with the data + * Data - Data to be attached + * + * RETURN: Status + * + * DESCRIPTION: Low-level attach data. Create and attach a Data object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsAttachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void *Data) +{ + ACPI_OPERAND_OBJECT *PrevObjDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *DataDesc; + + + /* We only allow one attachment per handler */ + + PrevObjDesc = NULL; + ObjDesc = Node->Object; + while (ObjDesc) + { + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && + (ObjDesc->Data.Handler == Handler)) + { + return (AE_ALREADY_EXISTS); + } + + PrevObjDesc = ObjDesc; + ObjDesc = ObjDesc->Common.NextObject; + } + + /* Create an internal object for the data */ + + DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA); + if (!DataDesc) + { + return (AE_NO_MEMORY); + } + + DataDesc->Data.Handler = Handler; + DataDesc->Data.Pointer = Data; + + /* Install the data object */ + + if (PrevObjDesc) + { + PrevObjDesc->Common.NextObject = DataDesc; + } + else + { + Node->Object = DataDesc; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDetachData + * + * PARAMETERS: Node - Namespace node + * Handler - Handler associated with the data + * + * RETURN: Status + * + * DESCRIPTION: Low-level detach data. Delete the data node, but the caller + * is responsible for the actual data. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDetachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *PrevObjDesc; + + + PrevObjDesc = NULL; + ObjDesc = Node->Object; + while (ObjDesc) + { + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && + (ObjDesc->Data.Handler == Handler)) + { + if (PrevObjDesc) + { + PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject; + } + else + { + Node->Object = ObjDesc->Common.NextObject; + } + + AcpiUtRemoveReference (ObjDesc); + return (AE_OK); + } + + PrevObjDesc = ObjDesc; + ObjDesc = ObjDesc->Common.NextObject; + } + + return (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetAttachedData + * + * PARAMETERS: Node - Namespace node + * Handler - Handler associated with the data + * Data - Where the data is returned + * + * RETURN: Status + * + * DESCRIPTION: Low level interface to obtain data previously associated with + * a namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsGetAttachedData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void **Data) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ObjDesc = Node->Object; + while (ObjDesc) + { + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && + (ObjDesc->Data.Handler == Handler)) + { + *Data = ObjDesc->Data.Pointer; + return (AE_OK); + } + + ObjDesc = ObjDesc->Common.NextObject; + } + + return (AE_NOT_FOUND); +} + + diff --git a/drivers/bus/acpi/acpica/namespace/nsparse.c b/drivers/bus/acpi/acpica/namespace/nsparse.c new file mode 100644 index 00000000000..58301560ae0 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsparse.c @@ -0,0 +1,297 @@ +/****************************************************************************** + * + * Module Name: nsparse - namespace interface to AML parser + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSPARSE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acdispat.h" +#include "actables.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsparse") + + +/******************************************************************************* + * + * FUNCTION: NsOneCompleteParse + * + * PARAMETERS: PassNumber - 1 or 2 + * TableDesc - The table to be parsed. + * + * RETURN: Status + * + * DESCRIPTION: Perform one complete parse of an ACPI/AML table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_PARSE_OBJECT *ParseRoot; + ACPI_STATUS Status; + UINT32 AmlLength; + UINT8 *AmlStart; + ACPI_WALK_STATE *WalkState; + ACPI_TABLE_HEADER *Table; + ACPI_OWNER_ID OwnerId; + + + ACPI_FUNCTION_TRACE (NsOneCompleteParse); + + + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create and init a Root Node */ + + ParseRoot = AcpiPsCreateScopeOp (); + if (!ParseRoot) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL); + if (!WalkState) + { + AcpiPsFreeOp (ParseRoot); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + AcpiPsFreeOp (ParseRoot); + return_ACPI_STATUS (Status); + } + + /* Table must consist of at least a complete header */ + + if (Table->Length < sizeof (ACPI_TABLE_HEADER)) + { + Status = AE_BAD_HEADER; + } + else + { + AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); + AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); + Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, + AmlStart, AmlLength, NULL, (UINT8) PassNumber); + } + + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* StartNode is the default location to load the table */ + + if (StartNode && StartNode != AcpiGbl_RootNode) + { + Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + } + + /* Parse the AML */ + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", PassNumber)); + Status = AcpiPsParseAml (WalkState); + +Cleanup: + AcpiPsDeleteParseTree (ParseRoot); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsParseTable + * + * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse + * StartNode - Where to enter the table into the namespace + * + * RETURN: Status + * + * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsParseTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsParseTable); + + + /* + * AML Parse, pass 1 + * + * In this pass, we load most of the namespace. Control methods + * are not parsed until later. A parse tree is not created. Instead, + * each Parser Op subtree is deleted when it is finished. This saves + * a great deal of memory, and allows a small cache of parse objects + * to service the entire parse. The second pass of the parse then + * performs another complete parse of the AML. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, + TableIndex, StartNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * AML Parse, pass 2 + * + * In this pass, we resolve forward references and other things + * that could not be completed during the first pass. + * Another complete parse of the AML is performed, but the + * overhead of this is compensated for by the fact that the + * parse objects are all cached. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, + TableIndex, StartNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/namespace/nspredef.c b/drivers/bus/acpi/acpica/namespace/nspredef.c new file mode 100644 index 00000000000..d979c43e93f --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nspredef.c @@ -0,0 +1,1263 @@ +/****************************************************************************** + * + * Module Name: nspredef - Validation of ACPI predefined methods and objects + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define ACPI_CREATE_PREDEFINED_TABLE + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acpredef.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nspredef") + + +/******************************************************************************* + * + * This module validates predefined ACPI objects that appear in the namespace, + * at the time they are evaluated (via AcpiEvaluateObject). The purpose of this + * validation is to detect problems with BIOS-exposed predefined ACPI objects + * before the results are returned to the ACPI-related drivers. + * + * There are several areas that are validated: + * + * 1) The number of input arguments as defined by the method/object in the + * ASL is validated against the ACPI specification. + * 2) The type of the return object (if any) is validated against the ACPI + * specification. + * 3) For returned package objects, the count of package elements is + * validated, as well as the type of each package element. Nested + * packages are supported. + * + * For any problems found, a warning message is issued. + * + ******************************************************************************/ + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsCheckPackage ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count); + +static ACPI_STATUS +AcpiNsCheckPackageElements ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **Elements, + UINT8 Type1, + UINT32 Count1, + UINT8 Type2, + UINT32 Count2, + UINT32 StartIndex); + +static ACPI_STATUS +AcpiNsCheckObjectType ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr, + UINT32 ExpectedBtypes, + UINT32 PackageIndex); + +static ACPI_STATUS +AcpiNsCheckReference ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject); + +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes); + +/* + * Names for the types that can be returned by the predefined objects. + * Used for warning messages. Must be in the same order as the ACPI_RTYPEs + */ +static const char *AcpiRtypeNames[] = +{ + "/Integer", + "/String", + "/Buffer", + "/Package", + "/Reference", +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPredefinedNames + * + * PARAMETERS: Node - Namespace node for the method/object + * UserParamCount - Number of parameters actually passed + * ReturnStatus - Status from the object evaluation + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status + * + * DESCRIPTION: Check an ACPI name for a match in the predefined name list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsCheckPredefinedNames ( + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + ACPI_STATUS ReturnStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status = AE_OK; + const ACPI_PREDEFINED_INFO *Predefined; + char *Pathname; + ACPI_PREDEFINED_DATA *Data; + + + /* Match the name for this method/object against the predefined list */ + + Predefined = AcpiNsCheckForPredefinedName (Node); + + /* Get the full pathname to the object, for use in warning messages */ + + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_OK); /* Could not get pathname, ignore */ + } + + /* + * Check that the parameter count for this method matches the ASL + * definition. For predefined names, ensure that both the caller and + * the method itself are in accordance with the ACPI specification. + */ + AcpiNsCheckParameterCount (Pathname, Node, UserParamCount, Predefined); + + /* If not a predefined name, we cannot validate the return object */ + + if (!Predefined) + { + goto Cleanup; + } + + /* + * If the method failed or did not actually return an object, we cannot + * validate the return object + */ + if ((ReturnStatus != AE_OK) && (ReturnStatus != AE_CTRL_RETURN_VALUE)) + { + goto Cleanup; + } + + /* + * If there is no return value, check if we require a return value for + * this predefined name. Either one return value is expected, or none, + * for both methods and other objects. + * + * Exit now if there is no return object. Warning if one was expected. + */ + if (!ReturnObject) + { + if ((Predefined->Info.ExpectedBtypes) && + (!(Predefined->Info.ExpectedBtypes & ACPI_RTYPE_NONE))) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Missing expected return value")); + + Status = AE_AML_NO_RETURN_VALUE; + } + goto Cleanup; + } + + /* + * 1) We have a return value, but if one wasn't expected, just exit, this is + * not a problem. For example, if the "Implicit Return" feature is + * enabled, methods will always return a value. + * + * 2) If the return value can be of any type, then we cannot perform any + * validation, exit. + */ + if ((!Predefined->Info.ExpectedBtypes) || + (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL)) + { + goto Cleanup; + } + + /* Create the parameter data block for object validation */ + + Data = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PREDEFINED_DATA)); + if (!Data) + { + goto Cleanup; + } + Data->Predefined = Predefined; + Data->NodeFlags = Node->Flags; + Data->Pathname = Pathname; + + /* + * Check that the type of the main return object is what is expected + * for this predefined name + */ + Status = AcpiNsCheckObjectType (Data, ReturnObjectPtr, + Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* + * For returned Package objects, check the type of all sub-objects. + * Note: Package may have been newly created by call above. + */ + if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiNsCheckPackage (Data, ReturnObjectPtr); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + + /* + * The return object was OK, or it was successfully repaired above. + * Now make some additional checks such as verifying that package + * objects are sorted correctly (if required) or buffer objects have + * the correct data width (bytes vs. dwords). These repairs are + * performed on a per-name basis, i.e., the code is specific to + * particular predefined names. + */ + Status = AcpiNsComplexRepairs (Data, Node, Status, ReturnObjectPtr); + +Exit: + /* + * If the object validation failed or if we successfully repaired one + * or more objects, mark the parent node to suppress further warning + * messages during the next evaluation of the same method/object. + */ + if (ACPI_FAILURE (Status) || (Data->Flags & ACPI_OBJECT_REPAIRED)) + { + Node->Flags |= ANOBJ_EVALUATED; + } + ACPI_FREE (Data); + +Cleanup: + ACPI_FREE (Pathname); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckParameterCount + * + * PARAMETERS: Pathname - Full pathname to the node (for error msgs) + * Node - Namespace node for the method/object + * UserParamCount - Number of args passed in by the caller + * Predefined - Pointer to entry in predefined name table + * + * RETURN: None + * + * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a + * predefined name is what is expected (i.e., what is defined in + * the ACPI specification for this predefined name.) + * + ******************************************************************************/ + +void +AcpiNsCheckParameterCount ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + const ACPI_PREDEFINED_INFO *Predefined) +{ + UINT32 ParamCount; + UINT32 RequiredParamsCurrent; + UINT32 RequiredParamsOld; + + + /* Methods have 0-7 parameters. All other types have zero. */ + + ParamCount = 0; + if (Node->Type == ACPI_TYPE_METHOD) + { + ParamCount = Node->Object->Method.ParamCount; + } + + if (!Predefined) + { + /* + * Check the parameter count for non-predefined methods/objects. + * + * Warning if too few or too many arguments have been passed by the + * caller. An incorrect number of arguments may not cause the method + * to fail. However, the method will fail if there are too few + * arguments and the method attempts to use one of the missing ones. + */ + if (UserParamCount < ParamCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Insufficient arguments - needs %u, found %u", + ParamCount, UserParamCount)); + } + else if (UserParamCount > ParamCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Excess arguments - needs %u, found %u", + ParamCount, UserParamCount)); + } + return; + } + + /* + * Validate the user-supplied parameter count. + * Allow two different legal argument counts (_SCP, etc.) + */ + RequiredParamsCurrent = Predefined->Info.ParamCount & 0x0F; + RequiredParamsOld = Predefined->Info.ParamCount >> 4; + + if (UserParamCount != ACPI_UINT32_MAX) + { + if ((UserParamCount != RequiredParamsCurrent) && + (UserParamCount != RequiredParamsOld)) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Parameter count mismatch - " + "caller passed %u, ACPI requires %u", + UserParamCount, RequiredParamsCurrent)); + } + } + + /* + * Check that the ASL-defined parameter count is what is expected for + * this predefined name (parameter count as defined by the ACPI + * specification) + */ + if ((ParamCount != RequiredParamsCurrent) && + (ParamCount != RequiredParamsOld)) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, Node->Flags, + "Parameter count mismatch - ASL declared %u, ACPI requires %u", + ParamCount, RequiredParamsCurrent)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckForPredefinedName + * + * PARAMETERS: Node - Namespace node for the method/object + * + * RETURN: Pointer to entry in predefined table. NULL indicates not found. + * + * DESCRIPTION: Check an object name against the predefined object list. + * + ******************************************************************************/ + +const ACPI_PREDEFINED_INFO * +AcpiNsCheckForPredefinedName ( + ACPI_NAMESPACE_NODE *Node) +{ + const ACPI_PREDEFINED_INFO *ThisName; + + + /* Quick check for a predefined name, first character must be underscore */ + + if (Node->Name.Ascii[0] != '_') + { + return (NULL); + } + + /* Search info table for a predefined method/object name */ + + ThisName = PredefinedNames; + while (ThisName->Info.Name[0]) + { + if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Info.Name)) + { + return (ThisName); + } + + /* + * Skip next entry in the table if this name returns a Package + * (next entry contains the package info) + */ + if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) + { + ThisName++; + } + + ThisName++; + } + + return (NULL); /* Not found */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackage + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status + * + * DESCRIPTION: Check a returned package object for the correct count and + * correct type of all sub-objects. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackage ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + const ACPI_PREDEFINED_INFO *Package; + ACPI_OPERAND_OBJECT **Elements; + ACPI_STATUS Status = AE_OK; + UINT32 ExpectedCount; + UINT32 Count; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsCheckPackage); + + + /* The package info for this name is in the next table entry */ + + Package = Data->Predefined + 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%s Validating return Package of Type %X, Count %X\n", + Data->Pathname, Package->RetInfo.Type, ReturnObject->Package.Count)); + + /* + * For variable-length Packages, we can safely remove all embedded + * and trailing NULL package elements + */ + AcpiNsRemoveNullElements (Data, Package->RetInfo.Type, ReturnObject); + + /* Extract package count and elements array */ + + Elements = ReturnObject->Package.Elements; + Count = ReturnObject->Package.Count; + + /* The package must have at least one element, else invalid */ + + if (!Count) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package has no elements (empty)")); + + return (AE_AML_OPERAND_VALUE); + } + + /* + * Decode the type of the expected package contents + * + * PTYPE1 packages contain no subpackages + * PTYPE2 packages contain sub-packages + */ + switch (Package->RetInfo.Type) + { + case ACPI_PTYPE1_FIXED: + + /* + * The package count is fixed and there are no sub-packages + * + * If package is too small, exit. + * If package is larger than expected, issue warning but continue + */ + ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; + if (Count < ExpectedCount) + { + goto PackageTooSmall; + } + else if (Count > ExpectedCount) + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Return Package is larger than needed - " + "found %u, expected %u\n", + Data->Pathname, Count, ExpectedCount)); + } + + /* Validate all elements of the returned package */ + + Status = AcpiNsCheckPackageElements (Data, Elements, + Package->RetInfo.ObjectType1, Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); + break; + + + case ACPI_PTYPE1_VAR: + + /* + * The package count is variable, there are no sub-packages, and all + * elements must be of the same type + */ + for (i = 0; i < Count; i++) + { + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo.ObjectType1, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + Elements++; + } + break; + + + case ACPI_PTYPE1_OPTION: + + /* + * The package count is variable, there are no sub-packages. There are + * a fixed number of required elements, and a variable number of + * optional elements. + * + * Check if package is at least as large as the minimum required + */ + ExpectedCount = Package->RetInfo3.Count; + if (Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Variable number of sub-objects */ + + for (i = 0; i < Count; i++) + { + if (i < Package->RetInfo3.Count) + { + /* These are the required package elements (0, 1, or 2) */ + + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo3.ObjectType[i], i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + else + { + /* These are the optional package elements */ + + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo3.TailObjectType, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + Elements++; + } + break; + + + case ACPI_PTYPE2_REV_FIXED: + + /* First element is the (Integer) revision */ + + Status = AcpiNsCheckObjectType (Data, Elements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Elements++; + Count--; + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + case ACPI_PTYPE2_PKG_COUNT: + + /* First element is the (Integer) count of sub-packages to follow */ + + Status = AcpiNsCheckObjectType (Data, Elements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Count cannot be larger than the parent package length, but allow it + * to be smaller. The >= accounts for the Integer above. + */ + ExpectedCount = (UINT32) (*Elements)->Integer.Value; + if (ExpectedCount >= Count) + { + goto PackageTooSmall; + } + + Count = ExpectedCount; + Elements++; + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + case ACPI_PTYPE2: + case ACPI_PTYPE2_FIXED: + case ACPI_PTYPE2_MIN: + case ACPI_PTYPE2_COUNT: + + /* + * These types all return a single Package that consists of a + * variable number of sub-Packages. + * + * First, ensure that the first element is a sub-Package. If not, + * the BIOS may have incorrectly returned the object as a single + * package instead of a Package of Packages (a common error if + * there is only one entry). We may be able to repair this by + * wrapping the returned Package with a new outer Package. + */ + if (*Elements && ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE)) + { + /* Create the new outer package and populate it */ + + Status = AcpiNsRepairPackageList (Data, ReturnObjectPtr); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update locals to point to the new package (of 1 element) */ + + ReturnObject = *ReturnObjectPtr; + Elements = ReturnObject->Package.Elements; + Count = 1; + } + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + default: + + /* Should not get here if predefined info table is correct */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid internal return type in table entry: %X", + Package->RetInfo.Type)); + + return (AE_AML_INTERNAL); + } + + return (Status); + + +PackageTooSmall: + + /* Error exit for the case with an incorrect package count */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package is too small - found %u elements, expected %u", + Count, ExpectedCount)); + + return (AE_AML_OPERAND_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackageList + * + * PARAMETERS: Data - Pointer to validation data structure + * Package - Pointer to package-specific info for method + * Elements - Element list of parent package. All elements + * of this list should be of type Package. + * Count - Count of subpackages + * + * RETURN: Status + * + * DESCRIPTION: Examine a list of subpackages + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count) +{ + ACPI_OPERAND_OBJECT *SubPackage; + ACPI_OPERAND_OBJECT **SubElements; + ACPI_STATUS Status; + UINT32 ExpectedCount; + UINT32 i; + UINT32 j; + + + /* + * Validate each sub-Package in the parent Package + * + * NOTE: assumes list of sub-packages contains no NULL elements. + * Any NULL elements should have been removed by earlier call + * to AcpiNsRemoveNullElements. + */ + for (i = 0; i < Count; i++) + { + SubPackage = *Elements; + SubElements = SubPackage->Package.Elements; + + /* Each sub-object must be of type Package */ + + Status = AcpiNsCheckObjectType (Data, &SubPackage, + ACPI_RTYPE_PACKAGE, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Examine the different types of expected sub-packages */ + + switch (Package->RetInfo.Type) + { + case ACPI_PTYPE2: + case ACPI_PTYPE2_PKG_COUNT: + case ACPI_PTYPE2_REV_FIXED: + + /* Each subpackage has a fixed number of elements */ + + ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + Status = AcpiNsCheckPackageElements (Data, SubElements, + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + Package->RetInfo.Count2, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_PTYPE2_FIXED: + + /* Each sub-package has a fixed length */ + + ExpectedCount = Package->RetInfo2.Count; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + for (j = 0; j < ExpectedCount; j++) + { + Status = AcpiNsCheckObjectType (Data, &SubElements[j], + Package->RetInfo2.ObjectType[j], j); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + break; + + + case ACPI_PTYPE2_MIN: + + /* Each sub-package has a variable but minimum length */ + + ExpectedCount = Package->RetInfo.Count1; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + Status = AcpiNsCheckPackageElements (Data, SubElements, + Package->RetInfo.ObjectType1, + SubPackage->Package.Count, 0, 0, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_PTYPE2_COUNT: + + /* + * First element is the (Integer) count of elements, including + * the count field. + */ + Status = AcpiNsCheckObjectType (Data, SubElements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Make sure package is large enough for the Count and is + * is as large as the minimum size + */ + ExpectedCount = (UINT32) (*SubElements)->Integer.Value; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + if (SubPackage->Package.Count < Package->RetInfo.Count1) + { + ExpectedCount = Package->RetInfo.Count1; + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + Status = AcpiNsCheckPackageElements (Data, (SubElements + 1), + Package->RetInfo.ObjectType1, + (ExpectedCount - 1), 0, 0, 1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + default: /* Should not get here, type was validated by caller */ + + return (AE_AML_INTERNAL); + } + + Elements++; + } + + return (AE_OK); + + +PackageTooSmall: + + /* The sub-package count was smaller than required */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Sub-Package[%u] is too small - found %u elements, expected %u", + i, SubPackage->Package.Count, ExpectedCount)); + + return (AE_AML_OPERAND_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackageElements + * + * PARAMETERS: Data - Pointer to validation data structure + * Elements - Pointer to the package elements array + * Type1 - Object type for first group + * Count1 - Count for first group + * Type2 - Object type for second group + * Count2 - Count for second group + * StartIndex - Start of the first group of elements + * + * RETURN: Status + * + * DESCRIPTION: Check that all elements of a package are of the correct object + * type. Supports up to two groups of different object types. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackageElements ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **Elements, + UINT8 Type1, + UINT32 Count1, + UINT8 Type2, + UINT32 Count2, + UINT32 StartIndex) +{ + ACPI_OPERAND_OBJECT **ThisElement = Elements; + ACPI_STATUS Status; + UINT32 i; + + + /* + * Up to two groups of package elements are supported by the data + * structure. All elements in each group must be of the same type. + * The second group can have a count of zero. + */ + for (i = 0; i < Count1; i++) + { + Status = AcpiNsCheckObjectType (Data, ThisElement, + Type1, i + StartIndex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ThisElement++; + } + + for (i = 0; i < Count2; i++) + { + Status = AcpiNsCheckObjectType (Data, ThisElement, + Type2, (i + Count1 + StartIndex)); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ThisElement++; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckObjectType + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * ExpectedBtypes - Bitmap of expected return type(s) + * PackageIndex - Index of object within parent package (if + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) + * + * RETURN: Status + * + * DESCRIPTION: Check the type of the return object against the expected object + * type(s). Use of Btype allows multiple expected object types. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckObjectType ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr, + UINT32 ExpectedBtypes, + UINT32 PackageIndex) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status = AE_OK; + UINT32 ReturnBtype; + char TypeBuffer[48]; /* Room for 5 types */ + + + /* + * If we get a NULL ReturnObject here, it is a NULL package element, + * and this is always an error. + */ + if (!ReturnObject) + { + goto TypeErrorExit; + } + + /* A Namespace node should not get here, but make sure */ + + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid return type - Found a Namespace node [%4.4s] type %s", + ReturnObject->Node.Name.Ascii, + AcpiUtGetTypeName (ReturnObject->Node.Type))); + return (AE_AML_OPERAND_TYPE); + } + + /* + * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. + * The bitmapped type allows multiple possible return types. + * + * Note, the cases below must handle all of the possible types returned + * from all of the predefined names (including elements of returned + * packages) + */ + switch (ReturnObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + ReturnBtype = ACPI_RTYPE_INTEGER; + break; + + case ACPI_TYPE_BUFFER: + ReturnBtype = ACPI_RTYPE_BUFFER; + break; + + case ACPI_TYPE_STRING: + ReturnBtype = ACPI_RTYPE_STRING; + break; + + case ACPI_TYPE_PACKAGE: + ReturnBtype = ACPI_RTYPE_PACKAGE; + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + ReturnBtype = ACPI_RTYPE_REFERENCE; + break; + + default: + /* Not one of the supported objects, must be incorrect */ + + goto TypeErrorExit; + } + + /* Is the object one of the expected types? */ + + if (!(ReturnBtype & ExpectedBtypes)) + { + /* Type mismatch -- attempt repair of the returned object */ + + Status = AcpiNsRepairObject (Data, ExpectedBtypes, + PackageIndex, ReturnObjectPtr); + if (ACPI_SUCCESS (Status)) + { + return (AE_OK); /* Repair was successful */ + } + goto TypeErrorExit; + } + + /* For reference objects, check that the reference type is correct */ + + if (ReturnObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + Status = AcpiNsCheckReference (Data, ReturnObject); + } + + return (Status); + + +TypeErrorExit: + + /* Create a string with all expected types for this predefined object */ + + AcpiNsGetExpectedTypes (TypeBuffer, ExpectedBtypes); + + if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - found %s, expected %s", + AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); + } + else + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package type mismatch at index %u - " + "found %s, expected %s", PackageIndex, + AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); + } + + return (AE_AML_OPERAND_TYPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckReference + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObject - Object returned from the evaluation of a + * method or object + * + * RETURN: Status + * + * DESCRIPTION: Check a returned reference object for the correct reference + * type. The only reference type that can be returned from a + * predefined method is a named reference. All others are invalid. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckReference ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject) +{ + + /* + * Check the reference object for the correct reference type (opcode). + * The only type of reference that can be converted to an ACPI_OBJECT is + * a reference to a named object (reference class: NAME) + */ + if (ReturnObject->Reference.Class == ACPI_REFCLASS_NAME) + { + return (AE_OK); + } + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - unexpected reference object type [%s] %2.2X", + AcpiUtGetReferenceName (ReturnObject), + ReturnObject->Reference.Class)); + + return (AE_AML_OPERAND_TYPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetExpectedTypes + * + * PARAMETERS: Buffer - Pointer to where the string is returned + * ExpectedBtypes - Bitmap of expected return type(s) + * + * RETURN: Buffer is populated with type names. + * + * DESCRIPTION: Translate the expected types bitmap into a string of ascii + * names of expected types, for use in warning messages. + * + ******************************************************************************/ + +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes) +{ + UINT32 ThisRtype; + UINT32 i; + UINT32 j; + + + j = 1; + Buffer[0] = 0; + ThisRtype = ACPI_RTYPE_INTEGER; + + for (i = 0; i < ACPI_NUM_RTYPES; i++) + { + /* If one of the expected types, concatenate the name of this type */ + + if (ExpectedBtypes & ThisRtype) + { + ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]); + j = 0; /* Use name separator from now on */ + } + ThisRtype <<= 1; /* Next Rtype */ + } +} diff --git a/drivers/bus/acpi/acpica/namespace/nsrepair.c b/drivers/bus/acpi/acpica/namespace/nsrepair.c new file mode 100644 index 00000000000..5c402df36b5 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsrepair.c @@ -0,0 +1,686 @@ +/****************************************************************************** + * + * Module Name: nsrepair - Repair for objects returned by predefined methods + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSREPAIR_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsrepair") + + +/******************************************************************************* + * + * This module attempts to repair or convert objects returned by the + * predefined methods to an object type that is expected, as per the ACPI + * specification. The need for this code is dictated by the many machines that + * return incorrect types for the standard predefined methods. Performing these + * conversions here, in one place, eliminates the need for individual ACPI + * device drivers to do the same. Note: Most of these conversions are different + * than the internal object conversion routines used for implicit object + * conversion. + * + * The following conversions can be performed as necessary: + * + * Integer -> String + * Integer -> Buffer + * String -> Integer + * String -> Buffer + * Buffer -> Integer + * Buffer -> String + * Buffer -> Package of Integers + * Package -> Package of one Package + * + ******************************************************************************/ + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsConvertToInteger ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +static ACPI_STATUS +AcpiNsConvertToString ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +static ACPI_STATUS +AcpiNsConvertToBuffer ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + +static ACPI_STATUS +AcpiNsConvertToPackage ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRepairObject + * + * PARAMETERS: Data - Pointer to validation data structure + * ExpectedBtypes - Object types expected + * PackageIndex - Index of object within parent package (if + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if repair was successful. + * + * DESCRIPTION: Attempt to repair/convert a return object of a type that was + * not expected. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRepairObject ( + ACPI_PREDEFINED_DATA *Data, + UINT32 ExpectedBtypes, + UINT32 PackageIndex, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT *NewObject; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (NsRepairObject); + + + /* + * At this point, we know that the type of the returned object was not + * one of the expected types for this predefined name. Attempt to + * repair the object by converting it to one of the expected object + * types for this predefined name. + */ + if (ExpectedBtypes & ACPI_RTYPE_INTEGER) + { + Status = AcpiNsConvertToInteger (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + if (ExpectedBtypes & ACPI_RTYPE_STRING) + { + Status = AcpiNsConvertToString (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + if (ExpectedBtypes & ACPI_RTYPE_BUFFER) + { + Status = AcpiNsConvertToBuffer (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + if (ExpectedBtypes & ACPI_RTYPE_PACKAGE) + { + Status = AcpiNsConvertToPackage (ReturnObject, &NewObject); + if (ACPI_SUCCESS (Status)) + { + goto ObjectRepaired; + } + } + + /* We cannot repair this object */ + + return (AE_AML_OPERAND_TYPE); + + +ObjectRepaired: + + /* Object was successfully repaired */ + + /* + * If the original object is a package element, we need to: + * 1. Set the reference count of the new object to match the + * reference count of the old object. + * 2. Decrement the reference count of the original object. + */ + if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) + { + NewObject->Common.ReferenceCount = + ReturnObject->Common.ReferenceCount; + + if (ReturnObject->Common.ReferenceCount > 1) + { + ReturnObject->Common.ReferenceCount--; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Converted %s to expected %s at index %u\n", + Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject), + AcpiUtGetObjectTypeName (NewObject), PackageIndex)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Converted %s to expected %s\n", + Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject), + AcpiUtGetObjectTypeName (NewObject))); + } + + /* Delete old object, install the new return object */ + + AcpiUtRemoveReference (ReturnObject); + *ReturnObjectPtr = NewObject; + Data->Flags |= ACPI_OBJECT_REPAIRED; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToInteger + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToInteger ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_STATUS Status; + UINT64 Value = 0; + UINT32 i; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_STRING: + + /* String-to-Integer conversion */ + + Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, + ACPI_ANY_BASE, &Value); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_BUFFER: + + /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */ + + if (OriginalObject->Buffer.Length > 8) + { + return (AE_AML_OPERAND_TYPE); + } + + /* Extract each buffer byte to create the integer */ + + for (i = 0; i < OriginalObject->Buffer.Length; i++) + { + Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8)); + } + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + NewObject = AcpiUtCreateIntegerObject (Value); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToString + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToString ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_SIZE Length; + ACPI_STATUS Status; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + /* + * Integer-to-String conversion. Commonly, convert + * an integer of value 0 to a NULL string. The last element of + * _BIF and _BIX packages occasionally need this fix. + */ + if (OriginalObject->Integer.Value == 0) + { + /* Allocate a new NULL string object */ + + NewObject = AcpiUtCreateStringObject (0); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + } + else + { + Status = AcpiExConvertToString (OriginalObject, &NewObject, + ACPI_IMPLICIT_CONVERT_HEX); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + break; + + case ACPI_TYPE_BUFFER: + /* + * Buffer-to-String conversion. Use a ToString + * conversion, no transform performed on the buffer data. The best + * example of this is the _BIF method, where the string data from + * the battery is often (incorrectly) returned as buffer object(s). + */ + Length = 0; + while ((Length < OriginalObject->Buffer.Length) && + (OriginalObject->Buffer.Pointer[Length])) + { + Length++; + } + + /* Allocate a new string object */ + + NewObject = AcpiUtCreateStringObject (Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* + * Copy the raw buffer data with no transform. String is already NULL + * terminated at Length+1. + */ + ACPI_MEMCPY (NewObject->String.Pointer, + OriginalObject->Buffer.Pointer, Length); + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToBuffer + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToBuffer ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Elements; + UINT32 *DwordBuffer; + UINT32 Count; + UINT32 i; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + /* + * Integer-to-Buffer conversion. + * Convert the Integer to a packed-byte buffer. _MAT and other + * objects need this sometimes, if a read has been performed on a + * Field object that is less than or equal to the global integer + * size (32 or 64 bits). + */ + Status = AcpiExConvertToBuffer (OriginalObject, &NewObject); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_STRING: + + /* String-to-Buffer conversion. Simple data copy */ + + NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + ACPI_MEMCPY (NewObject->Buffer.Pointer, + OriginalObject->String.Pointer, OriginalObject->String.Length); + break; + + case ACPI_TYPE_PACKAGE: + /* + * This case is often seen for predefined names that must return a + * Buffer object with multiple DWORD integers within. For example, + * _FDE and _GTM. The Package can be converted to a Buffer. + */ + + /* All elements of the Package must be integers */ + + Elements = OriginalObject->Package.Elements; + Count = OriginalObject->Package.Count; + + for (i = 0; i < Count; i++) + { + if ((!*Elements) || + ((*Elements)->Common.Type != ACPI_TYPE_INTEGER)) + { + return (AE_AML_OPERAND_TYPE); + } + Elements++; + } + + /* Create the new buffer object to replace the Package */ + + NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count)); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* Copy the package elements (integers) to the buffer as DWORDs */ + + Elements = OriginalObject->Package.Elements; + DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer); + + for (i = 0; i < Count; i++) + { + *DwordBuffer = (UINT32) (*Elements)->Integer.Value; + DwordBuffer++; + Elements++; + } + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToPackage + * + * PARAMETERS: OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of + * the buffer is converted to a single integer package element. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsConvertToPackage ( + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject; + ACPI_OPERAND_OBJECT **Elements; + UINT32 Length; + UINT8 *Buffer; + + + switch (OriginalObject->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* Buffer-to-Package conversion */ + + Length = OriginalObject->Buffer.Length; + NewObject = AcpiUtCreatePackageObject (Length); + if (!NewObject) + { + return (AE_NO_MEMORY); + } + + /* Convert each buffer byte to an integer package element */ + + Elements = NewObject->Package.Elements; + Buffer = OriginalObject->Buffer.Pointer; + + while (Length--) + { + *Elements = AcpiUtCreateIntegerObject ((UINT64) *Buffer); + if (!*Elements) + { + AcpiUtRemoveReference (NewObject); + return (AE_NO_MEMORY); + } + Elements++; + Buffer++; + } + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + *ReturnObject = NewObject; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRepairPackageList + * + * PARAMETERS: Data - Pointer to validation data structure + * ObjDescPtr - Pointer to the object to repair. The new + * package object is returned here, + * overwriting the old object. + * + * RETURN: Status, new object in *ObjDescPtr + * + * DESCRIPTION: Repair a common problem with objects that are defined to return + * a variable-length Package of Packages. If the variable-length + * is one, some BIOS code mistakenly simply declares a single + * Package instead of a Package with one sub-Package. This + * function attempts to repair this error by wrapping a Package + * object around the original Package, creating the correct + * Package with one sub-Package. + * + * Names that can be repaired in this manner include: + * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRepairPackageList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_OPERAND_OBJECT *PkgObjDesc; + + + ACPI_FUNCTION_NAME (NsRepairPackageList); + + + /* + * Create the new outer package and populate it. The new package will + * have a single element, the lone subpackage. + */ + PkgObjDesc = AcpiUtCreatePackageObject (1); + if (!PkgObjDesc) + { + return (AE_NO_MEMORY); + } + + PkgObjDesc->Package.Elements[0] = *ObjDescPtr; + + /* Return the new object in the object pointer */ + + *ObjDescPtr = PkgObjDesc; + Data->Flags |= ACPI_OBJECT_REPAIRED; + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Repaired incorrectly formed Package\n", Data->Pathname)); + + return (AE_OK); +} diff --git a/drivers/bus/acpi/acpica/namespace/nsrepair2.c b/drivers/bus/acpi/acpica/namespace/nsrepair2.c new file mode 100644 index 00000000000..c08028452b4 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsrepair2.c @@ -0,0 +1,796 @@ +/****************************************************************************** + * + * Module Name: nsrepair2 - Repair for objects returned by specific + * predefined methods + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSREPAIR2_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acpredef.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsrepair2") + + +/* + * Information structure and handler for ACPI predefined names that can + * be repaired on a per-name basis. + */ +typedef +ACPI_STATUS (*ACPI_REPAIR_FUNCTION) ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +typedef struct acpi_repair_info +{ + char Name[ACPI_NAME_SIZE]; + ACPI_REPAIR_FUNCTION RepairFunction; + +} ACPI_REPAIR_INFO; + + +/* Local prototypes */ + +static const ACPI_REPAIR_INFO * +AcpiNsMatchRepairableName ( + ACPI_NAMESPACE_NODE *Node); + +static ACPI_STATUS +AcpiNsRepair_ALR ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_FDE ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_PSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsRepair_TSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsCheckSortedList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject, + UINT32 ExpectedCount, + UINT32 SortIndex, + UINT8 SortDirection, + char *SortKeyName); + +static ACPI_STATUS +AcpiNsSortList ( + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count, + UINT32 Index, + UINT8 SortDirection); + +/* Values for SortDirection above */ + +#define ACPI_SORT_ASCENDING 0 +#define ACPI_SORT_DESCENDING 1 + + +/* + * This table contains the names of the predefined methods for which we can + * perform more complex repairs. + * + * As necessary: + * + * _ALR: Sort the list ascending by AmbientIlluminance + * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs + * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs + * _PSS: Sort the list descending by Power + * _TSS: Sort the list descending by Power + */ +static const ACPI_REPAIR_INFO AcpiNsRepairableNames[] = +{ + {"_ALR", AcpiNsRepair_ALR}, + {"_FDE", AcpiNsRepair_FDE}, + {"_GTM", AcpiNsRepair_FDE}, /* _GTM has same repair as _FDE */ + {"_PSS", AcpiNsRepair_PSS}, + {"_TSS", AcpiNsRepair_TSS}, + {{0,0,0,0}, NULL} /* Table terminator */ +}; + + +#define ACPI_FDE_FIELD_COUNT 5 +#define ACPI_FDE_BYTE_BUFFER_SIZE 5 +#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (UINT32)) + + +/****************************************************************************** + * + * FUNCTION: AcpiNsComplexRepairs + * + * PARAMETERS: Data - Pointer to validation data structure + * Node - Namespace node for the method/object + * ValidateStatus - Original status of earlier validation + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if repair was successful. If name is not + * matched, ValidateStatus is returned. + * + * DESCRIPTION: Attempt to repair/convert a return object of a type that was + * not expected. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiNsComplexRepairs ( + ACPI_PREDEFINED_DATA *Data, + ACPI_NAMESPACE_NODE *Node, + ACPI_STATUS ValidateStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + const ACPI_REPAIR_INFO *Predefined; + ACPI_STATUS Status; + + + /* Check if this name is in the list of repairable names */ + + Predefined = AcpiNsMatchRepairableName (Node); + if (!Predefined) + { + return (ValidateStatus); + } + + Status = Predefined->RepairFunction (Data, ReturnObjectPtr); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsMatchRepairableName + * + * PARAMETERS: Node - Namespace node for the method/object + * + * RETURN: Pointer to entry in repair table. NULL indicates not found. + * + * DESCRIPTION: Check an object name against the repairable object list. + * + *****************************************************************************/ + +static const ACPI_REPAIR_INFO * +AcpiNsMatchRepairableName ( + ACPI_NAMESPACE_NODE *Node) +{ + const ACPI_REPAIR_INFO *ThisName; + + + /* Search info table for a repairable predefined method/object name */ + + ThisName = AcpiNsRepairableNames; + while (ThisName->RepairFunction) + { + if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Name)) + { + return (ThisName); + } + ThisName++; + } + + return (NULL); /* Not found */ +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_ALR + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list + * ascending by the ambient illuminance values. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_ALR ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status; + + + Status = AcpiNsCheckSortedList (Data, ReturnObject, 2, 1, + ACPI_SORT_ASCENDING, "AmbientIlluminance"); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_FDE + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return + * value is a Buffer of 5 DWORDs. This function repairs a common + * problem where the return value is a Buffer of BYTEs, not + * DWORDs. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_FDE ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT *BufferObject; + UINT8 *ByteBuffer; + UINT32 *DwordBuffer; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsRepair_FDE); + + + switch (ReturnObject->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* This is the expected type. Length should be (at least) 5 DWORDs */ + + if (ReturnObject->Buffer.Length >= ACPI_FDE_DWORD_BUFFER_SIZE) + { + return (AE_OK); + } + + /* We can only repair if we have exactly 5 BYTEs */ + + if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Incorrect return buffer length %u, expected %u", + ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE)); + + return (AE_AML_OPERAND_TYPE); + } + + /* Create the new (larger) buffer object */ + + BufferObject = AcpiUtCreateBufferObject (ACPI_FDE_DWORD_BUFFER_SIZE); + if (!BufferObject) + { + return (AE_NO_MEMORY); + } + + /* Expand each byte to a DWORD */ + + ByteBuffer = ReturnObject->Buffer.Pointer; + DwordBuffer = ACPI_CAST_PTR (UINT32, BufferObject->Buffer.Pointer); + + for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) + { + *DwordBuffer = (UINT32) *ByteBuffer; + DwordBuffer++; + ByteBuffer++; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s Expanded Byte Buffer to expected DWord Buffer\n", + Data->Pathname)); + break; + + default: + return (AE_AML_OPERAND_TYPE); + } + + /* Delete the original return object, return the new buffer object */ + + AcpiUtRemoveReference (ReturnObject); + *ReturnObjectPtr = BufferObject; + + Data->Flags |= ACPI_OBJECT_REPAIRED; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_TSS + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list + * descending by the power dissipation values. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_TSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status; + + + Status = AcpiNsCheckSortedList (Data, ReturnObject, 5, 1, + ACPI_SORT_DESCENDING, "PowerDissipation"); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRepair_PSS + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status. AE_OK if object is OK or was repaired successfully + * + * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list + * by the CPU frequencies. Check that the power dissipation values + * are all proportional to CPU frequency (i.e., sorting by + * frequency should be the same as sorting by power.) + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsRepair_PSS ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_OPERAND_OBJECT **OuterElements; + UINT32 OuterElementCount; + ACPI_OPERAND_OBJECT **Elements; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 PreviousValue; + ACPI_STATUS Status; + UINT32 i; + + + /* + * Entries (sub-packages) in the _PSS Package must be sorted by power + * dissipation, in descending order. If it appears that the list is + * incorrectly sorted, sort it. We sort by CpuFrequency, since this + * should be proportional to the power. + */ + Status =AcpiNsCheckSortedList (Data, ReturnObject, 6, 0, + ACPI_SORT_DESCENDING, "CpuFrequency"); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * We now know the list is correctly sorted by CPU frequency. Check if + * the power dissipation values are proportional. + */ + PreviousValue = ACPI_UINT32_MAX; + OuterElements = ReturnObject->Package.Elements; + OuterElementCount = ReturnObject->Package.Count; + + for (i = 0; i < OuterElementCount; i++) + { + Elements = (*OuterElements)->Package.Elements; + ObjDesc = Elements[1]; /* Index1 = PowerDissipation */ + + if ((UINT32) ObjDesc->Integer.Value > PreviousValue) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "SubPackage[%u,%u] - suspicious power dissipation values", + i-1, i)); + } + + PreviousValue = (UINT32) ObjDesc->Integer.Value; + OuterElements++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsCheckSortedList + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObject - Pointer to the top-level returned object + * ExpectedCount - Minimum length of each sub-package + * SortIndex - Sub-package entry to sort on + * SortDirection - Ascending or descending + * SortKeyName - Name of the SortIndex field + * + * RETURN: Status. AE_OK if the list is valid and is sorted correctly or + * has been repaired by sorting the list. + * + * DESCRIPTION: Check if the package list is valid and sorted correctly by the + * SortIndex. If not, then sort the list. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckSortedList ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject, + UINT32 ExpectedCount, + UINT32 SortIndex, + UINT8 SortDirection, + char *SortKeyName) +{ + UINT32 OuterElementCount; + ACPI_OPERAND_OBJECT **OuterElements; + ACPI_OPERAND_OBJECT **Elements; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 i; + UINT32 PreviousValue; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (NsCheckSortedList); + + + /* The top-level object must be a package */ + + if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) + { + return (AE_AML_OPERAND_TYPE); + } + + /* + * NOTE: assumes list of sub-packages contains no NULL elements. + * Any NULL elements should have been removed by earlier call + * to AcpiNsRemoveNullElements. + */ + OuterElements = ReturnObject->Package.Elements; + OuterElementCount = ReturnObject->Package.Count; + if (!OuterElementCount) + { + return (AE_AML_PACKAGE_LIMIT); + } + + PreviousValue = 0; + if (SortDirection == ACPI_SORT_DESCENDING) + { + PreviousValue = ACPI_UINT32_MAX; + } + + /* Examine each subpackage */ + + for (i = 0; i < OuterElementCount; i++) + { + /* Each element of the top-level package must also be a package */ + + if ((*OuterElements)->Common.Type != ACPI_TYPE_PACKAGE) + { + return (AE_AML_OPERAND_TYPE); + } + + /* Each sub-package must have the minimum length */ + + if ((*OuterElements)->Package.Count < ExpectedCount) + { + return (AE_AML_PACKAGE_LIMIT); + } + + Elements = (*OuterElements)->Package.Elements; + ObjDesc = Elements[SortIndex]; + + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + return (AE_AML_OPERAND_TYPE); + } + + /* + * The list must be sorted in the specified order. If we detect a + * discrepancy, issue a warning and sort the entire list + */ + if (((SortDirection == ACPI_SORT_ASCENDING) && + (ObjDesc->Integer.Value < PreviousValue)) || + ((SortDirection == ACPI_SORT_DESCENDING) && + (ObjDesc->Integer.Value > PreviousValue))) + { + Status = AcpiNsSortList (ReturnObject->Package.Elements, + OuterElementCount, SortIndex, SortDirection); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Data->Flags |= ACPI_OBJECT_REPAIRED; + + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Repaired unsorted list - now sorted by %s\n", + Data->Pathname, SortKeyName)); + return (AE_OK); + } + + PreviousValue = (UINT32) ObjDesc->Integer.Value; + OuterElements++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsRemoveNullElements + * + * PARAMETERS: Data - Pointer to validation data structure + * PackageType - An AcpiReturnPackageTypes value + * ObjDesc - A Package object + * + * RETURN: None. + * + * DESCRIPTION: Remove all NULL package elements from packages that contain + * a variable number of sub-packages. + * + *****************************************************************************/ + +void +AcpiNsRemoveNullElements ( + ACPI_PREDEFINED_DATA *Data, + UINT8 PackageType, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT **Source; + ACPI_OPERAND_OBJECT **Dest; + UINT32 Count; + UINT32 NewCount; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsRemoveNullElements); + + + /* + * PTYPE1 packages contain no subpackages. + * PTYPE2 packages contain a variable number of sub-packages. We can + * safely remove all NULL elements from the PTYPE2 packages. + */ + switch (PackageType) + { + case ACPI_PTYPE1_FIXED: + case ACPI_PTYPE1_VAR: + case ACPI_PTYPE1_OPTION: + return; + + case ACPI_PTYPE2: + case ACPI_PTYPE2_COUNT: + case ACPI_PTYPE2_PKG_COUNT: + case ACPI_PTYPE2_FIXED: + case ACPI_PTYPE2_MIN: + case ACPI_PTYPE2_REV_FIXED: + break; + + default: + return; + } + + Count = ObjDesc->Package.Count; + NewCount = Count; + + Source = ObjDesc->Package.Elements; + Dest = Source; + + /* Examine all elements of the package object, remove nulls */ + + for (i = 0; i < Count; i++) + { + if (!*Source) + { + NewCount--; + } + else + { + *Dest = *Source; + Dest++; + } + Source++; + } + + /* Update parent package if any null elements were removed */ + + if (NewCount < Count) + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Found and removed %u NULL elements\n", + Data->Pathname, (Count - NewCount))); + + /* NULL terminate list and update the package count */ + + *Dest = NULL; + ObjDesc->Package.Count = NewCount; + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsSortList + * + * PARAMETERS: Elements - Package object element list + * Count - Element count for above + * Index - Sort by which package element + * SortDirection - Ascending or Descending sort + * + * RETURN: Status + * + * DESCRIPTION: Sort the objects that are in a package element list. + * + * NOTE: Assumes that all NULL elements have been removed from the package. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiNsSortList ( + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count, + UINT32 Index, + UINT8 SortDirection) +{ + ACPI_OPERAND_OBJECT *ObjDesc1; + ACPI_OPERAND_OBJECT *ObjDesc2; + ACPI_OPERAND_OBJECT *TempObj; + UINT32 i; + UINT32 j; + + + /* Simple bubble sort */ + + for (i = 1; i < Count; i++) + { + for (j = (Count - 1); j >= i; j--) + { + ObjDesc1 = Elements[j-1]->Package.Elements[Index]; + ObjDesc2 = Elements[j]->Package.Elements[Index]; + + if (((SortDirection == ACPI_SORT_ASCENDING) && + (ObjDesc1->Integer.Value > ObjDesc2->Integer.Value)) || + + ((SortDirection == ACPI_SORT_DESCENDING) && + (ObjDesc1->Integer.Value < ObjDesc2->Integer.Value))) + { + TempObj = Elements[j-1]; + Elements[j-1] = Elements[j]; + Elements[j] = TempObj; + } + } + } + + return (AE_OK); +} diff --git a/drivers/bus/acpi/acpica/namespace/nssearch.c b/drivers/bus/acpi/acpica/namespace/nssearch.c new file mode 100644 index 00000000000..fce7c5ad4de --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nssearch.c @@ -0,0 +1,507 @@ +/******************************************************************************* + * + * Module Name: nssearch - Namespace search + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSSEARCH_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#ifdef ACPI_ASL_COMPILER +#include "amlcode.h" +#endif + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nssearch") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchOneScope + * + * PARAMETERS: TargetName - Ascii ACPI name to search for + * ParentNode - Starting node where search will begin + * Type - Object type to match + * ReturnNode - Where the matched Named obj is returned + * + * RETURN: Status + * + * DESCRIPTION: Search a single level of the namespace. Performs a + * simple search of the specified level, and does not add + * entries or search parents. + * + * + * Named object lists are built (and subsequently dumped) in the + * order in which the names are encountered during the namespace load; + * + * All namespace searching is linear in this implementation, but + * could be easily modified to support any improved search + * algorithm. However, the linear search was chosen for simplicity + * and because the trees are small and the other interpreter + * execution overhead is relatively high. + * + * Note: CPU execution analysis has shown that the AML interpreter spends + * a very small percentage of its time searching the namespace. Therefore, + * the linear search seems to be sufficient, as there would seem to be + * little value in improving the search. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchOneScope ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (NsSearchOneScope); + + +#ifdef ACPI_DEBUG_OUTPUT + if (ACPI_LV_NAMES & AcpiDbgLevel) + { + char *ScopeName; + + ScopeName = AcpiNsGetExternalPathname (ParentNode); + if (ScopeName) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching %s (%p) For [%4.4s] (%s)\n", + ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName), + AcpiUtGetTypeName (Type))); + + ACPI_FREE (ScopeName); + } + } +#endif + + /* + * Search for name at this namespace level, which is to say that we + * must search for the name among the children of this object + */ + Node = ParentNode->Child; + while (Node) + { + /* Check for match against the name */ + + if (Node->Name.Integer == TargetName) + { + /* Resolve a control method alias if any */ + + if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + { + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); + } + + /* Found matching entry */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", + ACPI_CAST_PTR (char, &TargetName), + AcpiUtGetTypeName (Node->Type), + Node, AcpiUtGetNodeName (ParentNode), ParentNode)); + + *ReturnNode = Node; + return_ACPI_STATUS (AE_OK); + } + + /* + * The last entry in the list points back to the parent, + * so a flag is used to indicate the end-of-list + */ + if (Node->Flags & ANOBJ_END_OF_PEER_LIST) + { + /* Searched entire list, we are done */ + + break; + } + + /* Didn't match name, move on to the next peer object */ + + Node = Node->Peer; + } + + /* Searched entire namespace level, not found */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Name [%4.4s] (%s) not found in search in scope [%4.4s] " + "%p first child %p\n", + ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type), + AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child)); + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchParentTree + * + * PARAMETERS: TargetName - Ascii ACPI name to search for + * Node - Starting node where search will begin + * Type - Object type to match + * ReturnNode - Where the matched Node is returned + * + * RETURN: Status + * + * DESCRIPTION: Called when a name has not been found in the current namespace + * level. Before adding it or giving up, ACPI scope rules require + * searching enclosing scopes in cases identified by AcpiNsLocal(). + * + * "A name is located by finding the matching name in the current + * name space, and then in the parent name space. If the parent + * name space does not contain the name, the search continues + * recursively until either the name is found or the name space + * does not have a parent (the root of the name space). This + * indicates that the name is not found" (From ACPI Specification, + * section 5.3) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_TRACE (NsSearchParentTree); + + + ParentNode = AcpiNsGetParentNode (Node); + + /* + * If there is no parent (i.e., we are at the root) or type is "local", + * we won't be searching the parent tree. + */ + if (!ParentNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", + ACPI_CAST_PTR (char, &TargetName))); + return_ACPI_STATUS (AE_NOT_FOUND); + } + + if (AcpiNsLocal (Type)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "[%4.4s] type [%s] must be local to this scope (no parent search)\n", + ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type))); + return_ACPI_STATUS (AE_NOT_FOUND); + } + + /* Search the parent tree */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching parent [%4.4s] for [%4.4s]\n", + AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName))); + + /* Search parents until target is found or we have backed up to the root */ + + while (ParentNode) + { + /* + * Search parent scope. Use TYPE_ANY because we don't care about the + * object type at this point, we only care about the existence of + * the actual name we are searching for. Typechecking comes later. + */ + Status = AcpiNsSearchOneScope ( + TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Not found here, go up another level (until we reach the root) */ + + ParentNode = AcpiNsGetParentNode (ParentNode); + } + + /* Not found in parent tree */ + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchAndEnter + * + * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) + * WalkState - Current state of the walk + * Node - Starting node where search will begin + * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x. + * Otherwise,search only. + * Type - Object type to match + * Flags - Flags describing the search restrictions + * ReturnNode - Where the Node is returned + * + * RETURN: Status + * + * DESCRIPTION: Search for a name segment in a single namespace level, + * optionally adding it if it is not found. If the passed + * Type is not Any and the type previously stored in the + * entry was Any (i.e. unknown), update the stored type. + * + * In ACPI_IMODE_EXECUTE, search only. + * In other modes, search and add if not found. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 TargetName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_INTERPRETER_MODE InterpreterMode, + ACPI_OBJECT_TYPE Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *NewNode; + + + ACPI_FUNCTION_TRACE (NsSearchAndEnter); + + + /* Parameter validation */ + + if (!Node || !TargetName || !ReturnNode) + { + ACPI_ERROR ((AE_INFO, + "Null parameter: Node %p Name %X ReturnNode %p", + Node, TargetName, ReturnNode)); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Name must consist of valid ACPI characters. We will repair the name if + * necessary because we don't want to abort because of this, but we want + * all namespace names to be printable. A warning message is appropriate. + * + * This issue came up because there are in fact machines that exhibit + * this problem, and we want to be able to enable ACPI support for them, + * even though there are a few bad names. + */ + AcpiUtRepairName (ACPI_CAST_PTR (char, &TargetName)); + + /* Try to find the name in the namespace level specified by the caller */ + + *ReturnNode = ACPI_ENTRY_NOT_FOUND; + Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode); + if (Status != AE_NOT_FOUND) + { + /* + * If we found it AND the request specifies that a find is an error, + * return the error + */ + if ((Status == AE_OK) && + (Flags & ACPI_NS_ERROR_IF_FOUND)) + { + Status = AE_ALREADY_EXISTS; + } + +#ifdef ACPI_ASL_COMPILER + if (*ReturnNode && (*ReturnNode)->Type == ACPI_TYPE_ANY) + { + (*ReturnNode)->Flags |= ANOBJ_IS_EXTERNAL; + } +#endif + + /* Either found it or there was an error: finished either way */ + + return_ACPI_STATUS (Status); + } + + /* + * The name was not found. If we are NOT performing the first pass + * (name entry) of loading the namespace, search the parent tree (all the + * way to the root if necessary.) We don't want to perform the parent + * search when the namespace is actually being loaded. We want to perform + * the search when namespace references are being resolved (load pass 2) + * and during the execution phase. + */ + if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) && + (Flags & ACPI_NS_SEARCH_PARENT)) + { + /* + * Not found at this level - search parent tree according to the + * ACPI specification + */ + Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* In execute mode, just search, never add names. Exit now */ + + if (InterpreterMode == ACPI_IMODE_EXECUTE) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%4.4s Not found in %p [Not adding]\n", + ACPI_CAST_PTR (char, &TargetName), Node)); + + return_ACPI_STATUS (AE_NOT_FOUND); + } + + /* Create the new named object */ + + NewNode = AcpiNsCreateNode (TargetName); + if (!NewNode) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + +#ifdef ACPI_ASL_COMPILER + + /* Node is an object defined by an External() statement */ + + if (Flags & ACPI_NS_EXTERNAL || + (WalkState && WalkState->Opcode == AML_SCOPE_OP)) + { + NewNode->Flags |= ANOBJ_IS_EXTERNAL; + } +#endif + + if (Flags & ACPI_NS_TEMPORARY) + { + NewNode->Flags |= ANOBJ_TEMPORARY; + } + + /* Install the new object into the parent's list of children */ + + AcpiNsInstallNode (WalkState, Node, NewNode, Type); + *ReturnNode = NewNode; + return_ACPI_STATUS (AE_OK); +} + diff --git a/drivers/bus/acpi/acpica/namespace/nsutils.c b/drivers/bus/acpi/acpica/namespace/nsutils.c new file mode 100644 index 00000000000..ed0c3f7ec81 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsutils.c @@ -0,0 +1,1184 @@ +/****************************************************************************** + * + * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing + * parents and siblings and Scope manipulation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsutils") + +/* Local prototypes */ + +static BOOLEAN +AcpiNsValidPathSeparator ( + char Sep); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *NodeToSearch); +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiNsReportError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * InternalName - Name or path of the namespace node + * LookupStatus - Exception code from NS lookup + * + * RETURN: None + * + * DESCRIPTION: Print warning message with full pathname + * + ******************************************************************************/ + +void +AcpiNsReportError ( + const char *ModuleName, + UINT32 LineNumber, + const char *InternalName, + ACPI_STATUS LookupStatus) +{ + ACPI_STATUS Status; + UINT32 BadName; + char *Name = NULL; + + + AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); + + if (LookupStatus == AE_BAD_CHARACTER) + { + /* There is a non-ascii character in the name */ + + ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName)); + AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName); + } + else + { + /* Convert path to external format */ + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, + InternalName, NULL, &Name); + + /* Print target name */ + + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf ("[%s]", Name); + } + else + { + AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]"); + } + + if (Name) + { + ACPI_FREE (Name); + } + } + + AcpiOsPrintf (" Namespace lookup failure, %s\n", + AcpiFormatException (LookupStatus)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsReportMethodError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Message - Error message to use on failure + * PrefixNode - Prefix relative to the path + * Path - Path to the node (optional) + * MethodStatus - Execution status + * + * RETURN: None + * + * DESCRIPTION: Print warning message with full pathname + * + ******************************************************************************/ + +void +AcpiNsReportMethodError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Message, + ACPI_NAMESPACE_NODE *PrefixNode, + const char *Path, + ACPI_STATUS MethodStatus) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = PrefixNode; + + + AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); + + if (Path) + { + Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH, + &Node); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("[Could not get node by pathname]"); + } + } + + AcpiNsPrintNodePathname (Node, Message); + AcpiOsPrintf (", %s\n", AcpiFormatException (MethodStatus)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsPrintNodePathname + * + * PARAMETERS: Node - Object + * Message - Prefix message + * + * DESCRIPTION: Print an object's full namespace pathname + * Manages allocation/freeing of a pathname buffer + * + ******************************************************************************/ + +void +AcpiNsPrintNodePathname ( + ACPI_NAMESPACE_NODE *Node, + const char *Message) +{ + ACPI_BUFFER Buffer; + ACPI_STATUS Status; + + + if (!Node) + { + AcpiOsPrintf ("[NULL NAME]"); + return; + } + + /* Convert handle to full pathname and print it (with supplied message) */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + + Status = AcpiNsHandleToPathname (Node, &Buffer); + if (ACPI_SUCCESS (Status)) + { + if (Message) + { + AcpiOsPrintf ("%s ", Message); + } + + AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node); + ACPI_FREE (Buffer.Pointer); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsValidRootPrefix + * + * PARAMETERS: Prefix - Character to be checked + * + * RETURN: TRUE if a valid prefix + * + * DESCRIPTION: Check if a character is a valid ACPI Root prefix + * + ******************************************************************************/ + +BOOLEAN +AcpiNsValidRootPrefix ( + char Prefix) +{ + + return ((BOOLEAN) (Prefix == '\\')); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsValidPathSeparator + * + * PARAMETERS: Sep - Character to be checked + * + * RETURN: TRUE if a valid path separator + * + * DESCRIPTION: Check if a character is a valid ACPI path separator + * + ******************************************************************************/ + +static BOOLEAN +AcpiNsValidPathSeparator ( + char Sep) +{ + + return ((BOOLEAN) (Sep == '.')); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetType + * + * PARAMETERS: Node - Parent Node to be examined + * + * RETURN: Type field from Node whose handle is passed + * + * DESCRIPTION: Return the type of a Namespace node + * + ******************************************************************************/ + +ACPI_OBJECT_TYPE +AcpiNsGetType ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_FUNCTION_TRACE (NsGetType); + + + if (!Node) + { + ACPI_WARNING ((AE_INFO, "Null Node parameter")); + return_UINT32 (ACPI_TYPE_ANY); + } + + return_UINT32 ((ACPI_OBJECT_TYPE) Node->Type); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsLocal + * + * PARAMETERS: Type - A namespace object type + * + * RETURN: LOCAL if names must be found locally in objects of the + * passed type, 0 if enclosing scopes should be searched + * + * DESCRIPTION: Returns scope rule for the given object type. + * + ******************************************************************************/ + +UINT32 +AcpiNsLocal ( + ACPI_OBJECT_TYPE Type) +{ + ACPI_FUNCTION_TRACE (NsLocal); + + + if (!AcpiUtValidObjectType (Type)) + { + /* Type code out of range */ + + ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type)); + return_UINT32 (ACPI_NS_NORMAL); + } + + return_UINT32 ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetInternalNameLength + * + * PARAMETERS: Info - Info struct initialized with the + * external name pointer. + * + * RETURN: None + * + * DESCRIPTION: Calculate the length of the internal (AML) namestring + * corresponding to the external (ASL) namestring. + * + ******************************************************************************/ + +void +AcpiNsGetInternalNameLength ( + ACPI_NAMESTRING_INFO *Info) +{ + const char *NextExternalChar; + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + NextExternalChar = Info->ExternalName; + Info->NumCarats = 0; + Info->NumSegments = 0; + Info->FullyQualified = FALSE; + + /* + * For the internal name, the required length is 4 bytes per segment, plus + * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null + * (which is not really needed, but no there's harm in putting it there) + * + * strlen() + 1 covers the first NameSeg, which has no path separator + */ + if (AcpiNsValidRootPrefix (*NextExternalChar)) + { + Info->FullyQualified = TRUE; + NextExternalChar++; + + /* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */ + + while (AcpiNsValidRootPrefix (*NextExternalChar)) + { + NextExternalChar++; + } + } + else + { + /* Handle Carat prefixes */ + + while (*NextExternalChar == '^') + { + Info->NumCarats++; + NextExternalChar++; + } + } + + /* + * Determine the number of ACPI name "segments" by counting the number of + * path separators within the string. Start with one segment since the + * segment count is [(# separators) + 1], and zero separators is ok. + */ + if (*NextExternalChar) + { + Info->NumSegments = 1; + for (i = 0; NextExternalChar[i]; i++) + { + if (AcpiNsValidPathSeparator (NextExternalChar[i])) + { + Info->NumSegments++; + } + } + } + + Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) + + 4 + Info->NumCarats; + + Info->NextExternalChar = NextExternalChar; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsBuildInternalName + * + * PARAMETERS: Info - Info struct fully initialized + * + * RETURN: Status + * + * DESCRIPTION: Construct the internal (AML) namestring + * corresponding to the external (ASL) namestring. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsBuildInternalName ( + ACPI_NAMESTRING_INFO *Info) +{ + UINT32 NumSegments = Info->NumSegments; + char *InternalName = Info->InternalName; + const char *ExternalName = Info->NextExternalChar; + char *Result = NULL; + UINT32 i; + + + ACPI_FUNCTION_TRACE (NsBuildInternalName); + + + /* Setup the correct prefixes, counts, and pointers */ + + if (Info->FullyQualified) + { + InternalName[0] = '\\'; + + if (NumSegments <= 1) + { + Result = &InternalName[1]; + } + else if (NumSegments == 2) + { + InternalName[1] = AML_DUAL_NAME_PREFIX; + Result = &InternalName[2]; + } + else + { + InternalName[1] = AML_MULTI_NAME_PREFIX_OP; + InternalName[2] = (char) NumSegments; + Result = &InternalName[3]; + } + } + else + { + /* + * Not fully qualified. + * Handle Carats first, then append the name segments + */ + i = 0; + if (Info->NumCarats) + { + for (i = 0; i < Info->NumCarats; i++) + { + InternalName[i] = '^'; + } + } + + if (NumSegments <= 1) + { + Result = &InternalName[i]; + } + else if (NumSegments == 2) + { + InternalName[i] = AML_DUAL_NAME_PREFIX; + Result = &InternalName[(ACPI_SIZE) i+1]; + } + else + { + InternalName[i] = AML_MULTI_NAME_PREFIX_OP; + InternalName[(ACPI_SIZE) i+1] = (char) NumSegments; + Result = &InternalName[(ACPI_SIZE) i+2]; + } + } + + /* Build the name (minus path separators) */ + + for (; NumSegments; NumSegments--) + { + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (AcpiNsValidPathSeparator (*ExternalName) || + (*ExternalName == 0)) + { + /* Pad the segment with underscore(s) if segment is short */ + + Result[i] = '_'; + } + else + { + /* Convert the character to uppercase and save it */ + + Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName); + ExternalName++; + } + } + + /* Now we must have a path separator, or the pathname is bad */ + + if (!AcpiNsValidPathSeparator (*ExternalName) && + (*ExternalName != 0)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Move on the next segment */ + + ExternalName++; + Result += ACPI_NAME_SIZE; + } + + /* Terminate the string */ + + *Result = 0; + + if (Info->FullyQualified) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n", + InternalName, InternalName)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n", + InternalName, InternalName)); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInternalizeName + * + * PARAMETERS: *ExternalName - External representation of name + * **Converted Name - Where to return the resulting + * internal represention of the name + * + * RETURN: Status + * + * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0") + * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * + *******************************************************************************/ + +ACPI_STATUS +AcpiNsInternalizeName ( + const char *ExternalName, + char **ConvertedName) +{ + char *InternalName; + ACPI_NAMESTRING_INFO Info; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsInternalizeName); + + + if ((!ExternalName) || + (*ExternalName == 0) || + (!ConvertedName)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the length of the new internal name */ + + Info.ExternalName = ExternalName; + AcpiNsGetInternalNameLength (&Info); + + /* We need a segment to store the internal name */ + + InternalName = ACPI_ALLOCATE_ZEROED (Info.Length); + if (!InternalName) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Build the name */ + + Info.InternalName = InternalName; + Status = AcpiNsBuildInternalName (&Info); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (InternalName); + return_ACPI_STATUS (Status); + } + + *ConvertedName = InternalName; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExternalizeName + * + * PARAMETERS: InternalNameLength - Lenth of the internal name below + * InternalName - Internal representation of name + * ConvertedNameLength - Where the length is returned + * ConvertedName - Where the resulting external name + * is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * to its external (printable) form (e.g. "\_PR_.CPU0") + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + const char *InternalName, + UINT32 *ConvertedNameLength, + char **ConvertedName) +{ + UINT32 NamesIndex = 0; + UINT32 NumSegments = 0; + UINT32 RequiredLength; + UINT32 PrefixLength = 0; + UINT32 i = 0; + UINT32 j = 0; + + + ACPI_FUNCTION_TRACE (NsExternalizeName); + + + if (!InternalNameLength || + !InternalName || + !ConvertedName) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check for a prefix (one '\' | one or more '^') */ + + switch (InternalName[0]) + { + case '\\': + PrefixLength = 1; + break; + + case '^': + for (i = 0; i < InternalNameLength; i++) + { + if (InternalName[i] == '^') + { + PrefixLength = i + 1; + } + else + { + break; + } + } + + if (i == InternalNameLength) + { + PrefixLength = i; + } + + break; + + default: + break; + } + + /* + * Check for object names. Note that there could be 0-255 of these + * 4-byte elements. + */ + if (PrefixLength < InternalNameLength) + { + switch (InternalName[PrefixLength]) + { + case AML_MULTI_NAME_PREFIX_OP: + + /* 4-byte names */ + + NamesIndex = PrefixLength + 2; + NumSegments = (UINT8) + InternalName[(ACPI_SIZE) PrefixLength + 1]; + break; + + case AML_DUAL_NAME_PREFIX: + + /* Two 4-byte names */ + + NamesIndex = PrefixLength + 1; + NumSegments = 2; + break; + + case 0: + + /* NullName */ + + NamesIndex = 0; + NumSegments = 0; + break; + + default: + + /* one 4-byte name */ + + NamesIndex = PrefixLength; + NumSegments = 1; + break; + } + } + + /* + * Calculate the length of ConvertedName, which equals the length + * of the prefix, length of all object names, length of any required + * punctuation ('.') between object names, plus the NULL terminator. + */ + RequiredLength = PrefixLength + (4 * NumSegments) + + ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; + + /* + * Check to see if we're still in bounds. If not, there's a problem + * with InternalName (invalid format). + */ + if (RequiredLength > InternalNameLength) + { + ACPI_ERROR ((AE_INFO, "Invalid internal name")); + return_ACPI_STATUS (AE_BAD_PATHNAME); + } + + /* Build the ConvertedName */ + + *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength); + if (!(*ConvertedName)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + j = 0; + + for (i = 0; i < PrefixLength; i++) + { + (*ConvertedName)[j++] = InternalName[i]; + } + + if (NumSegments > 0) + { + for (i = 0; i < NumSegments; i++) + { + if (i > 0) + { + (*ConvertedName)[j++] = '.'; + } + + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + } + } + + if (ConvertedNameLength) + { + *ConvertedNameLength = (UINT32) RequiredLength; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsValidateHandle + * + * PARAMETERS: Handle - Handle to be validated and typecast to a + * namespace node. + * + * RETURN: A pointer to a namespace node + * + * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special + * cases for the root node. + * + * NOTE: Real integer handles would allow for more verification + * and keep all pointers within this subsystem - however this introduces + * more overhead and has not been necessary to this point. Drivers + * holding handles are typically notified before a node becomes invalid + * due to a table unload. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsValidateHandle ( + ACPI_HANDLE Handle) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* Parameter validation */ + + if ((!Handle) || (Handle == ACPI_ROOT_OBJECT)) + { + return (AcpiGbl_RootNode); + } + + /* We can at least attempt to verify the handle */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED) + { + return (NULL); + } + + return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for namespace and ACPI table storage. + * + ******************************************************************************/ + +void +AcpiNsTerminate ( + void) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (NsTerminate); + + + /* + * 1) Free the entire namespace -- all nodes and objects + * + * Delete all object descriptors attached to namepsace nodes + */ + AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); + + /* Detach any objects attached to the root */ + + ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode); + if (ObjDesc) + { + AcpiNsDetachObject (AcpiGbl_RootNode); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsOpensScope + * + * PARAMETERS: Type - A valid namespace type + * + * RETURN: NEWSCOPE if the passed type "opens a name scope" according + * to the ACPI specification, else 0 + * + ******************************************************************************/ + +UINT32 +AcpiNsOpensScope ( + ACPI_OBJECT_TYPE Type) +{ + ACPI_FUNCTION_TRACE_STR (NsOpensScope, AcpiUtGetTypeName (Type)); + + + if (!AcpiUtValidObjectType (Type)) + { + /* type code out of range */ + + ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type)); + return_UINT32 (ACPI_NS_NORMAL); + } + + return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNode + * + * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The + * \ (backslash) and ^ (carat) prefixes, and the + * . (period) to separate segments are supported. + * PrefixNode - Root of subtree to be searched, or NS_ALL for the + * root of the name space. If Name is fully + * qualified (first INT8 is '\'), the passed value + * of Scope will not be accessed. + * Flags - Used to indicate whether to perform upsearch or + * not. + * ReturnNode - Where the Node is returned + * + * DESCRIPTION: Look up a name relative to a given scope and return the + * corresponding Node. NOTE: Scope can be null. + * + * MUTEX: Locks namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsGetNode ( + ACPI_NAMESPACE_NODE *PrefixNode, + const char *Pathname, + UINT32 Flags, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_GENERIC_STATE ScopeInfo; + ACPI_STATUS Status; + char *InternalPath; + + + ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname)); + + + if (!Pathname) + { + *ReturnNode = PrefixNode; + if (!PrefixNode) + { + *ReturnNode = AcpiGbl_RootNode; + } + return_ACPI_STATUS (AE_OK); + } + + /* Convert path to internal representation */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Must lock namespace during lookup */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Setup lookup scope (search starting point) */ + + ScopeInfo.Scope.Node = PrefixNode; + + /* Lookup the name in the namespace */ + + Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), + NULL, ReturnNode); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n", + Pathname, AcpiFormatException (Status))); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +Cleanup: + ACPI_FREE (InternalPath); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetParentNode + * + * PARAMETERS: Node - Current table entry + * + * RETURN: Parent entry of the given entry + * + * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetParentNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_FUNCTION_ENTRY (); + + + if (!Node) + { + return (NULL); + } + + /* + * Walk to the end of this peer list. The last entry is marked with a flag + * and the peer pointer is really a pointer back to the parent. This saves + * putting a parent back pointer in each and every named object! + */ + while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) + { + Node = Node->Peer; + } + + return (Node->Peer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNextValidNode + * + * PARAMETERS: Node - Current table entry + * + * RETURN: Next valid Node in the linked node list. NULL if no more valid + * nodes. + * + * DESCRIPTION: Find the next valid node within a name table. + * Useful for implementing NULL-end-of-list loops. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextValidNode ( + ACPI_NAMESPACE_NODE *Node) +{ + + /* If we are at the end of this peer list, return NULL */ + + if (Node->Flags & ANOBJ_END_OF_PEER_LIST) + { + return NULL; + } + + /* Otherwise just return the next peer */ + + return (Node->Peer); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiNsFindParentName + * + * PARAMETERS: *ChildNode - Named Obj whose name is to be found + * + * RETURN: The ACPI name + * + * DESCRIPTION: Search for the given obj in its parent scope and return the + * name segment, or "????" if the parent name can't be found + * (which "should not happen"). + * + ******************************************************************************/ + +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_TRACE (NsFindParentName); + + + if (ChildNode) + { + /* Valid entry. Get the parent Node */ + + ParentNode = AcpiNsGetParentNode (ChildNode); + if (ParentNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Parent of %p [%4.4s] is %p [%4.4s]\n", + ChildNode, AcpiUtGetNodeName (ChildNode), + ParentNode, AcpiUtGetNodeName (ParentNode))); + + if (ParentNode->Name.Integer) + { + return_VALUE ((ACPI_NAME) ParentNode->Name.Integer); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Unable to find parent of %p (%4.4s)\n", + ChildNode, AcpiUtGetNodeName (ChildNode))); + } + + return_VALUE (ACPI_UNKNOWN_NAME); +} +#endif + + diff --git a/drivers/bus/acpi/acpica/namespace/nswalk.c b/drivers/bus/acpi/acpica/namespace/nswalk.c new file mode 100644 index 00000000000..7711e9a3768 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nswalk.c @@ -0,0 +1,468 @@ +/****************************************************************************** + * + * Module Name: nswalk - Functions for walking the ACPI namespace + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSWALK_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nswalk") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNextNode + * + * PARAMETERS: ParentNode - Parent node whose children we are + * getting + * ChildNode - Previous child that was found. + * The NEXT child will be returned + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * DESCRIPTION: Return the next peer node within the namespace. If Handle + * is valid, Scope is ignored. Otherwise, the first node + * within Scope is returned. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNode ( + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_FUNCTION_ENTRY (); + + + if (!ChildNode) + { + /* It's really the parent's _scope_ that we want */ + + return (ParentNode->Child); + } + + /* + * Get the next node. + * + * If we are at the end of this peer list, return NULL + */ + if (ChildNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + return NULL; + } + + /* Otherwise just return the next peer */ + + return (ChildNode->Peer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNextNodeTyped + * + * PARAMETERS: Type - Type of node to be searched for + * ParentNode - Parent node whose children we are + * getting + * ChildNode - Previous child that was found. + * The NEXT child will be returned + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * DESCRIPTION: Return the next peer node within the namespace. If Handle + * is valid, Scope is ignored. Otherwise, the first node + * within Scope is returned. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNodeTyped ( + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *NextNode = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + NextNode = AcpiNsGetNextNode (ParentNode, ChildNode); + + /* If any type is OK, we are done */ + + if (Type == ACPI_TYPE_ANY) + { + /* NextNode is NULL if we are at the end-of-list */ + + return (NextNode); + } + + /* Must search for the node -- but within this scope only */ + + while (NextNode) + { + /* If type matches, we are done */ + + if (NextNode->Type == Type) + { + return (NextNode); + } + + /* Otherwise, move on to the next node */ + + NextNode = AcpiNsGetNextValidNode (NextNode); + } + + /* Not found */ + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartNode - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * Flags - Whether to unlock the NS before invoking + * the callback routine + * PreOrderVisit - Called during tree pre-order visit + * when an object of "Type" is found + * PostOrderVisit - Called during tree post-order visit + * when an object of "Type" is found + * Context - Passed to user function(s) above + * ReturnValue - from the UserFunction if terminated + * early. Otherwise, returns NULL. + * RETURNS: Status + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the node specified by StartHandle. + * The callback function is called whenever a node that matches + * the type parameter is found. If the callback function returns + * a non-zero value, the search is terminated immediately and + * this value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the callback function(s) can be + * tailored to each task, whether it is a print function, + * a compare function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartNode, + UINT32 MaxDepth, + UINT32 Flags, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_STATUS MutexStatus; + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_OBJECT_TYPE ChildType; + UINT32 Level; + BOOLEAN NodePreviouslyVisited = FALSE; + + + ACPI_FUNCTION_TRACE (NsWalkNamespace); + + + /* Special case for the namespace Root Node */ + + if (StartNode == ACPI_ROOT_OBJECT) + { + StartNode = AcpiGbl_RootNode; + } + + /* Null child means "get first node" */ + + ParentNode = StartNode; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); + ChildType = ACPI_TYPE_ANY; + Level = 1; + + /* + * Traverse the tree of nodes until we bubble back up to where we + * started. When Level is zero, the loop is done because we have + * bubbled up to (and passed) the original parent handle (StartEntry) + */ + while (Level > 0 && ChildNode) + { + Status = AE_OK; + + /* Found next child, get the type if we are not searching for ANY */ + + if (Type != ACPI_TYPE_ANY) + { + ChildType = ChildNode->Type; + } + + /* + * Ignore all temporary namespace nodes (created during control + * method execution) unless told otherwise. These temporary nodes + * can cause a race condition because they can be deleted during + * the execution of the user function (if the namespace is + * unlocked before invocation of the user function.) Only the + * debugger namespace dump will examine the temporary nodes. + */ + if ((ChildNode->Flags & ANOBJ_TEMPORARY) && + !(Flags & ACPI_NS_WALK_TEMP_NODES)) + { + Status = AE_CTRL_DEPTH; + } + + /* Type must match requested type */ + + else if (ChildType == Type) + { + /* + * Found a matching node, invoke the user callback function. + * Unlock the namespace if flag is set. + */ + if (Flags & ACPI_NS_WALK_UNLOCK) + { + MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (MutexStatus)) + { + return_ACPI_STATUS (MutexStatus); + } + } + + /* + * Invoke the user function, either pre-order or post-order + * or both. + */ + if (!NodePreviouslyVisited) + { + if (PreOrderVisit) + { + Status = PreOrderVisit (ChildNode, Level, + Context, ReturnValue); + } + } + else + { + if (PostOrderVisit) + { + Status = PostOrderVisit (ChildNode, Level, + Context, ReturnValue); + } + } + + if (Flags & ACPI_NS_WALK_UNLOCK) + { + MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (MutexStatus)) + { + return_ACPI_STATUS (MutexStatus); + } + } + + switch (Status) + { + case AE_OK: + case AE_CTRL_DEPTH: + + /* Just keep going */ + break; + + case AE_CTRL_TERMINATE: + + /* Exit now, with OK status */ + + return_ACPI_STATUS (AE_OK); + + default: + + /* All others are valid exceptions */ + + return_ACPI_STATUS (Status); + } + } + + /* + * Depth first search: Attempt to go down another level in the + * namespace if we are allowed to. Don't go any further if we have + * reached the caller specified maximum depth or if the user + * function has specified that the maximum depth has been reached. + */ + if (!NodePreviouslyVisited && + (Level < MaxDepth) && + (Status != AE_CTRL_DEPTH)) + { + if (ChildNode->Child) + { + /* There is at least one child of this node, visit it */ + + Level++; + ParentNode = ChildNode; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); + continue; + } + } + + /* No more children, re-visit this node */ + + if (!NodePreviouslyVisited) + { + NodePreviouslyVisited = TRUE; + continue; + } + + /* No more children, visit peers */ + + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + if (ChildNode) + { + NodePreviouslyVisited = FALSE; + } + + /* No peers, re-visit parent */ + + else + { + /* + * No more children of this node (AcpiNsGetNextNode failed), go + * back upwards in the namespace tree to the node's parent. + */ + Level--; + ChildNode = ParentNode; + ParentNode = AcpiNsGetParentNode (ParentNode); + + NodePreviouslyVisited = TRUE; + } + } + + /* Complete walk, not terminated by user function */ + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/namespace/nsxfeval.c b/drivers/bus/acpi/acpica/namespace/nsxfeval.c new file mode 100644 index 00000000000..a0f96a04ee0 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsxfeval.c @@ -0,0 +1,1020 @@ +/******************************************************************************* + * + * Module Name: nsxfeval - Public interfaces to the ACPI subsystem + * ACPI Object evaluation interfaces + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFEVAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsxfeval") + +/* Local prototypes */ + +static void +AcpiNsResolveReferences ( + ACPI_EVALUATE_INFO *Info); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvaluateObjectTyped + * + * PARAMETERS: Handle - Object handle (optional) + * Pathname - Object pathname (optional) + * ExternalParams - List of parameters to pass to method, + * terminated by NULL. May be NULL + * if no parameters are being passed. + * ReturnBuffer - Where to put method's return value (if + * any). If NULL, no value is returned. + * ReturnType - Expected type of return object + * + * RETURN: Status + * + * DESCRIPTION: Find and evaluate the given object, passing the given + * parameters if necessary. One of "Handle" or "Pathname" must + * be valid (non-null) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvaluateObjectTyped ( + ACPI_HANDLE Handle, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ExternalParams, + ACPI_BUFFER *ReturnBuffer, + ACPI_OBJECT_TYPE ReturnType) +{ + ACPI_STATUS Status; + BOOLEAN MustFree = FALSE; + + + ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped); + + + /* Return buffer must be valid */ + + if (!ReturnBuffer) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER) + { + MustFree = TRUE; + } + + /* Evaluate the object */ + + Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Type ANY means "don't care" */ + + if (ReturnType == ACPI_TYPE_ANY) + { + return_ACPI_STATUS (AE_OK); + } + + if (ReturnBuffer->Length == 0) + { + /* Error because caller specifically asked for a return value */ + + ACPI_ERROR ((AE_INFO, "No return value")); + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Examine the object type returned from EvaluateObject */ + + if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType) + { + return_ACPI_STATUS (AE_OK); + } + + /* Return object type does not match requested type */ + + ACPI_ERROR ((AE_INFO, + "Incorrect return type [%s] requested [%s]", + AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type), + AcpiUtGetTypeName (ReturnType))); + + if (MustFree) + { + /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ + + AcpiOsFree (ReturnBuffer->Pointer); + ReturnBuffer->Pointer = NULL; + } + + ReturnBuffer->Length = 0; + return_ACPI_STATUS (AE_TYPE); +} + +ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped) + + +/******************************************************************************* + * + * FUNCTION: AcpiEvaluateObject + * + * PARAMETERS: Handle - Object handle (optional) + * Pathname - Object pathname (optional) + * ExternalParams - List of parameters to pass to method, + * terminated by NULL. May be NULL + * if no parameters are being passed. + * ReturnBuffer - Where to put method's return value (if + * any). If NULL, no value is returned. + * + * RETURN: Status + * + * DESCRIPTION: Find and evaluate the given object, passing the given + * parameters if necessary. One of "Handle" or "Pathname" must + * be valid (non-null) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvaluateObject ( + ACPI_HANDLE Handle, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ExternalParams, + ACPI_BUFFER *ReturnBuffer) +{ + ACPI_STATUS Status; + ACPI_EVALUATE_INFO *Info; + ACPI_SIZE BufferSpaceNeeded; + UINT32 i; + + + ACPI_FUNCTION_TRACE (AcpiEvaluateObject); + + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Pathname = Pathname; + + /* Convert and validate the device handle */ + + Info->PrefixNode = AcpiNsValidateHandle (Handle); + if (!Info->PrefixNode) + { + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* + * If there are parameters to be passed to a control method, the external + * objects must all be converted to internal objects + */ + if (ExternalParams && ExternalParams->Count) + { + /* + * Allocate a new parameter block for the internal objects + * Add 1 to count to allow for null terminated internal list + */ + Info->Parameters = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) ExternalParams->Count + 1) * sizeof (void *)); + if (!Info->Parameters) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Convert each external object in the list to an internal object */ + + for (i = 0; i < ExternalParams->Count; i++) + { + Status = AcpiUtCopyEobjectToIobject ( + &ExternalParams->Pointer[i], &Info->Parameters[i]); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + Info->Parameters[ExternalParams->Count] = NULL; + } + + /* + * Three major cases: + * 1) Fully qualified pathname + * 2) No handle, not fully qualified pathname (error) + * 3) Valid handle + */ + if ((Pathname) && + (AcpiNsValidRootPrefix (Pathname[0]))) + { + /* The path is fully qualified, just evaluate by name */ + + Info->PrefixNode = NULL; + Status = AcpiNsEvaluate (Info); + } + else if (!Handle) + { + /* + * A handle is optional iff a fully qualified pathname is specified. + * Since we've already handled fully qualified names above, this is + * an error + */ + if (!Pathname) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Both Handle and Pathname are NULL")); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Null Handle with relative pathname [%s]", Pathname)); + } + + Status = AE_BAD_PARAMETER; + } + else + { + /* We have a namespace a node and a possible relative path */ + + Status = AcpiNsEvaluate (Info); + } + + /* + * If we are expecting a return value, and all went well above, + * copy the return value to an external object. + */ + if (ReturnBuffer) + { + if (!Info->ReturnObject) + { + ReturnBuffer->Length = 0; + } + else + { + if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) == + ACPI_DESC_TYPE_NAMED) + { + /* + * If we received a NS Node as a return object, this means that + * the object we are evaluating has nothing interesting to + * return (such as a mutex, etc.) We return an error because + * these types are essentially unsupported by this interface. + * We don't check up front because this makes it easier to add + * support for various types at a later date if necessary. + */ + Status = AE_TYPE; + Info->ReturnObject = NULL; /* No need to delete a NS Node */ + ReturnBuffer->Length = 0; + } + + if (ACPI_SUCCESS (Status)) + { + /* Dereference Index and RefOf references */ + + AcpiNsResolveReferences (Info); + + /* Get the size of the returned object */ + + Status = AcpiUtGetObjectSize (Info->ReturnObject, + &BufferSpaceNeeded); + if (ACPI_SUCCESS (Status)) + { + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (ReturnBuffer, + BufferSpaceNeeded); + if (ACPI_FAILURE (Status)) + { + /* + * Caller's buffer is too small or a new one can't + * be allocated + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Needed buffer size %X, %s\n", + (UINT32) BufferSpaceNeeded, + AcpiFormatException (Status))); + } + else + { + /* We have enough space for the object, build it */ + + Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject, + ReturnBuffer); + } + } + } + } + } + + if (Info->ReturnObject) + { + /* + * Delete the internal return object. NOTE: Interpreter must be + * locked to avoid race condition. + */ + AcpiExEnterInterpreter (); + + /* Remove one reference on the return object (should delete it) */ + + AcpiUtRemoveReference (Info->ReturnObject); + AcpiExExitInterpreter (); + } + + +Cleanup: + + /* Free the input parameter list (if we created one) */ + + if (Info->Parameters) + { + /* Free the allocated parameter block */ + + AcpiUtDeleteInternalObjectList (Info->Parameters); + } + + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEvaluateObject) + + +/******************************************************************************* + * + * FUNCTION: AcpiNsResolveReferences + * + * PARAMETERS: Info - Evaluation info block + * + * RETURN: Info->ReturnObject is replaced with the dereferenced object + * + * DESCRIPTION: Dereference certain reference objects. Called before an + * internal return object is converted to an external ACPI_OBJECT. + * + * Performs an automatic dereference of Index and RefOf reference objects. + * These reference objects are not supported by the ACPI_OBJECT, so this is a + * last resort effort to return something useful. Also, provides compatibility + * with other ACPI implementations. + * + * NOTE: does not handle references within returned package objects or nested + * references, but this support could be added later if found to be necessary. + * + ******************************************************************************/ + +static void +AcpiNsResolveReferences ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + + + /* We are interested in reference objects only */ + + if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return; + } + + /* + * Two types of references are supported - those created by Index and + * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted + * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle + * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to + * an ACPI_OBJECT. + */ + switch (Info->ReturnObject->Reference.Class) + { + case ACPI_REFCLASS_INDEX: + + ObjDesc = *(Info->ReturnObject->Reference.Where); + break; + + case ACPI_REFCLASS_REFOF: + + Node = Info->ReturnObject->Reference.Object; + if (Node) + { + ObjDesc = Node->Object; + } + break; + + default: + return; + } + + /* Replace the existing reference object */ + + if (ObjDesc) + { + AcpiUtAddReference (ObjDesc); + AcpiUtRemoveReference (Info->ReturnObject); + Info->ReturnObject = ObjDesc; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartObject - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * PreOrderVisit - Called during tree pre-order visit + * when an object of "Type" is found + * PostOrderVisit - Called during tree post-order visit + * when an object of "Type" is found + * Context - Passed to user function(s) above + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The callback function is called whenever an object that matches + * the type parameter is found. If the callback function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the callback function(s) can be + * tailored to each task, whether it is a print function, + * a compare function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiWalkNamespace); + + + /* Parameter validation */ + + if ((Type > ACPI_TYPE_LOCAL_MAX) || + (!MaxDepth) || + (!PreOrderVisit && !PostOrderVisit)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Need to acquire the namespace reader lock to prevent interference + * with any concurrent table unloads (which causes the deletion of + * namespace objects). We cannot allow the deletion of a namespace node + * while the user function is using it. The exception to this are the + * nodes created and deleted during control method execution -- these + * nodes are marked as temporary nodes and are ignored by the namespace + * walk. Thus, control methods can be executed while holding the + * namespace deletion lock (and the user function can execute control + * methods.) + */ + Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Lock the namespace around the walk. The namespace will be + * unlocked/locked around each call to the user function - since the user + * function must be allowed to make ACPICA calls itself (for example, it + * will typically execute control methods during device enumeration.) + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, + ACPI_NS_WALK_UNLOCK, PreOrderVisit, + PostOrderVisit, Context, ReturnValue); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +UnlockAndExit: + (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWalkNamespace) + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetDeviceCallback + * + * PARAMETERS: Callback from AcpiGetDevice + * + * RETURN: Status + * + * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non- + * present devices, or if they specified a HID, it filters based + * on that. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsGetDeviceCallback ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_GET_DEVICES_INFO *Info = Context; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + UINT32 Flags; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; + UINT32 i; + BOOLEAN Found; + int NoMatch; + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (ObjHandle); + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* Run _STA to determine if device is present */ + + Status = AcpiUtExecute_STA (Node, &Flags); + if (ACPI_FAILURE (Status)) + { + return (AE_CTRL_DEPTH); + } + + if (!(Flags & ACPI_STA_DEVICE_PRESENT) && + !(Flags & ACPI_STA_DEVICE_FUNCTIONING)) + { + /* + * Don't examine the children of the device only when the + * device is neither present nor functional. See ACPI spec, + * description of _STA for more information. + */ + return (AE_CTRL_DEPTH); + } + + /* Filter based on device HID & CID */ + + if (Info->Hid != NULL) + { + Status = AcpiUtExecute_HID (Node, &Hid); + if (Status == AE_NOT_FOUND) + { + return (AE_OK); + } + else if (ACPI_FAILURE (Status)) + { + return (AE_CTRL_DEPTH); + } + + NoMatch = ACPI_STRCMP (Hid->String, Info->Hid); + ACPI_FREE (Hid); + + if (NoMatch) + { + /* + * HID does not match, attempt match within the + * list of Compatible IDs (CIDs) + */ + Status = AcpiUtExecute_CID (Node, &Cid); + if (Status == AE_NOT_FOUND) + { + return (AE_OK); + } + else if (ACPI_FAILURE (Status)) + { + return (AE_CTRL_DEPTH); + } + + /* Walk the CID list */ + + Found = FALSE; + for (i = 0; i < Cid->Count; i++) + { + if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0) + { + /* Found a matching CID */ + + Found = TRUE; + break; + } + } + + ACPI_FREE (Cid); + if (!Found) + { + return (AE_OK); + } + } + } + + /* We have a valid device, invoke the user function */ + + Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, + ReturnValue); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetDevices + * + * PARAMETERS: HID - HID to search for. Can be NULL. + * UserFunction - Called when a matching object is found + * Context - Passed to user function + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The UserFunction is called whenever an object of type + * Device is found. If the user function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * This is a wrapper for WalkNamespace, but the callback performs + * additional filtering. Please see AcpiNsGetDeviceCallback. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetDevices ( + char *HID, + ACPI_WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_GET_DEVICES_INFO Info; + + + ACPI_FUNCTION_TRACE (AcpiGetDevices); + + + /* Parameter validation */ + + if (!UserFunction) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * We're going to call their callback from OUR callback, so we need + * to know what it is, and their context parameter. + */ + Info.Hid = HID; + Info.Context = Context; + Info.UserFunction = UserFunction; + + /* + * Lock the namespace around the walk. + * The namespace will be unlocked/locked around each call + * to the user function - since this function + * must be allowed to make Acpi calls itself. + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, + AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetDevices) + + +/******************************************************************************* + * + * FUNCTION: AcpiAttachData + * + * PARAMETERS: ObjHandle - Namespace node + * Handler - Handler for this attachment + * Data - Pointer to data to be attached + * + * RETURN: Status + * + * DESCRIPTION: Attach arbitrary data and handler to a namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAttachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void *Data) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!ObjHandle || + !Handler || + !Data) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiNsAttachData (Node, Handler, Data); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiAttachData) + + +/******************************************************************************* + * + * FUNCTION: AcpiDetachData + * + * PARAMETERS: ObjHandle - Namespace node handle + * Handler - Handler used in call to AcpiAttachData + * + * RETURN: Status + * + * DESCRIPTION: Remove data that was previously attached to a node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDetachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!ObjHandle || + !Handler) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiNsDetachData (Node, Handler); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDetachData) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetData + * + * PARAMETERS: ObjHandle - Namespace node + * Handler - Handler used in call to AttachData + * Data - Where the data is returned + * + * RETURN: Status + * + * DESCRIPTION: Retrieve data that was previously attached to a namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void **Data) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!ObjHandle || + !Handler || + !Data) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiNsGetAttachedData (Node, Handler, Data); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetData) + + diff --git a/drivers/bus/acpi/acpica/namespace/nsxfname.c b/drivers/bus/acpi/acpica/namespace/nsxfname.c new file mode 100644 index 00000000000..cb7aaa6f941 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsxfname.c @@ -0,0 +1,776 @@ +/****************************************************************************** + * + * Module Name: nsxfname - Public interfaces to the ACPI subsystem + * ACPI Namespace oriented interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSXFNAME_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsxfname") + +/* Local prototypes */ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea); + + +/****************************************************************************** + * + * FUNCTION: AcpiGetHandle + * + * PARAMETERS: Parent - Object to search under (search scope). + * Pathname - Pointer to an asciiz string containing the + * name + * RetHandle - Where the return handle is returned + * + * RETURN: Status + * + * DESCRIPTION: This routine will search for a caller specified name in the + * name space. The caller can restrict the search region by + * specifying a non NULL parent. The parent value is itself a + * namespace handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + ACPI_NAMESPACE_NODE *PrefixNode = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + /* Parameter Validation */ + + if (!RetHandle || !Pathname) + { + return (AE_BAD_PARAMETER); + } + + /* Convert a parent handle to a prefix node */ + + if (Parent) + { + PrefixNode = AcpiNsValidateHandle (Parent); + if (!PrefixNode) + { + return (AE_BAD_PARAMETER); + } + } + + /* + * Valid cases are: + * 1) Fully qualified pathname + * 2) Parent + Relative pathname + * + * Error for + */ + if (AcpiNsValidRootPrefix (Pathname[0])) + { + /* Pathname is fully qualified (starts with '\') */ + + /* Special case for root-only, since we can't search for it */ + + if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH)) + { + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode); + return (AE_OK); + } + } + else if (!PrefixNode) + { + /* Relative path with null prefix is disallowed */ + + return (AE_BAD_PARAMETER); + } + + /* Find the Node and convert to a handle */ + + Status = AcpiNsGetNode (PrefixNode, Pathname, ACPI_NS_NO_UPSEARCH, &Node); + if (ACPI_SUCCESS (Status)) + { + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); + } + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetHandle) + + +/****************************************************************************** + * + * FUNCTION: AcpiGetName + * + * PARAMETERS: Handle - Handle to be converted to a pathname + * NameType - Full pathname or single segment + * Buffer - Buffer for returned path + * + * RETURN: Pointer to a string containing the fully qualified Name. + * + * DESCRIPTION: This routine returns the fully qualified name associated with + * the Handle parameter. This and the AcpiPathnameToHandle are + * complementary functions. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetName ( + ACPI_HANDLE Handle, + UINT32 NameType, + ACPI_BUFFER *Buffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + /* Parameter validation */ + + if (NameType > ACPI_NAME_TYPE_MAX) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtValidateBuffer (Buffer); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (NameType == ACPI_FULL_PATHNAME) + { + /* Get the full pathname (From the namespace root) */ + + Status = AcpiNsHandleToPathname (Handle, Buffer); + return (Status); + } + + /* + * Wants the single segment ACPI name. + * Validate handle and convert to a namespace Node + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Just copy the ACPI name from the Node and zero terminate it */ + + ACPI_STRNCPY (Buffer->Pointer, AcpiUtGetNodeName (Node), + ACPI_NAME_SIZE); + ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; + Status = AE_OK; + + +UnlockAndExit: + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetName) + + +/****************************************************************************** + * + * FUNCTION: AcpiNsCopyDeviceId + * + * PARAMETERS: Dest - Pointer to the destination DEVICE_ID + * Source - Pointer to the source DEVICE_ID + * StringArea - Pointer to where to copy the dest string + * + * RETURN: Pointer to the next string area + * + * DESCRIPTION: Copy a single DEVICE_ID, including the string data. + * + ******************************************************************************/ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea) +{ + /* Create the destination DEVICE_ID */ + + Dest->String = StringArea; + Dest->Length = Source->Length; + + /* Copy actual string and return a pointer to the next string area */ + + ACPI_MEMCPY (StringArea, Source->String, Source->Length); + return (StringArea + Source->Length); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiGetObjectInfo + * + * PARAMETERS: Handle - Object Handle + * ReturnBuffer - Where the info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns information about an object as gleaned from the + * namespace node and possibly by running several standard + * control methods (Such as in the case of a device.) + * + * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, + * _ADR, _SxW, and _SxD methods. + * + * Note: Allocates the return buffer, must be freed by the caller. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Handle, + ACPI_DEVICE_INFO **ReturnBuffer) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_DEVICE_INFO *Info; + ACPI_DEVICE_ID_LIST *CidList = NULL; + ACPI_DEVICE_ID *Hid = NULL; + ACPI_DEVICE_ID *Uid = NULL; + char *NextIdString; + ACPI_OBJECT_TYPE Type; + ACPI_NAME Name; + UINT8 ParamCount= 0; + UINT8 Valid = 0; + UINT32 InfoSize; + UINT32 i; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Handle || !ReturnBuffer) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + /* Get the namespace node data while the namespace is locked */ + + InfoSize = sizeof (ACPI_DEVICE_INFO); + Type = Node->Type; + Name = Node->Name.Integer; + + if (Node->Type == ACPI_TYPE_METHOD) + { + ParamCount = Node->Object->Method.ParamCount; + } + + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) + { + /* + * Get extra info for ACPI Device/Processor objects only: + * Run the Device _HID, _UID, and _CID methods. + * + * Note: none of these methods are required, so they may or may + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. + */ + + /* Execute the Device._HID method */ + + Status = AcpiUtExecute_HID (Node, &Hid); + if (ACPI_SUCCESS (Status)) + { + InfoSize += Hid->Length; + Valid |= ACPI_VALID_HID; + } + + /* Execute the Device._UID method */ + + Status = AcpiUtExecute_UID (Node, &Uid); + if (ACPI_SUCCESS (Status)) + { + InfoSize += Uid->Length; + Valid |= ACPI_VALID_UID; + } + + /* Execute the Device._CID method */ + + Status = AcpiUtExecute_CID (Node, &CidList); + if (ACPI_SUCCESS (Status)) + { + /* Add size of CID strings and CID pointer array */ + + InfoSize += (CidList->ListSize - sizeof (ACPI_DEVICE_ID_LIST)); + Valid |= ACPI_VALID_CID; + } + } + + /* + * Now that we have the variable-length data, we can allocate the + * return buffer + */ + Info = ACPI_ALLOCATE_ZEROED (InfoSize); + if (!Info) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the fixed-length data */ + + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) + { + /* + * Get extra info for ACPI Device/Processor objects only: + * Run the _STA, _ADR and, SxW, and _SxD methods. + * + * Note: none of these methods are required, so they may or may + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. + */ + + /* Execute the Device._STA method */ + + Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_STA; + } + + /* Execute the Device._ADR method */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, + &Info->Address); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_ADR; + } + + /* Execute the Device._SxW methods */ + + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, + Info->LowestDstates); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_SXWS; + } + + /* Execute the Device._SxD methods */ + + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, + Info->HighestDstates); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_SXDS; + } + } + + /* + * Create a pointer to the string area of the return buffer. + * Point to the end of the base ACPI_DEVICE_INFO structure. + */ + NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids); + if (CidList) + { + /* Point past the CID DEVICE_ID array */ + + NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_DEVICE_ID)); + } + + /* + * Copy the HID, UID, and CIDs to the return buffer. The variable-length + * strings are copied to the reserved area at the end of the buffer. + * + * For HID and CID, check if the ID is a PCI Root Bridge. + */ + if (Hid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId, + Hid, NextIdString); + + if (AcpiUtIsPciRootBridge (Hid->String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } + + if (Uid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId, + Uid, NextIdString); + } + + if (CidList) + { + Info->CompatibleIdList.Count = CidList->Count; + Info->CompatibleIdList.ListSize = CidList->ListSize; + + /* Copy each CID */ + + for (i = 0; i < CidList->Count; i++) + { + NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i], + &CidList->Ids[i], NextIdString); + + if (AcpiUtIsPciRootBridge (CidList->Ids[i].String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } + } + + /* Copy the fixed-length data */ + + Info->InfoSize = InfoSize; + Info->Type = Type; + Info->Name = Name; + Info->ParamCount = ParamCount; + Info->Valid = Valid; + + *ReturnBuffer = Info; + Status = AE_OK; + + +Cleanup: + if (Hid) + { + ACPI_FREE (Hid); + } + if (Uid) + { + ACPI_FREE (Uid); + } + if (CidList) + { + ACPI_FREE (CidList); + } + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo) + + +/****************************************************************************** + * + * FUNCTION: AcpiInstallMethod + * + * PARAMETERS: Buffer - An ACPI table containing one control method + * + * RETURN: Status + * + * DESCRIPTION: Install a control method into the namespace. If the method + * name already exists in the namespace, it is overwritten. The + * input buffer must contain a valid DSDT or SSDT containing a + * single control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallMethod ( + UINT8 *Buffer) +{ + ACPI_TABLE_HEADER *Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Buffer); + UINT8 *AmlBuffer; + UINT8 *AmlStart; + char *Path; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *MethodObj; + ACPI_PARSE_STATE ParserState; + UINT32 AmlLength; + UINT16 Opcode; + UINT8 MethodFlags; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Buffer) + { + return (AE_BAD_PARAMETER); + } + + /* Table must be a DSDT or SSDT */ + + if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) && + !ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) + { + return (AE_BAD_HEADER); + } + + /* First AML opcode in the table must be a control method */ + + ParserState.Aml = Buffer + sizeof (ACPI_TABLE_HEADER); + Opcode = AcpiPsPeekOpcode (&ParserState); + if (Opcode != AML_METHOD_OP) + { + return (AE_BAD_PARAMETER); + } + + /* Extract method information from the raw AML */ + + ParserState.Aml += AcpiPsGetOpcodeSize (Opcode); + ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState); + Path = AcpiPsGetNextNamestring (&ParserState); + MethodFlags = *ParserState.Aml++; + AmlStart = ParserState.Aml; + AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); + + /* + * Allocate resources up-front. We don't want to have to delete a new + * node from the namespace if we cannot allocate memory. + */ + AmlBuffer = ACPI_ALLOCATE (AmlLength); + if (!AmlBuffer) + { + return (AE_NO_MEMORY); + } + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + ACPI_FREE (AmlBuffer); + return (AE_NO_MEMORY); + } + + /* Lock namespace for AcpiNsLookup, we may be creating a new node */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* The lookup either returns an existing node or creates a new one */ + + Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1, + ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) /* NsLookup */ + { + if (Status != AE_ALREADY_EXISTS) + { + goto ErrorExit; + } + + /* Node existed previously, make sure it is a method node */ + + if (Node->Type != ACPI_TYPE_METHOD) + { + Status = AE_TYPE; + goto ErrorExit; + } + } + + /* Copy the method AML to the local buffer */ + + ACPI_MEMCPY (AmlBuffer, AmlStart, AmlLength); + + /* Initialize the method object with the new method's information */ + + MethodObj->Method.AmlStart = AmlBuffer; + MethodObj->Method.AmlLength = AmlLength; + + MethodObj->Method.ParamCount = (UINT8) + (MethodFlags & AML_METHOD_ARG_COUNT); + + MethodObj->Method.MethodFlags = (UINT8) + (MethodFlags & ~AML_METHOD_ARG_COUNT); + + if (MethodFlags & AML_METHOD_SERIALIZED) + { + MethodObj->Method.SyncLevel = (UINT8) + ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); + } + + /* + * Now that it is complete, we can attach the new method object to + * the method Node (detaches/deletes any existing object) + */ + Status = AcpiNsAttachObject (Node, MethodObj, + ACPI_TYPE_METHOD); + + /* + * Flag indicates AML buffer is dynamic, must be deleted later. + * Must be set only after attach above. + */ + Node->Flags |= ANOBJ_ALLOCATED_BUFFER; + + /* Remove local reference to the method object */ + + AcpiUtRemoveReference (MethodObj); + return (Status); + + +ErrorExit: + + ACPI_FREE (AmlBuffer); + ACPI_FREE (MethodObj); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallMethod) diff --git a/drivers/bus/acpi/acpica/namespace/nsxfobj.c b/drivers/bus/acpi/acpica/namespace/nsxfobj.c new file mode 100644 index 00000000000..9c42a33f8b2 --- /dev/null +++ b/drivers/bus/acpi/acpica/namespace/nsxfobj.c @@ -0,0 +1,357 @@ +/******************************************************************************* + * + * Module Name: nsxfobj - Public interfaces to the ACPI subsystem + * ACPI Object oriented interfaces + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFOBJ_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsxfobj") + +/******************************************************************************* + * + * FUNCTION: AcpiGetType + * + * PARAMETERS: Handle - Handle of object whose type is desired + * RetType - Where the type will be placed + * + * RETURN: Status + * + * DESCRIPTION: This routine returns the type associatd with a particular handle + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetType ( + ACPI_HANDLE Handle, + ACPI_OBJECT_TYPE *RetType) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter Validation */ + + if (!RetType) + { + return (AE_BAD_PARAMETER); + } + + /* + * Special case for the predefined Root Node + * (return type ANY) + */ + if (Handle == ACPI_ROOT_OBJECT) + { + *RetType = ACPI_TYPE_ANY; + return (AE_OK); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + *RetType = Node->Type; + + + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetType) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetParent + * + * PARAMETERS: Handle - Handle of object whose parent is desired + * RetHandle - Where the parent handle will be placed + * + * RETURN: Status + * + * DESCRIPTION: Returns a handle to the parent of the object represented by + * Handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Handle, + ACPI_HANDLE *RetHandle) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_STATUS Status; + + + if (!RetHandle) + { + return (AE_BAD_PARAMETER); + } + + /* Special case for the predefined Root Node (no parent) */ + + if (Handle == ACPI_ROOT_OBJECT) + { + return (AE_NULL_ENTRY); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Get the parent entry */ + + ParentNode = AcpiNsGetParentNode (Node); + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, ParentNode); + + /* Return exception if parent is null */ + + if (!ParentNode) + { + Status = AE_NULL_ENTRY; + } + + +UnlockAndExit: + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetParent) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetNextObject + * + * PARAMETERS: Type - Type of object to be searched for + * Parent - Parent object whose children we are getting + * LastChild - Previous child that was found. + * The NEXT child will be returned + * RetHandle - Where handle to the next object is placed + * + * RETURN: Status + * + * DESCRIPTION: Return the next peer object within the namespace. If Handle is + * valid, Scope is ignored. Otherwise, the first object within + * Scope is returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode = NULL; + ACPI_NAMESPACE_NODE *ChildNode = NULL; + + + /* Parameter validation */ + + if (Type > ACPI_TYPE_EXTERNAL_MAX) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* If null handle, use the parent */ + + if (!Child) + { + /* Start search at the beginning of the specified scope */ + + ParentNode = AcpiNsValidateHandle (Parent); + if (!ParentNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + else + { + /* Non-null handle, ignore the parent */ + /* Convert and validate the handle */ + + ChildNode = AcpiNsValidateHandle (Child); + if (!ChildNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* Internal function does the real work */ + + Node = AcpiNsGetNextNodeTyped (Type, ParentNode, ChildNode); + if (!Node) + { + Status = AE_NOT_FOUND; + goto UnlockAndExit; + } + + if (RetHandle) + { + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); + } + + +UnlockAndExit: + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetNextObject) + diff --git a/drivers/bus/acpi/acpica/osl/osl.c b/drivers/bus/acpi/acpica/osl/osl.c new file mode 100644 index 00000000000..a8c240a77d2 --- /dev/null +++ b/drivers/bus/acpi/acpica/osl/osl.c @@ -0,0 +1,751 @@ +/******************************************************************************* +* * +* ACPI Component Architecture Operating System Layer (OSL) for ReactOS * +* * +*******************************************************************************/ + +#include + +#define NDEBUG +#include + +#define NUM_SEMAPHORES 128 + +static PKINTERRUPT AcpiInterrupt; +static BOOLEAN AcpiInterruptHandlerRegistered = FALSE; +static ACPI_OSD_HANDLER AcpiIrqHandler = NULL; +static PVOID AcpiIrqContext = NULL; +static ULONG AcpiIrqNumber = 0; +static KDPC AcpiDpc; +static PVOID IVTVirtualAddress = NULL; + + +typedef struct semaphore_entry +{ + UINT16 MaxUnits; + UINT16 CurrentUnits; + void *OsHandle; +} SEMAPHORE_ENTRY; + +static SEMAPHORE_ENTRY AcpiGbl_Semaphores[NUM_SEMAPHORES]; + +VOID NTAPI +OslDpcStub( + IN PKDPC Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2) +{ + ACPI_OSD_EXEC_CALLBACK Routine = (ACPI_OSD_EXEC_CALLBACK)SystemArgument1; + + DPRINT("OslDpcStub()\n"); + DPRINT("Calling [%p]([%p])\n", Routine, SystemArgument2); + (*Routine)(SystemArgument2); +} + +BOOLEAN NTAPI +OslIsrStub( + PKINTERRUPT Interrupt, + PVOID ServiceContext) +{ + INT32 Status; + + Status = (*AcpiIrqHandler)(AcpiIrqContext); + + if (ACPI_SUCCESS(Status)) + return TRUE; + else + return FALSE; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine); + +ACPI_STATUS +AcpiOsInitialize (void) +{ + DPRINT("AcpiOsInitialize called\n"); + +#ifndef NDEBUG + /* Verboseness level of the acpica core */ + AcpiDbgLevel = 0x00FFFFFF; + AcpiDbgLayer = 0xFFFFFFFF; +#endif + + UINT32 i; + + for (i = 0; i < NUM_SEMAPHORES; i++) + { + AcpiGbl_Semaphores[i].OsHandle = NULL; + } + + KeInitializeDpc(&AcpiDpc, OslDpcStub, NULL); + + return AE_OK; +} + +ACPI_STATUS +AcpiOsTerminate(void) +{ + DPRINT1("AcpiOsTerminate() called\n"); + + if (AcpiInterruptHandlerRegistered) + AcpiOsRemoveInterruptHandler(AcpiIrqNumber, AcpiIrqHandler); + + return AE_OK; +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiOsPrintf ( + const char *Fmt, + ...) +{ + va_list Args; + va_start (Args, Fmt); + + AcpiOsVprintf (Fmt, Args); + + va_end (Args); + return; +} + +void +AcpiOsVprintf ( + const char *Fmt, + va_list Args) +{ + vDbgPrintEx (-1, DPFLTR_ERROR_LEVEL, Fmt, Args); + return; +} + +void * +AcpiOsAllocate (ACPI_SIZE size) +{ + DPRINT("AcpiOsAllocate size %d\n",size); + return ExAllocatePool(NonPagedPool, size); +} + +void * +AcpiOsCallocate(ACPI_SIZE size) +{ + PVOID ptr = ExAllocatePool(NonPagedPool, size); + if (ptr) + memset(ptr, 0, size); + return ptr; +} + +void +AcpiOsFree(void *ptr) +{ + if (!ptr) + DPRINT1("Attempt to free null pointer!!!\n"); + ExFreePool(ptr); +} + +#ifndef ACPI_USE_LOCAL_CACHE + +void* +AcpiOsAcquireObjectHelper ( + POOL_TYPE PoolType, + SIZE_T NumberOfBytes, + ULONG Tag) +{ + void* Alloc = ExAllocatePool(PoolType, NumberOfBytes); + + /* acpica expects memory allocated from cache to be zeroed */ + RtlZeroMemory(Alloc,NumberOfBytes); + return Alloc; +} + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache) +{ + PNPAGED_LOOKASIDE_LIST Lookaside = + ExAllocatePool(NonPagedPool,sizeof(NPAGED_LOOKASIDE_LIST)); + + ExInitializeNPagedLookasideList(Lookaside, + (PALLOCATE_FUNCTION)AcpiOsAcquireObjectHelper,// custom memory allocator + NULL, + 0, + ObjectSize, + 'IPCA', + 0); + *ReturnCache = (ACPI_CACHE_T *)Lookaside; + + DPRINT("AcpiOsCreateCache %p\n", Lookaside); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsDeleteCache %p\n", Cache); + ExDeleteNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST) Cache); + ExFreePool(Cache); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsPurgeCache\n"); + /* No such functionality for LookAside lists */ + return (AE_OK); +} + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache) +{ + PNPAGED_LOOKASIDE_LIST List = (PNPAGED_LOOKASIDE_LIST)Cache; + DPRINT("AcpiOsAcquireObject from %p\n", Cache); + void* ptr = + ExAllocateFromNPagedLookasideList(List); + ASSERT(ptr); + + RtlZeroMemory(ptr,List->L.Size); + return ptr; +} + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object) +{ + DPRINT("AcpiOsReleaseObject %p from %p\n",Object, Cache); + ExFreeToNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST)Cache, + Object); + return (AE_OK); +} + +#endif + +void * +AcpiOsMapMemory ( + ACPI_PHYSICAL_ADDRESS phys, + ACPI_SIZE length) +{ + PHYSICAL_ADDRESS Address; + + DPRINT("AcpiOsMapMemory(phys 0x%X size 0x%X)\n", (ULONG)phys, length); + if (phys == 0x0) + { + IVTVirtualAddress = ExAllocatePool(NonPagedPool, length); + return IVTVirtualAddress; + } + + Address.QuadPart = (ULONG)phys; + return MmMapIoSpace(Address, length, MmNonCached); +} + +void +AcpiOsUnmapMemory ( + void *virt, + ACPI_SIZE length) +{ + DPRINT("AcpiOsUnmapMemory()\n"); + + if (virt == 0x0) + { + ExFreePool(IVTVirtualAddress); + return; + } + MmUnmapIoSpace(virt, length); +} + +UINT32 +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine, + void *Context) +{ + ULONG Vector; + KIRQL DIrql; + KAFFINITY Affinity; + NTSTATUS Status; + + DPRINT("AcpiOsInstallInterruptHandler()\n"); + Vector = HalGetInterruptVector( + Internal, + 0, + InterruptNumber, + 0, + &DIrql, + &Affinity); + + AcpiIrqNumber = InterruptNumber; + AcpiIrqHandler = ServiceRoutine; + AcpiIrqContext = Context; + AcpiInterruptHandlerRegistered = TRUE; + + Status = IoConnectInterrupt( + &AcpiInterrupt, + OslIsrStub, + NULL, + NULL, + Vector, + DIrql, + DIrql, + LevelSensitive, /* FIXME: LevelSensitive or Latched? */ + TRUE, + Affinity, + FALSE); + + if (!NT_SUCCESS(Status)) + { + DPRINT("Could not connect to interrupt %d\n", Vector); + return AE_ERROR; + } + return AE_OK; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine) +{ + DPRINT("AcpiOsRemoveInterruptHandler()\n"); + if (AcpiInterruptHandlerRegistered) + { + IoDisconnectInterrupt(AcpiInterrupt); + AcpiInterrupt = NULL; + AcpiInterruptHandlerRegistered = FALSE; + } + + return AE_OK; +} + +void +AcpiOsStall (UINT32 microseconds) +{ + DPRINT1("AcpiOsStall %d\n",microseconds); + KeStallExecutionProcessor(microseconds); + return; +} + +void +AcpiOsSleep (ACPI_INTEGER milliseconds) +{ + DPRINT1("AcpiOsSleep %d\n", milliseconds); + KeStallExecutionProcessor(milliseconds*1000); + return; +} + +ACPI_STATUS +AcpiOsReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadPort %p, width %d\n",Address,Width); + + switch (Width) + { + case 8: + *Value = READ_PORT_UCHAR((PUCHAR)Address); + break; + + case 16: + *Value = READ_PORT_USHORT((PUSHORT)Address); + break; + + case 32: + *Value = READ_PORT_ULONG((PULONG)Address); + break; + default: + DPRINT1("AcpiOsReadPort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWritePort %p, width %d\n",Address,Width); + switch (Width) + { + case 8: + WRITE_PORT_UCHAR((PUCHAR)Address, Value); + break; + + case 16: + WRITE_PORT_USHORT((PUSHORT)Address, Value); + break; + + case 32: + WRITE_PORT_ULONG((PULONG)Address, Value); + break; + + default: + DPRINT1("AcpiOsWritePort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadMemory %p\n", Address); + switch (Width) + { + case 8: + *Value = (*(PUCHAR)(ULONG)Address); + break; + case 16: + *Value = (*(PUSHORT)(ULONG)Address); + break; + case 32: + *Value = (*(PULONG)(ULONG)Address); + break; + + default: + DPRINT1("AcpiOsReadMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + + +ACPI_STATUS +AcpiOsWriteMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWriteMemory %p\n", Address); + switch (Width) + { + case 8: + *(PUCHAR)(ULONG)Address = Value; + break; + case 16: + *(PUSHORT)(ULONG)Address = Value; + break; + case 32: + *(PULONG)(ULONG)Address = Value; + break; + + default: + DPRINT1("AcpiOsWriteMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadPciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + void *Value, + UINT32 Width) +{ + NTSTATUS Status; + PCI_SLOT_NUMBER slot; + + if (Register == 0) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Bus; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsReadPciConfiguration, slot=0x%X, func=0x%X\n", slot.u.AsULONG, Register); + Status = HalGetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + Value, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsWritePciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + ACPI_INTEGER Value, + UINT32 Width) +{ + NTSTATUS Status; + ULONG buf = Value; + PCI_SLOT_NUMBER slot; + + if (Register == 0) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Bus; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsWritePciConfiguration, slot=0x%x\n", slot.u.AsULONG); + Status = HalSetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + &buf, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_SEMAPHORE *OutHandle) +{ + PFAST_MUTEX Mutex; + + Mutex = ExAllocatePool(NonPagedPool, sizeof(FAST_MUTEX)); + if (!Mutex) + return AE_NO_MEMORY; + + DPRINT("AcpiOsCreateSemaphore() at 0x%X\n", Mutex); + + ExInitializeFastMutex(Mutex); + + *OutHandle = Mutex; + return AE_OK; +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_SEMAPHORE Handle) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsDeleteSemaphore(handle 0x%X)\n", Handle); + + if (!Mutex) + return AE_BAD_PARAMETER; + + ExFreePool(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsWaitSemaphore( + ACPI_SEMAPHORE Handle, + UINT32 units, + UINT16 timeout) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + if (!Mutex || (units < 1)) + { + DPRINT("AcpiOsWaitSemaphore(handle 0x%X, units %d) Bad parameters\n", + Mutex, units); + return AE_BAD_PARAMETER; + } + + DPRINT("Waiting for semaphore %p\n", Handle); + ASSERT(Mutex); + + ExAcquireFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsSignalSemaphore %p\n",Handle); + ASSERT(Mutex); + + ExReleaseFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle) +{ + DPRINT("AcpiOsCreateLock\n"); + return (AcpiOsCreateSemaphore (1, 1, OutHandle)); +} + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle) +{ + DPRINT("AcpiOsDeleteLock %p\n", Handle); + AcpiOsDeleteSemaphore (Handle); +} + + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_HANDLE Handle) +{ + DPRINT("AcpiOsAcquireLock, %p\n", Handle); + AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); + return (0); +} + + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags) +{ + DPRINT("AcpiOsReleaseLock %p\n",Handle); + AcpiOsSignalSemaphore (Handle, 1); +} + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info) +{ + + switch (Function) + { + case ACPI_SIGNAL_FATAL: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + case ACPI_SIGNAL_BREAKPOINT: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + } + + return (AE_OK); +} + + +ACPI_THREAD_ID +AcpiOsGetThreadId (void) +{ + return (ULONG)PsGetCurrentThreadId(); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + DPRINT1("AcpiOsExecute\n"); + + KeInsertQueueDpc(&AcpiDpc, (PVOID)Function, (PVOID)Context); + +#ifdef _MULTI_THREADED + //_beginthread (Function, (unsigned) 0, Context); +#endif + + return 0; +} + +UINT64 +AcpiOsGetTimer (void) +{ + DPRINT("AcpiOsGetTimer\n"); + LARGE_INTEGER Timer; + KeQueryTickCount(&Timer); + + return Timer.QuadPart; +} + +void +AcpiOsDerivePciId( + ACPI_HANDLE rhandle, + ACPI_HANDLE chandle, + ACPI_PCI_ID **PciId) +{ + DPRINT("AcpiOsDerivePciId\n"); + return; +} + +ACPI_STATUS +AcpiOsPredefinedOverride ( + const ACPI_PREDEFINED_NAMES *InitVal, + ACPI_STRING *NewVal) +{ + if (!InitVal || !NewVal) + return AE_BAD_PARAMETER; + + *NewVal = ACPI_OS_NAME; + DPRINT("AcpiOsPredefinedOverride\n"); + return AE_OK; +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void); + +ACPI_STATUS +AcpiOsTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable) +{ + DPRINT("AcpiOsTableOverride\n"); + *NewTable = NULL; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateInterface ( + char *Interface) +{ + DPRINT("AcpiOsValidateInterface\n"); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateAddress ( + UINT8 SpaceId, + ACPI_PHYSICAL_ADDRESS Address, + ACPI_SIZE Length) +{ + DPRINT("AcpiOsValidateAddress\n"); + return (AE_OK); +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void) +{ + DPRINT("AcpiOsGetRootPointer\n"); + ACPI_PHYSICAL_ADDRESS pa = 0; + + AcpiFindRootPointer(&pa); + return pa; +} diff --git a/drivers/bus/acpi/acpica/parser/psargs.c b/drivers/bus/acpi/acpica/parser/psargs.c new file mode 100644 index 00000000000..60d4a835b1b --- /dev/null +++ b/drivers/bus/acpi/acpica/parser/psargs.c @@ -0,0 +1,893 @@ +/****************************************************************************** + * + * Module Name: psargs - Parse AML opcode arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __PSARGS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdispat.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psargs") + +/* Local prototypes */ + +static UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState); + +static ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState); + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageLength + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Decoded package length. On completion, the AML pointer points + * past the length byte or bytes. + * + * DESCRIPTION: Decode and return a package length field. + * Note: Largest package length is 28 bits, from ACPI specification + * + ******************************************************************************/ + +static UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Aml = ParserState->Aml; + UINT32 PackageLength = 0; + UINT32 ByteCount; + UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */ + + + ACPI_FUNCTION_TRACE (PsGetNextPackageLength); + + + /* + * Byte 0 bits [6:7] contain the number of additional bytes + * used to encode the package length, either 0,1,2, or 3 + */ + ByteCount = (Aml[0] >> 6); + ParserState->Aml += ((ACPI_SIZE) ByteCount + 1); + + /* Get bytes 3, 2, 1 as needed */ + + while (ByteCount) + { + /* + * Final bit positions for the package length bytes: + * Byte3->[20:27] + * Byte2->[12:19] + * Byte1->[04:11] + * Byte0->[00:03] + */ + PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4)); + + ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */ + ByteCount--; + } + + /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ + + PackageLength |= (Aml[0] & ByteZeroMask); + return_UINT32 (PackageLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageEnd + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to end-of-package +1 + * + * DESCRIPTION: Get next package length and return a pointer past the end of + * the package. Consumes the package length field + * + ******************************************************************************/ + +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + UINT32 PackageLength; + + + ACPI_FUNCTION_TRACE (PsGetNextPackageEnd); + + + /* Function below updates ParserState->Aml */ + + PackageLength = AcpiPsGetNextPackageLength (ParserState); + + return_PTR (Start + PackageLength); /* end of package */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamestring + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to the start of the name string (pointer points into + * the AML. + * + * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name + * prefix characters. Set parser state to point past the string. + * (Name is consumed from the AML.) + * + ******************************************************************************/ + +char * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + UINT8 *End = ParserState->Aml; + + + ACPI_FUNCTION_TRACE (PsGetNextNamestring); + + + /* Point past any namestring prefix characters (backslash or carat) */ + + while (AcpiPsIsPrefixChar (*End)) + { + End++; + } + + /* Decode the path prefix character */ + + switch (*End) + { + case 0: + + /* NullName */ + + if (End == Start) + { + Start = NULL; + } + End++; + break; + + case AML_DUAL_NAME_PREFIX: + + /* Two name segments */ + + End += 1 + (2 * ACPI_NAME_SIZE); + break; + + case AML_MULTI_NAME_PREFIX_OP: + + /* Multiple name segments, 4 chars each, count in next byte */ + + End += 2 + (*(End + 1) * ACPI_NAME_SIZE); + break; + + default: + + /* Single name segment */ + + End += ACPI_NAME_SIZE; + break; + } + + ParserState->Aml = End; + return_PTR ((char *) Start); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamepath + * + * PARAMETERS: ParserState - Current parser state object + * Arg - Where the namepath will be stored + * ArgCount - If the namepath points to a control method + * the method's argument is returned here. + * PossibleMethodCall - Whether the namepath can possibly be the + * start of a method call + * + * RETURN: Status + * + * DESCRIPTION: Get next name (if method call, return # of required args). + * Names are looked up in the internal namespace to determine + * if the name represents a control method. If a method + * is found, the number of arguments to the method is returned. + * This information is critical for parsing to continue correctly. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsGetNextNamepath ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + BOOLEAN PossibleMethodCall) +{ + ACPI_STATUS Status; + char *Path; + ACPI_PARSE_OBJECT *NameOp; + ACPI_OPERAND_OBJECT *MethodDesc; + ACPI_NAMESPACE_NODE *Node; + UINT8 *Start = ParserState->Aml; + + + ACPI_FUNCTION_TRACE (PsGetNextNamepath); + + + Path = AcpiPsGetNextNamestring (ParserState); + AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); + + /* Null path case is allowed, just exit */ + + if (!Path) + { + Arg->Common.Value.Name = Path; + return_ACPI_STATUS (AE_OK); + } + + /* + * Lookup the name in the internal namespace, starting with the current + * scope. We don't want to add anything new to the namespace here, + * however, so we use MODE_EXECUTE. + * Allow searching of the parent tree, but don't open a new scope - + * we just want to lookup the object (must be mode EXECUTE to perform + * the upsearch) + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + + /* + * If this name is a control method invocation, we must + * setup the method call + */ + if (ACPI_SUCCESS (Status) && + PossibleMethodCall && + (Node->Type == ACPI_TYPE_METHOD)) + { + if (WalkState->Opcode == AML_UNLOAD_OP) + { + /* + * AcpiPsGetNextNamestring has increased the AML pointer, + * so we need to restore the saved AML pointer for method call. + */ + WalkState->ParserState.Aml = Start; + WalkState->ArgCount = 1; + AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); + return_ACPI_STATUS (AE_OK); + } + + /* This name is actually a control method invocation */ + + MethodDesc = AcpiNsGetAttachedObject (Node); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path)); + + NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + if (!NameOp) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Change Arg into a METHOD CALL and attach name to it */ + + AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); + NameOp->Common.Value.Name = Path; + + /* Point METHODCALL/NAME to the METHOD Node */ + + NameOp->Common.Node = Node; + AcpiPsAppendArg (Arg, NameOp); + + if (!MethodDesc) + { + ACPI_ERROR ((AE_INFO, + "Control Method %p has no attached object", + Node)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Control Method - %p Args %X\n", + Node, MethodDesc->Method.ParamCount)); + + /* Get the number of arguments to expect */ + + WalkState->ArgCount = MethodDesc->Method.ParamCount; + return_ACPI_STATUS (AE_OK); + } + + /* + * Special handling if the name was not found during the lookup - + * some NotFound cases are allowed + */ + if (Status == AE_NOT_FOUND) + { + /* 1) NotFound is ok during load pass 1/2 (allow forward references) */ + + if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) != + ACPI_PARSE_EXECUTE) + { + Status = AE_OK; + } + + /* 2) NotFound during a CondRefOf(x) is ok by definition */ + + else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP) + { + Status = AE_OK; + } + + /* + * 3) NotFound while building a Package is ok at this point, we + * may flag as an error later if slack mode is not enabled. + * (Some ASL code depends on allowing this behavior) + */ + else if ((Arg->Common.Parent) && + ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + Status = AE_OK; + } + } + + /* Final exception check (may have been changed from code above) */ + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + + if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == + ACPI_PARSE_EXECUTE) + { + /* Report a control method execution error */ + + Status = AcpiDsMethodError (Status, WalkState); + } + } + + /* Save the namepath */ + + Arg->Common.Value.Name = Path; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextSimpleArg + * + * PARAMETERS: ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * Arg - Where the argument is returned + * + * RETURN: None + * + * DESCRIPTION: Get the next simple argument (constant, string, or namestring) + * + ******************************************************************************/ + +void +AcpiPsGetNextSimpleArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT *Arg) +{ + UINT32 Length; + UINT16 Opcode; + UINT8 *Aml = ParserState->Aml; + + + ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType); + + + switch (ArgType) + { + case ARGP_BYTEDATA: + + /* Get 1 byte from the AML stream */ + + Opcode = AML_BYTE_OP; + Arg->Common.Value.Integer = (ACPI_INTEGER) *Aml; + Length = 1; + break; + + + case ARGP_WORDDATA: + + /* Get 2 bytes from the AML stream */ + + Opcode = AML_WORD_OP; + ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 2; + break; + + + case ARGP_DWORDDATA: + + /* Get 4 bytes from the AML stream */ + + Opcode = AML_DWORD_OP; + ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 4; + break; + + + case ARGP_QWORDDATA: + + /* Get 8 bytes from the AML stream */ + + Opcode = AML_QWORD_OP; + ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 8; + break; + + + case ARGP_CHARLIST: + + /* Get a pointer to the string, point past the string */ + + Opcode = AML_STRING_OP; + Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml); + + /* Find the null terminator */ + + Length = 0; + while (Aml[Length]) + { + Length++; + } + Length++; + break; + + + case ARGP_NAME: + case ARGP_NAMESTRING: + + AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); + Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState); + return_VOID; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid ArgType %X", ArgType)); + return_VOID; + } + + AcpiPsInitOp (Arg, Opcode); + ParserState->Aml += Length; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextField + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: A newly allocated FIELD op + * + * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) + * + ******************************************************************************/ + +static ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState) +{ + UINT32 AmlOffset = (UINT32) + ACPI_PTR_DIFF (ParserState->Aml, + ParserState->AmlStart); + ACPI_PARSE_OBJECT *Field; + UINT16 Opcode; + UINT32 Name; + + + ACPI_FUNCTION_TRACE (PsGetNextField); + + + /* Determine field type */ + + switch (ACPI_GET8 (ParserState->Aml)) + { + default: + + Opcode = AML_INT_NAMEDFIELD_OP; + break; + + case 0x00: + + Opcode = AML_INT_RESERVEDFIELD_OP; + ParserState->Aml++; + break; + + case 0x01: + + Opcode = AML_INT_ACCESSFIELD_OP; + ParserState->Aml++; + break; + } + + /* Allocate a new field op */ + + Field = AcpiPsAllocOp (Opcode); + if (!Field) + { + return_PTR (NULL); + } + + Field->Common.AmlOffset = AmlOffset; + + /* Decode the field type */ + + switch (Opcode) + { + case AML_INT_NAMEDFIELD_OP: + + /* Get the 4-character name */ + + ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml); + AcpiPsSetName (Field, Name); + ParserState->Aml += ACPI_NAME_SIZE; + + /* Get the length which is encoded as a package length */ + + Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_INT_RESERVEDFIELD_OP: + + /* Get the length which is encoded as a package length */ + + Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_INT_ACCESSFIELD_OP: + + /* + * Get AccessType and AccessAttrib and merge into the field Op + * AccessType is first operand, AccessAttribute is second + */ + Field->Common.Value.Integer = (((UINT32) ACPI_GET8 (ParserState->Aml) << 8)); + ParserState->Aml++; + Field->Common.Value.Integer |= ACPI_GET8 (ParserState->Aml); + ParserState->Aml++; + break; + + default: + + /* Opcode was set in previous switch */ + break; + } + + return_PTR (Field); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextArg + * + * PARAMETERS: WalkState - Current state + * ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * ReturnArg - Where the next arg is returned + * + * RETURN: Status, and an op object containing the next argument. + * + * DESCRIPTION: Get next argument (including complex list arguments that require + * pushing the parser stack) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsGetNextArg ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT **ReturnArg) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE_OBJECT *Prev = NULL; + ACPI_PARSE_OBJECT *Field; + UINT32 Subop; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState); + + + switch (ArgType) + { + case ARGP_BYTEDATA: + case ARGP_WORDDATA: + case ARGP_DWORDDATA: + case ARGP_CHARLIST: + case ARGP_NAME: + case ARGP_NAMESTRING: + + /* Constants, strings, and namestrings are all the same size */ + + Arg = AcpiPsAllocOp (AML_BYTE_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); + break; + + + case ARGP_PKGLENGTH: + + /* Package length, nothing returned */ + + ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); + break; + + + case ARGP_FIELDLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* Non-empty list */ + + while (ParserState->Aml < ParserState->PkgEnd) + { + Field = AcpiPsGetNextField (ParserState); + if (!Field) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + if (Prev) + { + Prev->Common.Next = Field; + } + else + { + Arg = Field; + } + Prev = Field; + } + + /* Skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_BYTELIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* Non-empty list */ + + Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Fill in bytelist data */ + + Arg->Common.Value.Size = (UINT32) + ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); + Arg->Named.Data = ParserState->Aml; + + /* Skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_TARGET: + case ARGP_SUPERNAME: + case ARGP_SIMPLENAME: + + Subop = AcpiPsPeekOpcode (ParserState); + if (Subop == 0 || + AcpiPsIsLeadingChar (Subop) || + AcpiPsIsPrefixChar (Subop)) + { + /* NullName or NameString */ + + Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* To support SuperName arg of Unload */ + + if (WalkState->Opcode == AML_UNLOAD_OP) + { + Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1); + + /* + * If the SuperName arg of Unload is a method call, + * we have restored the AML pointer, just free this Arg + */ + if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP) + { + AcpiPsFreeOp (Arg); + Arg = NULL; + } + } + else + { + Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0); + } + } + else + { + /* Single complex argument, nothing returned */ + + WalkState->ArgCount = 1; + } + break; + + + case ARGP_DATAOBJ: + case ARGP_TERMARG: + + /* Single complex argument, nothing returned */ + + WalkState->ArgCount = 1; + break; + + + case ARGP_DATAOBJLIST: + case ARGP_TERMLIST: + case ARGP_OBJLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* Non-empty list of variable arguments, nothing returned */ + + WalkState->ArgCount = ACPI_VAR_ARGS; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid ArgType: %X", ArgType)); + Status = AE_AML_OPERAND_TYPE; + break; + } + + *ReturnArg = Arg; + return_ACPI_STATUS (Status); +} diff --git a/drivers/bus/acpi/acpica/parser/psloop.c b/drivers/bus/acpi/acpica/parser/psloop.c new file mode 100644 index 00000000000..4171e0dc6de --- /dev/null +++ b/drivers/bus/acpi/acpica/parser/psloop.c @@ -0,0 +1,1341 @@ +/****************************************************************************** + * + * Module Name: psloop - Main AML parse loop + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, (such as + * Perl) do. Parsing is done by hand rather than with a YACC generated parser + * to tightly constrain stack and dynamic memory usage. Parsing is kept + * flexible and the code fairly compact by parsing based on a list of AML + * opcode templates in AmlOpInfo[]. + */ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psloop") + +static UINT32 AcpiGbl_Depth = 0; + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiPsGetAmlOpcode ( + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiPsBuildNamedOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *UnnamedOp, + ACPI_PARSE_OBJECT **Op); + +static ACPI_STATUS +AcpiPsCreateOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT **NewOp); + +static ACPI_STATUS +AcpiPsGetArguments ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *Op); + +static ACPI_STATUS +AcpiPsCompleteOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **Op, + ACPI_STATUS Status); + +static ACPI_STATUS +AcpiPsCompleteFinalOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS Status); + +static void +AcpiPsLinkModuleCode ( + ACPI_PARSE_OBJECT *ParentOp, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId); + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetAmlOpcode + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Extract the next AML opcode from the input stream. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsGetAmlOpcode ( + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState); + + + WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, + WalkState->ParserState.AmlStart); + WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState)); + + /* + * First cut to determine what we have found: + * 1) A valid AML opcode + * 2) A name string + * 3) An unknown/invalid opcode + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + + switch (WalkState->OpInfo->Class) + { + case AML_CLASS_ASCII: + case AML_CLASS_PREFIX: + /* + * Starts with a valid prefix or ASCII char, this is a name + * string. Convert the bare name string to a namepath. + */ + WalkState->Opcode = AML_INT_NAMEPATH_OP; + WalkState->ArgTypes = ARGP_NAMESTRING; + break; + + case AML_CLASS_UNKNOWN: + + /* The opcode is unrecognized. Just skip unknown opcodes */ + + ACPI_ERROR ((AE_INFO, + "Found unknown opcode %X at AML address %p offset %X, ignoring", + WalkState->Opcode, WalkState->ParserState.Aml, WalkState->AmlOffset)); + + ACPI_DUMP_BUFFER (WalkState->ParserState.Aml, 128); + + /* Assume one-byte bad opcode */ + + WalkState->ParserState.Aml++; + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + + default: + + /* Found opcode info, this is a normal opcode */ + + WalkState->ParserState.Aml += AcpiPsGetOpcodeSize (WalkState->Opcode); + WalkState->ArgTypes = WalkState->OpInfo->ParseArgs; + break; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsBuildNamedOp + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Begin of named Op in AML + * UnnamedOp - Early Op (not a named Op) + * Op - Returned Op + * + * RETURN: Status + * + * DESCRIPTION: Parse a named Op + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsBuildNamedOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *UnnamedOp, + ACPI_PARSE_OBJECT **Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState); + + + UnnamedOp->Common.Value.Arg = NULL; + UnnamedOp->Common.ArgListLength = 0; + UnnamedOp->Common.AmlOpcode = WalkState->Opcode; + + /* + * Get and append arguments until we find the node that contains + * the name (the type ARGP_NAME). + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && + (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME)) + { + Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiPsAppendArg (UnnamedOp, Arg); + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } + + /* + * Make sure that we found a NAME and didn't run out of arguments + */ + if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes)) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* We know that this arg is a name, move to next arg */ + + INCREMENT_ARG_LIST (WalkState->ArgTypes); + + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + WalkState->Op = NULL; + + Status = WalkState->DescendingCallback (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog")); + return_ACPI_STATUS (Status); + } + + if (!*Op) + { + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + } + + Status = AcpiPsNextParseState (WalkState, *Op, Status); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_PENDING) + { + return_ACPI_STATUS (AE_CTRL_PARSE_PENDING); + } + return_ACPI_STATUS (Status); + } + + AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg); + AcpiGbl_Depth++; + + if ((*Op)->Common.AmlOpcode == AML_REGION_OP || + (*Op)->Common.AmlOpcode == AML_DATA_REGION_OP) + { + /* + * Defer final parsing of an OperationRegion body, because we don't + * have enough info in the first pass to parse it correctly (i.e., + * there may be method calls within the TermArg elements of the body.) + * + * However, we must continue parsing because the opregion is not a + * standalone package -- we don't know where the end is at this point. + * + * (Length is unknown until parse of the body complete) + */ + (*Op)->Named.Data = AmlOpStart; + (*Op)->Named.Length = 0; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateOp + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Op start in AML + * NewOp - Returned Op + * + * RETURN: Status + * + * DESCRIPTION: Get Op from AML + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCreateOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT **NewOp) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *NamedOp = NULL; + ACPI_PARSE_OBJECT *ParentScope; + UINT8 ArgumentCount; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState); + + + Status = AcpiPsGetAmlOpcode (WalkState); + if (Status == AE_CTRL_PARSE_CONTINUE) + { + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + } + + /* Create Op structure and append to parent's argument list */ + + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + if (WalkState->OpInfo->Flags & AML_NAMED) + { + Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp); + AcpiPsFreeOp (Op); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *NewOp = NamedOp; + return_ACPI_STATUS (AE_OK); + } + + /* Not a named opcode, just allocate Op and append to parent */ + + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration + * BodyLength is unknown until we parse the body + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = 0; + } + + if (WalkState->Opcode == AML_BANK_FIELD_OP) + { + /* + * Backup to beginning of BankField declaration + * BodyLength is unknown until we parse the body + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = 0; + } + + ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState)); + AcpiPsAppendArg (ParentScope, Op); + + if (ParentScope) + { + OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode); + if (OpInfo->Flags & AML_HAS_TARGET) + { + ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type); + if (ParentScope->Common.ArgListLength > ArgumentCount) + { + Op->Common.Flags |= ACPI_PARSEOP_TARGET; + } + } + else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) + { + Op->Common.Flags |= ACPI_PARSEOP_TARGET; + } + } + + if (WalkState->DescendingCallback != NULL) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + WalkState->Op = *NewOp = Op; + + Status = WalkState->DescendingCallback (WalkState, &Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_CTRL_PARSE_PENDING; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArguments + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Op start in AML + * Op - Current Op + * + * RETURN: Status + * + * DESCRIPTION: Get arguments for passed Op. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsGetArguments ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg = NULL; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState); + + + switch (Op->Common.AmlOpcode) + { + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_QWORD_OP: /* AML_QWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ + + /* Fill in constant or string argument directly */ + + AcpiPsGetNextSimpleArg (&(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op); + break; + + case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ + + Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + WalkState->ArgTypes = 0; + break; + + default: + /* + * Op is not a constant or string, append each argument to the Op + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount) + { + WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, + WalkState->ParserState.AmlStart); + + Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Arg) + { + Arg->Common.AmlOffset = WalkState->AmlOffset; + AcpiPsAppendArg (Op, Arg); + } + + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } + + + /* + * Handle executable code at "module-level". This refers to + * executable opcodes that appear outside of any control method. + */ + if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) && + ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0)) + { + /* + * We want to skip If/Else/While constructs during Pass1 because we + * want to actually conditionally execute the code during Pass2. + * + * Except for disassembly, where we always want to walk the + * If/Else/While packages + */ + switch (Op->Common.AmlOpcode) + { + case AML_IF_OP: + case AML_ELSE_OP: + case AML_WHILE_OP: + + /* + * Currently supported module-level opcodes are: + * IF/ELSE/WHILE. These appear to be the most common, + * and easiest to support since they open an AML + * package. + */ + if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) + { + AcpiPsLinkModuleCode (Op->Common.Parent, AmlOpStart, + (UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart), + WalkState->OwnerId); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Pass1: Skipping an If/Else/While body\n")); + + /* Skip body of if/else/while in pass 1 */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + break; + + default: + /* + * Check for an unsupported executable opcode at module + * level. We must be in PASS1, the parent must be a SCOPE, + * The opcode class must be EXECUTE, and the opcode must + * not be an argument to another opcode. + */ + if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) && + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) + { + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if ((OpInfo->Class == AML_CLASS_EXECUTE) && + (!Arg)) + { + ACPI_WARNING ((AE_INFO, + "Detected an unsupported executable opcode " + "at module-level: [0x%.4X] at table offset 0x%.4X", + Op->Common.AmlOpcode, + (UINT32) (ACPI_PTR_DIFF (AmlOpStart, + WalkState->ParserState.AmlStart) + + sizeof (ACPI_TABLE_HEADER)))); + } + } + break; + } + } + + /* Special processing for certain opcodes */ + + switch (Op->Common.AmlOpcode) + { + case AML_METHOD_OP: + /* + * Skip parsing of control method because we don't have enough + * info in the first pass to parse it correctly. + * + * Save the length and address of the body + */ + Op->Named.Data = WalkState->ParserState.Aml; + Op->Named.Length = (UINT32) + (WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml); + + /* Skip body of method */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + break; + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + if ((Op->Common.Parent) && + (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) + { + /* + * Skip parsing of Buffers and Packages because we don't have + * enough info in the first pass to parse them correctly. + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = (UINT32) + (WalkState->ParserState.PkgEnd - AmlOpStart); + + /* Skip body */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + } + break; + + case AML_WHILE_OP: + + if (WalkState->ControlState) + { + WalkState->ControlState->Control.PackageEnd = + WalkState->ParserState.PkgEnd; + } + break; + + default: + + /* No action for all other opcodes */ + break; + } + + break; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsLinkModuleCode + * + * PARAMETERS: ParentOp - Parent parser op + * AmlStart - Pointer to the AML + * AmlLength - Length of executable AML + * OwnerId - OwnerId of module level code + * + * RETURN: None. + * + * DESCRIPTION: Wrap the module-level code with a method object and link the + * object to the global list. Note, the mutex field of the method + * object is used to link multiple module-level code objects. + * + ******************************************************************************/ + +static void +AcpiPsLinkModuleCode ( + ACPI_PARSE_OBJECT *ParentOp, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_OPERAND_OBJECT *MethodObj; + ACPI_NAMESPACE_NODE *ParentNode; + + + /* Get the tail of the list */ + + Prev = Next = AcpiGbl_ModuleCodeList; + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + } + + /* + * Insert the module level code into the list. Merge it if it is + * adjacent to the previous element. + */ + if (!Prev || + ((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart)) + { + /* Create, initialize, and link a new temporary method object */ + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + return; + } + + if (ParentOp->Common.Node) + { + ParentNode = ParentOp->Common.Node; + } + else + { + ParentNode = AcpiGbl_RootNode; + } + + MethodObj->Method.AmlStart = AmlStart; + MethodObj->Method.AmlLength = AmlLength; + MethodObj->Method.OwnerId = OwnerId; + MethodObj->Method.Flags |= AOPOBJ_MODULE_LEVEL; + + /* + * Save the parent node in NextObject. This is cheating, but we + * don't want to expand the method object. + */ + MethodObj->Method.NextObject = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParentNode); + + if (!Prev) + { + AcpiGbl_ModuleCodeList = MethodObj; + } + else + { + Prev->Method.Mutex = MethodObj; + } + } + else + { + Prev->Method.AmlLength += AmlLength; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteOp + * + * PARAMETERS: WalkState - Current state + * Op - Returned Op + * Status - Parse status before complete Op + * + * RETURN: Status + * + * DESCRIPTION: Complete Op + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCompleteOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **Op, + ACPI_STATUS Status) +{ + ACPI_STATUS Status2; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState); + + + /* + * Finished one argument of the containing scope + */ + WalkState->ParserState.Scope->ParseScope.ArgCount--; + + /* Close this Op (will result in parse subtree deletion) */ + + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + + *Op = NULL; + + switch (Status) + { + case AE_OK: + break; + + + case AE_CTRL_TRANSFER: + + /* We are about to transfer to a called method */ + + WalkState->PrevOp = NULL; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + + + case AE_CTRL_END: + + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + if (*Op) + { + WalkState->Op = *Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode); + WalkState->Opcode = (*Op)->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, *Op, Status); + + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + Status = AE_OK; + break; + + + case AE_CTRL_BREAK: + case AE_CTRL_CONTINUE: + + /* Pop off scopes until we find the While */ + + while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP)) + { + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } + + /* Close this iteration of the While loop */ + + WalkState->Op = *Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode); + WalkState->Opcode = (*Op)->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, *Op, Status); + + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + + Status = AE_OK; + break; + + + case AE_CTRL_TERMINATE: + + /* Clean up */ + do + { + if (*Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + + AcpiUtDeleteGenericState ( + AcpiUtPopGenericState (&WalkState->ControlState)); + } + + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (*Op); + + return_ACPI_STATUS (AE_OK); + + + default: /* All other non-AE_OK status */ + + do + { + if (*Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (*Op); + + +#if 0 + /* + * TBD: Cleanup parse ops on error + */ + if (*Op == NULL) + { + AcpiPsPopScope (ParserState, Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } +#endif + WalkState->PrevOp = NULL; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + } + + /* This scope complete? */ + + if (AcpiPsHasCompletedScope (&(WalkState->ParserState))) + { + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op)); + } + else + { + *Op = NULL; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteFinalOp + * + * PARAMETERS: WalkState - Current state + * Op - Current Op + * Status - Current parse status before complete last + * Op + * + * RETURN: Status + * + * DESCRIPTION: Complete last Op. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCompleteFinalOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS Status) +{ + ACPI_STATUS Status2; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState); + + + /* + * Complete the last Op (if not completed), and clear the scope stack. + * It is easily possible to end an AML "package" with an unbounded number + * of open scopes (such as when several ASL blocks are closed with + * sequential closing braces). We want to terminate each one cleanly. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op)); + do + { + if (Op) + { + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (&(WalkState->ParserState), &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + /* First error is most important */ + + (void) AcpiPsCompleteThisOp (WalkState, Op); + return_ACPI_STATUS (Status); + } + } + + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes, + &WalkState->ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseLoop + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Parse AML (pointed to by the current parser state) and return + * a tree of ops. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = NULL; /* current op */ + ACPI_PARSE_STATE *ParserState; + UINT8 *AmlOpStart = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState); + + + if (WalkState->DescendingCallback == NULL) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + ParserState = &WalkState->ParserState; + WalkState->ArgTypes = 0; + +#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + + if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) + { + /* We are restarting a preempted control method */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + /* + * We must check if a predicate to an IF or WHILE statement + * was just completed + */ + if ((ParserState->Scope->ParseScope.Op) && + ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) || + (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING)) + { + /* + * A predicate was just completed, get the value of the + * predicate and branch based on that value + */ + WalkState->Op = NULL; + Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE)); + if (ACPI_FAILURE (Status) && + ((Status & AE_CODE_MASK) != AE_CODE_CONTROL)) + { + if (Status == AE_AML_NO_RETURN_VALUE) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Invoked method did not return a value")); + + } + + ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed")); + return_ACPI_STATUS (Status); + } + + Status = AcpiPsNextParseState (WalkState, Op, Status); + } + + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); + } + else if (WalkState->PrevOp) + { + /* We were in the middle of an op */ + + Op = WalkState->PrevOp; + WalkState->ArgTypes = WalkState->PrevArgTypes; + } + } +#endif + + /* Iterative parsing loop, while there is more AML to process: */ + + while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) + { + AmlOpStart = ParserState->Aml; + if (!Op) + { + Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_PARSE_CONTINUE) + { + continue; + } + + if (Status == AE_CTRL_PARSE_PENDING) + { + Status = AE_OK; + } + + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + + Op->Common.AmlOffset = WalkState->AmlOffset; + + if (WalkState->OpInfo) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", + (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name, + Op, ParserState->Aml, Op->Common.AmlOffset)); + } + } + + + /* + * Start ArgCount at zero because we don't know if there are + * any args yet + */ + WalkState->ArgCount = 0; + + /* Are there any arguments that must be processed? */ + + if (WalkState->ArgTypes) + { + /* Get arguments */ + + Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op); + if (ACPI_FAILURE (Status)) + { + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + } + + /* Check for arguments that need to be processed */ + + if (WalkState->ArgCount) + { + /* + * There are arguments (complex ones), push Op and + * prepare for argument + */ + Status = AcpiPsPushScope (ParserState, Op, + WalkState->ArgTypes, WalkState->ArgCount); + if (ACPI_FAILURE (Status)) + { + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + + Op = NULL; + continue; + } + + /* + * All arguments have been processed -- Op is complete, + * prepare for next + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (WalkState->OpInfo->Flags & AML_NAMED) + { + if (AcpiGbl_Depth) + { + AcpiGbl_Depth--; + } + + if (Op->Common.AmlOpcode == AML_REGION_OP || + Op->Common.AmlOpcode == AML_DATA_REGION_OP) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Completed parsing an OpRegion declaration, we now + * know the length. + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + } + + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + + if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP) + { + /* + * Backup to beginning of BankField declaration + * + * BodyLength is unknown until we parse the body + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + + /* This op complete, notify the dispatcher */ + + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + } + } + + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } /* while ParserState->Aml */ + + Status = AcpiPsCompleteFinalOp (WalkState, Op, Status); + return_ACPI_STATUS (Status); +} + diff --git a/drivers/bus/acpi/acpica/parser/psopcode.c b/drivers/bus/acpi/acpica/parser/psopcode.c new file mode 100644 index 00000000000..d107c523707 --- /dev/null +++ b/drivers/bus/acpi/acpica/parser/psopcode.c @@ -0,0 +1,589 @@ +/****************************************************************************** + * + * Module Name: psopcode - Parser/Interpreter opcode information table + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acopcode.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psopcode") + + +static const UINT8 AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6}; + + +/******************************************************************************* + * + * NAME: AcpiGbl_AmlOpInfo + * + * DESCRIPTION: Opcode table. Each entry contains + * The name is a simple ascii string, the operand specifier is an + * ascii string with one letter per operand. The letter specifies + * the operand type. + * + ******************************************************************************/ + +/* + * Summary of opcode types/flags + * + + Opcodes that have associated namespace objects (AML_NSOBJECT flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_FIELD_OP + AML_INDEX_FIELD_OP + AML_BANK_FIELD_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + AML_INT_NAMEDFIELD_OP + AML_INT_METHODCALL_OP + AML_INT_NAMEPATH_OP + + Opcodes that are "namespace" opcodes (AML_NSOPCODE flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_FIELD_OP + AML_INDEX_FIELD_OP + AML_BANK_FIELD_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_INT_NAMEDFIELD_OP + + Opcodes that have an associated namespace node (AML_NSNODE flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + AML_INT_NAMEDFIELD_OP + AML_INT_METHODCALL_OP + AML_INT_NAMEPATH_OP + + Opcodes that define named ACPI objects (AML_NAMED flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_INT_NAMEDFIELD_OP + + Opcodes that contain executable AML as part of the definition that + must be deferred until needed + + AML_METHOD_OP + AML_VAR_PACKAGE_OP + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + AML_REGION_OP + AML_BUFFER_OP + + Field opcodes + + AML_CREATE_FIELD_OP + AML_FIELD_OP + AML_INDEX_FIELD_OP + AML_BANK_FIELD_OP + + Field "Create" opcodes + + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + + ******************************************************************************/ + + +/* + * Master Opcode information table. A summary of everything we know about each + * opcode, all in one place. + */ +const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = +{ +/*! [Begin] no source code translation */ +/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ + +/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), +/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), +/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), +/* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), +/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R), +/* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), +/* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), +/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), +/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), + +/* Prefixed opcodes (Two-byte opcodes with a prefix op) */ + +/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), +/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE), +/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R), +/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), +/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), +/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), +/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), +/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R), +/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_LOCAL_BANK_FIELD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD | AML_DEFER), + +/* Internal opcodes that map to invalid AML opcodes */ + +/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ), +/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), +/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0), +/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), +/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL), +/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), + +/* ACPI 2.0 opcodes */ + +/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), +/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), +/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), +/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), + +/* ACPI 3.0 opcodes */ + +/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R) + +/*! [End] no source code translation !*/ +}; + +/* + * This table is directly indexed by the opcodes, and returns an + * index into the table above + */ +static const UINT8 AcpiGbl_ShortOpIndex[256] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 8 9 A B C D E F */ +/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, +/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, +/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, +/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, +/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, +/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, +/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, +/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, +/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, +/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, +/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, +/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, +/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, +/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, +/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, +}; + +/* + * This table is indexed by the second opcode of the extended opcode + * pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo) + */ +static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 8 9 A B C D E F */ +/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, +/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, +/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, +/* 0x88 */ 0x7C, +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeInfo + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the info about the opcode. + * + * DESCRIPTION: Find AML opcode description based on the opcode. + * NOTE: This procedure must ALWAYS return a valid pointer! + * + ******************************************************************************/ + +const ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode) +{ + ACPI_FUNCTION_NAME (PsGetOpcodeInfo); + + + /* + * Detect normal 8-bit opcode or extended 16-bit opcode + */ + if (!(Opcode & 0xFF00)) + { + /* Simple (8-bit) opcode: 0-255, can't index beyond table */ + + return (&AcpiGbl_AmlOpInfo [AcpiGbl_ShortOpIndex [(UINT8) Opcode]]); + } + + if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) && + (((UINT8) Opcode) <= MAX_EXTENDED_OPCODE)) + { + /* Valid extended (16-bit) opcode */ + + return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]); + } + + /* Unknown AML opcode */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Unknown AML opcode [%4.4X]\n", Opcode)); + + return (&AcpiGbl_AmlOpInfo [_UNK]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeName + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the name of the opcode (ASCII String) + * Note: Never returns NULL. + * + * DESCRIPTION: Translate an opcode into a human-readable string + * + ******************************************************************************/ + +char * +AcpiPsGetOpcodeName ( + UINT16 Opcode) +{ +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) + + const ACPI_OPCODE_INFO *Op; + + + Op = AcpiPsGetOpcodeInfo (Opcode); + + /* Always guaranteed to return a valid pointer */ + + return (Op->Name); + +#else + return ("OpcodeName unavailable"); + +#endif +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArgumentCount + * + * PARAMETERS: OpType - Type associated with the AML opcode + * + * RETURN: Argument count + * + * DESCRIPTION: Obtain the number of expected arguments for an AML opcode + * + ******************************************************************************/ + +UINT8 +AcpiPsGetArgumentCount ( + UINT32 OpType) +{ + + if (OpType <= AML_TYPE_EXEC_6A_0T_1R) + { + return (AcpiGbl_ArgumentCount[OpType]); + } + + return (0); +} diff --git a/drivers/bus/acpi/acpica/parser/psparse.c b/drivers/bus/acpi/acpica/parser/psparse.c new file mode 100644 index 00000000000..820f54bd0ca --- /dev/null +++ b/drivers/bus/acpi/acpica/parser/psparse.c @@ -0,0 +1,791 @@ +/****************************************************************************** + * + * Module Name: psparse - Parser top level AML parse routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, + * like Perl, do. Parsing is done by hand rather than with a YACC + * generated parser to tightly constrain stack and dynamic memory + * usage. At the same time, parsing is kept flexible and the code + * fairly compact by parsing based on a list of AML opcode + * templates in AmlOpInfo[] + */ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psparse") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeSize + * + * PARAMETERS: Opcode - An AML opcode + * + * RETURN: Size of the opcode, in bytes (1 or 2) + * + * DESCRIPTION: Get the size of the current opcode. + * + ******************************************************************************/ + +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode) +{ + + /* Extended (2-byte) opcode if > 255 */ + + if (Opcode > 0x00FF) + { + return (2); + } + + /* Otherwise, just a single byte opcode */ + + return (1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPeekOpcode + * + * PARAMETERS: ParserState - A parser state object + * + * RETURN: Next AML opcode + * + * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) + * + ******************************************************************************/ + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Aml; + UINT16 Opcode; + + + Aml = ParserState->Aml; + Opcode = (UINT16) ACPI_GET8 (Aml); + + if (Opcode == AML_EXTENDED_OP_PREFIX) + { + /* Extended opcode, get the second opcode byte */ + + Aml++; + Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml)); + } + + return (Opcode); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteThisOp + * + * PARAMETERS: WalkState - Current State + * Op - Op to complete + * + * RETURN: Status + * + * DESCRIPTION: Perform any cleanup at the completion of an Op. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + const ACPI_OPCODE_INFO *ParentInfo; + ACPI_PARSE_OBJECT *ReplacementOp = NULL; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op); + + + /* Check for null Op, can happen if AML code is corrupt */ + + if (!Op) + { + return_ACPI_STATUS (AE_OK); /* OK for now */ + } + + /* Delete this op and the subtree below it if asked to */ + + if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || + (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT)) + { + return_ACPI_STATUS (AE_OK); + } + + /* Make sure that we only delete this subtree */ + + if (Op->Common.Parent) + { + Prev = Op->Common.Parent->Common.Value.Arg; + if (!Prev) + { + /* Nothing more to do */ + + goto Cleanup; + } + + /* + * Check if we need to replace the operator and its subtree + * with a return value op (placeholder op) + */ + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); + + switch (ParentInfo->Class) + { + case AML_CLASS_CONTROL: + break; + + case AML_CLASS_CREATE: + + /* + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op + */ + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + break; + + case AML_CLASS_NAMED_OBJECT: + + /* + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op + */ + if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + } + else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) + { + if ((Op->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + else + { + ReplacementOp->Named.Data = Op->Named.Data; + ReplacementOp->Named.Length = Op->Named.Length; + } + } + } + break; + + default: + + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + } + + /* We must unlink this op from the parent tree */ + + if (Prev == Op) + { + /* This op is the first in the list */ + + if (ReplacementOp) + { + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Op->Common.Parent->Common.Value.Arg = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; + } + else + { + Op->Common.Parent->Common.Value.Arg = Op->Common.Next; + } + } + + /* Search the parent list */ + + else while (Prev) + { + /* Traverse all siblings in the parent's argument list */ + + Next = Prev->Common.Next; + if (Next == Op) + { + if (ReplacementOp) + { + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Prev->Common.Next = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; + Next = NULL; + } + else + { + Prev->Common.Next = Op->Common.Next; + Next = NULL; + } + } + Prev = Next; + } + } + + +Cleanup: + + /* Now we can actually delete the subtree rooted at Op */ + + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsNextParseState + * + * PARAMETERS: WalkState - Current state + * Op - Current parse op + * CallbackStatus - Status from previous operation + * + * RETURN: Status + * + * DESCRIPTION: Update the parser state based upon the return exception from + * the parser callback. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsNextParseState ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS CallbackStatus) +{ + ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; + ACPI_STATUS Status = AE_CTRL_PENDING; + + + ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op); + + + switch (CallbackStatus) + { + case AE_CTRL_TERMINATE: + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + ParserState->Aml = ParserState->AmlEnd; + Status = AE_CTRL_TERMINATE; + break; + + + case AE_CTRL_BREAK: + + ParserState->Aml = WalkState->AmlLastWhile; + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_BREAK; + break; + + + case AE_CTRL_CONTINUE: + + ParserState->Aml = WalkState->AmlLastWhile; + Status = AE_CTRL_CONTINUE; + break; + + + case AE_CTRL_PENDING: + + ParserState->Aml = WalkState->AmlLastWhile; + break; + +#if 0 + case AE_CTRL_SKIP: + + ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd; + Status = AE_OK; + break; +#endif + + case AE_CTRL_TRUE: + /* + * Predicate of an IF was true, and we are at the matching ELSE. + * Just close out this package + */ + ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState); + Status = AE_CTRL_PENDING; + break; + + + case AE_CTRL_FALSE: + /* + * Either an IF/WHILE Predicate was false or we encountered a BREAK + * opcode. In both cases, we do not execute the rest of the + * package; We simply close out the parent (finishing the walk of + * this branch of the tree) and continue execution at the parent + * level. + */ + ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd; + + /* In the case of a BREAK, just force a predicate (if any) to FALSE */ + + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_END; + break; + + + case AE_CTRL_TRANSFER: + + /* A method call (invocation) -- transfer control */ + + Status = AE_CTRL_TRANSFER; + WalkState->PrevOp = Op; + WalkState->MethodCallOp = Op; + WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node; + + /* Will return value (if any) be used by the caller? */ + + WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState); + break; + + + default: + + Status = CallbackStatus; + if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL) + { + Status = AE_OK; + } + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseAml + * + * PARAMETERS: WalkState - Current state + * + * + * RETURN: Status + * + * DESCRIPTION: Parse raw AML and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseAml ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_THREAD_STATE *Thread; + ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList; + ACPI_WALK_STATE *PreviousWalkState; + + + ACPI_FUNCTION_TRACE (PsParseAml); + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Entered with WalkState=%p Aml=%p size=%X\n", + WalkState, WalkState->ParserState.Aml, + WalkState->ParserState.AmlSize)); + + if (!WalkState->ParserState.Aml) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Create and initialize a new thread state */ + + Thread = AcpiUtCreateThreadState (); + if (!Thread) + { + if (WalkState->MethodDesc) + { + /* Executing a control method - additional cleanup */ + + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + } + + AcpiDsDeleteWalkState (WalkState); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + WalkState->Thread = Thread; + + /* + * If executing a method, the starting SyncLevel is this method's + * SyncLevel + */ + if (WalkState->MethodDesc) + { + WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel; + } + + AcpiDsPushWalkState (WalkState, Thread); + + /* + * This global allows the AML debugger to get a handle to the currently + * executing control method. + */ + AcpiGbl_CurrentWalkList = Thread; + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState)); + + Status = AE_OK; + while (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + /* + * The ParseLoop executes AML until the method terminates + * or calls another method. + */ + Status = AcpiPsParseLoop (WalkState); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Completed one call to walk loop, %s State=%p\n", + AcpiFormatException (Status), WalkState)); + + if (Status == AE_CTRL_TRANSFER) + { + /* + * A method call was detected. + * Transfer control to the called control method + */ + Status = AcpiDsCallControlMethod (Thread, WalkState, NULL); + if (ACPI_FAILURE (Status)) + { + Status = AcpiDsMethodError (Status, WalkState); + } + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + WalkState = AcpiDsGetCurrentWalkState (Thread); + continue; + } + else if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + } + else if ((Status != AE_OK) && (WalkState->MethodDesc)) + { + /* Either the method parse or actual execution failed */ + + ACPI_ERROR_METHOD ("Method parse/execution failed", + WalkState->MethodNode, NULL, Status); + + /* Check for possible multi-thread reentrancy problem */ + + if ((Status == AE_ALREADY_EXISTS) && + (!WalkState->MethodDesc->Method.Mutex)) + { + ACPI_INFO ((AE_INFO, + "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error", + WalkState->MethodNode->Name.Ascii)); + + /* + * Method tried to create an object twice. The probable cause is + * that the method cannot handle reentrancy. + * + * The method is marked NotSerialized, but it tried to create + * a named object, causing the second thread entrance to fail. + * Workaround this problem by marking the method permanently + * as Serialized. + */ + WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED; + WalkState->MethodDesc->Method.SyncLevel = 0; + } + } + + /* We are done with this walk, move on to the parent if any */ + + WalkState = AcpiDsPopWalkState (Thread); + + /* Reset the current scope to the beginning of scope stack */ + + AcpiDsScopeStackClear (WalkState); + + /* + * If we just returned from the execution of a control method or if we + * encountered an error during the method parse phase, there's lots of + * cleanup to do + */ + if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) || + (ACPI_FAILURE (Status))) + { + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + } + + /* Delete this walk state and all linked control states */ + + AcpiPsCleanupScope (&WalkState->ParserState); + PreviousWalkState = WalkState; + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "ReturnValue=%p, ImplicitValue=%p State=%p\n", + WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState)); + + /* Check if we have restarted a preempted walk */ + + WalkState = AcpiDsGetCurrentWalkState (Thread); + if (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + /* + * There is another walk state, restart it. + * If the method return value is not used by the parent, + * The object is deleted + */ + if (!PreviousWalkState->ReturnDesc) + { + /* + * In slack mode execution, if there is no return value + * we should implicitly return zero (0) as a default value. + */ + if (AcpiGbl_EnableInterpreterSlack && + !PreviousWalkState->ImplicitReturnObj) + { + PreviousWalkState->ImplicitReturnObj = + AcpiUtCreateIntegerObject ((UINT64) 0); + if (!PreviousWalkState->ImplicitReturnObj) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* Restart the calling control method */ + + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ImplicitReturnObj); + } + else + { + /* + * We have a valid return value, delete any implicit + * return value. + */ + AcpiDsClearImplicitReturn (PreviousWalkState); + + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ReturnDesc); + } + if (ACPI_SUCCESS (Status)) + { + WalkState->WalkType |= ACPI_WALK_METHOD_RESTART; + } + } + else + { + /* On error, delete any return object or implicit return */ + + AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + AcpiDsClearImplicitReturn (PreviousWalkState); + } + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + else if (PreviousWalkState->CallerReturnDesc) + { + if (PreviousWalkState->ImplicitReturnObj) + { + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ImplicitReturnObj; + } + else + { + /* NULL if no return value */ + + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ReturnDesc; + } + } + else + { + if (PreviousWalkState->ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + } + if (PreviousWalkState->ImplicitReturnObj) + { + /* Caller doesn't want it, must delete it */ + + AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj); + } + } + + AcpiDsDeleteWalkState (PreviousWalkState); + } + + /* Normal exit */ + + AcpiExReleaseAllMutexes (Thread); + AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread)); + AcpiGbl_CurrentWalkList = PrevWalkList; + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/parser/psscope.c b/drivers/bus/acpi/acpica/parser/psscope.c new file mode 100644 index 00000000000..979dbb15151 --- /dev/null +++ b/drivers/bus/acpi/acpica/parser/psscope.c @@ -0,0 +1,374 @@ +/****************************************************************************** + * + * Module Name: psscope - Parser scope stack management routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psscope") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetParentScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to an Op object + * + * DESCRIPTION: Get parent of current op being parsed + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetParentScope ( + ACPI_PARSE_STATE *ParserState) +{ + + return (ParserState->Scope->ParseScope.Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsHasCompletedScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Boolean, TRUE = scope completed. + * + * DESCRIPTION: Is parsing of current argument complete? Determined by + * 1) AML pointer is at or beyond the end of the scope + * 2) The scope argument count has reached zero. + * + ******************************************************************************/ + +BOOLEAN +AcpiPsHasCompletedScope ( + ACPI_PARSE_STATE *ParserState) +{ + + return ((BOOLEAN) + ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || + !ParserState->Scope->ParseScope.ArgCount))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitScope + * + * PARAMETERS: ParserState - Current parser state object + * Root - the Root Node of this new scope + * + * RETURN: Status + * + * DESCRIPTION: Allocate and init a new scope object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsInitScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *RootOp) +{ + ACPI_GENERIC_STATE *Scope; + + + ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp); + + + Scope = AcpiUtCreateGenericState (); + if (!Scope) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE; + Scope->ParseScope.Op = RootOp; + Scope->ParseScope.ArgCount = ACPI_VAR_ARGS; + Scope->ParseScope.ArgEnd = ParserState->AmlEnd; + Scope->ParseScope.PkgEnd = ParserState->AmlEnd; + + ParserState->Scope = Scope; + ParserState->StartOp = RootOp; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPushScope + * + * PARAMETERS: ParserState - Current parser state object + * Op - Current op to be pushed + * RemainingArgs - List of args remaining + * ArgCount - Fixed or variable number of args + * + * RETURN: Status + * + * DESCRIPTION: Push current op to begin parsing its argument + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsPushScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Op, + UINT32 RemainingArgs, + UINT32 ArgCount) +{ + ACPI_GENERIC_STATE *Scope; + + + ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op); + + + Scope = AcpiUtCreateGenericState (); + if (!Scope) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE; + Scope->ParseScope.Op = Op; + Scope->ParseScope.ArgList = RemainingArgs; + Scope->ParseScope.ArgCount = ArgCount; + Scope->ParseScope.PkgEnd = ParserState->PkgEnd; + + /* Push onto scope stack */ + + AcpiUtPushGenericState (&ParserState->Scope, Scope); + + if (ArgCount == ACPI_VAR_ARGS) + { + /* Multiple arguments */ + + Scope->ParseScope.ArgEnd = ParserState->PkgEnd; + } + else + { + /* Single argument */ + + Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPopScope + * + * PARAMETERS: ParserState - Current parser state object + * Op - Where the popped op is returned + * ArgList - Where the popped "next argument" is + * returned + * ArgCount - Count of objects in ArgList + * + * RETURN: Status + * + * DESCRIPTION: Return to parsing a previous op + * + ******************************************************************************/ + +void +AcpiPsPopScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT **Op, + UINT32 *ArgList, + UINT32 *ArgCount) +{ + ACPI_GENERIC_STATE *Scope = ParserState->Scope; + + + ACPI_FUNCTION_TRACE (PsPopScope); + + + /* Only pop the scope if there is in fact a next scope */ + + if (Scope->Common.Next) + { + Scope = AcpiUtPopGenericState (&ParserState->Scope); + + /* Return to parsing previous op */ + + *Op = Scope->ParseScope.Op; + *ArgList = Scope->ParseScope.ArgList; + *ArgCount = Scope->ParseScope.ArgCount; + ParserState->PkgEnd = Scope->ParseScope.PkgEnd; + + /* All done with this scope state structure */ + + AcpiUtDeleteGenericState (Scope); + } + else + { + /* Empty parse stack, prepare to fetch next opcode */ + + *Op = NULL; + *ArgList = 0; + *ArgCount = 0; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Popped Op %p Args %X\n", *Op, *ArgCount)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCleanupScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: None + * + * DESCRIPTION: Destroy available list, remaining stack levels, and return + * root scope + * + ******************************************************************************/ + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *ParserState) +{ + ACPI_GENERIC_STATE *Scope; + + + ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState); + + + if (!ParserState) + { + return_VOID; + } + + /* Delete anything on the scope stack */ + + while (ParserState->Scope) + { + Scope = AcpiUtPopGenericState (&ParserState->Scope); + AcpiUtDeleteGenericState (Scope); + } + + return_VOID; +} + diff --git a/drivers/bus/acpi/acpica/parser/pstree.c b/drivers/bus/acpi/acpica/parser/pstree.c new file mode 100644 index 00000000000..20ac405cac3 --- /dev/null +++ b/drivers/bus/acpi/acpica/parser/pstree.c @@ -0,0 +1,427 @@ +/****************************************************************************** + * + * Module Name: pstree - Parser op tree manipulation/traversal/search + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __PSTREE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("pstree") + +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *op); +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArg + * + * PARAMETERS: Op - Get an argument for this op + * Argn - Nth argument to get + * + * RETURN: The argument (as an Op object). NULL if argument does not exist + * + * DESCRIPTION: Get the specified op's argument. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetArg ( + ACPI_PARSE_OBJECT *Op, + UINT32 Argn) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_ENTRY (); + + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + /* Invalid opcode or ASCII character */ + + return (NULL); + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(OpInfo->Flags & AML_HAS_ARGS)) + { + /* Has no linked argument objects */ + + return (NULL); + } + + /* Get the requested argument object */ + + Arg = Op->Common.Value.Arg; + while (Arg && Argn) + { + Argn--; + Arg = Arg->Common.Next; + } + + return (Arg); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAppendArg + * + * PARAMETERS: Op - Append an argument to this Op. + * Arg - Argument Op to append + * + * RETURN: None. + * + * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK) + * + ******************************************************************************/ + +void +AcpiPsAppendArg ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *Arg) +{ + ACPI_PARSE_OBJECT *PrevArg; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Op) + { + return; + } + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + /* Invalid opcode */ + + ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X", + Op->Common.AmlOpcode)); + return; + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(OpInfo->Flags & AML_HAS_ARGS)) + { + /* Has no linked argument objects */ + + return; + } + + /* Append the argument to the linked argument list */ + + if (Op->Common.Value.Arg) + { + /* Append to existing argument list */ + + PrevArg = Op->Common.Value.Arg; + while (PrevArg->Common.Next) + { + PrevArg = PrevArg->Common.Next; + } + PrevArg->Common.Next = Arg; + } + else + { + /* No argument list, this will be the first argument */ + + Op->Common.Value.Arg = Arg; + } + + /* Set the parent in this arg and any args linked after it */ + + while (Arg) + { + Arg->Common.Parent = Op; + Arg = Arg->Common.Next; + + Op->Common.ArgListLength++; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetDepthNext + * + * PARAMETERS: Origin - Root of subtree to search + * Op - Last (previous) Op that was found + * + * RETURN: Next Op found in the search. + * + * DESCRIPTION: Get next op in tree (walking the tree in depth-first order) + * Return NULL when reaching "origin" or when walking up from root + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *Arg; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Op) + { + return (NULL); + } + + /* Look for an argument or child */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + return (Next); + } + + /* Look for a sibling */ + + Next = Op->Common.Next; + if (Next) + { + return (Next); + } + + /* Look for a sibling of parent */ + + Parent = Op->Common.Parent; + + while (Parent) + { + Arg = AcpiPsGetArg (Parent, 0); + while (Arg && (Arg != Origin) && (Arg != Op)) + { + Arg = Arg->Common.Next; + } + + if (Arg == Origin) + { + /* Reached parent of origin, end search */ + + return (NULL); + } + + if (Parent->Common.Next) + { + /* Found sibling of parent */ + + return (Parent->Common.Next); + } + + Op = Parent; + Parent = Parent->Common.Parent; + } + + return (Next); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiPsGetChild + * + * PARAMETERS: Op - Get the child of this Op + * + * RETURN: Child Op, Null if none is found. + * + * DESCRIPTION: Get op's children or NULL if none + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Child = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + switch (Op->Common.AmlOpcode) + { + case AML_SCOPE_OP: + case AML_ELSE_OP: + case AML_DEVICE_OP: + case AML_THERMAL_ZONE_OP: + case AML_INT_METHODCALL_OP: + + Child = AcpiPsGetArg (Op, 0); + break; + + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_IF_OP: + case AML_WHILE_OP: + case AML_FIELD_OP: + + Child = AcpiPsGetArg (Op, 1); + break; + + + case AML_POWER_RES_OP: + case AML_INDEX_FIELD_OP: + + Child = AcpiPsGetArg (Op, 2); + break; + + + case AML_PROCESSOR_OP: + case AML_BANK_FIELD_OP: + + Child = AcpiPsGetArg (Op, 3); + break; + + + default: + /* All others have no children */ + break; + } + + return (Child); +} +#endif + + diff --git a/drivers/bus/acpi/acpica/parser/psutils.c b/drivers/bus/acpi/acpica/parser/psutils.c new file mode 100644 index 00000000000..42f2b015d6c --- /dev/null +++ b/drivers/bus/acpi/acpica/parser/psutils.c @@ -0,0 +1,362 @@ +/****************************************************************************** + * + * Module Name: psutils - Parser miscellaneous utilities (Parser only) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateScopeOp + * + * PARAMETERS: None + * + * RETURN: A new Scope object, null on failure + * + * DESCRIPTION: Create a Scope and associated namepath op with the root name + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsCreateScopeOp ( + void) +{ + ACPI_PARSE_OBJECT *ScopeOp; + + + ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP); + if (!ScopeOp) + { + return (NULL); + } + + ScopeOp->Named.Name = ACPI_ROOT_NAME; + return (ScopeOp); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitOp + * + * PARAMETERS: Op - A newly allocated Op object + * Opcode - Opcode to store in the Op + * + * RETURN: None + * + * DESCRIPTION: Initialize a parse (Op) object + * + ******************************************************************************/ + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode) +{ + ACPI_FUNCTION_ENTRY (); + + + Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER; + Op->Common.AmlOpcode = Opcode; + + ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName, + (AcpiPsGetOpcodeInfo (Opcode))->Name, + sizeof (Op->Common.AmlOpName))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAllocOp + * + * PARAMETERS: Opcode - Opcode that will be stored in the new Op + * + * RETURN: Pointer to the new Op, null on failure + * + * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on + * opcode. A cache of opcodes is available for the pure + * GENERIC_OP, since this is by far the most commonly used. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsAllocOp ( + UINT16 Opcode) +{ + ACPI_PARSE_OBJECT *Op; + const ACPI_OPCODE_INFO *OpInfo; + UINT8 Flags = ACPI_PARSEOP_GENERIC; + + + ACPI_FUNCTION_ENTRY (); + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + + /* Determine type of ParseOp required */ + + if (OpInfo->Flags & AML_DEFER) + { + Flags = ACPI_PARSEOP_DEFERRED; + } + else if (OpInfo->Flags & AML_NAMED) + { + Flags = ACPI_PARSEOP_NAMED; + } + else if (Opcode == AML_INT_BYTELIST_OP) + { + Flags = ACPI_PARSEOP_BYTELIST; + } + + /* Allocate the minimum required size object */ + + if (Flags == ACPI_PARSEOP_GENERIC) + { + /* The generic op (default) is by far the most common (16 to 1) */ + + Op = AcpiOsAcquireObject (AcpiGbl_PsNodeCache); + } + else + { + /* Extended parseop */ + + Op = AcpiOsAcquireObject (AcpiGbl_PsNodeExtCache); + } + + /* Initialize the Op */ + + if (Op) + { + AcpiPsInitOp (Op, Opcode); + Op->Common.Flags = Flags; + } + + return (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFreeOp + * + * PARAMETERS: Op - Op to be freed + * + * RETURN: None. + * + * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list + * or actually free it. + * + ******************************************************************************/ + +void +AcpiPsFreeOp ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_FUNCTION_NAME (PsFreeOp); + + + if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", Op)); + } + + if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) + { + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeCache, Op); + } + else + { + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeExtCache, Op); + } +} + + +/******************************************************************************* + * + * FUNCTION: Utility functions + * + * DESCRIPTION: Low level character and object functions + * + ******************************************************************************/ + + +/* + * Is "c" a namestring lead character? + */ +BOOLEAN +AcpiPsIsLeadingChar ( + UINT32 c) +{ + return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z'))); +} + + +/* + * Is "c" a namestring prefix character? + */ +BOOLEAN +AcpiPsIsPrefixChar ( + UINT32 c) +{ + return ((BOOLEAN) (c == '\\' || c == '^')); +} + + +/* + * Get op's name (4-byte name segment) or 0 if unnamed + */ +UINT32 +AcpiPsGetName ( + ACPI_PARSE_OBJECT *Op) +{ + + /* The "generic" object has no name associated with it */ + + if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) + { + return (0); + } + + /* Only the "Extended" parse objects have a name */ + + return (Op->Named.Name); +} + + +/* + * Set op's name + */ +void +AcpiPsSetName ( + ACPI_PARSE_OBJECT *Op, + UINT32 name) +{ + + /* The "generic" object has no name associated with it */ + + if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) + { + return; + } + + Op->Named.Name = name; +} + diff --git a/drivers/bus/acpi/acpica/parser/pswalk.c b/drivers/bus/acpi/acpica/parser/pswalk.c new file mode 100644 index 00000000000..d8d5f5e6f21 --- /dev/null +++ b/drivers/bus/acpi/acpica/parser/pswalk.c @@ -0,0 +1,193 @@ +/****************************************************************************** + * + * Module Name: pswalk - Parser routines to walk parsed op tree(s) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("pswalk") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteParseTree + * + * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete + * + * RETURN: None + * + * DESCRIPTION: Delete a portion of or an entire parse tree. + * + ******************************************************************************/ + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *SubtreeRoot) +{ + ACPI_PARSE_OBJECT *Op = SubtreeRoot; + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot); + + + /* Visit all nodes in the subtree */ + + while (Op) + { + /* Check if we are not ascending */ + + if (Op != Parent) + { + /* Look for an argument or child of the current op */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + /* Still going downward in tree (Op is not completed yet) */ + + Op = Next; + continue; + } + } + + /* No more children, this Op is complete. */ + + Next = Op->Common.Next; + Parent = Op->Common.Parent; + + AcpiPsFreeOp (Op); + + /* If we are back to the starting point, the walk is complete. */ + + if (Op == SubtreeRoot) + { + return_VOID; + } + if (Next) + { + Op = Next; + } + else + { + Op = Parent; + } + } + + return_VOID; +} diff --git a/drivers/bus/acpi/acpica/parser/psxface.c b/drivers/bus/acpi/acpica/parser/psxface.c new file mode 100644 index 00000000000..1bf36e01c93 --- /dev/null +++ b/drivers/bus/acpi/acpica/parser/psxface.c @@ -0,0 +1,510 @@ +/****************************************************************************** + * + * Module Name: psxface - Parser external interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __PSXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psxface") + +/* Local Prototypes */ + +static void +AcpiPsStartTrace ( + ACPI_EVALUATE_INFO *Info); + +static void +AcpiPsStopTrace ( + ACPI_EVALUATE_INFO *Info); + +static void +AcpiPsUpdateParameterList ( + ACPI_EVALUATE_INFO *Info, + UINT16 Action); + + +/******************************************************************************* + * + * FUNCTION: AcpiDebugTrace + * + * PARAMETERS: MethodName - Valid ACPI name string + * DebugLevel - Optional level mask. 0 to use default + * DebugLayer - Optional layer mask. 0 to use default + * Flags - bit 1: one shot(1) or persistent(0) + * + * RETURN: Status + * + * DESCRIPTION: External interface to enable debug tracing during control + * method execution + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDebugTrace ( + char *Name, + UINT32 DebugLevel, + UINT32 DebugLayer, + UINT32 Flags) +{ + ACPI_STATUS Status; + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* TBDs: Validate name, allow full path or just nameseg */ + + AcpiGbl_TraceMethodName = *ACPI_CAST_PTR (UINT32, Name); + AcpiGbl_TraceFlags = Flags; + + if (DebugLevel) + { + AcpiGbl_TraceDbgLevel = DebugLevel; + } + if (DebugLayer) + { + AcpiGbl_TraceDbgLayer = DebugLayer; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsStartTrace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Start control method execution trace + * + ******************************************************************************/ + +static void +AcpiPsStartTrace ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return; + } + + if ((!AcpiGbl_TraceMethodName) || + (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer)) + { + goto Exit; + } + + AcpiGbl_OriginalDbgLevel = AcpiDbgLevel; + AcpiGbl_OriginalDbgLayer = AcpiDbgLayer; + + AcpiDbgLevel = 0x00FFFFFF; + AcpiDbgLayer = ACPI_UINT32_MAX; + + if (AcpiGbl_TraceDbgLevel) + { + AcpiDbgLevel = AcpiGbl_TraceDbgLevel; + } + if (AcpiGbl_TraceDbgLayer) + { + AcpiDbgLayer = AcpiGbl_TraceDbgLayer; + } + + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsStopTrace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Stop control method execution trace + * + ******************************************************************************/ + +static void +AcpiPsStopTrace ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return; + } + + if ((!AcpiGbl_TraceMethodName) || + (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer)) + { + goto Exit; + } + + /* Disable further tracing if type is one-shot */ + + if (AcpiGbl_TraceFlags & 1) + { + AcpiGbl_TraceMethodName = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; + } + + AcpiDbgLevel = AcpiGbl_OriginalDbgLevel; + AcpiDbgLayer = AcpiGbl_OriginalDbgLayer; + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsExecuteMethod + * + * PARAMETERS: Info - Method info block, contains: + * Node - Method Node to execute + * ObjDesc - Method object + * Parameters - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * PassNumber - Parse or execute pass + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsExecuteMethod ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (PsExecuteMethod); + + + /* Validate the Info and method Node */ + + if (!Info || !Info->ResolvedNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + /* Init for new method, wait on concurrency semaphore */ + + Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The caller "owns" the parameters, so give each one an extra reference + */ + AcpiPsUpdateParameterList (Info, REF_INCREMENT); + + /* Begin tracing if requested */ + + AcpiPsStartTrace (Info); + + /* + * Execute the method. Performs parse simultaneously + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n", + Info->ResolvedNode->Name.Ascii, Info->ResolvedNode, Info->ObjDesc)); + + /* Create and init a Root Node */ + + Op = AcpiPsCreateScopeOp (); + if (!Op) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create and initialize a new walk state */ + + Info->PassNumber = ACPI_IMODE_EXECUTE; + WalkState = AcpiDsCreateWalkState ( + Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->ResolvedNode, + Info->ObjDesc->Method.AmlStart, + Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + if (Info->ObjDesc->Method.Flags & AOPOBJ_MODULE_LEVEL) + { + WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL; + } + + /* Invoke an internal method if necessary */ + + if (Info->ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + { + Status = Info->ObjDesc->Method.Extra.Implementation (WalkState); + Info->ReturnObject = WalkState->ReturnDesc; + + /* Cleanup states */ + + AcpiDsScopeStackClear (WalkState); + AcpiPsCleanupScope (&WalkState->ParserState); + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* + * Start method evaluation with an implicit return of zero. This is done + * for Windows compatibility. + */ + if (AcpiGbl_EnableInterpreterSlack) + { + WalkState->ImplicitReturnObj = + AcpiUtCreateIntegerObject ((UINT64) 0); + if (!WalkState->ImplicitReturnObj) + { + Status = AE_NO_MEMORY; + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + } + + /* Parse the AML */ + + Status = AcpiPsParseAml (WalkState); + + /* WalkState was deleted by ParseAml */ + +Cleanup: + AcpiPsDeleteParseTree (Op); + + /* End optional tracing */ + + AcpiPsStopTrace (Info); + + /* Take away the extra reference that we gave the parameters above */ + + AcpiPsUpdateParameterList (Info, REF_DECREMENT); + + /* Exit now if error above */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * If the method has returned an object, signal this to the caller with + * a control exception code + */ + if (Info->ReturnObject) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n", + Info->ReturnObject)); + ACPI_DUMP_STACK_ENTRY (Info->ReturnObject); + + Status = AE_CTRL_RETURN_VALUE; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsUpdateParameterList + * + * PARAMETERS: Info - See ACPI_EVALUATE_INFO + * (Used: ParameterType and Parameters) + * Action - Add or Remove reference + * + * RETURN: Status + * + * DESCRIPTION: Update reference count on all method parameter objects + * + ******************************************************************************/ + +static void +AcpiPsUpdateParameterList ( + ACPI_EVALUATE_INFO *Info, + UINT16 Action) +{ + UINT32 i; + + + if (Info->Parameters) + { + /* Update reference count for each parameter */ + + for (i = 0; Info->Parameters[i]; i++) + { + /* Ignore errors, just do them all */ + + (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action); + } + } +} + + diff --git a/drivers/bus/acpi/acpica/resources/rsaddr.c b/drivers/bus/acpi/acpica/resources/rsaddr.c new file mode 100644 index 00000000000..f2f3c4421f6 --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rsaddr.c @@ -0,0 +1,479 @@ +/******************************************************************************* + * + * Module Name: rsaddr - Address resource descriptors (16/32/64) + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSADDR_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsaddr") + + +/******************************************************************************* + * + * AcpiRsConvertAddress16 - All WORD (16-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16, + sizeof (AML_RESOURCE_ADDRESS16), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Granularity), + AML_OFFSET (Address16.Granularity), + 5}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS16)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32, + sizeof (AML_RESOURCE_ADDRESS32), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Granularity), + AML_OFFSET (Address32.Granularity), + 5}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS32)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64, + sizeof (AML_RESOURCE_ADDRESS64), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Granularity), + AML_OFFSET (Address64.Granularity), + 5}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS64)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* Revision ID */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID), + AML_OFFSET (ExtAddress64.RevisionID), + 1}, + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + * Type-Specific Attribute + */ + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Granularity), + AML_OFFSET (ExtAddress64.Granularity), + 6} +}; + + +/******************************************************************************* + * + * AcpiRsConvertGeneralFlags - Flags common to all address descriptors + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)}, + + /* Resource Type (Memory, Io, BusNumber, etc.) */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType), + AML_OFFSET (Address.ResourceType), + 1}, + + /* General Flags - Consume, Decode, MinFixed, MaxFixed */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer), + AML_OFFSET (Address.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode), + AML_OFFSET (Address.Flags), + 1}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed), + AML_OFFSET (Address.Flags), + 2}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed), + AML_OFFSET (Address.Flags), + 3} +}; + + +/******************************************************************************* + * + * AcpiRsConvertMemFlags - Flags common to Memory address descriptors + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)}, + + /* Memory-specific flags */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect), + AML_OFFSET (Address.SpecificFlags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching), + AML_OFFSET (Address.SpecificFlags), + 1}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType), + AML_OFFSET (Address.SpecificFlags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation), + AML_OFFSET (Address.SpecificFlags), + 5} +}; + + +/******************************************************************************* + * + * AcpiRsConvertIoFlags - Flags common to I/O address descriptors + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)}, + + /* I/O-specific flags */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType), + AML_OFFSET (Address.SpecificFlags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation), + AML_OFFSET (Address.SpecificFlags), + 4}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType), + AML_OFFSET (Address.SpecificFlags), + 5} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetAddressCommon + * + * PARAMETERS: Resource - Pointer to the internal resource struct + * Aml - Pointer to the AML resource descriptor + * + * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise + * + * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor + * to an internal resource descriptor + * + ******************************************************************************/ + +BOOLEAN +AcpiRsGetAddressCommon ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Validate the Resource Type */ + + if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0)) + { + return (FALSE); + } + + /* Get the Resource Type and General Flags */ + + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags); + + /* Get the Type-Specific Flags (Memory and I/O descriptors only) */ + + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) + { + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags); + } + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) + { + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags); + } + else + { + /* Generic resource type, just grab the TypeSpecific byte */ + + Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags; + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetAddressCommon + * + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * Resource - Pointer to the internal resource struct + * + * RETURN: None + * + * DESCRIPTION: Convert common flag fields from a resource descriptor to an + * AML descriptor + * + ******************************************************************************/ + +void +AcpiRsSetAddressCommon ( + AML_RESOURCE *Aml, + ACPI_RESOURCE *Resource) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Set the Resource Type and General Flags */ + + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags); + + /* Set the Type-Specific Flags (Memory and I/O descriptors only) */ + + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) + { + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags); + } + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) + { + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags); + } + else + { + /* Generic resource type, just copy the TypeSpecific byte */ + + Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific; + } +} + + diff --git a/drivers/bus/acpi/acpica/resources/rscalc.c b/drivers/bus/acpi/acpica/resources/rscalc.c new file mode 100644 index 00000000000..76aa44ff839 --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rscalc.c @@ -0,0 +1,745 @@ +/******************************************************************************* + * + * Module Name: rscalc - Calculate stream and list lengths + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSCALC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rscalc") + + +/* Local prototypes */ + +static UINT8 +AcpiRsCountSetBits ( + UINT16 BitField); + +static ACPI_RS_LENGTH +AcpiRsStructOptionLength ( + ACPI_RESOURCE_SOURCE *ResourceSource); + +static UINT32 +AcpiRsStreamOptionLength ( + UINT32 ResourceLength, + UINT32 MinimumTotalLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCountSetBits + * + * PARAMETERS: BitField - Field in which to count bits + * + * RETURN: Number of bits set within the field + * + * DESCRIPTION: Count the number of bits set in a resource field. Used for + * (Short descriptor) interrupt and DMA lists. + * + ******************************************************************************/ + +static UINT8 +AcpiRsCountSetBits ( + UINT16 BitField) +{ + UINT8 BitsSet; + + + ACPI_FUNCTION_ENTRY (); + + + for (BitsSet = 0; BitField; BitsSet++) + { + /* Zero the least significant bit that is set */ + + BitField &= (UINT16) (BitField - 1); + } + + return (BitsSet); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStructOptionLength + * + * PARAMETERS: ResourceSource - Pointer to optional descriptor field + * + * RETURN: Status + * + * DESCRIPTION: Common code to handle optional ResourceSourceIndex and + * ResourceSource fields in some Large descriptors. Used during + * list-to-stream conversion + * + ******************************************************************************/ + +static ACPI_RS_LENGTH +AcpiRsStructOptionLength ( + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * If the ResourceSource string is valid, return the size of the string + * (StringLength includes the NULL terminator) plus the size of the + * ResourceSourceIndex (1). + */ + if (ResourceSource->StringPtr) + { + return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1)); + } + + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStreamOptionLength + * + * PARAMETERS: ResourceLength - Length from the resource header + * MinimumTotalLength - Minimum length of this resource, before + * any optional fields. Includes header size + * + * RETURN: Length of optional string (0 if no string present) + * + * DESCRIPTION: Common code to handle optional ResourceSourceIndex and + * ResourceSource fields in some Large descriptors. Used during + * stream-to-list conversion + * + ******************************************************************************/ + +static UINT32 +AcpiRsStreamOptionLength ( + UINT32 ResourceLength, + UINT32 MinimumAmlResourceLength) +{ + UINT32 StringLength = 0; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * The ResourceSourceIndex and ResourceSource are optional elements of some + * Large-type resource descriptors. + */ + + /* + * If the length of the actual resource descriptor is greater than the ACPI + * spec-defined minimum length, it means that a ResourceSourceIndex exists + * and is followed by a (required) null terminated string. The string length + * (including the null terminator) is the resource length minus the minimum + * length, minus one byte for the ResourceSourceIndex itself. + */ + if (ResourceLength > MinimumAmlResourceLength) + { + /* Compute the length of the optional string */ + + StringLength = ResourceLength - MinimumAmlResourceLength - 1; + } + + /* + * Round the length up to a multiple of the native word in order to + * guarantee that the entire resource descriptor is native word aligned + */ + return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetAmlLength + * + * PARAMETERS: Resource - Pointer to the resource linked list + * SizeNeeded - Where the required size is returned + * + * RETURN: Status + * + * DESCRIPTION: Takes a linked list of internal resource descriptors and + * calculates the size buffer needed to hold the corresponding + * external resource byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetAmlLength ( + ACPI_RESOURCE *Resource, + ACPI_SIZE *SizeNeeded) +{ + ACPI_SIZE AmlSizeNeeded = 0; + ACPI_RS_LENGTH TotalSize; + + + ACPI_FUNCTION_TRACE (RsGetAmlLength); + + + /* Traverse entire list of internal resource descriptors */ + + while (Resource) + { + /* Validate the descriptor type */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* Get the base size of the (external stream) resource descriptor */ + + TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type]; + + /* + * Augment the base size for descriptors with optional and/or + * variable-length fields + */ + switch (Resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + + /* Length can be 3 or 2 */ + + if (Resource->Data.Irq.DescriptorLength == 2) + { + TotalSize--; + } + break; + + + case ACPI_RESOURCE_TYPE_START_DEPENDENT: + + /* Length can be 1 or 0 */ + + if (Resource->Data.Irq.DescriptorLength == 0) + { + TotalSize--; + } + break; + + + case ACPI_RESOURCE_TYPE_VENDOR: + /* + * Vendor Defined Resource: + * For a Vendor Specific resource, if the Length is between 1 and 7 + * it will be created as a Small Resource data type, otherwise it + * is a Large Resource data type. + */ + if (Resource->Data.Vendor.ByteLength > 7) + { + /* Base size of a Large resource descriptor */ + + TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER); + } + + /* Add the size of the vendor-specific data */ + + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + Resource->Data.Vendor.ByteLength); + break; + + + case ACPI_RESOURCE_TYPE_END_TAG: + /* + * End Tag: + * We are done -- return the accumulated total size. + */ + *SizeNeeded = AmlSizeNeeded + TotalSize; + + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); + + + case ACPI_RESOURCE_TYPE_ADDRESS16: + /* + * 16-Bit Address Resource: + * Add the size of the optional ResourceSource info + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address16.ResourceSource)); + break; + + + case ACPI_RESOURCE_TYPE_ADDRESS32: + /* + * 32-Bit Address Resource: + * Add the size of the optional ResourceSource info + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address32.ResourceSource)); + break; + + + case ACPI_RESOURCE_TYPE_ADDRESS64: + /* + * 64-Bit Address Resource: + * Add the size of the optional ResourceSource info + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address64.ResourceSource)); + break; + + + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + /* + * Extended IRQ Resource: + * Add the size of each additional optional interrupt beyond the + * required 1 (4 bytes for each UINT32 interrupt number) + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + + ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) + + + /* Add the size of the optional ResourceSource info */ + + AcpiRsStructOptionLength ( + &Resource->Data.ExtendedIrq.ResourceSource)); + break; + + + default: + break; + } + + /* Update the total */ + + AmlSizeNeeded += TotalSize; + + /* Point to the next object */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + /* Did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetListLength + * + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * AmlBufferLength - Size of AmlBuffer + * SizeNeeded - Where the size needed is returned + * + * RETURN: Status + * + * DESCRIPTION: Takes an external resource byte stream and calculates the size + * buffer needed to hold the corresponding internal resource + * descriptor linked list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetListLength ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, + ACPI_SIZE *SizeNeeded) +{ + ACPI_STATUS Status; + UINT8 *EndAml; + UINT8 *Buffer; + UINT32 BufferSize; + UINT16 Temp16; + UINT16 ResourceLength; + UINT32 ExtraStructBytes; + UINT8 ResourceIndex; + UINT8 MinimumAmlResourceLength; + + + ACPI_FUNCTION_TRACE (RsGetListLength); + + + *SizeNeeded = 0; + EndAml = AmlBuffer + AmlBufferLength; + + /* Walk the list of AML resource descriptors */ + + while (AmlBuffer < EndAml) + { + /* Validate the Resource Type and Resource Length */ + + Status = AcpiUtValidateResource (AmlBuffer, &ResourceIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the resource length and base (minimum) AML size */ + + ResourceLength = AcpiUtGetResourceLength (AmlBuffer); + MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; + + /* + * Augment the size for descriptors with optional + * and/or variable length fields + */ + ExtraStructBytes = 0; + Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer); + + switch (AcpiUtGetResourceType (AmlBuffer)) + { + case ACPI_RESOURCE_NAME_IRQ: + /* + * IRQ Resource: + * Get the number of bits set in the 16-bit IRQ mask + */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + ExtraStructBytes = AcpiRsCountSetBits (Temp16); + break; + + + case ACPI_RESOURCE_NAME_DMA: + /* + * DMA Resource: + * Get the number of bits set in the 8-bit DMA mask + */ + ExtraStructBytes = AcpiRsCountSetBits (*Buffer); + break; + + + case ACPI_RESOURCE_NAME_VENDOR_SMALL: + case ACPI_RESOURCE_NAME_VENDOR_LARGE: + /* + * Vendor Resource: + * Get the number of vendor data bytes + */ + ExtraStructBytes = ResourceLength; + break; + + + case ACPI_RESOURCE_NAME_END_TAG: + /* + * End Tag: + * This is the normal exit, add size of EndTag + */ + *SizeNeeded += ACPI_RS_SIZE_MIN; + return_ACPI_STATUS (AE_OK); + + + case ACPI_RESOURCE_NAME_ADDRESS32: + case ACPI_RESOURCE_NAME_ADDRESS16: + case ACPI_RESOURCE_NAME_ADDRESS64: + /* + * Address Resource: + * Add the size of the optional ResourceSource + */ + ExtraStructBytes = AcpiRsStreamOptionLength ( + ResourceLength, MinimumAmlResourceLength); + break; + + + case ACPI_RESOURCE_NAME_EXTENDED_IRQ: + /* + * Extended IRQ Resource: + * Using the InterruptTableLength, add 4 bytes for each additional + * interrupt. Note: at least one interrupt is required and is + * included in the minimum descriptor size (reason for the -1) + */ + ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32); + + /* Add the size of the optional ResourceSource */ + + ExtraStructBytes += AcpiRsStreamOptionLength ( + ResourceLength - ExtraStructBytes, MinimumAmlResourceLength); + break; + + + default: + break; + } + + /* + * Update the required buffer size for the internal descriptor structs + * + * Important: Round the size up for the appropriate alignment. This + * is a requirement on IA64. + */ + BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] + + ExtraStructBytes; + BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize); + + *SizeNeeded += BufferSize; + + ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, + "Type %.2X, AmlLength %.2X InternalLength %.2X\n", + AcpiUtGetResourceType (AmlBuffer), + AcpiUtGetDescriptorLength (AmlBuffer), BufferSize)); + + /* + * Point to the next resource within the AML stream using the length + * contained in the resource descriptor header + */ + AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer); + } + + /* Did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPciRoutingTableLength + * + * PARAMETERS: PackageObject - Pointer to the package object + * BufferSizeNeeded - UINT32 pointer of the size buffer + * needed to properly return the + * parsed data + * + * RETURN: Status + * + * DESCRIPTION: Given a package representing a PCI routing table, this + * calculates the size of the corresponding linked list of + * descriptions. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_SIZE *BufferSizeNeeded) +{ + UINT32 NumberOfElements; + ACPI_SIZE TempSizeNeeded = 0; + ACPI_OPERAND_OBJECT **TopObjectList; + UINT32 Index; + ACPI_OPERAND_OBJECT *PackageElement; + ACPI_OPERAND_OBJECT **SubObjectList; + BOOLEAN NameFound; + UINT32 TableIndex; + + + ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength); + + + NumberOfElements = PackageObject->Package.Count; + + /* + * Calculate the size of the return buffer. + * The base size is the number of elements * the sizes of the + * structures. Additional space for the strings is added below. + * The minus one is to subtract the size of the UINT8 Source[1] + * member because it is added below. + * + * But each PRT_ENTRY structure has a pointer to a string and + * the size of that string must be found. + */ + TopObjectList = PackageObject->Package.Elements; + + for (Index = 0; Index < NumberOfElements; Index++) + { + /* Dereference the sub-package */ + + PackageElement = *TopObjectList; + + /* We must have a valid Package object */ + + if (!PackageElement || + (PackageElement->Common.Type != ACPI_TYPE_PACKAGE)) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * The SubObjectList will now point to an array of the + * four IRQ elements: Address, Pin, Source and SourceIndex + */ + SubObjectList = PackageElement->Package.Elements; + + /* Scan the IrqTableElements for the Source Name String */ + + NameFound = FALSE; + + for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) + { + if (*SubObjectList && /* Null object allowed */ + + ((ACPI_TYPE_STRING == + (*SubObjectList)->Common.Type) || + + ((ACPI_TYPE_LOCAL_REFERENCE == + (*SubObjectList)->Common.Type) && + + ((*SubObjectList)->Reference.Class == + ACPI_REFCLASS_NAME)))) + { + NameFound = TRUE; + } + else + { + /* Look at the next element */ + + SubObjectList++; + } + } + + TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); + + /* Was a String type found? */ + + if (NameFound) + { + if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING) + { + /* + * The length String.Length field does not include the + * terminating NULL, add 1 + */ + TempSizeNeeded += ((ACPI_SIZE) + (*SubObjectList)->String.Length + 1); + } + else + { + TempSizeNeeded += AcpiNsGetPathnameLength ( + (*SubObjectList)->Reference.Node); + } + } + else + { + /* + * If no name was found, then this is a NULL, which is + * translated as a UINT32 zero. + */ + TempSizeNeeded += sizeof (UINT32); + } + + /* Round up the size since each element must be aligned */ + + TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded); + + /* Point to the next ACPI_OPERAND_OBJECT */ + + TopObjectList++; + } + + /* + * Add an extra element to the end of the list, essentially a + * NULL terminator + */ + *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE); + return_ACPI_STATUS (AE_OK); +} diff --git a/drivers/bus/acpi/acpica/resources/rscreate.c b/drivers/bus/acpi/acpica/resources/rscreate.c new file mode 100644 index 00000000000..e9c840b64e5 --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rscreate.c @@ -0,0 +1,533 @@ +/******************************************************************************* + * + * Module Name: rscreate - Create resource lists/tables + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSCREATE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rscreate") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateResourceList + * + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * OutputBuffer - Pointer to the user's buffer + * + * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code + * If OutputBuffer is not large enough, OutputBufferLength + * indicates how large OutputBuffer should be, else it + * indicates how may UINT8 elements of OutputBuffer are valid. + * + * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method + * execution and parses the stream to create a linked list + * of device resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *AmlBuffer, + ACPI_BUFFER *OutputBuffer) +{ + + ACPI_STATUS Status; + UINT8 *AmlStart; + ACPI_SIZE ListSizeNeeded = 0; + UINT32 AmlBufferLength; + void *Resource; + + + ACPI_FUNCTION_TRACE (RsCreateResourceList); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n", + AmlBuffer)); + + /* Params already validated, so we don't re-validate here */ + + AmlBufferLength = AmlBuffer->Buffer.Length; + AmlStart = AmlBuffer->Buffer.Pointer; + + /* + * Pass the AmlBuffer into a module that can calculate + * the buffer size needed for the linked list + */ + Status = AcpiRsGetListLength (AmlStart, AmlBufferLength, + &ListSizeNeeded); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n", + Status, (UINT32) ListSizeNeeded)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Do the conversion */ + + Resource = OutputBuffer->Pointer; + Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength, + AcpiRsConvertAmlToResources, &Resource); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreatePciRoutingTable + * + * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT + * package + * OutputBuffer - Pointer to the user's buffer + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. + * If the OutputBuffer is too small, the error will be + * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a + * linked list of PCI interrupt descriptions + * + * NOTE: It is the caller's responsibility to ensure that the start of the + * output buffer is aligned properly (if necessary). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_BUFFER *OutputBuffer) +{ + UINT8 *Buffer; + ACPI_OPERAND_OBJECT **TopObjectList; + ACPI_OPERAND_OBJECT **SubObjectList; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_SIZE BufferSizeNeeded = 0; + UINT32 NumberOfElements; + UINT32 Index; + ACPI_PCI_ROUTING_TABLE *UserPrt; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_BUFFER PathBuffer; + + + ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable); + + + /* Params already validated, so we don't re-validate here */ + + /* Get the required buffer length */ + + Status = AcpiRsGetPciRoutingTableLength (PackageObject, + &BufferSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", + (UINT32) BufferSizeNeeded)); + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a + * package that in turn contains an ACPI_INTEGER Address, a UINT8 Pin, + * a Name, and a UINT8 SourceIndex. + */ + TopObjectList = PackageObject->Package.Elements; + NumberOfElements = PackageObject->Package.Count; + Buffer = OutputBuffer->Pointer; + UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); + + for (Index = 0; Index < NumberOfElements; Index++) + { + /* + * Point UserPrt past this current structure + * + * NOTE: On the first iteration, UserPrt->Length will + * be zero because we cleared the return buffer earlier + */ + Buffer += UserPrt->Length; + UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); + + /* + * Fill in the Length field with the information we have at this point. + * The minus four is to subtract the size of the UINT8 Source[4] member + * because it is added below. + */ + UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); + + /* Each element of the top-level package must also be a package */ + + if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X]) Need sub-package, found %s", + Index, AcpiUtGetObjectTypeName (*TopObjectList))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Each sub-package must be of length 4 */ + + if ((*TopObjectList)->Package.Count != 4) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X]) Need package of length 4, found length %d", + Index, (*TopObjectList)->Package.Count)); + return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); + } + + /* + * Dereference the sub-package. + * The SubObjectList will now point to an array of the four IRQ + * elements: [Address, Pin, Source, SourceIndex] + */ + SubObjectList = (*TopObjectList)->Package.Elements; + + /* 1) First subobject: Dereference the PRT.Address */ + + ObjDesc = SubObjectList[0]; + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, "(PRT[%X].Address) Need Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + + UserPrt->Address = ObjDesc->Integer.Value; + + /* 2) Second subobject: Dereference the PRT.Pin */ + + ObjDesc = SubObjectList[1]; + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, "(PRT[%X].Pin) Need Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + + UserPrt->Pin = (UINT32) ObjDesc->Integer.Value; + + /* + * If the BIOS has erroneously reversed the _PRT SourceName (index 2) + * and the SourceIndex (index 3), fix it. _PRT is important enough to + * workaround this BIOS error. This also provides compatibility with + * other ACPI implementations. + */ + ObjDesc = SubObjectList[3]; + if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) + { + SubObjectList[3] = SubObjectList[2]; + SubObjectList[2] = ObjDesc; + + ACPI_WARNING ((AE_INFO, + "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed", + Index)); + } + + /* + * 3) Third subobject: Dereference the PRT.SourceName + * The name may be unresolved (slack mode), so allow a null object + */ + ObjDesc = SubObjectList[2]; + if (ObjDesc) + { + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X].Source) Need name, found Reference Class %X", + Index, ObjDesc->Reference.Class)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + Node = ObjDesc->Reference.Node; + + /* Use *remaining* length of the buffer as max for pathname */ + + PathBuffer.Length = OutputBuffer->Length - + (UINT32) ((UINT8 *) UserPrt->Source - + (UINT8 *) OutputBuffer->Pointer); + PathBuffer.Pointer = UserPrt->Source; + + Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); + + /* +1 to include null terminator */ + + UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; + break; + + + case ACPI_TYPE_STRING: + + ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); + + /* + * Add to the Length field the length of the string + * (add 1 for terminator) + */ + UserPrt->Length += ObjDesc->String.Length + 1; + break; + + + case ACPI_TYPE_INTEGER: + /* + * If this is a number, then the Source Name is NULL, since the + * entire buffer was zeroed out, we can leave this alone. + * + * Add to the Length field the length of the UINT32 NULL + */ + UserPrt->Length += sizeof (UINT32); + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "(PRT[%X].Source) Need Ref/String/Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + } + + /* Now align the current length */ + + UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length); + + /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ + + ObjDesc = SubObjectList[3]; + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X].SourceIndex) Need Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + + UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value; + + /* Point to the next ACPI_OPERAND_OBJECT in the top level package */ + + TopObjectList++; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateAmlResources + * + * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's buffer + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. + * If the OutputBuffer is too small, the error will be + * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the linked list of device resources and + * creates a bytestream to be used as input for the + * _SRS control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateAmlResources ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_BUFFER *OutputBuffer) +{ + ACPI_STATUS Status; + ACPI_SIZE AmlSizeNeeded = 0; + + + ACPI_FUNCTION_TRACE (RsCreateAmlResources); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", + LinkedListBuffer)); + + /* + * Params already validated, so we don't re-validate here + * + * Pass the LinkedListBuffer into a module that calculates + * the buffer size needed for the byte stream. + */ + Status = AcpiRsGetAmlLength (LinkedListBuffer, + &AmlSizeNeeded); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", + (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Do the conversion */ + + Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded, + OutputBuffer->Pointer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + return_ACPI_STATUS (AE_OK); +} + diff --git a/drivers/bus/acpi/acpica/resources/rsdump.c b/drivers/bus/acpi/acpica/resources/rsdump.c new file mode 100644 index 00000000000..62db284c6f3 --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rsdump.c @@ -0,0 +1,872 @@ +/******************************************************************************* + * + * Module Name: rsdump - Functions to display the resource structures. + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSDUMP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsdump") + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Local prototypes */ + +static void +AcpiRsOutString ( + char *Title, + char *Value); + +static void +AcpiRsOutInteger8 ( + char *Title, + UINT8 Value); + +static void +AcpiRsOutInteger16 ( + char *Title, + UINT16 Value); + +static void +AcpiRsOutInteger32 ( + char *Title, + UINT32 Value); + +static void +AcpiRsOutInteger64 ( + char *Title, + UINT64 Value); + +static void +AcpiRsOutTitle ( + char *Title); + +static void +AcpiRsDumpByteList ( + UINT16 Length, + UINT8 *Data); + +static void +AcpiRsDumpDwordList ( + UINT8 Length, + UINT32 *Data); + +static void +AcpiRsDumpShortByteList ( + UINT8 Length, + UINT8 *Data); + +static void +AcpiRsDumpResourceSource ( + ACPI_RESOURCE_SOURCE *ResourceSource); + +static void +AcpiRsDumpAddressCommon ( + ACPI_RESOURCE_DATA *Resource); + +static void +AcpiRsDumpDescriptor ( + void *Resource, + ACPI_RSDUMP_INFO *Table); + + +#define ACPI_RSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f) +#define ACPI_PRT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f) +#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_RSDUMP_INFO)) + + +/******************************************************************************* + * + * Resource Descriptor info tables + * + * Note: The first table entry must be a Title or Literal and must contain + * the table length (number of table entries) + * + ******************************************************************************/ + +ACPI_RSDUMP_INFO AcpiRsDumpIrq[7] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq), "IRQ", NULL}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.DescriptorLength), "Descriptor Length", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering), "Triggering", AcpiGbl_HeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity), "Polarity", AcpiGbl_LlDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable), "Sharing", AcpiGbl_ShrDecode}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.InterruptCount), "Interrupt Count", NULL}, + {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]), "Interrupt List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpDma[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma), "DMA", NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type), "Speed", AcpiGbl_TypDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster), "Mastering", AcpiGbl_BmDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer), "Transfer Type", AcpiGbl_SizDecode}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Dma.ChannelCount), "Channel Count", NULL}, + {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]), "Channel List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[4] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf), "Start-Dependent-Functions",NULL}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (StartDpf.DescriptorLength), "Descriptor Length", NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority), "Compatibility Priority", AcpiGbl_ConfigDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness), "Performance/Robustness", AcpiGbl_ConfigDecode} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[1] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf), "End-Dependent-Functions", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpIo[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo), "I/O", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode), "Address Decoding", AcpiGbl_IoDecode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[3] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo), "Fixed I/O", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedIo.Address), "Address", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (FixedIo.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpVendor[3] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor), "Vendor Specific", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Vendor.ByteLength), "Length", NULL}, + {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]), "Vendor Data", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpEndTag[1] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag), "EndTag", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpMemory24[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24), "24-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpMemory32[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32), "32-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[4] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32), "32-Bit Fixed Memory Range",NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.Address), "Address", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress16[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16), "16-Bit WORD Address Space",NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address16.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress32[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32), "32-Bit DWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address32.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress64[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64), "64-Bit QWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address64.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64), "64-Bit Extended Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.AddressLength), "Address Length", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific), "Type-Specific Attribute", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq), "Extended IRQ", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer), "Type", AcpiGbl_ConsumeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering), "Triggering", AcpiGbl_HeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity), "Polarity", AcpiGbl_LlDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable), "Sharing", AcpiGbl_ShrDecode}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource), NULL, NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount), "Interrupt Count", NULL}, + {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]), "Interrupt List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg), "Generic Register", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.SpaceId), "Space ID", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitWidth), "Bit Width", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitOffset), "Bit Offset", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.AccessSize), "Access Size", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (GenericReg.Address), "Address", NULL} +}; + + +/* + * Tables used for common address descriptor flag fields + */ +static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags), NULL, NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer), "Consumer/Producer", AcpiGbl_ConsumeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode), "Address Decode", AcpiGbl_DecDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed), "Min Relocatability", AcpiGbl_MinDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed), "Max Relocatability", AcpiGbl_MaxDecode} +}; + +static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] = +{ + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags), "Resource Type", (void *) "Memory Range"}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching), "Caching", AcpiGbl_MemDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType), "Range Type", AcpiGbl_MtpDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation), "Translation", AcpiGbl_TtpDecode} +}; + +static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] = +{ + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags), "Resource Type", (void *) "I/O Range"}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType), "Range Type", AcpiGbl_RngDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation), "Translation", AcpiGbl_TtpDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType), "Translation Type", AcpiGbl_TrsDecode} +}; + + +/* + * Table used to dump _PRT contents + */ +static ACPI_RSDUMP_INFO AcpiRsDumpPrt[5] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt), NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_PRT_OFFSET (Address), "Address", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (Pin), "Pin", NULL}, + {ACPI_RSD_STRING, ACPI_PRT_OFFSET (Source[0]), "Source", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (SourceIndex), "Source Index", NULL} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpDescriptor + * + * PARAMETERS: Resource + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +static void +AcpiRsDumpDescriptor ( + void *Resource, + ACPI_RSDUMP_INFO *Table) +{ + UINT8 *Target = NULL; + UINT8 *PreviousTarget; + char *Name; + UINT8 Count; + + + /* First table entry must contain the table length (# of table entries) */ + + Count = Table->Offset; + + while (Count) + { + PreviousTarget = Target; + Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset); + Name = Table->Name; + + switch (Table->Opcode) + { + case ACPI_RSD_TITLE: + /* + * Optional resource title + */ + if (Table->Name) + { + AcpiOsPrintf ("%s Resource\n", Name); + } + break; + + /* Strings */ + + case ACPI_RSD_LITERAL: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer)); + break; + + case ACPI_RSD_STRING: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target)); + break; + + /* Data items, 8/16/32/64 bit */ + + case ACPI_RSD_UINT8: + AcpiRsOutInteger8 (Name, ACPI_GET8 (Target)); + break; + + case ACPI_RSD_UINT16: + AcpiRsOutInteger16 (Name, ACPI_GET16 (Target)); + break; + + case ACPI_RSD_UINT32: + AcpiRsOutInteger32 (Name, ACPI_GET32 (Target)); + break; + + case ACPI_RSD_UINT64: + AcpiRsOutInteger64 (Name, ACPI_GET64 (Target)); + break; + + /* Flags: 1-bit and 2-bit flags supported */ + + case ACPI_RSD_1BITFLAG: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, + Table->Pointer [*Target & 0x01])); + break; + + case ACPI_RSD_2BITFLAG: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, + Table->Pointer [*Target & 0x03])); + break; + + case ACPI_RSD_SHORTLIST: + /* + * Short byte list (single line output) for DMA and IRQ resources + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsOutTitle (Name); + AcpiRsDumpShortByteList (*PreviousTarget, Target); + } + break; + + case ACPI_RSD_LONGLIST: + /* + * Long byte list for Vendor resource data + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target); + } + break; + + case ACPI_RSD_DWORDLIST: + /* + * Dword list for Extended Interrupt resources + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsDumpDwordList (*PreviousTarget, + ACPI_CAST_PTR (UINT32, Target)); + } + break; + + case ACPI_RSD_ADDRESS: + /* + * Common flags for all Address resources + */ + AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target)); + break; + + case ACPI_RSD_SOURCE: + /* + * Optional ResourceSource for Address resources + */ + AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target)); + break; + + default: + AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", + Table->Opcode); + return; + } + + Table++; + Count--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpResourceSource + * + * PARAMETERS: ResourceSource - Pointer to a Resource Source struct + * + * RETURN: None + * + * DESCRIPTION: Common routine for dumping the optional ResourceSource and the + * corresponding ResourceSourceIndex. + * + ******************************************************************************/ + +static void +AcpiRsDumpResourceSource ( + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + ACPI_FUNCTION_ENTRY (); + + + if (ResourceSource->Index == 0xFF) + { + return; + } + + AcpiRsOutInteger8 ("Resource Source Index", + ResourceSource->Index); + + AcpiRsOutString ("Resource Source", + ResourceSource->StringPtr ? + ResourceSource->StringPtr : "[Not Specified]"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpAddressCommon + * + * PARAMETERS: Resource - Pointer to an internal resource descriptor + * + * RETURN: None + * + * DESCRIPTION: Dump the fields that are common to all Address resource + * descriptors + * + ******************************************************************************/ + +static void +AcpiRsDumpAddressCommon ( + ACPI_RESOURCE_DATA *Resource) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Decode the type-specific flags */ + + switch (Resource->Address.ResourceType) + { + case ACPI_MEMORY_RANGE: + + AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags); + break; + + case ACPI_IO_RANGE: + + AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags); + break; + + case ACPI_BUS_NUMBER_RANGE: + + AcpiRsOutString ("Resource Type", "Bus Number Range"); + break; + + default: + + AcpiRsOutInteger8 ("Resource Type", + (UINT8) Resource->Address.ResourceType); + break; + } + + /* Decode the general flags */ + + AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpResourceList + * + * PARAMETERS: ResourceList - Pointer to a resource descriptor list + * + * RETURN: None + * + * DESCRIPTION: Dispatches the structure to the correct dump routine. + * + ******************************************************************************/ + +void +AcpiRsDumpResourceList ( + ACPI_RESOURCE *ResourceList) +{ + UINT32 Count = 0; + UINT32 Type; + + + ACPI_FUNCTION_ENTRY (); + + + if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer)) + { + return; + } + + /* Walk list and dump all resource descriptors (END_TAG terminates) */ + + do + { + AcpiOsPrintf ("\n[%02X] ", Count); + Count++; + + /* Validate Type before dispatch */ + + Type = ResourceList->Type; + if (Type > ACPI_RESOURCE_TYPE_MAX) + { + AcpiOsPrintf ( + "Invalid descriptor type (%X) in resource list\n", + ResourceList->Type); + return; + } + + /* Dump the resource descriptor */ + + AcpiRsDumpDescriptor (&ResourceList->Data, + AcpiGbl_DumpResourceDispatch[Type]); + + /* Point to the next resource structure */ + + ResourceList = ACPI_ADD_PTR (ACPI_RESOURCE, ResourceList, + ResourceList->Length); + + /* Exit when END_TAG descriptor is reached */ + + } while (Type != ACPI_RESOURCE_TYPE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpIrqList + * + * PARAMETERS: RouteTable - Pointer to the routing table to dump. + * + * RETURN: None + * + * DESCRIPTION: Print IRQ routing table + * + ******************************************************************************/ + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable) +{ + ACPI_PCI_ROUTING_TABLE *PrtElement; + UINT8 Count; + + + ACPI_FUNCTION_ENTRY (); + + + if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer)) + { + return; + } + + PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable); + + /* Dump all table elements, Exit on zero length element */ + + for (Count = 0; PrtElement->Length; Count++) + { + AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count); + AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt); + + PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE, + PrtElement, PrtElement->Length); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsOut* + * + * PARAMETERS: Title - Name of the resource field + * Value - Value of the resource field + * + * RETURN: None + * + * DESCRIPTION: Miscellaneous helper functions to consistently format the + * output of the resource dump routines + * + ******************************************************************************/ + +static void +AcpiRsOutString ( + char *Title, + char *Value) +{ + AcpiOsPrintf ("%27s : %s", Title, Value); + if (!*Value) + { + AcpiOsPrintf ("[NULL NAMESTRING]"); + } + AcpiOsPrintf ("\n"); +} + +static void +AcpiRsOutInteger8 ( + char *Title, + UINT8 Value) +{ + AcpiOsPrintf ("%27s : %2.2X\n", Title, Value); +} + +static void +AcpiRsOutInteger16 ( + char *Title, + UINT16 Value) +{ + AcpiOsPrintf ("%27s : %4.4X\n", Title, Value); +} + +static void +AcpiRsOutInteger32 ( + char *Title, + UINT32 Value) +{ + AcpiOsPrintf ("%27s : %8.8X\n", Title, Value); +} + +static void +AcpiRsOutInteger64 ( + char *Title, + UINT64 Value) +{ + AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title, + ACPI_FORMAT_UINT64 (Value)); +} + +static void +AcpiRsOutTitle ( + char *Title) +{ + AcpiOsPrintf ("%27s : ", Title); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDump*List + * + * PARAMETERS: Length - Number of elements in the list + * Data - Start of the list + * + * RETURN: None + * + * DESCRIPTION: Miscellaneous functions to dump lists of raw data + * + ******************************************************************************/ + +static void +AcpiRsDumpByteList ( + UINT16 Length, + UINT8 *Data) +{ + UINT8 i; + + + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%25s%2.2X : %2.2X\n", + "Byte", i, Data[i]); + } +} + +static void +AcpiRsDumpShortByteList ( + UINT8 Length, + UINT8 *Data) +{ + UINT8 i; + + + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%X ", Data[i]); + } + AcpiOsPrintf ("\n"); +} + +static void +AcpiRsDumpDwordList ( + UINT8 Length, + UINT32 *Data) +{ + UINT8 i; + + + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%25s%2.2X : %8.8X\n", + "Dword", i, Data[i]); + } +} + +#endif + diff --git a/drivers/bus/acpi/acpica/resources/rsinfo.c b/drivers/bus/acpi/acpica/resources/rsinfo.c new file mode 100644 index 00000000000..abf79943d97 --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rsinfo.c @@ -0,0 +1,290 @@ +/******************************************************************************* + * + * Module Name: rsinfo - Dispatch and Info tables + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSINFO_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsinfo") + +/* + * Resource dispatch and information tables. Any new resource types (either + * Large or Small) must be reflected in each of these tables, so they are here + * in one place. + * + * The tables for Large descriptors are indexed by bits 6:0 of the AML + * descriptor type byte. The tables for Small descriptors are indexed by + * bits 6:3 of the descriptor byte. The tables for internal resource + * descriptors are indexed by the ACPI_RESOURCE_TYPE field. + */ + + +/* Dispatch table for resource-to-AML (Set Resource) conversion functions */ + +ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[] = +{ + AcpiRsSetIrq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */ + AcpiRsConvertDma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */ + AcpiRsSetStartDpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */ + AcpiRsConvertEndDpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */ + AcpiRsConvertIo, /* 0x04, ACPI_RESOURCE_TYPE_IO */ + AcpiRsConvertFixedIo, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */ + AcpiRsSetVendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */ + AcpiRsConvertEndTag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */ + AcpiRsConvertMemory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */ + AcpiRsConvertMemory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */ + AcpiRsConvertFixedMemory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + AcpiRsConvertAddress16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */ + AcpiRsConvertAddress32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */ + AcpiRsConvertAddress64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */ + AcpiRsConvertExtAddress64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + AcpiRsConvertExtIrq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + AcpiRsConvertGenericReg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; + +/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ + +ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[] = +{ + /* Small descriptors */ + + NULL, /* 0x00, Reserved */ + NULL, /* 0x01, Reserved */ + NULL, /* 0x02, Reserved */ + NULL, /* 0x03, Reserved */ + AcpiRsGetIrq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */ + AcpiRsConvertDma, /* 0x05, ACPI_RESOURCE_NAME_DMA */ + AcpiRsGetStartDpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */ + AcpiRsConvertEndDpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ + AcpiRsConvertIo, /* 0x08, ACPI_RESOURCE_NAME_IO */ + AcpiRsConvertFixedIo, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */ + NULL, /* 0x0A, Reserved */ + NULL, /* 0x0B, Reserved */ + NULL, /* 0x0C, Reserved */ + NULL, /* 0x0D, Reserved */ + AcpiRsGetVendorSmall, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ + AcpiRsConvertEndTag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ + + /* Large descriptors */ + + NULL, /* 0x00, Reserved */ + AcpiRsConvertMemory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ + AcpiRsConvertGenericReg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ + NULL, /* 0x03, Reserved */ + AcpiRsGetVendorLarge, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */ + AcpiRsConvertMemory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */ + AcpiRsConvertFixedMemory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */ + AcpiRsConvertAddress32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */ + AcpiRsConvertAddress16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */ + AcpiRsConvertExtIrq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */ + AcpiRsConvertAddress64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */ + AcpiRsConvertExtAddress64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */ +}; + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Dispatch table for resource dump functions */ + +ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[] = +{ + AcpiRsDumpIrq, /* ACPI_RESOURCE_TYPE_IRQ */ + AcpiRsDumpDma, /* ACPI_RESOURCE_TYPE_DMA */ + AcpiRsDumpStartDpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */ + AcpiRsDumpEndDpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */ + AcpiRsDumpIo, /* ACPI_RESOURCE_TYPE_IO */ + AcpiRsDumpFixedIo, /* ACPI_RESOURCE_TYPE_FIXED_IO */ + AcpiRsDumpVendor, /* ACPI_RESOURCE_TYPE_VENDOR */ + AcpiRsDumpEndTag, /* ACPI_RESOURCE_TYPE_END_TAG */ + AcpiRsDumpMemory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */ + AcpiRsDumpMemory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */ + AcpiRsDumpFixedMemory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + AcpiRsDumpAddress16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */ + AcpiRsDumpAddress32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */ + AcpiRsDumpAddress64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */ + AcpiRsDumpExtAddress64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + AcpiRsDumpExtIrq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + AcpiRsDumpGenericReg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; +#endif + + +/* + * Base sizes for external AML resource descriptors, indexed by internal type. + * Includes size of the descriptor header (1 byte for small descriptors, + * 3 bytes for large descriptors) + */ +const UINT8 AcpiGbl_AmlResourceSizes[] = +{ + sizeof (AML_RESOURCE_IRQ), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */ + sizeof (AML_RESOURCE_DMA), /* ACPI_RESOURCE_TYPE_DMA */ + sizeof (AML_RESOURCE_START_DEPENDENT), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */ + sizeof (AML_RESOURCE_END_DEPENDENT), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */ + sizeof (AML_RESOURCE_IO), /* ACPI_RESOURCE_TYPE_IO */ + sizeof (AML_RESOURCE_FIXED_IO), /* ACPI_RESOURCE_TYPE_FIXED_IO */ + sizeof (AML_RESOURCE_VENDOR_SMALL), /* ACPI_RESOURCE_TYPE_VENDOR */ + sizeof (AML_RESOURCE_END_TAG), /* ACPI_RESOURCE_TYPE_END_TAG */ + sizeof (AML_RESOURCE_MEMORY24), /* ACPI_RESOURCE_TYPE_MEMORY24 */ + sizeof (AML_RESOURCE_MEMORY32), /* ACPI_RESOURCE_TYPE_MEMORY32 */ + sizeof (AML_RESOURCE_FIXED_MEMORY32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + sizeof (AML_RESOURCE_ADDRESS16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */ + sizeof (AML_RESOURCE_ADDRESS32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */ + sizeof (AML_RESOURCE_ADDRESS64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */ + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),/*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + sizeof (AML_RESOURCE_EXTENDED_IRQ), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + sizeof (AML_RESOURCE_GENERIC_REGISTER) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; + + +const UINT8 AcpiGbl_ResourceStructSizes[] = +{ + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_IRQ), + ACPI_RS_SIZE (ACPI_RESOURCE_DMA), + ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), + ACPI_RS_SIZE_MIN, + ACPI_RS_SIZE (ACPI_RESOURCE_IO), + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), + 0, + 0, + 0, + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RS_SIZE_MIN, + + /* Large descriptors */ + + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24), + ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32), + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32), + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32), + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16), + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ), + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64), + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64) +}; + diff --git a/drivers/bus/acpi/acpica/resources/rsio.c b/drivers/bus/acpi/acpica/resources/rsio.c new file mode 100644 index 00000000000..fb9213dd72e --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rsio.c @@ -0,0 +1,376 @@ +/******************************************************************************* + * + * Module Name: rsio - IO and DMA resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSIO_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsio") + + +/******************************************************************************* + * + * AcpiRsConvertIo + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertIo[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO, + ACPI_RS_SIZE (ACPI_RESOURCE_IO), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO, + sizeof (AML_RESOURCE_IO), + 0}, + + /* Decode flag */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode), + AML_OFFSET (Io.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Address Alignment + * Length + * Minimum Base Address + * Maximum Base Address + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment), + AML_OFFSET (Io.Alignment), + 2}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum), + AML_OFFSET (Io.Minimum), + 2} +}; + + +/******************************************************************************* + * + * AcpiRsConvertFixedIo + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO, + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO, + sizeof (AML_RESOURCE_FIXED_IO), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Base Address + * Length + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength), + AML_OFFSET (FixedIo.AddressLength), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address), + AML_OFFSET (FixedIo.Address), + 1} +}; + + +/******************************************************************************* + * + * AcpiRsConvertGenericReg + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER, + ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER, + sizeof (AML_RESOURCE_GENERIC_REGISTER), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Address Space ID + * Register Bit Width + * Register Bit Offset + * Access Size + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId), + AML_OFFSET (GenericReg.AddressSpaceId), + 4}, + + /* Get the Register Address */ + + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address), + AML_OFFSET (GenericReg.Address), + 1} +}; + + +/******************************************************************************* + * + * AcpiRsConvertEndDpf + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT, + sizeof (AML_RESOURCE_END_DEPENDENT), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsConvertEndTag + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)}, + + /* + * Note: The checksum field is set to zero, meaning that the resource + * data is treated as if the checksum operation succeeded. + * (ACPI Spec 1.0b Section 6.4.2.8) + */ + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG, + sizeof (AML_RESOURCE_END_TAG), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsGetStartDpf + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[6] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT, + ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), + ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)}, + + /* Defaults for Compatibility and Performance priorities */ + + {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + ACPI_ACCEPTABLE_CONFIGURATION, + 2}, + + /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength), + AML_OFFSET (StartDpf.DescriptorType), + 0}, + + /* All done if there is no flag byte present in the descriptor */ + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1}, + + /* Flag byte is present, get the flags */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + AML_OFFSET (StartDpf.Flags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + AML_OFFSET (StartDpf.Flags), + 2} +}; + + +/******************************************************************************* + * + * AcpiRsSetStartDpf + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[10] = +{ + /* Start with a default descriptor of length 1 */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT, + sizeof (AML_RESOURCE_START_DEPENDENT), + ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)}, + + /* Set the default flag values */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + AML_OFFSET (StartDpf.Flags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + AML_OFFSET (StartDpf.Flags), + 2}, + /* + * All done if the output descriptor length is required to be 1 + * (i.e., optimization to 0 bytes cannot be attempted) + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), + 1}, + + /* Set length to 0 bytes (no flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}, + + /* + * All done if the output descriptor length is required to be 0. + * + * TBD: Perhaps we should check for error if input flags are not + * compatible with a 0-byte descriptor. + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), + 0}, + + /* Reset length to 1 byte (descriptor with flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)}, + + + /* + * All done if flags byte is necessary -- if either priority value + * is not ACPI_ACCEPTABLE_CONFIGURATION + */ + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + ACPI_ACCEPTABLE_CONFIGURATION}, + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + ACPI_ACCEPTABLE_CONFIGURATION}, + + /* Flag byte is not necessary */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)} +}; + + diff --git a/drivers/bus/acpi/acpica/resources/rsirq.c b/drivers/bus/acpi/acpica/resources/rsirq.c new file mode 100644 index 00000000000..7eab4351399 --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rsirq.c @@ -0,0 +1,348 @@ +/******************************************************************************* + * + * Module Name: rsirq - IRQ resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSIRQ_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsirq") + + +/******************************************************************************* + * + * AcpiRsGetIrq + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetIrq[8] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ, + ACPI_RS_SIZE (ACPI_RESOURCE_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsGetIrq)}, + + /* Get the IRQ mask (bytes 1:2) */ + + {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), + AML_OFFSET (Irq.IrqMask), + ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, + + /* Set default flags (others are zero) */ + + {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.Irq.Triggering), + ACPI_EDGE_SENSITIVE, + 1}, + + /* Get the descriptor length (2 or 3 for IRQ descriptor) */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Irq.DescriptorLength), + AML_OFFSET (Irq.DescriptorType), + 0}, + + /* All done if no flag byte present in descriptor */ + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3}, + + /* Get flags: Triggering[0], Polarity[3], Sharing[4] */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), + AML_OFFSET (Irq.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), + AML_OFFSET (Irq.Flags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), + AML_OFFSET (Irq.Flags), + 4} +}; + + +/******************************************************************************* + * + * AcpiRsSetIrq + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsSetIrq[13] = +{ + /* Start with a default descriptor of length 3 */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ, + sizeof (AML_RESOURCE_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsSetIrq)}, + + /* Convert interrupt list to 16-bit IRQ bitmask */ + + {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), + AML_OFFSET (Irq.IrqMask), + ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, + + /* Set the flags byte */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), + AML_OFFSET (Irq.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), + AML_OFFSET (Irq.Flags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), + AML_OFFSET (Irq.Flags), + 4}, + + /* + * All done if the output descriptor length is required to be 3 + * (i.e., optimization to 2 bytes cannot be attempted) + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.Irq.DescriptorLength), + 3}, + + /* Set length to 2 bytes (no flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)}, + + /* + * All done if the output descriptor length is required to be 2. + * + * TBD: Perhaps we should check for error if input flags are not + * compatible with a 2-byte descriptor. + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.Irq.DescriptorLength), + 2}, + + /* Reset length to 3 bytes (descriptor with flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ)}, + + /* + * Check if the flags byte is necessary. Not needed if the flags are: + * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE + */ + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Triggering), + ACPI_EDGE_SENSITIVE}, + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Polarity), + ACPI_ACTIVE_HIGH}, + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Sharable), + ACPI_EXCLUSIVE}, + + /* We can optimize to a 2-byte IrqNoFlags() descriptor */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertExtIrq + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[9] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ, + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtIrq)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ, + sizeof (AML_RESOURCE_EXTENDED_IRQ), + 0}, + + /* Flag bits */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.ProducerConsumer), + AML_OFFSET (ExtendedIrq.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Triggering), + AML_OFFSET (ExtendedIrq.Flags), + 1}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Polarity), + AML_OFFSET (ExtendedIrq.Flags), + 2}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Sharable), + AML_OFFSET (ExtendedIrq.Flags), + 3}, + + /* IRQ Table length (Byte4) */ + + {ACPI_RSC_COUNT, ACPI_RS_OFFSET (Data.ExtendedIrq.InterruptCount), + AML_OFFSET (ExtendedIrq.InterruptCount), + sizeof (UINT32)}, + + /* Copy every IRQ in the table, each is 32 bits */ + + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), + AML_OFFSET (ExtendedIrq.Interrupts[0]), + 0}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET (Data.ExtendedIrq.ResourceSource), + ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), + sizeof (AML_RESOURCE_EXTENDED_IRQ)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertDma + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertDma[6] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA, + ACPI_RS_SIZE (ACPI_RESOURCE_DMA), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertDma)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA, + sizeof (AML_RESOURCE_DMA), + 0}, + + /* Flags: transfer preference, bus mastering, channel speed */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Transfer), + AML_OFFSET (Dma.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Dma.BusMaster), + AML_OFFSET (Dma.Flags), + 2}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Type), + AML_OFFSET (Dma.Flags), + 5}, + + /* DMA channel mask bits */ + + {ACPI_RSC_BITMASK, ACPI_RS_OFFSET (Data.Dma.Channels[0]), + AML_OFFSET (Dma.DmaChannelMask), + ACPI_RS_OFFSET (Data.Dma.ChannelCount)} +}; + diff --git a/drivers/bus/acpi/acpica/resources/rslist.c b/drivers/bus/acpi/acpica/resources/rslist.c new file mode 100644 index 00000000000..3adce2b3939 --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rslist.c @@ -0,0 +1,286 @@ +/******************************************************************************* + * + * Module Name: rslist - Linked list utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSLIST_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rslist") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertAmlToResources + * + * PARAMETERS: ACPI_WALK_AML_CALLBACK + * ResourcePtr - Pointer to the buffer that will + * contain the output structures + * + * RETURN: Status + * + * DESCRIPTION: Convert an AML resource to an internal representation of the + * resource that is aligned and easier to access. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertAmlToResources ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context) +{ + ACPI_RESOURCE **ResourcePtr = ACPI_CAST_INDIRECT_PTR ( + ACPI_RESOURCE, Context); + ACPI_RESOURCE *Resource; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsConvertAmlToResources); + + + /* + * Check that the input buffer and all subsequent pointers into it + * are aligned on a native word boundary. Most important on IA64 + */ + Resource = *ResourcePtr; + if (ACPI_IS_MISALIGNED (Resource)) + { + ACPI_WARNING ((AE_INFO, + "Misaligned resource pointer %p", Resource)); + } + + /* Convert the AML byte stream resource to a local resource struct */ + + Status = AcpiRsConvertAmlToResource ( + Resource, ACPI_CAST_PTR (AML_RESOURCE, Aml), + AcpiGbl_GetResourceDispatch[ResourceIndex]); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not convert AML resource (Type %X)", *Aml)); + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, + "Type %.2X, AmlLength %.2X InternalLength %.2X\n", + AcpiUtGetResourceType (Aml), Length, + Resource->Length)); + + /* Point to the next structure in the output buffer */ + + *ResourcePtr = ACPI_ADD_PTR (void, Resource, Resource->Length); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertResourcesToAml + * + * PARAMETERS: Resource - Pointer to the resource linked list + * AmlSizeNeeded - Calculated size of the byte stream + * needed from calling AcpiRsGetAmlLength() + * The size of the OutputBuffer is + * guaranteed to be >= AmlSizeNeeded + * OutputBuffer - Pointer to the buffer that will + * contain the byte stream + * + * RETURN: Status + * + * DESCRIPTION: Takes the resource linked list and parses it, creating a + * byte stream of resources in the caller's output buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertResourcesToAml ( + ACPI_RESOURCE *Resource, + ACPI_SIZE AmlSizeNeeded, + UINT8 *OutputBuffer) +{ + UINT8 *Aml = OutputBuffer; + UINT8 *EndAml = OutputBuffer + AmlSizeNeeded; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsConvertResourcesToAml); + + + /* Walk the resource descriptor list, convert each descriptor */ + + while (Aml < EndAml) + { + /* Validate the (internal) Resource Type */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + ACPI_ERROR ((AE_INFO, + "Invalid descriptor type (%X) in resource list", + Resource->Type)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* Perform the conversion */ + + Status = AcpiRsConvertResourceToAml (Resource, + ACPI_CAST_PTR (AML_RESOURCE, Aml), + AcpiGbl_SetResourceDispatch[Resource->Type]); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not convert resource (type %X) to AML", + Resource->Type)); + return_ACPI_STATUS (Status); + } + + /* Perform final sanity check on the new AML resource descriptor */ + + Status = AcpiUtValidateResource ( + ACPI_CAST_PTR (AML_RESOURCE, Aml), NULL); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Check for end-of-list, normal exit */ + + if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) + { + /* An End Tag indicates the end of the input Resource Template */ + + return_ACPI_STATUS (AE_OK); + } + + /* + * Extract the total length of the new descriptor and set the + * Aml to point to the next (output) resource descriptor + */ + Aml += AcpiUtGetDescriptorLength (Aml); + + /* Point to the next input resource descriptor */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + /* Completed buffer, but did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); +} + diff --git a/drivers/bus/acpi/acpica/resources/rsmemory.c b/drivers/bus/acpi/acpica/resources/rsmemory.c new file mode 100644 index 00000000000..a3d08c01a1b --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rsmemory.c @@ -0,0 +1,323 @@ +/******************************************************************************* + * + * Module Name: rsmem24 - Memory resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSMEMORY_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsmemory") + + +/******************************************************************************* + * + * AcpiRsConvertMemory24 + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory24)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24, + sizeof (AML_RESOURCE_MEMORY24), + 0}, + + /* Read/Write bit */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory24.WriteProtect), + AML_OFFSET (Memory24.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length + */ + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Memory24.Minimum), + AML_OFFSET (Memory24.Minimum), + 4} +}; + + +/******************************************************************************* + * + * AcpiRsConvertMemory32 + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory32)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32, + sizeof (AML_RESOURCE_MEMORY32), + 0}, + + /* Read/Write bit */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory32.WriteProtect), + AML_OFFSET (Memory32.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length + */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Memory32.Minimum), + AML_OFFSET (Memory32.Minimum), + 4} +}; + + +/******************************************************************************* + * + * AcpiRsConvertFixedMemory32 + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32, + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedMemory32)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32, + sizeof (AML_RESOURCE_FIXED_MEMORY32), + 0}, + + /* Read/Write bit */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.FixedMemory32.WriteProtect), + AML_OFFSET (FixedMemory32.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Base Address + * Range Length + */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.FixedMemory32.Address), + AML_OFFSET (FixedMemory32.Address), + 2} +}; + + +/******************************************************************************* + * + * AcpiRsGetVendorSmall + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[3] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorSmall)}, + + /* Length of the vendor data (byte count) */ + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + sizeof (UINT8)}, + + /* Vendor data */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_SMALL_HEADER), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsGetVendorLarge + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[3] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorLarge)}, + + /* Length of the vendor data (byte count) */ + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + sizeof (UINT8)}, + + /* Vendor data */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_LARGE_HEADER), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsSetVendor + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsSetVendor[7] = +{ + /* Default is a small vendor descriptor */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL, + sizeof (AML_RESOURCE_SMALL_HEADER), + ACPI_RSC_TABLE_SIZE (AcpiRsSetVendor)}, + + /* Get the length and copy the data */ + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_SMALL_HEADER), + 0}, + + /* + * All done if the Vendor byte length is 7 or less, meaning that it will + * fit within a small descriptor + */ + {ACPI_RSC_EXIT_LE, 0, 0, 7}, + + /* Must create a large vendor descriptor */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE, + sizeof (AML_RESOURCE_LARGE_HEADER), + 0}, + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_LARGE_HEADER), + 0} +}; + + diff --git a/drivers/bus/acpi/acpica/resources/rsmisc.c b/drivers/bus/acpi/acpica/resources/rsmisc.c new file mode 100644 index 00000000000..3565334e732 --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rsmisc.c @@ -0,0 +1,683 @@ +/******************************************************************************* + * + * Module Name: rsmisc - Miscellaneous resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSMISC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsmisc") + + +#define INIT_RESOURCE_TYPE(i) i->ResourceOffset +#define INIT_RESOURCE_LENGTH(i) i->AmlOffset +#define INIT_TABLE_LENGTH(i) i->Value + +#define COMPARE_OPCODE(i) i->ResourceOffset +#define COMPARE_TARGET(i) i->AmlOffset +#define COMPARE_VALUE(i) i->Value + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertAmlToResource + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table + * + * RETURN: Status + * + * DESCRIPTION: Convert an external AML resource descriptor to the corresponding + * internal resource descriptor + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertAmlToResource ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info) +{ + ACPI_RS_LENGTH AmlResourceLength; + void *Source; + void *Destination; + char *Target; + UINT8 Count; + UINT8 FlagsMode = FALSE; + UINT16 ItemCount = 0; + UINT16 Temp16 = 0; + + + ACPI_FUNCTION_TRACE (RsConvertAmlToResource); + + + if (((ACPI_SIZE) Resource) & 0x3) + { + /* Each internal resource struct is expected to be 32-bit aligned */ + + ACPI_WARNING ((AE_INFO, + "Misaligned resource pointer (get): %p Type %2.2X Len %X", + Resource, Resource->Type, Resource->Length)); + } + + /* Extract the resource Length field (does not include header length) */ + + AmlResourceLength = AcpiUtGetResourceLength (Aml); + + /* + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) + */ + Count = INIT_TABLE_LENGTH (Info); + + while (Count) + { + /* + * Source is the external AML byte stream buffer, + * destination is the internal resource descriptor + */ + Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); + Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); + + switch (Info->Opcode) + { + case ACPI_RSC_INITGET: + /* + * Get the resource type and the initial (minimum) length + */ + ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info)); + Resource->Type = INIT_RESOURCE_TYPE (Info); + Resource->Length = INIT_RESOURCE_LENGTH (Info); + break; + + + case ACPI_RSC_INITSET: + break; + + + case ACPI_RSC_FLAGINIT: + + FlagsMode = TRUE; + break; + + + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + ACPI_SET8 (Destination) = (UINT8) + ((ACPI_GET8 (Source) >> Info->Value) & 0x01); + break; + + + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + ACPI_SET8 (Destination) = (UINT8) + ((ACPI_GET8 (Source) >> Info->Value) & 0x03); + break; + + + case ACPI_RSC_COUNT: + + ItemCount = ACPI_GET8 (Source); + ACPI_SET8 (Destination) = (UINT8) ItemCount; + + Resource->Length = Resource->Length + + (Info->Value * (ItemCount - 1)); + break; + + + case ACPI_RSC_COUNT16: + + ItemCount = AmlResourceLength; + ACPI_SET16 (Destination) = ItemCount; + + Resource->Length = Resource->Length + + (Info->Value * (ItemCount - 1)); + break; + + + case ACPI_RSC_LENGTH: + + Resource->Length = Resource->Length + Info->Value; + break; + + + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: + /* + * Raw data move. Use the Info value field unless ItemCount has + * been previously initialized via a COUNT opcode + */ + if (Info->Value) + { + ItemCount = Info->Value; + } + AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); + break; + + + case ACPI_RSC_SET8: + + ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value); + break; + + + case ACPI_RSC_DATA8: + + Target = ACPI_ADD_PTR (char, Resource, Info->Value); + ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target)); + break; + + + case ACPI_RSC_ADDRESS: + /* + * Common handler for address descriptor flags + */ + if (!AcpiRsGetAddressCommon (Resource, Aml)) + { + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + } + break; + + + case ACPI_RSC_SOURCE: + /* + * Optional ResourceSource (Index and String) + */ + Resource->Length += + AcpiRsGetResourceSource (AmlResourceLength, Info->Value, + Destination, Aml, NULL); + break; + + + case ACPI_RSC_SOURCEX: + /* + * Optional ResourceSource (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + Target = ACPI_ADD_PTR (char, Resource, Info->AmlOffset + (ItemCount * 4)); + + Resource->Length += + AcpiRsGetResourceSource (AmlResourceLength, + (ACPI_RS_LENGTH) (((ItemCount - 1) * sizeof (UINT32)) + Info->Value), + Destination, Aml, Target); + break; + + + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination); + if (ItemCount) + { + Resource->Length += (ItemCount - 1); + } + + Target = ACPI_ADD_PTR (char, Resource, Info->Value); + ACPI_SET8 (Target) = (UINT8) ItemCount; + break; + + + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + ACPI_MOVE_16_TO_16 (&Temp16, Source); + + ItemCount = AcpiRsDecodeBitmask (Temp16, Destination); + if (ItemCount) + { + Resource->Length += (ItemCount - 1); + } + + Target = ACPI_ADD_PTR (char, Resource, Info->Value); + ACPI_SET8 (Target) = (UINT8) ItemCount; + break; + + + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (Info->ResourceOffset) + { + case ACPI_RSC_COMPARE_AML_LENGTH: + if (AmlResourceLength != Info->Value) + { + goto Exit; + } + break; + + case ACPI_RSC_COMPARE_VALUE: + if (ACPI_GET8 (Source) != Info->Value) + { + goto Exit; + } + break; + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Count--; + Info++; + } + +Exit: + if (!FlagsMode) + { + /* Round the resource struct length up to the next boundary (32 or 64) */ + + Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length); + } + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertResourceToAml + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table + * + * RETURN: Status + * + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertResourceToAml ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info) +{ + void *Source = NULL; + void *Destination; + ACPI_RSDESC_SIZE AmlLength = 0; + UINT8 Count; + UINT16 Temp16 = 0; + UINT16 ItemCount = 0; + + + ACPI_FUNCTION_TRACE (RsConvertResourceToAml); + + + /* + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) + */ + Count = INIT_TABLE_LENGTH (Info); + + while (Count) + { + /* + * Source is the internal resource descriptor, + * destination is the external AML byte stream buffer + */ + Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); + Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); + + switch (Info->Opcode) + { + case ACPI_RSC_INITSET: + + ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info)); + AmlLength = INIT_RESOURCE_LENGTH (Info); + AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml); + break; + + + case ACPI_RSC_INITGET: + break; + + + case ACPI_RSC_FLAGINIT: + /* + * Clear the flag byte + */ + ACPI_SET8 (Destination) = 0; + break; + + + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + ACPI_SET8 (Destination) |= (UINT8) + ((ACPI_GET8 (Source) & 0x01) << Info->Value); + break; + + + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + ACPI_SET8 (Destination) |= (UINT8) + ((ACPI_GET8 (Source) & 0x03) << Info->Value); + break; + + + case ACPI_RSC_COUNT: + + ItemCount = ACPI_GET8 (Source); + ACPI_SET8 (Destination) = (UINT8) ItemCount; + + AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1))); + break; + + + case ACPI_RSC_COUNT16: + + ItemCount = ACPI_GET16 (Source); + AmlLength = (UINT16) (AmlLength + ItemCount); + AcpiRsSetResourceLength (AmlLength, Aml); + break; + + + case ACPI_RSC_LENGTH: + + AcpiRsSetResourceLength (Info->Value, Aml); + break; + + + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: + + if (Info->Value) + { + ItemCount = Info->Value; + } + AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); + break; + + + case ACPI_RSC_ADDRESS: + + /* Set the Resource Type, General Flags, and Type-Specific Flags */ + + AcpiRsSetAddressCommon (Aml, Resource); + break; + + + case ACPI_RSC_SOURCEX: + /* + * Optional ResourceSource (Index and String) + */ + AmlLength = AcpiRsSetResourceSource ( + Aml, (ACPI_RS_LENGTH) AmlLength, Source); + AcpiRsSetResourceLength (AmlLength, Aml); + break; + + + case ACPI_RSC_SOURCE: + /* + * Optional ResourceSource (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source); + AcpiRsSetResourceLength (AmlLength, Aml); + break; + + + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + ACPI_SET8 (Destination) = (UINT8) + AcpiRsEncodeBitmask (Source, + *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); + break; + + + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + Temp16 = AcpiRsEncodeBitmask (Source, + *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); + ACPI_MOVE_16_TO_16 (Destination, &Temp16); + break; + + + case ACPI_RSC_EXIT_LE: + /* + * Control - Exit conversion if less than or equal + */ + if (ItemCount <= Info->Value) + { + goto Exit; + } + break; + + + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (COMPARE_OPCODE (Info)) + { + case ACPI_RSC_COMPARE_VALUE: + + if (*ACPI_ADD_PTR (UINT8, Resource, + COMPARE_TARGET (Info)) != COMPARE_VALUE (Info)) + { + goto Exit; + } + break; + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + break; + + + case ACPI_RSC_EXIT_EQ: + /* + * Control - Exit conversion if equal + */ + if (*ACPI_ADD_PTR (UINT8, Resource, + COMPARE_TARGET (Info)) == COMPARE_VALUE (Info)) + { + goto Exit; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Count--; + Info++; + } + +Exit: + return_ACPI_STATUS (AE_OK); +} + + +#if 0 +/* Previous resource validations */ + + if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) + { + return_ACPI_STATUS (AE_SUPPORT); + } + + if (Resource->Data.StartDpf.PerformanceRobustness >= 3) + { + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); + } + + if (((Aml->Irq.Flags & 0x09) == 0x00) || + ((Aml->Irq.Flags & 0x09) == 0x09)) + { + /* + * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive] + * polarity/trigger interrupts are allowed (ACPI spec, section + * "IRQ Format"), so 0x00 and 0x09 are illegal. + */ + ACPI_ERROR ((AE_INFO, + "Invalid interrupt polarity/trigger in resource list, %X", + Aml->Irq.Flags)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + Resource->Data.ExtendedIrq.InterruptCount = Temp8; + if (Temp8 < 1) + { + /* Must have at least one IRQ */ + + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + } + + if (Resource->Data.Dma.Transfer == 0x03) + { + ACPI_ERROR ((AE_INFO, + "Invalid DMA.Transfer preference (3)")); + return_ACPI_STATUS (AE_BAD_DATA); + } +#endif + + diff --git a/drivers/bus/acpi/acpica/resources/rsutils.c b/drivers/bus/acpi/acpica/resources/rsutils.c new file mode 100644 index 00000000000..4e0f04ce8e5 --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rsutils.c @@ -0,0 +1,874 @@ +/******************************************************************************* + * + * Module Name: rsutils - Utilities for the resource manager + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acresrc.h" + + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDecodeBitmask + * + * PARAMETERS: Mask - Bitmask to decode + * List - Where the converted list is returned + * + * RETURN: Count of bits set (length of list) + * + * DESCRIPTION: Convert a bit mask into a list of values + * + ******************************************************************************/ + +UINT8 +AcpiRsDecodeBitmask ( + UINT16 Mask, + UINT8 *List) +{ + UINT8 i; + UINT8 BitCount; + + + ACPI_FUNCTION_ENTRY (); + + + /* Decode the mask bits */ + + for (i = 0, BitCount = 0; Mask; i++) + { + if (Mask & 0x0001) + { + List[BitCount] = i; + BitCount++; + } + + Mask >>= 1; + } + + return (BitCount); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEncodeBitmask + * + * PARAMETERS: List - List of values to encode + * Count - Length of list + * + * RETURN: Encoded bitmask + * + * DESCRIPTION: Convert a list of values to an encoded bitmask + * + ******************************************************************************/ + +UINT16 +AcpiRsEncodeBitmask ( + UINT8 *List, + UINT8 Count) +{ + UINT32 i; + UINT16 Mask; + + + ACPI_FUNCTION_ENTRY (); + + + /* Encode the list into a single bitmask */ + + for (i = 0, Mask = 0; i < Count; i++) + { + Mask |= (0x1 << List[i]); + } + + return (Mask); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMoveData + * + * PARAMETERS: Destination - Pointer to the destination descriptor + * Source - Pointer to the source descriptor + * ItemCount - How many items to move + * MoveType - Byte width + * + * RETURN: None + * + * DESCRIPTION: Move multiple data items from one descriptor to another. Handles + * alignment issues and endian issues if necessary, as configured + * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) + * + ******************************************************************************/ + +void +AcpiRsMoveData ( + void *Destination, + void *Source, + UINT16 ItemCount, + UINT8 MoveType) +{ + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + /* One move per item */ + + for (i = 0; i < ItemCount; i++) + { + switch (MoveType) + { + /* + * For the 8-bit case, we can perform the move all at once + * since there are no alignment or endian issues + */ + case ACPI_RSC_MOVE8: + ACPI_MEMCPY (Destination, Source, ItemCount); + return; + + /* + * 16-, 32-, and 64-bit cases must use the move macros that perform + * endian conversion and/or accomodate hardware that cannot perform + * misaligned memory transfers + */ + case ACPI_RSC_MOVE16: + ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], + &ACPI_CAST_PTR (UINT16, Source)[i]); + break; + + case ACPI_RSC_MOVE32: + ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], + &ACPI_CAST_PTR (UINT32, Source)[i]); + break; + + case ACPI_RSC_MOVE64: + ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i], + &ACPI_CAST_PTR (UINT64, Source)[i]); + break; + + default: + return; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceLength + * + * PARAMETERS: TotalLength - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Set the ResourceLength field of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically. Note: Descriptor Type field must + * be valid. + * + ******************************************************************************/ + +void +AcpiRsSetResourceLength ( + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml) +{ + ACPI_RS_LENGTH ResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* Length is the total descriptor length minus the header length */ + + ResourceLength = (ACPI_RS_LENGTH) + (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); + + /* Length is stored differently for large and small descriptors */ + + if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) + { + /* Large descriptor -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength); + } + else + { + /* Small descriptor -- bits 2:0 of byte 0 contain the length */ + + Aml->SmallHeader.DescriptorType = (UINT8) + + /* Clear any existing length, preserving descriptor type bits */ + + ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) + + | ResourceLength); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceHeader + * + * PARAMETERS: DescriptorType - Byte to be inserted as the type + * TotalLength - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically + * + ******************************************************************************/ + +void +AcpiRsSetResourceHeader ( + UINT8 DescriptorType, + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Set the Resource Type */ + + Aml->SmallHeader.DescriptorType = DescriptorType; + + /* Set the Resource Length */ + + AcpiRsSetResourceLength (TotalLength, Aml); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStrcpy + * + * PARAMETERS: Destination - Pointer to the destination string + * Source - Pointer to the source string + * + * RETURN: String length, including NULL terminator + * + * DESCRIPTION: Local string copy that returns the string length, saving a + * strcpy followed by a strlen. + * + ******************************************************************************/ + +static UINT16 +AcpiRsStrcpy ( + char *Destination, + char *Source) +{ + UINT16 i; + + + ACPI_FUNCTION_ENTRY (); + + + for (i = 0; Source[i]; i++) + { + Destination[i] = Source[i]; + } + + Destination[i] = 0; + + /* Return string length including the NULL terminator */ + + return ((UINT16) (i + 1)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetResourceSource + * + * PARAMETERS: ResourceLength - Length field of the descriptor + * MinimumLength - Minimum length of the descriptor (minus + * any optional fields) + * ResourceSource - Where the ResourceSource is returned + * Aml - Pointer to the raw AML descriptor + * StringPtr - (optional) where to store the actual + * ResourceSource string + * + * RETURN: Length of the string plus NULL terminator, rounded up to native + * word boundary + * + * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor + * to an internal resource descriptor + * + ******************************************************************************/ + +ACPI_RS_LENGTH +AcpiRsGetResourceSource ( + ACPI_RS_LENGTH ResourceLength, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource, + AML_RESOURCE *Aml, + char *StringPtr) +{ + ACPI_RSDESC_SIZE TotalLength; + UINT8 *AmlResourceSource; + + + ACPI_FUNCTION_ENTRY (); + + + TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); + AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); + + /* + * ResourceSource is present if the length of the descriptor is longer than + * the minimum length. + * + * Note: Some resource descriptors will have an additional null, so + * we add 1 to the minimum length. + */ + if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) + { + /* Get the ResourceSourceIndex */ + + ResourceSource->Index = AmlResourceSource[0]; + + ResourceSource->StringPtr = StringPtr; + if (!StringPtr) + { + /* + * String destination pointer is not specified; Set the String + * pointer to the end of the current ResourceSource structure. + */ + ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource, + sizeof (ACPI_RESOURCE_SOURCE)); + } + + /* + * In order for the Resource length to be a multiple of the native + * word, calculate the length of the string (+1 for NULL terminator) + * and expand to the next word multiple. + * + * Zero the entire area of the buffer. + */ + TotalLength = (UINT32) ACPI_STRLEN ( + ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; + TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); + + ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); + + /* Copy the ResourceSource string to the destination */ + + ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, + ACPI_CAST_PTR (char, &AmlResourceSource[1])); + + return ((ACPI_RS_LENGTH) TotalLength); + } + + /* ResourceSource is not present */ + + ResourceSource->Index = 0; + ResourceSource->StringLength = 0; + ResourceSource->StringPtr = NULL; + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceSource + * + * PARAMETERS: Aml - Pointer to the raw AML descriptor + * MinimumLength - Minimum length of the descriptor (minus + * any optional fields) + * ResourceSource - Internal ResourceSource + + * + * RETURN: Total length of the AML descriptor + * + * DESCRIPTION: Convert an optional ResourceSource from internal format to a + * raw AML resource descriptor + * + ******************************************************************************/ + +ACPI_RSDESC_SIZE +AcpiRsSetResourceSource ( + AML_RESOURCE *Aml, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + UINT8 *AmlResourceSource; + ACPI_RSDESC_SIZE DescriptorLength; + + + ACPI_FUNCTION_ENTRY (); + + + DescriptorLength = MinimumLength; + + /* Non-zero string length indicates presence of a ResourceSource */ + + if (ResourceSource->StringLength) + { + /* Point to the end of the AML descriptor */ + + AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); + + /* Copy the ResourceSourceIndex */ + + AmlResourceSource[0] = (UINT8) ResourceSource->Index; + + /* Copy the ResourceSource string */ + + ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]), + ResourceSource->StringPtr); + + /* + * Add the length of the string (+ 1 for null terminator) to the + * final descriptor length + */ + DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); + } + + /* Return the new total length of the AML descriptor */ + + return (DescriptorLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrtMethodData + * + * PARAMETERS: Node - Device node + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _PRT value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetPrtMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, + ACPI_BTYPE_PACKAGE, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Create a resource linked list from the byte stream buffer that comes + * back from the _CRS method execution. + */ + Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by EvaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetCrsMethodData + * + * PARAMETERS: Node - Device node + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _CRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetCrsMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, + ACPI_BTYPE_BUFFER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by evaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrsMethodData + * + * PARAMETERS: Node - Device node + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _PRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetPrsMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, + ACPI_BTYPE_BUFFER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by evaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetMethodData + * + * PARAMETERS: Handle - Handle to the containing object + * Path - Path to method, relative to Handle + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _CRS or _PRS value of an + * object contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetMethodData ( + ACPI_HANDLE Handle, + char *Path, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the method + * execution. + */ + Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by EvaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetSrsMethodData + * + * PARAMETERS: Node - Device node + * InBuffer - Pointer to a buffer structure of the + * parameter + * + * RETURN: Status + * + * DESCRIPTION: This function is called to set the _SRS of an object contained + * in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + * Note: Parameters guaranteed valid by caller + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *InBuffer) +{ + ACPI_EVALUATE_INFO *Info; + ACPI_OPERAND_OBJECT *Args[2]; + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + + + ACPI_FUNCTION_TRACE (RsSetSrsMethodData); + + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = Node; + Info->Pathname = METHOD_NAME__SRS; + Info->Parameters = Args; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + /* + * The InBuffer parameter will point to a linked list of + * resource parameters. It needs to be formatted into a + * byte stream to be sent in as an input parameter to _SRS + * + * Convert the linked list into a byte stream + */ + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Create and initialize the method parameter object */ + + Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!Args[0]) + { + /* + * Must free the buffer allocated above (otherwise it is freed + * later) + */ + ACPI_FREE (Buffer.Pointer); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Args[0]->Buffer.Length = (UINT32) Buffer.Length; + Args[0]->Buffer.Pointer = Buffer.Pointer; + Args[0]->Common.Flags = AOPOBJ_DATA_VALID; + Args[1] = NULL; + + /* Execute the method, no return value is expected */ + + Status = AcpiNsEvaluate (Info); + + /* Clean up and return the status from AcpiNsEvaluate */ + + AcpiUtRemoveReference (Args[0]); + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + diff --git a/drivers/bus/acpi/acpica/resources/rsxface.c b/drivers/bus/acpi/acpica/resources/rsxface.c new file mode 100644 index 00000000000..a509c7afc7a --- /dev/null +++ b/drivers/bus/acpi/acpica/resources/rsxface.c @@ -0,0 +1,713 @@ +/******************************************************************************* + * + * Module Name: rsxface - Public interfaces to the resource manager + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsxface") + +/* Local macros for 16,32-bit to 64-bit conversion */ + +#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) +#define ACPI_COPY_ADDRESS(Out, In) \ + ACPI_COPY_FIELD(Out, In, ResourceType); \ + ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ + ACPI_COPY_FIELD(Out, In, Decode); \ + ACPI_COPY_FIELD(Out, In, MinAddressFixed); \ + ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \ + ACPI_COPY_FIELD(Out, In, Info); \ + ACPI_COPY_FIELD(Out, In, Granularity); \ + ACPI_COPY_FIELD(Out, In, Minimum); \ + ACPI_COPY_FIELD(Out, In, Maximum); \ + ACPI_COPY_FIELD(Out, In, TranslationOffset); \ + ACPI_COPY_FIELD(Out, In, AddressLength); \ + ACPI_COPY_FIELD(Out, In, ResourceSource); + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiRsMatchVendorResource ( + ACPI_RESOURCE *Resource, + void *Context); + +static ACPI_STATUS +AcpiRsValidateParameters ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *Buffer, + ACPI_NAMESPACE_NODE **ReturnNode); + + +/******************************************************************************* + * + * FUNCTION: AcpiRsValidateParameters + * + * PARAMETERS: DeviceHandle - Handle to a device + * Buffer - Pointer to a data buffer + * ReturnNode - Pointer to where the device node is returned + * + * RETURN: Status + * + * DESCRIPTION: Common parameter validation for resource interfaces + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiRsValidateParameters ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *Buffer, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (RsValidateParameters); + + + /* + * Must have a valid handle to an ACPI device + */ + if (!DeviceHandle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Node = AcpiNsValidateHandle (DeviceHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (Node->Type != ACPI_TYPE_DEVICE) + { + return_ACPI_STATUS (AE_TYPE); + } + + /* + * Validate the user buffer object + * + * if there is a non-zero buffer length we also need a valid pointer in + * the buffer. If it's a zero buffer length, we'll be returning the + * needed buffer size (later), so keep going. + */ + Status = AcpiUtValidateBuffer (Buffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *ReturnNode = Node; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetIrqRoutingTable + * + * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying + * RetBuffer - Pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the IRQ routing table for a + * specific bus. The caller must first acquire a handle for the + * desired bus. The routine table is placed in the buffer pointed + * to by the RetBuffer variable parameter. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. + * + * This function attempts to execute the _PRT method contained in + * the object indicated by the passed DeviceHandle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetIrqRoutingTable ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable); + + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsGetPrtMethodData (Node, RetBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetCurrentResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * RetBuffer - Pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the current resources for a + * specific device. The caller must first acquire a handle for + * the desired device. The resource data is placed in the buffer + * pointed to by the RetBuffer variable parameter. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. + * + * This function attempts to execute the _CRS method contained in + * the object indicated by the passed DeviceHandle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiGetCurrentResources); + + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsGetCrsMethodData (Node, RetBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetPossibleResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * RetBuffer - Pointer to a buffer to receive the + * resources for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get a list of the possible resources + * for a specific device. The caller must first acquire a handle + * for the desired device. The resource data is placed in the + * buffer pointed to by the RetBuffer variable. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetPossibleResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiGetPossibleResources); + + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsGetPrsMethodData (Node, RetBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources) + + +/******************************************************************************* + * + * FUNCTION: AcpiSetCurrentResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are setting resources + * InBuffer - Pointer to a buffer containing the + * resources to be set for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to set the current resources for a + * specific device. The caller must first acquire a handle for + * the desired device. The resource data is passed to the routine + * the buffer pointed to by the InBuffer variable. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *InBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiSetCurrentResources); + + + /* Validate the buffer, don't allow zero length */ + + if ((!InBuffer) || + (!InBuffer->Pointer) || + (!InBuffer->Length)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsSetSrsMethodData (Node, InBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources) + + +/****************************************************************************** + * + * FUNCTION: AcpiResourceToAddress64 + * + * PARAMETERS: Resource - Pointer to a resource + * Out - Pointer to the users's return buffer + * (a struct acpi_resource_address64) + * + * RETURN: Status + * + * DESCRIPTION: If the resource is an address16, address32, or address64, + * copy it to the address64 return buffer. This saves the + * caller from having to duplicate code for different-sized + * addresses. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiResourceToAddress64 ( + ACPI_RESOURCE *Resource, + ACPI_RESOURCE_ADDRESS64 *Out) +{ + ACPI_RESOURCE_ADDRESS16 *Address16; + ACPI_RESOURCE_ADDRESS32 *Address32; + + + if (!Resource || !Out) + { + return (AE_BAD_PARAMETER); + } + + /* Convert 16 or 32 address descriptor to 64 */ + + switch (Resource->Type) + { + case ACPI_RESOURCE_TYPE_ADDRESS16: + + Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data); + ACPI_COPY_ADDRESS (Out, Address16); + break; + + case ACPI_RESOURCE_TYPE_ADDRESS32: + + Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data); + ACPI_COPY_ADDRESS (Out, Address32); + break; + + case ACPI_RESOURCE_TYPE_ADDRESS64: + + /* Simple copy for 64 bit source */ + + ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64)); + break; + + default: + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetVendorResource + * + * PARAMETERS: DeviceHandle - Handle for the parent device object + * Name - Method name for the parent resource + * (METHOD_NAME__CRS or METHOD_NAME__PRS) + * Uuid - Pointer to the UUID to be matched. + * includes both subtype and 16-byte UUID + * RetBuffer - Where the vendor resource is returned + * + * RETURN: Status + * + * DESCRIPTION: Walk a resource template for the specified evice to find a + * vendor-defined resource that matches the supplied UUID and + * UUID subtype. Returns a ACPI_RESOURCE of type Vendor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetVendorResource ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_VENDOR_UUID *Uuid, + ACPI_BUFFER *RetBuffer) +{ + ACPI_VENDOR_WALK_INFO Info; + ACPI_STATUS Status; + + + /* Other parameters are validated by AcpiWalkResources */ + + if (!Uuid || !RetBuffer) + { + return (AE_BAD_PARAMETER); + } + + Info.Uuid = Uuid; + Info.Buffer = RetBuffer; + Info.Status = AE_NOT_EXIST; + + /* Walk the _CRS or _PRS resource list for this device */ + + Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource, + &Info); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + return (Info.Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetVendorResource) + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMatchVendorResource + * + * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiRsMatchVendorResource ( + ACPI_RESOURCE *Resource, + void *Context) +{ + ACPI_VENDOR_WALK_INFO *Info = Context; + ACPI_RESOURCE_VENDOR_TYPED *Vendor; + ACPI_BUFFER *Buffer; + ACPI_STATUS Status; + + + /* Ignore all descriptors except Vendor */ + + if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR) + { + return (AE_OK); + } + + Vendor = &Resource->Data.VendorTyped; + + /* + * For a valid match, these conditions must hold: + * + * 1) Length of descriptor data must be at least as long as a UUID struct + * 2) The UUID subtypes must match + * 3) The UUID data must match + */ + if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) || + (Vendor->UuidSubtype != Info->Uuid->Subtype) || + (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH))) + { + return (AE_OK); + } + + /* Validate/Allocate/Clear caller buffer */ + + Buffer = Info->Buffer; + Status = AcpiUtInitializeBuffer (Buffer, Resource->Length); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Found the correct resource, copy and return it */ + + ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length); + Buffer->Length = Resource->Length; + + /* Found the desired descriptor, terminate resource walk */ + + Info->Status = AE_OK; + return (AE_CTRL_TERMINATE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiWalkResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * Name - Method name of the resources we want + * (METHOD_NAME__CRS or METHOD_NAME__PRS) + * UserFunction - Called for each resource + * Context - Passed to UserFunction + * + * RETURN: Status + * + * DESCRIPTION: Retrieves the current or possible resource list for the + * specified device. The UserFunction is called once for + * each resource in the list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWalkResources ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_WALK_RESOURCE_CALLBACK UserFunction, + void *Context) +{ + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + ACPI_RESOURCE *Resource; + ACPI_RESOURCE *ResourceEnd; + + + ACPI_FUNCTION_TRACE (AcpiWalkResources); + + + /* Parameter validation */ + + if (!DeviceHandle || !UserFunction || !Name || + (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) && + !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the _CRS or _PRS resource list */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Buffer now contains the resource list */ + + Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer); + ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length); + + /* Walk the resource list until the EndTag is found (or buffer end) */ + + while (Resource < ResourceEnd) + { + /* Sanity check the resource */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + Status = AE_AML_INVALID_RESOURCE_TYPE; + break; + } + + /* Invoke the user function, abort on any error returned */ + + Status = UserFunction (Resource, Context); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_TERMINATE) + { + /* This is an OK termination by the user function */ + + Status = AE_OK; + } + break; + } + + /* EndTag indicates end-of-list */ + + if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) + { + break; + } + + /* Get the next resource descriptor */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + ACPI_FREE (Buffer.Pointer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWalkResources) diff --git a/drivers/bus/acpi/acpica/tables/tbconvrt.c b/drivers/bus/acpi/acpica/tables/tbconvrt.c new file mode 100644 index 00000000000..77ece2ae07a --- /dev/null +++ b/drivers/bus/acpi/acpica/tables/tbconvrt.c @@ -0,0 +1,547 @@ +/****************************************************************************** + * + * Module Name: tbconvrt - ACPI Table conversion utilities + * $Revision: 1.1 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000, 2001 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include + +#define _COMPONENT ACPI_TABLES + MODULE_NAME ("tbconvrt") + + +/* + * Build a GAS structure from earlier ACPI table entries (V1.0 and 0.71 extensions) + * + * 1) Address space + * 2) Length in bytes -- convert to length in bits + * 3) Bit offset is zero + * 4) Reserved field is zero + * 5) Expand address to 64 bits + */ +#define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d) {a.address_space_id = (u8) d;\ + a.register_bit_width = (u8) MUL_8 (b);\ + a.register_bit_offset = 0;\ + a.reserved = 0;\ + ACPI_STORE_ADDRESS (a.address,c);} + + +/* ACPI V1.0 entries -- address space is always I/O */ + +#define ASL_BUILD_GAS_FROM_V1_ENTRY(a,b,c) ASL_BUILD_GAS_FROM_ENTRY(a,b,c,ADDRESS_SPACE_SYSTEM_IO) + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_convert_to_xsdt + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_convert_to_xsdt ( + ACPI_TABLE_DESC *table_info, + u32 *number_of_tables) { + u32 table_size; + u32 pointer_size; + u32 i; + XSDT_DESCRIPTOR *new_table; + + +#ifndef _IA64 + + if (acpi_gbl_RSDP->revision < 2) { + pointer_size = sizeof (u32); + } + + else +#endif + { + pointer_size = sizeof (UINT64); + } + + /* + * Determine the number of tables pointed to by the RSDT/XSDT. + * This is defined by the ACPI Specification to be the number of + * pointers contained within the RSDT/XSDT. The size of the pointers + * is architecture-dependent. + */ + + table_size = table_info->pointer->length; + *number_of_tables = (table_size - + sizeof (ACPI_TABLE_HEADER)) / pointer_size; + + /* Compute size of the converted XSDT */ + + table_size = (*number_of_tables * sizeof (UINT64)) + sizeof (ACPI_TABLE_HEADER); + + + /* Allocate an XSDT */ + + new_table = acpi_cm_callocate (table_size); + if (!new_table) { + return (AE_NO_MEMORY); + } + + /* Copy the header and set the length */ + + MEMCPY (new_table, table_info->pointer, sizeof (ACPI_TABLE_HEADER)); + new_table->header.length = table_size; + + /* Copy the table pointers */ + + for (i = 0; i < *number_of_tables; i++) { + if (acpi_gbl_RSDP->revision < 2) { +#ifdef _IA64 + new_table->table_offset_entry[i] = + ((RSDT_DESCRIPTOR_REV071 *) table_info->pointer)->table_offset_entry[i]; +#else + ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], + ((RSDT_DESCRIPTOR_REV1 *) table_info->pointer)->table_offset_entry[i]); +#endif + } + else { + new_table->table_offset_entry[i] = + ((XSDT_DESCRIPTOR *) table_info->pointer)->table_offset_entry[i]; + } + } + + + /* Delete the original table (either mapped or in a buffer) */ + + acpi_tb_delete_single_table (table_info); + + + /* Point the table descriptor to the new table */ + + table_info->pointer = (ACPI_TABLE_HEADER *) new_table; + table_info->base_pointer = (ACPI_TABLE_HEADER *) new_table; + table_info->length = table_size; + table_info->allocation = ACPI_MEM_ALLOCATED; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_convert_table_fadt + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: + * Converts BIOS supplied 1.0 and 0.71 ACPI FADT to an intermediate + * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply + * copied to the intermediate FADT. The ACPI CA software uses this + * intermediate FADT. Thus a significant amount of special #ifdef + * type codeing is saved. This intermediate FADT will need to be + * freed at some point. + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_convert_table_fadt (void) +{ + +#ifdef _IA64 + FADT_DESCRIPTOR_REV071 *FADT71; + u8 pm1_address_space; + u8 pm2_address_space; + u8 pm_timer_address_space; + u8 gpe0address_space; + u8 gpe1_address_space; +#else + FADT_DESCRIPTOR_REV1 *FADT1; +#endif + + FADT_DESCRIPTOR_REV2 *FADT2; + ACPI_TABLE_DESC *table_desc; + + + /* Acpi_gbl_FADT is valid */ + /* Allocate and zero the 2.0 buffer */ + + FADT2 = acpi_cm_callocate (sizeof (FADT_DESCRIPTOR_REV2)); + if (FADT2 == NULL) { + return (AE_NO_MEMORY); + } + + + /* The ACPI FADT revision number is FADT2_REVISION_ID=3 */ + /* So, if the current table revision is less than 3 it is type 1.0 or 0.71 */ + + if (acpi_gbl_FADT->header.revision >= FADT2_REVISION_ID) { + /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ + + *FADT2 = *((FADT_DESCRIPTOR_REV2*) acpi_gbl_FADT); + + } + + else { + +#ifdef _IA64 + /* + * For the 64-bit case only, a revision ID less than V2.0 means the + * tables are the 0.71 extensions + */ + + /* The BIOS stored FADT should agree with Revision 0.71 */ + + FADT71 = (FADT_DESCRIPTOR_REV071 *) acpi_gbl_FADT; + + /* Copy the table header*/ + + FADT2->header = FADT71->header; + + /* Copy the common fields */ + + FADT2->sci_int = FADT71->sci_int; + FADT2->acpi_enable = FADT71->acpi_enable; + FADT2->acpi_disable = FADT71->acpi_disable; + FADT2->S4_bios_req = FADT71->S4_bios_req; + FADT2->plvl2_lat = FADT71->plvl2_lat; + FADT2->plvl3_lat = FADT71->plvl3_lat; + FADT2->day_alrm = FADT71->day_alrm; + FADT2->mon_alrm = FADT71->mon_alrm; + FADT2->century = FADT71->century; + FADT2->gpe1_base = FADT71->gpe1_base; + + /* + * We still use the block length registers even though + * the GAS structure should obsolete them. This is because + * these registers are byte lengths versus the GAS which + * contains a bit width + */ + FADT2->pm1_evt_len = FADT71->pm1_evt_len; + FADT2->pm1_cnt_len = FADT71->pm1_cnt_len; + FADT2->pm2_cnt_len = FADT71->pm2_cnt_len; + FADT2->pm_tm_len = FADT71->pm_tm_len; + FADT2->gpe0blk_len = FADT71->gpe0blk_len; + FADT2->gpe1_blk_len = FADT71->gpe1_blk_len; + FADT2->gpe1_base = FADT71->gpe1_base; + + /* Copy the existing 0.71 flags to 2.0. The other bits are zero.*/ + + FADT2->wb_invd = FADT71->flush_cash; + FADT2->proc_c1 = FADT71->proc_c1; + FADT2->plvl2_up = FADT71->plvl2_up; + FADT2->pwr_button = FADT71->pwr_button; + FADT2->sleep_button = FADT71->sleep_button; + FADT2->fixed_rTC = FADT71->fixed_rTC; + FADT2->rtcs4 = FADT71->rtcs4; + FADT2->tmr_val_ext = FADT71->tmr_val_ext; + FADT2->dock_cap = FADT71->dock_cap; + + + /* We should not use these next two addresses */ + /* Since our buffer is pre-zeroed nothing to do for */ + /* the next three data items in the structure */ + /* FADT2->Firmware_ctrl = 0; */ + /* FADT2->Dsdt = 0; */ + + /* System Interrupt Model isn't used in ACPI 2.0*/ + /* FADT2->Reserved1 = 0; */ + + /* This field is set by the OEM to convey the preferred */ + /* power management profile to OSPM. It doesn't have any*/ + /* 0.71 equivalence. Since we don't know what kind of */ + /* 64-bit system this is, we will pick unspecified. */ + + FADT2->prefer_PM_profile = PM_UNSPECIFIED; + + + /* Port address of SMI command port */ + /* We shouldn't use this port because IA64 doesn't */ + /* have or use SMI. It has PMI. */ + + FADT2->smi_cmd = (u32)(FADT71->smi_cmd & 0xFFFFFFFF); + + + /* processor performance state control*/ + /* The value OSPM writes to the SMI_CMD register to assume */ + /* processor performance state control responsibility. */ + /* There isn't any equivalence in 0.71 */ + /* Again this should be meaningless for IA64 */ + /* FADT2->Pstate_cnt = 0; */ + + /* The 32-bit Power management and GPE registers are */ + /* not valid in IA-64 and we are not going to use them */ + /* so leaving them pre-zeroed. */ + + /* Support for the _CST object and C States change notification.*/ + /* This data item hasn't any 0.71 equivalence so leaving it zero.*/ + /* FADT2->Cst_cnt = 0; */ + + /* number of flush strides that need to be read */ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Flush_size = 0; */ + + /* Processor's memory cache line width, in bytes */ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Flush_stride = 0; */ + + /* Processor's duty cycle index in processor's P_CNT reg*/ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Duty_offset = 0; */ + + /* Processor's duty cycle value bit width in P_CNT register.*/ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Duty_width = 0; */ + + + /* Since there isn't any equivalence in 0.71 */ + /* and since Big_sur had to support legacy */ + + FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES; + + /* Copy to ACPI 2.0 64-BIT Extended Addresses */ + + FADT2->Xfirmware_ctrl = FADT71->firmware_ctrl; + FADT2->Xdsdt = FADT71->dsdt; + + + /* Extract the address space IDs */ + + pm1_address_space = (u8)((FADT71->address_space & PM1_BLK_ADDRESS_SPACE) >> 1); + pm2_address_space = (u8)((FADT71->address_space & PM2_CNT_BLK_ADDRESS_SPACE) >> 2); + pm_timer_address_space = (u8)((FADT71->address_space & PM_TMR_BLK_ADDRESS_SPACE) >> 3); + gpe0address_space = (u8)((FADT71->address_space & GPE0_BLK_ADDRESS_SPACE) >> 4); + gpe1_address_space = (u8)((FADT71->address_space & GPE1_BLK_ADDRESS_SPACE) >> 5); + + /* + * Convert the 0.71 (non-GAS style) Block addresses to V2.0 GAS structures, + * in this order: + * + * PM 1_a Events + * PM 1_b Events + * PM 1_a Control + * PM 1_b Control + * PM 2 Control + * PM Timer Control + * GPE Block 0 + * GPE Block 1 + */ + + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_evt_blk, FADT71->pm1_evt_len, FADT71->pm1a_evt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_evt_blk, FADT71->pm1_evt_len, FADT71->pm1b_evt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1a_cnt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1b_cnt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm2_cnt_blk, FADT71->pm2_cnt_len, FADT71->pm2_cnt_blk, pm2_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm_tmr_blk, FADT71->pm_tm_len, FADT71->pm_tmr_blk, pm_timer_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe0blk, FADT71->gpe0blk_len, FADT71->gpe0blk, gpe0address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe1_blk, FADT71->gpe1_blk_len, FADT71->gpe1_blk, gpe1_address_space); + +#else + + /* ACPI 1.0 FACS */ + + + /* The BIOS stored FADT should agree with Revision 1.0 */ + + FADT1 = (FADT_DESCRIPTOR_REV1*) acpi_gbl_FADT; + + /* + * Copy the table header and the common part of the tables + * The 2.0 table is an extension of the 1.0 table, so the + * entire 1.0 table can be copied first, then expand some + * fields to 64 bits. + */ + + MEMCPY (FADT2, FADT1, sizeof (FADT_DESCRIPTOR_REV1)); + + + /* Convert table pointers to 64-bit fields */ + + ACPI_STORE_ADDRESS (FADT2->Xfirmware_ctrl, FADT1->firmware_ctrl); + ACPI_STORE_ADDRESS (FADT2->Xdsdt, FADT1->dsdt); + + /* System Interrupt Model isn't used in ACPI 2.0*/ + /* FADT2->Reserved1 = 0; */ + + /* This field is set by the OEM to convey the preferred */ + /* power management profile to OSPM. It doesn't have any*/ + /* 1.0 equivalence. Since we don't know what kind of */ + /* 32-bit system this is, we will pick unspecified. */ + + FADT2->prefer_PM_profile = PM_UNSPECIFIED; + + + /* Processor Performance State Control. This is the value */ + /* OSPM writes to the SMI_CMD register to assume processor */ + /* performance state control responsibility. There isn't */ + /* any equivalence in 1.0. So leave it zeroed. */ + + FADT2->pstate_cnt = 0; + + + /* Support for the _CST object and C States change notification.*/ + /* This data item hasn't any 1.0 equivalence so leaving it zero.*/ + + FADT2->cst_cnt = 0; + + + /* Since there isn't any equivalence in 1.0 and since it */ + /* is highly likely that a 1.0 system has legacy support. */ + + FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES; + + + /* + * Convert the V1.0 Block addresses to V2.0 GAS structures + * in this order: + * + * PM 1_a Events + * PM 1_b Events + * PM 1_a Control + * PM 1_b Control + * PM 2 Control + * PM Timer Control + * GPE Block 0 + * GPE Block 1 + */ + + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_evt_blk, FADT1->pm1_evt_len, FADT1->pm1a_evt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_evt_blk, FADT1->pm1_evt_len, FADT1->pm1b_evt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1a_cnt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1b_cnt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm2_cnt_blk, FADT1->pm2_cnt_len, FADT1->pm2_cnt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm_tmr_blk, FADT1->pm_tm_len, FADT1->pm_tmr_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe0blk, FADT1->gpe0blk_len, FADT1->gpe0blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe1_blk, FADT1->gpe1_blk_len, FADT1->gpe1_blk); +#endif + } + + + /* + * Global FADT pointer will point to the common V2.0 FADT + */ + acpi_gbl_FADT = FADT2; + acpi_gbl_FADT->header.length = sizeof (FADT_DESCRIPTOR); + + + /* Free the original table */ + + table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_FADT]; + acpi_tb_delete_single_table (table_desc); + + + /* Install the new table */ + + table_desc->pointer = (ACPI_TABLE_HEADER *) acpi_gbl_FADT; + table_desc->base_pointer = acpi_gbl_FADT; + table_desc->allocation = ACPI_MEM_ALLOCATED; + table_desc->length = sizeof (FADT_DESCRIPTOR_REV2); + + + /* Dump the entire FADT */ + + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_convert_table_facs + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_build_common_facs ( + ACPI_TABLE_DESC *table_info) +{ + ACPI_COMMON_FACS *common_facs; + +#ifdef _IA64 + FACS_DESCRIPTOR_REV071 *FACS71; +#else + FACS_DESCRIPTOR_REV1 *FACS1; +#endif + + FACS_DESCRIPTOR_REV2 *FACS2; + + + /* Allocate a common FACS */ + + common_facs = acpi_cm_callocate (sizeof (ACPI_COMMON_FACS)); + if (!common_facs) { + return (AE_NO_MEMORY); + } + + + /* Copy fields to the new FACS */ + + if (acpi_gbl_RSDP->revision < 2) { +#ifdef _IA64 + /* 0.71 FACS */ + + FACS71 = (FACS_DESCRIPTOR_REV071 *) acpi_gbl_FACS; + + common_facs->global_lock = (u32 *) &(FACS71->global_lock); + common_facs->firmware_waking_vector = &FACS71->firmware_waking_vector; + common_facs->vector_width = 64; +#else + /* ACPI 1.0 FACS */ + + FACS1 = (FACS_DESCRIPTOR_REV1 *) acpi_gbl_FACS; + + common_facs->global_lock = &(FACS1->global_lock); + common_facs->firmware_waking_vector = (UINT64 *) &FACS1->firmware_waking_vector; + common_facs->vector_width = 32; + +#endif + } + + else { + /* ACPI 2.0 FACS */ + + FACS2 = (FACS_DESCRIPTOR_REV2 *) acpi_gbl_FACS; + + common_facs->global_lock = &(FACS2->global_lock); + common_facs->firmware_waking_vector = &FACS2->Xfirmware_waking_vector; + common_facs->vector_width = 64; + } + + + /* Set the global FACS pointer to point to the common FACS */ + + + acpi_gbl_FACS = common_facs; + + return (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/tables/tbfadt.c b/drivers/bus/acpi/acpica/tables/tbfadt.c new file mode 100644 index 00000000000..c657a0b75ac --- /dev/null +++ b/drivers/bus/acpi/acpica/tables/tbfadt.c @@ -0,0 +1,752 @@ +/****************************************************************************** + * + * Module Name: tbfadt - FADT table utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBFADT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbfadt") + +/* Local prototypes */ + +static inline void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *GenericAddress, + UINT8 SpaceId, + UINT8 ByteWidth, + UINT64 Address); + +static void +AcpiTbConvertFadt ( + void); + +static void +AcpiTbValidateFadt ( + void); + +static void +AcpiTbSetupFadtRegisters ( + void); + + +/* Table for conversion of FADT to common internal format and FADT validation */ + +typedef struct acpi_fadt_info +{ + char *Name; + UINT8 Address64; + UINT8 Address32; + UINT8 Length; + UINT8 DefaultLength; + UINT8 Type; + +} ACPI_FADT_INFO; + +#define ACPI_FADT_REQUIRED 1 +#define ACPI_FADT_SEPARATE_LENGTH 2 + +static ACPI_FADT_INFO FadtInfoTable[] = +{ + {"Pm1aEventBlock", + ACPI_FADT_OFFSET (XPm1aEventBlock), + ACPI_FADT_OFFSET (Pm1aEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), + ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ + ACPI_FADT_REQUIRED}, + + {"Pm1bEventBlock", + ACPI_FADT_OFFSET (XPm1bEventBlock), + ACPI_FADT_OFFSET (Pm1bEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), + ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ + 0}, + + {"Pm1aControlBlock", + ACPI_FADT_OFFSET (XPm1aControlBlock), + ACPI_FADT_OFFSET (Pm1aControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), + ACPI_PM1_REGISTER_WIDTH, + ACPI_FADT_REQUIRED}, + + {"Pm1bControlBlock", + ACPI_FADT_OFFSET (XPm1bControlBlock), + ACPI_FADT_OFFSET (Pm1bControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), + ACPI_PM1_REGISTER_WIDTH, + 0}, + + {"Pm2ControlBlock", + ACPI_FADT_OFFSET (XPm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlLength), + ACPI_PM2_REGISTER_WIDTH, + ACPI_FADT_SEPARATE_LENGTH}, + + {"PmTimerBlock", + ACPI_FADT_OFFSET (XPmTimerBlock), + ACPI_FADT_OFFSET (PmTimerBlock), + ACPI_FADT_OFFSET (PmTimerLength), + ACPI_PM_TIMER_WIDTH, + ACPI_FADT_REQUIRED}, + + {"Gpe0Block", + ACPI_FADT_OFFSET (XGpe0Block), + ACPI_FADT_OFFSET (Gpe0Block), + ACPI_FADT_OFFSET (Gpe0BlockLength), + 0, + ACPI_FADT_SEPARATE_LENGTH}, + + {"Gpe1Block", + ACPI_FADT_OFFSET (XGpe1Block), + ACPI_FADT_OFFSET (Gpe1Block), + ACPI_FADT_OFFSET (Gpe1BlockLength), + 0, + ACPI_FADT_SEPARATE_LENGTH} +}; + +#define ACPI_FADT_INFO_ENTRIES \ + (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO)) + + +/* Table used to split Event Blocks into separate status/enable registers */ + +typedef struct acpi_fadt_pm_info +{ + ACPI_GENERIC_ADDRESS *Target; + UINT8 Source; + UINT8 RegisterNum; + +} ACPI_FADT_PM_INFO; + +static ACPI_FADT_PM_INFO FadtPmInfoTable[] = +{ + {&AcpiGbl_XPm1aStatus, + ACPI_FADT_OFFSET (XPm1aEventBlock), + 0}, + + {&AcpiGbl_XPm1aEnable, + ACPI_FADT_OFFSET (XPm1aEventBlock), + 1}, + + {&AcpiGbl_XPm1bStatus, + ACPI_FADT_OFFSET (XPm1bEventBlock), + 0}, + + {&AcpiGbl_XPm1bEnable, + ACPI_FADT_OFFSET (XPm1bEventBlock), + 1} +}; + +#define ACPI_FADT_PM_INFO_ENTRIES \ + (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO)) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitGenericAddress + * + * PARAMETERS: GenericAddress - GAS struct to be initialized + * SpaceId - ACPI Space ID for this register + * ByteWidth - Width of this register, in bytes + * Address - Address of the register + * + * RETURN: None + * + * DESCRIPTION: Initialize a Generic Address Structure (GAS) + * See the ACPI specification for a full description and + * definition of this structure. + * + ******************************************************************************/ + +static inline void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *GenericAddress, + UINT8 SpaceId, + UINT8 ByteWidth, + UINT64 Address) +{ + + /* + * The 64-bit Address field is non-aligned in the byte packed + * GAS struct. + */ + ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address); + + /* All other fields are byte-wide */ + + GenericAddress->SpaceId = SpaceId; + GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth); + GenericAddress->BitOffset = 0; + GenericAddress->AccessWidth = 0; /* Access width ANY */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbParseFadt + * + * PARAMETERS: TableIndex - Index for the FADT + * + * RETURN: None + * + * DESCRIPTION: Initialize the FADT, DSDT and FACS tables + * (FADT contains the addresses of the DSDT and FACS) + * + ******************************************************************************/ + +void +AcpiTbParseFadt ( + UINT32 TableIndex) +{ + UINT32 Length; + ACPI_TABLE_HEADER *Table; + + + /* + * The FADT has multiple versions with different lengths, + * and it contains pointers to both the DSDT and FACS tables. + * + * Get a local copy of the FADT and convert it to a common format + * Map entire FADT, assumed to be smaller than one page. + */ + Length = AcpiGbl_RootTableList.Tables[TableIndex].Length; + + Table = AcpiOsMapMemory ( + AcpiGbl_RootTableList.Tables[TableIndex].Address, Length); + if (!Table) + { + return; + } + + /* + * Validate the FADT checksum before we copy the table. Ignore + * checksum error as we want to try to get the DSDT and FACS. + */ + (void) AcpiTbVerifyChecksum (Table, Length); + + /* Create a local copy of the FADT in common ACPI 2.0+ format */ + + AcpiTbCreateLocalFadt (Table, Length); + + /* All done with the real FADT, unmap it */ + + AcpiOsUnmapMemory (Table, Length); + + /* Obtain the DSDT and FACS tables via their addresses within the FADT */ + + AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, + ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); + + AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, + ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCreateLocalFadt + * + * PARAMETERS: Table - Pointer to BIOS FADT + * Length - Length of the table + * + * RETURN: None + * + * DESCRIPTION: Get a local copy of the FADT and convert it to a common format. + * Performs validation on some important FADT fields. + * + * NOTE: We create a local copy of the FADT regardless of the version. + * + ******************************************************************************/ + +void +AcpiTbCreateLocalFadt ( + ACPI_TABLE_HEADER *Table, + UINT32 Length) +{ + + /* + * Check if the FADT is larger than the largest table that we expect + * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue + * a warning. + */ + if (Length > sizeof (ACPI_TABLE_FADT)) + { + ACPI_WARNING ((AE_INFO, + "FADT (revision %u) is longer than ACPI 2.0 version, " + "truncating length 0x%X to 0x%X", + Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT))); + } + + /* Clear the entire local FADT */ + + ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT)); + + /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */ + + ACPI_MEMCPY (&AcpiGbl_FADT, Table, + ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT))); + + /* Convert the local copy of the FADT to the common internal format */ + + AcpiTbConvertFadt (); + + /* Validate FADT values now, before we make any changes */ + + AcpiTbValidateFadt (); + + /* Initialize the global ACPI register structures */ + + AcpiTbSetupFadtRegisters (); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbConvertFadt + * + * PARAMETERS: None, uses AcpiGbl_FADT + * + * RETURN: None + * + * DESCRIPTION: Converts all versions of the FADT to a common internal format. + * Expand 32-bit addresses to 64-bit as necessary. + * + * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), + * and must contain a copy of the actual FADT. + * + * Notes on 64-bit register addresses: + * + * After this FADT conversion, later ACPICA code will only use the 64-bit "X" + * fields of the FADT for all ACPI register addresses. + * + * The 64-bit "X" fields are optional extensions to the original 32-bit FADT + * V1.0 fields. Even if they are present in the FADT, they are optional and + * are unused if the BIOS sets them to zero. Therefore, we must copy/expand + * 32-bit V1.0 fields if the corresponding X field is zero. + * + * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the + * corresponding "X" fields in the internal FADT. + * + * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded + * to the corresponding 64-bit X fields. For compatibility with other ACPI + * implementations, we ignore the 64-bit field if the 32-bit field is valid, + * regardless of whether the host OS is 32-bit or 64-bit. + * + ******************************************************************************/ + +static void +AcpiTbConvertFadt ( + void) +{ + ACPI_GENERIC_ADDRESS *Address64; + UINT32 Address32; + UINT32 i; + + + /* Update the local FADT table header length */ + + AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT); + + /* + * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. + * Later code will always use the X 64-bit field. + */ + if (!AcpiGbl_FADT.XFacs) + { + AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; + } + if (!AcpiGbl_FADT.XDsdt) + { + AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; + } + + /* + * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which + * should be zero are indeed zero. This will workaround BIOSs that + * inadvertently place values in these fields. + * + * The ACPI 1.0 reserved fields that will be zeroed are the bytes located + * at offset 45, 55, 95, and the word located at offset 109, 110. + */ + if (AcpiGbl_FADT.Header.Revision < 3) + { + AcpiGbl_FADT.PreferredProfile = 0; + AcpiGbl_FADT.PstateControl = 0; + AcpiGbl_FADT.CstControl = 0; + AcpiGbl_FADT.BootFlags = 0; + } + + /* + * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" + * generic address structures as necessary. Later code will always use + * the 64-bit address structures. + * + * March 2009: + * We now always use the 32-bit address if it is valid (non-null). This + * is not in accordance with the ACPI specification which states that + * the 64-bit address supersedes the 32-bit version, but we do this for + * compatibility with other ACPI implementations. Most notably, in the + * case where both the 32 and 64 versions are non-null, we use the 32-bit + * version. This is the only address that is guaranteed to have been + * tested by the BIOS manufacturer. + */ + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + Address32 = *ACPI_ADD_PTR (UINT32, + &AcpiGbl_FADT, FadtInfoTable[i].Address32); + + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, + &AcpiGbl_FADT, FadtInfoTable[i].Address64); + + /* + * If both 32- and 64-bit addresses are valid (non-zero), + * they must match. + */ + if (Address64->Address && Address32 && + (Address64->Address != (UINT64) Address32)) + { + ACPI_ERROR ((AE_INFO, + "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 32", + FadtInfoTable[i].Name, Address32, + ACPI_FORMAT_UINT64 (Address64->Address))); + } + + /* Always use 32-bit address if it is valid (non-null) */ + + if (Address32) + { + /* + * Copy the 32-bit address to the 64-bit GAS structure. The + * Space ID is always I/O for 32-bit legacy address fields + */ + AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO, + *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length), + (UINT64) Address32); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateFadt + * + * PARAMETERS: Table - Pointer to the FADT to be validated + * + * RETURN: None + * + * DESCRIPTION: Validate various important fields within the FADT. If a problem + * is found, issue a message, but no status is returned. + * Used by both the table manager and the disassembler. + * + * Possible additional checks: + * (AcpiGbl_FADT.Pm1EventLength >= 4) + * (AcpiGbl_FADT.Pm1ControlLength >= 2) + * (AcpiGbl_FADT.PmTimerLength >= 4) + * Gpe block lengths must be multiple of 2 + * + ******************************************************************************/ + +static void +AcpiTbValidateFadt ( + void) +{ + char *Name; + ACPI_GENERIC_ADDRESS *Address64; + UINT8 Length; + UINT32 i; + + + /* + * Check for FACS and DSDT address mismatches. An address mismatch between + * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and + * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables. + */ + if (AcpiGbl_FADT.Facs && + (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs)) + { + ACPI_WARNING ((AE_INFO, + "32/64X FACS address mismatch in FADT - " + "%8.8X/%8.8X%8.8X, using 32", + AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs))); + + AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; + } + + if (AcpiGbl_FADT.Dsdt && + (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt)) + { + ACPI_WARNING ((AE_INFO, + "32/64X DSDT address mismatch in FADT - " + "%8.8X/%8.8X%8.8X, using 32", + AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt))); + + AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; + } + + /* Examine all of the 64-bit extended address fields (X fields) */ + + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + /* + * Generate pointer to the 64-bit address, get the register + * length (width) and the register name + */ + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, + &AcpiGbl_FADT, FadtInfoTable[i].Address64); + Length = *ACPI_ADD_PTR (UINT8, + &AcpiGbl_FADT, FadtInfoTable[i].Length); + Name = FadtInfoTable[i].Name; + + /* + * For each extended field, check for length mismatch between the + * legacy length field and the corresponding 64-bit X length field. + */ + if (Address64->Address && + (Address64->BitWidth != ACPI_MUL_8 (Length))) + { + ACPI_WARNING ((AE_INFO, + "32/64X length mismatch in %s: %d/%d", + Name, ACPI_MUL_8 (Length), Address64->BitWidth)); + } + + if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED) + { + /* + * Field is required (PM1aEvent, PM1aControl, PmTimer). + * Both the address and length must be non-zero. + */ + if (!Address64->Address || !Length) + { + ACPI_ERROR ((AE_INFO, + "Required field %s has zero address and/or length:" + " %8.8X%8.8X/%X", + Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + } + } + else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH) + { + /* + * Field is optional (PM2Control, GPE0, GPE1) AND has its own + * length field. If present, both the address and length must + * be valid. + */ + if ((Address64->Address && !Length) || + (!Address64->Address && Length)) + { + ACPI_WARNING ((AE_INFO, + "Optional field %s has zero address or length: " + "%8.8X%8.8X/%X", + Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + } + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSetupFadtRegisters + * + * PARAMETERS: None, uses AcpiGbl_FADT. + * + * RETURN: None + * + * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally, + * force FADT register definitions to their default lengths. + * + ******************************************************************************/ + +static void +AcpiTbSetupFadtRegisters ( + void) +{ + ACPI_GENERIC_ADDRESS *Target64; + ACPI_GENERIC_ADDRESS *Source64; + UINT8 Pm1RegisterByteWidth; + UINT32 i; + + + /* + * Optionally check all register lengths against the default values and + * update them if they are incorrect. + */ + if (AcpiGbl_UseDefaultRegisterWidths) + { + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, + FadtInfoTable[i].Address64); + + /* + * If a valid register (Address != 0) and the (DefaultLength > 0) + * (Not a GPE register), then check the width against the default. + */ + if ((Target64->Address) && + (FadtInfoTable[i].DefaultLength > 0) && + (FadtInfoTable[i].DefaultLength != Target64->BitWidth)) + { + ACPI_WARNING ((AE_INFO, + "Invalid length for %s: %d, using default %d", + FadtInfoTable[i].Name, Target64->BitWidth, + FadtInfoTable[i].DefaultLength)); + + /* Incorrect size, set width to the default */ + + Target64->BitWidth = FadtInfoTable[i].DefaultLength; + } + } + } + + /* + * Get the length of the individual PM1 registers (enable and status). + * Each register is defined to be (event block length / 2). Extra divide + * by 8 converts bits to bytes. + */ + Pm1RegisterByteWidth = (UINT8) + ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth); + + /* + * Calculate separate GAS structs for the PM1x (A/B) Status and Enable + * registers. These addresses do not appear (directly) in the FADT, so it + * is useful to pre-calculate them from the PM1 Event Block definitions. + * + * The PM event blocks are split into two register blocks, first is the + * PM Status Register block, followed immediately by the PM Enable + * Register block. Each is of length (Pm1EventLength/2) + * + * Note: The PM1A event block is required by the ACPI specification. + * However, the PM1B event block is optional and is rarely, if ever, + * used. + */ + + for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++) + { + Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, + FadtPmInfoTable[i].Source); + + if (Source64->Address) + { + AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target, + Source64->SpaceId, Pm1RegisterByteWidth, + Source64->Address + + (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth)); + } + } +} + diff --git a/drivers/bus/acpi/acpica/tables/tbfind.c b/drivers/bus/acpi/acpica/tables/tbfind.c new file mode 100644 index 00000000000..1838b5eb78a --- /dev/null +++ b/drivers/bus/acpi/acpica/tables/tbfind.c @@ -0,0 +1,215 @@ +/****************************************************************************** + * + * Module Name: tbfind - find table + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBFIND_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbfind") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFindTable + * + * PARAMETERS: Signature - String with ACPI table signature + * OemId - String with the table OEM ID + * OemTableId - String with the OEM Table ID + * TableIndex - Where the table index is returned + * + * RETURN: Status and table index + * + * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the + * Signature, OEM ID and OEM Table ID. Returns an index that can + * be used to get the table header or entire table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + UINT32 *TableIndex) +{ + UINT32 i; + ACPI_STATUS Status; + ACPI_TABLE_HEADER Header; + + + ACPI_FUNCTION_TRACE (TbFindTable); + + + /* Normalize the input strings */ + + ACPI_MEMSET (&Header, 0, sizeof (ACPI_TABLE_HEADER)); + ACPI_STRNCPY (Header.Signature, Signature, ACPI_NAME_SIZE); + ACPI_STRNCPY (Header.OemId, OemId, ACPI_OEM_ID_SIZE); + ACPI_STRNCPY (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE); + + /* Search for the table */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature), + Header.Signature, ACPI_NAME_SIZE)) + { + /* Not the requested table */ + + continue; + } + + /* Table with matching signature has been found */ + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + /* Table is not currently mapped, map it */ + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + continue; + } + } + + /* Check for table match on all IDs */ + + if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature, + Header.Signature, ACPI_NAME_SIZE) && + (!OemId[0] || + !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId, + Header.OemId, ACPI_OEM_ID_SIZE)) && + (!OemTableId[0] || + !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId, + Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE))) + { + *TableIndex = i; + + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", + Header.Signature)); + return_ACPI_STATUS (AE_OK); + } + } + + return_ACPI_STATUS (AE_NOT_FOUND); +} diff --git a/drivers/bus/acpi/acpica/tables/tbget.c b/drivers/bus/acpi/acpica/tables/tbget.c new file mode 100644 index 00000000000..e16db9d26b3 --- /dev/null +++ b/drivers/bus/acpi/acpica/tables/tbget.c @@ -0,0 +1,608 @@ +/****************************************************************************** + * + * Module Name: tbget - ACPI Table get* routines + * $Revision: 1.1 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000, 2001 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include + +#define _COMPONENT ACPI_TABLES + MODULE_NAME ("tbget") + +#define RSDP_CHECKSUM_LENGTH 20 + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_table_ptr + * + * PARAMETERS: Table_type - one of the defined table types + * Instance - Which table of this type + * Table_ptr_loc - pointer to location to place the pointer for + * return + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the pointer to an ACPI table. + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table_ptr ( + ACPI_TABLE_TYPE table_type, + u32 instance, + ACPI_TABLE_HEADER **table_ptr_loc) +{ + ACPI_TABLE_DESC *table_desc; + u32 i; + + + if (!acpi_gbl_DSDT) { + return (AE_NO_ACPI_TABLES); + } + + if (table_type > ACPI_TABLE_MAX) { + return (AE_BAD_PARAMETER); + } + + + /* + * For all table types (Single/Multiple), the first + * instance is always in the list head. + */ + + if (instance == 1) { + /* + * Just pluck the pointer out of the global table! + * Will be null if no table is present + */ + + *table_ptr_loc = acpi_gbl_acpi_tables[table_type].pointer; + return (AE_OK); + } + + + /* + * Check for instance out of range + */ + if (instance > acpi_gbl_acpi_tables[table_type].count) { + return (AE_NOT_EXIST); + } + + /* Walk the list to get the desired table + * Since the if (Instance == 1) check above checked for the + * first table, setting Table_desc equal to the .Next member + * is actually pointing to the second table. Therefore, we + * need to walk from the 2nd table until we reach the Instance + * that the user is looking for and return its table pointer. + */ + table_desc = acpi_gbl_acpi_tables[table_type].next; + for (i = 2; i < instance; i++) { + table_desc = table_desc->next; + } + + /* We are now pointing to the requested table's descriptor */ + + *table_ptr_loc = table_desc->pointer; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_table + * + * PARAMETERS: Physical_address - Physical address of table to retrieve + * *Buffer_ptr - If Buffer_ptr is valid, read data from + * buffer rather than searching memory + * *Table_info - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Maps the physical address of table into a logical address + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table ( + ACPI_PHYSICAL_ADDRESS physical_address, + ACPI_TABLE_HEADER *buffer_ptr, + ACPI_TABLE_DESC *table_info) +{ + ACPI_TABLE_HEADER *table_header = NULL; + ACPI_TABLE_HEADER *full_table = NULL; + u32 size; + u8 allocation; + ACPI_STATUS status = AE_OK; + + + if (!table_info) { + return (AE_BAD_PARAMETER); + } + + + if (buffer_ptr) { + /* + * Getting data from a buffer, not BIOS tables + */ + + table_header = buffer_ptr; + status = acpi_tb_validate_table_header (table_header); + if (ACPI_FAILURE (status)) { + /* Table failed verification, map all errors to BAD_DATA */ + + return (AE_BAD_DATA); + } + + /* Allocate buffer for the entire table */ + + full_table = acpi_cm_allocate (table_header->length); + if (!full_table) { + return (AE_NO_MEMORY); + } + + /* Copy the entire table (including header) to the local buffer */ + + size = table_header->length; + MEMCPY (full_table, buffer_ptr, size); + + /* Save allocation type */ + + allocation = ACPI_MEM_ALLOCATED; + } + + + /* + * Not reading from a buffer, just map the table's physical memory + * into our address space. + */ + else { + size = SIZE_IN_HEADER; + + status = acpi_tb_map_acpi_table (physical_address, &size, + (void **) &full_table); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Save allocation type */ + + allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + table_info->pointer = full_table; + table_info->length = size; + table_info->allocation = allocation; + table_info->base_pointer = full_table; + + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_all_tables + * + * PARAMETERS: Number_of_tables - Number of tables to get + * Table_ptr - Input buffer pointer, optional + * + * RETURN: Status + * + * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must + * already be loaded and validated. + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_all_tables ( + u32 number_of_tables, + ACPI_TABLE_HEADER *table_ptr) +{ + ACPI_STATUS status = AE_OK; + u32 index; + ACPI_TABLE_DESC table_info; + + + /* + * Loop through all table pointers found in RSDT. + * This will NOT include the FACS and DSDT - we must get + * them after the loop + */ + + for (index = 0; index < number_of_tables; index++) { + /* Clear the Table_info each time */ + + MEMSET (&table_info, 0, sizeof (ACPI_TABLE_DESC)); + + /* Get the table via the XSDT */ + + status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) + ACPI_GET_ADDRESS (acpi_gbl_XSDT->table_offset_entry[index]), + table_ptr, &table_info); + + /* Ignore a table that failed verification */ + + if (status == AE_BAD_DATA) { + continue; + } + + /* However, abort on serious errors */ + + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Recognize and install the table */ + + status = acpi_tb_install_table (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + /* + * Unrecognized or unsupported table, delete it and ignore the + * error. Just get as many tables as we can, later we will + * determine if there are enough tables to continue. + */ + + acpi_tb_uninstall_table (&table_info); + } + } + + + /* + * Convert the FADT to a common format. This allows earlier revisions of the + * table to coexist with newer versions, using common access code. + */ + status = acpi_tb_convert_table_fadt (); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* + * Get the minimum set of ACPI tables, namely: + * + * 1) FADT (via RSDT in loop above) + * 2) FACS + * 3) DSDT + * + */ + + + /* + * Get the FACS (must have the FADT first, from loop above) + * Acpi_tb_get_table_facs will fail if FADT pointer is not valid + */ + + status = acpi_tb_get_table_facs (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* Install the FACS */ + + status = acpi_tb_install_table (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* + * Create the common FACS pointer table + * (Contains pointers to the original table) + */ + + status = acpi_tb_build_common_facs (&table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* + * Get the DSDT (We know that the FADT is valid now) + */ + + status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xdsdt), + table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Install the DSDT */ + + status = acpi_tb_install_table (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Dump the DSDT Header */ + + /* Dump the entire DSDT */ + + /* + * Initialize the capabilities flags. + * Assumes that platform supports ACPI_MODE since we have tables! + */ + acpi_gbl_system_flags |= acpi_hw_get_mode_capabilities (); + + + /* Always delete the RSDP mapping, we are done with it */ + + acpi_tb_delete_acpi_table (ACPI_TABLE_RSDP); + + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_verify_rsdp + * + * PARAMETERS: Number_of_tables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_verify_rsdp ( + ACPI_PHYSICAL_ADDRESS rsdp_physical_address) +{ + ACPI_TABLE_DESC table_info; + ACPI_STATUS status; + u8 *table_ptr; + + + /* + * Obtain access to the RSDP structure + */ + status = acpi_os_map_memory (rsdp_physical_address, + sizeof (RSDP_DESCRIPTOR), + (void **) &table_ptr); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* + * The signature and checksum must both be correct + */ + if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { + /* Nope, BAD Signature */ + + status = AE_BAD_SIGNATURE; + goto cleanup; + } + + if (acpi_tb_checksum (table_ptr, RSDP_CHECKSUM_LENGTH) != 0) { + /* Nope, BAD Checksum */ + + status = AE_BAD_CHECKSUM; + goto cleanup; + } + + /* TBD: Check extended checksum if table version >= 2 */ + + /* The RSDP supplied is OK */ + + table_info.pointer = (ACPI_TABLE_HEADER *) table_ptr; + table_info.length = sizeof (RSDP_DESCRIPTOR); + table_info.allocation = ACPI_MEM_MAPPED; + table_info.base_pointer = table_ptr; + + /* Save the table pointers and allocation info */ + + status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); + if (ACPI_FAILURE (status)) { + goto cleanup; + } + + + /* Save the RSDP in a global for easy access */ + + acpi_gbl_RSDP = (RSDP_DESCRIPTOR *) table_info.pointer; + return (status); + + + /* Error exit */ +cleanup: + + acpi_os_unmap_memory (table_ptr, sizeof (RSDP_DESCRIPTOR)); + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_table_rsdt + * + * PARAMETERS: Number_of_tables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table_rsdt ( + u32 *number_of_tables) +{ + ACPI_TABLE_DESC table_info; + ACPI_STATUS status = AE_OK; + ACPI_PHYSICAL_ADDRESS physical_address; + u32 signature_length; + char *table_signature; + + + /* + * Get the RSDT from the RSDP + */ + + /* + * For RSDP revision 0 or 1, we use the RSDT. + * For RSDP revision 2 (and above), we use the XSDT + */ + if (acpi_gbl_RSDP->revision < 2) { +#ifdef _IA64 + /* 0.71 RSDP has 64bit Rsdt address field */ + physical_address = ((RSDP_DESCRIPTOR_REV071 *)acpi_gbl_RSDP)->rsdt_physical_address; +#else + physical_address = (ACPI_PHYSICAL_ADDRESS) acpi_gbl_RSDP->rsdt_physical_address; +#endif + table_signature = RSDT_SIG; + signature_length = sizeof (RSDT_SIG) -1; + } + else { + physical_address = (ACPI_PHYSICAL_ADDRESS) + ACPI_GET_ADDRESS (acpi_gbl_RSDP->xsdt_physical_address); + table_signature = XSDT_SIG; + signature_length = sizeof (XSDT_SIG) -1; + } + + + /* Get the RSDT/XSDT */ + + status = acpi_tb_get_table (physical_address, NULL, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* Check the RSDT or XSDT signature */ + + if (STRNCMP ((char *) table_info.pointer, table_signature, + signature_length)) { + /* Invalid RSDT or XSDT signature */ + + REPORT_ERROR (("Invalid signature where RSDP indicates %s should be located\n", + table_signature)); + + return (AE_NO_ACPI_TABLES); + } + + + /* Valid RSDT signature, verify the checksum */ + + status = acpi_tb_verify_table_checksum (table_info.pointer); + + + /* Convert and/or copy to an XSDT structure */ + + status = acpi_tb_convert_to_xsdt (&table_info, number_of_tables); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Save the table pointers and allocation info */ + + status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + acpi_gbl_XSDT = (XSDT_DESCRIPTOR *) table_info.pointer; + + return (status); +} + + +/****************************************************************************** + * + * FUNCTION: Acpi_tb_get_table_facs + * + * PARAMETERS: *Buffer_ptr - If Buffer_ptr is valid, read data from + * buffer rather than searching memory + * *Table_info - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns a pointer to the FACS as defined in FADT. This + * function assumes the global variable FADT has been + * correctly initialized. The value of FADT->Firmware_ctrl + * into a far pointer which is returned. + * + *****************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table_facs ( + ACPI_TABLE_HEADER *buffer_ptr, + ACPI_TABLE_DESC *table_info) +{ + void *table_ptr = NULL; + u32 size; + u8 allocation; + ACPI_STATUS status = AE_OK; + + + /* Must have a valid FADT pointer */ + + if (!acpi_gbl_FADT) { + return (AE_NO_ACPI_TABLES); + } + + size = sizeof (FACS_DESCRIPTOR); + if (buffer_ptr) { + /* + * Getting table from a file -- allocate a buffer and + * read the table. + */ + table_ptr = acpi_cm_allocate (size); + if(!table_ptr) { + return (AE_NO_MEMORY); + } + + MEMCPY (table_ptr, buffer_ptr, size); + + /* Save allocation type */ + + allocation = ACPI_MEM_ALLOCATED; + } + + else { + /* Just map the physical memory to our address space */ + + status = acpi_tb_map_acpi_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xfirmware_ctrl), + &size, &table_ptr); + if (ACPI_FAILURE(status)) { + return (status); + } + + /* Save allocation type */ + + allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + table_info->pointer = table_ptr; + table_info->length = size; + table_info->allocation = allocation; + table_info->base_pointer = table_ptr; + + return (status); +} + diff --git a/drivers/bus/acpi/acpica/tables/tbinstal.c b/drivers/bus/acpi/acpica/tables/tbinstal.c new file mode 100644 index 00000000000..c911f84f68b --- /dev/null +++ b/drivers/bus/acpi/acpica/tables/tbinstal.c @@ -0,0 +1,785 @@ +/****************************************************************************** + * + * Module Name: tbinstal - ACPI table installation and removal + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __TBINSTAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbinstal") + + +/****************************************************************************** + * + * FUNCTION: AcpiTbVerifyTable + * + * PARAMETERS: TableDesc - table + * + * RETURN: Status + * + * DESCRIPTION: this function is called to verify and map table + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (TbVerifyTable); + + + /* Map the table if necessary */ + + if (!TableDesc->Pointer) + { + if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_MAPPED) + { + TableDesc->Pointer = AcpiOsMapMemory ( + TableDesc->Address, TableDesc->Length); + } + + if (!TableDesc->Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* FACS is the odd table, has no standard ACPI header and no checksum */ + + if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS)) + { + /* Always calculate checksum, ignore bad checksum if requested */ + + Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAddTable + * + * PARAMETERS: TableDesc - Table descriptor + * TableIndex - Where the table index is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to add an ACPI table. It is used to + * dynamically load tables via the Load and LoadTable AML + * operators. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAddTable ( + ACPI_TABLE_DESC *TableDesc, + UINT32 *TableIndex) +{ + UINT32 i; + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER *OverrideTable = NULL; + + + ACPI_FUNCTION_TRACE (TbAddTable); + + + if (!TableDesc->Pointer) + { + Status = AcpiTbVerifyTable (TableDesc); + if (ACPI_FAILURE (Status) || !TableDesc->Pointer) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Originally, we checked the table signature for "SSDT" or "PSDT" here. + * Next, we added support for OEMx tables, signature "OEM". + * Valid tables were encountered with a null signature, so we've just + * given up on validating the signature, since it seems to be a waste + * of code. The original code was removed (05/2008). + */ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Check if table is already registered */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_FAILURE (Status) || + !AcpiGbl_RootTableList.Tables[i].Pointer) + { + continue; + } + } + + /* + * Check for a table match on the entire table length, + * not just the header. + */ + if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length) + { + continue; + } + + if (ACPI_MEMCMP (TableDesc->Pointer, + AcpiGbl_RootTableList.Tables[i].Pointer, + AcpiGbl_RootTableList.Tables[i].Length)) + { + continue; + } + + /* + * Note: the current mechanism does not unregister a table if it is + * dynamically unloaded. The related namespace entries are deleted, + * but the table remains in the root table list. + * + * The assumption here is that the number of different tables that + * will be loaded is actually small, and there is minimal overhead + * in just keeping the table in case it is needed again. + * + * If this assumption changes in the future (perhaps on large + * machines with many table load/unload operations), tables will + * need to be unregistered when they are unloaded, and slots in the + * root table list should be reused when empty. + */ + + /* + * Table is already registered. + * We can delete the table that was passed as a parameter. + */ + AcpiTbDeleteTable (TableDesc); + *TableIndex = i; + + if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED) + { + /* Table is still loaded, this is an error */ + + Status = AE_ALREADY_EXISTS; + goto Release; + } + else + { + /* Table was unloaded, allow it to be reloaded */ + + TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer; + TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address; + Status = AE_OK; + goto PrintHeader; + } + } + + /* + * ACPI Table Override: + * Allow the host to override dynamically loaded tables. + */ + Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable); + if (ACPI_SUCCESS (Status) && OverrideTable) + { + ACPI_INFO ((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + TableDesc->Pointer->Signature, + ACPI_CAST_PTR (void, TableDesc->Address))); + + /* We can delete the table that was passed as a parameter */ + + AcpiTbDeleteTable (TableDesc); + + /* Setup descriptor for the new table */ + + TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable); + TableDesc->Pointer = OverrideTable; + TableDesc->Length = OverrideTable->Length; + TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE; + } + + /* Add the table to the global root table list */ + + Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer, + TableDesc->Length, TableDesc->Flags, TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Release; + } + +PrintHeader: + AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); + +Release: + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbResizeRootTableList + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Expand the size of global table array + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbResizeRootTableList ( + void) +{ + ACPI_TABLE_DESC *Tables; + + + ACPI_FUNCTION_TRACE (TbResizeRootTableList); + + + /* AllowResize flag is a parameter to AcpiInitializeTables */ + + if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) + { + ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); + return_ACPI_STATUS (AE_SUPPORT); + } + + /* Increase the Table Array size */ + + Tables = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) AcpiGbl_RootTableList.Size + + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC)); + if (!Tables) + { + ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy and free the previous table array */ + + if (AcpiGbl_RootTableList.Tables) + { + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, + (ACPI_SIZE) AcpiGbl_RootTableList.Size * sizeof (ACPI_TABLE_DESC)); + + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + } + + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.Size += ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbStoreTable + * + * PARAMETERS: Address - Table address + * Table - Table header + * Length - Table length + * Flags - flags + * + * RETURN: Status and table index. + * + * DESCRIPTION: Add an ACPI table to the global table list + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbStoreTable ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Table, + UINT32 Length, + UINT8 Flags, + UINT32 *TableIndex) +{ + ACPI_STATUS Status = AE_OK; + + + /* Ensure that there is room for the table in the Root Table List */ + + if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + { + Status = AcpiTbResizeRootTableList(); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* Initialize added table */ + + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = Address; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Pointer = Table; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Length = Length; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].OwnerId = 0; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Flags = Flags; + + ACPI_MOVE_32_TO_32 ( + &(AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Signature), + Table->Signature); + + *TableIndex = AcpiGbl_RootTableList.Count; + AcpiGbl_RootTableList.Count++; + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteTable + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: None + * + * DESCRIPTION: Delete one internal ACPI table + * + ******************************************************************************/ + +void +AcpiTbDeleteTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + /* Table must be mapped or allocated */ + + if (!TableDesc->Pointer) + { + return; + } + + switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) + { + case ACPI_TABLE_ORIGIN_MAPPED: + AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length); + break; + + case ACPI_TABLE_ORIGIN_ALLOCATED: + ACPI_FREE (TableDesc->Pointer); + break; + + default: + break; + } + + TableDesc->Pointer = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbTerminate + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all internal ACPI tables + * + ******************************************************************************/ + +void +AcpiTbTerminate ( + void) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (TbTerminate); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Delete the individual tables */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; i++) + { + AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); + } + + /* + * Delete the root table array if allocated locally. Array cannot be + * mapped, so we don't need to check for that flag. + */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + + AcpiGbl_RootTableList.Tables = NULL; + AcpiGbl_RootTableList.Flags = 0; + AcpiGbl_RootTableList.Count = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteNamespaceByOwner + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Delete all namespace objects created when this table was loaded. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbDeleteNamespaceByOwner ( + UINT32 TableIndex) +{ + ACPI_OWNER_ID OwnerId; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (TableIndex >= AcpiGbl_RootTableList.Count) + { + /* The table index does not exist */ + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Get the owner ID for this table, used to delete namespace nodes */ + + OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + + /* + * Need to acquire the namespace writer lock to prevent interference + * with any concurrent namespace walks. The interpreter must be + * released during the deletion since the acquisition of the deletion + * lock may block, and also since the execution of a namespace walk + * must be allowed to use the interpreter. + */ + (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); + + AcpiNsDeleteNamespaceByOwner (OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAllocateOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Allocates OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAllocateOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbAllocateOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + Status = AcpiUtAllocateOwnerId + (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbReleaseOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Releases OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbReleaseOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbReleaseOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + AcpiUtReleaseOwnerId ( + &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetOwnerId + * + * PARAMETERS: TableIndex - Table index + * OwnerId - Where the table OwnerId is returned + * + * RETURN: Status + * + * DESCRIPTION: returns OwnerId for the ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetOwnerId ( + UINT32 TableIndex, + ACPI_OWNER_ID *OwnerId) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbGetOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbIsTableLoaded + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Table Loaded Flag + * + ******************************************************************************/ + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex) +{ + BOOLEAN IsLoaded = FALSE; + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + IsLoaded = (BOOLEAN) + (AcpiGbl_RootTableList.Tables[TableIndex].Flags & + ACPI_TABLE_IS_LOADED); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return (IsLoaded); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSetTableLoadedFlag + * + * PARAMETERS: TableIndex - Table index + * IsLoaded - TRUE if table is loaded, FALSE otherwise + * + * RETURN: None + * + * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. + * + ******************************************************************************/ + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded) +{ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + if (IsLoaded) + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags |= + ACPI_TABLE_IS_LOADED; + } + else + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags &= + ~ACPI_TABLE_IS_LOADED; + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); +} + diff --git a/drivers/bus/acpi/acpica/tables/tbutils.c b/drivers/bus/acpi/acpica/tables/tbutils.c new file mode 100644 index 00000000000..ec2a88e283d --- /dev/null +++ b/drivers/bus/acpi/acpica/tables/tbutils.c @@ -0,0 +1,741 @@ +/****************************************************************************** + * + * Module Name: tbutils - table utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbutils") + +/* Local prototypes */ + +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length); + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header); + +static ACPI_PHYSICAL_ADDRESS +AcpiTbGetRootTableEntry ( + UINT8 *TableEntry, + UINT32 TableEntrySize); + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitializeFacs + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global + * for accessing the Global Lock and Firmware Waking Vector + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInitializeFacs ( + void) +{ + ACPI_STATUS Status; + + + Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, + ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_FACS)); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbTablesLoaded + * + * PARAMETERS: None + * + * RETURN: TRUE if required ACPI tables are loaded + * + * DESCRIPTION: Determine if the minimum required ACPI tables are present + * (FADT, FACS, DSDT) + * + ******************************************************************************/ + +BOOLEAN +AcpiTbTablesLoaded ( + void) +{ + + if (AcpiGbl_RootTableList.Count >= 3) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFixString + * + * PARAMETERS: String - String to be repaired + * Length - Maximum length + * + * RETURN: None + * + * DESCRIPTION: Replace every non-printable or non-ascii byte in the string + * with a question mark '?'. + * + ******************************************************************************/ + +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length) +{ + + while (Length && *String) + { + if (!ACPI_IS_PRINT (*String)) + { + *String = '?'; + } + String++; + Length--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCleanupTableHeader + * + * PARAMETERS: OutHeader - Where the cleaned header is returned + * Header - Input ACPI table header + * + * RETURN: Returns the cleaned header in OutHeader + * + * DESCRIPTION: Copy the table header and ensure that all "string" fields in + * the header consist of printable characters. + * + ******************************************************************************/ + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header) +{ + + ACPI_MEMCPY (OutHeader, Header, sizeof (ACPI_TABLE_HEADER)); + + AcpiTbFixString (OutHeader->Signature, ACPI_NAME_SIZE); + AcpiTbFixString (OutHeader->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (OutHeader->OemTableId, ACPI_OEM_TABLE_ID_SIZE); + AcpiTbFixString (OutHeader->AslCompilerId, ACPI_NAME_SIZE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbPrintTableHeader + * + * PARAMETERS: Address - Table physical address + * Header - Table header + * + * RETURN: None + * + * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. + * + ******************************************************************************/ + +void +AcpiTbPrintTableHeader ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Header) +{ + ACPI_TABLE_HEADER LocalHeader; + + + /* + * The reason that the Address is cast to a void pointer is so that we + * can use %p which will work properly on both 32-bit and 64-bit hosts. + */ + if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_FACS)) + { + /* FACS only has signature and length fields */ + + ACPI_INFO ((AE_INFO, "%4.4s %p %05X", + Header->Signature, ACPI_CAST_PTR (void, Address), + Header->Length)); + } + else if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_RSDP)) + { + /* RSDP has no common fields */ + + ACPI_MEMCPY (LocalHeader.OemId, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE); + + ACPI_INFO ((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", + ACPI_CAST_PTR (void, Address), + (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ? + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision, + LocalHeader.OemId)); + } + else + { + /* Standard ACPI table with full common header */ + + AcpiTbCleanupTableHeader (&LocalHeader, Header); + + ACPI_INFO ((AE_INFO, + "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", + LocalHeader.Signature, ACPI_CAST_PTR (void, Address), + LocalHeader.Length, LocalHeader.Revision, LocalHeader.OemId, + LocalHeader.OemTableId, LocalHeader.OemRevision, + LocalHeader.AslCompilerId, LocalHeader.AslCompilerRevision)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateChecksum + * + * PARAMETERS: Table - ACPI table to verify + * Length - Length of entire table + * + * RETURN: Status + * + * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns + * exception on bad checksum. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyChecksum ( + ACPI_TABLE_HEADER *Table, + UINT32 Length) +{ + UINT8 Checksum; + + + /* Compute the checksum on the table */ + + Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Length); + + /* Checksum ok? (should be zero) */ + + if (Checksum) + { + ACPI_WARNING ((AE_INFO, + "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X", + Table->Signature, Table->Checksum, + (UINT8) (Table->Checksum - Checksum))); + +#if (ACPI_CHECKSUM_ABORT) + return (AE_BAD_CHECKSUM); +#endif + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbChecksum + * + * PARAMETERS: Buffer - Pointer to memory region to be checked + * Length - Length of this memory region + * + * RETURN: Checksum (UINT8) + * + * DESCRIPTION: Calculates circular checksum of memory region. + * + ******************************************************************************/ + +UINT8 +AcpiTbChecksum ( + UINT8 *Buffer, + UINT32 Length) +{ + UINT8 Sum = 0; + UINT8 *End = Buffer + Length; + + + while (Buffer < End) + { + Sum = (UINT8) (Sum + *(Buffer++)); + } + + return Sum; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInstallTable + * + * PARAMETERS: Address - Physical address of DSDT or FACS + * Signature - Table signature, NULL if no need to + * match + * TableIndex - Index into root table array + * + * RETURN: None + * + * DESCRIPTION: Install an ACPI table into the global data structure. The + * table override mechanism is implemented here to allow the host + * OS to replace any table before it is installed in the root + * table array. + * + ******************************************************************************/ + +void +AcpiTbInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + char *Signature, + UINT32 TableIndex) +{ + UINT8 Flags; + ACPI_STATUS Status; + ACPI_TABLE_HEADER *TableToInstall; + ACPI_TABLE_HEADER *MappedTable; + ACPI_TABLE_HEADER *OverrideTable = NULL; + + + if (!Address) + { + ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]", + Signature)); + return; + } + + /* Map just the table header */ + + MappedTable = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!MappedTable) + { + return; + } + + /* If a particular signature is expected (DSDT/FACS), it must match */ + + if (Signature && + !ACPI_COMPARE_NAME (MappedTable->Signature, Signature)) + { + ACPI_ERROR ((AE_INFO, + "Invalid signature 0x%X for ACPI table, expected [%s]", + *ACPI_CAST_PTR (UINT32, MappedTable->Signature), Signature)); + goto UnmapAndExit; + } + + /* + * ACPI Table Override: + * + * Before we install the table, let the host OS override it with a new + * one if desired. Any table within the RSDT/XSDT can be replaced, + * including the DSDT which is pointed to by the FADT. + */ + Status = AcpiOsTableOverride (MappedTable, &OverrideTable); + if (ACPI_SUCCESS (Status) && OverrideTable) + { + ACPI_INFO ((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + MappedTable->Signature, ACPI_CAST_PTR (void, Address))); + + AcpiGbl_RootTableList.Tables[TableIndex].Pointer = OverrideTable; + Address = ACPI_PTR_TO_PHYSADDR (OverrideTable); + + TableToInstall = OverrideTable; + Flags = ACPI_TABLE_ORIGIN_OVERRIDE; + } + else + { + TableToInstall = MappedTable; + Flags = ACPI_TABLE_ORIGIN_MAPPED; + } + + /* Initialize the table entry */ + + AcpiGbl_RootTableList.Tables[TableIndex].Address = Address; + AcpiGbl_RootTableList.Tables[TableIndex].Length = TableToInstall->Length; + AcpiGbl_RootTableList.Tables[TableIndex].Flags = Flags; + + ACPI_MOVE_32_TO_32 ( + &(AcpiGbl_RootTableList.Tables[TableIndex].Signature), + TableToInstall->Signature); + + AcpiTbPrintTableHeader (Address, TableToInstall); + + if (TableIndex == ACPI_TABLE_INDEX_DSDT) + { + /* Global integer width is based upon revision of the DSDT */ + + AcpiUtSetIntegerWidth (TableToInstall->Revision); + } + +UnmapAndExit: + AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetRootTableEntry + * + * PARAMETERS: TableEntry - Pointer to the RSDT/XSDT table entry + * TableEntrySize - sizeof 32 or 64 (RSDT or XSDT) + * + * RETURN: Physical address extracted from the root table + * + * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on + * both 32-bit and 64-bit platforms + * + * NOTE: ACPI_PHYSICAL_ADDRESS is 32-bit on 32-bit platforms, 64-bit on + * 64-bit platforms. + * + ******************************************************************************/ + +static ACPI_PHYSICAL_ADDRESS +AcpiTbGetRootTableEntry ( + UINT8 *TableEntry, + UINT32 TableEntrySize) +{ + UINT64 Address64; + + + /* + * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): + * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT + */ + if (TableEntrySize == sizeof (UINT32)) + { + /* + * 32-bit platform, RSDT: Return 32-bit table entry + * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return + */ + return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (UINT32, TableEntry))); + } + else + { + /* + * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return + * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, + * return 64-bit + */ + ACPI_MOVE_64_TO_64 (&Address64, TableEntry); + +#if ACPI_MACHINE_WIDTH == 32 + if (Address64 > ACPI_UINT32_MAX) + { + /* Will truncate 64-bit address to 32 bits, issue warning */ + + ACPI_WARNING ((AE_INFO, + "64-bit Physical Address in XSDT is too large (%8.8X%8.8X)," + " truncating", + ACPI_FORMAT_UINT64 (Address64))); + } +#endif + return ((ACPI_PHYSICAL_ADDRESS) (Address64)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbParseRootTable + * + * PARAMETERS: Rsdp - Pointer to the RSDP + * + * RETURN: Status + * + * DESCRIPTION: This function is called to parse the Root System Description + * Table (RSDT or XSDT) + * + * NOTE: Tables are mapped (not copied) for efficiency. The FACS must + * be mapped and cannot be copied because it contains the actual + * memory location of the ACPI Global Lock. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbParseRootTable ( + ACPI_PHYSICAL_ADDRESS RsdpAddress) +{ + ACPI_TABLE_RSDP *Rsdp; + UINT32 TableEntrySize; + UINT32 i; + UINT32 TableCount; + ACPI_TABLE_HEADER *Table; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + UINT8 *TableEntry; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbParseRootTable); + + + /* + * Map the entire RSDP and extract the address of the RSDT or XSDT + */ + Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP)); + if (!Rsdp) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiTbPrintTableHeader (RsdpAddress, + ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp)); + + /* Differentiate between RSDT and XSDT root tables */ + + if (Rsdp->Revision > 1 && Rsdp->XsdtPhysicalAddress) + { + /* + * Root table is an XSDT (64-bit physical addresses). We must use the + * XSDT if the revision is > 1 and the XSDT pointer is present, as per + * the ACPI specification. + */ + Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress; + TableEntrySize = sizeof (UINT64); + } + else + { + /* Root table is an RSDT (32-bit physical addresses) */ + + Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress; + TableEntrySize = sizeof (UINT32); + } + + /* + * It is not possible to map more than one entry in some environments, + * so unmap the RSDP here before mapping other tables + */ + AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP)); + + + /* Map the RSDT/XSDT table header to get the full table length */ + + Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiTbPrintTableHeader (Address, Table); + + /* Get the length of the full table, verify length and map entire table */ + + Length = Table->Length; + AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + ACPI_ERROR ((AE_INFO, "Invalid length 0x%X in RSDT/XSDT", Length)); + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + Table = AcpiOsMapMemory (Address, Length); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Validate the root table checksum */ + + Status = AcpiTbVerifyChecksum (Table, Length); + if (ACPI_FAILURE (Status)) + { + AcpiOsUnmapMemory (Table, Length); + return_ACPI_STATUS (Status); + } + + /* Calculate the number of tables described in the root table */ + + TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) / + TableEntrySize); + + /* + * First two entries in the table array are reserved for the DSDT + * and FACS, which are not actually present in the RSDT/XSDT - they + * come from the FADT + */ + TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER); + AcpiGbl_RootTableList.Count = 2; + + /* + * Initialize the root table array from the RSDT/XSDT + */ + for (i = 0; i < TableCount; i++) + { + if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + { + /* There is no more room in the root table array, attempt resize */ + + Status = AcpiTbResizeRootTableList (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Truncating %u table entries!", + (unsigned) (TableCount - + (AcpiGbl_RootTableList.Count - 2)))); + break; + } + } + + /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ + + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = + AcpiTbGetRootTableEntry (TableEntry, TableEntrySize); + + TableEntry += TableEntrySize; + AcpiGbl_RootTableList.Count++; + } + + /* + * It is not possible to map more than one entry in some environments, + * so unmap the root table here before mapping other tables + */ + AcpiOsUnmapMemory (Table, Length); + + /* + * Complete the initialization of the root table array by examining + * the header of each table + */ + for (i = 2; i < AcpiGbl_RootTableList.Count; i++) + { + AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, + NULL, i); + + /* Special case for FADT - get the DSDT and FACS */ + + if (ACPI_COMPARE_NAME ( + &AcpiGbl_RootTableList.Tables[i].Signature, ACPI_SIG_FADT)) + { + AcpiTbParseFadt (i); + } + } + + return_ACPI_STATUS (AE_OK); +} diff --git a/drivers/bus/acpi/acpica/tables/tbxface.c b/drivers/bus/acpi/acpica/tables/tbxface.c new file mode 100644 index 00000000000..4c12916c5ac --- /dev/null +++ b/drivers/bus/acpi/acpica/tables/tbxface.c @@ -0,0 +1,750 @@ +/****************************************************************************** + * + * Module Name: tbxface - Public interfaces to the ACPI subsystem + * ACPI table oriented interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbxface") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbLoadNamespace ( + void); + + +/******************************************************************************* + * + * FUNCTION: AcpiAllocateRootTable + * + * PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of + * ACPI_TABLE_DESC structures + * + * RETURN: Status + * + * DESCRIPTION: Allocate a root table array. Used by iASL compiler and + * AcpiInitializeTables. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAllocateRootTable ( + UINT32 InitialTableCount) +{ + + AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE; + + return (AcpiTbResizeRootTableList ()); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiInitializeTables + * + * PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated + * ACPI_TABLE_DESC structures. If NULL, the + * array is dynamically allocated. + * InitialTableCount - Size of InitialTableArray, in number of + * ACPI_TABLE_DESC structures + * AllowRealloc - Flag to tell Table Manager if resize of + * pre-allocated array is allowed. Ignored + * if InitialTableArray is NULL. + * + * RETURN: Status + * + * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT. + * + * NOTE: Allows static allocation of the initial table array in order + * to avoid the use of dynamic memory in confined environments + * such as the kernel boot sequence where it may not be available. + * + * If the host OS memory managers are initialized, use NULL for + * InitialTableArray, and the table will be dynamically allocated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInitializeTables ( + ACPI_TABLE_DESC *InitialTableArray, + UINT32 InitialTableCount, + BOOLEAN AllowResize) +{ + ACPI_PHYSICAL_ADDRESS RsdpAddress; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInitializeTables); + + + /* + * Set up the Root Table Array + * Allocate the table array if requested + */ + if (!InitialTableArray) + { + Status = AcpiAllocateRootTable (InitialTableCount); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* Root Table Array has been statically allocated by the host */ + + ACPI_MEMSET (InitialTableArray, 0, + (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC)); + + AcpiGbl_RootTableList.Tables = InitialTableArray; + AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN; + if (AllowResize) + { + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; + } + } + + /* Get the address of the RSDP */ + + RsdpAddress = AcpiOsGetRootPointer (); + if (!RsdpAddress) + { + return_ACPI_STATUS (AE_NOT_FOUND); + } + + /* + * Get the root table (RSDT or XSDT) and extract all entries to the local + * Root Table Array. This array contains the information of the RSDT/XSDT + * in a common, more useable format. + */ + Status = AcpiTbParseRootTable (RsdpAddress); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInitializeTables) + + +/******************************************************************************* + * + * FUNCTION: AcpiReallocateRootTable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the + * root list from the previously provided scratch area. Should + * be called once dynamic memory allocation is available in the + * kernel + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReallocateRootTable ( + void) +{ + ACPI_TABLE_DESC *Tables; + ACPI_SIZE NewSize; + + + ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); + + + /* + * Only reallocate the root table if the host provided a static buffer + * for the table array in the call to AcpiInitializeTables. + */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + return_ACPI_STATUS (AE_SUPPORT); + } + + NewSize = ((ACPI_SIZE) AcpiGbl_RootTableList.Count + + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC); + + /* Create new array and copy the old array */ + + Tables = ACPI_ALLOCATE_ZEROED (NewSize); + if (!Tables) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, NewSize); + + AcpiGbl_RootTableList.Size = AcpiGbl_RootTableList.Count; + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.Flags = + ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTableHeader + * + * PARAMETERS: Signature - ACPI signature of needed table + * Instance - Which instance (for SSDTs) + * OutTableHeader - The pointer to the table header to fill + * + * RETURN: Status and pointer to mapped table header + * + * DESCRIPTION: Finds an ACPI table header. + * + * NOTE: Caller is responsible in unmapping the header with + * AcpiOsUnmapMemory + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTableHeader ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader) +{ + UINT32 i; + UINT32 j; + ACPI_TABLE_HEADER *Header; + + + /* Parameter validation */ + + if (!Signature || !OutTableHeader) + { + return (AE_BAD_PARAMETER); + } + + /* Walk the root table list */ + + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + { + if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + Signature)) + { + continue; + } + + if (++j < Instance) + { + continue; + } + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + if ((AcpiGbl_RootTableList.Tables[i].Flags & + ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_MAPPED) + { + Header = AcpiOsMapMemory ( + AcpiGbl_RootTableList.Tables[i].Address, + sizeof (ACPI_TABLE_HEADER)); + if (!Header) + { + return AE_NO_MEMORY; + } + + ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER)); + AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER)); + } + else + { + return AE_NOT_FOUND; + } + } + else + { + ACPI_MEMCPY (OutTableHeader, + AcpiGbl_RootTableList.Tables[i].Pointer, + sizeof(ACPI_TABLE_HEADER)); + } + + return (AE_OK); + } + + return (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTable + * + * PARAMETERS: Signature - ACPI signature of needed table + * Instance - Which instance (for SSDTs) + * OutTable - Where the pointer to the table is returned + * + * RETURN: Status and pointer to table + * + * DESCRIPTION: Finds and verifies an ACPI table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTable ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **OutTable) +{ + UINT32 i; + UINT32 j; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Signature || !OutTable) + { + return (AE_BAD_PARAMETER); + } + + /* Walk the root table list */ + + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + { + if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + Signature)) + { + continue; + } + + if (++j < Instance) + { + continue; + } + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_SUCCESS (Status)) + { + *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer; + } + + return (Status); + } + + return (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTableByIndex + * + * PARAMETERS: TableIndex - Table index + * Table - Where the pointer to the table is returned + * + * RETURN: Status and pointer to the table + * + * DESCRIPTION: Obtain a table by an index into the global table list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTableByIndex ( + UINT32 TableIndex, + ACPI_TABLE_HEADER **Table) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetTableByIndex); + + + /* Parameter validation */ + + if (!Table) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Validate index */ + + if (TableIndex >= AcpiGbl_RootTableList.Count) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer) + { + /* Table is not mapped, map it */ + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + if (ACPI_FAILURE (Status)) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); + } + } + + *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbLoadNamespace + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in + * the RSDT/XSDT. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiTbLoadNamespace ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (TbLoadNamespace); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* + * Load the namespace. The DSDT is required, but any SSDT and PSDT tables + * are optional. + */ + if (!AcpiGbl_RootTableList.Count || + !ACPI_COMPARE_NAME ( + &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), + ACPI_SIG_DSDT) || + ACPI_FAILURE (AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) + { + Status = AE_NO_ACPI_TABLES; + goto UnlockAndExit; + } + + /* A valid DSDT is required */ + + Status = AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); + if (ACPI_FAILURE (Status)) + { + Status = AE_NO_ACPI_TABLES; + goto UnlockAndExit; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + + /* Load and parse tables */ + + Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + ACPI_SIG_SSDT) && + !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + ACPI_SIG_PSDT)) || + ACPI_FAILURE (AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[i]))) + { + continue; + } + + /* Ignore errors while loading tables, get as many as possible */ + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + (void) AcpiNsLoadTable (i, AcpiGbl_RootNode); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiLoadTables + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLoadTables ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiLoadTables); + + + /* Load the namespace from the tables */ + + Status = AcpiTbLoadNamespace (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While loading namespace from ACPI tables")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiLoadTables) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallTableHandler + * + * PARAMETERS: Handler - Table event handler + * Context - Value passed to the handler on each event + * + * RETURN: Status + * + * DESCRIPTION: Install table event handler + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallTableHandler ( + ACPI_TABLE_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallTableHandler); + + + if (!Handler) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow more than one handler */ + + if (AcpiGbl_TableHandler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_TableHandler = Handler; + AcpiGbl_TableHandlerContext = Context; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveTableHandler + * + * PARAMETERS: Handler - Table event handler that was installed + * previously. + * + * RETURN: Status + * + * DESCRIPTION: Remove table event handler + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveTableHandler ( + ACPI_TABLE_HANDLER Handler) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Make sure that the installed handler is the same */ + + if (!Handler || + Handler != AcpiGbl_TableHandler) + { + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* Remove the handler */ + + AcpiGbl_TableHandler = NULL; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler) + diff --git a/drivers/bus/acpi/acpica/tables/tbxfroot.c b/drivers/bus/acpi/acpica/tables/tbxfroot.c new file mode 100644 index 00000000000..e0a571f36f4 --- /dev/null +++ b/drivers/bus/acpi/acpica/tables/tbxfroot.c @@ -0,0 +1,371 @@ +/****************************************************************************** + * + * Module Name: tbxfroot - Find the root ACPI table (RSDT) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBXFROOT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbxfroot") + +/* Local prototypes */ + +static UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length); + +static ACPI_STATUS +AcpiTbValidateRsdp ( + ACPI_TABLE_RSDP *Rsdp); + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateRsdp + * + * PARAMETERS: Rsdp - Pointer to unvalidated RSDP + * + * RETURN: Status + * + * DESCRIPTION: Validate the RSDP (ptr) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiTbValidateRsdp ( + ACPI_TABLE_RSDP *Rsdp) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * The signature and checksum must both be correct + * + * Note: Sometimes there exists more than one RSDP in memory; the valid + * RSDP has a valid checksum, all others have an invalid checksum. + */ + if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP, + sizeof (ACPI_SIG_RSDP)-1) != 0) + { + /* Nope, BAD Signature */ + + return (AE_BAD_SIGNATURE); + } + + /* Check the standard checksum */ + + if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + { + return (AE_BAD_CHECKSUM); + } + + /* Check extended checksum if table version >= 2 */ + + if ((Rsdp->Revision >= 2) && + (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) + { + return (AE_BAD_CHECKSUM); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiFindRootPointer + * + * PARAMETERS: TableAddress - Where the table pointer is returned + * + * RETURN: Status, RSDP physical address + * + * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor + * pointer structure. If it is found, set *RSDP to point to it. + * + * NOTE1: The RSDP must be either in the first 1K of the Extended + * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) + * Only a 32-bit physical address is necessary. + * + * NOTE2: This function is always available, regardless of the + * initialization state of the rest of ACPI. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiFindRootPointer ( + ACPI_SIZE *TableAddress) +{ + UINT8 *TablePtr; + UINT8 *MemRover; + UINT32 PhysicalAddress; + + + ACPI_FUNCTION_TRACE (AcpiFindRootPointer); + + + /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ + + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH); + if (!TablePtr) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr); + + /* Convert segment part to physical address */ + + PhysicalAddress <<= 4; + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH); + + /* EBDA present? */ + + if (PhysicalAddress > 0x400) + { + /* + * 1b) Search EBDA paragraphs (EBDA is required to be a + * minimum of 1K length) + */ + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, + ACPI_EBDA_WINDOW_SIZE); + if (!TablePtr) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE); + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); + + if (MemRover) + { + /* Return the physical address */ + + PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr); + + *TableAddress = PhysicalAddress; + return_ACPI_STATUS (AE_OK); + } + } + + /* + * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh + */ + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE); + + if (!TablePtr) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); + AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); + + if (MemRover) + { + /* Return the physical address */ + + PhysicalAddress = (UINT32) + (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr)); + + *TableAddress = PhysicalAddress; + return_ACPI_STATUS (AE_OK); + } + + /* A valid RSDP was not found */ + + ACPI_ERROR ((AE_INFO, "A valid RSDP was not found")); + return_ACPI_STATUS (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL (AcpiFindRootPointer) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbScanMemoryForRsdp + * + * PARAMETERS: StartAddress - Starting pointer for search + * Length - Maximum length to search + * + * RETURN: Pointer to the RSDP if found, otherwise NULL. + * + * DESCRIPTION: Search a block of memory for the RSDP signature + * + ******************************************************************************/ + +static UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length) +{ + ACPI_STATUS Status; + UINT8 *MemRover; + UINT8 *EndAddress; + + + ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp); + + + EndAddress = StartAddress + Length; + + /* Search from given start address for the requested length */ + + for (MemRover = StartAddress; MemRover < EndAddress; + MemRover += ACPI_RSDP_SCAN_STEP) + { + /* The RSDP signature and checksum must both be correct */ + + Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover)); + if (ACPI_SUCCESS (Status)) + { + /* Sig and checksum valid, we have found a real RSDP */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "RSDP located at physical address %p\n", MemRover)); + return_PTR (MemRover); + } + + /* No sig match or bad checksum, keep searching */ + } + + /* Searched entire block, no RSDP was found */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Searched entire block from %p, valid RSDP was not found\n", + StartAddress)); + return_PTR (NULL); +} + diff --git a/drivers/bus/acpi/acpica/utilities/utalloc.c b/drivers/bus/acpi/acpica/utilities/utalloc.c new file mode 100644 index 00000000000..a66b94005c1 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utalloc.c @@ -0,0 +1,488 @@ +/****************************************************************************** + * + * Module Name: utalloc - local memory allocation routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTALLOC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdebug.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utalloc") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateCaches + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create all local caches + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateCaches ( + void) +{ + ACPI_STATUS Status; + + + /* Object Caches, for frequently used objects */ + + Status = AcpiOsCreateCache ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), + ACPI_MAX_NAMESPACE_CACHE_DEPTH, &AcpiGbl_NamespaceCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-State", sizeof (ACPI_GENERIC_STATE), + ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-Parse", sizeof (ACPI_PARSE_OBJ_COMMON), + ACPI_MAX_PARSE_CACHE_DEPTH, &AcpiGbl_PsNodeCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-ParseExt", sizeof (ACPI_PARSE_OBJ_NAMED), + ACPI_MAX_EXTPARSE_CACHE_DEPTH, &AcpiGbl_PsNodeExtCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-Operand", sizeof (ACPI_OPERAND_OBJECT), + ACPI_MAX_OBJECT_CACHE_DEPTH, &AcpiGbl_OperandCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Memory allocation lists */ + + Status = AcpiUtCreateList ("Acpi-Global", 0, + &AcpiGbl_GlobalList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), + &AcpiGbl_NsNodeList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } +#endif + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteCaches + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Purge and delete all local caches + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtDeleteCaches ( + void) +{ +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + char Buffer[7]; + + if (AcpiGbl_DisplayFinalMemStats) + { + ACPI_STRCPY (Buffer, "MEMORY"); + (void) AcpiDbDisplayStatistics (Buffer); + } +#endif + + (void) AcpiOsDeleteCache (AcpiGbl_NamespaceCache); + AcpiGbl_NamespaceCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_StateCache); + AcpiGbl_StateCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_OperandCache); + AcpiGbl_OperandCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_PsNodeCache); + AcpiGbl_PsNodeCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_PsNodeExtCache); + AcpiGbl_PsNodeExtCache = NULL; + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Debug only - display leftover memory allocation, if any */ + + AcpiUtDumpAllocations (ACPI_UINT32_MAX, NULL); + + /* Free memory lists */ + + AcpiOsFree (AcpiGbl_GlobalList); + AcpiGbl_GlobalList = NULL; + + AcpiOsFree (AcpiGbl_NsNodeList); + AcpiGbl_NsNodeList = NULL; +#endif + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidateBuffer + * + * PARAMETERS: Buffer - Buffer descriptor to be validated + * + * RETURN: Status + * + * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtValidateBuffer ( + ACPI_BUFFER *Buffer) +{ + + /* Obviously, the structure pointer must be valid */ + + if (!Buffer) + { + return (AE_BAD_PARAMETER); + } + + /* Special semantics for the length */ + + if ((Buffer->Length == ACPI_NO_BUFFER) || + (Buffer->Length == ACPI_ALLOCATE_BUFFER) || + (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER)) + { + return (AE_OK); + } + + /* Length is valid, the buffer pointer must be also */ + + if (!Buffer->Pointer) + { + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInitializeBuffer + * + * PARAMETERS: Buffer - Buffer to be validated + * RequiredLength - Length needed + * + * RETURN: Status + * + * DESCRIPTION: Validate that the buffer is of the required length or + * allocate a new buffer. Returned buffer is always zeroed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtInitializeBuffer ( + ACPI_BUFFER *Buffer, + ACPI_SIZE RequiredLength) +{ + ACPI_SIZE InputBufferLength; + + + /* Parameter validation */ + + if (!Buffer || !RequiredLength) + { + return (AE_BAD_PARAMETER); + } + + /* + * Buffer->Length is used as both an input and output parameter. Get the + * input actual length and set the output required buffer length. + */ + InputBufferLength = Buffer->Length; + Buffer->Length = RequiredLength; + + /* + * The input buffer length contains the actual buffer length, or the type + * of buffer to be allocated by this routine. + */ + switch (InputBufferLength) + { + case ACPI_NO_BUFFER: + + /* Return the exception (and the required buffer length) */ + + return (AE_BUFFER_OVERFLOW); + + case ACPI_ALLOCATE_BUFFER: + + /* Allocate a new buffer */ + + Buffer->Pointer = AcpiOsAllocate (RequiredLength); + break; + + case ACPI_ALLOCATE_LOCAL_BUFFER: + + /* Allocate a new buffer with local interface to allow tracking */ + + Buffer->Pointer = ACPI_ALLOCATE (RequiredLength); + break; + + default: + + /* Existing buffer: Validate the size of the buffer */ + + if (InputBufferLength < RequiredLength) + { + return (AE_BUFFER_OVERFLOW); + } + break; + } + + /* Validate allocation from above or input buffer pointer */ + + if (!Buffer->Pointer) + { + return (AE_NO_MEMORY); + } + + /* Have a valid buffer, clear it */ + + ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocate + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of malloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocate ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + void *Allocation; + + + ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size); + + + /* Check for an inadvertent size of zero bytes */ + + if (!Size) + { + ACPI_WARNING ((Module, Line, + "Attempt to allocate zero bytes, allocating 1 byte")); + Size = 1; + } + + Allocation = AcpiOsAllocate (Size); + if (!Allocation) + { + /* Report allocation error */ + + ACPI_WARNING ((Module, Line, + "Could not allocate size %X", (UINT32) Size)); + + return_PTR (NULL); + } + + return_PTR (Allocation); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateZeroed + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory. + * + ******************************************************************************/ + +void * +AcpiUtAllocateZeroed ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + void *Allocation; + + + ACPI_FUNCTION_ENTRY (); + + + Allocation = AcpiUtAllocate (Size, Component, Module, Line); + if (Allocation) + { + /* Clear the memory block */ + + ACPI_MEMSET (Allocation, 0, Size); + } + + return (Allocation); +} + diff --git a/drivers/bus/acpi/acpica/utilities/utcache.c b/drivers/bus/acpi/acpica/utilities/utcache.c new file mode 100644 index 00000000000..aabc0a23052 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utcache.c @@ -0,0 +1,433 @@ +/****************************************************************************** + * + * Module Name: utcache - local cache allocation routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTCACHE_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utcache") + + +#ifdef ACPI_USE_LOCAL_CACHE +/******************************************************************************* + * + * FUNCTION: AcpiOsCreateCache + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * MaxDepth - Maximum depth of the cache (in objects) + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a cache object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_MEMORY_LIST **ReturnCache) +{ + ACPI_MEMORY_LIST *Cache; + + + ACPI_FUNCTION_ENTRY (); + + + if (!CacheName || !ReturnCache || (ObjectSize < 16)) + { + return (AE_BAD_PARAMETER); + } + + /* Create the cache object */ + + Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); + if (!Cache) + { + return (AE_NO_MEMORY); + } + + /* Populate the cache object and return it */ + + ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + Cache->LinkOffset = 8; + Cache->ListName = CacheName; + Cache->ObjectSize = ObjectSize; + Cache->MaxDepth = MaxDepth; + + *ReturnCache = Cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsPurgeCache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_MEMORY_LIST *Cache) +{ + char *Next; + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Cache) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Walk the list of objects in this cache */ + + while (Cache->ListHead) + { + /* Delete and unlink one cached state object */ + + Next = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Cache->ListHead)[Cache->LinkOffset]))); + ACPI_FREE (Cache->ListHead); + + Cache->ListHead = Next; + Cache->CurrentDepth--; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsDeleteCache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache and delete the + * cache object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_MEMORY_LIST *Cache) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + /* Purge all objects in the cache */ + + Status = AcpiOsPurgeCache (Cache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Now we can delete the cache object */ + + AcpiOsFree (Cache); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsReleaseObject + * + * PARAMETERS: Cache - Handle to cache object + * Object - The object to be released + * + * RETURN: None + * + * DESCRIPTION: Release an object to the specified cache. If cache is full, + * the object is deleted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_MEMORY_LIST *Cache, + void *Object) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Cache || !Object) + { + return (AE_BAD_PARAMETER); + } + + /* If cache is full, just free this object */ + + if (Cache->CurrentDepth >= Cache->MaxDepth) + { + ACPI_FREE (Object); + ACPI_MEM_TRACKING (Cache->TotalFreed++); + } + + /* Otherwise put this object back into the cache */ + + else + { + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Mark the object as cached */ + + ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize); + ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED); + + /* Put the object at the head of the cache list */ + + * (ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[Cache->LinkOffset]))) = Cache->ListHead; + Cache->ListHead = Object; + Cache->CurrentDepth++; + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsAcquireObject + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: the acquired object. NULL on error + * + * DESCRIPTION: Get an object from the specified cache. If cache is empty, + * the object is allocated. + * + ******************************************************************************/ + +void * +AcpiOsAcquireObject ( + ACPI_MEMORY_LIST *Cache) +{ + ACPI_STATUS Status; + void *Object; + + + ACPI_FUNCTION_NAME (OsAcquireObject); + + + if (!Cache) + { + return (NULL); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + ACPI_MEM_TRACKING (Cache->Requests++); + + /* Check the cache first */ + + if (Cache->ListHead) + { + /* There is an object available, use it */ + + Object = Cache->ListHead; + Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[Cache->LinkOffset]))); + + Cache->CurrentDepth--; + + ACPI_MEM_TRACKING (Cache->Hits++); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p from %s cache\n", Object, Cache->ListName)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + /* Clear (zero) the previously used Object */ + + ACPI_MEMSET (Object, 0, Cache->ObjectSize); + } + else + { + /* The cache is empty, create a new object */ + + ACPI_MEM_TRACKING (Cache->TotalAllocated++); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + if ((Cache->TotalAllocated - Cache->TotalFreed) > Cache->MaxOccupied) + { + Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed; + } +#endif + + /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */ + + Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize); + if (!Object) + { + return (NULL); + } + } + + return (Object); +} +#endif /* ACPI_USE_LOCAL_CACHE */ + + diff --git a/drivers/bus/acpi/acpica/utilities/utclib.c b/drivers/bus/acpi/acpica/utilities/utclib.c new file mode 100644 index 00000000000..a9b8122fab8 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utclib.c @@ -0,0 +1,961 @@ +/****************************************************************************** + * + * Module Name: cmclib - Local implementation of C library functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMCLIB_C__ + +#include "acpi.h" +#include "accommon.h" + +/* + * These implementations of standard C Library routines can optionally be + * used if a C library is not available. In general, they are less efficient + * than an inline or assembly implementation + */ + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("cmclib") + + +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +#define NEGATIVE 1 +#define POSITIVE 0 + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemcmp (memcmp) + * + * PARAMETERS: Buffer1 - First Buffer + * Buffer2 - Second Buffer + * Count - Maximum # of bytes to compare + * + * RETURN: Index where Buffers mismatched, or 0 if Buffers matched + * + * DESCRIPTION: Compare two Buffers, with a maximum length + * + ******************************************************************************/ + +int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count) +{ + + for ( ; Count-- && (*Buffer1 == *Buffer2); Buffer1++, Buffer2++) + { + } + + return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *Buffer1 - + (unsigned char) *Buffer2)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemcpy (memcpy) + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory + * + ******************************************************************************/ + +void * +AcpiUtMemcpy ( + void *Dest, + const void *Src, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + char *Old = (char *) Src; + + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemset (memset) + * + * PARAMETERS: Dest - Buffer to set + * Value - Value to set each byte of memory + * Count - Number of bytes to set + * + * RETURN: Dest + * + * DESCRIPTION: Initialize a buffer to a known value. + * + ******************************************************************************/ + +void * +AcpiUtMemset ( + void *Dest, + UINT8 Value, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + + + while (Count) + { + *New = (char) Value; + New++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrlen (strlen) + * + * PARAMETERS: String - Null terminated string + * + * RETURN: Length + * + * DESCRIPTION: Returns the length of the input string + * + ******************************************************************************/ + + +ACPI_SIZE +AcpiUtStrlen ( + const char *String) +{ + UINT32 Length = 0; + + + /* Count the string until a null is encountered */ + + while (*String) + { + Length++; + String++; + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcpy (strcpy) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string + * + ******************************************************************************/ + +char * +AcpiUtStrcpy ( + char *DstString, + const char *SrcString) +{ + char *String = DstString; + + + /* Move bytes brute force */ + + while (*SrcString) + { + *String = *SrcString; + + String++; + SrcString++; + } + + /* Null terminate */ + + *String = 0; + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncpy (strncpy) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string, with a maximum length + * + ******************************************************************************/ + +char * +AcpiUtStrncpy ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count) +{ + char *String = DstString; + + + /* Copy the string */ + + for (String = DstString; + Count && (Count--, (*String++ = *SrcString++)); ) + {;} + + /* Pad with nulls if necessary */ + + while (Count--) + { + *String = 0; + String++; + } + + /* Return original pointer */ + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcmp (strcmp) + * + * PARAMETERS: String1 - First string + * String2 - Second string + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings + * + ******************************************************************************/ + +int +AcpiUtStrcmp ( + const char *String1, + const char *String2) +{ + + + for ( ; (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((unsigned char) *String1 - (unsigned char) *String2); +} + + +#ifdef ACPI_FUTURE_IMPLEMENTATION +/* Not used at this time */ +/******************************************************************************* + * + * FUNCTION: AcpiUtStrchr (strchr) + * + * PARAMETERS: String - Search string + * ch - character to search for + * + * RETURN: Ptr to char or NULL if not found + * + * DESCRIPTION: Search a string for a character + * + ******************************************************************************/ + +char * +AcpiUtStrchr ( + const char *String, + int ch) +{ + + + for ( ; (*String); String++) + { + if ((*String) == (char) ch) + { + return ((char *) String); + } + } + + return (NULL); +} +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncmp (strncmp) + * + * PARAMETERS: String1 - First string + * String2 - Second string + * Count - Maximum # of bytes to compare + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings, with a maximum length + * + ******************************************************************************/ + +int +AcpiUtStrncmp ( + const char *String1, + const char *String2, + ACPI_SIZE Count) +{ + + + for ( ; Count-- && (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *String1 - + (unsigned char) *String2)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcat (Strcat) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string + * + ******************************************************************************/ + +char * +AcpiUtStrcat ( + char *DstString, + const char *SrcString) +{ + char *String; + + + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatenate the string */ + + for (--String; (*String++ = *SrcString++); ) + { ; } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncat (strncat) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string, + * with a maximum count. + * + ******************************************************************************/ + +char * +AcpiUtStrncat ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count) +{ + char *String; + + + if (Count) + { + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatenate the string */ + + for (--String; (*String++ = *SrcString++) && --Count; ) + { ; } + + /* Null terminate if necessary */ + + if (!Count) + { + *String = 0; + } + } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrstr (strstr) + * + * PARAMETERS: String1 - Target string + * String2 - Substring to search for + * + * RETURN: Where substring match starts, Null if no match found + * + * DESCRIPTION: Checks if String2 occurs in String1. This is not really a + * full implementation of strstr, only sufficient for command + * matching + * + ******************************************************************************/ + +char * +AcpiUtStrstr ( + char *String1, + char *String2) +{ + char *String; + + + if (AcpiUtStrlen (String2) > AcpiUtStrlen (String1)) + { + return (NULL); + } + + /* Walk entire string, comparing the letters */ + + for (String = String1; *String2; ) + { + if (*String2 != *String) + { + return (NULL); + } + + String2++; + String++; + } + + return (String1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoul (strtoul) + * + * PARAMETERS: String - Null terminated string + * Terminater - Where a pointer to the terminating byte is + * returned + * Base - Radix of the string + * + * RETURN: Converted value + * + * DESCRIPTION: Convert a string into a 32-bit unsigned value. + * Note: use AcpiUtStrtoul64 for 64-bit integers. + * + ******************************************************************************/ + +UINT32 +AcpiUtStrtoul ( + const char *String, + char **Terminator, + UINT32 Base) +{ + UINT32 converted = 0; + UINT32 index; + UINT32 sign; + const char *StringStart; + UINT32 ReturnValue = 0; + ACPI_STATUS Status = AE_OK; + + + /* + * Save the value of the pointer to the buffer's first + * character, save the current errno value, and then + * skip over any white space in the buffer: + */ + StringStart = String; + while (ACPI_IS_SPACE (*String) || *String == '\t') + { + ++String; + } + + /* + * The buffer may contain an optional plus or minus sign. + * If it does, then skip over it but remember what is was: + */ + if (*String == '-') + { + sign = NEGATIVE; + ++String; + } + else if (*String == '+') + { + ++String; + sign = POSITIVE; + } + else + { + sign = POSITIVE; + } + + /* + * If the input parameter Base is zero, then we need to + * determine if it is octal, decimal, or hexadecimal: + */ + if (Base == 0) + { + if (*String == '0') + { + if (AcpiUtToLower (*(++String)) == 'x') + { + Base = 16; + ++String; + } + else + { + Base = 8; + } + } + else + { + Base = 10; + } + } + else if (Base < 2 || Base > 36) + { + /* + * The specified Base parameter is not in the domain of + * this function: + */ + goto done; + } + + /* + * For octal and hexadecimal bases, skip over the leading + * 0 or 0x, if they are present. + */ + if (Base == 8 && *String == '0') + { + String++; + } + + if (Base == 16 && + *String == '0' && + AcpiUtToLower (*(++String)) == 'x') + { + String++; + } + + /* + * Main loop: convert the string to an unsigned long: + */ + while (*String) + { + if (ACPI_IS_DIGIT (*String)) + { + index = (UINT32) ((UINT8) *String - '0'); + } + else + { + index = (UINT32) AcpiUtToUpper (*String); + if (ACPI_IS_UPPER (index)) + { + index = index - 'A' + 10; + } + else + { + goto done; + } + } + + if (index >= Base) + { + goto done; + } + + /* + * Check to see if value is out of range: + */ + + if (ReturnValue > ((ACPI_UINT32_MAX - (UINT32) index) / + (UINT32) Base)) + { + Status = AE_ERROR; + ReturnValue = 0; /* reset */ + } + else + { + ReturnValue *= Base; + ReturnValue += index; + converted = 1; + } + + ++String; + } + +done: + /* + * If appropriate, update the caller's pointer to the next + * unconverted character in the buffer. + */ + if (Terminator) + { + if (converted == 0 && ReturnValue == 0 && String != NULL) + { + *Terminator = (char *) StringStart; + } + else + { + *Terminator = (char *) String; + } + } + + if (Status == AE_ERROR) + { + ReturnValue = ACPI_UINT32_MAX; + } + + /* + * If a minus sign was present, then "the conversion is negated": + */ + if (sign == NEGATIVE) + { + ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; + } + + return (ReturnValue); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtToUpper (TOUPPER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to uppercase + * + ******************************************************************************/ + +int +AcpiUtToUpper ( + int c) +{ + + return (ACPI_IS_LOWER(c) ? ((c)-0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtToLower (TOLOWER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to lowercase + * + ******************************************************************************/ + +int +AcpiUtToLower ( + int c) +{ + + return (ACPI_IS_UPPER(c) ? ((c)+0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: is* functions + * + * DESCRIPTION: is* functions use the ctype table below + * + ******************************************************************************/ + +const UINT8 _acpi_ctype[257] = { + _ACPI_CN, /* 0x0 0. */ + _ACPI_CN, /* 0x1 1. */ + _ACPI_CN, /* 0x2 2. */ + _ACPI_CN, /* 0x3 3. */ + _ACPI_CN, /* 0x4 4. */ + _ACPI_CN, /* 0x5 5. */ + _ACPI_CN, /* 0x6 6. */ + _ACPI_CN, /* 0x7 7. */ + _ACPI_CN, /* 0x8 8. */ + _ACPI_CN|_ACPI_SP, /* 0x9 9. */ + _ACPI_CN|_ACPI_SP, /* 0xA 10. */ + _ACPI_CN|_ACPI_SP, /* 0xB 11. */ + _ACPI_CN|_ACPI_SP, /* 0xC 12. */ + _ACPI_CN|_ACPI_SP, /* 0xD 13. */ + _ACPI_CN, /* 0xE 14. */ + _ACPI_CN, /* 0xF 15. */ + _ACPI_CN, /* 0x10 16. */ + _ACPI_CN, /* 0x11 17. */ + _ACPI_CN, /* 0x12 18. */ + _ACPI_CN, /* 0x13 19. */ + _ACPI_CN, /* 0x14 20. */ + _ACPI_CN, /* 0x15 21. */ + _ACPI_CN, /* 0x16 22. */ + _ACPI_CN, /* 0x17 23. */ + _ACPI_CN, /* 0x18 24. */ + _ACPI_CN, /* 0x19 25. */ + _ACPI_CN, /* 0x1A 26. */ + _ACPI_CN, /* 0x1B 27. */ + _ACPI_CN, /* 0x1C 28. */ + _ACPI_CN, /* 0x1D 29. */ + _ACPI_CN, /* 0x1E 30. */ + _ACPI_CN, /* 0x1F 31. */ + _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ + _ACPI_PU, /* 0x21 33. '!' */ + _ACPI_PU, /* 0x22 34. '"' */ + _ACPI_PU, /* 0x23 35. '#' */ + _ACPI_PU, /* 0x24 36. '$' */ + _ACPI_PU, /* 0x25 37. '%' */ + _ACPI_PU, /* 0x26 38. '&' */ + _ACPI_PU, /* 0x27 39. ''' */ + _ACPI_PU, /* 0x28 40. '(' */ + _ACPI_PU, /* 0x29 41. ')' */ + _ACPI_PU, /* 0x2A 42. '*' */ + _ACPI_PU, /* 0x2B 43. '+' */ + _ACPI_PU, /* 0x2C 44. ',' */ + _ACPI_PU, /* 0x2D 45. '-' */ + _ACPI_PU, /* 0x2E 46. '.' */ + _ACPI_PU, /* 0x2F 47. '/' */ + _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ + _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ + _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ + _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ + _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ + _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ + _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ + _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ + _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ + _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ + _ACPI_PU, /* 0x3A 58. ':' */ + _ACPI_PU, /* 0x3B 59. ';' */ + _ACPI_PU, /* 0x3C 60. '<' */ + _ACPI_PU, /* 0x3D 61. '=' */ + _ACPI_PU, /* 0x3E 62. '>' */ + _ACPI_PU, /* 0x3F 63. '?' */ + _ACPI_PU, /* 0x40 64. '@' */ + _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ + _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ + _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ + _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ + _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ + _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ + _ACPI_UP, /* 0x47 71. 'G' */ + _ACPI_UP, /* 0x48 72. 'H' */ + _ACPI_UP, /* 0x49 73. 'I' */ + _ACPI_UP, /* 0x4A 74. 'J' */ + _ACPI_UP, /* 0x4B 75. 'K' */ + _ACPI_UP, /* 0x4C 76. 'L' */ + _ACPI_UP, /* 0x4D 77. 'M' */ + _ACPI_UP, /* 0x4E 78. 'N' */ + _ACPI_UP, /* 0x4F 79. 'O' */ + _ACPI_UP, /* 0x50 80. 'P' */ + _ACPI_UP, /* 0x51 81. 'Q' */ + _ACPI_UP, /* 0x52 82. 'R' */ + _ACPI_UP, /* 0x53 83. 'S' */ + _ACPI_UP, /* 0x54 84. 'T' */ + _ACPI_UP, /* 0x55 85. 'U' */ + _ACPI_UP, /* 0x56 86. 'V' */ + _ACPI_UP, /* 0x57 87. 'W' */ + _ACPI_UP, /* 0x58 88. 'X' */ + _ACPI_UP, /* 0x59 89. 'Y' */ + _ACPI_UP, /* 0x5A 90. 'Z' */ + _ACPI_PU, /* 0x5B 91. '[' */ + _ACPI_PU, /* 0x5C 92. '\' */ + _ACPI_PU, /* 0x5D 93. ']' */ + _ACPI_PU, /* 0x5E 94. '^' */ + _ACPI_PU, /* 0x5F 95. '_' */ + _ACPI_PU, /* 0x60 96. '`' */ + _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ + _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ + _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ + _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ + _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ + _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ + _ACPI_LO, /* 0x67 103. 'g' */ + _ACPI_LO, /* 0x68 104. 'h' */ + _ACPI_LO, /* 0x69 105. 'i' */ + _ACPI_LO, /* 0x6A 106. 'j' */ + _ACPI_LO, /* 0x6B 107. 'k' */ + _ACPI_LO, /* 0x6C 108. 'l' */ + _ACPI_LO, /* 0x6D 109. 'm' */ + _ACPI_LO, /* 0x6E 110. 'n' */ + _ACPI_LO, /* 0x6F 111. 'o' */ + _ACPI_LO, /* 0x70 112. 'p' */ + _ACPI_LO, /* 0x71 113. 'q' */ + _ACPI_LO, /* 0x72 114. 'r' */ + _ACPI_LO, /* 0x73 115. 's' */ + _ACPI_LO, /* 0x74 116. 't' */ + _ACPI_LO, /* 0x75 117. 'u' */ + _ACPI_LO, /* 0x76 118. 'v' */ + _ACPI_LO, /* 0x77 119. 'w' */ + _ACPI_LO, /* 0x78 120. 'x' */ + _ACPI_LO, /* 0x79 121. 'y' */ + _ACPI_LO, /* 0x7A 122. 'z' */ + _ACPI_PU, /* 0x7B 123. '{' */ + _ACPI_PU, /* 0x7C 124. '|' */ + _ACPI_PU, /* 0x7D 125. '}' */ + _ACPI_PU, /* 0x7E 126. '~' */ + _ACPI_CN, /* 0x7F 127. */ + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ +}; + + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + diff --git a/drivers/bus/acpi/acpica/utilities/utcopy.c b/drivers/bus/acpi/acpica/utilities/utcopy.c new file mode 100644 index 00000000000..5423eff9dec --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utcopy.c @@ -0,0 +1,1142 @@ +/****************************************************************************** + * + * Module Name: utcopy - Internal to external object translation utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTCOPY_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utcopy") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, + UINT8 *DataSpace, + ACPI_SIZE *BufferSpaceUsed); + +static ACPI_STATUS +AcpiUtCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT8 *Buffer, + ACPI_SIZE *SpaceUsed); + +static ACPI_STATUS +AcpiUtCopyEsimpleToIsimple( + ACPI_OBJECT *UserObj, + ACPI_OPERAND_OBJECT **ReturnObj); + +static ACPI_STATUS +AcpiUtCopyEpackageToIpackage ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **InternalObject); + +static ACPI_STATUS +AcpiUtCopySimpleObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc); + +static ACPI_STATUS +AcpiUtCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIsimpleToEsimple + * + * PARAMETERS: InternalObject - Source object to be copied + * ExternalObject - Where to return the copied object + * DataSpace - Where object data is returned (such as + * buffer and string data) + * BufferSpaceUsed - Length of DataSpace that was used + * + * RETURN: Status + * + * DESCRIPTION: This function is called to copy a simple internal object to + * an external object. + * + * The DataSpace buffer is assumed to have sufficient space for + * the object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, + UINT8 *DataSpace, + ACPI_SIZE *BufferSpaceUsed) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple); + + + *BufferSpaceUsed = 0; + + /* + * Check for NULL object case (could be an uninitialized + * package element) + */ + if (!InternalObject) + { + return_ACPI_STATUS (AE_OK); + } + + /* Always clear the external object */ + + ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); + + /* + * In general, the external object will be the same type as + * the internal object + */ + ExternalObject->Type = InternalObject->Common.Type; + + /* However, only a limited number of external types are supported */ + + switch (InternalObject->Common.Type) + { + case ACPI_TYPE_STRING: + + ExternalObject->String.Pointer = (char *) DataSpace; + ExternalObject->String.Length = InternalObject->String.Length; + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + (ACPI_SIZE) InternalObject->String.Length + 1); + + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->String.Pointer, + (ACPI_SIZE) InternalObject->String.Length + 1); + break; + + + case ACPI_TYPE_BUFFER: + + ExternalObject->Buffer.Pointer = DataSpace; + ExternalObject->Buffer.Length = InternalObject->Buffer.Length; + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + InternalObject->String.Length); + + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->Buffer.Pointer, + InternalObject->Buffer.Length); + break; + + + case ACPI_TYPE_INTEGER: + + ExternalObject->Integer.Value = InternalObject->Integer.Value; + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + /* This is an object reference. */ + + switch (InternalObject->Reference.Class) + { + case ACPI_REFCLASS_NAME: + + /* + * For namepath, return the object handle ("reference") + * We are referring to the namespace node + */ + ExternalObject->Reference.Handle = + InternalObject->Reference.Node; + ExternalObject->Reference.ActualType = + AcpiNsGetType (InternalObject->Reference.Node); + break; + + default: + + /* All other reference types are unsupported */ + + return_ACPI_STATUS (AE_TYPE); + } + break; + + + case ACPI_TYPE_PROCESSOR: + + ExternalObject->Processor.ProcId = + InternalObject->Processor.ProcId; + ExternalObject->Processor.PblkAddress = + InternalObject->Processor.Address; + ExternalObject->Processor.PblkLength = + InternalObject->Processor.Length; + break; + + + case ACPI_TYPE_POWER: + + ExternalObject->PowerResource.SystemLevel = + InternalObject->PowerResource.SystemLevel; + + ExternalObject->PowerResource.ResourceOrder = + InternalObject->PowerResource.ResourceOrder; + break; + + + default: + /* + * There is no corresponding external object type + */ + ACPI_ERROR ((AE_INFO, + "Unsupported object type, cannot convert to external object: %s", + AcpiUtGetTypeName (InternalObject->Common.Type))); + + return_ACPI_STATUS (AE_SUPPORT); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIelementToEelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; + ACPI_SIZE ObjectSpace; + UINT32 ThisIndex; + ACPI_OBJECT *TargetObject; + + + ACPI_FUNCTION_ENTRY (); + + + ThisIndex = State->Pkg.Index; + TargetObject = (ACPI_OBJECT *) + &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; + + switch (ObjectType) + { + case ACPI_COPY_TYPE_SIMPLE: + + /* + * This is a simple or null object + */ + Status = AcpiUtCopyIsimpleToEsimple (SourceObject, + TargetObject, Info->FreeSpace, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_COPY_TYPE_PACKAGE: + + /* + * Build the package object + */ + TargetObject->Type = ACPI_TYPE_PACKAGE; + TargetObject->Package.Count = SourceObject->Package.Count; + TargetObject->Package.Elements = + ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); + + /* + * Pass the new package object back to the package walk routine + */ + State->Pkg.ThisTargetObj = TargetObject; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( + (ACPI_SIZE) TargetObject->Package.Count * + sizeof (ACPI_OBJECT)); + break; + + + default: + return (AE_BAD_PARAMETER); + } + + Info->FreeSpace += ObjectSpace; + Info->Length += ObjectSpace; + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIpackageToEpackage + * + * PARAMETERS: InternalObject - Pointer to the object we are returning + * Buffer - Where the object is returned + * SpaceUsed - Where the object length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to place a package object in a user + * buffer. A package object by definition contains other objects. + * + * The buffer is assumed to have sufficient space for the object. + * The caller must have verified the buffer length needed using + * the AcpiUtGetObjectSize function before calling this function. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT8 *Buffer, + ACPI_SIZE *SpaceUsed) +{ + ACPI_OBJECT *ExternalObject; + ACPI_STATUS Status; + ACPI_PKG_INFO Info; + + + ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage); + + + /* + * First package at head of the buffer + */ + ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer); + + /* + * Free space begins right after the first package + */ + Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( + sizeof (ACPI_OBJECT)); + Info.ObjectSpace = 0; + Info.NumPackages = 1; + + ExternalObject->Type = InternalObject->Common.Type; + ExternalObject->Package.Count = InternalObject->Package.Count; + ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, + Info.FreeSpace); + + /* + * Leave room for an array of ACPI_OBJECTS in the buffer + * and move the free space past it + */ + Info.Length += (ACPI_SIZE) ExternalObject->Package.Count * + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.FreeSpace += ExternalObject->Package.Count * + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + + Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, + AcpiUtCopyIelementToEelement, &Info); + + *SpaceUsed = Info.Length; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIobjectToEobject + * + * PARAMETERS: InternalObject - The internal object to be converted + * RetBuffer - Where the object is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to build an API object to be returned + * to the caller. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCopyIobjectToEobject ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject); + + + if (InternalObject->Common.Type == ACPI_TYPE_PACKAGE) + { + /* + * Package object: Copy all subobjects (including + * nested packages) + */ + Status = AcpiUtCopyIpackageToEpackage (InternalObject, + RetBuffer->Pointer, &RetBuffer->Length); + } + else + { + /* + * Build a simple object (no nested objects) + */ + Status = AcpiUtCopyIsimpleToEsimple (InternalObject, + ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer), + ACPI_ADD_PTR (UINT8, RetBuffer->Pointer, + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), + &RetBuffer->Length); + /* + * build simple does not include the object size in the length + * so we add it in here + */ + RetBuffer->Length += sizeof (ACPI_OBJECT); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyEsimpleToIsimple + * + * PARAMETERS: ExternalObject - The external object to be converted + * RetInternalObject - Where the internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: This function copies an external object to an internal one. + * NOTE: Pointers can be copied, we don't need to copy data. + * (The pointers have to be valid in our address space no matter + * what we do with them!) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyEsimpleToIsimple ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **RetInternalObject) +{ + ACPI_OPERAND_OBJECT *InternalObject; + + + ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple); + + + /* + * Simple types supported are: String, Buffer, Integer + */ + switch (ExternalObject->Type) + { + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_LOCAL_REFERENCE: + + InternalObject = AcpiUtCreateInternalObject ( + (UINT8) ExternalObject->Type); + if (!InternalObject) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + break; + + case ACPI_TYPE_ANY: /* This is the case for a NULL object */ + + *RetInternalObject = NULL; + return_ACPI_STATUS (AE_OK); + + default: + /* All other types are not supported */ + + ACPI_ERROR ((AE_INFO, + "Unsupported object type, cannot convert to internal object: %s", + AcpiUtGetTypeName (ExternalObject->Type))); + + return_ACPI_STATUS (AE_SUPPORT); + } + + + /* Must COPY string and buffer contents */ + + switch (ExternalObject->Type) + { + case ACPI_TYPE_STRING: + + InternalObject->String.Pointer = + ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) + ExternalObject->String.Length + 1); + + if (!InternalObject->String.Pointer) + { + goto ErrorExit; + } + + ACPI_MEMCPY (InternalObject->String.Pointer, + ExternalObject->String.Pointer, + ExternalObject->String.Length); + + InternalObject->String.Length = ExternalObject->String.Length; + break; + + + case ACPI_TYPE_BUFFER: + + InternalObject->Buffer.Pointer = + ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length); + if (!InternalObject->Buffer.Pointer) + { + goto ErrorExit; + } + + ACPI_MEMCPY (InternalObject->Buffer.Pointer, + ExternalObject->Buffer.Pointer, + ExternalObject->Buffer.Length); + + InternalObject->Buffer.Length = ExternalObject->Buffer.Length; + + /* Mark buffer data valid */ + + InternalObject->Buffer.Flags |= AOPOBJ_DATA_VALID; + break; + + + case ACPI_TYPE_INTEGER: + + InternalObject->Integer.Value = ExternalObject->Integer.Value; + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + + /* TBD: should validate incoming handle */ + + InternalObject->Reference.Class = ACPI_REFCLASS_NAME; + InternalObject->Reference.Node = ExternalObject->Reference.Handle; + break; + + default: + /* Other types can't get here */ + break; + } + + *RetInternalObject = InternalObject; + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + AcpiUtRemoveReference (InternalObject); + return_ACPI_STATUS (AE_NO_MEMORY); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyEpackageToIpackage + * + * PARAMETERS: ExternalObject - The external object to be converted + * InternalObject - Where the internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Copy an external package object to an internal package. + * Handles nested packages. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyEpackageToIpackage ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **InternalObject) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *PackageObject; + ACPI_OPERAND_OBJECT **PackageElements; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage); + + + /* Create the package object */ + + PackageObject = AcpiUtCreatePackageObject (ExternalObject->Package.Count); + if (!PackageObject) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + PackageElements = PackageObject->Package.Elements; + + /* + * Recursive implementation. Probably ok, since nested external packages + * as parameters should be very rare. + */ + for (i = 0; i < ExternalObject->Package.Count; i++) + { + Status = AcpiUtCopyEobjectToIobject ( + &ExternalObject->Package.Elements[i], + &PackageElements[i]); + if (ACPI_FAILURE (Status)) + { + /* Truncate package and delete it */ + + PackageObject->Package.Count = i; + PackageElements[i] = NULL; + AcpiUtRemoveReference (PackageObject); + return_ACPI_STATUS (Status); + } + } + + /* Mark package data valid */ + + PackageObject->Package.Flags |= AOPOBJ_DATA_VALID; + + *InternalObject = PackageObject; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyEobjectToIobject + * + * PARAMETERS: ExternalObject - The external object to be converted + * InternalObject - Where the internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Converts an external object to an internal object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCopyEobjectToIobject ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **InternalObject) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject); + + + if (ExternalObject->Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiUtCopyEpackageToIpackage (ExternalObject, InternalObject); + } + else + { + /* + * Build a simple object (no nested objects) + */ + Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopySimpleObject + * + * PARAMETERS: SourceDesc - The internal object to be copied + * DestDesc - New target object + * + * RETURN: Status + * + * DESCRIPTION: Simple copy of one internal object to another. Reference count + * of the destination object is preserved. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopySimpleObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc) +{ + UINT16 ReferenceCount; + ACPI_OPERAND_OBJECT *NextObject; + ACPI_STATUS Status; + + + /* Save fields from destination that we don't want to overwrite */ + + ReferenceCount = DestDesc->Common.ReferenceCount; + NextObject = DestDesc->Common.NextObject; + + /* Copy the entire source object over the destination object*/ + + ACPI_MEMCPY ((char *) DestDesc, (char *) SourceDesc, + sizeof (ACPI_OPERAND_OBJECT)); + + /* Restore the saved fields */ + + DestDesc->Common.ReferenceCount = ReferenceCount; + DestDesc->Common.NextObject = NextObject; + + /* New object is not static, regardless of source */ + + DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + + /* Handle the objects with extra data */ + + switch (DestDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + /* + * Allocate and copy the actual buffer if and only if: + * 1) There is a valid buffer pointer + * 2) The buffer has a length > 0 + */ + if ((SourceDesc->Buffer.Pointer) && + (SourceDesc->Buffer.Length)) + { + DestDesc->Buffer.Pointer = + ACPI_ALLOCATE (SourceDesc->Buffer.Length); + if (!DestDesc->Buffer.Pointer) + { + return (AE_NO_MEMORY); + } + + /* Copy the actual buffer data */ + + ACPI_MEMCPY (DestDesc->Buffer.Pointer, + SourceDesc->Buffer.Pointer, + SourceDesc->Buffer.Length); + } + break; + + case ACPI_TYPE_STRING: + /* + * Allocate and copy the actual string if and only if: + * 1) There is a valid string pointer + * (Pointer to a NULL string is allowed) + */ + if (SourceDesc->String.Pointer) + { + DestDesc->String.Pointer = + ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); + if (!DestDesc->String.Pointer) + { + return (AE_NO_MEMORY); + } + + /* Copy the actual string data */ + + ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, + (ACPI_SIZE) SourceDesc->String.Length + 1); + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * We copied the reference object, so we now must add a reference + * to the object pointed to by the reference + * + * DDBHandle reference (from Load/LoadTable) is a special reference, + * it does not have a Reference.Object, so does not need to + * increase the reference count + */ + if (SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) + { + break; + } + + AcpiUtAddReference (SourceDesc->Reference.Object); + break; + + case ACPI_TYPE_REGION: + /* + * We copied the Region Handler, so we now must add a reference + */ + if (DestDesc->Region.Handler) + { + AcpiUtAddReference (DestDesc->Region.Handler); + } + break; + + /* + * For Mutex and Event objects, we cannot simply copy the underlying + * OS object. We must create a new one. + */ + case ACPI_TYPE_MUTEX: + + Status = AcpiOsCreateMutex (&DestDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_EVENT: + + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, + &DestDesc->Event.OsSemaphore); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + default: + /* Nothing to do for other simple objects */ + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIelementToIelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT **ThisTargetPtr; + ACPI_OPERAND_OBJECT *TargetObject; + + + ACPI_FUNCTION_ENTRY (); + + + ThisIndex = State->Pkg.Index; + ThisTargetPtr = (ACPI_OPERAND_OBJECT **) + &State->Pkg.DestObject->Package.Elements[ThisIndex]; + + switch (ObjectType) + { + case ACPI_COPY_TYPE_SIMPLE: + + /* A null source object indicates a (legal) null package element */ + + if (SourceObject) + { + /* + * This is a simple object, just copy it + */ + TargetObject = AcpiUtCreateInternalObject ( + SourceObject->Common.Type); + if (!TargetObject) + { + return (AE_NO_MEMORY); + } + + Status = AcpiUtCopySimpleObject (SourceObject, TargetObject); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + *ThisTargetPtr = TargetObject; + } + else + { + /* Pass through a null element */ + + *ThisTargetPtr = NULL; + } + break; + + + case ACPI_COPY_TYPE_PACKAGE: + + /* + * This object is a package - go down another nesting level + * Create and build the package object + */ + TargetObject = AcpiUtCreatePackageObject (SourceObject->Package.Count); + if (!TargetObject) + { + return (AE_NO_MEMORY); + } + + TargetObject->Common.Flags = SourceObject->Common.Flags; + + /* Pass the new package object back to the package walk routine */ + + State->Pkg.ThisTargetObj = TargetObject; + + /* Store the object pointer in the parent package object */ + + *ThisTargetPtr = TargetObject; + break; + + + default: + return (AE_BAD_PARAMETER); + } + + return (Status); + +ErrorExit: + AcpiUtRemoveReference (TargetObject); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIpackageToIpackage + * + * PARAMETERS: SourceObj - Pointer to the source package object + * DestObj - Where the internal object is returned + * WalkState - Current Walk state descriptor + * + * RETURN: Status + * + * DESCRIPTION: This function is called to copy an internal package object + * into another internal package object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage); + + + DestObj->Common.Type = SourceObj->Common.Type; + DestObj->Common.Flags = SourceObj->Common.Flags; + DestObj->Package.Count = SourceObj->Package.Count; + + /* + * Create the object array and walk the source package tree + */ + DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) SourceObj->Package.Count + 1) * + sizeof (void *)); + if (!DestObj->Package.Elements) + { + ACPI_ERROR ((AE_INFO, "Package allocation failure")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the package element-by-element by walking the package "tree". + * This handles nested packages of arbitrary depth. + */ + Status = AcpiUtWalkPackageTree (SourceObj, DestObj, + AcpiUtCopyIelementToIelement, WalkState); + if (ACPI_FAILURE (Status)) + { + /* On failure, delete the destination package object */ + + AcpiUtRemoveReference (DestObj); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIobjectToIobject + * + * PARAMETERS: SourceDesc - The internal object to be copied + * DestDesc - Where the copied object is returned + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Copy an internal object to a new internal object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCopyIobjectToIobject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject); + + + /* Create the top level object */ + + *DestDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type); + if (!*DestDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the object and possible subobjects */ + + if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc, + WalkState); + } + else + { + Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/utilities/utdebug.c b/drivers/bus/acpi/acpica/utilities/utdebug.c new file mode 100644 index 00000000000..3901b07d197 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utdebug.c @@ -0,0 +1,814 @@ +/****************************************************************************** + * + * Module Name: utdebug - Debug print routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTDEBUG_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utdebug") + + +#ifdef ACPI_DEBUG_OUTPUT + +static ACPI_THREAD_ID AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; +static char *AcpiGbl_FnEntryStr = "----Entry"; +static char *AcpiGbl_FnExitStr = "----Exit-"; + +/* Local prototypes */ + +static const char * +AcpiUtTrimFunctionName ( + const char *FunctionName); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInitStackPtrTrace + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Save the current CPU stack pointer at subsystem startup + * + ******************************************************************************/ + +void +AcpiUtInitStackPtrTrace ( + void) +{ + ACPI_SIZE CurrentSp; + + + AcpiGbl_EntryStackPointer = &CurrentSp; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrackStackPtr + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Save the current CPU stack pointer + * + ******************************************************************************/ + +void +AcpiUtTrackStackPtr ( + void) +{ + ACPI_SIZE CurrentSp; + + + if (&CurrentSp < AcpiGbl_LowestStackPointer) + { + AcpiGbl_LowestStackPointer = &CurrentSp; + } + + if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting) + { + AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrimFunctionName + * + * PARAMETERS: FunctionName - Ascii string containing a procedure name + * + * RETURN: Updated pointer to the function name + * + * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. + * This allows compiler macros such as __FUNCTION__ to be used + * with no change to the debug output. + * + ******************************************************************************/ + +static const char * +AcpiUtTrimFunctionName ( + const char *FunctionName) +{ + + /* All Function names are longer than 4 chars, check is safe */ + + if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED) + { + /* This is the case where the original source has not been modified */ + + return (FunctionName + 4); + } + + if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER) + { + /* This is the case where the source has been 'linuxized' */ + + return (FunctionName + 5); + } + + return (FunctionName); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDebugPrint + * + * PARAMETERS: RequestedDebugLevel - Requested debug print level + * LineNumber - Caller's line number (for error output) + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print error message with prefix consisting of the module name, + * line number, and component ID. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrint ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) +{ + ACPI_THREAD_ID ThreadId; + va_list args; + + + /* + * Stay silent if the debug level or component ID is disabled + */ + if (!(RequestedDebugLevel & AcpiDbgLevel) || + !(ComponentId & AcpiDbgLayer)) + { + return; + } + + /* + * Thread tracking and context switch notification + */ + ThreadId = AcpiOsGetThreadId (); + if (ThreadId != AcpiGbl_PrevThreadId) + { + if (ACPI_LV_THREADS & AcpiDbgLevel) + { + AcpiOsPrintf ( + "\n**** Context Switch from TID %p to TID %p ****\n\n", + ACPI_CAST_PTR (void, AcpiGbl_PrevThreadId), + ACPI_CAST_PTR (void, ThreadId)); + } + + AcpiGbl_PrevThreadId = ThreadId; + } + + /* + * Display the module name, current line number, thread ID (if requested), + * current procedure nesting level, and the current procedure name + */ + AcpiOsPrintf ("%8s-%04ld ", ModuleName, LineNumber); + + if (ACPI_LV_THREADS & AcpiDbgLevel) + { + AcpiOsPrintf ("[%p] ", ACPI_CAST_PTR (void, ThreadId)); + } + + AcpiOsPrintf ("[%02ld] %-22.22s: ", + AcpiGbl_NestingLevel, AcpiUtTrimFunctionName (FunctionName)); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + va_end (args); +} + +ACPI_EXPORT_SYMBOL (AcpiDebugPrint) + + +/******************************************************************************* + * + * FUNCTION: AcpiDebugPrintRaw + * + * PARAMETERS: RequestedDebugLevel - Requested debug print level + * LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print message with no headers. Has same interface as + * DebugPrint so that the same macros can be used. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrintRaw ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) +{ + va_list args; + + + if (!(RequestedDebugLevel & AcpiDbgLevel) || + !(ComponentId & AcpiDbgLayer)) + { + return; + } + + va_start (args, Format); + AcpiOsVprintf (Format, args); + va_end (args); +} + +ACPI_EXPORT_SYMBOL (AcpiDebugPrintRaw) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrace + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTrace ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId) +{ + + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s\n", AcpiGbl_FnEntryStr); +} + +ACPI_EXPORT_SYMBOL (AcpiUtTrace) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTracePtr + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Pointer - Pointer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTracePtr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + void *Pointer) +{ + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %p\n", AcpiGbl_FnEntryStr, Pointer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTraceStr + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * String - Additional string to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTraceStr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + char *String) +{ + + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %s\n", AcpiGbl_FnEntryStr, String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTraceU32 + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Integer - Integer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTraceU32 ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT32 Integer) +{ + + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %08X\n", AcpiGbl_FnEntryStr, Integer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId) +{ + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s\n", AcpiGbl_FnExitStr); + + AcpiGbl_NestingLevel--; +} + +ACPI_EXPORT_SYMBOL (AcpiUtExit) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStatusExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Status - Exit status code + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit status also. + * + ******************************************************************************/ + +void +AcpiUtStatusExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_STATUS Status) +{ + + if (ACPI_SUCCESS (Status)) + { + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %s\n", AcpiGbl_FnExitStr, + AcpiFormatException (Status)); + } + else + { + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, + AcpiFormatException (Status)); + } + + AcpiGbl_NestingLevel--; +} + +ACPI_EXPORT_SYMBOL (AcpiUtStatusExit) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValueExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Value - Value to be printed with exit msg + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit value also. + * + ******************************************************************************/ + +void +AcpiUtValueExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_INTEGER Value) +{ + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, + ACPI_FORMAT_UINT64 (Value)); + + AcpiGbl_NestingLevel--; +} + +ACPI_EXPORT_SYMBOL (AcpiUtValueExit) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPtrExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Ptr - Pointer to display + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit value also. + * + ******************************************************************************/ + +void +AcpiUtPtrExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT8 *Ptr) +{ + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %p\n", AcpiGbl_FnExitStr, Ptr); + + AcpiGbl_NestingLevel--; +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpBuffer + * + * PARAMETERS: Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * Display - BYTE, WORD, DWORD, or QWORD display + * ComponentID - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii. + * + ******************************************************************************/ + +void +AcpiUtDumpBuffer2 ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display) +{ + UINT32 i = 0; + UINT32 j; + UINT32 Temp32; + UINT8 BufChar; + + + if (!Buffer) + { + AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n"); + return; + } + + if ((Count < 4) || (Count & 0x01)) + { + Display = DB_BYTE_DISPLAY; + } + + /* Nasty little dump buffer routine! */ + + while (i < Count) + { + /* Print current offset */ + + AcpiOsPrintf ("%6.4X: ", i); + + /* Print 16 hex chars */ + + for (j = 0; j < 16;) + { + if (i + j >= Count) + { + /* Dump fill spaces */ + + AcpiOsPrintf ("%*s", ((Display * 2) + 1), " "); + j += Display; + continue; + } + + switch (Display) + { + case DB_BYTE_DISPLAY: + default: /* Default is BYTE display */ + + AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]); + break; + + + case DB_WORD_DISPLAY: + + ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiOsPrintf ("%04X ", Temp32); + break; + + + case DB_DWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiOsPrintf ("%08X ", Temp32); + break; + + + case DB_QWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiOsPrintf ("%08X", Temp32); + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]); + AcpiOsPrintf ("%08X ", Temp32); + break; + } + + j += Display; + } + + /* + * Print the ASCII equivalent characters but watch out for the bad + * unprintable ones (printable chars are 0x20 through 0x7E) + */ + AcpiOsPrintf (" "); + for (j = 0; j < 16; j++) + { + if (i + j >= Count) + { + AcpiOsPrintf ("\n"); + return; + } + + BufChar = Buffer[(ACPI_SIZE) i + j]; + if (ACPI_IS_PRINT (BufChar)) + { + AcpiOsPrintf ("%c", BufChar); + } + else + { + AcpiOsPrintf ("."); + } + } + + /* Done with that line. */ + + AcpiOsPrintf ("\n"); + i += 16; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpBuffer + * + * PARAMETERS: Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * Display - BYTE, WORD, DWORD, or QWORD display + * ComponentID - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii. + * + ******************************************************************************/ + +void +AcpiUtDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 ComponentId) +{ + + /* Only dump the buffer if tracing is enabled */ + + if (!((ACPI_LV_TABLES & AcpiDbgLevel) && + (ComponentId & AcpiDbgLayer))) + { + return; + } + + AcpiUtDumpBuffer2 (Buffer, Count, Display); +} + + diff --git a/drivers/bus/acpi/acpica/utilities/utdelete.c b/drivers/bus/acpi/acpica/utilities/utdelete.c new file mode 100644 index 00000000000..bf30aee74e0 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utdelete.c @@ -0,0 +1,828 @@ +/******************************************************************************* + * + * Module Name: utdelete - object deletion and reference count utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTDELETE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utdelete") + +/* Local prototypes */ + +static void +AcpiUtDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object); + +static void +AcpiUtUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteInternalObj + * + * PARAMETERS: Object - Object to be deleted + * + * RETURN: None + * + * DESCRIPTION: Low level object deletion, after reference counts have been + * updated (All reference counts, including sub-objects!) + * + ******************************************************************************/ + +static void +AcpiUtDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object) +{ + void *ObjPointer = NULL; + ACPI_OPERAND_OBJECT *HandlerDesc; + ACPI_OPERAND_OBJECT *SecondDesc; + ACPI_OPERAND_OBJECT *NextDesc; + ACPI_OPERAND_OBJECT **LastObjPtr; + + + ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object); + + + if (!Object) + { + return_VOID; + } + + /* + * Must delete or free any pointers within the object that are not + * actual ACPI objects (for example, a raw buffer pointer). + */ + switch (Object->Common.Type) + { + case ACPI_TYPE_STRING: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", + Object, Object->String.Pointer)); + + /* Free the actual string buffer */ + + if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) + { + /* But only if it is NOT a pointer into an ACPI table */ + + ObjPointer = Object->String.Pointer; + } + break; + + + case ACPI_TYPE_BUFFER: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", + Object, Object->Buffer.Pointer)); + + /* Free the actual buffer */ + + if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) + { + /* But only if it is NOT a pointer into an ACPI table */ + + ObjPointer = Object->Buffer.Pointer; + } + break; + + + case ACPI_TYPE_PACKAGE: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", + Object->Package.Count)); + + /* + * Elements of the package are not handled here, they are deleted + * separately + */ + + /* Free the (variable length) element pointer array */ + + ObjPointer = Object->Package.Elements; + break; + + + /* + * These objects have a possible list of notify handlers. + * Device object also may have a GPE block. + */ + case ACPI_TYPE_DEVICE: + + if (Object->Device.GpeBlock) + { + (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock); + } + + /*lint -fallthrough */ + + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* Walk the notify handler list for this object */ + + HandlerDesc = Object->CommonNotify.Handler; + while (HandlerDesc) + { + NextDesc = HandlerDesc->AddressSpace.Next; + AcpiUtRemoveReference (HandlerDesc); + HandlerDesc = NextDesc; + } + break; + + + case ACPI_TYPE_MUTEX: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Mutex %p, OS Mutex %p\n", + Object, Object->Mutex.OsMutex)); + + if (Object == AcpiGbl_GlobalLockMutex) + { + /* Global Lock has extra semaphore */ + + (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore); + AcpiGbl_GlobalLockSemaphore = NULL; + + AcpiOsDeleteMutex (Object->Mutex.OsMutex); + AcpiGbl_GlobalLockMutex = NULL; + } + else + { + AcpiExUnlinkMutex (Object); + AcpiOsDeleteMutex (Object->Mutex.OsMutex); + } + break; + + + case ACPI_TYPE_EVENT: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Event %p, OS Semaphore %p\n", + Object, Object->Event.OsSemaphore)); + + (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore); + Object->Event.OsSemaphore = NULL; + break; + + + case ACPI_TYPE_METHOD: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Method %p\n", Object)); + + /* Delete the method mutex if it exists */ + + if (Object->Method.Mutex) + { + AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex); + AcpiUtDeleteObjectDesc (Object->Method.Mutex); + Object->Method.Mutex = NULL; + } + break; + + + case ACPI_TYPE_REGION: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Region %p\n", Object)); + + SecondDesc = AcpiNsGetSecondaryObject (Object); + if (SecondDesc) + { + /* + * Free the RegionContext if and only if the handler is one of the + * default handlers -- and therefore, we created the context object + * locally, it was not created by an external caller. + */ + HandlerDesc = Object->Region.Handler; + if (HandlerDesc) + { + NextDesc = HandlerDesc->AddressSpace.RegionList; + LastObjPtr = &HandlerDesc->AddressSpace.RegionList; + + /* Remove the region object from the handler's list */ + + while (NextDesc) + { + if (NextDesc == Object) + { + *LastObjPtr = NextDesc->Region.Next; + break; + } + + /* Walk the linked list of handler */ + + LastObjPtr = &NextDesc->Region.Next; + NextDesc = NextDesc->Region.Next; + } + + if (HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) + { + /* Deactivate region and free region context */ + + if (HandlerDesc->AddressSpace.Setup) + { + (void) HandlerDesc->AddressSpace.Setup (Object, + ACPI_REGION_DEACTIVATE, + HandlerDesc->AddressSpace.Context, + &SecondDesc->Extra.RegionContext); + } + } + + AcpiUtRemoveReference (HandlerDesc); + } + + /* Now we can free the Extra object */ + + AcpiUtDeleteObjectDesc (SecondDesc); + } + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Buffer Field %p\n", Object)); + + SecondDesc = AcpiNsGetSecondaryObject (Object); + if (SecondDesc) + { + AcpiUtDeleteObjectDesc (SecondDesc); + } + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Bank Field %p\n", Object)); + + SecondDesc = AcpiNsGetSecondaryObject (Object); + if (SecondDesc) + { + AcpiUtDeleteObjectDesc (SecondDesc); + } + break; + + + default: + break; + } + + /* Free any allocated memory (pointer within the object) found above */ + + if (ObjPointer) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", + ObjPointer)); + ACPI_FREE (ObjPointer); + } + + /* Now the object can be safely deleted */ + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", + Object, AcpiUtGetObjectTypeName (Object))); + + AcpiUtDeleteObjectDesc (Object); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteInternalObjectList + * + * PARAMETERS: ObjList - Pointer to the list to be deleted + * + * RETURN: None + * + * DESCRIPTION: This function deletes an internal object list, including both + * simple objects and package objects + * + ******************************************************************************/ + +void +AcpiUtDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList) +{ + ACPI_OPERAND_OBJECT **InternalObj; + + + ACPI_FUNCTION_TRACE (UtDeleteInternalObjectList); + + + /* Walk the null-terminated internal list */ + + for (InternalObj = ObjList; *InternalObj; InternalObj++) + { + AcpiUtRemoveReference (*InternalObj); + } + + /* Free the combined parameter pointer list and object array */ + + ACPI_FREE (ObjList); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtUpdateRefCount + * + * PARAMETERS: Object - Object whose ref count is to be updated + * Action - What to do + * + * RETURN: New ref count + * + * DESCRIPTION: Modify the ref count and return it. + * + ******************************************************************************/ + +static void +AcpiUtUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action) +{ + UINT16 Count; + UINT16 NewCount; + + + ACPI_FUNCTION_NAME (UtUpdateRefCount); + + + if (!Object) + { + return; + } + + Count = Object->Common.ReferenceCount; + NewCount = Count; + + /* + * Perform the reference count action (increment, decrement, force delete) + */ + switch (Action) + { + case REF_INCREMENT: + + NewCount++; + Object->Common.ReferenceCount = NewCount; + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Incremented]\n", + Object, NewCount)); + break; + + case REF_DECREMENT: + + if (Count < 1) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, can't decrement! (Set to 0)\n", + Object, NewCount)); + + NewCount = 0; + } + else + { + NewCount--; + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Decremented]\n", + Object, NewCount)); + } + + if (Object->Common.Type == ACPI_TYPE_METHOD) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); + } + + Object->Common.ReferenceCount = NewCount; + if (NewCount == 0) + { + AcpiUtDeleteInternalObj (Object); + } + break; + + case REF_FORCE_DELETE: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count)); + + NewCount = 0; + Object->Common.ReferenceCount = NewCount; + AcpiUtDeleteInternalObj (Object); + break; + + default: + + ACPI_ERROR ((AE_INFO, "Unknown action (%X)", Action)); + break; + } + + /* + * Sanity check the reference count, for debug purposes only. + * (A deleted object will have a huge reference count) + */ + if (Count > ACPI_MAX_REFERENCE_COUNT) + { + ACPI_WARNING ((AE_INFO, + "Large Reference Count (%X) in object %p", Count, Object)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtUpdateObjectReference + * + * PARAMETERS: Object - Increment ref count for this object + * and all sub-objects + * Action - Either REF_INCREMENT or REF_DECREMENT or + * REF_FORCE_DELETE + * + * RETURN: Status + * + * DESCRIPTION: Increment the object reference count + * + * Object references are incremented when: + * 1) An object is attached to a Node (namespace object) + * 2) An object is copied (all subobjects must be incremented) + * + * Object references are decremented when: + * 1) An object is detached from an Node + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_OPERAND_OBJECT *NextObject = NULL; + ACPI_GENERIC_STATE *State; + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (UtUpdateObjectReference, Object); + + + while (Object) + { + /* Make sure that this isn't a namespace handle */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Object %p is NS handle\n", Object)); + return_ACPI_STATUS (AE_OK); + } + + /* + * All sub-objects must have their reference count incremented also. + * Different object types have different subobjects. + */ + switch (Object->Common.Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_POWER: + case ACPI_TYPE_THERMAL: + + /* Update the notify objects for these types (if present) */ + + AcpiUtUpdateRefCount (Object->CommonNotify.SystemNotify, Action); + AcpiUtUpdateRefCount (Object->CommonNotify.DeviceNotify, Action); + break; + + case ACPI_TYPE_PACKAGE: + /* + * We must update all the sub-objects of the package, + * each of whom may have their own sub-objects. + */ + for (i = 0; i < Object->Package.Count; i++) + { + /* + * Push each element onto the stack for later processing. + * Note: There can be null elements within the package, + * these are simply ignored + */ + Status = AcpiUtCreateUpdateStateAndPush ( + Object->Package.Elements[i], Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + } + break; + + case ACPI_TYPE_BUFFER_FIELD: + + NextObject = Object->BufferField.BufferObj; + break; + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + NextObject = Object->Field.RegionObj; + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + NextObject = Object->BankField.BankObj; + Status = AcpiUtCreateUpdateStateAndPush ( + Object->BankField.RegionObj, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + break; + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + NextObject = Object->IndexField.IndexObj; + Status = AcpiUtCreateUpdateStateAndPush ( + Object->IndexField.DataObj, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * The target of an Index (a package, string, or buffer) or a named + * reference must track changes to the ref count of the index or + * target object. + */ + if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) || + (Object->Reference.Class== ACPI_REFCLASS_NAME)) + { + NextObject = Object->Reference.Object; + } + break; + + case ACPI_TYPE_REGION: + default: + break; /* No subobjects for all other types */ + } + + /* + * Now we can update the count in the main object. This can only + * happen after we update the sub-objects in case this causes the + * main object to be deleted. + */ + AcpiUtUpdateRefCount (Object, Action); + Object = NULL; + + /* Move on to the next object to be updated */ + + if (NextObject) + { + Object = NextObject; + NextObject = NULL; + } + else if (StateList) + { + State = AcpiUtPopGenericState (&StateList); + Object = State->Update.Object; + AcpiUtDeleteGenericState (State); + } + } + + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not update object reference count")); + + /* Free any stacked Update State objects */ + + while (StateList) + { + State = AcpiUtPopGenericState (&StateList); + AcpiUtDeleteGenericState (State); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAddReference + * + * PARAMETERS: Object - Object whose reference count is to be + * incremented + * + * RETURN: None + * + * DESCRIPTION: Add one reference to an ACPI object + * + ******************************************************************************/ + +void +AcpiUtAddReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + ACPI_FUNCTION_TRACE_PTR (UtAddReference, Object); + + + /* Ensure that we have a valid object */ + + if (!AcpiUtValidInternalObject (Object)) + { + return_VOID; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Incremented]\n", + Object, Object->Common.ReferenceCount)); + + /* Increment the reference count */ + + (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveReference + * + * PARAMETERS: Object - Object whose ref count will be decremented + * + * RETURN: None + * + * DESCRIPTION: Decrement the reference count of an ACPI internal object + * + ******************************************************************************/ + +void +AcpiUtRemoveReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + ACPI_FUNCTION_TRACE_PTR (UtRemoveReference, Object); + + + /* + * Allow a NULL pointer to be passed in, just ignore it. This saves + * each caller from having to check. Also, ignore NS nodes. + * + */ + if (!Object || + (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)) + + { + return_VOID; + } + + /* Ensure that we have a valid object */ + + if (!AcpiUtValidInternalObject (Object)) + { + return_VOID; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Decremented]\n", + Object, Object->Common.ReferenceCount)); + + /* + * Decrement the reference count, and only actually delete the object + * if the reference count becomes 0. (Must also decrement the ref count + * of all subobjects!) + */ + (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT); + return_VOID; +} + + diff --git a/drivers/bus/acpi/acpica/utilities/uteval.c b/drivers/bus/acpi/acpica/utilities/uteval.c new file mode 100644 index 00000000000..ecb0cf19a70 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/uteval.c @@ -0,0 +1,575 @@ +/****************************************************************************** + * + * Module Name: uteval - Object evaluation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTEVAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("uteval") + + +/* + * Strings supported by the _OSI predefined (internal) method. + * + * March 2009: Removed "Linux" as this host no longer wants to respond true + * for this string. Basically, the only safe OS strings are windows-related + * and in many or most cases represent the only test path within the + * BIOS-provided ASL code. + * + * The second element of each entry is used to track the newest version of + * Windows that the BIOS has requested. + */ +static const ACPI_INTERFACE_INFO AcpiInterfacesSupported[] = +{ + /* Operating System Vendor Strings */ + + {"Windows 2000", ACPI_OSI_WIN_2000}, /* Windows 2000 */ + {"Windows 2001", ACPI_OSI_WIN_XP}, /* Windows XP */ + {"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ + {"Windows 2001.1", ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ + {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ + {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ + {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ + {"Windows 2006.1", ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ + {"Windows 2006 SP1", ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ + {"Windows 2009", ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ + + /* Feature Group Strings */ + + {"Extended Address Space Descriptor", 0} + + /* + * All "optional" feature group strings (features that are implemented + * by the host) should be implemented in the host version of + * AcpiOsValidateInterface and should not be added here. + */ +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtOsiImplementation + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Implementation of the _OSI predefined control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtOsiImplementation ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *StringDesc; + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT32 ReturnValue; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtOsiImplementation); + + + /* Validate the string input argument */ + + StringDesc = WalkState->Arguments[0].Object; + if (!StringDesc || (StringDesc->Common.Type != ACPI_TYPE_STRING)) + { + return_ACPI_STATUS (AE_TYPE); + } + + /* Create a return object */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Default return value is 0, NOT SUPPORTED */ + + ReturnValue = 0; + + /* Compare input string to static table of supported interfaces */ + + for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiInterfacesSupported); i++) + { + if (!ACPI_STRCMP (StringDesc->String.Pointer, + AcpiInterfacesSupported[i].Name)) + { + /* + * The interface is supported. + * Update the OsiData if necessary. We keep track of the latest + * version of Windows that has been requested by the BIOS. + */ + if (AcpiInterfacesSupported[i].Value > AcpiGbl_OsiData) + { + AcpiGbl_OsiData = AcpiInterfacesSupported[i].Value; + } + + ReturnValue = ACPI_UINT32_MAX; + goto Exit; + } + } + + /* + * Did not match the string in the static table, call the host OSL to + * check for a match with one of the optional strings (such as + * "Module Device", "3.0 Thermal Model", etc.) + */ + Status = AcpiOsValidateInterface (StringDesc->String.Pointer); + if (ACPI_SUCCESS (Status)) + { + /* The interface is supported */ + + ReturnValue = ACPI_UINT32_MAX; + } + + +Exit: + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, + "ACPI: BIOS _OSI(%s) is %ssupported\n", + StringDesc->String.Pointer, ReturnValue == 0 ? "not " : "")); + + /* Complete the return value */ + + ReturnDesc->Integer.Value = ReturnValue; + WalkState->ReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtEvaluateObject + * + * PARAMETERS: PrefixNode - Starting node + * Path - Path to object from starting node + * ExpectedReturnTypes - Bitmap of allowed return types + * ReturnDesc - Where a return value is stored + * + * RETURN: Status + * + * DESCRIPTION: Evaluates a namespace object and verifies the type of the + * return object. Common code that simplifies accessing objects + * that have required return objects of fixed types. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtEvaluateObject ( + ACPI_NAMESPACE_NODE *PrefixNode, + char *Path, + UINT32 ExpectedReturnBtypes, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_EVALUATE_INFO *Info; + ACPI_STATUS Status; + UINT32 ReturnBtype; + + + ACPI_FUNCTION_TRACE (UtEvaluateObject); + + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = PrefixNode; + Info->Pathname = Path; + + /* Evaluate the object/method */ + + Status = AcpiNsEvaluate (Info); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n", + AcpiUtGetNodeName (PrefixNode), Path)); + } + else + { + ACPI_ERROR_METHOD ("Method execution failed", + PrefixNode, Path, Status); + } + + goto Cleanup; + } + + /* Did we get a return object? */ + + if (!Info->ReturnObject) + { + if (ExpectedReturnBtypes) + { + ACPI_ERROR_METHOD ("No object was returned from", + PrefixNode, Path, AE_NOT_EXIST); + + Status = AE_NOT_EXIST; + } + + goto Cleanup; + } + + /* Map the return object type to the bitmapped type */ + + switch ((Info->ReturnObject)->Common.Type) + { + case ACPI_TYPE_INTEGER: + ReturnBtype = ACPI_BTYPE_INTEGER; + break; + + case ACPI_TYPE_BUFFER: + ReturnBtype = ACPI_BTYPE_BUFFER; + break; + + case ACPI_TYPE_STRING: + ReturnBtype = ACPI_BTYPE_STRING; + break; + + case ACPI_TYPE_PACKAGE: + ReturnBtype = ACPI_BTYPE_PACKAGE; + break; + + default: + ReturnBtype = 0; + break; + } + + if ((AcpiGbl_EnableInterpreterSlack) && + (!ExpectedReturnBtypes)) + { + /* + * We received a return object, but one was not expected. This can + * happen frequently if the "implicit return" feature is enabled. + * Just delete the return object and return AE_OK. + */ + AcpiUtRemoveReference (Info->ReturnObject); + goto Cleanup; + } + + /* Is the return object one of the expected types? */ + + if (!(ExpectedReturnBtypes & ReturnBtype)) + { + ACPI_ERROR_METHOD ("Return object type is incorrect", + PrefixNode, Path, AE_TYPE); + + ACPI_ERROR ((AE_INFO, + "Type returned from %s was incorrect: %s, expected Btypes: %X", + Path, AcpiUtGetObjectTypeName (Info->ReturnObject), + ExpectedReturnBtypes)); + + /* On error exit, we must delete the return object */ + + AcpiUtRemoveReference (Info->ReturnObject); + Status = AE_TYPE; + goto Cleanup; + } + + /* Object type is OK, return it */ + + *ReturnDesc = Info->ReturnObject; + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtEvaluateNumericObject + * + * PARAMETERS: ObjectName - Object name to be evaluated + * DeviceNode - Node for the device + * Value - Where the value is returned + * + * RETURN: Status + * + * DESCRIPTION: Evaluates a numeric namespace object for a selected device + * and stores result in *Value. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtEvaluateNumericObject ( + char *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Value) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtEvaluateNumericObject); + + + Status = AcpiUtEvaluateObject (DeviceNode, ObjectName, + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the returned Integer */ + + *Value = ObjDesc->Integer.Value; + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_STA + * + * PARAMETERS: DeviceNode - Node for the device + * Flags - Where the status flags are returned + * + * RETURN: Status + * + * DESCRIPTION: Executes _STA for selected device and stores results in + * *Flags. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *Flags) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_STA); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA, + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (AE_NOT_FOUND == Status) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "_STA on %4.4s was not found, assuming device is present\n", + AcpiUtGetNodeName (DeviceNode))); + + *Flags = ACPI_UINT32_MAX; + Status = AE_OK; + } + + return_ACPI_STATUS (Status); + } + + /* Extract the status flags */ + + *Flags = (UINT32) ObjDesc->Integer.Value; + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecutePowerMethods + * + * PARAMETERS: DeviceNode - Node for the device + * MethodNames - Array of power method names + * MethodCount - Number of methods to execute + * OutValues - Where the power method values are returned + * + * RETURN: Status, OutValues + * + * DESCRIPTION: Executes the specified power methods for the device and returns + * the result(s). + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecutePowerMethods ( + ACPI_NAMESPACE_NODE *DeviceNode, + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_STATUS FinalStatus = AE_NOT_FOUND; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtExecutePowerMethods); + + + for (i = 0; i < MethodCount; i++) + { + /* + * Execute the power method (_SxD or _SxW). The only allowable + * return type is an Integer. + */ + Status = AcpiUtEvaluateObject (DeviceNode, + ACPI_CAST_PTR (char, MethodNames[i]), + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_SUCCESS (Status)) + { + OutValues[i] = (UINT8) ObjDesc->Integer.Value; + + /* Delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + FinalStatus = AE_OK; /* At least one value is valid */ + continue; + } + + OutValues[i] = ACPI_UINT8_MAX; + if (Status == AE_NOT_FOUND) + { + continue; /* Ignore if not found */ + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n", + ACPI_CAST_PTR (char, MethodNames[i]), + AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status))); + } + + return_ACPI_STATUS (FinalStatus); +} diff --git a/drivers/bus/acpi/acpica/utilities/utglobal.c b/drivers/bus/acpi/acpica/utilities/utglobal.c new file mode 100644 index 00000000000..b49ce352fbc --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utglobal.c @@ -0,0 +1,975 @@ +/****************************************************************************** + * + * Module Name: utglobal - Global variables for the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTGLOBAL_C__ +#define DEFINE_ACPI_GLOBALS + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utglobal") + + +/******************************************************************************* + * + * Static global variable initialization. + * + ******************************************************************************/ + +/* + * We want the debug switches statically initialized so they + * are already set when the debugger is entered. + */ + +/* Debug switch - level and trace mask */ + +#ifdef ACPI_DEBUG_OUTPUT +UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT; +#else +UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT; +#endif + +/* Debug switch - layer (component) mask */ + +UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; +UINT32 AcpiGbl_NestingLevel = 0; + +/* Debugger globals */ + +BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; +BOOLEAN AcpiGbl_AbortMethod = FALSE; +BOOLEAN AcpiGbl_MethodExecuting = FALSE; + +/* System flags */ + +UINT32 AcpiGbl_StartupFlags = 0; + +/* System starts uninitialized */ + +BOOLEAN AcpiGbl_Shutdown = TRUE; + +const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = +{ + "\\_S0_", + "\\_S1_", + "\\_S2_", + "\\_S3_", + "\\_S4_", + "\\_S5_" +}; + +const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS] = +{ + "_S0W", + "_S1W", + "_S2W", + "_S3W", + "_S4W" +}; + +const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = +{ + "_S1D", + "_S2D", + "_S3D", + "_S4D" +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiFormatException + * + * PARAMETERS: Status - The ACPI_STATUS code to be formatted + * + * RETURN: A string containing the exception text. A valid pointer is + * always returned. + * + * DESCRIPTION: This function translates an ACPI exception into an ASCII string + * It is here instead of utxface.c so it is always present. + * + ******************************************************************************/ + +const char * +AcpiFormatException ( + ACPI_STATUS Status) +{ + const char *Exception = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + Exception = AcpiUtValidateException (Status); + if (!Exception) + { + /* Exception code was not recognized */ + + ACPI_ERROR ((AE_INFO, + "Unknown exception code: 0x%8.8X", Status)); + + Exception = "UNKNOWN_STATUS_CODE"; + } + + return (ACPI_CAST_PTR (const char, Exception)); +} + +ACPI_EXPORT_SYMBOL (AcpiFormatException) + + +/******************************************************************************* + * + * Namespace globals + * + ******************************************************************************/ + +/* + * Predefined ACPI Names (Built-in to the Interpreter) + * + * NOTES: + * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run + * during the initialization sequence. + * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to + * perform a Notify() operation on it. + */ +const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = +{ + {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_SB_", ACPI_TYPE_DEVICE, NULL}, + {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_TZ_", ACPI_TYPE_THERMAL, NULL}, + {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, + {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, + {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, + +#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) + {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, +#endif + + /* Table terminator */ + + {NULL, ACPI_TYPE_ANY, NULL} +}; + +/* + * Properties of the ACPI Object Types, both internal and external. + * The table is indexed by values of ACPI_OBJECT_TYPE + */ +const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] = +{ + ACPI_NS_NORMAL, /* 00 Any */ + ACPI_NS_NORMAL, /* 01 Number */ + ACPI_NS_NORMAL, /* 02 String */ + ACPI_NS_NORMAL, /* 03 Buffer */ + ACPI_NS_NORMAL, /* 04 Package */ + ACPI_NS_NORMAL, /* 05 FieldUnit */ + ACPI_NS_NEWSCOPE, /* 06 Device */ + ACPI_NS_NORMAL, /* 07 Event */ + ACPI_NS_NEWSCOPE, /* 08 Method */ + ACPI_NS_NORMAL, /* 09 Mutex */ + ACPI_NS_NORMAL, /* 10 Region */ + ACPI_NS_NEWSCOPE, /* 11 Power */ + ACPI_NS_NEWSCOPE, /* 12 Processor */ + ACPI_NS_NEWSCOPE, /* 13 Thermal */ + ACPI_NS_NORMAL, /* 14 BufferField */ + ACPI_NS_NORMAL, /* 15 DdbHandle */ + ACPI_NS_NORMAL, /* 16 Debug Object */ + ACPI_NS_NORMAL, /* 17 DefField */ + ACPI_NS_NORMAL, /* 18 BankField */ + ACPI_NS_NORMAL, /* 19 IndexField */ + ACPI_NS_NORMAL, /* 20 Reference */ + ACPI_NS_NORMAL, /* 21 Alias */ + ACPI_NS_NORMAL, /* 22 MethodAlias */ + ACPI_NS_NORMAL, /* 23 Notify */ + ACPI_NS_NORMAL, /* 24 Address Handler */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ + ACPI_NS_NEWSCOPE, /* 27 Scope */ + ACPI_NS_NORMAL, /* 28 Extra */ + ACPI_NS_NORMAL, /* 29 Data */ + ACPI_NS_NORMAL /* 30 Invalid */ +}; + + +/* Hex to ASCII conversion table */ + +static const char AcpiGbl_HexToAscii[] = +{ + '0','1','2','3','4','5','6','7', + '8','9','A','B','C','D','E','F' +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtHexToAsciiChar + * + * PARAMETERS: Integer - Contains the hex digit + * Position - bit position of the digit within the + * integer (multiple of 4) + * + * RETURN: The converted Ascii character + * + * DESCRIPTION: Convert a hex digit to an Ascii character + * + ******************************************************************************/ + +char +AcpiUtHexToAsciiChar ( + ACPI_INTEGER Integer, + UINT32 Position) +{ + + return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); +} + + +/****************************************************************************** + * + * Event and Hardware globals + * + ******************************************************************************/ + +ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = +{ + /* Name Parent Register Register Bit Position Register Bit Mask */ + + /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, + /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, + /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, + /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, + /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, + /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, + /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, + /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, + + /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, + /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, + /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, + /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, + /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, + /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, + + /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, + /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, + /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, + /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE, ACPI_BITMASK_SLEEP_TYPE}, + /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, + + /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} +}; + + +ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = +{ + /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, + /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, + /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, + /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, + /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, +}; + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetRegionName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a Space ID into a name string (Debug only) + * + ******************************************************************************/ + +/* Region type decoding */ + +const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = +{ + "SystemMemory", + "SystemIO", + "PCI_Config", + "EmbeddedControl", + "SMBus", + "SystemCMOS", + "PCIBARTarget", + "IPMI", + "DataTable" +}; + + +char * +AcpiUtGetRegionName ( + UINT8 SpaceId) +{ + + if (SpaceId >= ACPI_USER_REGION_BEGIN) + { + return ("UserDefinedRegion"); + } + else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) + { + return ("InvalidSpaceId"); + } + + return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId])); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetEventName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a Event ID into a name string (Debug only) + * + ******************************************************************************/ + +/* Event type decoding */ + +static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = +{ + "PM_Timer", + "GlobalLock", + "PowerButton", + "SleepButton", + "RealTimeClock", +}; + + +char * +AcpiUtGetEventName ( + UINT32 EventId) +{ + + if (EventId > ACPI_EVENT_MAX) + { + return ("InvalidEventID"); + } + + return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId])); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetTypeName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a Type ID into a name string (Debug only) + * + ******************************************************************************/ + +/* + * Elements of AcpiGbl_NsTypeNames below must match + * one-to-one with values of ACPI_OBJECT_TYPE + * + * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; + * when stored in a table it really means that we have thus far seen no + * evidence to indicate what type is actually going to be stored for this entry. + */ +static const char AcpiGbl_BadType[] = "UNDEFINED"; + +/* Printable names of the ACPI object types */ + +static const char *AcpiGbl_NsTypeNames[] = +{ + /* 00 */ "Untyped", + /* 01 */ "Integer", + /* 02 */ "String", + /* 03 */ "Buffer", + /* 04 */ "Package", + /* 05 */ "FieldUnit", + /* 06 */ "Device", + /* 07 */ "Event", + /* 08 */ "Method", + /* 09 */ "Mutex", + /* 10 */ "Region", + /* 11 */ "Power", + /* 12 */ "Processor", + /* 13 */ "Thermal", + /* 14 */ "BufferField", + /* 15 */ "DdbHandle", + /* 16 */ "DebugObject", + /* 17 */ "RegionField", + /* 18 */ "BankField", + /* 19 */ "IndexField", + /* 20 */ "Reference", + /* 21 */ "Alias", + /* 22 */ "MethodAlias", + /* 23 */ "Notify", + /* 24 */ "AddrHandler", + /* 25 */ "ResourceDesc", + /* 26 */ "ResourceFld", + /* 27 */ "Scope", + /* 28 */ "Extra", + /* 29 */ "Data", + /* 30 */ "Invalid" +}; + + +char * +AcpiUtGetTypeName ( + ACPI_OBJECT_TYPE Type) +{ + + if (Type > ACPI_TYPE_INVALID) + { + return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); + } + + return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type])); +} + + +char * +AcpiUtGetObjectTypeName ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + if (!ObjDesc) + { + return ("[NULL Object Descriptor]"); + } + + return (AcpiUtGetTypeName (ObjDesc->Common.Type)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetNodeName + * + * PARAMETERS: Object - A namespace node + * + * RETURN: Pointer to a string + * + * DESCRIPTION: Validate the node and return the node's ACPI name. + * + ******************************************************************************/ + +char * +AcpiUtGetNodeName ( + void *Object) +{ + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object; + + + /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ + + if (!Object) + { + return ("NULL"); + } + + /* Check for Root node */ + + if ((Object == ACPI_ROOT_OBJECT) || + (Object == AcpiGbl_RootNode)) + { + return ("\"\\\" "); + } + + /* Descriptor must be a namespace node */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + return ("####"); + } + + /* + * Ensure name is valid. The name was validated/repaired when the node + * was created, but make sure it has not been corrupted. + */ + AcpiUtRepairName (Node->Name.Ascii); + + /* Return the name */ + + return (Node->Name.Ascii); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetDescriptorName + * + * PARAMETERS: Object - An ACPI object + * + * RETURN: Pointer to a string + * + * DESCRIPTION: Validate object and return the descriptor type + * + ******************************************************************************/ + +/* Printable names of object descriptor types */ + +static const char *AcpiGbl_DescTypeNames[] = +{ + /* 00 */ "Invalid", + /* 01 */ "Cached", + /* 02 */ "State-Generic", + /* 03 */ "State-Update", + /* 04 */ "State-Package", + /* 05 */ "State-Control", + /* 06 */ "State-RootParseScope", + /* 07 */ "State-ParseScope", + /* 08 */ "State-WalkScope", + /* 09 */ "State-Result", + /* 10 */ "State-Notify", + /* 11 */ "State-Thread", + /* 12 */ "Walk", + /* 13 */ "Parser", + /* 14 */ "Operand", + /* 15 */ "Node" +}; + + +char * +AcpiUtGetDescriptorName ( + void *Object) +{ + + if (!Object) + { + return ("NULL OBJECT"); + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX) + { + return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); + } + + return (ACPI_CAST_PTR (char, + AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)])); + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetReferenceName + * + * PARAMETERS: Object - An ACPI reference object + * + * RETURN: Pointer to a string + * + * DESCRIPTION: Decode a reference object sub-type to a string. + * + ******************************************************************************/ + +/* Printable names of reference object sub-types */ + +static const char *AcpiGbl_RefClassNames[] = +{ + /* 00 */ "Local", + /* 01 */ "Argument", + /* 02 */ "RefOf", + /* 03 */ "Index", + /* 04 */ "DdbHandle", + /* 05 */ "Named Object", + /* 06 */ "Debug" +}; + +const char * +AcpiUtGetReferenceName ( + ACPI_OPERAND_OBJECT *Object) +{ + + if (!Object) + { + return ("NULL Object"); + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) + { + return ("Not an Operand object"); + } + + if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return ("Not a Reference object"); + } + + if (Object->Reference.Class > ACPI_REFCLASS_MAX) + { + return ("Unknown Reference class"); + } + + return (AcpiGbl_RefClassNames[Object->Reference.Class]); +} + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/* + * Strings and procedures used for debug only + */ + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetMutexName + * + * PARAMETERS: MutexId - The predefined ID for this mutex. + * + * RETURN: String containing the name of the mutex. Always returns a valid + * pointer. + * + * DESCRIPTION: Translate a mutex ID into a name string (Debug only) + * + ******************************************************************************/ + +char * +AcpiUtGetMutexName ( + UINT32 MutexId) +{ + + if (MutexId > ACPI_MAX_MUTEX) + { + return ("Invalid Mutex ID"); + } + + return (AcpiGbl_MutexNames[MutexId]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetNotifyName + * + * PARAMETERS: NotifyValue - Value from the Notify() request + * + * RETURN: String corresponding to the Notify Value. + * + * DESCRIPTION: Translate a Notify Value to a notify namestring. + * + ******************************************************************************/ + +/* Names for Notify() values, used for debug output */ + +static const char *AcpiGbl_NotifyValueNames[] = +{ + "Bus Check", + "Device Check", + "Device Wake", + "Eject Request", + "Device Check Light", + "Frequency Mismatch", + "Bus Mode Mismatch", + "Power Fault", + "Capabilities Check", + "Device PLD Check", + "Reserved", + "System Locality Update" +}; + +const char * +AcpiUtGetNotifyName ( + UINT32 NotifyValue) +{ + + if (NotifyValue <= ACPI_NOTIFY_MAX) + { + return (AcpiGbl_NotifyValueNames[NotifyValue]); + } + else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) + { + return ("Reserved"); + } + else /* Greater or equal to 0x80 */ + { + return ("**Device Specific**"); + } +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidObjectType + * + * PARAMETERS: Type - Object type to be validated + * + * RETURN: TRUE if valid object type, FALSE otherwise + * + * DESCRIPTION: Validate an object type + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidObjectType ( + ACPI_OBJECT_TYPE Type) +{ + + if (Type > ACPI_TYPE_LOCAL_MAX) + { + /* Note: Assumes all TYPEs are contiguous (external/local) */ + + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInitGlobals + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Init library globals. All globals that require specific + * initialization should be initialized here! + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtInitGlobals ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtInitGlobals); + + + /* Create all memory caches */ + + Status = AcpiUtCreateCaches (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Mutex locked flags */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + AcpiGbl_MutexInfo[i].Mutex = NULL; + AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[i].UseCount = 0; + } + + for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) + { + AcpiGbl_OwnerIdMask[i] = 0; + } + + /* Last OwnerID is never valid */ + + AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; + + /* Event counters */ + + AcpiMethodCount = 0; + AcpiSciCount = 0; + AcpiGpeCount = 0; + + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + AcpiFixedEventCount[i] = 0; + } + + /* GPE support */ + + AcpiGbl_GpeXruptListHead = NULL; + AcpiGbl_GpeFadtBlocks[0] = NULL; + AcpiGbl_GpeFadtBlocks[1] = NULL; + AcpiCurrentGpeCount = 0; + + /* Global handlers */ + + AcpiGbl_SystemNotify.Handler = NULL; + AcpiGbl_DeviceNotify.Handler = NULL; + AcpiGbl_ExceptionHandler = NULL; + AcpiGbl_InitHandler = NULL; + AcpiGbl_TableHandler = NULL; + + /* Global Lock support */ + + AcpiGbl_GlobalLockSemaphore = NULL; + AcpiGbl_GlobalLockMutex = NULL; + AcpiGbl_GlobalLockAcquired = FALSE; + AcpiGbl_GlobalLockHandle = 0; + AcpiGbl_GlobalLockPresent = FALSE; + + /* Miscellaneous variables */ + + AcpiGbl_CmSingleStep = FALSE; + AcpiGbl_DbTerminateThreads = FALSE; + AcpiGbl_Shutdown = FALSE; + AcpiGbl_NsLookupCount = 0; + AcpiGbl_PsFindCount = 0; + AcpiGbl_AcpiHardwarePresent = TRUE; + AcpiGbl_LastOwnerIdIndex = 0; + AcpiGbl_NextOwnerIdOffset = 0; + AcpiGbl_TraceMethodName = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; + AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; + AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; + AcpiGbl_OsiData = 0; + + /* Hardware oriented */ + + AcpiGbl_EventsInitialized = FALSE; + AcpiGbl_SystemAwakeAndRunning = TRUE; + + /* Namespace */ + + AcpiGbl_ModuleCodeList = NULL; + AcpiGbl_RootNode = NULL; + AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; + AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; + AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; + AcpiGbl_RootNodeStruct.Child = NULL; + AcpiGbl_RootNodeStruct.Peer = NULL; + AcpiGbl_RootNodeStruct.Object = NULL; + AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; + + +#ifdef ACPI_DISASSEMBLER + AcpiGbl_ExternalList = NULL; +#endif + +#ifdef ACPI_DEBUG_OUTPUT + AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); +#endif + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + AcpiGbl_DisplayFinalMemStats = FALSE; +#endif + + return_ACPI_STATUS (AE_OK); +} + +/* Public globals */ + +ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) +ACPI_EXPORT_SYMBOL (AcpiDbgLevel) +ACPI_EXPORT_SYMBOL (AcpiDbgLayer) +ACPI_EXPORT_SYMBOL (AcpiGpeCount) +ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount) + + diff --git a/drivers/bus/acpi/acpica/utilities/utids.c b/drivers/bus/acpi/acpica/utilities/utids.c new file mode 100644 index 00000000000..76693305008 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utids.c @@ -0,0 +1,497 @@ +/****************************************************************************** + * + * Module Name: utids - support for device IDs - HID, UID, CID + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTIDS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utids") + +/* Local prototypes */ + +static void +AcpiUtCopyIdString ( + char *Destination, + char *Source); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIdString + * + * PARAMETERS: Destination - Where to copy the string + * Source - Source string + * + * RETURN: None + * + * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods. + * Performs removal of a leading asterisk if present -- workaround + * for a known issue on a bunch of machines. + * + ******************************************************************************/ + +static void +AcpiUtCopyIdString ( + char *Destination, + char *Source) +{ + + /* + * Workaround for ID strings that have a leading asterisk. This construct + * is not allowed by the ACPI specification (ID strings must be + * alphanumeric), but enough existing machines have this embedded in their + * ID strings that the following code is useful. + */ + if (*Source == '*') + { + Source++; + } + + /* Do the actual copy */ + + ACPI_STRCPY (Destination, Source); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_HID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the string HID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _HID control method that returns the hardware + * ID of the device. The HID is either an 32-bit encoded EISAID + * Integer or a String. A string is always returned. An EISAID + * is converted to a string. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID *Hid; + UINT32 Length; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_HID); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + Length = ACPI_EISAID_STRING_SIZE; + } + else + { + Length = ObjDesc->String.Length + 1; + } + + /* Allocate a buffer for the HID */ + + Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Hid) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after DEVICE_ID struct */ + + Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_DEVICE_ID)); + + /* Convert EISAID to a string or simply copy existing string */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + AcpiExEisaIdToString (Hid->String, ObjDesc->Integer.Value); + } + else + { + AcpiUtCopyIdString (Hid->String, ObjDesc->String.Pointer); + } + + Hid->Length = Length; + *ReturnId = Hid; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_UID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the string UID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _UID control method that returns the unique + * ID of the device. The UID is either a 64-bit Integer (NOT an + * EISAID) or a string. Always returns a string. A 64-bit integer + * is converted to a decimal string. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID *Uid; + UINT32 Length; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_UID); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + Length = ACPI_MAX64_DECIMAL_DIGITS + 1; + } + else + { + Length = ObjDesc->String.Length + 1; + } + + /* Allocate a buffer for the UID */ + + Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Uid) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after DEVICE_ID struct */ + + Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_DEVICE_ID)); + + /* Convert an Integer to string, or just copy an existing string */ + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + AcpiExIntegerToString (Uid->String, ObjDesc->Integer.Value); + } + else + { + AcpiUtCopyIdString (Uid->String, ObjDesc->String.Pointer); + } + + Uid->Length = Length; + *ReturnId = Uid; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_CID + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnCidList - Where the CID list is returned + * + * RETURN: Status, list of CID strings + * + * DESCRIPTION: Executes the _CID control method that returns one or more + * compatible hardware IDs for the device. + * + * NOTE: Internal function, no parameter validation + * + * A _CID method can return either a single compatible ID or a package of + * compatible IDs. Each compatible ID can be one of the following: + * 1) Integer (32 bit compressed EISA ID) or + * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") + * + * The Integer CIDs are converted to string format by this function. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_CID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID_LIST **ReturnCidList) +{ + ACPI_OPERAND_OBJECT **CidObjects; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_DEVICE_ID_LIST *CidList; + char *NextIdString; + UINT32 StringAreaSize; + UINT32 Length; + UINT32 CidListSize; + ACPI_STATUS Status; + UINT32 Count; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtExecute_CID); + + + /* Evaluate the _CID method for this device */ + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Get the count and size of the returned _CIDs. _CID can return either + * a Package of Integers/Strings or a single Integer or String. + * Note: This section also validates that all CID elements are of the + * correct type (Integer or String). + */ + if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + Count = ObjDesc->Package.Count; + CidObjects = ObjDesc->Package.Elements; + } + else /* Single Integer or String CID */ + { + Count = 1; + CidObjects = &ObjDesc; + } + + StringAreaSize = 0; + for (i = 0; i < Count; i++) + { + /* String lengths include null terminator */ + + switch (CidObjects[i]->Common.Type) + { + case ACPI_TYPE_INTEGER: + StringAreaSize += ACPI_EISAID_STRING_SIZE; + break; + + case ACPI_TYPE_STRING: + StringAreaSize += CidObjects[i]->String.Length + 1; + break; + + default: + Status = AE_TYPE; + goto Cleanup; + } + } + + /* + * Now that we know the length of the CIDs, allocate return buffer: + * 1) Size of the base structure + + * 2) Size of the CID DEVICE_ID array + + * 3) Size of the actual CID strings + */ + CidListSize = sizeof (ACPI_DEVICE_ID_LIST) + + ((Count - 1) * sizeof (ACPI_DEVICE_ID)) + + StringAreaSize; + + CidList = ACPI_ALLOCATE_ZEROED (CidListSize); + if (!CidList) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for CID strings starts after the CID DEVICE_ID array */ + + NextIdString = ACPI_CAST_PTR (char, CidList->Ids) + + ((ACPI_SIZE) Count * sizeof (ACPI_DEVICE_ID)); + + /* Copy/convert the CIDs to the return buffer */ + + for (i = 0; i < Count; i++) + { + if (CidObjects[i]->Common.Type == ACPI_TYPE_INTEGER) + { + /* Convert the Integer (EISAID) CID to a string */ + + AcpiExEisaIdToString (NextIdString, CidObjects[i]->Integer.Value); + Length = ACPI_EISAID_STRING_SIZE; + } + else /* ACPI_TYPE_STRING */ + { + /* Copy the String CID from the returned object */ + + AcpiUtCopyIdString (NextIdString, CidObjects[i]->String.Pointer); + Length = CidObjects[i]->String.Length + 1; + } + + CidList->Ids[i].String = NextIdString; + CidList->Ids[i].Length = Length; + NextIdString += Length; + } + + /* Finish the CID list */ + + CidList->Count = Count; + CidList->ListSize = CidListSize; + *ReturnCidList = CidList; + + +Cleanup: + + /* On exit, we must delete the _CID return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + diff --git a/drivers/bus/acpi/acpica/utilities/utinit.c b/drivers/bus/acpi/acpica/utilities/utinit.c new file mode 100644 index 00000000000..d59904b46a2 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utinit.c @@ -0,0 +1,228 @@ +/****************************************************************************** + * + * Module Name: utinit - Common ACPI subsystem initialization + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTINIT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utinit") + +/* Local prototypes */ + +static void AcpiUtTerminate ( + void); + + +/****************************************************************************** + * + * FUNCTION: AcpiUtTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Free global memory + * + ******************************************************************************/ + +static void +AcpiUtTerminate ( + void) +{ + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_BLOCK_INFO *NextGpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptInfo; + ACPI_GPE_XRUPT_INFO *NextGpeXruptInfo; + + + ACPI_FUNCTION_TRACE (UtTerminate); + + + /* Free global GPE blocks and related info structures */ + + GpeXruptInfo = AcpiGbl_GpeXruptListHead; + while (GpeXruptInfo) + { + GpeBlock = GpeXruptInfo->GpeBlockListHead; + while (GpeBlock) + { + NextGpeBlock = GpeBlock->Next; + ACPI_FREE (GpeBlock->EventInfo); + ACPI_FREE (GpeBlock->RegisterInfo); + ACPI_FREE (GpeBlock); + + GpeBlock = NextGpeBlock; + } + NextGpeXruptInfo = GpeXruptInfo->Next; + ACPI_FREE (GpeXruptInfo); + GpeXruptInfo = NextGpeXruptInfo; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtSubsystemShutdown + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Shutdown the various components. Do not delete the mutex + * objects here, because the AML debugger may be still running. + * + ******************************************************************************/ + +void +AcpiUtSubsystemShutdown ( + void) +{ + ACPI_FUNCTION_TRACE (UtSubsystemShutdown); + + +#ifndef ACPI_ASL_COMPILER + + /* Close the AcpiEvent Handling */ + + AcpiEvTerminate (); +#endif + + /* Close the Namespace */ + + AcpiNsTerminate (); + + /* Delete the ACPI tables */ + + AcpiTbTerminate (); + + /* Close the globals */ + + AcpiUtTerminate (); + + /* Purge the local caches */ + + (void) AcpiUtDeleteCaches (); + return_VOID; +} + + diff --git a/drivers/bus/acpi/acpica/utilities/utlock.c b/drivers/bus/acpi/acpica/utilities/utlock.c new file mode 100644 index 00000000000..dd4e100001a --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utlock.c @@ -0,0 +1,277 @@ +/****************************************************************************** + * + * Module Name: utlock - Reader/Writer lock interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTLOCK_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utlock") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateRwLock + * AcpiUtDeleteRwLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader/writer lock creation and deletion interfaces. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateRwLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Lock->NumReaders = 0; + Status = AcpiOsCreateMutex (&Lock->ReaderMutex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateMutex (&Lock->WriterMutex); + return (Status); +} + + +void +AcpiUtDeleteRwLock ( + ACPI_RW_LOCK *Lock) +{ + + AcpiOsDeleteMutex (Lock->ReaderMutex); + AcpiOsDeleteMutex (Lock->WriterMutex); + + Lock->NumReaders = 0; + Lock->ReaderMutex = NULL; + Lock->WriterMutex = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireReadLock + * AcpiUtReleaseReadLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader interfaces for reader/writer locks. On acquisition, + * only the first reader acquires the write mutex. On release, + * only the last reader releases the write mutex. Although this + * algorithm can in theory starve writers, this should not be a + * problem with ACPICA since the subsystem is infrequently used + * in comparison to (for example) an I/O system. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireReadLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Acquire the write lock only for the first reader */ + + Lock->NumReaders++; + if (Lock->NumReaders == 1) + { + Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER); + } + + AcpiOsReleaseMutex (Lock->ReaderMutex); + return (Status); +} + + +ACPI_STATUS +AcpiUtReleaseReadLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Release the write lock only for the very last reader */ + + Lock->NumReaders--; + if (Lock->NumReaders == 0) + { + AcpiOsReleaseMutex (Lock->WriterMutex); + } + + AcpiOsReleaseMutex (Lock->ReaderMutex); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireWriteLock + * AcpiUtReleaseWriteLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Writer interfaces for reader/writer locks. Simply acquire or + * release the writer mutex associated with the lock. Acquisition + * of the lock is fully exclusive and will block all readers and + * writers until it is released. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireWriteLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER); + return (Status); +} + + +void +AcpiUtReleaseWriteLock ( + ACPI_RW_LOCK *Lock) +{ + + AcpiOsReleaseMutex (Lock->WriterMutex); +} + diff --git a/drivers/bus/acpi/acpica/utilities/utmath.c b/drivers/bus/acpi/acpica/utilities/utmath.c new file mode 100644 index 00000000000..b0a40ff2bcf --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utmath.c @@ -0,0 +1,431 @@ +/******************************************************************************* + * + * Module Name: utmath - Integer math support routines + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTMATH_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmath") + +/* + * Support for double-precision integer divide. This code is included here + * in order to support kernel environments where the double-precision math + * library is not available. + */ + +#ifndef ACPI_USE_NATIVE_DIVIDE +/******************************************************************************* + * + * FUNCTION: AcpiUtShortDivide + * + * PARAMETERS: Dividend - 64-bit dividend + * Divisor - 32-bit divisor + * OutQuotient - Pointer to where the quotient is returned + * OutRemainder - Pointer to where the remainder is returned + * + * RETURN: Status (Checks for divide-by-zero) + * + * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits) + * divide and modulo. The result is a 64-bit quotient and a + * 32-bit remainder. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtShortDivide ( + ACPI_INTEGER Dividend, + UINT32 Divisor, + ACPI_INTEGER *OutQuotient, + UINT32 *OutRemainder) +{ + UINT64_OVERLAY DividendOvl; + UINT64_OVERLAY Quotient; + UINT32 Remainder32; + + + ACPI_FUNCTION_TRACE (UtShortDivide); + + + /* Always check for a zero divisor */ + + if (Divisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + DividendOvl.Full = Dividend; + + /* + * The quotient is 64 bits, the remainder is always 32 bits, + * and is generated by the second divide. + */ + ACPI_DIV_64_BY_32 (0, DividendOvl.Part.Hi, Divisor, + Quotient.Part.Hi, Remainder32); + ACPI_DIV_64_BY_32 (Remainder32, DividendOvl.Part.Lo, Divisor, + Quotient.Part.Lo, Remainder32); + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = Quotient.Full; + } + if (OutRemainder) + { + *OutRemainder = Remainder32; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDivide + * + * PARAMETERS: InDividend - Dividend + * InDivisor - Divisor + * OutQuotient - Pointer to where the quotient is returned + * OutRemainder - Pointer to where the remainder is returned + * + * RETURN: Status (Checks for divide-by-zero) + * + * DESCRIPTION: Perform a divide and modulo. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtDivide ( + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, + ACPI_INTEGER *OutQuotient, + ACPI_INTEGER *OutRemainder) +{ + UINT64_OVERLAY Dividend; + UINT64_OVERLAY Divisor; + UINT64_OVERLAY Quotient; + UINT64_OVERLAY Remainder; + UINT64_OVERLAY NormalizedDividend; + UINT64_OVERLAY NormalizedDivisor; + UINT32 Partial1; + UINT64_OVERLAY Partial2; + UINT64_OVERLAY Partial3; + + + ACPI_FUNCTION_TRACE (UtDivide); + + + /* Always check for a zero divisor */ + + if (InDivisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + Divisor.Full = InDivisor; + Dividend.Full = InDividend; + if (Divisor.Part.Hi == 0) + { + /* + * 1) Simplest case is where the divisor is 32 bits, we can + * just do two divides + */ + Remainder.Part.Hi = 0; + + /* + * The quotient is 64 bits, the remainder is always 32 bits, + * and is generated by the second divide. + */ + ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor.Part.Lo, + Quotient.Part.Hi, Partial1); + ACPI_DIV_64_BY_32 (Partial1, Dividend.Part.Lo, Divisor.Part.Lo, + Quotient.Part.Lo, Remainder.Part.Lo); + } + + else + { + /* + * 2) The general case where the divisor is a full 64 bits + * is more difficult + */ + Quotient.Part.Hi = 0; + NormalizedDividend = Dividend; + NormalizedDivisor = Divisor; + + /* Normalize the operands (shift until the divisor is < 32 bits) */ + + do + { + ACPI_SHIFT_RIGHT_64 (NormalizedDivisor.Part.Hi, + NormalizedDivisor.Part.Lo); + ACPI_SHIFT_RIGHT_64 (NormalizedDividend.Part.Hi, + NormalizedDividend.Part.Lo); + + } while (NormalizedDivisor.Part.Hi != 0); + + /* Partial divide */ + + ACPI_DIV_64_BY_32 (NormalizedDividend.Part.Hi, + NormalizedDividend.Part.Lo, + NormalizedDivisor.Part.Lo, + Quotient.Part.Lo, Partial1); + + /* + * The quotient is always 32 bits, and simply requires adjustment. + * The 64-bit remainder must be generated. + */ + Partial1 = Quotient.Part.Lo * Divisor.Part.Hi; + Partial2.Full = (ACPI_INTEGER) Quotient.Part.Lo * Divisor.Part.Lo; + Partial3.Full = (ACPI_INTEGER) Partial2.Part.Hi + Partial1; + + Remainder.Part.Hi = Partial3.Part.Lo; + Remainder.Part.Lo = Partial2.Part.Lo; + + if (Partial3.Part.Hi == 0) + { + if (Partial3.Part.Lo >= Dividend.Part.Hi) + { + if (Partial3.Part.Lo == Dividend.Part.Hi) + { + if (Partial2.Part.Lo > Dividend.Part.Lo) + { + Quotient.Part.Lo--; + Remainder.Full -= Divisor.Full; + } + } + else + { + Quotient.Part.Lo--; + Remainder.Full -= Divisor.Full; + } + } + + Remainder.Full = Remainder.Full - Dividend.Full; + Remainder.Part.Hi = (UINT32) -((INT32) Remainder.Part.Hi); + Remainder.Part.Lo = (UINT32) -((INT32) Remainder.Part.Lo); + + if (Remainder.Part.Lo) + { + Remainder.Part.Hi--; + } + } + } + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = Quotient.Full; + } + if (OutRemainder) + { + *OutRemainder = Remainder.Full; + } + + return_ACPI_STATUS (AE_OK); +} + +#else + +/******************************************************************************* + * + * FUNCTION: AcpiUtShortDivide, AcpiUtDivide + * + * PARAMETERS: See function headers above + * + * DESCRIPTION: Native versions of the UtDivide functions. Use these if either + * 1) The target is a 64-bit platform and therefore 64-bit + * integer math is supported directly by the machine. + * 2) The target is a 32-bit or 16-bit platform, and the + * double-precision integer math library is available to + * perform the divide. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtShortDivide ( + ACPI_INTEGER InDividend, + UINT32 Divisor, + ACPI_INTEGER *OutQuotient, + UINT32 *OutRemainder) +{ + + ACPI_FUNCTION_TRACE (UtShortDivide); + + + /* Always check for a zero divisor */ + + if (Divisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = InDividend / Divisor; + } + if (OutRemainder) + { + *OutRemainder = (UINT32) (InDividend % Divisor); + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_STATUS +AcpiUtDivide ( + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, + ACPI_INTEGER *OutQuotient, + ACPI_INTEGER *OutRemainder) +{ + ACPI_FUNCTION_TRACE (UtDivide); + + + /* Always check for a zero divisor */ + + if (InDivisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = InDividend / InDivisor; + } + if (OutRemainder) + { + *OutRemainder = InDividend % InDivisor; + } + + return_ACPI_STATUS (AE_OK); +} + +#endif + + diff --git a/drivers/bus/acpi/acpica/utilities/utmisc.c b/drivers/bus/acpi/acpica/utilities/utmisc.c new file mode 100644 index 00000000000..bc27cd52938 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utmisc.c @@ -0,0 +1,1485 @@ +/******************************************************************************* + * + * Module Name: utmisc - common utility procedures + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTMISC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmisc") + +/* + * Common suffix for messages + */ +#define ACPI_COMMON_MSG_SUFFIX \ + AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidateException + * + * PARAMETERS: Status - The ACPI_STATUS code to be formatted + * + * RETURN: A string containing the exception text. NULL if exception is + * not valid. + * + * DESCRIPTION: This function validates and translates an ACPI exception into + * an ASCII string. + * + ******************************************************************************/ + +const char * +AcpiUtValidateException ( + ACPI_STATUS Status) +{ + UINT32 SubStatus; + const char *Exception = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Status is composed of two parts, a "type" and an actual code + */ + SubStatus = (Status & ~AE_CODE_MASK); + + switch (Status & AE_CODE_MASK) + { + case AE_CODE_ENVIRONMENTAL: + + if (SubStatus <= AE_CODE_ENV_MAX) + { + Exception = AcpiGbl_ExceptionNames_Env [SubStatus]; + } + break; + + case AE_CODE_PROGRAMMER: + + if (SubStatus <= AE_CODE_PGM_MAX) + { + Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus]; + } + break; + + case AE_CODE_ACPI_TABLES: + + if (SubStatus <= AE_CODE_TBL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus]; + } + break; + + case AE_CODE_AML: + + if (SubStatus <= AE_CODE_AML_MAX) + { + Exception = AcpiGbl_ExceptionNames_Aml [SubStatus]; + } + break; + + case AE_CODE_CONTROL: + + if (SubStatus <= AE_CODE_CTRL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus]; + } + break; + + default: + break; + } + + return (ACPI_CAST_PTR (const char, Exception)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtIsPciRootBridge + * + * PARAMETERS: Id - The HID/CID in string format + * + * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id) +{ + + /* + * Check if this is a PCI root bridge. + * ACPI 3.0+: check for a PCI Express root also. + */ + if (!(ACPI_STRCMP (Id, + PCI_ROOT_HID_STRING)) || + + !(ACPI_STRCMP (Id, + PCI_EXPRESS_ROOT_HID_STRING))) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtIsAmlTable + * + * PARAMETERS: Table - An ACPI table + * + * RETURN: TRUE if table contains executable AML; FALSE otherwise + * + * DESCRIPTION: Check ACPI Signature for a table that contains AML code. + * Currently, these are DSDT,SSDT,PSDT. All other table types are + * data tables that do not contain AML code. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtIsAmlTable ( + ACPI_TABLE_HEADER *Table) +{ + + /* These are the only tables that contain executable AML */ + + if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) || + ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) || + ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateOwnerId + * + * PARAMETERS: OwnerId - Where the new owner ID is returned + * + * RETURN: Status + * + * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to + * track objects created by the table or method, to be deleted + * when the method exits or the table is unloaded. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAllocateOwnerId ( + ACPI_OWNER_ID *OwnerId) +{ + UINT32 i; + UINT32 j; + UINT32 k; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtAllocateOwnerId); + + + /* Guard against multiple allocations of ID to the same location */ + + if (*OwnerId) + { + ACPI_ERROR ((AE_INFO, "Owner ID [%2.2X] already exists", *OwnerId)); + return_ACPI_STATUS (AE_ALREADY_EXISTS); + } + + /* Mutex for the global ID mask */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Find a free owner ID, cycle through all possible IDs on repeated + * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have + * to be scanned twice. + */ + for (i = 0, j = AcpiGbl_LastOwnerIdIndex; + i < (ACPI_NUM_OWNERID_MASKS + 1); + i++, j++) + { + if (j >= ACPI_NUM_OWNERID_MASKS) + { + j = 0; /* Wraparound to start of mask array */ + } + + for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++) + { + if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX) + { + /* There are no free IDs in this mask */ + + break; + } + + if (!(AcpiGbl_OwnerIdMask[j] & (1 << k))) + { + /* + * Found a free ID. The actual ID is the bit index plus one, + * making zero an invalid Owner ID. Save this as the last ID + * allocated and update the global ID mask. + */ + AcpiGbl_OwnerIdMask[j] |= (1 << k); + + AcpiGbl_LastOwnerIdIndex = (UINT8) j; + AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1); + + /* + * Construct encoded ID from the index and bit position + * + * Note: Last [j].k (bit 255) is never used and is marked + * permanently allocated (prevents +1 overflow) + */ + *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j)); + + ACPI_DEBUG_PRINT ((ACPI_DB_VALUES, + "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId)); + goto Exit; + } + } + + AcpiGbl_NextOwnerIdOffset = 0; + } + + /* + * All OwnerIds have been allocated. This typically should + * not happen since the IDs are reused after deallocation. The IDs are + * allocated upon table load (one per table) and method execution, and + * they are released when a table is unloaded or a method completes + * execution. + * + * If this error happens, there may be very deep nesting of invoked control + * methods, or there may be a bug where the IDs are not released. + */ + Status = AE_OWNER_ID_LIMIT; + ACPI_ERROR ((AE_INFO, + "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT")); + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReleaseOwnerId + * + * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID + * + * RETURN: None. No error is returned because we are either exiting a + * control method or unloading a table. Either way, we would + * ignore any error anyway. + * + * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 + * + ******************************************************************************/ + +void +AcpiUtReleaseOwnerId ( + ACPI_OWNER_ID *OwnerIdPtr) +{ + ACPI_OWNER_ID OwnerId = *OwnerIdPtr; + ACPI_STATUS Status; + UINT32 Index; + UINT32 Bit; + + + ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId); + + + /* Always clear the input OwnerId (zero is an invalid ID) */ + + *OwnerIdPtr = 0; + + /* Zero is not a valid OwnerID */ + + if (OwnerId == 0) + { + ACPI_ERROR ((AE_INFO, "Invalid OwnerId: %2.2X", OwnerId)); + return_VOID; + } + + /* Mutex for the global ID mask */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Normalize the ID to zero */ + + OwnerId--; + + /* Decode ID to index/offset pair */ + + Index = ACPI_DIV_32 (OwnerId); + Bit = 1 << ACPI_MOD_32 (OwnerId); + + /* Free the owner ID only if it is valid */ + + if (AcpiGbl_OwnerIdMask[Index] & Bit) + { + AcpiGbl_OwnerIdMask[Index] ^= Bit; + } + else + { + ACPI_ERROR ((AE_INFO, + "Release of non-allocated OwnerId: %2.2X", OwnerId + 1)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrupr (strupr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: None + * + * DESCRIPTION: Convert string to uppercase + * + * NOTE: This is not a POSIX function, so it appears here, not in utclib.c + * + ******************************************************************************/ + +void +AcpiUtStrupr ( + char *SrcString) +{ + char *String; + + + ACPI_FUNCTION_ENTRY (); + + + if (!SrcString) + { + return; + } + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) ACPI_TOUPPER (*String); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPrintString + * + * PARAMETERS: String - Null terminated ASCII string + * MaxLength - Maximum output length + * + * RETURN: None + * + * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape + * sequences. + * + ******************************************************************************/ + +void +AcpiUtPrintString ( + char *String, + UINT8 MaxLength) +{ + UINT32 i; + + + if (!String) + { + AcpiOsPrintf ("<\"NULL STRING PTR\">"); + return; + } + + AcpiOsPrintf ("\""); + for (i = 0; String[i] && (i < MaxLength); i++) + { + /* Escape sequences */ + + switch (String[i]) + { + case 0x07: + AcpiOsPrintf ("\\a"); /* BELL */ + break; + + case 0x08: + AcpiOsPrintf ("\\b"); /* BACKSPACE */ + break; + + case 0x0C: + AcpiOsPrintf ("\\f"); /* FORMFEED */ + break; + + case 0x0A: + AcpiOsPrintf ("\\n"); /* LINEFEED */ + break; + + case 0x0D: + AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/ + break; + + case 0x09: + AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */ + break; + + case 0x0B: + AcpiOsPrintf ("\\v"); /* VERTICAL TAB */ + break; + + case '\'': /* Single Quote */ + case '\"': /* Double Quote */ + case '\\': /* Backslash */ + AcpiOsPrintf ("\\%c", (int) String[i]); + break; + + default: + + /* Check for printable character or hex escape */ + + if (ACPI_IS_PRINT (String[i])) + { + /* This is a normal character */ + + AcpiOsPrintf ("%c", (int) String[i]); + } + else + { + /* All others will be Hex escapes */ + + AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]); + } + break; + } + } + AcpiOsPrintf ("\""); + + if (i == MaxLength && String[i]) + { + AcpiOsPrintf ("..."); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDwordByteSwap + * + * PARAMETERS: Value - Value to be converted + * + * RETURN: UINT32 integer with bytes swapped + * + * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) + * + ******************************************************************************/ + +UINT32 +AcpiUtDwordByteSwap ( + UINT32 Value) +{ + union + { + UINT32 Value; + UINT8 Bytes[4]; + } Out; + union + { + UINT32 Value; + UINT8 Bytes[4]; + } In; + + + ACPI_FUNCTION_ENTRY (); + + + In.Value = Value; + + Out.Bytes[0] = In.Bytes[3]; + Out.Bytes[1] = In.Bytes[2]; + Out.Bytes[2] = In.Bytes[1]; + Out.Bytes[3] = In.Bytes[0]; + + return (Out.Value); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtSetIntegerWidth + * + * PARAMETERS: Revision From DSDT header + * + * RETURN: None + * + * DESCRIPTION: Set the global integer bit width based upon the revision + * of the DSDT. For Revision 1 and 0, Integers are 32 bits. + * For Revision 2 and above, Integers are 64 bits. Yes, this + * makes a difference. + * + ******************************************************************************/ + +void +AcpiUtSetIntegerWidth ( + UINT8 Revision) +{ + + if (Revision < 2) + { + /* 32-bit case */ + + AcpiGbl_IntegerBitWidth = 32; + AcpiGbl_IntegerNybbleWidth = 8; + AcpiGbl_IntegerByteWidth = 4; + } + else + { + /* 64-bit case (ACPI 2.0+) */ + + AcpiGbl_IntegerBitWidth = 64; + AcpiGbl_IntegerNybbleWidth = 16; + AcpiGbl_IntegerByteWidth = 8; + } +} + + +#ifdef ACPI_DEBUG_OUTPUT +/******************************************************************************* + * + * FUNCTION: AcpiUtDisplayInitPathname + * + * PARAMETERS: Type - Object type of the node + * ObjHandle - Handle whose pathname will be displayed + * Path - Additional path string to be appended. + * (NULL if no extra path) + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Display full pathname of an object, DEBUG ONLY + * + ******************************************************************************/ + +void +AcpiUtDisplayInitPathname ( + UINT8 Type, + ACPI_NAMESPACE_NODE *ObjHandle, + char *Path) +{ + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + + + ACPI_FUNCTION_ENTRY (); + + + /* Only print the path if the appropriate debug level is enabled */ + + if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) + { + return; + } + + /* Get the full pathname to the node */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Print what we're doing */ + + switch (Type) + { + case ACPI_TYPE_METHOD: + AcpiOsPrintf ("Executing "); + break; + + default: + AcpiOsPrintf ("Initializing "); + break; + } + + /* Print the object type and pathname */ + + AcpiOsPrintf ("%-12s %s", + AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); + + /* Extra path is used to append names like _STA, _INI, etc. */ + + if (Path) + { + AcpiOsPrintf (".%s", Path); + } + AcpiOsPrintf ("\n"); + + ACPI_FREE (Buffer.Pointer); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidAcpiChar + * + * PARAMETERS: Char - The character to be examined + * Position - Byte position (0-3) + * + * RETURN: TRUE if the character is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI character. Must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + * We allow a '!' as the last character because of the ASF! table + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidAcpiChar ( + char Character, + UINT32 Position) +{ + + if (!((Character >= 'A' && Character <= 'Z') || + (Character >= '0' && Character <= '9') || + (Character == '_'))) + { + /* Allow a '!' in the last position */ + + if (Character == '!' && Position == 3) + { + return (TRUE); + } + + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidAcpiName + * + * PARAMETERS: Name - The name to be examined + * + * RETURN: TRUE if the name is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidAcpiName ( + UINT32 Name) +{ + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i)) + { + return (FALSE); + } + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRepairName + * + * PARAMETERS: Name - The ACPI name to be repaired + * + * RETURN: Repaired version of the name + * + * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and + * return the new name. NOTE: the Name parameter must reside in + * read/write memory, cannot be a const. + * + * An ACPI Name must consist of valid ACPI characters. We will repair the name + * if necessary because we don't want to abort because of this, but we want + * all namespace names to be printable. A warning message is appropriate. + * + * This issue came up because there are in fact machines that exhibit + * this problem, and we want to be able to enable ACPI support for them, + * even though there are a few bad names. + * + ******************************************************************************/ + +void +AcpiUtRepairName ( + char *Name) +{ + UINT32 i; + BOOLEAN FoundBadChar = FALSE; + + + ACPI_FUNCTION_NAME (UtRepairName); + + + /* Check each character in the name */ + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (AcpiUtValidAcpiChar (Name[i], i)) + { + continue; + } + + /* + * Replace a bad character with something printable, yet technically + * still invalid. This prevents any collisions with existing "good" + * names in the namespace. + */ + Name[i] = '*'; + FoundBadChar = TRUE; + } + + if (FoundBadChar) + { + /* Report warning only if in strict mode or debug mode */ + + if (!AcpiGbl_EnableInterpreterSlack) + { + ACPI_WARNING ((AE_INFO, + "Found bad character(s) in name, repaired: [%4.4s]\n", Name)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Found bad character(s) in name, repaired: [%4.4s]\n", Name)); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoul64 + * + * PARAMETERS: String - Null terminated string + * Base - Radix of the string: 16 or ACPI_ANY_BASE; + * ACPI_ANY_BASE means 'in behalf of ToInteger' + * RetInteger - Where the converted integer is returned + * + * RETURN: Status and Converted value + * + * DESCRIPTION: Convert a string into an unsigned value. Performs either a + * 32-bit or 64-bit conversion, depending on the current mode + * of the interpreter. + * NOTE: Does not support Octal strings, not needed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtStrtoul64 ( + char *String, + UINT32 Base, + ACPI_INTEGER *RetInteger) +{ + UINT32 ThisDigit = 0; + ACPI_INTEGER ReturnValue = 0; + ACPI_INTEGER Quotient; + ACPI_INTEGER Dividend; + UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); + UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); + UINT8 ValidDigits = 0; + UINT8 SignOf0x = 0; + UINT8 Term = 0; + + + ACPI_FUNCTION_TRACE_STR (UtStroul64, String); + + + switch (Base) + { + case ACPI_ANY_BASE: + case 16: + break; + + default: + /* Invalid Base */ + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!String) + { + goto ErrorExit; + } + + /* Skip over any white space in the buffer */ + + while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t')) + { + String++; + } + + if (ToIntegerOp) + { + /* + * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. + * We need to determine if it is decimal or hexadecimal. + */ + if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x')) + { + SignOf0x = 1; + Base = 16; + + /* Skip over the leading '0x' */ + String += 2; + } + else + { + Base = 10; + } + } + + /* Any string left? Check that '0x' is not followed by white space. */ + + if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t') + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + goto AllDone; + } + } + + /* + * Perform a 32-bit or 64-bit conversion, depending upon the current + * execution mode of the interpreter + */ + Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; + + /* Main loop: convert the string to a 32- or 64-bit integer */ + + while (*String) + { + if (ACPI_IS_DIGIT (*String)) + { + /* Convert ASCII 0-9 to Decimal value */ + + ThisDigit = ((UINT8) *String) - '0'; + } + else if (Base == 10) + { + /* Digit is out of range; possible in ToInteger case only */ + + Term = 1; + } + else + { + ThisDigit = (UINT8) ACPI_TOUPPER (*String); + if (ACPI_IS_XDIGIT ((char) ThisDigit)) + { + /* Convert ASCII Hex char to value */ + + ThisDigit = ThisDigit - 'A' + 10; + } + else + { + Term = 1; + } + } + + if (Term) + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + break; + } + } + else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) + { + /* Skip zeros */ + String++; + continue; + } + + ValidDigits++; + + if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32))) + { + /* + * This is ToInteger operation case. + * No any restrictions for string-to-integer conversion, + * see ACPI spec. + */ + goto ErrorExit; + } + + /* Divide the digit into the correct position */ + + (void) AcpiUtShortDivide ((Dividend - (ACPI_INTEGER) ThisDigit), + Base, &Quotient, NULL); + + if (ReturnValue > Quotient) + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + break; + } + } + + ReturnValue *= Base; + ReturnValue += ThisDigit; + String++; + } + + /* All done, normal exit */ + +AllDone: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ReturnValue))); + + *RetInteger = ReturnValue; + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + /* Base was set/validated above */ + + if (Base == 10) + { + return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); + } + else + { + return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateUpdateStateAndPush + * + * PARAMETERS: Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: Status + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + /* Ignore null objects; these are expected */ + + if (!Object) + { + return (AE_OK); + } + + State = AcpiUtCreateUpdateState (Object, Action); + if (!State) + { + return (AE_NO_MEMORY); + } + + AcpiUtPushGenericState (StateList, State); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtWalkPackageTree + * + * PARAMETERS: SourceObject - The package to walk + * TargetObject - Target object (if package is being copied) + * WalkCallback - Called once for each package element + * Context - Passed to the callback function + * + * RETURN: Status + * + * DESCRIPTION: Walk through a package + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_GENERIC_STATE *State; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT *ThisSourceObj; + + + ACPI_FUNCTION_TRACE (UtWalkPackageTree); + + + State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0); + if (!State) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + while (State) + { + /* Get one element of the package */ + + ThisIndex = State->Pkg.Index; + ThisSourceObj = (ACPI_OPERAND_OBJECT *) + State->Pkg.SourceObject->Package.Elements[ThisIndex]; + + /* + * Check for: + * 1) An uninitialized package element. It is completely + * legal to declare a package and leave it uninitialized + * 2) Not an internal object - can be a namespace node instead + * 3) Any type other than a package. Packages are handled in else + * case below. + */ + if ((!ThisSourceObj) || + (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) || + (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE)) + { + Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj, + State, Context); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + State->Pkg.Index++; + while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) + { + /* + * We've handled all of the objects at this level, This means + * that we have just completed a package. That package may + * have contained one or more packages itself. + * + * Delete this state and pop the previous state (package). + */ + AcpiUtDeleteGenericState (State); + State = AcpiUtPopGenericState (&StateList); + + /* Finished when there are no more states */ + + if (!State) + { + /* + * We have handled all of the objects in the top level + * package just add the length of the package objects + * and exit + */ + return_ACPI_STATUS (AE_OK); + } + + /* + * Go back up a level and move the index past the just + * completed package object. + */ + State->Pkg.Index++; + } + } + else + { + /* This is a subobject of type package */ + + Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj, + State, Context); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Push the current state and create a new one + * The callback above returned a new target package object. + */ + AcpiUtPushGenericState (&StateList, State); + State = AcpiUtCreatePkgState (ThisSourceObj, + State->Pkg.ThisTargetObj, 0); + if (!State) + { + /* Free any stacked Update State objects */ + + while (StateList) + { + State = AcpiUtPopGenericState (&StateList); + AcpiUtDeleteGenericState (State); + } + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + } + + /* We should never get here */ + + return_ACPI_STATUS (AE_AML_INTERNAL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiError, AcpiException, AcpiWarning, AcpiInfo + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Print message with module/line/version info + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) +{ + va_list args; + + + AcpiOsPrintf ("ACPI Error: "); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiException ( + const char *ModuleName, + UINT32 LineNumber, + ACPI_STATUS Status, + const char *Format, + ...) +{ + va_list args; + + + AcpiOsPrintf ("ACPI Exception: %s, ", AcpiFormatException (Status)); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiWarning ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) +{ + va_list args; + + + AcpiOsPrintf ("ACPI Warning: "); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiInfo ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) +{ + va_list args; + + + AcpiOsPrintf ("ACPI: "); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + AcpiOsPrintf ("\n"); + va_end (args); +} + +ACPI_EXPORT_SYMBOL (AcpiError) +ACPI_EXPORT_SYMBOL (AcpiException) +ACPI_EXPORT_SYMBOL (AcpiWarning) +ACPI_EXPORT_SYMBOL (AcpiInfo) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPredefinedWarning + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Pathname - Full pathname to the node + * NodeFlags - From Namespace node for the method/object + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Warnings for the predefined validation module. Messages are + * only emitted the first time a problem with a particular + * method/object is detected. This prevents a flood of error + * messages for methods that are repeatedly evaluated. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedWarning ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...) +{ + va_list args; + + + /* + * Warning messages for this method/object will be disabled after the + * first time a validation fails or an object is successfully repaired. + */ + if (NodeFlags & ANOBJ_EVALUATED) + { + return; + } + + AcpiOsPrintf ("ACPI Warning for %s: ", Pathname); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} + +/******************************************************************************* + * + * FUNCTION: AcpiUtPredefinedInfo + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * Pathname - Full pathname to the node + * NodeFlags - From Namespace node for the method/object + * Format - Printf format string + additional args + * + * RETURN: None + * + * DESCRIPTION: Info messages for the predefined validation module. Messages + * are only emitted the first time a problem with a particular + * method/object is detected. This prevents a flood of + * messages for methods that are repeatedly evaluated. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiUtPredefinedInfo ( + const char *ModuleName, + UINT32 LineNumber, + char *Pathname, + UINT8 NodeFlags, + const char *Format, + ...) +{ + va_list args; + + + /* + * Warning messages for this method/object will be disabled after the + * first time a validation fails or an object is successfully repaired. + */ + if (NodeFlags & ANOBJ_EVALUATED) + { + return; + } + + AcpiOsPrintf ("ACPI Info for %s: ", Pathname); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} diff --git a/drivers/bus/acpi/acpica/utilities/utmutex.c b/drivers/bus/acpi/acpica/utilities/utmutex.c new file mode 100644 index 00000000000..f6e7cc36522 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utmutex.c @@ -0,0 +1,477 @@ +/******************************************************************************* + * + * Module Name: utmutex - local mutex support + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTMUTEX_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmutex") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCreateMutex ( + ACPI_MUTEX_HANDLE MutexId); + +static ACPI_STATUS +AcpiUtDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMutexInitialize + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Create the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtMutexInitialize ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtMutexInitialize); + + + /* Create each of the predefined mutex objects */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + Status = AcpiUtCreateMutex (i); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Create the spinlocks for use at interrupt level */ + + Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create the reader/writer lock for namespace access */ + + Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMutexTerminate + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. + * + ******************************************************************************/ + +void +AcpiUtMutexTerminate ( + void) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtMutexTerminate); + + + /* Delete each predefined mutex object */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + (void) AcpiUtDeleteMutex (i); + } + + /* Delete the spinlocks */ + + AcpiOsDeleteLock (AcpiGbl_GpeLock); + AcpiOsDeleteLock (AcpiGbl_HardwareLock); + + /* Delete the reader/writer lock */ + + AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateMutex + * + * PARAMETERS: MutexID - ID of the mutex to be created + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCreateMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId); + + + if (MutexId > ACPI_MAX_MUTEX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!AcpiGbl_MutexInfo[MutexId].Mutex) + { + Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex); + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[MutexId].UseCount = 0; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteMutex + * + * PARAMETERS: MutexID - ID of the mutex to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete a mutex object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + + ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId); + + + if (MutexId > ACPI_MAX_MUTEX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex); + + AcpiGbl_MutexInfo[MutexId].Mutex = NULL; + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireMutex + * + * PARAMETERS: MutexID - ID of the mutex to be acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + ACPI_THREAD_ID ThisThreadId; + + + ACPI_FUNCTION_NAME (UtAcquireMutex); + + + if (MutexId > ACPI_MAX_MUTEX) + { + return (AE_BAD_PARAMETER); + } + + ThisThreadId = AcpiOsGetThreadId (); + +#ifdef ACPI_MUTEX_DEBUG + { + UINT32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than or equal to this one. If so, the thread has violated + * the mutex ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = MutexId; i < ACPI_NUM_MUTEX; i++) + { + if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) + { + if (i == MutexId) + { + ACPI_ERROR ((AE_INFO, + "Mutex [%s] already acquired by this thread [%p]", + AcpiUtGetMutexName (MutexId), + ACPI_CAST_PTR (void, ThisThreadId))); + + return (AE_ALREADY_ACQUIRED); + } + + ACPI_ERROR ((AE_INFO, + "Invalid acquire order: Thread %p owns [%s], wants [%s]", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (i), + AcpiUtGetMutexName (MutexId))); + + return (AE_ACQUIRE_DEADLOCK); + } + } + } +#endif + + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %p attempting to acquire Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + + Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex, + ACPI_WAIT_FOREVER); + if (ACPI_SUCCESS (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p acquired Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + + AcpiGbl_MutexInfo[MutexId].UseCount++; + AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Thread %p could not acquire Mutex [%X]", + ACPI_CAST_PTR (void, ThisThreadId), MutexId)); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReleaseMutex + * + * PARAMETERS: MutexID - ID of the mutex to be released + * + * RETURN: Status + * + * DESCRIPTION: Release a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_THREAD_ID ThisThreadId; + + + ACPI_FUNCTION_NAME (UtReleaseMutex); + + + ThisThreadId = AcpiOsGetThreadId (); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + + if (MutexId > ACPI_MAX_MUTEX) + { + return (AE_BAD_PARAMETER); + } + + /* + * Mutex must be acquired in order to release it! + */ + if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED) + { + ACPI_ERROR ((AE_INFO, + "Mutex [%X] is not acquired, cannot release", MutexId)); + + return (AE_NOT_ACQUIRED); + } + +#ifdef ACPI_MUTEX_DEBUG + { + UINT32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than this one. If so, the thread has violated the mutex + * ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = MutexId; i < ACPI_NUM_MUTEX; i++) + { + if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) + { + if (i == MutexId) + { + continue; + } + + ACPI_ERROR ((AE_INFO, + "Invalid release order: owns [%s], releasing [%s]", + AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); + + return (AE_RELEASE_DEADLOCK); + } + } + } +#endif + + /* Mark unlocked FIRST */ + + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + + AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex); + return (AE_OK); +} + + diff --git a/drivers/bus/acpi/acpica/utilities/utobject.c b/drivers/bus/acpi/acpica/utilities/utobject.c new file mode 100644 index 00000000000..5164744891b --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utobject.c @@ -0,0 +1,859 @@ +/****************************************************************************** + * + * Module Name: utobject - ACPI object create/delete/size/cache routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTOBJECT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utobject") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateInternalObjectDbg + * + * PARAMETERS: ModuleName - Source file name of caller + * LineNumber - Line number of caller + * ComponentId - Component type of caller + * Type - ACPI Type of the new object + * + * RETURN: A new internal object, null on failure + * + * DESCRIPTION: Create and initialize a new internal object. + * + * NOTE: We always allocate the worst-case object descriptor because + * these objects are cached, and we want them to be + * one-size-satisifies-any-request. This in itself may not be + * the most memory efficient, but the efficiency of the object + * cache should more than make up for this! + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateInternalObjectDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + ACPI_OBJECT_TYPE Type) +{ + ACPI_OPERAND_OBJECT *Object; + ACPI_OPERAND_OBJECT *SecondObject; + + + ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg, + AcpiUtGetTypeName (Type)); + + + /* Allocate the raw object descriptor */ + + Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId); + if (!Object) + { + return_PTR (NULL); + } + + switch (Type) + { + case ACPI_TYPE_REGION: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + + /* These types require a secondary object */ + + SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, + LineNumber, ComponentId); + if (!SecondObject) + { + AcpiUtDeleteObjectDesc (Object); + return_PTR (NULL); + } + + SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA; + SecondObject->Common.ReferenceCount = 1; + + /* Link the second object to the first */ + + Object->Common.NextObject = SecondObject; + break; + + default: + /* All others have no secondary object */ + break; + } + + /* Save the object type in the object descriptor */ + + Object->Common.Type = (UINT8) Type; + + /* Init the reference count */ + + Object->Common.ReferenceCount = 1; + + /* Any per-type initialization should go here */ + + return_PTR (Object); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePackageObject + * + * PARAMETERS: Count - Number of package elements + * + * RETURN: Pointer to a new Package object, null on failure + * + * DESCRIPTION: Create a fully initialized package object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreatePackageObject ( + UINT32 Count) +{ + ACPI_OPERAND_OBJECT *PackageDesc; + ACPI_OPERAND_OBJECT **PackageElements; + + + ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count); + + + /* Create a new Package object */ + + PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); + if (!PackageDesc) + { + return_PTR (NULL); + } + + /* + * Create the element array. Count+1 allows the array to be null + * terminated. + */ + PackageElements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) Count + 1) * sizeof (void *)); + if (!PackageElements) + { + ACPI_FREE (PackageDesc); + return_PTR (NULL); + } + + PackageDesc->Package.Count = Count; + PackageDesc->Package.Elements = PackageElements; + return_PTR (PackageDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateIntegerObject + * + * PARAMETERS: InitialValue - Initial value for the integer + * + * RETURN: Pointer to a new Integer object, null on failure + * + * DESCRIPTION: Create an initialized integer object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateIntegerObject ( + UINT64 InitialValue) +{ + ACPI_OPERAND_OBJECT *IntegerDesc; + + + ACPI_FUNCTION_TRACE (UtCreateIntegerObject); + + + /* Create and initialize a new integer object */ + + IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!IntegerDesc) + { + return_PTR (NULL); + } + + IntegerDesc->Integer.Value = InitialValue; + return_PTR (IntegerDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateBufferObject + * + * PARAMETERS: BufferSize - Size of buffer to be created + * + * RETURN: Pointer to a new Buffer object, null on failure + * + * DESCRIPTION: Create a fully initialized buffer object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateBufferObject ( + ACPI_SIZE BufferSize) +{ + ACPI_OPERAND_OBJECT *BufferDesc; + UINT8 *Buffer = NULL; + + + ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize); + + + /* Create a new Buffer object */ + + BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!BufferDesc) + { + return_PTR (NULL); + } + + /* Create an actual buffer only if size > 0 */ + + if (BufferSize > 0) + { + /* Allocate the actual buffer */ + + Buffer = ACPI_ALLOCATE_ZEROED (BufferSize); + if (!Buffer) + { + ACPI_ERROR ((AE_INFO, "Could not allocate size %X", + (UINT32) BufferSize)); + AcpiUtRemoveReference (BufferDesc); + return_PTR (NULL); + } + } + + /* Complete buffer object initialization */ + + BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + BufferDesc->Buffer.Pointer = Buffer; + BufferDesc->Buffer.Length = (UINT32) BufferSize; + + /* Return the new buffer descriptor */ + + return_PTR (BufferDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateStringObject + * + * PARAMETERS: StringSize - Size of string to be created. Does not + * include NULL terminator, this is added + * automatically. + * + * RETURN: Pointer to a new String object + * + * DESCRIPTION: Create a fully initialized string object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize) +{ + ACPI_OPERAND_OBJECT *StringDesc; + char *String; + + + ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize); + + + /* Create a new String object */ + + StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); + if (!StringDesc) + { + return_PTR (NULL); + } + + /* + * Allocate the actual string buffer -- (Size + 1) for NULL terminator. + * NOTE: Zero-length strings are NULL terminated + */ + String = ACPI_ALLOCATE_ZEROED (StringSize + 1); + if (!String) + { + ACPI_ERROR ((AE_INFO, "Could not allocate size %X", + (UINT32) StringSize)); + AcpiUtRemoveReference (StringDesc); + return_PTR (NULL); + } + + /* Complete string object initialization */ + + StringDesc->String.Pointer = String; + StringDesc->String.Length = (UINT32) StringSize; + + /* Return the new string descriptor */ + + return_PTR (StringDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidInternalObject + * + * PARAMETERS: Object - Object to be validated + * + * RETURN: TRUE if object is valid, FALSE otherwise + * + * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidInternalObject ( + void *Object) +{ + + ACPI_FUNCTION_NAME (UtValidInternalObject); + + + /* Check for a null pointer */ + + if (!Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n")); + return (FALSE); + } + + /* Check the descriptor type field */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (Object)) + { + case ACPI_DESC_TYPE_OPERAND: + + /* The object appears to be a valid ACPI_OPERAND_OBJECT */ + + return (TRUE); + + default: + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%p is not not an ACPI operand obj [%s]\n", + Object, AcpiUtGetDescriptorName (Object))); + break; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateObjectDescDbg + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * + * RETURN: Pointer to newly allocated object descriptor. Null on error + * + * DESCRIPTION: Allocate a new object descriptor. Gracefully handle + * error conditions. + * + ******************************************************************************/ + +void * +AcpiUtAllocateObjectDescDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg); + + + Object = AcpiOsAcquireObject (AcpiGbl_OperandCache); + if (!Object) + { + ACPI_ERROR ((ModuleName, LineNumber, + "Could not allocate an object descriptor")); + + return_PTR (NULL); + } + + /* Mark the descriptor type */ + + ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND); + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", + Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT))); + + return_PTR (Object); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteObjectDesc + * + * PARAMETERS: Object - An Acpi internal object to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache + * + ******************************************************************************/ + +void +AcpiUtDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object) +{ + ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object); + + + /* Object must be an ACPI_OPERAND_OBJECT */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) + { + ACPI_ERROR ((AE_INFO, + "%p is not an ACPI Operand object [%s]", Object, + AcpiUtGetDescriptorName (Object))); + return_VOID; + } + + (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetSimpleObjectSize + * + * PARAMETERS: InternalObject - An ACPI operand object + * ObjLength - Where the length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain a simple object for return to an external user. + * + * The length includes the object structure plus any additional + * needed space. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_SIZE *ObjLength) +{ + ACPI_SIZE Length; + ACPI_SIZE Size; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject); + + + /* Start with the length of the (external) Acpi object */ + + Length = sizeof (ACPI_OBJECT); + + /* A NULL object is allowed, can be a legal uninitialized package element */ + + if (!InternalObject) + { + /* + * Object is NULL, just return the length of ACPI_OBJECT + * (A NULL ACPI_OBJECT is an object of all zeroes.) + */ + *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); + return_ACPI_STATUS (AE_OK); + } + + /* A Namespace Node should never appear here */ + + if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED) + { + /* A namespace node should never get here */ + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * The final length depends on the object type + * Strings and Buffers are packed right up against the parent object and + * must be accessed bytewise or there may be alignment problems on + * certain processors + */ + switch (InternalObject->Common.Type) + { + case ACPI_TYPE_STRING: + + Length += (ACPI_SIZE) InternalObject->String.Length + 1; + break; + + + case ACPI_TYPE_BUFFER: + + Length += (ACPI_SIZE) InternalObject->Buffer.Length; + break; + + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_POWER: + + /* No extra data for these types */ + + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + switch (InternalObject->Reference.Class) + { + case ACPI_REFCLASS_NAME: + + /* + * Get the actual length of the full pathname to this object. + * The reference will be converted to the pathname to the object + */ + Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node); + if (!Size) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size); + break; + + default: + + /* + * No other reference opcodes are supported. + * Notably, Locals and Args are not supported, but this may be + * required eventually. + */ + ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " + "unsupported Reference Class [%s] %X in object %p", + AcpiUtGetReferenceName (InternalObject), + InternalObject->Reference.Class, InternalObject)); + Status = AE_TYPE; + break; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " + "unsupported type [%s] %X in object %p", + AcpiUtGetObjectTypeName (InternalObject), + InternalObject->Common.Type, InternalObject)); + Status = AE_TYPE; + break; + } + + /* + * Account for the space required by the object rounded up to the next + * multiple of the machine word size. This keeps each object aligned + * on a machine word boundary. (preventing alignment faults on some + * machines.) + */ + *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetElementLength + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Get the length of one package element. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; + ACPI_SIZE ObjectSpace; + + + switch (ObjectType) + { + case ACPI_COPY_TYPE_SIMPLE: + + /* + * Simple object - just get the size (Null object/entry is handled + * here also) and sum it into the running package length + */ + Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Info->Length += ObjectSpace; + break; + + + case ACPI_COPY_TYPE_PACKAGE: + + /* Package object - nothing much to do here, let the walk handle it */ + + Info->NumPackages++; + State->Pkg.ThisTargetObj = NULL; + break; + + + default: + + /* No other types allowed */ + + return (AE_BAD_PARAMETER); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetPackageObjectSize + * + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain a package object for return to an external user. + * + * This is moderately complex since a package contains other + * objects including packages. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_SIZE *ObjLength) +{ + ACPI_STATUS Status; + ACPI_PKG_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject); + + + Info.Length = 0; + Info.ObjectSpace = 0; + Info.NumPackages = 1; + + Status = AcpiUtWalkPackageTree (InternalObject, NULL, + AcpiUtGetElementLength, &Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * We have handled all of the objects in all levels of the package. + * just add the length of the package objects themselves. + * Round up to the next machine word. + */ + Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) * + (ACPI_SIZE) Info.NumPackages; + + /* Return the total package length */ + + *ObjLength = Info.Length; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetObjectSize + * + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length will be returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain an object for return to an API user. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtGetObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_SIZE *ObjLength) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) && + (InternalObject->Common.Type == ACPI_TYPE_PACKAGE)) + { + Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength); + } + else + { + Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength); + } + + return (Status); +} + + diff --git a/drivers/bus/acpi/acpica/utilities/utresrc.c b/drivers/bus/acpi/acpica/utilities/utresrc.c new file mode 100644 index 00000000000..2f19d639868 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utresrc.c @@ -0,0 +1,772 @@ +/******************************************************************************* + * + * Module Name: utresrc - Resource managment utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTRESRC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlresrc.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utresrc") + + +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) + +/* + * Strings used to decode resource descriptors. + * Used by both the disasssembler and the debugger resource dump routines + */ +const char *AcpiGbl_BmDecode[] = +{ + "NotBusMaster", + "BusMaster" +}; + +const char *AcpiGbl_ConfigDecode[] = +{ + "0 - Good Configuration", + "1 - Acceptable Configuration", + "2 - Suboptimal Configuration", + "3 - ***Invalid Configuration***", +}; + +const char *AcpiGbl_ConsumeDecode[] = +{ + "ResourceProducer", + "ResourceConsumer" +}; + +const char *AcpiGbl_DecDecode[] = +{ + "PosDecode", + "SubDecode" +}; + +const char *AcpiGbl_HeDecode[] = +{ + "Level", + "Edge" +}; + +const char *AcpiGbl_IoDecode[] = +{ + "Decode10", + "Decode16" +}; + +const char *AcpiGbl_LlDecode[] = +{ + "ActiveHigh", + "ActiveLow" +}; + +const char *AcpiGbl_MaxDecode[] = +{ + "MaxNotFixed", + "MaxFixed" +}; + +const char *AcpiGbl_MemDecode[] = +{ + "NonCacheable", + "Cacheable", + "WriteCombining", + "Prefetchable" +}; + +const char *AcpiGbl_MinDecode[] = +{ + "MinNotFixed", + "MinFixed" +}; + +const char *AcpiGbl_MtpDecode[] = +{ + "AddressRangeMemory", + "AddressRangeReserved", + "AddressRangeACPI", + "AddressRangeNVS" +}; + +const char *AcpiGbl_RngDecode[] = +{ + "InvalidRanges", + "NonISAOnlyRanges", + "ISAOnlyRanges", + "EntireRange" +}; + +const char *AcpiGbl_RwDecode[] = +{ + "ReadOnly", + "ReadWrite" +}; + +const char *AcpiGbl_ShrDecode[] = +{ + "Exclusive", + "Shared" +}; + +const char *AcpiGbl_SizDecode[] = +{ + "Transfer8", + "Transfer8_16", + "Transfer16", + "InvalidSize" +}; + +const char *AcpiGbl_TrsDecode[] = +{ + "DenseTranslation", + "SparseTranslation" +}; + +const char *AcpiGbl_TtpDecode[] = +{ + "TypeStatic", + "TypeTranslation" +}; + +const char *AcpiGbl_TypDecode[] = +{ + "Compatibility", + "TypeA", + "TypeB", + "TypeF" +}; + +#endif + + +/* + * Base sizes of the raw AML resource descriptors, indexed by resource type. + * Zero indicates a reserved (and therefore invalid) resource type. + */ +const UINT8 AcpiGbl_ResourceAmlSizes[] = +{ + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO), + 0, + 0, + 0, + 0, + ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG), + + /* Large descriptors */ + + 0, + ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER), + 0, + ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64) +}; + + +/* + * Resource types, used to validate the resource length field. + * The length of fixed-length types must match exactly, variable + * lengths must meet the minimum required length, etc. + * Zero indicates a reserved (and therefore invalid) resource type. + */ +static const UINT8 AcpiGbl_ResourceTypes[] = +{ + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_SMALL_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_SMALL_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + 0, + 0, + 0, + 0, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + + /* Large descriptors */ + + 0, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + 0, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtWalkAmlResources + * + * PARAMETERS: Aml - Pointer to the raw AML resource template + * AmlLength - Length of the entire template + * UserFunction - Called once for each descriptor found. If + * NULL, a pointer to the EndTag is returned + * Context - Passed to UserFunction + * + * RETURN: Status + * + * DESCRIPTION: Walk a raw AML resource list(buffer). User function called + * once for each resource found. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtWalkAmlResources ( + UINT8 *Aml, + ACPI_SIZE AmlLength, + ACPI_WALK_AML_CALLBACK UserFunction, + void *Context) +{ + ACPI_STATUS Status; + UINT8 *EndAml; + UINT8 ResourceIndex; + UINT32 Length; + UINT32 Offset = 0; + + + ACPI_FUNCTION_TRACE (UtWalkAmlResources); + + + /* The absolute minimum resource template is one EndTag descriptor */ + + if (AmlLength < sizeof (AML_RESOURCE_END_TAG)) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + + /* Point to the end of the resource template buffer */ + + EndAml = Aml + AmlLength; + + /* Walk the byte list, abort on any invalid descriptor type or length */ + + while (Aml < EndAml) + { + /* Validate the Resource Type and Resource Length */ + + Status = AcpiUtValidateResource (Aml, &ResourceIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the length of this descriptor */ + + Length = AcpiUtGetDescriptorLength (Aml); + + /* Invoke the user function */ + + if (UserFunction) + { + Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* An EndTag descriptor terminates this resource template */ + + if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) + { + /* + * There must be at least one more byte in the buffer for + * the 2nd byte of the EndTag + */ + if ((Aml + 1) >= EndAml) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + + /* Return the pointer to the EndTag if requested */ + + if (!UserFunction) + { + *(void **) Context = Aml; + } + + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); + } + + Aml += Length; + Offset += Length; + } + + /* Did not find an EndTag descriptor */ + + return (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidateResource + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * ReturnIndex - Where the resource index is returned. NULL + * if the index is not required. + * + * RETURN: Status, and optionally the Index into the global resource tables + * + * DESCRIPTION: Validate an AML resource descriptor by checking the Resource + * Type and Resource Length. Returns an index into the global + * resource information/dispatch tables for later use. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtValidateResource ( + void *Aml, + UINT8 *ReturnIndex) +{ + UINT8 ResourceType; + UINT8 ResourceIndex; + ACPI_RS_LENGTH ResourceLength; + ACPI_RS_LENGTH MinimumResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * 1) Validate the ResourceType field (Byte 0) + */ + ResourceType = ACPI_GET8 (Aml); + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (ResourceType & ACPI_RESOURCE_NAME_LARGE) + { + /* Verify the large resource type (name) against the max */ + + if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX) + { + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* + * Large Resource Type -- bits 6:0 contain the name + * Translate range 0x80-0x8B to index range 0x10-0x1B + */ + ResourceIndex = (UINT8) (ResourceType - 0x70); + } + else + { + /* + * Small Resource Type -- bits 6:3 contain the name + * Shift range to index range 0x00-0x0F + */ + ResourceIndex = (UINT8) + ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); + } + + /* Check validity of the resource type, zero indicates name is invalid */ + + if (!AcpiGbl_ResourceTypes[ResourceIndex]) + { + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + + /* + * 2) Validate the ResourceLength field. This ensures that the length + * is at least reasonable, and guarantees that it is non-zero. + */ + ResourceLength = AcpiUtGetResourceLength (Aml); + MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; + + /* Validate based upon the type of resource - fixed length or variable */ + + switch (AcpiGbl_ResourceTypes[ResourceIndex]) + { + case ACPI_FIXED_LENGTH: + + /* Fixed length resource, length must match exactly */ + + if (ResourceLength != MinimumResourceLength) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + case ACPI_VARIABLE_LENGTH: + + /* Variable length resource, length must be at least the minimum */ + + if (ResourceLength < MinimumResourceLength) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + case ACPI_SMALL_VARIABLE_LENGTH: + + /* Small variable length resource, length can be (Min) or (Min-1) */ + + if ((ResourceLength > MinimumResourceLength) || + (ResourceLength < (MinimumResourceLength - 1))) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + default: + + /* Shouldn't happen (because of validation earlier), but be sure */ + + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* Optionally return the resource table index */ + + if (ReturnIndex) + { + *ReturnIndex = ResourceIndex; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceType + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: The Resource Type with no extraneous bits (except the + * Large/Small descriptor bit -- this is left alone) + * + * DESCRIPTION: Extract the Resource Type/Name from the first byte of + * a resource descriptor. + * + ******************************************************************************/ + +UINT8 +AcpiUtGetResourceType ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource Type -- bits 6:0 contain the name */ + + return (ACPI_GET8 (Aml)); + } + else + { + /* Small Resource Type -- bits 6:3 contain the name */ + + return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte Length + * + * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By + * definition, this does not include the size of the descriptor + * header or the length field itself. + * + ******************************************************************************/ + +UINT16 +AcpiUtGetResourceLength ( + void *Aml) +{ + ACPI_RS_LENGTH ResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1)); + + } + else + { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + ResourceLength = (UINT16) (ACPI_GET8 (Aml) & + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); + } + + return (ResourceLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceHeaderLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Length of the AML header (depends on large/small descriptor) + * + * DESCRIPTION: Get the length of the header for this resource. + * + ******************************************************************************/ + +UINT8 +AcpiUtGetResourceHeaderLength ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Examine the large/small bit in the resource header */ + + if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) + { + return (sizeof (AML_RESOURCE_LARGE_HEADER)); + } + else + { + return (sizeof (AML_RESOURCE_SMALL_HEADER)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetDescriptorLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte length + * + * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the + * length of the descriptor header and the length field itself. + * Used to walk descriptor lists. + * + ******************************************************************************/ + +UINT32 +AcpiUtGetDescriptorLength ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * Get the Resource Length (does not include header length) and add + * the header length (depends on if this is a small or large resource) + */ + return (AcpiUtGetResourceLength (Aml) + + AcpiUtGetResourceHeaderLength (Aml)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceEndTag + * + * PARAMETERS: ObjDesc - The resource template buffer object + * EndTag - Where the pointer to the EndTag is returned + * + * RETURN: Status, pointer to the end tag + * + * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template + * Note: allows a buffer length of zero. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtGetResourceEndTag ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 **EndTag) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtGetResourceEndTag); + + + /* Allow a buffer length of zero */ + + if (!ObjDesc->Buffer.Length) + { + *EndTag = ObjDesc->Buffer.Pointer; + return_ACPI_STATUS (AE_OK); + } + + /* Validate the template and get a pointer to the EndTag */ + + Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length, NULL, EndTag); + + return_ACPI_STATUS (Status); +} + + diff --git a/drivers/bus/acpi/acpica/utilities/utstate.c b/drivers/bus/acpi/acpica/utilities/utstate.c new file mode 100644 index 00000000000..245ca02bfc5 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utstate.c @@ -0,0 +1,470 @@ +/******************************************************************************* + * + * Module Name: utstate - state object support procedures + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTSTATE_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utstate") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePkgStateAndPush + * + * PARAMETERS: Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: Status + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + State = AcpiUtCreatePkgState (InternalObject, ExternalObject, Index); + if (!State) + { + return (AE_NO_MEMORY); + } + + AcpiUtPushGenericState (StateList, State); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPushGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * State - State object to push + * + * RETURN: None + * + * DESCRIPTION: Push a state object onto a state stack + * + ******************************************************************************/ + +void +AcpiUtPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State) +{ + ACPI_FUNCTION_TRACE (UtPushGenericState); + + + /* Push the state object onto the front of the list (stack) */ + + State->Common.Next = *ListHead; + *ListHead = State; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPopGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * + * RETURN: The popped state object + * + * DESCRIPTION: Pop a state object from a state stack + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtPopGenericState ( + ACPI_GENERIC_STATE **ListHead) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE (UtPopGenericState); + + + /* Remove the state object at the head of the list (stack) */ + + State = *ListHead; + if (State) + { + /* Update the list head */ + + *ListHead = State->Common.Next; + } + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateGenericState + * + * PARAMETERS: None + * + * RETURN: The new state object. NULL on failure. + * + * DESCRIPTION: Create a generic state object. Attempt to obtain one from + * the global state cache; If none available, create a new one. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateGenericState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + State = AcpiOsAcquireObject (AcpiGbl_StateCache); + if (State) + { + /* Initialize */ + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE; + } + + return (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateThreadState + * + * PARAMETERS: None + * + * RETURN: New Thread State. NULL on failure + * + * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used + * to track per-thread info during method execution + * + ******************************************************************************/ + +ACPI_THREAD_STATE * +AcpiUtCreateThreadState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE (UtCreateThreadState); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_THREAD; + State->Thread.ThreadId = AcpiOsGetThreadId (); + + /* Check for invalid thread ID - zero is very bad, it will break things */ + + if (!State->Thread.ThreadId) + { + ACPI_ERROR ((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId")); + State->Thread.ThreadId = (ACPI_THREAD_ID) 1; + } + + return_PTR ((ACPI_THREAD_STATE *) State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateUpdateState + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR (UtCreateUpdateState, Object); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_UPDATE; + State->Update.Object = Object; + State->Update.Value = Action; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePkgState + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Package State" + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR (UtCreatePkgState, InternalObject); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PACKAGE; + State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject; + State->Pkg.DestObject = ExternalObject; + State->Pkg.Index= Index; + State->Pkg.NumPackages = 1; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateControlState + * + * PARAMETERS: None + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Control State" - a flavor of the generic state used + * to support nested IF/WHILE constructs in the AML. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateControlState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE (UtCreateControlState); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the control struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_CONTROL; + State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteGenericState + * + * PARAMETERS: State - The state object to be deleted + * + * RETURN: None + * + * DESCRIPTION: Release a state object to the state cache. NULL state objects + * are ignored. + * + ******************************************************************************/ + +void +AcpiUtDeleteGenericState ( + ACPI_GENERIC_STATE *State) +{ + ACPI_FUNCTION_TRACE (UtDeleteGenericState); + + + /* Ignore null state */ + + if (State) + { + (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State); + } + return_VOID; +} + + diff --git a/drivers/bus/acpi/acpica/utilities/uttrack.c b/drivers/bus/acpi/acpica/utilities/uttrack.c new file mode 100644 index 00000000000..d712c1a3e5a --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/uttrack.c @@ -0,0 +1,726 @@ +/****************************************************************************** + * + * Module Name: uttrack - Memory allocation tracking routines (debug only) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +/* + * These procedures are used for tracking memory leaks in the subsystem, and + * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set. + * + * Each memory allocation is tracked via a doubly linked list. Each + * element contains the caller's component, module name, function name, and + * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call + * AcpiUtTrackAllocation to add an element to the list; deletion + * occurs in the body of AcpiUtFree. + */ + +#define __UTTRACK_C__ + +#include "acpi.h" +#include "accommon.h" + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("uttrack") + +/* Local prototypes */ + +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + void *Allocation); + +static ACPI_STATUS +AcpiUtTrackAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + const char *Module, + UINT32 Line); + +static ACPI_STATUS +AcpiUtRemoveAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + UINT32 Component, + const char *Module, + UINT32 Line); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateList + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a local memory list for tracking purposed + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateList ( + char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache) +{ + ACPI_MEMORY_LIST *Cache; + + + Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); + if (!Cache) + { + return (AE_NO_MEMORY); + } + + ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + + Cache->ListName = ListName; + Cache->ObjectSize = ObjectSize; + + *ReturnCache = Cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateAndTrack + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: The subsystem's equivalent of malloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocateAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *Allocation; + ACPI_STATUS Status; + + + Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); + if (!Allocation) + { + return (NULL); + } + + Status = AcpiUtTrackAllocation (Allocation, Size, + ACPI_MEM_MALLOC, Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Allocation); + return (NULL); + } + + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->TotalSize += (UINT32) Size; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; + if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + { + AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + } + + return ((void *) &Allocation->UserSpace); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateZeroedAndTrack + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of calloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocateZeroedAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *Allocation; + ACPI_STATUS Status; + + + Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); + if (!Allocation) + { + /* Report allocation error */ + + ACPI_ERROR ((Module, Line, + "Could not allocate size %X", (UINT32) Size)); + return (NULL); + } + + Status = AcpiUtTrackAllocation (Allocation, Size, + ACPI_MEM_CALLOC, Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Allocation); + return (NULL); + } + + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->TotalSize += (UINT32) Size; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; + if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + { + AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + } + + return ((void *) &Allocation->UserSpace); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFreeAndTrack + * + * PARAMETERS: Allocation - Address of the memory to deallocate + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None + * + * DESCRIPTION: Frees the memory at Allocation + * + ******************************************************************************/ + +void +AcpiUtFreeAndTrack ( + void *Allocation, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *DebugBlock; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation); + + + if (NULL == Allocation) + { + ACPI_ERROR ((Module, Line, + "Attempt to delete a NULL address")); + + return_VOID; + } + + DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, + (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); + + AcpiGbl_GlobalList->TotalFreed++; + AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size; + + Status = AcpiUtRemoveAllocation (DebugBlock, + Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory")); + } + + AcpiOsFree (DebugBlock); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFindAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * + * RETURN: A list element if found; NULL otherwise. + * + * DESCRIPTION: Searches for an element in the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + void *Allocation) +{ + ACPI_DEBUG_MEM_BLOCK *Element; + + + ACPI_FUNCTION_ENTRY (); + + + Element = AcpiGbl_GlobalList->ListHead; + + /* Search for the address. */ + + while (Element) + { + if (Element == Allocation) + { + return (Element); + } + + Element = Element->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrackAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * Size - Size of the allocation + * AllocType - MEM_MALLOC or MEM_CALLOC + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None. + * + * DESCRIPTION: Inserts an element into the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtTrackAllocation ( + ACPI_DEBUG_MEM_BLOCK *Allocation, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_MEMORY_LIST *MemList; + ACPI_DEBUG_MEM_BLOCK *Element; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation); + + + MemList = AcpiGbl_GlobalList; + Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Search list for this address to make sure it is not already on the list. + * This will catch several kinds of problems. + */ + Element = AcpiUtFindAllocation (Allocation); + if (Element) + { + ACPI_ERROR ((AE_INFO, + "UtTrackAllocation: Allocation already present in list! (%p)", + Allocation)); + + ACPI_ERROR ((AE_INFO, "Element %p Address %p", + Element, Allocation)); + + goto UnlockAndExit; + } + + /* Fill in the instance data. */ + + Allocation->Size = (UINT32) Size; + Allocation->AllocType = AllocType; + Allocation->Component = Component; + Allocation->Line = Line; + + ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); + Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; + + /* Insert at list head */ + + if (MemList->ListHead) + { + ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation; + } + + Allocation->Next = MemList->ListHead; + Allocation->Previous = NULL; + + MemList->ListHead = Allocation; + + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: + * + * DESCRIPTION: Deletes an element from the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtRemoveAllocation ( + ACPI_DEBUG_MEM_BLOCK *Allocation, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_MEMORY_LIST *MemList; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtRemoveAllocation); + + + MemList = AcpiGbl_GlobalList; + if (NULL == MemList->ListHead) + { + /* No allocations! */ + + ACPI_ERROR ((Module, Line, + "Empty allocation list, nothing to free!")); + + return_ACPI_STATUS (AE_OK); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Unlink */ + + if (Allocation->Previous) + { + (Allocation->Previous)->Next = Allocation->Next; + } + else + { + MemList->ListHead = Allocation->Next; + } + + if (Allocation->Next) + { + (Allocation->Next)->Previous = Allocation->Previous; + } + + /* Mark the segment as deleted */ + + ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", + Allocation->Size)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpAllocationInfo + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: Print some info about the outstanding allocations. + * + ******************************************************************************/ + +void +AcpiUtDumpAllocationInfo ( + void) +{ +/* + ACPI_MEMORY_LIST *MemList; +*/ + + ACPI_FUNCTION_TRACE (UtDumpAllocationInfo); + +/* + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current allocations", + MemList->CurrentCount, + ROUND_UP_TO_1K (MemList->CurrentSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", + MemList->MaxConcurrentCount, + ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); + + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", + RunningObjectCount, + ROUND_UP_TO_1K (RunningObjectSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", + RunningAllocCount, + ROUND_UP_TO_1K (RunningAllocSize))); + + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current Nodes", + AcpiGbl_CurrentNodeCount, + ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max Nodes", + AcpiGbl_MaxConcurrentNodeCount, + ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * + sizeof (ACPI_NAMESPACE_NODE))))); +*/ + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpAllocations + * + * PARAMETERS: Component - Component(s) to dump info for. + * Module - Module to dump info for. NULL means all. + * + * RETURN: None + * + * DESCRIPTION: Print a list of all outstanding allocations. + * + ******************************************************************************/ + +void +AcpiUtDumpAllocations ( + UINT32 Component, + const char *Module) +{ + ACPI_DEBUG_MEM_BLOCK *Element; + ACPI_DESCRIPTOR *Descriptor; + UINT32 NumOutstanding = 0; + + + ACPI_FUNCTION_TRACE (UtDumpAllocations); + + + /* + * Walk the allocation list. + */ + if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY))) + { + return; + } + + Element = AcpiGbl_GlobalList->ListHead; + while (Element) + { + if ((Element->Component & Component) && + ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) + { + /* Ignore allocated objects that are in a cache */ + + Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); + if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) + { + AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", + Descriptor, Element->Size, Element->Module, + Element->Line, AcpiUtGetDescriptorName (Descriptor)); + + /* Most of the elements will be Operand objects. */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) + { + case ACPI_DESC_TYPE_OPERAND: + AcpiOsPrintf ("%12.12s R%hd", + AcpiUtGetTypeName (Descriptor->Object.Common.Type), + Descriptor->Object.Common.ReferenceCount); + break; + + case ACPI_DESC_TYPE_PARSER: + AcpiOsPrintf ("AmlOpcode %04hX", + Descriptor->Op.Asl.AmlOpcode); + break; + + case ACPI_DESC_TYPE_NAMED: + AcpiOsPrintf ("%4.4s", + AcpiUtGetNodeName (&Descriptor->Node)); + break; + + default: + break; + } + + AcpiOsPrintf ( "\n"); + NumOutstanding++; + } + } + Element = Element->Next; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + + /* Print summary */ + + if (!NumOutstanding) + { + ACPI_INFO ((AE_INFO, + "No outstanding allocations")); + } + else + { + ACPI_ERROR ((AE_INFO, + "%d(%X) Outstanding allocations", + NumOutstanding, NumOutstanding)); + } + + return_VOID; +} + +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + diff --git a/drivers/bus/acpi/acpica/utilities/utxface.c b/drivers/bus/acpi/acpica/utilities/utxface.c new file mode 100644 index 00000000000..ba57f4922b7 --- /dev/null +++ b/drivers/bus/acpi/acpica/utilities/utxface.c @@ -0,0 +1,734 @@ +/****************************************************************************** + * + * Module Name: utxface - External interfaces for "global" ACPI functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acdebug.h" +#include "actables.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utxface") + + +#ifndef ACPI_ASL_COMPILER + +/******************************************************************************* + * + * FUNCTION: AcpiInitializeSubsystem + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initializes all global variables. This is the first function + * called, so any early initialization belongs here. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInitializeSubsystem ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem); + + + AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE; + ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ()); + + /* Initialize the OS-Dependent layer */ + + Status = AcpiOsInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization")); + return_ACPI_STATUS (Status); + } + + /* Initialize all globals used by the subsystem */ + + Status = AcpiUtInitGlobals (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals")); + return_ACPI_STATUS (Status); + } + + /* Create the default mutex objects */ + + Status = AcpiUtMutexInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation")); + return_ACPI_STATUS (Status); + } + + /* + * Initialize the namespace manager and + * the root of the namespace tree + */ + Status = AcpiNsRootInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization")); + return_ACPI_STATUS (Status); + } + + /* If configured, initialize the AML debugger */ + + ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ()); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableSubsystem + * + * PARAMETERS: Flags - Init/enable Options + * + * RETURN: Status + * + * DESCRIPTION: Completes the subsystem initialization including hardware. + * Puts system into ACPI mode if it isn't already. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiEnableSubsystem); + + + /* Enable ACPI mode */ + + if (!(Flags & ACPI_NO_ACPI_ENABLE)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); + + AcpiGbl_OriginalMode = AcpiHwGetMode(); + + Status = AcpiEnable (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "AcpiEnable failed")); + return_ACPI_STATUS (Status); + } + } + + /* + * Obtain a permanent mapping for the FACS. This is required for the + * Global Lock and the Firmware Waking Vector + */ + Status = AcpiTbInitializeFacs (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Could not map the FACS table")); + return_ACPI_STATUS (Status); + } + + /* + * Install the default OpRegion handlers. These are installed unless + * other handlers have already been installed via the + * InstallAddressSpaceHandler interface. + */ + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing default address space handlers\n")); + + Status = AcpiEvInstallRegionHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize ACPI Event handling (Fixed and General Purpose) + * + * Note1: We must have the hardware and events initialized before we can + * execute any control methods safely. Any control method can require + * ACPI hardware support, so the hardware must be fully initialized before + * any method execution! + * + * Note2: Fixed events are initialized and enabled here. GPEs are + * initialized, but cannot be enabled until after the hardware is + * completely initialized (SCI and GlobalLock activated) and the various + * initialization control methods are run (_REG, _STA, _INI) on the + * entire namespace. + */ + if (!(Flags & ACPI_NO_EVENT_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI events\n")); + + Status = AcpiEvInitializeEvents (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Install the SCI handler and Global Lock handler. This completes the + * hardware initialization. + */ + if (!(Flags & ACPI_NO_HANDLER_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing SCI/GL handlers\n")); + + Status = AcpiEvInstallXruptHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem) + + +/******************************************************************************* + * + * FUNCTION: AcpiInitializeObjects + * + * PARAMETERS: Flags - Init/enable Options + * + * RETURN: Status + * + * DESCRIPTION: Completes namespace initialization by initializing device + * objects and executing AML code for Regions, buffers, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInitializeObjects ( + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiInitializeObjects); + + + /* + * Run all _REG methods + * + * Note: Any objects accessed by the _REG methods will be automatically + * initialized, even if they contain executable AML (see the call to + * AcpiNsInitializeObjects below). + */ + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Executing _REG OpRegion methods\n")); + + Status = AcpiEvInitializeOpRegions (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Execute any module-level code that was detected during the table load + * phase. Although illegal since ACPI 2.0, there are many machines that + * contain this type of code. Each block of detected executable AML code + * outside of any control method is wrapped with a temporary control + * method object and placed on a global list. The methods on this list + * are executed below. + */ + AcpiNsExecModuleCodeList (); + + /* + * Initialize the objects that remain uninitialized. This runs the + * executable AML that may be part of the declaration of these objects: + * OperationRegions, BufferFields, Buffers, and Packages. + */ + if (!(Flags & ACPI_NO_OBJECT_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); + + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize all device objects in the namespace. This runs the device + * _STA and _INI methods. + */ + if (!(Flags & ACPI_NO_DEVICE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI Devices\n")); + + Status = AcpiNsInitializeDevices (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize the GPE blocks defined in the FADT (GPE block 0 and 1). + * The runtime GPEs are enabled here. + * + * This is where the _PRW methods are executed for the GPEs. These + * methods can only be executed after the SCI and Global Lock handlers are + * installed and initialized. + * + * GPEs can only be enabled after the _REG, _STA, and _INI methods have + * been run. This ensures that all Operation Regions and all Devices have + * been initialized and are ready. + */ + if (!(Flags & ACPI_NO_EVENT_INIT)) + { + Status = AcpiEvInstallFadtGpes (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* + * Empty the caches (delete the cached objects) on the assumption that + * the table load filled them up more than they will be at runtime -- + * thus wasting non-paged memory. + */ + Status = AcpiPurgeCachedObjects (); + + AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK; + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInitializeObjects) + + +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiTerminate + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTerminate ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiTerminate); + + + /* Just exit if subsystem is already shutdown */ + + if (AcpiGbl_Shutdown) + { + ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated")); + return_ACPI_STATUS (AE_OK); + } + + /* Subsystem appears active, go ahead and shut it down */ + + AcpiGbl_Shutdown = TRUE; + AcpiGbl_StartupFlags = 0; + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); + + /* Terminate the AML Debugger if present */ + + ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE); + + /* Shutdown and free all resources */ + + AcpiUtSubsystemShutdown (); + + /* Free the mutex objects */ + + AcpiUtMutexTerminate (); + + +#ifdef ACPI_DEBUGGER + + /* Shut down the debugger */ + + AcpiDbTerminate (); +#endif + + /* Now we can shutdown the OS-dependent layer */ + + Status = AcpiOsTerminate (); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiTerminate) + + +#ifndef ACPI_ASL_COMPILER +/******************************************************************************* + * + * FUNCTION: AcpiSubsystemStatus + * + * PARAMETERS: None + * + * RETURN: Status of the ACPI subsystem + * + * DESCRIPTION: Other drivers that use the ACPI subsystem should call this + * before making any other calls, to ensure the subsystem + * initialized successfully. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSubsystemStatus ( + void) +{ + + if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK) + { + return (AE_OK); + } + else + { + return (AE_ERROR); + } +} + +ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetSystemInfo + * + * PARAMETERS: OutBuffer - A buffer to receive the resources for the + * device + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get information about the current + * state of the ACPI subsystem. It will return system information + * in the OutBuffer. + * + * If the function fails an appropriate status will be returned + * and the value of OutBuffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetSystemInfo ( + ACPI_BUFFER *OutBuffer) +{ + ACPI_SYSTEM_INFO *InfoPtr; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetSystemInfo); + + + /* Parameter validation */ + + Status = AcpiUtValidateBuffer (OutBuffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Populate the return buffer + */ + InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer; + + InfoPtr->AcpiCaVersion = ACPI_CA_VERSION; + + /* System flags (ACPI capabilities) */ + + InfoPtr->Flags = ACPI_SYS_MODE_ACPI; + + /* Timer resolution - 24 or 32 bits */ + + if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) + { + InfoPtr->TimerResolution = 24; + } + else + { + InfoPtr->TimerResolution = 32; + } + + /* Clear the reserved fields */ + + InfoPtr->Reserved1 = 0; + InfoPtr->Reserved2 = 0; + + /* Current debug levels */ + + InfoPtr->DebugLayer = AcpiDbgLayer; + InfoPtr->DebugLevel = AcpiDbgLevel; + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetStatistics + * + * PARAMETERS: Stats - Where the statistics are returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: Get the contents of the various system counters + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetStatistics ( + ACPI_STATISTICS *Stats) +{ + ACPI_FUNCTION_TRACE (AcpiGetStatistics); + + + /* Parameter validation */ + + if (!Stats) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Various interrupt-based event counters */ + + Stats->SciCount = AcpiSciCount; + Stats->GpeCount = AcpiGpeCount; + + ACPI_MEMCPY (Stats->FixedEventCount, AcpiFixedEventCount, + sizeof (AcpiFixedEventCount)); + + + /* Other counters */ + + Stats->MethodCount = AcpiMethodCount; + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetStatistics) + + +/***************************************************************************** + * + * FUNCTION: AcpiInstallInitializationHandler + * + * PARAMETERS: Handler - Callback procedure + * Function - Not (currently) used, see below + * + * RETURN: Status + * + * DESCRIPTION: Install an initialization handler + * + * TBD: When a second function is added, must save the Function also. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiInstallInitializationHandler ( + ACPI_INIT_HANDLER Handler, + UINT32 Function) +{ + + if (!Handler) + { + return (AE_BAD_PARAMETER); + } + + if (AcpiGbl_InitHandler) + { + return (AE_ALREADY_EXISTS); + } + + AcpiGbl_InitHandler = Handler; + return AE_OK; +} + +ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler) + + +/***************************************************************************** + * + * FUNCTION: AcpiPurgeCachedObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Empty all caches (delete the cached objects) + * + ****************************************************************************/ + +ACPI_STATUS +AcpiPurgeCachedObjects ( + void) +{ + ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects); + + (void) AcpiOsPurgeCache (AcpiGbl_StateCache); + (void) AcpiOsPurgeCache (AcpiGbl_OperandCache); + (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache); + (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache); + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects) + +#endif /* ACPI_ASL_COMPILER */ + diff --git a/drivers/bus/acpi/acpienum.c b/drivers/bus/acpi/acpienum.c new file mode 100644 index 00000000000..50ab9eeee4b --- /dev/null +++ b/drivers/bus/acpi/acpienum.c @@ -0,0 +1,151 @@ +/* $Id: acpienum.c 21698 2006-04-22 05:55:17Z tretiakov $ + * + * PROJECT: ReactOS ACPI bus driver + * FILE: acpi/ospm/acpienum.c + * PURPOSE: ACPI namespace enumerator + * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) + * UPDATE HISTORY: + * 01-05-2001 CSH Created + */ +#include +#include +#include +#include +#include + +//#define NDEBUG +#include + +#define HAS_CHILDREN(d) ((d)->children.next != &((d)->children)) +#define HAS_SIBLINGS(d) (((d)->parent) && ((d)->node.next != &(d)->parent->children)) +#define NODE_TO_DEVICE(n) (list_entry(n, struct acpi_device, node)) + +extern struct acpi_device *acpi_root; + +NTSTATUS +Bus_PlugInDevice ( + struct acpi_device *Device, + PFDO_DEVICE_DATA FdoData + ) +{ + PDEVICE_OBJECT pdo; + PPDO_DEVICE_DATA pdoData; + NTSTATUS status; + ULONG index; + WCHAR temp[256]; + PLIST_ENTRY entry; + + PAGED_CODE (); + + /* Check we didnt add this already */ + for (entry = FdoData->ListOfPDOs.Flink; + entry != &FdoData->ListOfPDOs; entry = entry->Flink) + { + pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); + //dont duplicate devices + if(pdoData->AcpiHandle == Device->handle) + return STATUS_SUCCESS; + } + + DPRINT("Exposing PDO\n" + "======AcpiHandle: %p\n" + "======HardwareId: %s\n", + Device->handle, + Device->pnp.hardware_id); + + + // + // Create the PDO + // + + DPRINT("FdoData->NextLowerDriver = 0x%p\n", FdoData->NextLowerDriver); + + status = IoCreateDevice(FdoData->Common.Self->DriverObject, + sizeof(PDO_DEVICE_DATA), + NULL, + FILE_DEVICE_CONTROLLER, + FILE_AUTOGENERATED_DEVICE_NAME, + FALSE, + &pdo); + + if (!NT_SUCCESS (status)) { + return status; + } + + pdoData = (PPDO_DEVICE_DATA) pdo->DeviceExtension; + pdoData->AcpiHandle = Device->handle; + + // + // Copy the hardware IDs + // + index = 0; + index += swprintf(&temp[index], + L"ACPI\\%hs", + Device->pnp.hardware_id); + index++; + + index += swprintf(&temp[index], + L"*%hs", + Device->pnp.hardware_id); + index++; + temp[index] = UNICODE_NULL; + + pdoData->HardwareIDs = ExAllocatePool(NonPagedPool, index*sizeof(WCHAR)); + + + if (!pdoData->HardwareIDs) { + IoDeleteDevice(pdo); + return STATUS_INSUFFICIENT_RESOURCES; + } + + RtlCopyMemory (pdoData->HardwareIDs, temp, index*sizeof(WCHAR)); + Bus_InitializePdo (pdo, FdoData); + + // + // Device Relation changes if a new pdo is created. So let + // the PNP system now about that. This forces it to send bunch of pnp + // queries and cause the function driver to be loaded. + // + + //IoInvalidateDeviceRelations (FdoData->UnderlyingPDO, BusRelations); + + return status; +} + + +/* looks alot like acpi_bus_walk doesnt it */ +NTSTATUS +ACPIEnumerateDevices(PFDO_DEVICE_DATA DeviceExtension) +{ + ULONG Count = 0; + struct acpi_device *Device = acpi_root; + + while(Device) + { + if (Device->status.present && Device->status.enabled && + Device->flags.hardware_id) + { + Bus_PlugInDevice(Device, DeviceExtension); + Count++; + } + + if (HAS_CHILDREN(Device)) { + Device = NODE_TO_DEVICE(Device->children.next); + continue; + } + if (HAS_SIBLINGS(Device)) { + Device = NODE_TO_DEVICE(Device->node.next); + continue; + } + while ((Device = Device->parent)) { + if (HAS_SIBLINGS(Device)) { + Device = NODE_TO_DEVICE(Device->node.next); + break; + } + } + } + DPRINT("acpi device count: %d\n", Count); + return STATUS_SUCCESS; +} + +/* EOF */ diff --git a/drivers/bus/acpi/busmgr/bus.c b/drivers/bus/acpi/busmgr/bus.c new file mode 100644 index 00000000000..88589023365 --- /dev/null +++ b/drivers/bus/acpi/busmgr/bus.c @@ -0,0 +1,1849 @@ +/* + * acpi_bus.c - ACPI Bus Driver ($Revision: 80 $) + * + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + + /* + * Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ + +#include + +#include +#include +#include +#include + +//#define NDEBUG +#include + +#define _COMPONENT ACPI_BUS_COMPONENT +ACPI_MODULE_NAME ("acpi_bus") + +#define WALK_UP 0 +#define WALK_DOWN 1 + +#define STRUCT_TO_INT(s) (*((int*)&s)) +#define HAS_CHILDREN(d) ((d)->children.next != &((d)->children)) +#define HAS_SIBLINGS(d) (((d)->parent) && ((d)->node.next != &(d)->parent->children)) +#define NODE_TO_DEVICE(n) (list_entry(n, struct acpi_device, node)) + +extern int event_is_open; +extern void acpi_pic_sci_set_trigger(unsigned int irq, UINT16 trigger); + +typedef int (*acpi_bus_walk_callback)(struct acpi_device*, int, void*); + +struct acpi_device *acpi_root; +KSPIN_LOCK acpi_bus_event_lock; +LIST_HEAD(acpi_bus_event_list); +//DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue); + + +static int +acpi_device_register ( + struct acpi_device *device, + struct acpi_device *parent) +{ + int result = 0; + + if (!device) + return_VALUE(AE_BAD_PARAMETER); + + return_VALUE(result); +} + + +static int +acpi_device_unregister ( + struct acpi_device *device) +{ + if (!device) + return_VALUE(AE_BAD_PARAMETER); + +#ifdef CONFIG_LDM + put_device(&device->dev); +#endif /*CONFIG_LDM*/ + + return_VALUE(0); +} + + +/* -------------------------------------------------------------------------- + Device Management + -------------------------------------------------------------------------- */ + +void +acpi_bus_data_handler ( + ACPI_HANDLE handle, + void *context) +{ + DPRINT1("acpi_bus_data_handler not implemented"); + + /* TBD */ + + return; +} + + +int +acpi_bus_get_device ( + ACPI_HANDLE handle, + struct acpi_device **device) +{ + ACPI_STATUS status = AE_OK; + + if (!device) + return_VALUE(AE_BAD_PARAMETER); + + /* TBD: Support fixed-feature devices */ + + status = AcpiGetData(handle, acpi_bus_data_handler, (void**)device); + if (ACPI_FAILURE(status) || !*device) { + DPRINT( "Error getting context for object [%p]\n", + handle); + return_VALUE(AE_NOT_FOUND); + } + + return 0; +} + +ACPI_STATUS acpi_bus_get_status_handle(ACPI_HANDLE handle, + unsigned long long *sta) +{ + ACPI_STATUS status; + + status = acpi_evaluate_integer(handle, "_STA", NULL, sta); + if (ACPI_SUCCESS(status)) + return AE_OK; + + if (status == AE_NOT_FOUND) { + *sta = ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | + ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; + return AE_OK; + } + return status; +} + +int +acpi_bus_get_status ( + struct acpi_device *device) +{ + ACPI_STATUS status; + unsigned long long sta; + + status = acpi_bus_get_status_handle(device->handle, &sta); + if (ACPI_FAILURE(status)) + return -1; + + STRUCT_TO_INT(device->status) = (int) sta; + + if (device->status.functional && !device->status.present) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " + "functional but not present;\n", + device->pnp.bus_id, + (UINT32) STRUCT_TO_INT(device->status))); + } + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", + device->pnp.bus_id, + (UINT32) STRUCT_TO_INT(device->status))); + return 0; +} + +void acpi_bus_private_data_handler(ACPI_HANDLE handle, + void *context) +{ + return; +} + +int acpi_bus_get_private_data(ACPI_HANDLE handle, void **data) +{ + ACPI_STATUS status = AE_OK; + + if (!*data) + return -1; + + status = AcpiGetData(handle, acpi_bus_private_data_handler, data); + if (ACPI_FAILURE(status) || !*data) { + DPRINT("No context for object [%p]\n", handle); + return -1; + } + + return 0; +} +/* -------------------------------------------------------------------------- + Power Management + -------------------------------------------------------------------------- */ + +int +acpi_bus_get_power ( + ACPI_HANDLE handle, + int *state) +{ + int result = 0; + ACPI_STATUS status = 0; + struct acpi_device *device = NULL; + unsigned long long psc = 0; + + result = acpi_bus_get_device(handle, &device); + if (result) + return_VALUE(result); + + *state = ACPI_STATE_UNKNOWN; + + if (!device->flags.power_manageable) { + /* TBD: Non-recursive algorithm for walking up hierarchy */ + if (device->parent) + *state = device->parent->power.state; + else + *state = ACPI_STATE_D0; + } + else { + /* + * Get the device's power state either directly (via _PSC) or + * indirectly (via power resources). + */ + if (device->power.flags.explicit_get) { + status = acpi_evaluate_integer(device->handle, "_PSC", + NULL, &psc); + if (ACPI_FAILURE(status)) + return_VALUE(AE_NOT_FOUND); + device->power.state = (int) psc; + } + else if (device->power.flags.power_resources) { + result = acpi_power_get_inferred_state(device); + if (result) + return_VALUE(result); + } + + *state = device->power.state; + } + + DPRINT("Device [%s] power state is D%d\n", + device->pnp.bus_id, device->power.state); + + return_VALUE(0); +} + + +int +acpi_bus_set_power ( + ACPI_HANDLE handle, + int state) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_device *device = NULL; + char object_name[5] = {'_','P','S','0'+state,'\0'}; + + + result = acpi_bus_get_device(handle, &device); + if (result) + return_VALUE(result); + + if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) + return_VALUE(AE_BAD_PARAMETER); + + /* Make sure this is a valid target state */ + + if (!device->flags.power_manageable) { + DPRINT1( "Device is not power manageable\n"); + return_VALUE(AE_NOT_FOUND); + } + /* + * Get device's current power state + */ + //if (!acpi_power_nocheck) { + /* + * Maybe the incorrect power state is returned on the bogus + * bios, which is different with the real power state. + * For example: the bios returns D0 state and the real power + * state is D3. OS expects to set the device to D0 state. In + * such case if OS uses the power state returned by the BIOS, + * the device can't be transisted to the correct power state. + * So if the acpi_power_nocheck is set, it is unnecessary to + * get the power state by calling acpi_bus_get_power. + */ + acpi_bus_get_power(device->handle, &device->power.state); + //} + + if ((state == device->power.state) && !device->flags.force_power_state) { + DPRINT1("Device is already at D%d\n", state); + return 0; + } + if (!device->power.states[state].flags.valid) { + DPRINT1( "Device does not support D%d\n", state); + return AE_NOT_FOUND; + } + if (device->parent && (state < device->parent->power.state)) { + DPRINT1( "Cannot set device to a higher-powered state than parent\n"); + return AE_NOT_FOUND; + } + + /* + * Transition Power + * ---------------- + * On transitions to a high-powered state we first apply power (via + * power resources) then evalute _PSx. Conversly for transitions to + * a lower-powered state. + */ + if (state < device->power.state) { + if (device->power.flags.power_resources) { + result = acpi_power_transition(device, state); + if (result) + goto end; + } + if (device->power.states[state].flags.explicit_set) { + status = AcpiEvaluateObject(device->handle, + object_name, NULL, NULL); + if (ACPI_FAILURE(status)) { + result = AE_NOT_FOUND; + goto end; + } + } + } + else { + if (device->power.states[state].flags.explicit_set) { + status = AcpiEvaluateObject(device->handle, + object_name, NULL, NULL); + if (ACPI_FAILURE(status)) { + result = AE_NOT_FOUND; + goto end; + } + } + if (device->power.flags.power_resources) { + result = acpi_power_transition(device, state); + if (result) + goto end; + } + } + +end: + if (result) + DPRINT( "Error transitioning device [%s] to D%d\n", + device->pnp.bus_id, state); + else + DPRINT("Device [%s] transitioned to D%d\n", + device->pnp.bus_id, state); + + return result; +} + +BOOLEAN acpi_bus_power_manageable(ACPI_HANDLE handle) +{ + struct acpi_device *device; + int result; + + result = acpi_bus_get_device(handle, &device); + return result ? 0 : device->flags.power_manageable; +} + +BOOLEAN acpi_bus_can_wakeup(ACPI_HANDLE handle) +{ + struct acpi_device *device; + int result; + + result = acpi_bus_get_device(handle, &device); + return result ? 0 : device->wakeup.flags.valid; +} + +static int +acpi_bus_get_power_flags ( + struct acpi_device *device) +{ + ACPI_STATUS status = 0; + ACPI_HANDLE handle = 0; + UINT32 i = 0; + + if (!device) + return AE_NOT_FOUND; + + /* + * Power Management Flags + */ + status = AcpiGetHandle(device->handle, "_PSC", &handle); + if (ACPI_SUCCESS(status)) + device->power.flags.explicit_get = 1; + status = AcpiGetHandle(device->handle, "_IRC", &handle); + if (ACPI_SUCCESS(status)) + device->power.flags.inrush_current = 1; + status = AcpiGetHandle(device->handle, "_PRW", &handle); + if (ACPI_SUCCESS(status)) + device->flags.wake_capable = 1; + + /* + * Enumerate supported power management states + */ + for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) { + struct acpi_device_power_state *ps = &device->power.states[i]; + char object_name[5] = {'_','P','R','0'+i,'\0'}; + + /* Evaluate "_PRx" to se if power resources are referenced */ + acpi_evaluate_reference(device->handle, object_name, NULL, + &ps->resources); + if (ps->resources.count) { + device->power.flags.power_resources = 1; + ps->flags.valid = 1; + } + + /* Evaluate "_PSx" to see if we can do explicit sets */ + object_name[2] = 'S'; + status = AcpiGetHandle(device->handle, object_name, &handle); + if (ACPI_SUCCESS(status)) { + ps->flags.explicit_set = 1; + ps->flags.valid = 1; + } + + /* State is valid if we have some power control */ + if (ps->resources.count || ps->flags.explicit_set) + ps->flags.valid = 1; + + ps->power = -1; /* Unknown - driver assigned */ + ps->latency = -1; /* Unknown - driver assigned */ + } + + /* Set defaults for D0 and D3 states (always valid) */ + device->power.states[ACPI_STATE_D0].flags.valid = 1; + device->power.states[ACPI_STATE_D0].power = 100; + device->power.states[ACPI_STATE_D3].flags.valid = 1; + device->power.states[ACPI_STATE_D3].power = 0; + + device->power.state = ACPI_STATE_UNKNOWN; + + return 0; +} + +/* -------------------------------------------------------------------------- + Performance Management + -------------------------------------------------------------------------- */ + +static int +acpi_bus_get_perf_flags ( + struct acpi_device *device) +{ + if (!device) + return AE_NOT_FOUND; + + device->performance.state = ACPI_STATE_UNKNOWN; + + return 0; +} + + +/* -------------------------------------------------------------------------- + Event Management + -------------------------------------------------------------------------- */ + + +int +acpi_bus_generate_event ( + struct acpi_device *device, + UINT8 type, + int data) +{ + struct acpi_bus_event *event = NULL; + //unsigned long flags = 0; + + DPRINT1("acpi_bus_generate_event"); + + if (!device) + return_VALUE(AE_BAD_PARAMETER); + + /* drop event on the floor if no one's listening */ + //if (!event_is_open) + // return_VALUE(0); + + event = ExAllocatePool(NonPagedPool,sizeof(struct acpi_bus_event)); + if (!event) + return_VALUE(-4); + + sprintf(event->device_class, "%s", device->pnp.device_class); + sprintf(event->bus_id, "%s", device->pnp.bus_id); + event->type = type; + event->data = data; + + //spin_lock_irqsave(&acpi_bus_event_lock, flags); + list_add_tail(&event->node, &acpi_bus_event_list); + //spin_unlock_irqrestore(&acpi_bus_event_lock, flags); + + //wake_up_interruptible(&acpi_bus_event_queue); + + return_VALUE(0); +} + +int +acpi_bus_receive_event ( + struct acpi_bus_event *event) +{ + //unsigned long flags = 0; + //struct acpi_bus_event *entry = NULL; + + //DECLARE_WAITQUEUE(wait, current); + + DPRINT1("acpi_bus_receive_event"); + + //if (!event) + // return AE_BAD_PARAMETER; + + //if (list_empty(&acpi_bus_event_list)) { + + // set_current_state(TASK_INTERRUPTIBLE); + // add_wait_queue(&acpi_bus_event_queue, &wait); + + // if (list_empty(&acpi_bus_event_list)) + // schedule(); + + // remove_wait_queue(&acpi_bus_event_queue, &wait); + // set_current_state(TASK_RUNNING); + + // if (signal_pending(current)) + // return_VALUE(-ERESTARTSYS); + //} + + //spin_lock_irqsave(&acpi_bus_event_lock, flags); + //entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node); + //if (entry) + // list_del(&entry->node); + //spin_unlock_irqrestore(&acpi_bus_event_lock, flags); + + //if (!entry) + // return_VALUE(AE_NOT_FOUND); + + //memcpy(event, entry, sizeof(struct acpi_bus_event)); + + //kfree(entry); + UNIMPLEMENTED; + return_VALUE(0); +} + + +/* -------------------------------------------------------------------------- + Namespace Management + -------------------------------------------------------------------------- */ + + +/** + * acpi_bus_walk + * ------------- + * Used to walk the ACPI Bus's device namespace. Can walk down (depth-first) + * or up. Able to parse starting at any node in the namespace. Note that a + * callback return value of -249 will terminate the walk. + * + * @start: starting point + * callback: function to call for every device encountered while parsing + * direction: direction to parse (up or down) + * @data: context for this search operation + */ +static int +acpi_bus_walk ( + struct acpi_device *start, + acpi_bus_walk_callback callback, + int direction, + void *data) +{ + int result = 0; + int level = 0; + struct acpi_device *device = NULL; + + if (!start || !callback) + return AE_BAD_PARAMETER; + + device = start; + + /* + * Parse Namespace + * --------------- + * Parse a given subtree (specified by start) in the given direction. + * Walking 'up' simply means that we execute the callback on leaf + * devices prior to their parents (useful for things like removing + * or powering down a subtree). + */ + + while (device) { + + if (direction == WALK_DOWN) + if (-249 == callback(device, level, data)) + break; + + /* Depth First */ + + if (HAS_CHILDREN(device)) { + device = NODE_TO_DEVICE(device->children.next); + ++level; + continue; + } + + if (direction == WALK_UP) + if (-249 == callback(device, level, data)) + break; + + /* Now Breadth */ + + if (HAS_SIBLINGS(device)) { + device = NODE_TO_DEVICE(device->node.next); + continue; + } + + /* Scope Exhausted - Find Next */ + + while ((device = device->parent)) { + --level; + if (HAS_SIBLINGS(device)) { + device = NODE_TO_DEVICE(device->node.next); + break; + } + } + } + + if ((direction == WALK_UP) && (result == 0)) + callback(start, level, data); + + return result; +} + + +/* -------------------------------------------------------------------------- + Notification Handling + -------------------------------------------------------------------------- */ + +static void +acpi_bus_check_device (ACPI_HANDLE handle) +{ + struct acpi_device *device; + ACPI_STATUS status = 0; + struct acpi_device_status old_status; + + if (acpi_bus_get_device(handle, &device)) + return; + if (!device) + return; + + old_status = device->status; + + /* + * Make sure this device's parent is present before we go about + * messing with the device. + */ + if (device->parent && !device->parent->status.present) { + device->status = device->parent->status; + return; + } + + status = acpi_bus_get_status(device); + if (ACPI_FAILURE(status)) + return; + + if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) + return; + + + /* + * Device Insertion/Removal + */ + if ((device->status.present) && !(old_status.present)) { + DPRINT("Device insertion detected\n"); + /* TBD: Handle device insertion */ + } + else if (!(device->status.present) && (old_status.present)) { + DPRINT("Device removal detected\n"); + /* TBD: Handle device removal */ + } + +} + + +static void +acpi_bus_check_scope (ACPI_HANDLE handle) +{ + /* Status Change? */ + acpi_bus_check_device(handle); + + /* + * TBD: Enumerate child devices within this device's scope and + * run acpi_bus_check_device()'s on them. + */ +} + + +/** + * acpi_bus_notify + * --------------- + * Callback for all 'system-level' device notifications (values 0x00-0x7F). + */ +static void +acpi_bus_notify ( + ACPI_HANDLE handle, + UINT32 type, + void *data) +{ + struct acpi_device *device = NULL; + struct acpi_driver *driver; + + DPRINT1("Notification %#02x to handle %p\n", type, handle); + + //blocking_notifier_call_chain(&acpi_bus_notify_list, + // type, (void *)handle); + + switch (type) { + + case ACPI_NOTIFY_BUS_CHECK: + DPRINT("Received BUS CHECK notification for device [%s]\n", + device->pnp.bus_id); + acpi_bus_check_scope(handle); + /* + * TBD: We'll need to outsource certain events to non-ACPI + * drivers via the device manager (device.c). + */ + break; + + case ACPI_NOTIFY_DEVICE_CHECK: + DPRINT("Received DEVICE CHECK notification for device [%s]\n", + device->pnp.bus_id); + acpi_bus_check_device(handle); + /* + * TBD: We'll need to outsource certain events to non-ACPI + * drivers via the device manager (device.c). + */ + break; + + case ACPI_NOTIFY_DEVICE_WAKE: + DPRINT("Received DEVICE WAKE notification for device [%s]\n", + device->pnp.bus_id); + acpi_bus_check_device(handle); + /* + * TBD: We'll need to outsource certain events to non-ACPI + * drivers via the device manager (device.c). + */ + break; + + case ACPI_NOTIFY_EJECT_REQUEST: + DPRINT1("Received EJECT REQUEST notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + case ACPI_NOTIFY_DEVICE_CHECK_LIGHT: + DPRINT1("Received DEVICE CHECK LIGHT notification for device [%s]\n", + device->pnp.bus_id); + /* TBD: Exactly what does 'light' mean? */ + break; + + case ACPI_NOTIFY_FREQUENCY_MISMATCH: + DPRINT1("Received FREQUENCY MISMATCH notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + case ACPI_NOTIFY_BUS_MODE_MISMATCH: + DPRINT1("Received BUS MODE MISMATCH notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + case ACPI_NOTIFY_POWER_FAULT: + DPRINT1("Received POWER FAULT notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + default: + DPRINT1("Received unknown/unsupported notification [%08x]\n", + type); + break; + } + + acpi_bus_get_device(handle, &device); + if (device) { + driver = device->driver; + if (driver && driver->ops.notify && + (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS)) + driver->ops.notify(device, type); + } +} + + +/* -------------------------------------------------------------------------- + Driver Management + -------------------------------------------------------------------------- */ + + +static LIST_HEAD(acpi_bus_drivers); +//static DECLARE_MUTEX(acpi_bus_drivers_lock); + + +/** + * acpi_bus_match + * -------------- + * Checks the device's hardware (_HID) or compatible (_CID) ids to see if it + * matches the specified driver's criteria. + */ +static int +acpi_bus_match ( + struct acpi_device *device, + struct acpi_driver *driver) +{ + int error = 0; + + if (device->flags.hardware_id) + if (strstr(driver->ids, device->pnp.hardware_id)) + goto Done; + + if (device->flags.compatible_ids) { + ACPI_DEVICE_ID_LIST *cid_list = device->pnp.cid_list; + int i; + + /* compare multiple _CID entries against driver ids */ + for (i = 0; i < cid_list->Count; i++) + { + if (strstr(driver->ids, cid_list->Ids[i].String)) + goto Done; + } + } + error = -2; + + Done: + + return error; +} + + +/** + * acpi_bus_driver_init + * -------------------- + * Used to initialize a device via its device driver. Called whenever a + * driver is bound to a device. Invokes the driver's add() and start() ops. + */ +static int +acpi_bus_driver_init ( + struct acpi_device *device, + struct acpi_driver *driver) +{ + int result = 0; + + if (!device || !driver) + return_VALUE(AE_BAD_PARAMETER); + + if (!driver->ops.add) + return_VALUE(-38); + + result = driver->ops.add(device); + if (result) { + device->driver = NULL; + //acpi_driver_data(device) = NULL; + return_VALUE(result); + } + + device->driver = driver; + + /* + * TBD - Configuration Management: Assign resources to device based + * upon possible configuration and currently allocated resources. + */ + + if (driver->ops.start) { + result = driver->ops.start(device); + if (result && driver->ops.remove) + driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); + return_VALUE(result); + } + + DPRINT("Driver successfully bound to device\n"); + + if (driver->ops.scan) { + driver->ops.scan(device); + } + + return_VALUE(0); +} + + +/** + * acpi_bus_attach + * ------------- + * Callback for acpi_bus_walk() used to find devices that match a specific + * driver's criteria and then attach the driver. + */ +static int +acpi_bus_attach ( + struct acpi_device *device, + int level, + void *data) +{ + int result = 0; + struct acpi_driver *driver = NULL; + + if (!device || !data) + return_VALUE(AE_BAD_PARAMETER); + + driver = (struct acpi_driver *) data; + + if (device->driver) + return_VALUE(-9); + + if (!device->status.present) + return_VALUE(AE_NOT_FOUND); + + result = acpi_bus_match(device, driver); + if (result) + return_VALUE(result); + + DPRINT("Found driver [%s] for device [%s]\n", + driver->name, device->pnp.bus_id); + + result = acpi_bus_driver_init(device, driver); + if (result) + return_VALUE(result); + + //down(&acpi_bus_drivers_lock); + ++driver->references; + //up(&acpi_bus_drivers_lock); + + return_VALUE(0); +} + + +/** + * acpi_bus_unattach + * ----------------- + * Callback for acpi_bus_walk() used to find devices that match a specific + * driver's criteria and unattach the driver. + */ +static int +acpi_bus_unattach ( + struct acpi_device *device, + int level, + void *data) +{ + int result = 0; + struct acpi_driver *driver = (struct acpi_driver *) data; + + if (!device || !driver) + return_VALUE(AE_BAD_PARAMETER); + + if (device->driver != driver) + return_VALUE(-6); + + if (!driver->ops.remove) + return_VALUE(-23); + + result = driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); + if (result) + return_VALUE(result); + + device->driver = NULL; + acpi_driver_data(device) = NULL; + + //down(&acpi_bus_drivers_lock); + driver->references--; + //up(&acpi_bus_drivers_lock); + + return_VALUE(0); +} + + +/** + * acpi_bus_find_driver + * -------------------- + * Parses the list of registered drivers looking for a driver applicable for + * the specified device. + */ +static int +acpi_bus_find_driver ( + struct acpi_device *device) +{ + int result = AE_NOT_FOUND; + struct list_head *entry = NULL; + struct acpi_driver *driver = NULL; + + if (!device || device->driver) + return_VALUE(AE_BAD_PARAMETER); + + //down(&acpi_bus_drivers_lock); + + list_for_each(entry, &acpi_bus_drivers) { + + driver = list_entry(entry, struct acpi_driver, node); + + if (acpi_bus_match(device, driver)) + continue; + + result = acpi_bus_driver_init(device, driver); + if (!result) + ++driver->references; + + break; + } + + //up(&acpi_bus_drivers_lock); + + return_VALUE(result); +} + + +/** + * acpi_bus_register_driver + * ------------------------ + * Registers a driver with the ACPI bus. Searches the namespace for all + * devices that match the driver's criteria and binds. + */ +int +acpi_bus_register_driver ( + struct acpi_driver *driver) +{ + if (!driver) + return_VALUE(AE_BAD_PARAMETER); + + //if (acpi_disabled) + // return_VALUE(AE_NOT_FOUND); + + //down(&acpi_bus_drivers_lock); + list_add_tail(&driver->node, &acpi_bus_drivers); + //up(&acpi_bus_drivers_lock); + + acpi_bus_walk(acpi_root, acpi_bus_attach, + WALK_DOWN, driver); + + return_VALUE(driver->references); +} + + +/** + * acpi_bus_unregister_driver + * -------------------------- + * Unregisters a driver with the ACPI bus. Searches the namespace for all + * devices that match the driver's criteria and unbinds. + */ +void +acpi_bus_unregister_driver ( + struct acpi_driver *driver) +{ + if (!driver) + return; + + acpi_bus_walk(acpi_root, acpi_bus_unattach, WALK_UP, driver); + + if (driver->references) + return; + + //down(&acpi_bus_drivers_lock); + list_del(&driver->node); + //up(&acpi_bus_drivers_lock); + + return; +} + + +/* -------------------------------------------------------------------------- + Device Enumeration + -------------------------------------------------------------------------- */ + +static int +acpi_bus_get_flags ( + struct acpi_device *device) +{ + ACPI_STATUS status = AE_OK; + ACPI_HANDLE temp = NULL; + + /* Presence of _STA indicates 'dynamic_status' */ + status = AcpiGetHandle(device->handle, "_STA", &temp); + if (ACPI_SUCCESS(status)) + device->flags.dynamic_status = 1; + + /* Presence of _CID indicates 'compatible_ids' */ + status = AcpiGetHandle(device->handle, "_CID", &temp); + if (ACPI_SUCCESS(status)) + device->flags.compatible_ids = 1; + + /* Presence of _RMV indicates 'removable' */ + status = AcpiGetHandle(device->handle, "_RMV", &temp); + if (ACPI_SUCCESS(status)) + device->flags.removable = 1; + + /* Presence of _EJD|_EJ0 indicates 'ejectable' */ + status = AcpiGetHandle(device->handle, "_EJD", &temp); + if (ACPI_SUCCESS(status)) + device->flags.ejectable = 1; + else { + status = AcpiGetHandle(device->handle, "_EJ0", &temp); + if (ACPI_SUCCESS(status)) + device->flags.ejectable = 1; + } + + /* Presence of _LCK indicates 'lockable' */ + status = AcpiGetHandle(device->handle, "_LCK", &temp); + if (ACPI_SUCCESS(status)) + device->flags.lockable = 1; + + /* Presence of _PS0|_PR0 indicates 'power manageable' */ + status = AcpiGetHandle(device->handle, "_PS0", &temp); + if (ACPI_FAILURE(status)) + status = AcpiGetHandle(device->handle, "_PR0", &temp); + if (ACPI_SUCCESS(status)) + device->flags.power_manageable = 1; + + /* TBD: Peformance management */ + + return_VALUE(0); +} + + +int +acpi_bus_add ( + struct acpi_device **child, + struct acpi_device *parent, + ACPI_HANDLE handle, + int type) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_device *device = NULL; + char bus_id[5] = {'?',0}; + ACPI_BUFFER buffer; + ACPI_DEVICE_INFO *info; + char *hid = NULL; + char *uid = NULL; + ACPI_DEVICE_ID_LIST *cid_list = NULL; + int i = 0; + + if (!child) + return_VALUE(AE_BAD_PARAMETER); + + device = ExAllocatePool(NonPagedPool,sizeof(struct acpi_device)); + if (!device) { + DPRINT1("Memory allocation error\n"); + return_VALUE(-12); + } + memset(device, 0, sizeof(struct acpi_device)); + + device->handle = handle; + device->parent = parent; + + /* + * Bus ID + * ------ + * The device's Bus ID is simply the object name. + * TBD: Shouldn't this value be unique (within the ACPI namespace)? + */ + switch (type) { + case ACPI_BUS_TYPE_SYSTEM: + sprintf(device->pnp.bus_id, "%s", "ACPI"); + break; + case ACPI_BUS_TYPE_POWER_BUTTON: + sprintf(device->pnp.bus_id, "%s", "PWRF"); + break; + case ACPI_BUS_TYPE_SLEEP_BUTTON: + sprintf(device->pnp.bus_id, "%s", "SLPF"); + break; + default: + buffer.Length = sizeof(bus_id); + buffer.Pointer = bus_id; + AcpiGetName(handle, ACPI_SINGLE_NAME, &buffer); + + + /* Clean up trailing underscores (if any) */ + for (i = 3; i > 1; i--) { + if (bus_id[i] == '_') + bus_id[i] = '\0'; + else + break; + } + sprintf(device->pnp.bus_id, "%s", bus_id); + buffer.Pointer = NULL; + break; + } + + /* + * Flags + * ----- + * Get prior to calling acpi_bus_get_status() so we know whether + * or not _STA is present. Note that we only look for object + * handles -- cannot evaluate objects until we know the device is + * present and properly initialized. + */ + result = acpi_bus_get_flags(device); + if (result) + goto end; + + /* + * Status + * ------ + * See if the device is present. We always assume that non-Device() + * objects (e.g. thermal zones, power resources, processors, etc.) are + * present, functioning, etc. (at least when parent object is present). + * Note that _STA has a different meaning for some objects (e.g. + * power resources) so we need to be careful how we use it. + */ + switch (type) { + case ACPI_BUS_TYPE_DEVICE: + result = acpi_bus_get_status(device); + if (result) + goto end; + break; + default: + STRUCT_TO_INT(device->status) = 0x0F; + break; + } + if (!device->status.present) { + result = -2; + goto end; + } + + /* + * Initialize Device + * ----------------- + * TBD: Synch with Core's enumeration/initialization process. + */ + + /* + * Hardware ID, Unique ID, & Bus Address + * ------------------------------------- + */ + switch (type) { + case ACPI_BUS_TYPE_DEVICE: + status = AcpiGetObjectInfo(handle,&info); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error reading device info\n")); + result = AE_NOT_FOUND; + goto end; + } + if (info->Valid & ACPI_VALID_HID) + hid = info->HardwareId.String; + if (info->Valid & ACPI_VALID_UID) + uid = info->UniqueId.String; + if (info->Valid & ACPI_VALID_CID) { + cid_list = &info->CompatibleIdList; + device->pnp.cid_list = ExAllocatePool(NonPagedPool,cid_list->ListSize); + if (device->pnp.cid_list) + memcpy(device->pnp.cid_list, cid_list, cid_list->ListSize); + else + DPRINT("Memory allocation error\n"); + } + if (info->Valid & ACPI_VALID_ADR) { + device->pnp.bus_address = info->Address; + device->flags.bus_address = 1; + } + break; + case ACPI_BUS_TYPE_POWER: + hid = ACPI_POWER_HID; + break; + case ACPI_BUS_TYPE_PROCESSOR: + hid = ACPI_PROCESSOR_HID; + break; + case ACPI_BUS_TYPE_SYSTEM: + hid = ACPI_SYSTEM_HID; + break; + case ACPI_BUS_TYPE_THERMAL: + hid = ACPI_THERMAL_HID; + break; + case ACPI_BUS_TYPE_POWER_BUTTON: + hid = ACPI_BUTTON_HID_POWERF; + break; + case ACPI_BUS_TYPE_SLEEP_BUTTON: + hid = ACPI_BUTTON_HID_SLEEPF; + break; + } + + /* + * \_SB + * ---- + * Fix for the system root bus device -- the only root-level device. + */ + if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { + hid = ACPI_BUS_HID; + sprintf(device->pnp.device_name, "%s", ACPI_BUS_DEVICE_NAME); + sprintf(device->pnp.device_class, "%s", ACPI_BUS_CLASS); + } + + if (hid) { + sprintf(device->pnp.hardware_id, "%s", hid); + device->flags.hardware_id = 1; + } + if (uid) { + sprintf(device->pnp.unique_id, "%s", uid); + device->flags.unique_id = 1; + } + + /* + * If we called get_object_info, we now are finished with the buffer, + * so we can free it. + */ + //if (buffer.Pointer) + //AcpiOsFree(buffer.Pointer); + + /* + * Power Management + * ---------------- + */ + if (device->flags.power_manageable) { + result = acpi_bus_get_power_flags(device); + if (result) + goto end; + } + + /* + * Performance Management + * ---------------------- + */ + if (device->flags.performance_manageable) { + result = acpi_bus_get_perf_flags(device); + if (result) + goto end; + } + + /* + * Context + * ------- + * Attach this 'struct acpi_device' to the ACPI object. This makes + * resolutions from handle->device very efficient. Note that we need + * to be careful with fixed-feature devices as they all attach to the + * root object. + */ + switch (type) { + case ACPI_BUS_TYPE_POWER_BUTTON: + case ACPI_BUS_TYPE_SLEEP_BUTTON: + break; + default: + status = AcpiAttachData(device->handle, + acpi_bus_data_handler, device); + break; + } + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error attaching device data\n")); + result = AE_NOT_FOUND; + goto end; + } + + /* + * Linkage + * ------- + * Link this device to its parent and siblings. + */ + INIT_LIST_HEAD(&device->children); + if (!device->parent) + INIT_LIST_HEAD(&device->node); + else + list_add_tail(&device->node, &device->parent->children); + + /* + * Global Device Hierarchy: + * ------------------------ + * Register this device with the global device hierarchy. + */ + acpi_device_register(device, parent); + + /* + * Bind _ADR-Based Devices + * ----------------------- + * If there's a a bus address (_ADR) then we utilize the parent's + * 'bind' function (if exists) to bind the ACPI- and natively- + * enumerated device representations. + */ + if (device->flags.bus_address) { + if (device->parent && device->parent->ops.bind) + device->parent->ops.bind(device); + } + + /* + * Locate & Attach Driver + * ---------------------- + * If there's a hardware id (_HID) or compatible ids (_CID) we check + * to see if there's a driver installed for this kind of device. Note + * that drivers can install before or after a device is enumerated. + * + * TBD: Assumes LDM provides driver hot-plug capability. + */ + if (device->flags.hardware_id || device->flags.compatible_ids) + acpi_bus_find_driver(device); + +end: + if (result) { + if (device->pnp.cid_list) { + ExFreePool(device->pnp.cid_list); + } + ExFreePool(device); + return_VALUE(result); + } + *child = device; + + return_VALUE(0); +} + + +static int +acpi_bus_remove ( + struct acpi_device *device, + int type) +{ + + if (!device) + return_VALUE(AE_NOT_FOUND); + + acpi_device_unregister(device); + + if (device && device->pnp.cid_list) + ExFreePool(device->pnp.cid_list); + + if (device) + ExFreePool(device); + + return_VALUE(0); +} + + +int +acpi_bus_scan ( + struct acpi_device *start) +{ + ACPI_STATUS status = AE_OK; + struct acpi_device *parent = NULL; + struct acpi_device *child = NULL; + ACPI_HANDLE phandle = 0; + ACPI_HANDLE chandle = 0; + ACPI_OBJECT_TYPE type = 0; + UINT32 level = 1; + + if (!start) + return_VALUE(AE_BAD_PARAMETER); + + parent = start; + phandle = start->handle; + + /* + * Parse through the ACPI namespace, identify all 'devices', and + * create a new 'struct acpi_device' for each. + */ + while ((level > 0) && parent) { + + status = AcpiGetNextObject(ACPI_TYPE_ANY, phandle, + chandle, &chandle); + + /* + * If this scope is exhausted then move our way back up. + */ + if (ACPI_FAILURE(status)) { + level--; + chandle = phandle; + AcpiGetParent(phandle, &phandle); + if (parent->parent) + parent = parent->parent; + continue; + } + + status = AcpiGetType(chandle, &type); + if (ACPI_FAILURE(status)) + continue; + + /* + * If this is a scope object then parse it (depth-first). + */ + if (type == ACPI_TYPE_LOCAL_SCOPE) { + level++; + phandle = chandle; + chandle = 0; + continue; + } + + /* + * We're only interested in objects that we consider 'devices'. + */ + switch (type) { + case ACPI_TYPE_DEVICE: + type = ACPI_BUS_TYPE_DEVICE; + break; + case ACPI_TYPE_PROCESSOR: + type = ACPI_BUS_TYPE_PROCESSOR; + break; + case ACPI_TYPE_THERMAL: + type = ACPI_BUS_TYPE_THERMAL; + break; + case ACPI_TYPE_POWER: + type = ACPI_BUS_TYPE_POWER; + break; + default: + continue; + } + + status = acpi_bus_add(&child, parent, chandle, type); + if (ACPI_FAILURE(status)) + continue; + + /* + * If the device is present, enabled, and functioning then + * parse its scope (depth-first). Note that we need to + * represent absent devices to facilitate PnP notifications + * -- but only the subtree head (not all of its children, + * which will be enumerated when the parent is inserted). + * + * TBD: Need notifications and other detection mechanisms + * in place before we can fully implement this. + */ + if (child->status.present) { + status = AcpiGetNextObject(ACPI_TYPE_ANY, chandle, + 0, NULL); + if (ACPI_SUCCESS(status)) { + level++; + phandle = chandle; + chandle = 0; + parent = child; + } + } + } + + return_VALUE(0); +} + + +static int +acpi_bus_scan_fixed ( + struct acpi_device *root) +{ + int result = 0; + struct acpi_device *device = NULL; + + if (!root) + return_VALUE(AE_NOT_FOUND); + + /* + * Enumerate all fixed-feature devices. + */ + if (AcpiGbl_FADT.Flags & ACPI_FADT_POWER_BUTTON) + result = acpi_bus_add(&device, acpi_root, + NULL, ACPI_BUS_TYPE_POWER_BUTTON); + + if (AcpiGbl_FADT.Flags & ACPI_FADT_SLEEP_BUTTON) + result = acpi_bus_add(&device, acpi_root, + NULL, ACPI_BUS_TYPE_SLEEP_BUTTON); + + return_VALUE(result); +} + + +/* -------------------------------------------------------------------------- + Initialization/Cleanup + -------------------------------------------------------------------------- */ + +static int +acpi_bus_init_irq (void) +{ + ACPI_STATUS status = AE_OK; + ACPI_OBJECT arg = {ACPI_TYPE_INTEGER}; + ACPI_OBJECT_LIST arg_list = {1, &arg}; + //char *message = NULL; + + DPRINT("acpi_bus_init_irq"); + + /* + * Let the system know what interrupt model we are using by + * evaluating the \_PIC object, if exists. + */ + + //switch (acpi_irq_model) { + //case ACPI_IRQ_MODEL_PIC: + // message = "PIC"; + // break; + //case ACPI_IRQ_MODEL_IOAPIC: + // message = "IOAPIC"; + // break; + //case ACPI_IRQ_MODEL_IOSAPIC: + // message = "IOSAPIC"; + // break; + //default: + // DPRINT1("Unknown interrupt routing model\n"); + // return_VALUE(AE_NOT_FOUND); + //} + + //DPRINT("Using %s for interrupt routing\n", message); + + //arg.Integer.Value = acpi_irq_model; + + //status = AcpiEvaluateObject(NULL, "\\_PIC", &arg_list, NULL); + //if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { + // ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n")); + // return_VALUE(AE_NOT_FOUND); + //} + + return_VALUE(0); +} + + +//void +//acpi_early_init (void) +//{ +// ACPI_STATUS status = AE_OK; +// +// DPRINT("acpi_early_init"); +// +// if (acpi_disabled) +// return_VOID; +// + /* enable workarounds, unless strict ACPI spec. compliance */ +// if (!acpi_strict) +// acpi_gbl_enable_interpreter_slack = TRUE; +// +// status = acpi_reallocate_root_table(); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX +// "Unable to reallocate ACPI tables\n"); +// goto error0; +// } +// +// status = acpi_initialize_subsystem(); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX +// "Unable to initialize the ACPI Interpreter\n"); +// goto error0; +// } +// +// status = acpi_load_tables(); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX +// "Unable to load the System Description Tables\n"); +// goto error0; +// } +// +//#ifdef CONFIG_X86 +// if (!acpi_ioapic) { +// /* compatible (0) means level (3) */ +// if (!(acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)) { +// acpi_sci_flags &= ~ACPI_MADT_TRIGGER_MASK; +// acpi_sci_flags |= ACPI_MADT_TRIGGER_LEVEL; +// } +// /* Set PIC-mode SCI trigger type */ +// acpi_pic_sci_set_trigger(acpi_gbl_FADT.sci_interrupt, +// (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2); +// } else { +// /* +// * now that acpi_gbl_FADT is initialized, +// * update it with result from INT_SRC_OVR parsing +// */ +// acpi_gbl_FADT.sci_interrupt = acpi_sci_override_gsi; +// } +//#endif +// +// status = +// acpi_enable_subsystem(~ +// (ACPI_NO_HARDWARE_INIT | +// ACPI_NO_ACPI_ENABLE)); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); +// goto error0; +// } +// +// return; +// +// error0: +// disable_acpi(); +// return; +//} + +int +acpi_bus_init (void) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + + DPRINT("acpi_bus_init"); + + status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION); + if (ACPI_FAILURE(status)) { + DPRINT1("Unable to start the ACPI Interpreter\n"); + goto error1; + } + + /* + * ACPI 2.0 requires the EC driver to be loaded and work before + * the EC device is found in the namespace. This is accomplished + * by looking for the ECDT table, and getting the EC parameters out + * of that. + */ + //result = acpi_ec_ecdt_probe(); + /* Ignore result. Not having an ECDT is not fatal. */ + + status = AcpiInitializeObjects(ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); + if (ACPI_FAILURE(status)) { + DPRINT1("Unable to initialize ACPI objects\n"); + goto error1; + } + + /* + * Maybe EC region is required at bus_scan/acpi_get_devices. So it + * is necessary to enable it as early as possible. + */ + //acpi_boot_ec_enable(); + + /* Initialize sleep structures */ + //acpi_sleep_init(); + + /* + * Get the system interrupt model and evaluate \_PIC. + */ + result = acpi_bus_init_irq(); + if (result) + goto error1; + + /* + * Register the for all standard device notifications. + */ + status = AcpiInstallNotifyHandler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &acpi_bus_notify, NULL); + if (ACPI_FAILURE(status)) { + DPRINT1("Unable to register for device notifications\n"); + result = AE_NOT_FOUND; + goto error1; + } + + /* + * Create the root device in the bus's device tree + */ + result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT, + ACPI_BUS_TYPE_SYSTEM); + if (result) + goto error2; + + /* + * Enumerate devices in the ACPI namespace. + */ + result = acpi_bus_scan_fixed(acpi_root); + if (result) + DPRINT1("acpi_bus_scan_fixed failed\n"); + result = acpi_bus_scan(acpi_root); + if (result) + DPRINT1("acpi_bus_scan failed\n"); + + //acpi_motherboard_init(); + return_VALUE(0); + + /* Mimic structured exception handling */ +error2: + AcpiRemoveNotifyHandler(ACPI_ROOT_OBJECT, + ACPI_SYSTEM_NOTIFY, &acpi_bus_notify); +error1: + AcpiTerminate(); + return_VALUE(AE_NOT_FOUND); +} + +static void +acpi_bus_exit (void) +{ + ACPI_STATUS status = AE_OK; + + DPRINT("acpi_bus_exit"); + + status = AcpiRemoveNotifyHandler(ACPI_ROOT_OBJECT, + ACPI_SYSTEM_NOTIFY, acpi_bus_notify); + if (ACPI_FAILURE(status)) + DPRINT1("Error removing notify handler\n"); + +#ifdef CONFIG_ACPI_PCI + acpi_pci_root_exit(); + acpi_pci_link_exit(); +#endif +#ifdef CONFIG_ACPI_EC + acpi_ec_exit(); +#endif + //acpi_power_exit(); + acpi_system_exit(); + + acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL); + + status = AcpiTerminate(); + if (ACPI_FAILURE(status)) + DPRINT1("Unable to terminate the ACPI Interpreter\n"); + else + DPRINT1("Interpreter disabled\n"); + + return_VOID; +} + + +int +acpi_init (void) +{ + int result = 0; + + DPRINT("acpi_init"); + + DPRINT("Subsystem revision %08x\n",ACPI_CA_VERSION); + + result = acpi_bus_init(); + + //if (!result) { + //pci_mmcfg_late_init(); + //if (!(pm_flags & PM_APM)) + // pm_flags |= PM_ACPI; + //else { + //DPRINT1("APM is already active, exiting\n"); + //disable_acpi(); + //result = -ENODEV; + //} + //} else + // disable_acpi(); + + /* + * If the laptop falls into the DMI check table, the power state check + * will be disabled in the course of device power transistion. + */ + //dmi_check_system(power_nocheck_dmi_table); + + /* + * Install drivers required for proper enumeration of the + * ACPI namespace. + */ + acpi_system_init(); /* ACPI System */ + acpi_power_init(); /* ACPI Bus Power Management */ + acpi_button_init(); + //acpi_ec_init(); /* ACPI Embedded Controller */ +#ifdef CONFIG_ACPI_PCI + if (!acpi_pci_disabled) { + acpi_pci_link_init(); /* ACPI PCI Interrupt Link */ + acpi_pci_root_init(); /* ACPI PCI Root Bridge */ + } +#endif + + //acpi_scan_init(); + //acpi_ec_init(); + //acpi_power_init(); + //acpi_system_init(); + //acpi_debug_init(); + //acpi_sleep_proc_init(); + //acpi_wakeup_device_init(); + + return result; +} + + +void +acpi_exit (void) +{ + DPRINT("acpi_exit"); + +#ifdef CONFIG_PM + pm_active = 0; +#endif + + acpi_bus_exit(); + + return_VOID; +} + diff --git a/drivers/bus/acpi/busmgr/button.c b/drivers/bus/acpi/busmgr/button.c new file mode 100644 index 00000000000..5e3eb2b5f0f --- /dev/null +++ b/drivers/bus/acpi/busmgr/button.c @@ -0,0 +1,328 @@ +/* + * acpi_button.c - ACPI Button Driver ($Revision: 29 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ +#include + +#include +#include +#include +#include + +#define NDEBUG +#include + + + +#define _COMPONENT ACPI_BUTTON_COMPONENT +ACPI_MODULE_NAME ("acpi_button") + + +static int acpi_button_add (struct acpi_device *device); +static int acpi_button_remove (struct acpi_device *device, int type); + +static struct acpi_driver acpi_button_driver = { + .name = ACPI_BUTTON_DRIVER_NAME, + .class = ACPI_BUTTON_CLASS, + .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E", + .ops = { + .add = acpi_button_add, + .remove = acpi_button_remove, + }, +}; + +struct acpi_button { + ACPI_HANDLE handle; + struct acpi_device *device; /* Fixed button kludge */ + UINT8 type; + unsigned long pushed; +}; +/* -------------------------------------------------------------------------- + Driver Interface + -------------------------------------------------------------------------- */ + +void +acpi_button_notify ( + ACPI_HANDLE handle, + UINT32 event, + void *data) +{ + struct acpi_button *button = (struct acpi_button *) data; + + ACPI_FUNCTION_TRACE("acpi_button_notify"); + + if (!button || !button->device) + return_VOID; + + switch (event) { + case ACPI_BUTTON_NOTIFY_STATUS: + acpi_bus_generate_event(button->device, event, ++button->pushed); + break; + default: + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Unsupported event [0x%x]\n", event)); + break; + } + + return_VOID; +} + + +ACPI_STATUS +acpi_button_notify_fixed ( + void *data) +{ + struct acpi_button *button = (struct acpi_button *) data; + + ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); + + if (!button) + return_ACPI_STATUS(AE_BAD_PARAMETER); + + acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); + + return_ACPI_STATUS(AE_OK); +} + + +static int +acpi_button_add ( + struct acpi_device *device) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_button *button = NULL; + + static struct acpi_device *power_button; + static struct acpi_device *sleep_button; + static struct acpi_device *lid_button; + + ACPI_FUNCTION_TRACE("acpi_button_add"); + + if (!device) + return_VALUE(-1); + + button = ExAllocatePool(NonPagedPool,sizeof(struct acpi_button)); + if (!button) + return_VALUE(-4); + memset(button, 0, sizeof(struct acpi_button)); + + button->device = device; + button->handle = device->handle; + acpi_driver_data(device) = button; + + /* + * Determine the button type (via hid), as fixed-feature buttons + * need to be handled a bit differently than generic-space. + */ + if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) { + button->type = ACPI_BUTTON_TYPE_POWER; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_POWER); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) { + button->type = ACPI_BUTTON_TYPE_POWERF; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_POWERF); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) { + button->type = ACPI_BUTTON_TYPE_SLEEP; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_SLEEP); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) { + button->type = ACPI_BUTTON_TYPE_SLEEPF; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_SLEEPF); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) { + button->type = ACPI_BUTTON_TYPE_LID; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_LID); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); + } + else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", + acpi_device_hid(device))); + result = -15; + goto end; + } + + /* + * Ensure only one button of each type is used. + */ + switch (button->type) { + case ACPI_BUTTON_TYPE_POWER: + case ACPI_BUTTON_TYPE_POWERF: + if (!power_button) + power_button = device; + else { + ExFreePool(button); + return_VALUE(-15); + } + break; + case ACPI_BUTTON_TYPE_SLEEP: + case ACPI_BUTTON_TYPE_SLEEPF: + if (!sleep_button) + sleep_button = device; + else { + ExFreePool(button); + return_VALUE(-15); + } + break; + case ACPI_BUTTON_TYPE_LID: + if (!lid_button) + lid_button = device; + else { + ExFreePool(button); + return_VALUE(-15); + } + break; + } + + switch (button->type) { + case ACPI_BUTTON_TYPE_POWERF: + status = AcpiInstallFixedEventHandler ( + ACPI_EVENT_POWER_BUTTON, + acpi_button_notify_fixed, + button); + break; + case ACPI_BUTTON_TYPE_SLEEPF: + status = AcpiInstallFixedEventHandler ( + ACPI_EVENT_SLEEP_BUTTON, + acpi_button_notify_fixed, + button); + break; + case ACPI_BUTTON_TYPE_LID: + status = AcpiInstallFixedEventHandler ( + ACPI_BUTTON_TYPE_LID, + acpi_button_notify_fixed, + button); + break; + default: + status = AcpiInstallNotifyHandler ( + button->handle, + ACPI_DEVICE_NOTIFY, + acpi_button_notify, + button); + break; + } + + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing notify handler\n")); + result = -15; + goto end; + } + + DPRINT("%s [%s]\n", + acpi_device_name(device), acpi_device_bid(device)); + +end: + if (result) { + ExFreePool(button); + } + + return_VALUE(result); +} + + +static int +acpi_button_remove (struct acpi_device *device, int type) +{ + ACPI_STATUS status = 0; + struct acpi_button *button = NULL; + + ACPI_FUNCTION_TRACE("acpi_button_remove"); + + if (!device || !acpi_driver_data(device)) + return_VALUE(-1); + + button = acpi_driver_data(device); + + /* Unregister for device notifications. */ + switch (button->type) { + case ACPI_BUTTON_TYPE_POWERF: + status = AcpiRemoveFixedEventHandler( + ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed); + break; + case ACPI_BUTTON_TYPE_SLEEPF: + status = AcpiRemoveFixedEventHandler( + ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed); + break; + case ACPI_BUTTON_TYPE_LID: + status = AcpiRemoveFixedEventHandler( + ACPI_BUTTON_TYPE_LID, acpi_button_notify_fixed); + break; + default: + status = AcpiRemoveNotifyHandler(button->handle, + ACPI_DEVICE_NOTIFY, acpi_button_notify); + break; + } + + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); + + ExFreePool(button); + + return_VALUE(0); +} + + +int +acpi_button_init (void) +{ + int result = 0; + + ACPI_FUNCTION_TRACE("acpi_button_init"); + + result = acpi_bus_register_driver(&acpi_button_driver); + if (result < 0) { + return_VALUE(-15); + } + + return_VALUE(0); +} + + +void +acpi_button_exit (void) +{ + ACPI_FUNCTION_TRACE("acpi_button_exit"); + + acpi_bus_unregister_driver(&acpi_button_driver); + + return_VOID; +} + + diff --git a/drivers/bus/acpi/busmgr/power.c b/drivers/bus/acpi/busmgr/power.c new file mode 100644 index 00000000000..6c6bc0814bf --- /dev/null +++ b/drivers/bus/acpi/busmgr/power.c @@ -0,0 +1,679 @@ +/* + * acpi_power.c - ACPI Bus Power Management ($Revision: 39 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +/* + * ACPI power-managed devices may be controlled in two ways: + * 1. via "Device Specific (D-State) Control" + * 2. via "Power Resource Control". + * This module is used to manage devices relying on Power Resource Control. + * + * An ACPI "power resource object" describes a software controllable power + * plane, clock plane, or other resource used by a power managed device. + * A device may rely on multiple power resources, and a power resource + * may be shared by multiple devices. + */ + +/* + * Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ + +#include +#include +#include +#include +#include + +//#define NDEBUG +#include + + +#define _COMPONENT ACPI_POWER_COMPONENT +ACPI_MODULE_NAME ("acpi_power") + +#define ACPI_POWER_RESOURCE_STATE_OFF 0x00 +#define ACPI_POWER_RESOURCE_STATE_ON 0x01 +#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF + +int acpi_power_nocheck; + +static int acpi_power_add (struct acpi_device *device); +static int acpi_power_remove (struct acpi_device *device, int type); +static int acpi_power_resume(struct acpi_device *device); + +static struct acpi_driver acpi_power_driver = { + .name = ACPI_POWER_DRIVER_NAME, + .class = ACPI_POWER_CLASS, + .ids = ACPI_POWER_HID, + .ops = { + .add = acpi_power_add, + .remove = acpi_power_remove, + .resume = acpi_power_resume, + }, +}; + +struct acpi_power_reference { + struct list_head node; + struct acpi_device *device; +}; + +struct acpi_power_resource +{ + struct acpi_device * device; + acpi_bus_id name; + UINT32 system_level; + UINT32 order; + //struct mutex resource_lock; + struct list_head reference; +}; + +static struct list_head acpi_power_resource_list; + + +/* -------------------------------------------------------------------------- + Power Resource Management + -------------------------------------------------------------------------- */ + +static int +acpi_power_get_context ( + ACPI_HANDLE handle, + struct acpi_power_resource **resource) +{ + int result = 0; + struct acpi_device *device = NULL; + + if (!resource) + return_VALUE(-15); + + result = acpi_bus_get_device(handle, &device); + if (result) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", + handle)); + return_VALUE(result); + } + + *resource = (struct acpi_power_resource *) acpi_driver_data(device); + if (!*resource) + return_VALUE(-15); + + return 0; +} + + +static int +acpi_power_get_state ( + ACPI_HANDLE handle, + int *state) +{ + ACPI_STATUS status = AE_OK; + unsigned long sta = 0; + char node_name[5]; + ACPI_BUFFER buffer = { sizeof(node_name), node_name }; + + + if (!handle || !state) + return_VALUE(-1); + + status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); + if (ACPI_FAILURE(status)) + return_VALUE(-15); + + *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON: + ACPI_POWER_RESOURCE_STATE_OFF; + + AcpiGetName(handle, ACPI_SINGLE_NAME, &buffer); + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", + node_name, *state?"on":"off")); + + return 0; +} + + +static int +acpi_power_get_list_state ( + struct acpi_handle_list *list, + int *state) +{ + int result = 0, state1; + UINT32 i = 0; + + if (!list || !state) + return_VALUE(-1); + + /* The state of the list is 'on' IFF all resources are 'on'. */ + + for (i=0; icount; i++) { + /* + * The state of the power resource can be obtained by + * using the ACPI handle. In such case it is unnecessary to + * get the Power resource first and then get its state again. + */ + result = acpi_power_get_state(list->handles[i], &state1); + if (result) + return result; + + *state = state1; + + if (*state != ACPI_POWER_RESOURCE_STATE_ON) + break; + } + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", + *state?"on":"off")); + + return result; +} + + +static int +acpi_power_on ( + ACPI_HANDLE handle, struct acpi_device *dev) +{ + int result = 0; + int found = 0; + ACPI_STATUS status = AE_OK; + struct acpi_power_resource *resource = NULL; + struct list_head *node, *next; + struct acpi_power_reference *ref; + + result = acpi_power_get_context(handle, &resource); + if (result) + return result; + + //mutex_lock(&resource->resource_lock); + list_for_each_safe(node, next, &resource->reference) { + ref = container_of(node, struct acpi_power_reference, node); + if (dev->handle == ref->device->handle) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] already referenced by resource [%s]\n", + dev->pnp.bus_id, resource->name)); + found = 1; + break; + } + } + + if (!found) { + ref = ExAllocatePool(NonPagedPool,sizeof (struct acpi_power_reference)); + if (!ref) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "kmalloc() failed\n")); + //mutex_unlock(&resource->resource_lock); + return -1;//-ENOMEM; + } + list_add_tail(&ref->node, &resource->reference); + ref->device = dev; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] added to resource [%s] references\n", + dev->pnp.bus_id, resource->name)); + } + //mutex_unlock(&resource->resource_lock); + + status = AcpiEvaluateObject(resource->device->handle, "_ON", NULL, NULL); + if (ACPI_FAILURE(status)) + return_VALUE(-15); + + /* Update the power resource's _device_ power state */ + resource->device->power.state = ACPI_STATE_D0; + + return 0; +} + + +static int +acpi_power_off_device ( + ACPI_HANDLE handle, + struct acpi_device *dev) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_power_resource *resource = NULL; + struct list_head *node, *next; + struct acpi_power_reference *ref; + + result = acpi_power_get_context(handle, &resource); + if (result) + return result; + + //mutex_lock(&resource->resource_lock); + list_for_each_safe(node, next, &resource->reference) { + ref = container_of(node, struct acpi_power_reference, node); + if (dev->handle == ref->device->handle) { + list_del(&ref->node); + ExFreePool(ref); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] removed from resource [%s] references\n", + dev->pnp.bus_id, resource->name)); + break; + } + } + + if (!list_empty(&resource->reference)) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cannot turn resource [%s] off - resource is in use\n", + resource->name)); + //mutex_unlock(&resource->resource_lock); + return 0; + } + //mutex_unlock(&resource->resource_lock); + + status = AcpiEvaluateObject(resource->device->handle, "_OFF", NULL, NULL); + if (ACPI_FAILURE(status)) + return -1; + + /* Update the power resource's _device_ power state */ + resource->device->power.state = ACPI_STATE_D3; + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", + resource->name)); + + return 0; +} + +/** + * acpi_device_sleep_wake - execute _DSW (Device Sleep Wake) or (deprecated in + * ACPI 3.0) _PSW (Power State Wake) + * @dev: Device to handle. + * @enable: 0 - disable, 1 - enable the wake capabilities of the device. + * @sleep_state: Target sleep state of the system. + * @dev_state: Target power state of the device. + * + * Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power + * State Wake) for the device, if present. On failure reset the device's + * wakeup.flags.valid flag. + * + * RETURN VALUE: + * 0 if either _DSW or _PSW has been successfully executed + * 0 if neither _DSW nor _PSW has been found + * -ENODEV if the execution of either _DSW or _PSW has failed + */ +int acpi_device_sleep_wake(struct acpi_device *dev, + int enable, int sleep_state, int dev_state) +{ + union acpi_object in_arg[3]; + struct acpi_object_list arg_list = { 3, in_arg }; + ACPI_STATUS status = AE_OK; + + /* + * Try to execute _DSW first. + * + * Three agruments are needed for the _DSW object: + * Argument 0: enable/disable the wake capabilities + * Argument 1: target system state + * Argument 2: target device state + * When _DSW object is called to disable the wake capabilities, maybe + * the first argument is filled. The values of the other two agruments + * are meaningless. + */ + in_arg[0].Type = ACPI_TYPE_INTEGER; + in_arg[0].Integer.Value = enable; + in_arg[1].Type = ACPI_TYPE_INTEGER; + in_arg[1].Integer.Value = sleep_state; + in_arg[2].Type = ACPI_TYPE_INTEGER; + in_arg[2].Integer.Value = dev_state; + status = AcpiEvaluateObject(dev->handle, "_DSW", &arg_list, NULL); + if (ACPI_SUCCESS(status)) { + return 0; + } else if (status != AE_NOT_FOUND) { + DPRINT1("_DSW execution failed\n"); + dev->wakeup.flags.valid = 0; + return -1; + } + + /* Execute _PSW */ + arg_list.Count = 1; + in_arg[0].Integer.Value = enable; + status = AcpiEvaluateObject(dev->handle, "_PSW", &arg_list, NULL); + if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { + DPRINT1("_PSW execution failed\n"); + dev->wakeup.flags.valid = 0; + return -1; + } + + return 0; +} + +/* + * Prepare a wakeup device, two steps (Ref ACPI 2.0:P229): + * 1. Power on the power resources required for the wakeup device + * 2. Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power + * State Wake) for the device, if present + */ +int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) +{ + int i, err = 0; + + if (!dev || !dev->wakeup.flags.valid) + return -1; + + //mutex_lock(&acpi_device_lock); + + if (dev->wakeup.prepare_count++) + goto out; + + /* Open power resource */ + for (i = 0; i < dev->wakeup.resources.count; i++) { + int ret = acpi_power_on(dev->wakeup.resources.handles[i], dev); + if (ret) { + DPRINT( "Transition power state\n"); + dev->wakeup.flags.valid = 0; + err = -1; + goto err_out; + } + } + + /* + * Passing 3 as the third argument below means the device may be placed + * in arbitrary power state afterwards. + */ + err = acpi_device_sleep_wake(dev, 1, sleep_state, 3); + + err_out: + if (err) + dev->wakeup.prepare_count = 0; + + out: + //mutex_unlock(&acpi_device_lock); + return err; +} + +/* + * Shutdown a wakeup device, counterpart of above method + * 1. Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power + * State Wake) for the device, if present + * 2. Shutdown down the power resources + */ +int acpi_disable_wakeup_device_power(struct acpi_device *dev) +{ + int i, err = 0; + + if (!dev || !dev->wakeup.flags.valid) + return -1; + + //mutex_lock(&acpi_device_lock); + + if (--dev->wakeup.prepare_count > 0) + goto out; + + /* + * Executing the code below even if prepare_count is already zero when + * the function is called may be useful, for example for initialisation. + */ + if (dev->wakeup.prepare_count < 0) + dev->wakeup.prepare_count = 0; + + err = acpi_device_sleep_wake(dev, 0, 0, 0); + if (err) + goto out; + + /* Close power resource */ + for (i = 0; i < dev->wakeup.resources.count; i++) { + int ret = acpi_power_off_device( + dev->wakeup.resources.handles[i], dev); + if (ret) { + DPRINT("Transition power state\n"); + dev->wakeup.flags.valid = 0; + err = -1; + goto out; + } + } + + out: + //mutex_unlock(&acpi_device_lock); + return err; +} + +/* -------------------------------------------------------------------------- + Device Power Management + -------------------------------------------------------------------------- */ + +int +acpi_power_get_inferred_state ( + struct acpi_device *device) +{ + int result = 0; + struct acpi_handle_list *list = NULL; + int list_state = 0; + int i = 0; + + + if (!device) + return_VALUE(-1); + + device->power.state = ACPI_STATE_UNKNOWN; + + /* + * We know a device's inferred power state when all the resources + * required for a given D-state are 'on'. + */ + for (i=ACPI_STATE_D0; ipower.states[i].resources; + if (list->count < 1) + continue; + + result = acpi_power_get_list_state(list, &list_state); + if (result) + return_VALUE(result); + + if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { + device->power.state = i; + return_VALUE(0); + } + } + + device->power.state = ACPI_STATE_D3; + + return_VALUE(0); +} + + +int +acpi_power_transition ( + struct acpi_device *device, + int state) +{ + int result = 0; + struct acpi_handle_list *cl = NULL; /* Current Resources */ + struct acpi_handle_list *tl = NULL; /* Target Resources */ + int i = 0; + + if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) + return_VALUE(-1); + + if ((device->power.state < ACPI_STATE_D0) || (device->power.state > ACPI_STATE_D3)) + return_VALUE(-15); + + cl = &device->power.states[device->power.state].resources; + tl = &device->power.states[state].resources; + + /* TBD: Resources must be ordered. */ + + /* + * First we reference all power resources required in the target list + * (e.g. so the device doesn't lose power while transitioning). + */ + for (i = 0; i < tl->count; i++) { + result = acpi_power_on(tl->handles[i], device); + if (result) + goto end; + } + + if (device->power.state == state) { + goto end; + } + + /* + * Then we dereference all power resources used in the current list. + */ + for (i = 0; i < cl->count; i++) { + result = acpi_power_off_device(cl->handles[i], device); + if (result) + goto end; + } + + end: + if (result) + device->power.state = ACPI_STATE_UNKNOWN; + else { + /* We shouldn't change the state till all above operations succeed */ + device->power.state = state; + } + + return result; +} + +/* -------------------------------------------------------------------------- + Driver Interface + -------------------------------------------------------------------------- */ + +int +acpi_power_add ( + struct acpi_device *device) +{ + int result = 0, state; + ACPI_STATUS status = AE_OK; + struct acpi_power_resource *resource = NULL; + union acpi_object acpi_object; + ACPI_BUFFER buffer = {sizeof(ACPI_OBJECT), &acpi_object}; + + + if (!device) + return_VALUE(-1); + + resource = ExAllocatePool(NonPagedPool,sizeof(struct acpi_power_resource)); + if (!resource) + return_VALUE(-4); + + resource->device = device; + //mutex_init(&resource->resource_lock); + INIT_LIST_HEAD(&resource->reference); + + strcpy(resource->name, device->pnp.bus_id); + strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); + strcpy(acpi_device_class(device), ACPI_POWER_CLASS); + device->driver_data = resource; + + /* Evalute the object to get the system level and resource order. */ + status = AcpiEvaluateObject(device->handle, NULL, NULL, &buffer); + if (ACPI_FAILURE(status)) { + result = -15; + goto end; + } + resource->system_level = acpi_object.PowerResource.SystemLevel; + resource->order = acpi_object.PowerResource.ResourceOrder; + + result = acpi_power_get_state(device->handle, &state); + if (result) + goto end; + + switch (state) { + case ACPI_POWER_RESOURCE_STATE_ON: + device->power.state = ACPI_STATE_D0; + break; + case ACPI_POWER_RESOURCE_STATE_OFF: + device->power.state = ACPI_STATE_D3; + break; + default: + device->power.state = ACPI_STATE_UNKNOWN; + break; + } + + + DPRINT("%s [%s] (%s)\n", acpi_device_name(device), + acpi_device_bid(device), state?"on":"off"); + +end: + if (result) + ExFreePool(resource); + + return result; +} + + +int +acpi_power_remove ( + struct acpi_device *device, + int type) +{ + struct acpi_power_resource *resource = NULL; + struct list_head *node, *next; + + if (!device || !acpi_driver_data(device)) + return_VALUE(-1); + + resource = acpi_driver_data(device); + + //mutex_lock(&resource->resource_lock); + list_for_each_safe(node, next, &resource->reference) { + struct acpi_power_reference *ref = container_of(node, struct acpi_power_reference, node); + list_del(&ref->node); + ExFreePool(ref); + } + //mutex_unlock(&resource->resource_lock); + ExFreePool(resource); + + return_VALUE(0); +} + +static int acpi_power_resume(struct acpi_device *device) +{ + int result = 0, state; + struct acpi_power_resource *resource = NULL; + struct acpi_power_reference *ref; + + if (!device || !acpi_driver_data(device)) + return -1; + + resource = acpi_driver_data(device); + + result = acpi_power_get_state(device->handle, &state); + if (result) + return result; + + //mutex_lock(&resource->resource_lock); + if (state == ACPI_POWER_RESOURCE_STATE_OFF && + !list_empty(&resource->reference)) { + ref = container_of(resource->reference.next, struct acpi_power_reference, node); + //mutex_unlock(&resource->resource_lock); + result = acpi_power_on(device->handle, ref->device); + return result; + } + + //mutex_unlock(&resource->resource_lock); + return 0; +} + +int +acpi_power_init (void) +{ + int result = 0; + + DPRINT("acpi_power_init"); + + INIT_LIST_HEAD(&acpi_power_resource_list); + + + result = acpi_bus_register_driver(&acpi_power_driver); + if (result < 0) { + return_VALUE(-15); + } + + return_VALUE(0); +} diff --git a/drivers/bus/acpi/busmgr/system.c b/drivers/bus/acpi/busmgr/system.c new file mode 100644 index 00000000000..d0f0503f366 --- /dev/null +++ b/drivers/bus/acpi/busmgr/system.c @@ -0,0 +1,427 @@ +/* + * acpi_system.c - ACPI System Driver ($Revision: 57 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +/* Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ +#include +#include +#include +#include +#include "list.h" + +//#define NDEBUG +#include + +ACPI_STATUS acpi_system_save_state(UINT32); + +#define _COMPONENT ACPI_SYSTEM_COMPONENT +ACPI_MODULE_NAME ("acpi_system") + +#define PREFIX "ACPI: " + +static int acpi_system_add (struct acpi_device *device); +static int acpi_system_remove (struct acpi_device *device, int type); + +ACPI_STATUS acpi_suspend (UINT32 state); + +static struct acpi_driver acpi_system_driver = { + .name = ACPI_SYSTEM_DRIVER_NAME, + .class = ACPI_SYSTEM_CLASS, + .ids = ACPI_SYSTEM_HID, + .ops = { + .add = acpi_system_add, + .remove = acpi_system_remove + }, +}; + +struct acpi_system +{ + ACPI_HANDLE handle; + UINT8 states[ACPI_S_STATE_COUNT]; +}; + + +static int +acpi_system_add ( + struct acpi_device *device) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_system *system = NULL; + UINT8 i = 0; + + ACPI_FUNCTION_TRACE("acpi_system_add"); + + if (!device) + return_VALUE(-1); + + system = ExAllocatePool(NonPagedPool,sizeof(struct acpi_system)); + if (!system) + return_VALUE(-14); + memset(system, 0, sizeof(struct acpi_system)); + + system->handle = device->handle; + sprintf(acpi_device_name(device), "%s", ACPI_SYSTEM_DEVICE_NAME); + sprintf(acpi_device_class(device), "%s", ACPI_SYSTEM_CLASS); + acpi_driver_data(device) = system; + + DPRINT("%s [%s] (supports", + acpi_device_name(device), acpi_device_bid(device)); + for (i=0; iS4bios_f &&*/ + 0 != AcpiGbl_FADT.SmiCommand) { + DPRINT(" S4bios"); + system->states[i] = 1; + } + /* no break */ + default: + if (ACPI_SUCCESS(status)) { + system->states[i] = 1; + DPRINT(" S%d", i); + } + } + } + +//#ifdef CONFIG_PM +// /* Install the soft-off (S5) handler. */ +// if (system->states[ACPI_STATE_S5]) { +// pm_power_off = acpi_power_off; +// register_sysrq_key('o', &sysrq_acpi_poweroff_op); +// } +//#endif + + if (result) + ExFreePool(system); + + return_VALUE(result); +} + +static int +acpi_system_remove ( + struct acpi_device *device, + int type) +{ + struct acpi_system *system = NULL; + + ACPI_FUNCTION_TRACE("acpi_system_remove"); + + if (!device || !acpi_driver_data(device)) + return_VALUE(-1); + + system = (struct acpi_system *) acpi_driver_data(device); + +//#ifdef CONFIG_PM +// /* Remove the soft-off (S5) handler. */ +// if (system->states[ACPI_STATE_S5]) { +// unregister_sysrq_key('o', &sysrq_acpi_poweroff_op); +// pm_power_off = NULL; +// } +//#endif +// +// + ExFreePool(system); + + return 0; +} + +/** + * acpi_system_restore_state - OS-specific restoration of state + * @state: sleep state we're exiting + * + * Note that if we're coming back from S4, the memory image should have + * already been loaded from the disk and is already in place. (Otherwise how + * else would we be here?). + */ +ACPI_STATUS +acpi_system_restore_state( + UINT32 state) +{ + /* + * We should only be here if we're coming back from STR or STD. + * And, in the case of the latter, the memory image should have already + * been loaded from disk. + */ + if (state > ACPI_STATE_S1) { + //acpi_restore_state_mem(); + + /* Do _early_ resume for irqs. Required by + * ACPI specs. + */ + /* TBD: call arch dependant reinitialization of the + * interrupts. + */ +#ifdef _X86_ + //init_8259A(0); +#endif + /* wait for power to come back */ + KeStallExecutionProcessor(100); + + } + + /* Be really sure that irqs are disabled. */ + //ACPI_DISABLE_IRQS(); + + /* Wait a little again, just in case... */ + KeStallExecutionProcessor(10); + + /* enable interrupts once again */ + //ACPI_ENABLE_IRQS(); + + /* turn all the devices back on */ + //if (state > ACPI_STATE_S1) + //pm_send_all(PM_RESUME, (void *)0); + + return AE_OK; +} + + +/** + * acpi_system_save_state - save OS specific state and power down devices + * @state: sleep state we're entering. + * + * This handles saving all context to memory, and possibly disk. + * First, we call to the device driver layer to save device state. + * Once we have that, we save whatevery processor and kernel state we + * need to memory. + * If we're entering S4, we then write the memory image to disk. + * + * Only then it is safe for us to power down devices, since we may need + * the disks and upstream buses to write to. + */ +ACPI_STATUS +acpi_system_save_state( + UINT32 state) +{ + int error = 0; + + /* Send notification to devices that they will be suspended. + * If any device or driver cannot make the transition, either up + * or down, we'll get an error back. + */ + /*if (state > ACPI_STATE_S1) { + error = pm_send_all(PM_SAVE_STATE, (void *)3); + if (error) + return AE_ERROR; + }*/ + + //if (state <= ACPI_STATE_S5) { + // /* Tell devices to stop I/O and actually save their state. + // * It is theoretically possible that something could fail, + // * so handle that gracefully.. + // */ + // if (state > ACPI_STATE_S1 && state != ACPI_STATE_S5) { + // error = pm_send_all(PM_SUSPEND, (void *)3); + // if (error) { + // /* Tell devices to restore state if they have + // * it saved and to start taking I/O requests. + // */ + // pm_send_all(PM_RESUME, (void *)0); + // return error; + // } + // } + + /* flush caches */ + ACPI_FLUSH_CPU_CACHE(); + + /* Do arch specific saving of state. */ + if (state > ACPI_STATE_S1) { + error = 0;//acpi_save_state_mem(); + + /* TBD: if no s4bios, write codes for + * acpi_save_state_disk()... + */ +#if 0 + if (!error && (state == ACPI_STATE_S4)) + error = acpi_save_state_disk(); +#endif + /*if (error) { + pm_send_all(PM_RESUME, (void *)0); + return error; + }*/ + } + //} + /* disable interrupts + * Note that acpi_suspend -- our caller -- will do this once we return. + * But, we want it done early, so we don't get any suprises during + * the device suspend sequence. + */ + //ACPI_DISABLE_IRQS(); + + /* Unconditionally turn off devices. + * Obvious if we enter a sleep state. + * If entering S5 (soft off), this should put devices in a + * quiescent state. + */ + + //if (state > ACPI_STATE_S1) { + // error = pm_send_all(PM_SUSPEND, (void *)3); + + // /* We're pretty screwed if we got an error from this. + // * We try to recover by simply calling our own restore_state + // * function; see above for definition. + // * + // * If it's S5 though, go through with it anyway.. + // */ + // if (error && state != ACPI_STATE_S5) + // acpi_system_restore_state(state); + //} + return error ? AE_ERROR : AE_OK; +} + + +/**************************************************************************** + * + * FUNCTION: acpi_system_suspend + * + * PARAMETERS: %state: Sleep state to enter. + * + * RETURN: ACPI_STATUS, whether or not we successfully entered and + * exited sleep. + * + * DESCRIPTION: Perform OS-specific action to enter sleep state. + * This is the final step in going to sleep, per spec. If we + * know we're coming back (i.e. not entering S5), we save the + * processor flags. [ We'll have to save and restore them anyway, + * so we use the arch-agnostic save_flags and restore_flags + * here.] We then set the place to return to in arch-specific + * globals using arch_set_return_point. Finally, we call the + * ACPI function to write the proper values to I/O ports. + * + ****************************************************************************/ + +ACPI_STATUS +acpi_system_suspend( + UINT32 state) +{ + ACPI_STATUS status = AE_ERROR; + //unsigned long flags = 0; + + //local_irq_save(flags); + /* kernel_fpu_begin(); */ + + switch (state) { + case ACPI_STATE_S1: + case ACPI_STATE_S5: + //barrier(); + status = AcpiEnterSleepState(state); + break; + case ACPI_STATE_S4: + //do_suspend_lowlevel_s4bios(0); + break; + } + + /* kernel_fpu_end(); */ + //local_irq_restore(flags); + + return status; +} + + + +/** + * acpi_suspend - OS-agnostic system suspend/resume support (S? states) + * @state: state we're entering + * + */ +ACPI_STATUS +acpi_suspend ( + UINT32 state) +{ + ACPI_STATUS status; + + /* only support S1 and S5 on kernel 2.4 */ + //if (state != ACPI_STATE_S1 && state != ACPI_STATE_S4 + // && state != ACPI_STATE_S5) + // return AE_ERROR; + + + //if (ACPI_STATE_S4 == state) { + // /* For s4bios, we need a wakeup address. */ + // if (1 == AcpiGbl_FACS->S4bios_f && + // 0 != AcpiGbl_FADT->smi_cmd) { + // if (!acpi_wakeup_address) + // return AE_ERROR; + // AcpiSetFirmwareWakingVector((acpi_physical_address) acpi_wakeup_address); + // } else + // /* We don't support S4 under 2.4. Give up */ + // return AE_ERROR; + //} + AcpiEnterSleepStatePrep(state); + + status = AcpiEnterSleepState(state); + if (!ACPI_SUCCESS(status) && state != ACPI_STATE_S5) + return status; + + /* disable interrupts and flush caches */ + _disable(); + ACPI_FLUSH_CPU_CACHE(); + + /* perform OS-specific sleep actions */ + status = acpi_system_suspend(state); + + /* Even if we failed to go to sleep, all of the devices are in an suspended + * mode. So, we run these unconditionaly to make sure we have a usable system + * no matter what. + */ + AcpiLeaveSleepState(state); + acpi_system_restore_state(state); + + /* make sure interrupts are enabled */ + _enable(); + + /* reset firmware waking vector */ + AcpiSetFirmwareWakingVector((ACPI_PHYSICAL_ADDRESS) 0); + + return status; +} + +int +acpi_system_init (void) +{ + int result = 0; + + ACPI_FUNCTION_TRACE("acpi_system_init"); + + result = acpi_bus_register_driver(&acpi_system_driver); + if (result < 0) + return_VALUE(AE_NOT_FOUND); + + return_VALUE(0); +} + + +void +acpi_system_exit (void) +{ + ACPI_FUNCTION_TRACE("acpi_system_exit"); + acpi_bus_unregister_driver(&acpi_system_driver); + return_VOID; +} + diff --git a/drivers/bus/acpi/busmgr/utils.c b/drivers/bus/acpi/busmgr/utils.c new file mode 100644 index 00000000000..67eaed017ca --- /dev/null +++ b/drivers/bus/acpi/busmgr/utils.c @@ -0,0 +1,376 @@ +/* + * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#include + +#include +#include +#include +#include + +//#define NDEBUG +#include + + /* Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ + +#define _COMPONENT ACPI_BUS_COMPONENT +ACPI_MODULE_NAME ("acpi_utils") + +static void +acpi_util_eval_error(ACPI_HANDLE h, ACPI_STRING p, ACPI_STATUS s) +{ +#ifdef ACPI_DEBUG_OUTPUT + char prefix[80] = {'\0'}; + ACPI_BUFFER buffer = {sizeof(prefix), prefix}; + AcpiGetName(h, ACPI_FULL_PATHNAME, &buffer); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n", + (char *) prefix, p, AcpiFormatException(s))); +#else + return; +#endif +} + + +/* -------------------------------------------------------------------------- + Object Evaluation Helpers + -------------------------------------------------------------------------- */ + + +ACPI_STATUS +acpi_extract_package ( + ACPI_OBJECT *package, + ACPI_BUFFER *format, + ACPI_BUFFER *buffer) +{ + UINT32 size_required = 0; + UINT32 tail_offset = 0; + char *format_string = NULL; + UINT32 format_count = 0; + UINT32 i = 0; + UINT8 *head = NULL; + UINT8 *tail = NULL; + + if (!package || (package->Type != ACPI_TYPE_PACKAGE) || (package->Package.Count < 1)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + if (!format || !format->Pointer || (format->Length < 1)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + if (!buffer) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + format_count = (format->Length/sizeof(char)) - 1; + if (format_count > package->Package.Count) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count)); + return_ACPI_STATUS(AE_BAD_DATA); + } + + format_string = format->Pointer; + + /* + * Calculate size_required. + */ + for (i=0; iPackage.Elements[i]); + + if (!element) { + return_ACPI_STATUS(AE_BAD_DATA); + } + + switch (element->Type) { + + case ACPI_TYPE_INTEGER: + switch (format_string[i]) { + case 'N': + size_required += sizeof(ACPI_INTEGER); + tail_offset += sizeof(ACPI_INTEGER); + break; + case 'S': + size_required += sizeof(char*) + sizeof(ACPI_INTEGER) + sizeof(char); + tail_offset += sizeof(char*); + break; + default: + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecing [%c].\n", i, format_string[i])); + return_ACPI_STATUS(AE_BAD_DATA); + break; + } + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + switch (format_string[i]) { + case 'S': + size_required += sizeof(char*) + (element->String.Length * sizeof(char)) + sizeof(char); + tail_offset += sizeof(char*); + break; + case 'B': + size_required += sizeof(UINT8*) + (element->Buffer.Length * sizeof(UINT8)); + tail_offset += sizeof(UINT8*); + break; + default: + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecing [%c].\n", i, format_string[i])); + return_ACPI_STATUS(AE_BAD_DATA); + break; + } + break; + + case ACPI_TYPE_PACKAGE: + default: + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i)); + /* TBD: handle nested packages... */ + return_ACPI_STATUS(AE_SUPPORT); + break; + } + } + + /* + * Validate output buffer. + */ + if (buffer->Length < size_required) { + buffer->Length = size_required; + return_ACPI_STATUS(AE_BUFFER_OVERFLOW); + } + else if (buffer->Length != size_required || !buffer->Pointer) { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + head = buffer->Pointer; + tail = buffer->Pointer + tail_offset; + + /* + * Extract package data. + */ + for (i=0; iPackage.Elements[i]); + + if (!element) { + return_ACPI_STATUS(AE_BAD_DATA); + } + + switch (element->Type) { + + case ACPI_TYPE_INTEGER: + switch (format_string[i]) { + case 'N': + *((ACPI_INTEGER*)head) = element->Integer.Value; + head += sizeof(ACPI_INTEGER); + break; + case 'S': + pointer = (UINT8**)head; + *pointer = tail; + *((ACPI_INTEGER*)tail) = element->Integer.Value; + head += sizeof(ACPI_INTEGER*); + tail += sizeof(ACPI_INTEGER); + /* NULL terminate string */ + *tail = (char)0; + tail += sizeof(char); + break; + default: + /* Should never get here */ + break; + } + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + switch (format_string[i]) { + case 'S': + pointer = (UINT8**)head; + *pointer = tail; + memcpy(tail, element->String.Pointer, element->String.Length); + head += sizeof(char*); + tail += element->String.Length * sizeof(char); + /* NULL terminate string */ + *tail = (char)0; + tail += sizeof(char); + break; + case 'B': + pointer = (UINT8**)head; + *pointer = tail; + memcpy(tail, element->Buffer.Pointer, element->Buffer.Length); + head += sizeof(UINT8*); + tail += element->Buffer.Length * sizeof(UINT8); + break; + default: + /* Should never get here */ + break; + } + break; + + case ACPI_TYPE_PACKAGE: + /* TBD: handle nested packages... */ + default: + /* Should never get here */ + break; + } + } + + return_ACPI_STATUS(AE_OK); +} + + +ACPI_STATUS +acpi_evaluate_integer ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + ACPI_OBJECT_LIST *arguments, + unsigned long long *data) +{ + ACPI_STATUS status = AE_OK; + ACPI_OBJECT element; + ACPI_BUFFER buffer = {sizeof(ACPI_OBJECT), &element}; + + ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); + + if (!data) + return_ACPI_STATUS(AE_BAD_PARAMETER); + + status = AcpiEvaluateObject(handle, pathname, arguments, &buffer); + if (ACPI_FAILURE(status)) { + acpi_util_eval_error(handle, pathname, status); + return_ACPI_STATUS(status); + } + + if (element.Type != ACPI_TYPE_INTEGER) { + acpi_util_eval_error(handle, pathname, AE_BAD_DATA); + return_ACPI_STATUS(AE_BAD_DATA); + } + + *data = element.Integer.Value; + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); + + return_ACPI_STATUS(AE_OK); +} + + +ACPI_STATUS +acpi_evaluate_reference ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + ACPI_OBJECT_LIST *arguments, + struct acpi_handle_list *list) +{ + ACPI_STATUS status = AE_OK; + ACPI_OBJECT *package = NULL; + ACPI_OBJECT *element = NULL; + ACPI_BUFFER buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + UINT32 i = 0; + + ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); + + if (!list) { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + /* Evaluate object. */ + + status = AcpiEvaluateObject(handle, pathname, arguments, &buffer); + if (ACPI_FAILURE(status)) + goto end; + + package = (ACPI_OBJECT *) buffer.Pointer; + + if ((buffer.Length == 0) || !package) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No return object (len %X ptr %p)\n", + buffer.Length, package)); + status = AE_BAD_DATA; + acpi_util_eval_error(handle, pathname, status); + goto end; + } + if (package->Type != ACPI_TYPE_PACKAGE) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Package], found type %X\n", + package->Type)); + status = AE_BAD_DATA; + acpi_util_eval_error(handle, pathname, status); + goto end; + } + if (!package->Package.Count) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "[Package] has zero elements (%p)\n", + package)); + status = AE_BAD_DATA; + acpi_util_eval_error(handle, pathname, status); + goto end; + } + + if (package->Package.Count > ACPI_MAX_HANDLES) { + return AE_NO_MEMORY; + } + list->count = package->Package.Count; + + /* Extract package data. */ + + for (i = 0; i < list->count; i++) { + + element = &(package->Package.Elements[i]); + + if (element->Type != ACPI_TYPE_LOCAL_REFERENCE) { + status = AE_BAD_DATA; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Reference] package element, found type %X\n", + element->type)); + acpi_util_eval_error(handle, pathname, status); + break; + } + + if (!element->Reference.Handle) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid reference in" + " package %s\n", pathname)); + status = AE_NULL_ENTRY; + break; + } + /* Get the ACPI_HANDLE. */ + + list->handles[i] = element->Reference.Handle; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n", + list->handles[i])); + } + +end: + if (ACPI_FAILURE(status)) { + list->count = 0; + //ExFreePool(list->handles); + } + + AcpiOsFree(buffer.Pointer); + + return_ACPI_STATUS(status); +} + + diff --git a/drivers/bus/acpi/buspdo.c b/drivers/bus/acpi/buspdo.c new file mode 100644 index 00000000000..92bc18b4544 --- /dev/null +++ b/drivers/bus/acpi/buspdo.c @@ -0,0 +1,1234 @@ +#include + +#include +#include +#include +#include + +#include +#include + +//#define NDEBUG +#include + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (PAGE, Bus_PDO_PnP) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceCaps) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceId) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceText) +#pragma alloc_text (PAGE, Bus_PDO_QueryResources) +#pragma alloc_text (PAGE, Bus_PDO_QueryResourceRequirements) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceRelations) +#pragma alloc_text (PAGE, Bus_PDO_QueryBusInformation) +#pragma alloc_text (PAGE, Bus_GetDeviceCapabilities) +#endif + +NTSTATUS +Bus_PDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PPDO_DEVICE_DATA DeviceData + ) +{ + NTSTATUS status; + POWER_STATE state; + + PAGED_CODE (); + + // + // NB: Because we are a bus enumerator, we have no one to whom we could + // defer these irps. Therefore we do not pass them down but merely + // return them. + // + + switch (IrpStack->MinorFunction) { + + case IRP_MN_START_DEVICE: + + // + // Here we do what ever initialization and ``turning on'' that is + // required to allow others to access this device. + // Power up the device. + // + if (DeviceData->AcpiHandle && acpi_bus_power_manageable(DeviceData->AcpiHandle) && + !ACPI_SUCCESS(acpi_bus_set_power(DeviceData->AcpiHandle, ACPI_STATE_D0))) + { + DPRINT1("Device %x failed to start!\n", DeviceData->AcpiHandle); + status = STATUS_UNSUCCESSFUL; + break; + } + + state.DeviceState = PowerDeviceD0; + PoSetPowerState(DeviceData->Common.Self, DevicePowerState, state); + DeviceData->Common.DevicePowerState = PowerDeviceD0; + SET_NEW_PNP_STATE(DeviceData->Common, Started); + status = STATUS_SUCCESS; + break; + + case IRP_MN_STOP_DEVICE: + + // + // Here we shut down the device and give up and unmap any resources + // we acquired for the device. + // + if (DeviceData->AcpiHandle && acpi_bus_power_manageable(DeviceData->AcpiHandle) && + !ACPI_SUCCESS(acpi_bus_set_power(DeviceData->AcpiHandle, ACPI_STATE_D3))) + { + DPRINT1("Device %x failed to stop!\n", DeviceData->AcpiHandle); + status = STATUS_UNSUCCESSFUL; + break; + } + + state.DeviceState = PowerDeviceD3; + PoSetPowerState(DeviceData->Common.Self, DevicePowerState, state); + DeviceData->Common.DevicePowerState = PowerDeviceD3; + SET_NEW_PNP_STATE(DeviceData->Common, Stopped); + status = STATUS_SUCCESS; + break; + + + case IRP_MN_QUERY_STOP_DEVICE: + + // + // No reason here why we can't stop the device. + // If there were a reason we should speak now, because answering success + // here may result in a stop device irp. + // + + SET_NEW_PNP_STATE(DeviceData->Common, StopPending); + status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: + + // + // The stop was canceled. Whatever state we set, or resources we put + // on hold in anticipation of the forthcoming STOP device IRP should be + // put back to normal. Someone, in the long list of concerned parties, + // has failed the stop device query. + // + + // + // First check to see whether you have received cancel-stop + // without first receiving a query-stop. This could happen if someone + // above us fails a query-stop and passes down the subsequent + // cancel-stop. + // + + if (StopPending == DeviceData->Common.DevicePnPState) + { + // + // We did receive a query-stop, so restore. + // + RESTORE_PREVIOUS_PNP_STATE(DeviceData->Common); + } + status = STATUS_SUCCESS;// We must not fail this IRP. + break; + case IRP_MN_QUERY_CAPABILITIES: + + // + // Return the capabilities of a device, such as whether the device + // can be locked or ejected..etc + // + + status = Bus_PDO_QueryDeviceCaps(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_ID: + + // Query the IDs of the device + status = Bus_PDO_QueryDeviceId(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_DEVICE_RELATIONS: + + DPRINT("\tQueryDeviceRelation Type: %s\n",DbgDeviceRelationString(\ + IrpStack->Parameters.QueryDeviceRelations.Type)); + + status = Bus_PDO_QueryDeviceRelations(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_DEVICE_TEXT: + + status = Bus_PDO_QueryDeviceText(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_RESOURCES: + + status = Bus_PDO_QueryResources(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: + + status = Bus_PDO_QueryResourceRequirements(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_BUS_INFORMATION: + + status = Bus_PDO_QueryBusInformation(DeviceData, Irp); + + break; + + + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: + + // + // OPTIONAL for bus drivers. + // The PnP Manager sends this IRP to a device + // stack so filter and function drivers can adjust the + // resources required by the device, if appropriate. + // + + //break; + + //case IRP_MN_QUERY_PNP_DEVICE_STATE: + + // + // OPTIONAL for bus drivers. + // The PnP Manager sends this IRP after the drivers for + // a device return success from the IRP_MN_START_DEVICE + // request. The PnP Manager also sends this IRP when a + // driver for the device calls IoInvalidateDeviceState. + // + + // break; + + //case IRP_MN_READ_CONFIG: + //case IRP_MN_WRITE_CONFIG: + + // + // Bus drivers for buses with configuration space must handle + // this request for their child devices. Our devices don't + // have a config space. + // + + // break; + + //case IRP_MN_SET_LOCK: + + // break; + + default: + + // + // For PnP requests to the PDO that we do not understand we should + // return the IRP WITHOUT setting the status or information fields. + // These fields may have already been set by a filter (eg acpi). + status = Irp->IoStatus.Status; + + break; + } + + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + return status; +} + +NTSTATUS +Bus_PDO_QueryDeviceCaps( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + + PIO_STACK_LOCATION stack; + PDEVICE_CAPABILITIES deviceCapabilities; + struct acpi_device *device = NULL; + ULONG i; + + PAGED_CODE (); + + if (DeviceData->AcpiHandle) + acpi_bus_get_device(DeviceData->AcpiHandle, &device); + + stack = IoGetCurrentIrpStackLocation (Irp); + + // + // Get the packet. + // + deviceCapabilities=stack->Parameters.DeviceCapabilities.Capabilities; + + // + // Set the capabilities. + // + + if (deviceCapabilities->Version != 1 || + deviceCapabilities->Size < sizeof(DEVICE_CAPABILITIES)) + { + return STATUS_UNSUCCESSFUL; + } + + deviceCapabilities->D1Latency = 0; + deviceCapabilities->D2Latency = 0; + deviceCapabilities->D3Latency = 0; + + deviceCapabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0; + deviceCapabilities->DeviceState[PowerSystemSleeping1] = PowerDeviceD3; + deviceCapabilities->DeviceState[PowerSystemSleeping2] = PowerDeviceD3; + deviceCapabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3; + + for (i = 0; i < ACPI_D_STATE_COUNT && device; i++) + { + if (!device->power.states[i].flags.valid) + continue; + + switch (i) + { + case ACPI_STATE_D0: + deviceCapabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0; + break; + + case ACPI_STATE_D1: + deviceCapabilities->DeviceState[PowerSystemSleeping1] = PowerDeviceD1; + deviceCapabilities->D1Latency = device->power.states[i].latency; + break; + + case ACPI_STATE_D2: + deviceCapabilities->DeviceState[PowerSystemSleeping2] = PowerDeviceD2; + deviceCapabilities->D2Latency = device->power.states[i].latency; + break; + + case ACPI_STATE_D3: + deviceCapabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3; + deviceCapabilities->D3Latency = device->power.states[i].latency; + break; + } + } + + // We can wake the system from D1 + deviceCapabilities->DeviceWake = PowerDeviceD1; + + + deviceCapabilities->DeviceD1 = + (deviceCapabilities->DeviceState[PowerSystemSleeping1] == PowerDeviceD1) ? TRUE : FALSE; + deviceCapabilities->DeviceD2 = + (deviceCapabilities->DeviceState[PowerSystemSleeping2] == PowerDeviceD2) ? TRUE : FALSE; + + deviceCapabilities->WakeFromD0 = FALSE; + deviceCapabilities->WakeFromD1 = TRUE; //Yes we can + deviceCapabilities->WakeFromD2 = FALSE; + deviceCapabilities->WakeFromD3 = FALSE; + + if (device) + { + deviceCapabilities->EjectSupported = device->flags.ejectable; + deviceCapabilities->HardwareDisabled = !device->status.enabled; + deviceCapabilities->Removable = device->flags.removable; + deviceCapabilities->SurpriseRemovalOK = device->flags.suprise_removal_ok; + deviceCapabilities->UniqueID = device->flags.unique_id; + deviceCapabilities->NoDisplayInUI = !device->status.show_in_ui; + deviceCapabilities->Address = device->pnp.bus_address; + } + else + { + deviceCapabilities->EjectSupported = FALSE; + deviceCapabilities->HardwareDisabled = FALSE; + deviceCapabilities->Removable = FALSE; + deviceCapabilities->SurpriseRemovalOK = FALSE; + deviceCapabilities->UniqueID = FALSE; + deviceCapabilities->NoDisplayInUI = FALSE; + deviceCapabilities->Address = 0; + } + + deviceCapabilities->SilentInstall = FALSE; + deviceCapabilities->UINumber = (ULONG)-1; + + return STATUS_SUCCESS; + +} + +NTSTATUS +Bus_PDO_QueryDeviceId( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + PIO_STACK_LOCATION stack; + PWCHAR buffer; + WCHAR temp[256]; + ULONG length; + NTSTATUS status = STATUS_SUCCESS; + struct acpi_device *Device; + + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + switch (stack->Parameters.QueryId.IdType) { + + case BusQueryDeviceID: + if (DeviceData->AcpiHandle) + { + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + + length = swprintf(temp, + L"ACPI\\%hs", + Device->pnp.hardware_id); + } + else + { + /* We know it's a fixed feature button because + * these are direct children of the ACPI root device + * and therefore have no handle + */ + length = swprintf(temp, + L"ACPI\\FixedButton"); + } + + temp[++length] = UNICODE_NULL; + + buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof(WCHAR), 'IPCA'); + + if (!buffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + RtlCopyMemory (buffer, temp, length * sizeof(WCHAR)); + Irp->IoStatus.Information = (ULONG_PTR) buffer; + DPRINT("BusQueryDeviceID: %ls\n",buffer); + break; + + case BusQueryInstanceID: + /* See comment in BusQueryDeviceID case */ + if(DeviceData->AcpiHandle) + { + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + + if (Device->flags.unique_id) + length = swprintf(temp, + L"%hs", + Device->pnp.unique_id); + else + /* FIXME: Generate unique id! */ + length = swprintf(temp, L"%ls", L"0000"); + } + else + /* FIXME: Generate unique id! */ + length = swprintf(temp, L"%ls", L"0000"); + + temp[++length] = UNICODE_NULL; + + buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof (WCHAR), 'IPCA'); + if (!buffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + RtlCopyMemory (buffer, temp, length * sizeof (WCHAR)); + DPRINT("BusQueryInstanceID: %ls\n",buffer); + Irp->IoStatus.Information = (ULONG_PTR) buffer; + break; + + case BusQueryHardwareIDs: + length = 0; + + /* See comment in BusQueryDeviceID case */ + if (DeviceData->AcpiHandle) + { + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + + length += swprintf(&temp[length], + L"ACPI\\%hs", + Device->pnp.hardware_id); + length++; + + length += swprintf(&temp[length], + L"*%hs", + Device->pnp.hardware_id); + length++; + } + else + { + length += swprintf(&temp[length], + L"ACPI\\FixedButton"); + length++; + + length += swprintf(&temp[length], + L"*FixedButton"); + length++; + } + + temp[length] = UNICODE_NULL; + + length++; + + temp[length] = UNICODE_NULL; + + buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof(WCHAR), 'IPCA'); + + if (!buffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + RtlCopyMemory (buffer, temp, length * sizeof(WCHAR)); + Irp->IoStatus.Information = (ULONG_PTR) buffer; + DPRINT("BusQueryHardwareIDs: %ls\n",buffer); + break; + + default: + status = Irp->IoStatus.Status; + } + return status; +} + +NTSTATUS +Bus_PDO_QueryDeviceText( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + PWCHAR Buffer; + PIO_STACK_LOCATION stack; + NTSTATUS status; + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + switch (stack->Parameters.QueryDeviceText.DeviceTextType) { + + case DeviceTextDescription: + + if (!Irp->IoStatus.Information) { + if (wcsstr (DeviceData->HardwareIDs, L"PNP000") != 0) + Buffer = L"Programmable interrupt controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP010") != 0) + Buffer = L"System timer"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP020") != 0) + Buffer = L"DMA controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP03") != 0) + Buffer = L"Keyboard"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP040") != 0) + Buffer = L"Parallel port"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP05") != 0) + Buffer = L"Serial port"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP06") != 0) + Buffer = L"Disk controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP07") != 0) + Buffer = L"Disk controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP09") != 0) + Buffer = L"Display adapter"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0A0") != 0) + Buffer = L"Bus controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0E0") != 0) + Buffer = L"PCMCIA controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0F") != 0) + Buffer = L"Mouse device"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP8") != 0) + Buffer = L"Network adapter"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNPA0") != 0) + Buffer = L"SCSI controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNPB0") != 0) + Buffer = L"Multimedia device"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNPC00") != 0) + Buffer = L"Modem"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0C") != 0) + Buffer = L"Power Button"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0E") != 0) + Buffer = L"Sleep Button"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0D") != 0) + Buffer = L"Lid Switch"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C09") != 0) + Buffer = L"ACPI Embedded Controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0B") != 0) + Buffer = L"ACPI Fan"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0A03") != 0) + Buffer = L"PCI Root Bridge"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0A") != 0) + Buffer = L"ACPI Battery"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0F") != 0) + Buffer = L"PCI Interrupt Link"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI_PWR") != 0) + Buffer = L"ACPI Power Resource"; + else if (wcsstr(DeviceData->HardwareIDs, L"Processor") != 0) + Buffer = L"Processor"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI_SYS") != 0) + Buffer = L"ACPI System"; + else if (wcsstr(DeviceData->HardwareIDs, L"ThermalZone") != 0) + Buffer = L"ACPI Thermal Zone"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI0002") != 0) + Buffer = L"Smart Battery"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI0003") != 0) + Buffer = L"AC Adapter"; + /* Simply checking if AcpiHandle is NULL eliminates the need to check + * for the 4 different names that ACPI knows the fixed feature button as internally + */ + else if (!DeviceData->AcpiHandle) + Buffer = L"ACPI Fixed Feature Button"; + else + Buffer = L"Other ACPI device"; + + DPRINT("\tDeviceTextDescription :%ws\n", Buffer); + + Irp->IoStatus.Information = (ULONG_PTR) Buffer; + } + status = STATUS_SUCCESS; + break; + + default: + status = Irp->IoStatus.Status; + break; + } + + return status; + +} + +NTSTATUS +Bus_PDO_QueryResources( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + BOOLEAN Done; + ULONG NumberOfResources = 0; + PCM_RESOURCE_LIST ResourceList; + PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor; + ACPI_STATUS AcpiStatus; + ACPI_BUFFER Buffer; + ACPI_RESOURCE* resource; + ULONG ResourceListSize; + ULONG i; + + ULONG RequirementsListSize; + PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList; + PIO_RESOURCE_DESCRIPTOR RequirementDescriptor; + + + /* Get current resources */ + Buffer.Length = 0; + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + return STATUS_SUCCESS; + } + if (Buffer.Length > 0) + { + Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length); + if (!Buffer.Pointer) + { + ASSERT(FALSE); + } + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + ASSERT(FALSE); + } + } + + resource= Buffer.Pointer; + /* Count number of resources */ + Done = FALSE; + while (!Done) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + NumberOfResources += irq_data->InterruptCount; + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + NumberOfResources += dma_data->ChannelCount; + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + NumberOfResources++; + break; + } + case ACPI_RESOURCE_TYPE_END_TAG: + { + Done = TRUE; + break; + } + default: + { + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + + /* Allocate memory */ + ResourceListSize = sizeof(CM_RESOURCE_LIST) + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); + ResourceList = (PCM_RESOURCE_LIST)ExAllocatePool(PagedPool, ResourceListSize); + + if (!ResourceList) + return FALSE; + ResourceList->Count = 1; + ResourceList->List[0].InterfaceType = Internal; /* FIXME */ + ResourceList->List[0].BusNumber = 0; /* We're the only ACPI bus device in the system */ + ResourceList->List[0].PartialResourceList.Version = 1; + ResourceList->List[0].PartialResourceList.Revision = 1; + ResourceList->List[0].PartialResourceList.Count = NumberOfResources; + ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors; + + RequirementsListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); + RequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)ExAllocatePool(PagedPool, RequirementsListSize); + + if (!RequirementsList) + { + ExFreePool(ResourceList); + return STATUS_SUCCESS; + } + RequirementsList->ListSize = RequirementsListSize; + RequirementsList->InterfaceType = Internal; + RequirementsList->BusNumber = 0; + RequirementsList->SlotNumber = 0; /* Not used by WDM drivers */ + RequirementsList->AlternativeLists = 1; + RequirementsList->List[0].Version = 1; + RequirementsList->List[0].Revision = 1; + RequirementsList->List[0].Count = NumberOfResources; + RequirementDescriptor = RequirementsList->List[0].Descriptors; + + /* Fill resources list structure */ + Done = FALSE; + while (!Done) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + for (i = 0; i < irq_data->InterruptCount; i++) + { + ResourceDescriptor->Type = CmResourceTypeInterrupt; + + ResourceDescriptor->ShareDisposition = + (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); + ResourceDescriptor->Flags = + (irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); + ResourceDescriptor->u.Interrupt.Level = irq_data->Interrupts[i]; + ResourceDescriptor->u.Interrupt.Vector = 0; + ResourceDescriptor->u.Interrupt.Affinity = (KAFFINITY)(-1); + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = ResourceDescriptor->Type; + RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition; + RequirementDescriptor->Flags = ResourceDescriptor->Flags; + RequirementDescriptor->u.Interrupt.MinimumVector = RequirementDescriptor->u.Interrupt.MaximumVector + = irq_data->Interrupts[i]; + + ResourceDescriptor++; + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + for (i = 0; i < dma_data->ChannelCount; i++) + { + ResourceDescriptor->Type = CmResourceTypeDma; + ResourceDescriptor->Flags = 0; + switch (dma_data->Type) + { + case ACPI_TYPE_A: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_A; break; + case ACPI_TYPE_B: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_B; break; + case ACPI_TYPE_F: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_F; break; + } + if (dma_data->BusMaster == ACPI_BUS_MASTER) + ResourceDescriptor->Flags |= CM_RESOURCE_DMA_BUS_MASTER; + switch (dma_data->Transfer) + { + case ACPI_TRANSFER_8: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8; break; + case ACPI_TRANSFER_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_16; break; + case ACPI_TRANSFER_8_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break; + } + ResourceDescriptor->u.Dma.Channel = dma_data->Channels[i]; + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = ResourceDescriptor->Type; + RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition; + RequirementDescriptor->Flags = ResourceDescriptor->Flags; + RequirementDescriptor->u.Dma.MinimumChannel = RequirementDescriptor->u.Dma.MaximumChannel + = ResourceDescriptor->u.Dma.Channel; + + ResourceDescriptor++; + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + ACPI_RESOURCE_IO *io_data = (ACPI_RESOURCE_IO*) &resource->Data; + ResourceDescriptor->Type = CmResourceTypePort; + ResourceDescriptor->ShareDisposition = CmResourceShareDriverExclusive; + ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (io_data->IoDecode == ACPI_DECODE_16) + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_16_BIT_DECODE; + else + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE; + ResourceDescriptor->u.Port.Start.u.HighPart = 0; + ResourceDescriptor->u.Port.Start.u.LowPart = io_data->Minimum; + ResourceDescriptor->u.Port.Length = io_data->AddressLength; + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = ResourceDescriptor->Type; + RequirementDescriptor->ShareDisposition = ResourceDescriptor->ShareDisposition; + RequirementDescriptor->Flags = ResourceDescriptor->Flags; + RequirementDescriptor->u.Port.Length = ResourceDescriptor->u.Port.Length; + RequirementDescriptor->u.Port.Alignment = 1; /* Start address is specified, so it doesn't matter */ + RequirementDescriptor->u.Port.MinimumAddress = RequirementDescriptor->u.Port.MaximumAddress + = ResourceDescriptor->u.Port.Start; + + ResourceDescriptor++; + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_END_TAG: + { + Done = TRUE; + break; + } + default: + { + DPRINT1("Unhandled resource type\n"); + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + + ExFreePool(Buffer.Pointer); + Irp->IoStatus.Information = (ULONG_PTR)ResourceList; + return STATUS_SUCCESS; +} + +NTSTATUS +Bus_PDO_QueryResourceRequirements( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + BOOLEAN Done; + ULONG NumberOfResources = 0; + ACPI_STATUS AcpiStatus; + ACPI_BUFFER Buffer; + ACPI_RESOURCE* resource; + ULONG i, RequirementsListSize; + PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList; + PIO_RESOURCE_DESCRIPTOR RequirementDescriptor; + + PAGED_CODE (); + + + /* Get current resources */ + Buffer.Length = 0; + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + return STATUS_SUCCESS; + } + if (Buffer.Length > 0) + { + Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length); + if (!Buffer.Pointer) + { + ASSERT(FALSE); + } + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + ASSERT(FALSE); + } + } + + resource= Buffer.Pointer; + /* Count number of resources */ + Done = FALSE; + while (!Done) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + NumberOfResources += irq_data->InterruptCount; + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + NumberOfResources += dma_data->ChannelCount; + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + NumberOfResources++; + break; + } + case ACPI_RESOURCE_TYPE_END_TAG: + { + Done = TRUE; + break; + } + default: + { + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + + RequirementsListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); + RequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)ExAllocatePool(PagedPool, RequirementsListSize); + + if (!RequirementsList) + { + ExFreePool(Buffer.Pointer); + return STATUS_SUCCESS; + } + RequirementsList->ListSize = RequirementsListSize; + RequirementsList->InterfaceType = Internal; + RequirementsList->BusNumber = 0; + RequirementsList->SlotNumber = 0; /* Not used by WDM drivers */ + RequirementsList->AlternativeLists = 1; + RequirementsList->List[0].Version = 1; + RequirementsList->List[0].Revision = 1; + RequirementsList->List[0].Count = NumberOfResources; + RequirementDescriptor = RequirementsList->List[0].Descriptors; + + /* Fill resources list structure */ + Done = FALSE; + while (!Done) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + for (i = 0; i < irq_data->InterruptCount; i++) + { + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = CmResourceTypeInterrupt; + RequirementDescriptor->ShareDisposition = (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); + RequirementDescriptor->Flags =(irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); + RequirementDescriptor->u.Interrupt.MinimumVector = irq_data->Interrupts[i]; + + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + for (i = 0; i < dma_data->ChannelCount; i++) + { + RequirementDescriptor->Type = CmResourceTypeDma; + RequirementDescriptor->Flags = 0; + switch (dma_data->Type) + { + case ACPI_TYPE_A: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_A; break; + case ACPI_TYPE_B: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_B; break; + case ACPI_TYPE_F: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_F; break; + } + if (dma_data->BusMaster == ACPI_BUS_MASTER) + RequirementDescriptor->Flags |= CM_RESOURCE_DMA_BUS_MASTER; + switch (dma_data->Transfer) + { + case ACPI_TRANSFER_8: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_8; break; + case ACPI_TRANSFER_16: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_16; break; + case ACPI_TRANSFER_8_16: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break; + } + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->ShareDisposition = CmResourceShareDriverExclusive; + RequirementDescriptor->u.Dma.MinimumChannel = dma_data->Channels[i]; + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + ACPI_RESOURCE_IO *io_data = (ACPI_RESOURCE_IO*) &resource->Data; + RequirementDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (io_data->IoDecode == ACPI_DECODE_16) + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_16_BIT_DECODE; + else + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE; + + RequirementDescriptor->u.Port.Length = io_data->AddressLength; + + RequirementDescriptor->Option = 0; /* Required */ + RequirementDescriptor->Type = CmResourceTypePort; + RequirementDescriptor->ShareDisposition = CmResourceShareDriverExclusive; + RequirementDescriptor->u.Port.Alignment = 1; /* Start address is specified, so it doesn't matter */ + RequirementDescriptor->u.Port.MinimumAddress.QuadPart = io_data->Minimum; + RequirementDescriptor->u.Port.MaximumAddress.QuadPart = io_data->Maximum; + + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_END_TAG: + { + Done = TRUE; + break; + } + default: + { + DPRINT1("Unhandled resource type\n"); + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + ExFreePool(Buffer.Pointer); + + return STATUS_SUCCESS; +} + +NTSTATUS +Bus_PDO_QueryDeviceRelations( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +/*++ + +Routine Description: + + The PnP Manager sends this IRP to gather information about + devices with a relationship to the specified device. + Bus drivers must handle this request for TargetDeviceRelation + for their child devices (child PDOs). + + If a driver returns relations in response to this IRP, + it allocates a DEVICE_RELATIONS structure from paged + memory containing a count and the appropriate number of + device object pointers. The PnP Manager frees the structure + when it is no longer needed. If a driver replaces a + DEVICE_RELATIONS structure allocated by another driver, + it must free the previous structure. + + A driver must reference the PDO of any device that it + reports in this IRP (ObReferenceObject). The PnP Manager + removes the reference when appropriate. + +Arguments: + + DeviceData - Pointer to the PDO's device extension. + Irp - Pointer to the irp. + +Return Value: + + NT STATUS + +--*/ +{ + + PIO_STACK_LOCATION stack; + PDEVICE_RELATIONS deviceRelations; + NTSTATUS status; + + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + switch (stack->Parameters.QueryDeviceRelations.Type) { + + case TargetDeviceRelation: + + deviceRelations = (PDEVICE_RELATIONS) Irp->IoStatus.Information; + if (deviceRelations) { + // + // Only PDO can handle this request. Somebody above + // is not playing by rule. + // + ASSERTMSG("Someone above is handling TargetDeviceRelation", !deviceRelations); + } + + deviceRelations = (PDEVICE_RELATIONS) + ExAllocatePoolWithTag (PagedPool, + sizeof(DEVICE_RELATIONS), + 'IPCA'); + if (!deviceRelations) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + // + // There is only one PDO pointer in the structure + // for this relation type. The PnP Manager removes + // the reference to the PDO when the driver or application + // un-registers for notification on the device. + // + + deviceRelations->Count = 1; + deviceRelations->Objects[0] = DeviceData->Common.Self; + ObReferenceObject(DeviceData->Common.Self); + + status = STATUS_SUCCESS; + Irp->IoStatus.Information = (ULONG_PTR) deviceRelations; + break; + + case BusRelations: // Not handled by PDO + case EjectionRelations: // optional for PDO + case RemovalRelations: // // optional for PDO + default: + status = Irp->IoStatus.Status; + } + + return status; +} + +NTSTATUS +Bus_PDO_QueryBusInformation( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +/*++ + +Routine Description: + + The PnP Manager uses this IRP to request the type and + instance number of a device's parent bus. Bus drivers + should handle this request for their child devices (PDOs). + +Arguments: + + DeviceData - Pointer to the PDO's device extension. + Irp - Pointer to the irp. + +Return Value: + + NT STATUS + +--*/ +{ + + PPNP_BUS_INFORMATION busInfo; + + PAGED_CODE (); + + busInfo = ExAllocatePoolWithTag (PagedPool, sizeof(PNP_BUS_INFORMATION), + 'IPCA'); + + if (busInfo == NULL) { + return STATUS_INSUFFICIENT_RESOURCES; + } + + busInfo->BusTypeGuid = GUID_ACPI_INTERFACE_STANDARD; + + busInfo->LegacyBusType = InternalPowerBus; + + busInfo->BusNumber = 0; //fixme + + Irp->IoStatus.Information = (ULONG_PTR)busInfo; + + return STATUS_SUCCESS; +} + + +NTSTATUS +Bus_GetDeviceCapabilities( + PDEVICE_OBJECT DeviceObject, + PDEVICE_CAPABILITIES DeviceCapabilities + ) +{ + IO_STATUS_BLOCK ioStatus; + KEVENT pnpEvent; + NTSTATUS status; + PDEVICE_OBJECT targetObject; + PIO_STACK_LOCATION irpStack; + PIRP pnpIrp; + + PAGED_CODE(); + + // + // Initialize the capabilities that we will send down + // + RtlZeroMemory( DeviceCapabilities, sizeof(DEVICE_CAPABILITIES) ); + DeviceCapabilities->Size = sizeof(DEVICE_CAPABILITIES); + DeviceCapabilities->Version = 1; + DeviceCapabilities->Address = -1; + DeviceCapabilities->UINumber = -1; + + // + // Initialize the event + // + KeInitializeEvent( &pnpEvent, NotificationEvent, FALSE ); + + targetObject = IoGetAttachedDeviceReference( DeviceObject ); + + // + // Build an Irp + // + pnpIrp = IoBuildSynchronousFsdRequest( + IRP_MJ_PNP, + targetObject, + NULL, + 0, + NULL, + &pnpEvent, + &ioStatus + ); + if (pnpIrp == NULL) { + + status = STATUS_INSUFFICIENT_RESOURCES; + goto GetDeviceCapabilitiesExit; + + } + + // + // Pnp Irps all begin life as STATUS_NOT_SUPPORTED; + // + pnpIrp->IoStatus.Status = STATUS_NOT_SUPPORTED; + + // + // Get the top of stack + // + irpStack = IoGetNextIrpStackLocation( pnpIrp ); + + // + // Set the top of stack + // + RtlZeroMemory( irpStack, sizeof(IO_STACK_LOCATION ) ); + irpStack->MajorFunction = IRP_MJ_PNP; + irpStack->MinorFunction = IRP_MN_QUERY_CAPABILITIES; + irpStack->Parameters.DeviceCapabilities.Capabilities = DeviceCapabilities; + + // + // Call the driver + // + status = IoCallDriver( targetObject, pnpIrp ); + if (status == STATUS_PENDING) { + + // + // Block until the irp comes back. + // Important thing to note here is when you allocate + // the memory for an event in the stack you must do a + // KernelMode wait instead of UserMode to prevent + // the stack from getting paged out. + // + + KeWaitForSingleObject( + &pnpEvent, + Executive, + KernelMode, + FALSE, + NULL + ); + status = ioStatus.Status; + + } + +GetDeviceCapabilitiesExit: + // + // Done with reference + // + ObDereferenceObject( targetObject ); + + // + // Done + // + return status; + +} + + diff --git a/drivers/bus/acpi/include/acpi_bus.h b/drivers/bus/acpi/include/acpi_bus.h new file mode 100644 index 00000000000..fa264a19c27 --- /dev/null +++ b/drivers/bus/acpi/include/acpi_bus.h @@ -0,0 +1,385 @@ +/* + * acpi_bus.h - ACPI Bus Driver ($Revision: 22 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#ifndef __ACPI_BUS_H__ +#define __ACPI_BUS_H__ + +#include + +#include "list.h" + + +/* TBD: Make dynamic */ +#define ACPI_MAX_HANDLES 10 +struct acpi_handle_list { + UINT32 count; + ACPI_HANDLE handles[ACPI_MAX_HANDLES]; +}; + + +/* acpi_utils.h */ +ACPI_STATUS +acpi_extract_package ( + ACPI_OBJECT *package, + ACPI_BUFFER *format, + ACPI_BUFFER *buffer); +ACPI_STATUS +acpi_evaluate_integer ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + struct acpi_object_list *arguments, + unsigned long long *data); +ACPI_STATUS +acpi_evaluate_reference ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + struct acpi_object_list *arguments, + struct acpi_handle_list *list); + +enum acpi_bus_removal_type { + ACPI_BUS_REMOVAL_NORMAL = 0, + ACPI_BUS_REMOVAL_EJECT, + ACPI_BUS_REMOVAL_SUPRISE, + ACPI_BUS_REMOVAL_TYPE_COUNT +}; + +enum acpi_bus_device_type { + ACPI_BUS_TYPE_DEVICE = 0, + ACPI_BUS_TYPE_POWER, + ACPI_BUS_TYPE_PROCESSOR, + ACPI_BUS_TYPE_THERMAL, + ACPI_BUS_TYPE_SYSTEM, + ACPI_BUS_TYPE_POWER_BUTTON, + ACPI_BUS_TYPE_SLEEP_BUTTON, + ACPI_BUS_DEVICE_TYPE_COUNT +}; + +struct acpi_driver; +struct acpi_device; + + +/* + * ACPI Driver + * ----------- + */ + +typedef int (*acpi_op_add) (struct acpi_device *device); +typedef int (*acpi_op_remove) (struct acpi_device *device, int type); +typedef int (*acpi_op_start) (struct acpi_device *device); +typedef int (*acpi_op_suspend) (struct acpi_device *device, int state); +typedef int (*acpi_op_resume) (struct acpi_device *device, int state); +typedef int (*acpi_op_scan) (struct acpi_device *device); +typedef int (*acpi_op_bind) (struct acpi_device *device); +typedef int (*acpi_op_unbind) (struct acpi_device * device); +typedef void (*acpi_op_notify) (struct acpi_device * device, UINT32 event); + +struct acpi_bus_ops { + UINT32 acpi_op_add:1; + UINT32 acpi_op_start:1; +}; + +struct acpi_device_ops { + acpi_op_add add; + acpi_op_remove remove; + acpi_op_start start; + acpi_op_suspend suspend; + acpi_op_resume resume; + acpi_op_bind bind; + acpi_op_unbind unbind; + acpi_op_notify notify; + acpi_op_scan scan; +}; + +#define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */ + +struct acpi_driver { + struct list_head node; + char name[80]; + char class[80]; + int references; + unsigned int flags; + char *ids; /* Supported Hardware IDs */ + struct acpi_device_ops ops; +}; + +/* + * ACPI Device + * ----------- + */ + +/* Status (_STA) */ + +struct acpi_device_status { + UINT32 present:1; + UINT32 enabled:1; + UINT32 show_in_ui:1; + UINT32 functional:1; + UINT32 battery_present:1; + UINT32 reserved:27; +}; + + +/* Flags */ + +struct acpi_device_flags { + UINT32 dynamic_status:1; + UINT32 hardware_id:1; + UINT32 compatible_ids:1; + UINT32 bus_address:1; + UINT32 unique_id:1; + UINT32 removable:1; + UINT32 ejectable:1; + UINT32 lockable:1; + UINT32 suprise_removal_ok:1; + UINT32 power_manageable:1; + UINT32 performance_manageable:1; + UINT32 wake_capable:1; + UINT32 force_power_state:1; + UINT32 reserved:20; +}; + +/* Plug and Play */ + +typedef char acpi_bus_id[8]; +typedef unsigned long acpi_bus_address; +typedef char acpi_hardware_id[9]; +typedef char acpi_unique_id[9]; +typedef char acpi_device_name[40]; +typedef char acpi_device_class[20]; + +struct acpi_device_pnp { + acpi_bus_id bus_id; /* Object name */ + acpi_bus_address bus_address; /* _ADR */ + acpi_hardware_id hardware_id; /* _HID */ + ACPI_DEVICE_ID_LIST *cid_list; /* _CIDs */ + acpi_unique_id unique_id; /* _UID */ + acpi_device_name device_name; /* Driver-determined */ + acpi_device_class device_class; /* " */ +}; + +#define acpi_device_bid(d) ((d)->pnp.bus_id) +#define acpi_device_adr(d) ((d)->pnp.bus_address) +#define acpi_device_hid(d) ((d)->pnp.hardware_id) +#define acpi_device_uid(d) ((d)->pnp.unique_id) +#define acpi_device_name(d) ((d)->pnp.device_name) +#define acpi_device_class(d) ((d)->pnp.device_class) + + +/* Power Management */ + +struct acpi_device_power_flags { + UINT32 explicit_get:1; /* _PSC present? */ + UINT32 power_resources:1; /* Power resources */ + UINT32 inrush_current:1; /* Serialize Dx->D0 */ + UINT32 power_removed:1; /* Optimize Dx->D0 */ + UINT32 reserved:28; +}; + +struct acpi_device_power_state { + struct { + UINT8 valid:1; + UINT8 explicit_set:1; /* _PSx present? */ + UINT8 reserved:6; + } flags; + int power; /* % Power (compared to D0) */ + int latency; /* Dx->D0 time (microseconds) */ + struct acpi_handle_list resources; /* Power resources referenced */ +}; + +struct acpi_device_power { + int state; /* Current state */ + struct acpi_device_power_flags flags; + struct acpi_device_power_state states[4]; /* Power states (D0-D3) */ +}; + + +/* Performance Management */ + +struct acpi_device_perf_flags { + UINT8 reserved:8; +}; + +struct acpi_device_perf_state { + struct { + UINT8 valid:1; + UINT8 reserved:7; + } flags; + UINT8 power; /* % Power (compared to P0) */ + UINT8 performance; /* % Performance ( " ) */ + int latency; /* Px->P0 time (microseconds) */ +}; + +struct acpi_device_perf { + int state; + struct acpi_device_perf_flags flags; + int state_count; + struct acpi_device_perf_state *states; +}; + +/* Wakeup Management */ +struct acpi_device_wakeup_flags { + UINT8 valid:1; /* Can successfully enable wakeup? */ + UINT8 run_wake:1; /* Run-Wake GPE devices */ +}; + +struct acpi_device_wakeup_state { + UINT8 enabled:1; +}; + +struct acpi_device_wakeup { + ACPI_HANDLE gpe_device; + ACPI_INTEGER gpe_number; + ACPI_INTEGER sleep_state; + struct acpi_handle_list resources; + struct acpi_device_wakeup_state state; + struct acpi_device_wakeup_flags flags; + int prepare_count; +}; + + +/* Device */ + +struct acpi_device { + int device_type; + ACPI_HANDLE handle; + struct acpi_device *parent; + struct list_head children; + struct list_head node; + struct list_head wakeup_list; + struct acpi_device_status status; + struct acpi_device_flags flags; + struct acpi_device_pnp pnp; + struct acpi_device_power power; + struct acpi_device_wakeup wakeup; + struct acpi_device_perf performance; + struct acpi_device_ops ops; + struct acpi_driver *driver; + void *driver_data; + struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */ + enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ + +}; + +#define acpi_driver_data(d) ((d)->driver_data) + +#define to_acpi_device(d) container_of(d, struct acpi_device, dev) +#define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) + +/* acpi_device.dev.bus == &acpi_bus_type */ +extern struct bus_type acpi_bus_type; + +/* + * Events + * ------ + */ + +struct acpi_bus_event { + struct list_head node; + acpi_device_class device_class; + acpi_bus_id bus_id; + UINT32 type; + UINT32 data; +}; + + +/* + * External Functions + */ +int acpi_bus_get_private_data(ACPI_HANDLE, void **); + +void acpi_bus_data_handler(ACPI_HANDLE handle, void *context); +ACPI_STATUS acpi_bus_get_status_handle(ACPI_HANDLE handle, + unsigned long long *sta); +int acpi_bus_get_status(struct acpi_device *device); +int acpi_bus_get_power(ACPI_HANDLE handle, int *state); +int acpi_bus_set_power(ACPI_HANDLE handle, int state); +BOOLEAN acpi_bus_power_manageable(ACPI_HANDLE handle); +BOOLEAN acpi_bus_can_wakeup(ACPI_HANDLE handle); +int acpi_bus_generate_proc_event(struct acpi_device *device, UINT8 type, int data); +int acpi_bus_receive_event(struct acpi_bus_event *event); +int acpi_bus_register_driver(struct acpi_driver *driver); +void acpi_bus_unregister_driver(struct acpi_driver *driver); +int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, + ACPI_HANDLE handle, int type); +int acpi_bus_trim(struct acpi_device *start, int rmdevice); +int acpi_bus_start(struct acpi_device *device); +ACPI_STATUS acpi_bus_get_ejd(ACPI_HANDLE handle, ACPI_HANDLE * ejd); +int acpi_match_device_ids(struct acpi_device *device, + const struct acpi_device_id *ids); + +/* + * Bind physical devices with ACPI devices + */ +//struct acpi_bus_type { +// struct list_head list; +// struct bus_type *bus; +// /* For general devices under the bus */ +// int (*find_device) (struct device *, ACPI_HANDLE *); +// /* For bridges, such as PCI root bridge, IDE controller */ +// int (*find_bridge) (struct device *, ACPI_HANDLE *); +//}; +//int register_acpi_bus_type(struct acpi_bus_type *); +//int unregister_acpi_bus_type(struct acpi_bus_type *); +//struct device *acpi_get_physical_device(ACPI_HANDLE); + +struct acpi_pci_root { + struct list_head node; + struct acpi_device * device; + struct acpi_pci_id id; + struct pci_bus *bus; + UINT16 segment; + UINT8 bus_nr; + + UINT32 osc_support_set; /* _OSC state of support bits */ + UINT32 osc_control_set; /* _OSC state of control bits */ + UINT32 osc_control_qry; /* the latest _OSC query result */ + + UINT32 osc_queried:1; /* has _OSC control been queried? */ +}; + +//static inline int acpi_pm_device_sleep_state(struct device *d, int *p) +//{ +// if (p) +// *p = ACPI_STATE_D0; +// return ACPI_STATE_D3; +//} +//static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable) +//{ +// return -1; +//} + +/* system defines: move to bigger header */ +extern enum acpi_irq_model_id acpi_irq_model; + +enum acpi_irq_model_id { + ACPI_IRQ_MODEL_PIC = 0, + ACPI_IRQ_MODEL_IOAPIC, + ACPI_IRQ_MODEL_IOSAPIC, + ACPI_IRQ_MODEL_COUNT +}; + + + +#endif /*__ACPI_BUS_H__*/ diff --git a/drivers/bus/acpi/include/acpi_drivers.h b/drivers/bus/acpi/include/acpi_drivers.h new file mode 100644 index 00000000000..6506e44882b --- /dev/null +++ b/drivers/bus/acpi/include/acpi_drivers.h @@ -0,0 +1,340 @@ +/* + * acpi_drivers.h ($Revision: 32 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#ifndef __ACPI_DRIVERS_H__ +#define __ACPI_DRIVERS_H__ + +#define ACPI_MAX_STRING 80 + + +/* -------------------------------------------------------------------------- + ACPI Bus + -------------------------------------------------------------------------- */ + +#define ACPI_BUS_COMPONENT 0x00010000 +#define ACPI_BUS_CLASS "system_bus" +#define ACPI_BUS_HID "ACPI_BUS" +#define ACPI_BUS_DRIVER_NAME "ACPI Bus Driver" +#define ACPI_BUS_DEVICE_NAME "System Bus" + + +/* -------------------------------------------------------------------------- + AC Adapter + -------------------------------------------------------------------------- */ + +#define ACPI_AC_COMPONENT 0x00020000 +#define ACPI_AC_CLASS "ac_adapter" +#define ACPI_AC_HID "ACPI0003" +#define ACPI_AC_DRIVER_NAME "ACPI AC Adapter Driver" +#define ACPI_AC_DEVICE_NAME "AC Adapter" +#define ACPI_AC_FILE_STATE "state" +#define ACPI_AC_NOTIFY_STATUS 0x80 +#define ACPI_AC_STATUS_OFFLINE 0x00 +#define ACPI_AC_STATUS_ONLINE 0x01 +#define ACPI_AC_STATUS_UNKNOWN 0xFF + + +/* -------------------------------------------------------------------------- + Battery + -------------------------------------------------------------------------- */ + +#define ACPI_BATTERY_COMPONENT 0x00040000 +#define ACPI_BATTERY_CLASS "battery" +#define ACPI_BATTERY_HID "PNP0C0A" +#define ACPI_BATTERY_DRIVER_NAME "ACPI Battery Driver" +#define ACPI_BATTERY_DEVICE_NAME "Battery" +#define ACPI_BATTERY_FILE_INFO "info" +#define ACPI_BATTERY_FILE_STATUS "state" +#define ACPI_BATTERY_FILE_ALARM "alarm" +#define ACPI_BATTERY_NOTIFY_STATUS 0x80 +#define ACPI_BATTERY_NOTIFY_INFO 0x81 +#define ACPI_BATTERY_UNITS_WATTS "mW" +#define ACPI_BATTERY_UNITS_AMPS "mA" + + +/* -------------------------------------------------------------------------- + Button + -------------------------------------------------------------------------- */ + +#define ACPI_BUTTON_COMPONENT 0x00080000 +#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" +#define ACPI_BUTTON_CLASS "button" +#define ACPI_BUTTON_FILE_INFO "info" +#define ACPI_BUTTON_FILE_STATE "state" +#define ACPI_BUTTON_TYPE_UNKNOWN 0x00 +#define ACPI_BUTTON_NOTIFY_STATUS 0x80 + +#define ACPI_BUTTON_SUBCLASS_POWER "power" +#define ACPI_BUTTON_HID_POWER "PNP0C0C" +#define ACPI_BUTTON_HID_POWERF "ACPI_FPB" +#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)" +#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)" +#define ACPI_BUTTON_TYPE_POWER 0x01 +#define ACPI_BUTTON_TYPE_POWERF 0x02 + +#define ACPI_BUTTON_SUBCLASS_SLEEP "sleep" +#define ACPI_BUTTON_HID_SLEEP "PNP0C0E" +#define ACPI_BUTTON_HID_SLEEPF "ACPI_FSB" +#define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button (CM)" +#define ACPI_BUTTON_DEVICE_NAME_SLEEPF "Sleep Button (FF)" +#define ACPI_BUTTON_TYPE_SLEEP 0x03 +#define ACPI_BUTTON_TYPE_SLEEPF 0x04 + +#define ACPI_BUTTON_SUBCLASS_LID "lid" +#define ACPI_BUTTON_HID_LID "PNP0C0D" +#define ACPI_BUTTON_DEVICE_NAME_LID "Lid Switch" +#define ACPI_BUTTON_TYPE_LID 0x05 + +int acpi_button_init (void); +void acpi_button_exit (void); + +/* -------------------------------------------------------------------------- + Embedded Controller + -------------------------------------------------------------------------- */ + +#define ACPI_EC_COMPONENT 0x00100000 +#define ACPI_EC_CLASS "embedded_controller" +#define ACPI_EC_HID "PNP0C09" +#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" +#define ACPI_EC_DEVICE_NAME "Embedded Controller" +#define ACPI_EC_FILE_INFO "info" + +#ifdef CONFIG_ACPI_EC + +int acpi_ec_ecdt_probe (void); +int acpi_ec_init (void); +void acpi_ec_exit (void); + +#endif + + +/* -------------------------------------------------------------------------- + Fan + -------------------------------------------------------------------------- */ + +#define ACPI_FAN_COMPONENT 0x00200000 +#define ACPI_FAN_CLASS "fan" +#define ACPI_FAN_HID "PNP0C0B" +#define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver" +#define ACPI_FAN_DEVICE_NAME "Fan" +#define ACPI_FAN_FILE_STATE "state" +#define ACPI_FAN_NOTIFY_STATUS 0x80 + + +/* -------------------------------------------------------------------------- + PCI + -------------------------------------------------------------------------- */ + +#ifdef CONFIG_ACPI_PCI + +#define ACPI_PCI_COMPONENT 0x00400000 + +/* ACPI PCI Root Bridge (pci_root.c) */ + +#define ACPI_PCI_ROOT_CLASS "pci_bridge" +#define ACPI_PCI_ROOT_HID "PNP0A03" +#define ACPI_PCI_ROOT_DRIVER_NAME "ACPI PCI Root Bridge Driver" +#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" + +int acpi_pci_root_init (void); +void acpi_pci_root_exit (void); + +/* ACPI PCI Interrupt Link (pci_link.c) */ + +#define ACPI_PCI_LINK_CLASS "pci_irq_routing" +#define ACPI_PCI_LINK_HID "PNP0C0F" +#define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver" +#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link" +#define ACPI_PCI_LINK_FILE_INFO "info" +#define ACPI_PCI_LINK_FILE_STATUS "state" + +int acpi_pci_link_check (void); +int acpi_pci_link_get_irq (ACPI_HANDLE handle, int index, int* edge_level, int* active_high_low); +int acpi_pci_link_init (void); +void acpi_pci_link_exit (void); + +/* ACPI PCI Interrupt Routing (pci_irq.c) */ + +int acpi_pci_irq_add_prt (ACPI_HANDLE handle, int segment, int bus); + +/* ACPI PCI Device Binding (pci_bind.c) */ + +struct pci_bus; + +int acpi_pci_bind (struct acpi_device *device); +int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus); + +#endif /*CONFIG_ACPI_PCI*/ + + +/* -------------------------------------------------------------------------- + Power Resource + -------------------------------------------------------------------------- */ + +#define ACPI_POWER_COMPONENT 0x00800000 +#define ACPI_POWER_CLASS "power_resource" +#define ACPI_POWER_HID "ACPI_PWR" +#define ACPI_POWER_DRIVER_NAME "ACPI Power Resource Driver" +#define ACPI_POWER_DEVICE_NAME "Power Resource" +#define ACPI_POWER_FILE_INFO "info" +#define ACPI_POWER_FILE_STATUS "state" +#define ACPI_POWER_RESOURCE_STATE_OFF 0x00 +#define ACPI_POWER_RESOURCE_STATE_ON 0x01 +#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF + + + +int acpi_power_get_inferred_state (struct acpi_device *device); +int acpi_power_transition (struct acpi_device *device, int state); +int acpi_power_init (void); +void acpi_power_exit (void); + + +/* -------------------------------------------------------------------------- + Processor + -------------------------------------------------------------------------- */ + +#define ACPI_PROCESSOR_COMPONENT 0x01000000 +#define ACPI_PROCESSOR_CLASS "processor" +#define ACPI_PROCESSOR_HID "Processor" +#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" +#define ACPI_PROCESSOR_DEVICE_NAME "Processor" +#define ACPI_PROCESSOR_FILE_INFO "info" +#define ACPI_PROCESSOR_FILE_POWER "power" +#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" +#define ACPI_PROCESSOR_FILE_THROTTLING "throttling" +#define ACPI_PROCESSOR_FILE_LIMIT "limit" +#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 +#define ACPI_PROCESSOR_NOTIFY_POWER 0x81 +#define ACPI_PROCESSOR_LIMIT_NONE 0x00 +#define ACPI_PROCESSOR_LIMIT_INCREMENT 0x01 +#define ACPI_PROCESSOR_LIMIT_DECREMENT 0x02 + +int acpi_processor_set_thermal_limit(ACPI_HANDLE handle, int type); + + +/* -------------------------------------------------------------------------- + System + -------------------------------------------------------------------------- */ + +#define ACPI_SYSTEM_COMPONENT 0x02000000 +#define ACPI_SYSTEM_CLASS "system" +#define ACPI_SYSTEM_HID "ACPI_SYS" +#define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver" +#define ACPI_SYSTEM_DEVICE_NAME "System" +#define ACPI_SYSTEM_FILE_INFO "info" +#define ACPI_SYSTEM_FILE_EVENT "event" +#define ACPI_SYSTEM_FILE_ALARM "alarm" +#define ACPI_SYSTEM_FILE_DSDT "dsdt" +#define ACPI_SYSTEM_FILE_FADT "fadt" +#define ACPI_SYSTEM_FILE_SLEEP "sleep" +#define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" +#define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" + +int acpi_system_init (void); +void acpi_system_exit (void); + + +/* -------------------------------------------------------------------------- + Thermal Zone + -------------------------------------------------------------------------- */ + +#define ACPI_THERMAL_COMPONENT 0x04000000 +#define ACPI_THERMAL_CLASS "thermal_zone" +#define ACPI_THERMAL_HID "ThermalZone" +#define ACPI_THERMAL_DRIVER_NAME "ACPI Thermal Zone Driver" +#define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" +#define ACPI_THERMAL_FILE_STATE "state" +#define ACPI_THERMAL_FILE_TEMPERATURE "temperature" +#define ACPI_THERMAL_FILE_TRIP_POINTS "trip_points" +#define ACPI_THERMAL_FILE_COOLING_MODE "cooling_mode" +#define ACPI_THERMAL_FILE_POLLING_FREQ "polling_frequency" +#define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80 +#define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81 +#define ACPI_THERMAL_NOTIFY_DEVICES 0x82 +#define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0 +#define ACPI_THERMAL_NOTIFY_HOT 0xF1 +#define ACPI_THERMAL_MODE_ACTIVE 0x00 +#define ACPI_THERMAL_MODE_PASSIVE 0x01 +#define ACPI_THERMAL_PATH_POWEROFF "/sbin/poweroff" + +/* Motherboard devices */ +int acpi_motherboard_init(void); +/* -------------------------------------------------------------------------- + Debug Support + -------------------------------------------------------------------------- */ + +#define ACPI_DEBUG_RESTORE 0 +#define ACPI_DEBUG_LOW 1 +#define ACPI_DEBUG_MEDIUM 2 +#define ACPI_DEBUG_HIGH 3 +#define ACPI_DEBUG_DRIVERS 4 + +extern UINT32 acpi_dbg_level; +extern UINT32 acpi_dbg_layer; + +static inline void +acpi_set_debug ( + UINT32 flag) +{ + static UINT32 layer_save; + static UINT32 level_save; + + switch (flag) { + case ACPI_DEBUG_RESTORE: + acpi_dbg_layer = layer_save; + acpi_dbg_level = level_save; + break; + case ACPI_DEBUG_LOW: + case ACPI_DEBUG_MEDIUM: + case ACPI_DEBUG_HIGH: + case ACPI_DEBUG_DRIVERS: + layer_save = acpi_dbg_layer; + level_save = acpi_dbg_level; + break; + } + + switch (flag) { + case ACPI_DEBUG_LOW: + acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; + acpi_dbg_level = ACPI_DEBUG_DEFAULT; + break; + case ACPI_DEBUG_MEDIUM: + acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; + acpi_dbg_level = ACPI_LV_FUNCTIONS | ACPI_LV_ALL_EXCEPTIONS; + break; + case ACPI_DEBUG_HIGH: + acpi_dbg_layer = 0xFFFFFFFF; + acpi_dbg_level = 0xFFFFFFFF; + break; + case ACPI_DEBUG_DRIVERS: + acpi_dbg_layer = ACPI_ALL_DRIVERS; + acpi_dbg_level = 0xFFFFFFFF; + break; + } +} + + +#endif /*__ACPI_DRIVERS_H__*/ diff --git a/drivers/bus/acpi/include/acpisys.h b/drivers/bus/acpi/include/acpisys.h new file mode 100644 index 00000000000..4779d2233f8 --- /dev/null +++ b/drivers/bus/acpi/include/acpisys.h @@ -0,0 +1,292 @@ +/* + * PROJECT: ReactOS ACPI bus driver + * FILE: acpi/ospm/include/acpisys.h + * PURPOSE: ACPI bus driver definitions + */ +typedef enum _DEVICE_PNP_STATE { + + NotStarted = 0, // Not started yet + Started, // Device has received the START_DEVICE IRP + StopPending, // Device has received the QUERY_STOP IRP + Stopped, // Device has received the STOP_DEVICE IRP + UnKnown // Unknown state + +} DEVICE_PNP_STATE; + +// +// A common header for the device extensions of the PDOs and FDO +// + +typedef struct _COMMON_DEVICE_DATA +{ + PDEVICE_OBJECT Self; + BOOLEAN IsFDO; + DEVICE_PNP_STATE DevicePnPState; + DEVICE_PNP_STATE PreviousPnPState; + SYSTEM_POWER_STATE SystemPowerState; + DEVICE_POWER_STATE DevicePowerState; +} COMMON_DEVICE_DATA, *PCOMMON_DEVICE_DATA; + +typedef struct _PDO_DEVICE_DATA +{ + COMMON_DEVICE_DATA Common; + ACPI_HANDLE AcpiHandle; + // A back pointer to the bus + PDEVICE_OBJECT ParentFdo; + // An array of (zero terminated wide character strings). + // The array itself also null terminated + PWCHAR HardwareIDs; + // Link point to hold all the PDOs for a single bus together + LIST_ENTRY Link; + ULONG InterfaceRefCount; + +} PDO_DEVICE_DATA, *PPDO_DEVICE_DATA; + +// +// The device extension of the bus itself. From whence the PDO's are born. +// + +typedef struct _FDO_DEVICE_DATA +{ + COMMON_DEVICE_DATA Common; + PDEVICE_OBJECT UnderlyingPDO; + + // The underlying bus PDO and the actual device object to which our + // FDO is attached + PDEVICE_OBJECT NextLowerDriver; + + // List of PDOs created so far + LIST_ENTRY ListOfPDOs; + + // The PDOs currently enumerated. + ULONG NumPDOs; + + // A synchronization for access to the device extension. + FAST_MUTEX Mutex; + + // The name returned from IoRegisterDeviceInterface, + // which is used as a handle for IoSetDeviceInterfaceState. + UNICODE_STRING InterfaceName; + +} FDO_DEVICE_DATA, *PFDO_DEVICE_DATA; + +#define FDO_FROM_PDO(pdoData) \ + ((PFDO_DEVICE_DATA) (pdoData)->ParentFdo->DeviceExtension) + +#define INITIALIZE_PNP_STATE(_Data_) \ + (_Data_).DevicePnPState = NotStarted;\ + (_Data_).PreviousPnPState = NotStarted; + +#define SET_NEW_PNP_STATE(_Data_, _state_) \ + (_Data_).PreviousPnPState = (_Data_).DevicePnPState;\ + (_Data_).DevicePnPState = (_state_); + +#define RESTORE_PREVIOUS_PNP_STATE(_Data_) \ + (_Data_).DevicePnPState = (_Data_).PreviousPnPState;\ + +/* acpienum.c */ + +//NTSTATUS +//ACPIEnumerateDevices( +// PFDO_DEVICE_EXTENSION DeviceExtension); + +NTSTATUS +NTAPI +Bus_CreateClose ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +VOID +Bus_DriverUnload ( + PDRIVER_OBJECT DriverObject + ); + +PCHAR +PnPMinorFunctionString ( + UCHAR MinorFunction +); + +NTSTATUS +NTAPI +Bus_AddDevice( + PDRIVER_OBJECT DriverObject, + PDEVICE_OBJECT PhysicalDeviceObject + ); + +NTSTATUS +Bus_SendIrpSynchronously ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +NTSTATUS +NTAPI +Bus_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +NTSTATUS +Bus_CompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context + ); + +VOID +Bus_InitializePdo ( + PDEVICE_OBJECT Pdo, + PFDO_DEVICE_DATA FdoData + ); + + +void +Bus_RemoveFdo ( + PFDO_DEVICE_DATA FdoData + ); + +NTSTATUS +Bus_DestroyPdo ( + PDEVICE_OBJECT Device, + PPDO_DEVICE_DATA PdoData + ); + + +NTSTATUS +Bus_FDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PFDO_DEVICE_DATA DeviceData + ); + + +NTSTATUS +Bus_StartFdo ( + PFDO_DEVICE_DATA FdoData, + PIRP Irp ); + +PCHAR +DbgDeviceIDString( + BUS_QUERY_ID_TYPE Type + ); + +PCHAR +DbgDeviceRelationString( + DEVICE_RELATION_TYPE Type + ); + +NTSTATUS +Bus_FDO_Power ( + PFDO_DEVICE_DATA FdoData, + PIRP Irp + ); + +NTSTATUS +Bus_PDO_Power ( + PPDO_DEVICE_DATA PdoData, + PIRP Irp + ); + +NTSTATUS +NTAPI +Bus_Power ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +PCHAR +PowerMinorFunctionString ( + UCHAR MinorFunction +); + +PCHAR +DbgSystemPowerString( + SYSTEM_POWER_STATE Type + ); + +PCHAR +DbgDevicePowerString( + DEVICE_POWER_STATE Type + ); + +NTSTATUS +Bus_PDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PPDO_DEVICE_DATA DeviceData + ); + +NTSTATUS +Bus_PDO_QueryDeviceCaps( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryDeviceId( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + + +NTSTATUS +Bus_PDO_QueryDeviceText( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryResources( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryResourceRequirements( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryDeviceRelations( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryBusInformation( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_GetDeviceCapabilities( + PDEVICE_OBJECT DeviceObject, + PDEVICE_CAPABILITIES DeviceCapabilities + ); + +NTSTATUS +Bus_PDO_QueryInterface( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +BOOLEAN +Bus_GetCrispinessLevel( + PVOID Context, + PUCHAR Level + ); +BOOLEAN +Bus_SetCrispinessLevel( + PVOID Context, + UCHAR Level + ); +BOOLEAN +Bus_IsSafetyLockEnabled( + PVOID Context + ); +VOID +Bus_InterfaceReference ( + PVOID Context + ); +VOID +Bus_InterfaceDereference ( + PVOID Context + ); + +/* EOF */ diff --git a/drivers/bus/acpi/include/glue.h b/drivers/bus/acpi/include/glue.h new file mode 100644 index 00000000000..6b45ba8f42c --- /dev/null +++ b/drivers/bus/acpi/include/glue.h @@ -0,0 +1,30 @@ +#ifndef __GLUE_HEADER +#define __GLUE_HEADER + +#include + +/* header for linux macros and definitions */ + + /** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ + #define container_of(ptr, type, member) (type *)( (char *)(ptr) - offsetof(type,member) ) + + +#define time_after(a,b) \ + ((long)(b) - (long)(a) < 0)) + +#define time_before(a,b) time_after(b,a) + +#define in_interrupt() ((__readeflags() >> 9) & 1) + +typedef int (*acpi_table_handler) (ACPI_TABLE_HEADER *table); + +typedef int (*acpi_table_entry_handler) (ACPI_SUBTABLE_HEADER *header, const unsigned long end); + + +#endif diff --git a/drivers/bus/acpi/include/list.h b/drivers/bus/acpi/include/list.h new file mode 100644 index 00000000000..bac8727aa73 --- /dev/null +++ b/drivers/bus/acpi/include/list.h @@ -0,0 +1,251 @@ + #ifndef _LINUX_LIST_H + #define _LINUX_LIST_H + + + /* + * Simple doubly linked list implementation. + * + * Some of the internal functions ("__xxx") are useful when + * manipulating whole lists rather than single entries, as + * sometimes we already know the next/prev entries and we can + * generate better code by using them directly rather than + * using the generic single-entry routines. + */ + + struct list_head { + struct list_head *next, *prev; + }; + + #define LIST_HEAD_INIT(name) { &(name), &(name) } + + #define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + + #define INIT_LIST_HEAD(ptr) do { \ + (ptr)->next = (ptr); (ptr)->prev = (ptr); \ + } while (0) + + + /* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ + static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) + { + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; + } + + /** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ + static inline void list_add(struct list_head *new, struct list_head *head) + { + __list_add(new, head, head->next); + } + + /** + * list_add_tail - add a new entry + * @new: new entry to be added + * @head: list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + */ + static inline void list_add_tail(struct list_head *new, struct list_head *head) + { + __list_add(new, head->prev, head); + } + + /* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ + static inline void __list_del(struct list_head *prev, struct list_head *next) + { + next->prev = prev; + prev->next = next; + } + + /** + * list_del - deletes entry from list. + * @entry: the element to delete from the list. + * Note: list_empty on entry does not return true after this, the entry is in an undefined state. + */ + static inline void list_del(struct list_head *entry) + { + __list_del(entry->prev, entry->next); + entry->next = (void *) 0; + entry->prev = (void *) 0; + } + + /** + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ + static inline void list_del_init(struct list_head *entry) + { + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); + } + + /** + * list_move - delete from one list and add as another's head + * @list: the entry to move + * @head: the head that will precede our entry + */ + static inline void list_move(struct list_head *list, struct list_head *head) + { + __list_del(list->prev, list->next); + list_add(list, head); + } + + /** + * list_move_tail - delete from one list and add as another's tail + * @list: the entry to move + * @head: the head that will follow our entry + */ + static inline void list_move_tail(struct list_head *list, + struct list_head *head) + { + __list_del(list->prev, list->next); + list_add_tail(list, head); + } + + /** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ + static inline int list_empty(struct list_head *head) + { + return head->next == head; + } + + static inline void __list_splice(struct list_head *list, + struct list_head *head) + { + struct list_head *first = list->next; + struct list_head *last = list->prev; + struct list_head *at = head->next; + + first->prev = head; + head->next = first; + + last->next = at; + at->prev = last; + } + +/** + * list_splice - join two lists + * @list: the new list to add. + * @head: the place to add it in the first list. + */ + static inline void list_splice(struct list_head *list, struct list_head *head) + { + if (!list_empty(list)) + __list_splice(list, head); + } + + /** + * list_splice_init - join two lists and reinitialise the emptied list. + * @list: the new list to add. + * @head: the place to add it in the first list. + * + * The list at @list is reinitialised + */ + static inline void list_splice_init(struct list_head *list, + struct list_head *head) + { + if (!list_empty(list)) { + __list_splice(list, head); + INIT_LIST_HEAD(list); + } + } + + /** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ + #define list_entry(ptr, type, member) \ + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + + /** + * list_for_each - iterate over a list + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + */ + #define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); \ + pos = pos->next) + /** + * list_for_each_prev - iterate over a list backwards + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + */ + #define list_for_each_prev(pos, head) \ + for (pos = (head)->prev; pos != (head); \ + pos = pos->prev) + +/** + * list_for_each_safe - iterate over a list safe against removal of list entry + * @pos: the &struct list_head to use as a loop counter. + * @n: another &struct list_head to use as temporary storage + * @head: the head for your list. + */ + #define list_for_each_safe(pos, n, head) \ + for (pos = (head)->next, n = pos->next; pos != (head); \ + pos = n, n = pos->next) + + /** + * list_for_each_entry - iterate over list of given type + * @pos: the type * to use as a loop counter. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ + #define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member)) + + /** + * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry + * @pos: the type * to use as a loop counter. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ + #define list_for_each_entry_safe(pos, n, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member), \ + n = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.next, typeof(*n), member)) + + /** + * list_for_each_entry_continue - iterate over list of given type + * continuing after existing point + * @pos: the type * to use as a loop counter. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ + #define list_for_each_entry_continue(pos, head, member) \ + for (pos = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member)) + + #endif diff --git a/drivers/bus/acpi/main.c b/drivers/bus/acpi/main.c new file mode 100644 index 00000000000..d8d8b3e7dad --- /dev/null +++ b/drivers/bus/acpi/main.c @@ -0,0 +1,218 @@ +#include + +#include +#include + +#include +#include + +//#define NDEBUG +#include + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (INIT, DriverEntry) +#pragma alloc_text (PAGE, Bus_AddDevice) + +#endif + + + +NTSTATUS +NTAPI +Bus_AddDevice( + PDRIVER_OBJECT DriverObject, + PDEVICE_OBJECT PhysicalDeviceObject + ) + +{ + NTSTATUS status; + PDEVICE_OBJECT deviceObject = NULL; + PFDO_DEVICE_DATA deviceData = NULL; + PWCHAR deviceName = NULL; + ULONG nameLength; + + PAGED_CODE (); + + DPRINT("Add Device: 0x%p\n", PhysicalDeviceObject); + + DPRINT1("#################### Bus_CreateClose Creating FDO Device ####################\n"); + status = IoCreateDevice(DriverObject, + sizeof(FDO_DEVICE_DATA), + NULL, + FILE_DEVICE_ACPI, + FILE_DEVICE_SECURE_OPEN, + TRUE, + &deviceObject); + if (!NT_SUCCESS(status)) + { + DPRINT1("IoCreateDevice() failed with status 0x%X\n", status); + goto End; + } + + deviceData = (PFDO_DEVICE_DATA) deviceObject->DeviceExtension; + RtlZeroMemory (deviceData, sizeof (FDO_DEVICE_DATA)); + + // + // Set the initial state of the FDO + // + + INITIALIZE_PNP_STATE(deviceData->Common); + + deviceData->Common.IsFDO = TRUE; + + deviceData->Common.Self = deviceObject; + + ExInitializeFastMutex (&deviceData->Mutex); + + InitializeListHead (&deviceData->ListOfPDOs); + + // Set the PDO for use with PlugPlay functions + + deviceData->UnderlyingPDO = PhysicalDeviceObject; + + // + // Set the initial powerstate of the FDO + // + + deviceData->Common.DevicePowerState = PowerDeviceUnspecified; + deviceData->Common.SystemPowerState = PowerSystemWorking; + + deviceObject->Flags |= DO_POWER_PAGABLE; + + // + // Attach our FDO to the device stack. + // The return value of IoAttachDeviceToDeviceStack is the top of the + // attachment chain. This is where all the IRPs should be routed. + // + + deviceData->NextLowerDriver = IoAttachDeviceToDeviceStack ( + deviceObject, + PhysicalDeviceObject); + + if (NULL == deviceData->NextLowerDriver) { + + status = STATUS_NO_SUCH_DEVICE; + goto End; + } + + +#ifndef NDEBUG + // + // We will demonstrate here the step to retrieve the name of the PDO + // + + status = IoGetDeviceProperty (PhysicalDeviceObject, + DevicePropertyPhysicalDeviceObjectName, + 0, + NULL, + &nameLength); + + if (status != STATUS_BUFFER_TOO_SMALL) + { + DPRINT1("AddDevice:IoGDP failed (0x%x)\n", status); + goto End; + } + + deviceName = ExAllocatePoolWithTag (NonPagedPool, + nameLength, 'IPCA'); + + if (NULL == deviceName) { + DPRINT1("AddDevice: no memory to alloc for deviceName(0x%x)\n", nameLength); + status = STATUS_INSUFFICIENT_RESOURCES; + goto End; + } + + status = IoGetDeviceProperty (PhysicalDeviceObject, + DevicePropertyPhysicalDeviceObjectName, + nameLength, + deviceName, + &nameLength); + + if (!NT_SUCCESS (status)) { + + DPRINT1("AddDevice:IoGDP(2) failed (0x%x)", status); + goto End; + } + + DPRINT1("AddDevice: %p to %p->%p (%ws) \n", + deviceObject, + deviceData->NextLowerDriver, + PhysicalDeviceObject, + deviceName); + +#endif + + // + // We are done with initializing, so let's indicate that and return. + // This should be the final step in the AddDevice process. + // + deviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + +End: + if (deviceName){ + ExFreePool(deviceName); + } + if (!NT_SUCCESS(status) && deviceObject){ + if (deviceData && deviceData->NextLowerDriver){ + IoDetachDevice (deviceData->NextLowerDriver); + } + IoDeleteDevice (deviceObject); + } + return status; + +} + +NTSTATUS +NTAPI +ACPIDispatchDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IrpSp; + NTSTATUS Status; + + DPRINT("Called. IRP is at (0x%X)\n", Irp); + + Irp->IoStatus.Information = 0; + + IrpSp = IoGetCurrentIrpStackLocation(Irp); + switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) { + default: + DPRINT("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode); + Status = STATUS_NOT_IMPLEMENTED; + break; + } + + if (Status != STATUS_PENDING) { + Irp->IoStatus.Status = Status; + + DPRINT("Completing IRP at 0x%X\n", Irp); + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + + DPRINT("Leaving. Status 0x%X\n", Status); + + return Status; +} + +NTSTATUS +NTAPI +DriverEntry ( + PDRIVER_OBJECT DriverObject, + PUNICODE_STRING RegistryPath + ) +{ + DPRINT("Driver Entry \n"); + + // + // Set entry points into the driver + // + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ACPIDispatchDeviceControl; + DriverObject->MajorFunction [IRP_MJ_PNP] = Bus_PnP; + DriverObject->MajorFunction [IRP_MJ_POWER] = Bus_Power; + + DriverObject->DriverExtension->AddDevice = Bus_AddDevice; + + return STATUS_SUCCESS; +} diff --git a/drivers/bus/acpi/osl.c b/drivers/bus/acpi/osl.c new file mode 100644 index 00000000000..be26a0811f9 --- /dev/null +++ b/drivers/bus/acpi/osl.c @@ -0,0 +1,752 @@ +/******************************************************************************* +* * +* ACPI Component Architecture Operating System Layer (OSL) for ReactOS * +* * +*******************************************************************************/ +#include + +#include + +#define NDEBUG +#include + +#define NUM_SEMAPHORES 128 + +static PKINTERRUPT AcpiInterrupt; +static BOOLEAN AcpiInterruptHandlerRegistered = FALSE; +static ACPI_OSD_HANDLER AcpiIrqHandler = NULL; +static PVOID AcpiIrqContext = NULL; +static ULONG AcpiIrqNumber = 0; +static KDPC AcpiDpc; +static PVOID IVTVirtualAddress = NULL; + + +typedef struct semaphore_entry +{ + UINT16 MaxUnits; + UINT16 CurrentUnits; + void *OsHandle; +} SEMAPHORE_ENTRY; + +static SEMAPHORE_ENTRY AcpiGbl_Semaphores[NUM_SEMAPHORES]; + +VOID NTAPI +OslDpcStub( + IN PKDPC Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2) +{ + ACPI_OSD_EXEC_CALLBACK Routine = (ACPI_OSD_EXEC_CALLBACK)SystemArgument1; + + DPRINT("OslDpcStub()\n"); + DPRINT("Calling [%p]([%p])\n", Routine, SystemArgument2); + (*Routine)(SystemArgument2); +} + +BOOLEAN NTAPI +OslIsrStub( + PKINTERRUPT Interrupt, + PVOID ServiceContext) +{ + INT32 Status; + + Status = (*AcpiIrqHandler)(AcpiIrqContext); + + if (ACPI_SUCCESS(Status)) + return TRUE; + else + return FALSE; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine); + +ACPI_STATUS +AcpiOsInitialize (void) +{ + DPRINT("AcpiOsInitialize called\n"); + +#ifndef NDEBUG + /* Verboseness level of the acpica core */ + AcpiDbgLevel = 0x00FFFFFF; + AcpiDbgLayer = 0xFFFFFFFF; +#endif + + UINT32 i; + + for (i = 0; i < NUM_SEMAPHORES; i++) + { + AcpiGbl_Semaphores[i].OsHandle = NULL; + } + + KeInitializeDpc(&AcpiDpc, OslDpcStub, NULL); + + return AE_OK; +} + +ACPI_STATUS +AcpiOsTerminate(void) +{ + DPRINT1("AcpiOsTerminate() called\n"); + + if (AcpiInterruptHandlerRegistered) + AcpiOsRemoveInterruptHandler(AcpiIrqNumber, AcpiIrqHandler); + + return AE_OK; +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiOsPrintf ( + const char *Fmt, + ...) +{ + va_list Args; + va_start (Args, Fmt); + + AcpiOsVprintf (Fmt, Args); + + va_end (Args); + return; +} + +void +AcpiOsVprintf ( + const char *Fmt, + va_list Args) +{ + vDbgPrintEx (-1, DPFLTR_ERROR_LEVEL, Fmt, Args); + return; +} + +void * +AcpiOsAllocate (ACPI_SIZE size) +{ + DPRINT("AcpiOsAllocate size %d\n",size); + return ExAllocatePool(NonPagedPool, size); +} + +void * +AcpiOsCallocate(ACPI_SIZE size) +{ + PVOID ptr = ExAllocatePool(NonPagedPool, size); + if (ptr) + memset(ptr, 0, size); + return ptr; +} + +void +AcpiOsFree(void *ptr) +{ + if (!ptr) + DPRINT1("Attempt to free null pointer!!!\n"); + ExFreePool(ptr); +} + +#ifndef ACPI_USE_LOCAL_CACHE + +void* +AcpiOsAcquireObjectHelper ( + POOL_TYPE PoolType, + SIZE_T NumberOfBytes, + ULONG Tag) +{ + void* Alloc = ExAllocatePool(PoolType, NumberOfBytes); + + /* acpica expects memory allocated from cache to be zeroed */ + RtlZeroMemory(Alloc,NumberOfBytes); + return Alloc; +} + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache) +{ + PNPAGED_LOOKASIDE_LIST Lookaside = + ExAllocatePool(NonPagedPool,sizeof(NPAGED_LOOKASIDE_LIST)); + + ExInitializeNPagedLookasideList(Lookaside, + (PALLOCATE_FUNCTION)AcpiOsAcquireObjectHelper,// custom memory allocator + NULL, + 0, + ObjectSize, + 'IPCA', + 0); + *ReturnCache = (ACPI_CACHE_T *)Lookaside; + + DPRINT("AcpiOsCreateCache %p\n", Lookaside); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsDeleteCache %p\n", Cache); + ExDeleteNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST) Cache); + ExFreePool(Cache); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsPurgeCache\n"); + /* No such functionality for LookAside lists */ + return (AE_OK); +} + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache) +{ + PNPAGED_LOOKASIDE_LIST List = (PNPAGED_LOOKASIDE_LIST)Cache; + DPRINT("AcpiOsAcquireObject from %p\n", Cache); + void* ptr = + ExAllocateFromNPagedLookasideList(List); + ASSERT(ptr); + + RtlZeroMemory(ptr,List->L.Size); + return ptr; +} + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object) +{ + DPRINT("AcpiOsReleaseObject %p from %p\n",Object, Cache); + ExFreeToNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST)Cache, + Object); + return (AE_OK); +} + +#endif + +void * +AcpiOsMapMemory ( + ACPI_PHYSICAL_ADDRESS phys, + ACPI_SIZE length) +{ + PHYSICAL_ADDRESS Address; + + DPRINT("AcpiOsMapMemory(phys 0x%X size 0x%X)\n", (ULONG)phys, length); + if (phys == 0x0) + { + IVTVirtualAddress = ExAllocatePool(NonPagedPool, length); + return IVTVirtualAddress; + } + + Address.QuadPart = (ULONG)phys; + return MmMapIoSpace(Address, length, MmNonCached); +} + +void +AcpiOsUnmapMemory ( + void *virt, + ACPI_SIZE length) +{ + DPRINT("AcpiOsUnmapMemory()\n"); + + if (virt == 0x0) + { + ExFreePool(IVTVirtualAddress); + return; + } + MmUnmapIoSpace(virt, length); +} + +UINT32 +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine, + void *Context) +{ + ULONG Vector; + KIRQL DIrql; + KAFFINITY Affinity; + NTSTATUS Status; + + DPRINT("AcpiOsInstallInterruptHandler()\n"); + Vector = HalGetInterruptVector( + Internal, + 0, + InterruptNumber, + 0, + &DIrql, + &Affinity); + + AcpiIrqNumber = InterruptNumber; + AcpiIrqHandler = ServiceRoutine; + AcpiIrqContext = Context; + AcpiInterruptHandlerRegistered = TRUE; + + Status = IoConnectInterrupt( + &AcpiInterrupt, + OslIsrStub, + NULL, + NULL, + Vector, + DIrql, + DIrql, + LevelSensitive, /* FIXME: LevelSensitive or Latched? */ + TRUE, + Affinity, + FALSE); + + if (!NT_SUCCESS(Status)) + { + DPRINT("Could not connect to interrupt %d\n", Vector); + return AE_ERROR; + } + return AE_OK; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine) +{ + DPRINT("AcpiOsRemoveInterruptHandler()\n"); + if (AcpiInterruptHandlerRegistered) + { + IoDisconnectInterrupt(AcpiInterrupt); + AcpiInterrupt = NULL; + AcpiInterruptHandlerRegistered = FALSE; + } + + return AE_OK; +} + +void +AcpiOsStall (UINT32 microseconds) +{ + DPRINT1("AcpiOsStall %d\n",microseconds); + KeStallExecutionProcessor(microseconds); + return; +} + +void +AcpiOsSleep (ACPI_INTEGER milliseconds) +{ + DPRINT1("AcpiOsSleep %d\n", milliseconds); + KeStallExecutionProcessor(milliseconds*1000); + return; +} + +ACPI_STATUS +AcpiOsReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadPort %p, width %d\n",Address,Width); + + switch (Width) + { + case 8: + *Value = READ_PORT_UCHAR((PUCHAR)Address); + break; + + case 16: + *Value = READ_PORT_USHORT((PUSHORT)Address); + break; + + case 32: + *Value = READ_PORT_ULONG((PULONG)Address); + break; + default: + DPRINT1("AcpiOsReadPort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWritePort %p, width %d\n",Address,Width); + switch (Width) + { + case 8: + WRITE_PORT_UCHAR((PUCHAR)Address, Value); + break; + + case 16: + WRITE_PORT_USHORT((PUSHORT)Address, Value); + break; + + case 32: + WRITE_PORT_ULONG((PULONG)Address, Value); + break; + + default: + DPRINT1("AcpiOsWritePort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadMemory %p\n", Address); + switch (Width) + { + case 8: + *Value = (*(PUCHAR)(ULONG)Address); + break; + case 16: + *Value = (*(PUSHORT)(ULONG)Address); + break; + case 32: + *Value = (*(PULONG)(ULONG)Address); + break; + + default: + DPRINT1("AcpiOsReadMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + + +ACPI_STATUS +AcpiOsWriteMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWriteMemory %p\n", Address); + switch (Width) + { + case 8: + *(PUCHAR)(ULONG)Address = Value; + break; + case 16: + *(PUSHORT)(ULONG)Address = Value; + break; + case 32: + *(PULONG)(ULONG)Address = Value; + break; + + default: + DPRINT1("AcpiOsWriteMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadPciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + void *Value, + UINT32 Width) +{ + NTSTATUS Status; + PCI_SLOT_NUMBER slot; + + if (Register == 0) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Bus; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsReadPciConfiguration, slot=0x%X, func=0x%X\n", slot.u.AsULONG, Register); + Status = HalGetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + Value, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsWritePciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + ACPI_INTEGER Value, + UINT32 Width) +{ + NTSTATUS Status; + ULONG buf = Value; + PCI_SLOT_NUMBER slot; + + if (Register == 0) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Bus; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsWritePciConfiguration, slot=0x%x\n", slot.u.AsULONG); + Status = HalSetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + &buf, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_SEMAPHORE *OutHandle) +{ + PFAST_MUTEX Mutex; + + Mutex = ExAllocatePool(NonPagedPool, sizeof(FAST_MUTEX)); + if (!Mutex) + return AE_NO_MEMORY; + + DPRINT("AcpiOsCreateSemaphore() at 0x%X\n", Mutex); + + ExInitializeFastMutex(Mutex); + + *OutHandle = Mutex; + return AE_OK; +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_SEMAPHORE Handle) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsDeleteSemaphore(handle 0x%X)\n", Handle); + + if (!Mutex) + return AE_BAD_PARAMETER; + + ExFreePool(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsWaitSemaphore( + ACPI_SEMAPHORE Handle, + UINT32 units, + UINT16 timeout) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + if (!Mutex || (units < 1)) + { + DPRINT("AcpiOsWaitSemaphore(handle 0x%X, units %d) Bad parameters\n", + Mutex, units); + return AE_BAD_PARAMETER; + } + + DPRINT("Waiting for semaphore %p\n", Handle); + ASSERT(Mutex); + + ExAcquireFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsSignalSemaphore %p\n",Handle); + ASSERT(Mutex); + + ExReleaseFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle) +{ + DPRINT("AcpiOsCreateLock\n"); + return (AcpiOsCreateSemaphore (1, 1, OutHandle)); +} + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle) +{ + DPRINT("AcpiOsDeleteLock %p\n", Handle); + AcpiOsDeleteSemaphore (Handle); +} + + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_HANDLE Handle) +{ + DPRINT("AcpiOsAcquireLock, %p\n", Handle); + AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); + return (0); +} + + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags) +{ + DPRINT("AcpiOsReleaseLock %p\n",Handle); + AcpiOsSignalSemaphore (Handle, 1); +} + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info) +{ + + switch (Function) + { + case ACPI_SIGNAL_FATAL: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + case ACPI_SIGNAL_BREAKPOINT: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + } + + return (AE_OK); +} + + +ACPI_THREAD_ID +AcpiOsGetThreadId (void) +{ + return (ULONG)PsGetCurrentThreadId(); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + DPRINT1("AcpiOsExecute\n"); + + KeInsertQueueDpc(&AcpiDpc, (PVOID)Function, (PVOID)Context); + +#ifdef _MULTI_THREADED + //_beginthread (Function, (unsigned) 0, Context); +#endif + + return 0; +} + +UINT64 +AcpiOsGetTimer (void) +{ + DPRINT("AcpiOsGetTimer\n"); + LARGE_INTEGER Timer; + KeQueryTickCount(&Timer); + + return Timer.QuadPart; +} + +void +AcpiOsDerivePciId( + ACPI_HANDLE rhandle, + ACPI_HANDLE chandle, + ACPI_PCI_ID **PciId) +{ + DPRINT("AcpiOsDerivePciId\n"); + return; +} + +ACPI_STATUS +AcpiOsPredefinedOverride ( + const ACPI_PREDEFINED_NAMES *InitVal, + ACPI_STRING *NewVal) +{ + if (!InitVal || !NewVal) + return AE_BAD_PARAMETER; + + *NewVal = ACPI_OS_NAME; + DPRINT("AcpiOsPredefinedOverride\n"); + return AE_OK; +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void); + +ACPI_STATUS +AcpiOsTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable) +{ + DPRINT("AcpiOsTableOverride\n"); + *NewTable = NULL; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateInterface ( + char *Interface) +{ + DPRINT("AcpiOsValidateInterface\n"); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateAddress ( + UINT8 SpaceId, + ACPI_PHYSICAL_ADDRESS Address, + ACPI_SIZE Length) +{ + DPRINT("AcpiOsValidateAddress\n"); + return (AE_OK); +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void) +{ + DPRINT("AcpiOsGetRootPointer\n"); + ACPI_PHYSICAL_ADDRESS pa = 0; + + AcpiFindRootPointer(&pa); + return pa; +} diff --git a/drivers/bus/acpi/pnp.c b/drivers/bus/acpi/pnp.c new file mode 100644 index 00000000000..4778dc66c2e --- /dev/null +++ b/drivers/bus/acpi/pnp.c @@ -0,0 +1,586 @@ +#include + +#include + +#include +#include +#include + +#include +//#define NDEBUG +#include + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (PAGE, Bus_PnP) +#pragma alloc_text (PAGE, Bus_PlugInDevice) +#pragma alloc_text (PAGE, Bus_InitializePdo) +#pragma alloc_text (PAGE, Bus_UnPlugDevice) +#pragma alloc_text (PAGE, Bus_DestroyPdo) +#pragma alloc_text (PAGE, Bus_FDO_PnP) +#pragma alloc_text (PAGE, Bus_StartFdo) +#pragma alloc_text (PAGE, Bus_SendIrpSynchronously) +#endif + + +NTSTATUS +NTAPI +Bus_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +{ + PIO_STACK_LOCATION irpStack; + NTSTATUS status; + PCOMMON_DEVICE_DATA commonData; + + PAGED_CODE (); + + irpStack = IoGetCurrentIrpStackLocation (Irp); + ASSERT (IRP_MJ_PNP == irpStack->MajorFunction); + + commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension; + + + if (commonData->IsFDO) { + DPRINT("FDO %s IRP:0x%p\n", + PnPMinorFunctionString(irpStack->MinorFunction), + Irp); + // + // Request is for the bus FDO + // + status = Bus_FDO_PnP ( + DeviceObject, + Irp, + irpStack, + (PFDO_DEVICE_DATA) commonData); + } else { + DPRINT("PDO %s IRP: 0x%p\n", + PnPMinorFunctionString(irpStack->MinorFunction), + Irp); + // + // Request is for the child PDO. + // + status = Bus_PDO_PnP ( + DeviceObject, + Irp, + irpStack, + (PPDO_DEVICE_DATA) commonData); + } + + return status; +} + +NTSTATUS +Bus_FDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PFDO_DEVICE_DATA DeviceData + ) +{ + NTSTATUS status; + ULONG length, prevcount, numPdosPresent; + PLIST_ENTRY entry; + PPDO_DEVICE_DATA pdoData; + PDEVICE_RELATIONS relations, oldRelations; + + PAGED_CODE (); + + switch (IrpStack->MinorFunction) { + + case IRP_MN_START_DEVICE: + + status = Bus_StartFdo (DeviceData, Irp); + + + // + // We must now complete the IRP, since we stopped it in the + // completion routine with MORE_PROCESSING_REQUIRED. + // + + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + return status; + + case IRP_MN_QUERY_STOP_DEVICE: + + // + // The PnP manager is trying to stop the device + // for resource rebalancing. + // + SET_NEW_PNP_STATE(DeviceData->Common, StopPending); + Irp->IoStatus.Status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: + + // + // The PnP Manager sends this IRP, at some point after an + // IRP_MN_QUERY_STOP_DEVICE, to inform the drivers for a + // device that the device will not be stopped for + // resource reconfiguration. + // + // + // First check to see whether you have received cancel-stop + // without first receiving a query-stop. This could happen if + // someone above us fails a query-stop and passes down the subsequent + // cancel-stop. + // + + if (StopPending == DeviceData->Common.DevicePnPState) + { + // + // We did receive a query-stop, so restore. + // + RESTORE_PREVIOUS_PNP_STATE(DeviceData->Common); + ASSERT(DeviceData->Common.DevicePnPState == Started); + } + Irp->IoStatus.Status = STATUS_SUCCESS; // We must not fail the IRP. + break; + + case IRP_MN_QUERY_DEVICE_RELATIONS: + + DPRINT("\tQueryDeviceRelation Type: %s\n", + DbgDeviceRelationString(\ + IrpStack->Parameters.QueryDeviceRelations.Type)); + + if (BusRelations != IrpStack->Parameters.QueryDeviceRelations.Type) { + // + // We don't support any other Device Relations + // + break; + } + + + ExAcquireFastMutex (&DeviceData->Mutex); + + oldRelations = (PDEVICE_RELATIONS) Irp->IoStatus.Information; + if (oldRelations) { + prevcount = oldRelations->Count; + if (!DeviceData->NumPDOs) { + // + // There is a device relations struct already present and we have + // nothing to add to it, so just call IoSkip and IoCall + // + ExReleaseFastMutex (&DeviceData->Mutex); + break; + } + } + else { + prevcount = 0; + } + + // + // Calculate the number of PDOs actually present on the bus + // + numPdosPresent = 0; + for (entry = DeviceData->ListOfPDOs.Flink; + entry != &DeviceData->ListOfPDOs; + entry = entry->Flink) { + pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); + numPdosPresent++; + } + + // + // Need to allocate a new relations structure and add our + // PDOs to it. + // + + length = sizeof(DEVICE_RELATIONS) + + ((numPdosPresent + prevcount) * sizeof (PDEVICE_OBJECT)) -1; + + relations = (PDEVICE_RELATIONS) ExAllocatePoolWithTag (PagedPool, + length, 'IPCA'); + + if (NULL == relations) { + // + // Fail the IRP + // + ExReleaseFastMutex (&DeviceData->Mutex); + Irp->IoStatus.Status = status = STATUS_INSUFFICIENT_RESOURCES; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + return status; + + } + + // + // Copy in the device objects so far + // + if (prevcount) { + RtlCopyMemory (relations->Objects, oldRelations->Objects, + prevcount * sizeof (PDEVICE_OBJECT)); + } + + relations->Count = prevcount + numPdosPresent; + + // + // For each PDO present on this bus add a pointer to the device relations + // buffer, being sure to take out a reference to that object. + // The Plug & Play system will dereference the object when it is done + // with it and free the device relations buffer. + // + + for (entry = DeviceData->ListOfPDOs.Flink; + entry != &DeviceData->ListOfPDOs; + entry = entry->Flink) { + + pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); + relations->Objects[prevcount] = pdoData->Common.Self; + ObReferenceObject (pdoData->Common.Self); + prevcount++; + } + + DPRINT("\t#PDOs present = %d\n\t#PDOs reported = %d\n", + DeviceData->NumPDOs, relations->Count); + + // + // Replace the relations structure in the IRP with the new + // one. + // + if (oldRelations) { + ExFreePool (oldRelations); + } + Irp->IoStatus.Information = (ULONG_PTR) relations; + + ExReleaseFastMutex (&DeviceData->Mutex); + + // + // Set up and pass the IRP further down the stack + // + Irp->IoStatus.Status = STATUS_SUCCESS; + break; + + default: + + // + // In the default case we merely call the next driver. + // We must not modify Irp->IoStatus.Status or complete the IRP. + // + + break; + } + + IoSkipCurrentIrpStackLocation (Irp); + status = IoCallDriver (DeviceData->NextLowerDriver, Irp); + return STATUS_SUCCESS; +} + +NTSTATUS +Bus_StartFdo ( + PFDO_DEVICE_DATA FdoData, + PIRP Irp ) +{ + NTSTATUS status = STATUS_SUCCESS; + POWER_STATE powerState; + ACPI_STATUS AcpiStatus; + + PAGED_CODE (); + + FdoData->Common.DevicePowerState = PowerDeviceD0; + powerState.DeviceState = PowerDeviceD0; + PoSetPowerState ( FdoData->Common.Self, DevicePowerState, powerState ); + + SET_NEW_PNP_STATE(FdoData->Common, Started); + + AcpiStatus = AcpiInitializeSubsystem(); + if(ACPI_FAILURE(AcpiStatus)){ + DPRINT1("Unable to AcpiInitializeSubsystem\n"); + return STATUS_UNSUCCESSFUL; + } + + + AcpiStatus = AcpiInitializeTables(NULL, 16, 0); + if (ACPI_FAILURE(status)){ + DPRINT1("Unable to AcpiInitializeSubsystem\n"); + return STATUS_UNSUCCESSFUL; + } + + AcpiStatus = AcpiLoadTables(); + if(ACPI_FAILURE(AcpiStatus)){ + DPRINT1("Unable to AcpiLoadTables\n"); + AcpiTerminate(); + return STATUS_UNSUCCESSFUL; + } + + DPRINT("Acpi subsystem init\n"); + /* Initialize ACPI bus manager */ + AcpiStatus = acpi_init(); + if (!ACPI_SUCCESS(AcpiStatus)) { + DPRINT("acpi_init() failed with status 0x%X\n", AcpiStatus); + AcpiTerminate(); + return STATUS_UNSUCCESSFUL; + } + status = ACPIEnumerateDevices(FdoData); + + return status; +} + +NTSTATUS +Bus_SendIrpSynchronously ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +{ + KEVENT event; + NTSTATUS status; + + PAGED_CODE(); + + KeInitializeEvent(&event, NotificationEvent, FALSE); + + IoCopyCurrentIrpStackLocationToNext(Irp); + + IoSetCompletionRoutine(Irp, + Bus_CompletionRoutine, + &event, + TRUE, + TRUE, + TRUE + ); + + status = IoCallDriver(DeviceObject, Irp); + + // + // Wait for lower drivers to be done with the Irp. + // Important thing to note here is when you allocate + // the memory for an event in the stack you must do a + // KernelMode wait instead of UserMode to prevent + // the stack from getting paged out. + // + + if (status == STATUS_PENDING) { + KeWaitForSingleObject(&event, + Executive, + KernelMode, + FALSE, + NULL + ); + status = Irp->IoStatus.Status; + } + + return status; +} + +NTSTATUS +Bus_CompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context + ) +{ + UNREFERENCED_PARAMETER (DeviceObject); + + // + // If the lower driver didn't return STATUS_PENDING, we don't need to + // set the event because we won't be waiting on it. + // This optimization avoids grabbing the dispatcher lock and improves perf. + // + if (Irp->PendingReturned == TRUE) { + + KeSetEvent ((PKEVENT) Context, IO_NO_INCREMENT, FALSE); + } + return STATUS_MORE_PROCESSING_REQUIRED; // Keep this IRP +} + +NTSTATUS +Bus_DestroyPdo ( + PDEVICE_OBJECT Device, + PPDO_DEVICE_DATA PdoData + ) +{ + PAGED_CODE (); + + // + // BusEnum does not queue any irps at this time so we have nothing to do. + // + + // + // Free any resources. + // + + if (PdoData->HardwareIDs) { + ExFreePool (PdoData->HardwareIDs); + PdoData->HardwareIDs = NULL; + } + + DPRINT("\tDeleting PDO: 0x%p\n", Device); + IoDeleteDevice (Device); + return STATUS_SUCCESS; +} + + +VOID +Bus_InitializePdo ( + PDEVICE_OBJECT Pdo, + PFDO_DEVICE_DATA FdoData + ) +{ + PPDO_DEVICE_DATA pdoData; + int acpistate; + DEVICE_POWER_STATE ntState; + + PAGED_CODE (); + + pdoData = (PPDO_DEVICE_DATA) Pdo->DeviceExtension; + + DPRINT("pdo 0x%p, extension 0x%p\n", Pdo, pdoData); + + if (pdoData->AcpiHandle) + acpi_bus_get_power(pdoData->AcpiHandle, &acpistate); + else + acpistate = ACPI_STATE_D0; + + switch(acpistate) + { + case ACPI_STATE_D0: + ntState = PowerDeviceD0; + break; + case ACPI_STATE_D1: + ntState = PowerDeviceD1; + break; + case ACPI_STATE_D2: + ntState = PowerDeviceD2; + break; + case ACPI_STATE_D3: + ntState = PowerDeviceD3; + break; + default: + DPRINT1("Unknown power state (%d) returned by acpi\n",acpistate); + ntState = PowerDeviceUnspecified; + break; + } + + // + // Initialize the rest + // + pdoData->Common.IsFDO = FALSE; + pdoData->Common.Self = Pdo; + + pdoData->ParentFdo = FdoData->Common.Self; + + + INITIALIZE_PNP_STATE(pdoData->Common); + + pdoData->Common.DevicePowerState = ntState; + pdoData->Common.SystemPowerState = FdoData->Common.SystemPowerState; + + Pdo->Flags |= DO_POWER_PAGABLE; + + ExAcquireFastMutex (&FdoData->Mutex); + InsertTailList(&FdoData->ListOfPDOs, &pdoData->Link); + FdoData->NumPDOs++; + ExReleaseFastMutex (&FdoData->Mutex); + + // This should be the last step in initialization. + Pdo->Flags &= ~DO_DEVICE_INITIALIZING; + +} + +#if DBG + +PCHAR +PnPMinorFunctionString ( + UCHAR MinorFunction +) +{ + switch (MinorFunction) + { + case IRP_MN_START_DEVICE: + return "IRP_MN_START_DEVICE"; + case IRP_MN_QUERY_REMOVE_DEVICE: + return "IRP_MN_QUERY_REMOVE_DEVICE"; + case IRP_MN_REMOVE_DEVICE: + return "IRP_MN_REMOVE_DEVICE"; + case IRP_MN_CANCEL_REMOVE_DEVICE: + return "IRP_MN_CANCEL_REMOVE_DEVICE"; + case IRP_MN_STOP_DEVICE: + return "IRP_MN_STOP_DEVICE"; + case IRP_MN_QUERY_STOP_DEVICE: + return "IRP_MN_QUERY_STOP_DEVICE"; + case IRP_MN_CANCEL_STOP_DEVICE: + return "IRP_MN_CANCEL_STOP_DEVICE"; + case IRP_MN_QUERY_DEVICE_RELATIONS: + return "IRP_MN_QUERY_DEVICE_RELATIONS"; + case IRP_MN_QUERY_INTERFACE: + return "IRP_MN_QUERY_INTERFACE"; + case IRP_MN_QUERY_CAPABILITIES: + return "IRP_MN_QUERY_CAPABILITIES"; + case IRP_MN_QUERY_RESOURCES: + return "IRP_MN_QUERY_RESOURCES"; + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: + return "IRP_MN_QUERY_RESOURCE_REQUIREMENTS"; + case IRP_MN_QUERY_DEVICE_TEXT: + return "IRP_MN_QUERY_DEVICE_TEXT"; + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: + return "IRP_MN_FILTER_RESOURCE_REQUIREMENTS"; + case IRP_MN_READ_CONFIG: + return "IRP_MN_READ_CONFIG"; + case IRP_MN_WRITE_CONFIG: + return "IRP_MN_WRITE_CONFIG"; + case IRP_MN_EJECT: + return "IRP_MN_EJECT"; + case IRP_MN_SET_LOCK: + return "IRP_MN_SET_LOCK"; + case IRP_MN_QUERY_ID: + return "IRP_MN_QUERY_ID"; + case IRP_MN_QUERY_PNP_DEVICE_STATE: + return "IRP_MN_QUERY_PNP_DEVICE_STATE"; + case IRP_MN_QUERY_BUS_INFORMATION: + return "IRP_MN_QUERY_BUS_INFORMATION"; + case IRP_MN_DEVICE_USAGE_NOTIFICATION: + return "IRP_MN_DEVICE_USAGE_NOTIFICATION"; + case IRP_MN_SURPRISE_REMOVAL: + return "IRP_MN_SURPRISE_REMOVAL"; + case IRP_MN_QUERY_LEGACY_BUS_INFORMATION: + return "IRP_MN_QUERY_LEGACY_BUS_INFORMATION"; + default: + return "unknown_pnp_irp"; + } +} + +PCHAR +DbgDeviceRelationString( + DEVICE_RELATION_TYPE Type + ) +{ + switch (Type) + { + case BusRelations: + return "BusRelations"; + case EjectionRelations: + return "EjectionRelations"; + case RemovalRelations: + return "RemovalRelations"; + case TargetDeviceRelation: + return "TargetDeviceRelation"; + default: + return "UnKnown Relation"; + } +} + +PCHAR +DbgDeviceIDString( + BUS_QUERY_ID_TYPE Type + ) +{ + switch (Type) + { + case BusQueryDeviceID: + return "BusQueryDeviceID"; + case BusQueryHardwareIDs: + return "BusQueryHardwareIDs"; + case BusQueryCompatibleIDs: + return "BusQueryCompatibleIDs"; + case BusQueryInstanceID: + return "BusQueryInstanceID"; + case BusQueryDeviceSerialNumber: + return "BusQueryDeviceSerialNumber"; + default: + return "UnKnown ID"; + } +} + +#endif + + diff --git a/drivers/bus/acpi/power.c b/drivers/bus/acpi/power.c new file mode 100644 index 00000000000..3af99c96402 --- /dev/null +++ b/drivers/bus/acpi/power.c @@ -0,0 +1,302 @@ +#include + +#include +#include + +#include +#include + +//#define NDEBUG +#include + +NTSTATUS +NTAPI +Bus_Power ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +{ + PIO_STACK_LOCATION irpStack; + NTSTATUS status; + PCOMMON_DEVICE_DATA commonData; + + status = STATUS_SUCCESS; + irpStack = IoGetCurrentIrpStackLocation (Irp); + ASSERT (IRP_MJ_POWER == irpStack->MajorFunction); + + commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension; + + if (commonData->IsFDO) { + + DPRINT("FDO %s IRP:0x%p %s %s\n", + PowerMinorFunctionString(irpStack->MinorFunction), Irp, + DbgSystemPowerString(commonData->SystemPowerState), + DbgDevicePowerString(commonData->DevicePowerState)); + + + status = Bus_FDO_Power ((PFDO_DEVICE_DATA)DeviceObject->DeviceExtension, + Irp); + } else { + + DPRINT("PDO %s IRP:0x%p %s %s\n", + PowerMinorFunctionString(irpStack->MinorFunction), Irp, + DbgSystemPowerString(commonData->SystemPowerState), + DbgDevicePowerString(commonData->DevicePowerState)); + + status = Bus_PDO_Power ((PPDO_DEVICE_DATA)DeviceObject->DeviceExtension, + Irp); + } + + return status; +} + + +NTSTATUS +Bus_FDO_Power ( + PFDO_DEVICE_DATA Data, + PIRP Irp + ) +{ + NTSTATUS status = STATUS_SUCCESS; + POWER_STATE powerState; + POWER_STATE_TYPE powerType; + PIO_STACK_LOCATION stack; + ULONG AcpiState; + ACPI_STATUS AcpiStatus; + SYSTEM_POWER_STATE oldPowerState; + + stack = IoGetCurrentIrpStackLocation (Irp); + powerType = stack->Parameters.Power.Type; + powerState = stack->Parameters.Power.State; + + + if (stack->MinorFunction == IRP_MN_SET_POWER) { + DPRINT("\tRequest to set %s state to %s\n", + ((powerType == SystemPowerState) ? "System" : "Device"), + ((powerType == SystemPowerState) ? \ + DbgSystemPowerString(powerState.SystemState) :\ + DbgDevicePowerString(powerState.DeviceState))); + } + + if (powerType == SystemPowerState) + { + switch (powerState.SystemState) { + case PowerSystemSleeping1: + AcpiState = ACPI_STATE_S1; + break; + case PowerSystemSleeping2: + AcpiState = ACPI_STATE_S2; + break; + case PowerSystemSleeping3: + AcpiState = ACPI_STATE_S3; + break; + case PowerSystemHibernate: + AcpiState = ACPI_STATE_S4; + break; + case PowerSystemShutdown: + AcpiState = ACPI_STATE_S5; + break; + default: + AcpiState = ACPI_STATE_UNKNOWN; + ASSERT(FALSE); + break; + } + oldPowerState = Data->Common.SystemPowerState; + Data->Common.SystemPowerState = powerState.SystemState; + AcpiStatus = acpi_suspend(AcpiState); + if (!ACPI_SUCCESS(AcpiStatus)) { + DPRINT1("Failed to enter sleep state %d (Status 0x%X)\n", + AcpiState, AcpiStatus); + Data->Common.SystemPowerState = oldPowerState; + status = STATUS_UNSUCCESSFUL; + } + } + PoStartNextPowerIrp (Irp); + IoSkipCurrentIrpStackLocation(Irp); + status = PoCallDriver (Data->NextLowerDriver, Irp); + return status; +} + + +NTSTATUS +Bus_PDO_Power ( + PPDO_DEVICE_DATA PdoData, + PIRP Irp + ) +{ + NTSTATUS status; + PIO_STACK_LOCATION stack; + POWER_STATE powerState; + POWER_STATE_TYPE powerType; + ULONG error; + + stack = IoGetCurrentIrpStackLocation (Irp); + powerType = stack->Parameters.Power.Type; + powerState = stack->Parameters.Power.State; + + switch (stack->MinorFunction) { + case IRP_MN_SET_POWER: + + DPRINT("\tSetting %s power state to %s\n", + ((powerType == SystemPowerState) ? "System" : "Device"), + ((powerType == SystemPowerState) ? \ + DbgSystemPowerString(powerState.SystemState) : \ + DbgDevicePowerString(powerState.DeviceState))); + + switch (powerType) { + case DevicePowerState: + if (!PdoData->AcpiHandle || !acpi_bus_power_manageable(PdoData->AcpiHandle)) + { + PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState); + PdoData->Common.DevicePowerState = powerState.DeviceState; + status = STATUS_SUCCESS; + break; + } + + switch (powerState.DeviceState) + { + case PowerDeviceD0: + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D0); + break; + + case PowerDeviceD1: + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D1); + break; + + case PowerDeviceD2: + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D2); + break; + + case PowerDeviceD3: + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D3); + break; + + default: + error = 0; + break; + } + + if (ACPI_SUCCESS(error)) + { + PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState); + PdoData->Common.DevicePowerState = powerState.DeviceState; + status = STATUS_SUCCESS; + } + else + status = STATUS_UNSUCCESSFUL; + break; + + case SystemPowerState: + PdoData->Common.SystemPowerState = powerState.SystemState; + status = STATUS_SUCCESS; + break; + + default: + status = STATUS_NOT_SUPPORTED; + break; + } + break; + + case IRP_MN_QUERY_POWER: + status = STATUS_SUCCESS; + break; + + case IRP_MN_WAIT_WAKE: + // + // We cannot support wait-wake because we are root-enumerated + // driver, and our parent, the PnP manager, doesn't support wait-wake. + // + case IRP_MN_POWER_SEQUENCE: + default: + status = STATUS_NOT_SUPPORTED; + break; + } + + if (status != STATUS_NOT_SUPPORTED) { + + Irp->IoStatus.Status = status; + } + + PoStartNextPowerIrp(Irp); + status = Irp->IoStatus.Status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + return status; +} + +#ifndef NDEBUG + +PCHAR +PowerMinorFunctionString ( + UCHAR MinorFunction +) +{ + switch (MinorFunction) + { + case IRP_MN_SET_POWER: + return "IRP_MN_SET_POWER"; + case IRP_MN_QUERY_POWER: + return "IRP_MN_QUERY_POWER"; + case IRP_MN_POWER_SEQUENCE: + return "IRP_MN_POWER_SEQUENCE"; + case IRP_MN_WAIT_WAKE: + return "IRP_MN_WAIT_WAKE"; + + default: + return "unknown_power_irp"; + } +} + +PCHAR +DbgSystemPowerString( + SYSTEM_POWER_STATE Type + ) +{ + switch (Type) + { + case PowerSystemUnspecified: + return "PowerSystemUnspecified"; + case PowerSystemWorking: + return "PowerSystemWorking"; + case PowerSystemSleeping1: + return "PowerSystemSleeping1"; + case PowerSystemSleeping2: + return "PowerSystemSleeping2"; + case PowerSystemSleeping3: + return "PowerSystemSleeping3"; + case PowerSystemHibernate: + return "PowerSystemHibernate"; + case PowerSystemShutdown: + return "PowerSystemShutdown"; + case PowerSystemMaximum: + return "PowerSystemMaximum"; + default: + return "UnKnown System Power State"; + } + } + +PCHAR +DbgDevicePowerString( + DEVICE_POWER_STATE Type + ) +{ + switch (Type) + { + case PowerDeviceUnspecified: + return "PowerDeviceUnspecified"; + case PowerDeviceD0: + return "PowerDeviceD0"; + case PowerDeviceD1: + return "PowerDeviceD1"; + case PowerDeviceD2: + return "PowerDeviceD2"; + case PowerDeviceD3: + return "PowerDeviceD3"; + case PowerDeviceMaximum: + return "PowerDeviceMaximum"; + default: + return "UnKnown Device Power State"; + } +} + +#endif diff --git a/drivers/drivers.rbuild b/drivers/drivers.rbuild index 5cc82caaca0..970810f015d 100644 --- a/drivers/drivers.rbuild +++ b/drivers/drivers.rbuild @@ -4,6 +4,9 @@ + + + diff --git a/drivers/storage/ide/uniata/id_ata.cpp b/drivers/storage/ide/uniata/id_ata.cpp index 70976684235..5bb5cf74009 100644 --- a/drivers/storage/ide/uniata/id_ata.cpp +++ b/drivers/storage/ide/uniata/id_ata.cpp @@ -687,7 +687,7 @@ AtapiSoftReset( GetBaseStatus(chan, statusByte2); KdPrint2((PRINT_PREFIX " statusByte2 %x:\n", statusByte2)); SelectDrive(chan, DeviceNumber); - AtapiStallExecution(10000); + AtapiStallExecution(500); AtapiWritePort1(chan, IDX_IO1_o_Command, IDE_COMMAND_ATAPI_RESET); // ReactOS modification: Already stop looping when we know that the drive has finished resetting. diff --git a/drivers/storage/ide/uniata/id_probe.cpp b/drivers/storage/ide/uniata/id_probe.cpp index 752c88c826e..725f5ffe790 100644 --- a/drivers/storage/ide/uniata/id_probe.cpp +++ b/drivers/storage/ide/uniata/id_probe.cpp @@ -2723,6 +2723,7 @@ CheckDevice( signatureHigh; UCHAR statusByte; ULONG RetVal=0; + ULONG waitCount = 10000; KdPrint2((PRINT_PREFIX "CheckDevice: Device %#x\n", deviceNumber)); @@ -2745,7 +2746,22 @@ CheckDevice( // Perform hard-reset. KdPrint2((PRINT_PREFIX "CheckDevice: BUSY\n")); + + AtapiWritePort1(chan, IDX_IO2_o_Control, IDE_DC_RESET_CONTROLLER ); + AtapiStallExecution(500 * 1000); + AtapiWritePort1(chan, IDX_IO2_o_Control, IDE_DC_REENABLE_CONTROLLER); + SelectDrive(chan, deviceNumber & 0x01); + + do { + // Wait for Busy to drop. + AtapiStallExecution(100); + GetStatus(chan, statusByte); + + } while ((statusByte & IDE_STATUS_BUSY) && waitCount--); + GetBaseStatus(chan, statusByte); + KdPrint2((PRINT_PREFIX + "CheckDevice: status after hard reset %x\n", statusByte)); } if((statusByte | IDE_STATUS_BUSY) == 0xff) { diff --git a/drivers/video/displays/directory.rbuild b/drivers/video/displays/directory.rbuild index eb650854819..514fd432fd2 100644 --- a/drivers/video/displays/directory.rbuild +++ b/drivers/video/displays/directory.rbuild @@ -7,4 +7,7 @@ + + + diff --git a/drivers/video/displays/framebuf_new/debug.c b/drivers/video/displays/framebuf_new/debug.c new file mode 100755 index 00000000000..ada125df7ec --- /dev/null +++ b/drivers/video/displays/framebuf_new/debug.c @@ -0,0 +1,59 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/debug.c + * PURPOSE: Debug Support + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#include "driver.h" + +#if DBG + +ULONG DebugLevel = 0xFFFFFFFF; + +/***************************************************************************** + * + * Routine Description: + * + * This function is variable-argument, level-sensitive debug print + * routine. + * If the specified debug level for the print statement is lower or equal + * to the current debug level, the message will be printed. + * + * Arguments: + * + * DebugPrintLevel - Specifies at which debugging level the string should + * be printed + * + * DebugMessage - Variable argument ascii c string + * + * Return Value: + * + * None. + * + ***************************************************************************/ + +VOID +DebugPrint( + ULONG DebugPrintLevel, + PCHAR DebugMessage, + ... + ) + +{ + + va_list ap; + + va_start(ap, DebugMessage); + + if (DebugPrintLevel <= DebugLevel) + { + EngDebugPrint(STANDARD_DEBUG_PREFIX, DebugMessage, ap); + } + + va_end(ap); + +} + +#endif diff --git a/drivers/video/displays/framebuf_new/debug.h b/drivers/video/displays/framebuf_new/debug.h new file mode 100755 index 00000000000..d73a223baaf --- /dev/null +++ b/drivers/video/displays/framebuf_new/debug.h @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/debug.h + * PURPOSE: Debug Support Header + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#if DBG + +VOID +DebugPrint( + ULONG DebugPrintLevel, + PCHAR DebugMessage, + ... + ); + +#define DISPDBG(arg) DebugPrint arg +#define RIP(x) { DebugPrint(0, x); EngDebugBreak();} + +#else + +#define DISPDBG(arg) +#define RIP(x) + +#endif diff --git a/drivers/video/displays/framebuf_new/driver.h b/drivers/video/displays/framebuf_new/driver.h new file mode 100755 index 00000000000..e9e617190c0 --- /dev/null +++ b/drivers/video/displays/framebuf_new/driver.h @@ -0,0 +1,75 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/driver.h + * PURPOSE: Main Driver Header File + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +//#define DBG 1 +#include "stddef.h" +#include +#include "windef.h" +#include "wingdi.h" +#include "winddi.h" +#include "devioctl.h" +#include "ntddvdeo.h" +#include "debug.h" + +typedef struct _PDEV +{ + HANDLE hDriver; // Handle to \Device\Screen + HDEV hdevEng; // Engine's handle to PDEV + HSURF hsurfEng; // Engine's handle to surface + HPALETTE hpalDefault; // Handle to the default palette for device. + PBYTE pjScreen; // This is pointer to base screen address + ULONG cxScreen; // Visible screen width + ULONG cyScreen; // Visible screen height + ULONG ulMode; // Mode the mini-port driver is in. + LONG lDeltaScreen; // Distance from one scan to the next. + ULONG cScreenSize; // size of video memory, including + // offscreen memory. + PVOID pOffscreenList; // linked list of DCI offscreen surfaces. + FLONG flRed; // For bitfields device, Red Mask + FLONG flGreen; // For bitfields device, Green Mask + FLONG flBlue; // For bitfields device, Blue Mask + ULONG cPaletteShift; // number of bits the 8-8-8 palette must + // be shifted by to fit in the hardware + // palette. + ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported. + POINTL ptlHotSpot; // adjustment for pointer hot spot + VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities + PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // hardware pointer attributes + DWORD cjPointerAttributes; // Size of buffer allocated + BOOL fHwCursorActive; // Are we currently using the hw cursor + PALETTEENTRY *pPal; // If this is pal managed, this is the pal + BOOL bSupportDCI; // Does the miniport support DCI? +// eVb: 3.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + LONG flHooks; +// eVb: 3.1 [END] +} PDEV, *PPDEV; + +DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *); +BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *); +BOOL bInitSURF(PPDEV, BOOL); +BOOL bInitPaletteInfo(PPDEV, DEVINFO *); +BOOL bInitPointer(PPDEV, DEVINFO *); +BOOL bInit256ColorPalette(PPDEV); +VOID vDisablePalette(PPDEV); +VOID vDisableSURF(PPDEV); + +#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256)) + +// +// Determines the size of the DriverExtra information in the DEVMODE +// structure passed to and from the display driver. +// + +#define DRIVER_EXTRA_SIZE 0 + +#define DLL_NAME L"framebuf" // Name of the DLL in UNICODE +#define STANDARD_DEBUG_PREFIX "FRAMEBUF: " // All debug output is prefixed +#define ALLOC_TAG 'bfDD' // Four byte tag (characters in + // reverse order) used for memory + // allocations diff --git a/drivers/video/displays/framebuf_new/enable.c b/drivers/video/displays/framebuf_new/enable.c new file mode 100644 index 00000000000..8031da8a173 --- /dev/null +++ b/drivers/video/displays/framebuf_new/enable.c @@ -0,0 +1,476 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/enable.c + * PURPOSE: Main Driver Initialization and PDEV Enabling + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#include "driver.h" + +// The driver function table with all function index/address pairs + +static DRVFN gadrvfn[] = +{ + { INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV }, + { INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV }, + { INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV }, + { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface }, + { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, + { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, + { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, + { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, + { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, + { INDEX_DrvGetModes, (PFN) DrvGetModes } +}; + +// Define the functions you want to hook for 8/16/24/32 pel formats + +#define HOOKS_BMF8BPP 0 + +#define HOOKS_BMF16BPP 0 + +#define HOOKS_BMF24BPP 0 + +#define HOOKS_BMF32BPP 0 + +/******************************Public*Routine******************************\ +* DrvEnableDriver +* +* Enables the driver by retrieving the drivers function table and version. +* +\**************************************************************************/ + +BOOL DrvEnableDriver( +ULONG iEngineVersion, +ULONG cj, +PDRVENABLEDATA pded) +{ +// Engine Version is passed down so future drivers can support previous +// engine versions. A next generation driver can support both the old +// and new engine conventions if told what version of engine it is +// working with. For the first version the driver does nothing with it. +// eVb: 1.1 [DDK Change] - Remove bogus statement + //iEngineVersion; +// eVb: 1.1 [END] +// Fill in as much as we can. + + if (cj >= sizeof(DRVENABLEDATA)) + pded->pdrvfn = gadrvfn; + + if (cj >= (sizeof(ULONG) * 2)) + pded->c = sizeof(gadrvfn) / sizeof(DRVFN); + +// DDI version this driver was targeted for is passed back to engine. +// Future graphic's engine may break calls down to old driver format. + + if (cj >= sizeof(ULONG)) +// eVb: 1.2 [DDK Change] - Use DDI_DRIVER_VERSION_NT4 instead of DDI_DRIVER_VERSION + pded->iDriverVersion = DDI_DRIVER_VERSION_NT4; +// eVb: 1.2 [END] + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* DrvEnablePDEV +* +* DDI function, Enables the Physical Device. +* +* Return Value: device handle to pdev. +* +\**************************************************************************/ + +DHPDEV DrvEnablePDEV( +DEVMODEW *pDevmode, // Pointer to DEVMODE +PWSTR pwszLogAddress, // Logical address +ULONG cPatterns, // number of patterns +HSURF *ahsurfPatterns, // return standard patterns +ULONG cjGdiInfo, // Length of memory pointed to by pGdiInfo +ULONG *pGdiInfo, // Pointer to GdiInfo structure +ULONG cjDevInfo, // Length of following PDEVINFO structure +DEVINFO *pDevInfo, // physical device information structure +HDEV hdev, // HDEV, used for callbacks +PWSTR pwszDeviceName, // DeviceName - not used +HANDLE hDriver) // Handle to base driver +{ + GDIINFO GdiInfo; + DEVINFO DevInfo; + PPDEV ppdev = (PPDEV) NULL; + + UNREFERENCED_PARAMETER(pwszLogAddress); + UNREFERENCED_PARAMETER(pwszDeviceName); + + // Allocate a physical device structure. + + ppdev = (PPDEV) EngAllocMem(0, sizeof(PDEV), ALLOC_TAG); + + if (ppdev == (PPDEV) NULL) + { + RIP("DISP DrvEnablePDEV failed EngAllocMem\n"); + return((DHPDEV) 0); + } + + memset(ppdev, 0, sizeof(PDEV)); + + // Save the screen handle in the PDEV. + + ppdev->hDriver = hDriver; + + // Get the current screen mode information. Set up device caps and devinfo. + + if (!bInitPDEV(ppdev, pDevmode, &GdiInfo, &DevInfo)) + { + DISPDBG((0,"DISP DrvEnablePDEV failed\n")); + goto error_free; + } + + // Initialize the cursor information. + + if (!bInitPointer(ppdev, &DevInfo)) + { + // Not a fatal error... + DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n")); + } + + // Initialize palette information. + + if (!bInitPaletteInfo(ppdev, &DevInfo)) + { + RIP("DrvEnablePDEV failed bInitPalette\n"); + goto error_free; + } + + // Copy the devinfo into the engine buffer. + + memcpy(pDevInfo, &DevInfo, min(sizeof(DEVINFO), cjDevInfo)); + + // Set the pdevCaps with GdiInfo we have prepared to the list of caps for this + // pdev. + + memcpy(pGdiInfo, &GdiInfo, min(cjGdiInfo, sizeof(GDIINFO))); + + return((DHPDEV) ppdev); + + // Error case for failure. +error_free: + EngFreeMem(ppdev); + return((DHPDEV) 0); +} + +/******************************Public*Routine******************************\ +* DrvCompletePDEV +* +* Store the HPDEV, the engines handle for this PDEV, in the DHPDEV. +* +\**************************************************************************/ + +VOID DrvCompletePDEV( +DHPDEV dhpdev, +HDEV hdev) +{ + ((PPDEV) dhpdev)->hdevEng = hdev; +} + +/******************************Public*Routine******************************\ +* DrvDisablePDEV +* +* Release the resources allocated in DrvEnablePDEV. If a surface has been +* enabled DrvDisableSurface will have already been called. +* +\**************************************************************************/ + +VOID DrvDisablePDEV( +DHPDEV dhpdev) +{ + vDisablePalette((PPDEV) dhpdev); + EngFreeMem(dhpdev); +} + +/******************************Public*Routine******************************\ +* DrvEnableSurface +* +* Enable the surface for the device. Hook the calls this driver supports. +* +* Return: Handle to the surface if successful, 0 for failure. +* +\**************************************************************************/ + +HSURF DrvEnableSurface( +DHPDEV dhpdev) +{ + PPDEV ppdev; + HSURF hsurf; + SIZEL sizl; + ULONG ulBitmapType; + FLONG flHooks; + + // Create engine bitmap around frame buffer. + + ppdev = (PPDEV) dhpdev; + + if (!bInitSURF(ppdev, TRUE)) + { + RIP("DISP DrvEnableSurface failed bInitSURF\n"); + return(FALSE); + } + + sizl.cx = ppdev->cxScreen; + sizl.cy = ppdev->cyScreen; + + if (ppdev->ulBitCount == 8) + { + if (!bInit256ColorPalette(ppdev)) { + RIP("DISP DrvEnableSurface failed to init the 8bpp palette\n"); + return(FALSE); + } + ulBitmapType = BMF_8BPP; + flHooks = HOOKS_BMF8BPP; + } + else if (ppdev->ulBitCount == 16) + { + ulBitmapType = BMF_16BPP; + flHooks = HOOKS_BMF16BPP; + } + else if (ppdev->ulBitCount == 24) + { + ulBitmapType = BMF_24BPP; + flHooks = HOOKS_BMF24BPP; + } + else + { + ulBitmapType = BMF_32BPP; + flHooks = HOOKS_BMF32BPP; + } +// eVb: 1.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + ppdev->flHooks = flHooks; +// eVb: 1.3 [END] +// eVb: 1.4 [DDK Change] - Use EngCreateDeviceSurface instead of EngCreateBitmap + hsurf = (HSURF)EngCreateDeviceSurface((DHSURF)ppdev, + sizl, + ulBitmapType); + + if (hsurf == (HSURF) 0) + { + RIP("DISP DrvEnableSurface failed EngCreateDeviceSurface\n"); + return(FALSE); + } +// eVb: 1.4 [END] + +// eVb: 1.5 [DDK Change] - Use EngModifySurface instead of EngAssociateSurface + if ( !EngModifySurface(hsurf, + ppdev->hdevEng, + ppdev->flHooks | HOOK_SYNCHRONIZE, + MS_NOTSYSTEMMEMORY, + (DHSURF)ppdev, + ppdev->pjScreen, + ppdev->lDeltaScreen, + NULL)) + { + RIP("DISP DrvEnableSurface failed EngModifySurface\n"); + return(FALSE); + } +// eVb: 1.5 [END] + ppdev->hsurfEng = hsurf; + + return(hsurf); +} + +/******************************Public*Routine******************************\ +* DrvDisableSurface +* +* Free resources allocated by DrvEnableSurface. Release the surface. +* +\**************************************************************************/ + +VOID DrvDisableSurface( +DHPDEV dhpdev) +{ + EngDeleteSurface(((PPDEV) dhpdev)->hsurfEng); + vDisableSURF((PPDEV) dhpdev); + ((PPDEV) dhpdev)->hsurfEng = (HSURF) 0; +} + +/******************************Public*Routine******************************\ +* DrvAssertMode +* +* This asks the device to reset itself to the mode of the pdev passed in. +* +\**************************************************************************/ + +BOOL DrvAssertMode( +DHPDEV dhpdev, +BOOL bEnable) +{ + PPDEV ppdev = (PPDEV) dhpdev; + ULONG ulReturn; + PBYTE pjScreen; + + if (bEnable) + { + // + // The screen must be reenabled, reinitialize the device to clean state. + // +// eVb: 1.6 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + pjScreen = ppdev->pjScreen; + + if (!bInitSURF(ppdev, FALSE)) + { + DISPDBG((0, "DISP DrvAssertMode failed bInitSURF\n")); + return (FALSE); + } + + if (pjScreen != ppdev->pjScreen) { + + if ( !EngModifySurface(ppdev->hsurfEng, + ppdev->hdevEng, + ppdev->flHooks | HOOK_SYNCHRONIZE, + MS_NOTSYSTEMMEMORY, + (DHSURF)ppdev, + ppdev->pjScreen, + ppdev->lDeltaScreen, + NULL)) + { + DISPDBG((0, "DISP DrvAssertMode failed EngModifySurface\n")); + return (FALSE); + } + } +// eVb: 1.6 [END] + return (TRUE); + } + else + { + // + // We must give up the display. + // Call the kernel driver to reset the device to a known state. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_RESET_DEVICE, + NULL, + 0, + NULL, + 0, + &ulReturn)) + { + RIP("DISP DrvAssertMode failed IOCTL"); + return FALSE; + } + else + { + return TRUE; + } + } +} + +/******************************Public*Routine******************************\ +* DrvGetModes +* +* Returns the list of available modes for the device. +* +\**************************************************************************/ + +ULONG DrvGetModes( +HANDLE hDriver, +ULONG cjSize, +DEVMODEW *pdm) + +{ + + DWORD cModes; + DWORD cbOutputSize; + PVIDEO_MODE_INFORMATION pVideoModeInformation, pVideoTemp; + DWORD cOutputModes = cjSize / (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); + DWORD cbModeSize; + + DISPDBG((3, "DrvGetModes\n")); + + cModes = getAvailableModes(hDriver, + (PVIDEO_MODE_INFORMATION *) &pVideoModeInformation, + &cbModeSize); + + if (cModes == 0) + { + DISPDBG((0, "DrvGetModes failed to get mode information")); + return 0; + } + + if (pdm == NULL) + { + cbOutputSize = cModes * (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); + } + else + { + // + // Now copy the information for the supported modes back into the output + // buffer + // + + cbOutputSize = 0; + + pVideoTemp = pVideoModeInformation; + + do + { + if (pVideoTemp->Length != 0) + { + if (cOutputModes == 0) + { + break; + } + + // + // Zero the entire structure to start off with. + // + + memset(pdm, 0, sizeof(DEVMODEW)); + + // + // Set the name of the device to the name of the DLL. + // + + memcpy(pdm->dmDeviceName, DLL_NAME, sizeof(DLL_NAME)); + + pdm->dmSpecVersion = DM_SPECVERSION; + pdm->dmDriverVersion = DM_SPECVERSION; + pdm->dmSize = sizeof(DEVMODEW); + pdm->dmDriverExtra = DRIVER_EXTRA_SIZE; + + pdm->dmBitsPerPel = pVideoTemp->NumberOfPlanes * + pVideoTemp->BitsPerPlane; + pdm->dmPelsWidth = pVideoTemp->VisScreenWidth; + pdm->dmPelsHeight = pVideoTemp->VisScreenHeight; + pdm->dmDisplayFrequency = pVideoTemp->Frequency; + pdm->dmDisplayFlags = 0; + + pdm->dmFields = DM_BITSPERPEL | + DM_PELSWIDTH | + DM_PELSHEIGHT | + DM_DISPLAYFREQUENCY | + DM_DISPLAYFLAGS ; + + // + // Go to the next DEVMODE entry in the buffer. + // + + cOutputModes--; + + pdm = (LPDEVMODEW) ( ((ULONG)pdm) + sizeof(DEVMODEW) + + DRIVER_EXTRA_SIZE); + + cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); + + } + + pVideoTemp = (PVIDEO_MODE_INFORMATION) + (((PUCHAR)pVideoTemp) + cbModeSize); + + } while (--cModes); + } + + EngFreeMem(pVideoModeInformation); + + return cbOutputSize; + +} diff --git a/drivers/video/displays/framebuf_new/framebuf_new.rbuild b/drivers/video/displays/framebuf_new/framebuf_new.rbuild new file mode 100644 index 00000000000..c334ac9ac4a --- /dev/null +++ b/drivers/video/displays/framebuf_new/framebuf_new.rbuild @@ -0,0 +1,18 @@ + + + + + . + win32k + debug.c + enable.c + palette.c + pointer.c + screen.c + framebuf_new.rc + + -mrtd + -fno-builtin + -Wno-unused-variable + + diff --git a/drivers/video/displays/framebuf_new/framebuf_new.rc b/drivers/video/displays/framebuf_new/framebuf_new.rc new file mode 100644 index 00000000000..98ba2627f11 --- /dev/null +++ b/drivers/video/displays/framebuf_new/framebuf_new.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Framebuffer Display Driver\0" +#define REACTOS_STR_INTERNAL_NAME "framebuf\0" +#define REACTOS_STR_ORIGINAL_FILENAME "framebuf.dll\0" +#include diff --git a/drivers/video/displays/framebuf_new/framebuf_new.spec b/drivers/video/displays/framebuf_new/framebuf_new.spec new file mode 100644 index 00000000000..aec115e4ef7 --- /dev/null +++ b/drivers/video/displays/framebuf_new/framebuf_new.spec @@ -0,0 +1 @@ +@ stdcall DrvEnableDriver(long long ptr) diff --git a/drivers/video/displays/framebuf_new/palette.c b/drivers/video/displays/framebuf_new/palette.c new file mode 100755 index 00000000000..c8cff990e2b --- /dev/null +++ b/drivers/video/displays/framebuf_new/palette.c @@ -0,0 +1,332 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/palette.c + * PURPOSE: Palette Support + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#include "driver.h" + +// Global Table defining the 20 Window Default Colors. For 256 color +// palettes the first 10 must be put at the beginning of the palette +// and the last 10 at the end of the palette. + +const PALETTEENTRY BASEPALETTE[20] = +{ + { 0, 0, 0, 0 }, // 0 + { 0x80,0, 0, 0 }, // 1 + { 0, 0x80,0, 0 }, // 2 + { 0x80,0x80,0, 0 }, // 3 + { 0, 0, 0x80,0 }, // 4 + { 0x80,0, 0x80,0 }, // 5 + { 0, 0x80,0x80,0 }, // 6 + { 0xC0,0xC0,0xC0,0 }, // 7 + { 192, 220, 192, 0 }, // 8 + { 166, 202, 240, 0 }, // 9 + { 255, 251, 240, 0 }, // 10 + { 160, 160, 164, 0 }, // 11 + { 0x80,0x80,0x80,0 }, // 12 + { 0xFF,0, 0 ,0 }, // 13 + { 0, 0xFF,0 ,0 }, // 14 + { 0xFF,0xFF,0 ,0 }, // 15 + { 0 ,0, 0xFF,0 }, // 16 + { 0xFF,0, 0xFF,0 }, // 17 + { 0, 0xFF,0xFF,0 }, // 18 + { 0xFF,0xFF,0xFF,0 }, // 19 +}; + +BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo); + +/******************************Public*Routine******************************\ +* bInitPaletteInfo +* +* Initializes the palette information for this PDEV. +* +* Called by DrvEnablePDEV. +* +\**************************************************************************/ + +BOOL bInitPaletteInfo(PPDEV ppdev, DEVINFO *pDevInfo) +{ + if (!bInitDefaultPalette(ppdev, pDevInfo)) + return(FALSE); + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* vDisablePalette +* +* Frees resources allocated by bInitPaletteInfo. +* +\**************************************************************************/ + +VOID vDisablePalette(PPDEV ppdev) +{ +// Delete the default palette if we created one. + + if (ppdev->hpalDefault) + { + EngDeletePalette(ppdev->hpalDefault); + ppdev->hpalDefault = (HPALETTE) 0; + } + + if (ppdev->pPal != (PPALETTEENTRY)NULL) + EngFreeMem((PVOID)ppdev->pPal); +} + +/******************************Public*Routine******************************\ +* bInitDefaultPalette +* +* Initializes default palette for PDEV. +* +\**************************************************************************/ + +BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo) +{ + if (ppdev->ulBitCount == 8) + { + ULONG ulLoop; + BYTE jRed,jGre,jBlu; + + // + // Allocate our palette + // + + ppdev->pPal = (PPALETTEENTRY)EngAllocMem(0, sizeof(PALETTEENTRY) * 256, + ALLOC_TAG); + + if ((ppdev->pPal) == NULL) { + RIP("DISP bInitDefaultPalette() failed EngAllocMem\n"); + return(FALSE); + } + + // + // Generate 256 (8*4*4) RGB combinations to fill the palette + // + + jRed = jGre = jBlu = 0; + + for (ulLoop = 0; ulLoop < 256; ulLoop++) + { + ppdev->pPal[ulLoop].peRed = jRed; + ppdev->pPal[ulLoop].peGreen = jGre; + ppdev->pPal[ulLoop].peBlue = jBlu; + ppdev->pPal[ulLoop].peFlags = (BYTE)0; + + if (!(jRed += 32)) + if (!(jGre += 32)) + jBlu += 64; + } + + // + // Fill in Windows Reserved Colors from the WIN 3.0 DDK + // The Window Manager reserved the first and last 10 colors for + // painting windows borders and for non-palette managed applications. + // + + for (ulLoop = 0; ulLoop < 10; ulLoop++) + { + // + // First 10 + // + + ppdev->pPal[ulLoop] = BASEPALETTE[ulLoop]; + + // + // Last 10 + // + + ppdev->pPal[246 + ulLoop] = BASEPALETTE[ulLoop+10]; + } + + // + // Create handle for palette. + // + + ppdev->hpalDefault = + pDevInfo->hpalDefault = EngCreatePalette(PAL_INDEXED, + 256, + (PULONG) ppdev->pPal, + 0,0,0); + + if (ppdev->hpalDefault == (HPALETTE) 0) + { + RIP("DISP bInitDefaultPalette failed EngCreatePalette\n"); + EngFreeMem(ppdev->pPal); + return(FALSE); + } + + // + // Initialize the hardware with the initial palette. + // + + return(TRUE); + + } else { + + ppdev->hpalDefault = + pDevInfo->hpalDefault = EngCreatePalette(PAL_BITFIELDS, + 0,(PULONG) NULL, + ppdev->flRed, + ppdev->flGreen, + ppdev->flBlue); + + if (ppdev->hpalDefault == (HPALETTE) 0) + { + RIP("DISP bInitDefaultPalette failed EngCreatePalette\n"); + return(FALSE); + } + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* bInit256ColorPalette +* +* Initialize the hardware's palette registers. +* +\**************************************************************************/ + +BOOL bInit256ColorPalette(PPDEV ppdev) +{ + BYTE ajClutSpace[MAX_CLUT_SIZE]; + PVIDEO_CLUT pScreenClut; + ULONG ulReturnedDataLength; + ULONG cColors; + PVIDEO_CLUTDATA pScreenClutData; + + if (ppdev->ulBitCount == 8) + { + // + // Fill in pScreenClut header info: + // + + pScreenClut = (PVIDEO_CLUT) ajClutSpace; + pScreenClut->NumEntries = 256; + pScreenClut->FirstEntry = 0; + + // + // Copy colours in: + // + + cColors = 256; + pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0])); + + while(cColors--) + { + pScreenClutData[cColors].Red = ppdev->pPal[cColors].peRed >> + ppdev->cPaletteShift; + pScreenClutData[cColors].Green = ppdev->pPal[cColors].peGreen >> + ppdev->cPaletteShift; + pScreenClutData[cColors].Blue = ppdev->pPal[cColors].peBlue >> + ppdev->cPaletteShift; + pScreenClutData[cColors].Unused = 0; + } + + // + // Set palette registers: + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_COLOR_REGISTERS, + pScreenClut, + MAX_CLUT_SIZE, + NULL, + 0, + &ulReturnedDataLength)) + { + DISPDBG((0, "Failed bEnablePalette")); + return(FALSE); + } + } + + DISPDBG((5, "Passed bEnablePalette")); + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* DrvSetPalette +* +* DDI entry point for manipulating the palette. +* +\**************************************************************************/ + +BOOL DrvSetPalette( +DHPDEV dhpdev, +PALOBJ* ppalo, +FLONG fl, +ULONG iStart, +ULONG cColors) +{ + BYTE ajClutSpace[MAX_CLUT_SIZE]; + PVIDEO_CLUT pScreenClut; + PVIDEO_CLUTDATA pScreenClutData; + PDEV* ppdev; + + UNREFERENCED_PARAMETER(fl); + + ppdev = (PDEV*) dhpdev; + + // + // Fill in pScreenClut header info: + // + + pScreenClut = (PVIDEO_CLUT) ajClutSpace; + pScreenClut->NumEntries = (USHORT) cColors; + pScreenClut->FirstEntry = (USHORT) iStart; + + pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0])); + + if (cColors != PALOBJ_cGetColors(ppalo, iStart, cColors, + (ULONG*) pScreenClutData)) + { + DISPDBG((0, "DrvSetPalette failed PALOBJ_cGetColors\n")); + return (FALSE); + } + + // + // Set the high reserved byte in each palette entry to 0. + // Do the appropriate palette shifting to fit in the DAC. + // + + if (ppdev->cPaletteShift) + { + while(cColors--) + { + pScreenClutData[cColors].Red >>= ppdev->cPaletteShift; + pScreenClutData[cColors].Green >>= ppdev->cPaletteShift; + pScreenClutData[cColors].Blue >>= ppdev->cPaletteShift; + pScreenClutData[cColors].Unused = 0; + } + } + else + { + while(cColors--) + { + pScreenClutData[cColors].Unused = 0; + } + } + + // + // Set palette registers + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_COLOR_REGISTERS, + pScreenClut, + MAX_CLUT_SIZE, + NULL, + 0, + &cColors)) + { + DISPDBG((0, "DrvSetPalette failed EngDeviceIoControl\n")); + return (FALSE); + } + + return(TRUE); + +} diff --git a/drivers/video/displays/framebuf_new/pointer.c b/drivers/video/displays/framebuf_new/pointer.c new file mode 100755 index 00000000000..d3752a2763c --- /dev/null +++ b/drivers/video/displays/framebuf_new/pointer.c @@ -0,0 +1,455 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/pointer.c + * PURPOSE: Hardware Pointer Support + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + */ + +#include "driver.h" + +BOOL bCopyColorPointer( +PPDEV ppdev, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo); + +BOOL bCopyMonoPointer( +PPDEV ppdev, +SURFOBJ *psoMask); + +BOOL bSetHardwarePointerShape( +SURFOBJ *pso, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo, +LONG x, +LONG y, +FLONG fl); + +/******************************Public*Routine******************************\ +* DrvMovePointer +* +* Moves the hardware pointer to a new position. +* +\**************************************************************************/ + +VOID DrvMovePointer +( + SURFOBJ *pso, + LONG x, + LONG y, + RECTL *prcl +) +{ + PPDEV ppdev = (PPDEV) pso->dhpdev; + DWORD returnedDataLength; + VIDEO_POINTER_POSITION NewPointerPosition; + + // We don't use the exclusion rectangle because we only support + // hardware Pointers. If we were doing our own Pointer simulations + // we would want to update prcl so that the engine would call us + // to exclude out pointer before drawing to the pixels in prcl. + + UNREFERENCED_PARAMETER(prcl); + + if (x == -1) + { + // + // A new position of (-1,-1) means hide the pointer. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_DISABLE_POINTER, + NULL, + 0, + NULL, + 0, + &returnedDataLength)) + { + // + // Not the end of the world, print warning in checked build. + // + + DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_DISABLE_POINTER\n")); + } + } + else + { + NewPointerPosition.Column = (SHORT) x - (SHORT) (ppdev->ptlHotSpot.x); + NewPointerPosition.Row = (SHORT) y - (SHORT) (ppdev->ptlHotSpot.y); + + // + // Call miniport driver to move Pointer. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_POINTER_POSITION, + &NewPointerPosition, + sizeof(VIDEO_POINTER_POSITION), + NULL, + 0, + &returnedDataLength)) + { + // + // Not the end of the world, print warning in checked build. + // + + DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_SET_POINTER_POSITION\n")); + } + } +} + +/******************************Public*Routine******************************\ +* DrvSetPointerShape +* +* Sets the new pointer shape. +* +\**************************************************************************/ + +ULONG DrvSetPointerShape +( + SURFOBJ *pso, + SURFOBJ *psoMask, + SURFOBJ *psoColor, + XLATEOBJ *pxlo, + LONG xHot, + LONG yHot, + LONG x, + LONG y, + RECTL *prcl, + FLONG fl +) +{ + PPDEV ppdev = (PPDEV) pso->dhpdev; + DWORD returnedDataLength; + + // We don't use the exclusion rectangle because we only support + // hardware Pointers. If we were doing our own Pointer simulations + // we would want to update prcl so that the engine would call us + // to exclude out pointer before drawing to the pixels in prcl. + UNREFERENCED_PARAMETER(prcl); + + if (ppdev->pPointerAttributes == (PVIDEO_POINTER_ATTRIBUTES) NULL) + { + // Mini-port has no hardware Pointer support. + return(SPS_ERROR); + } + + // See if we are being asked to hide the pointer + + if (psoMask == (SURFOBJ *) NULL) + { + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_DISABLE_POINTER, + NULL, + 0, + NULL, + 0, + &returnedDataLength)) + { + // + // It should never be possible to fail. + // Message supplied for debugging. + // + + DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); + } + + return(TRUE); + } + + ppdev->ptlHotSpot.x = xHot; + ppdev->ptlHotSpot.y = yHot; + + if (!bSetHardwarePointerShape(pso,psoMask,psoColor,pxlo,x,y,fl)) + { + if (ppdev->fHwCursorActive) { + ppdev->fHwCursorActive = FALSE; + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_DISABLE_POINTER, + NULL, + 0, + NULL, + 0, + &returnedDataLength)) { + + DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); + } + } + + // + // Mini-port declines to realize this Pointer + // + + return(SPS_DECLINE); + } + else + { + ppdev->fHwCursorActive = TRUE; + } + + return(SPS_ACCEPT_NOEXCLUDE); +} + +/******************************Public*Routine******************************\ +* bSetHardwarePointerShape +* +* Changes the shape of the Hardware Pointer. +* +* Returns: True if successful, False if Pointer shape can't be hardware. +* +\**************************************************************************/ + +BOOL bSetHardwarePointerShape( +SURFOBJ *pso, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo, +LONG x, +LONG y, +FLONG fl) +{ + PPDEV ppdev = (PPDEV) pso->dhpdev; + PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; + DWORD returnedDataLength; + + if (psoColor != (SURFOBJ *) NULL) + { + if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER) && + bCopyColorPointer(ppdev, psoMask, psoColor, pxlo)) + { + pPointerAttributes->Flags |= VIDEO_MODE_COLOR_POINTER; + } else { + return(FALSE); + } + + } else { + + if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER) && + bCopyMonoPointer(ppdev, psoMask)) + { + pPointerAttributes->Flags |= VIDEO_MODE_MONO_POINTER; + } else { + return(FALSE); + } + } + + // + // Initialize Pointer attributes and position + // + + pPointerAttributes->Enable = 1; + + // + // if x,y = -1,-1 then pass them directly to the miniport so that + // the cursor will be disabled + + pPointerAttributes->Column = (SHORT)(x); + pPointerAttributes->Row = (SHORT)(y); + + if ((x != -1) || (y != -1)) { + pPointerAttributes->Column -= (SHORT)(ppdev->ptlHotSpot.x); + pPointerAttributes->Row -= (SHORT)(ppdev->ptlHotSpot.y); + } + + // + // set animate flags + // + + if (fl & SPS_ANIMATESTART) { + pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_START; + } else if (fl & SPS_ANIMATEUPDATE) { + pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_UPDATE; + } + + // + // Set the new Pointer shape. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_POINTER_ATTR, + pPointerAttributes, + ppdev->cjPointerAttributes, + NULL, + 0, + &returnedDataLength)) { + + DISPDBG((1, "DISP:Failed IOCTL_VIDEO_SET_POINTER_ATTR call\n")); + return(FALSE); + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* bCopyMonoPointer +* +* Copies two monochrome masks into a buffer of the maximum size handled by the +* miniport, with any extra bits set to 0. The masks are converted to topdown +* form if they aren't already. Returns TRUE if we can handle this pointer in +* hardware, FALSE if not. +* +\**************************************************************************/ + +BOOL bCopyMonoPointer( + PPDEV ppdev, + SURFOBJ *pso) +{ + ULONG cy; + PBYTE pjSrcAnd, pjSrcXor; + LONG lDeltaSrc, lDeltaDst; + LONG lSrcWidthInBytes; + ULONG cxSrc = pso->sizlBitmap.cx; + ULONG cySrc = pso->sizlBitmap.cy; + ULONG cxSrcBytes; + PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; + PBYTE pjDstAnd = pPointerAttributes->Pixels; + PBYTE pjDstXor = pPointerAttributes->Pixels; + + // Make sure the new pointer isn't too big to handle + // (*2 because both masks are in there) + if ((cxSrc > ppdev->PointerCapabilities.MaxWidth) || + (cySrc > (ppdev->PointerCapabilities.MaxHeight * 2))) + { + return(FALSE); + } + + pjDstXor += ((ppdev->PointerCapabilities.MaxWidth + 7) / 8) * + ppdev->pPointerAttributes->Height; + + // set the desk and mask to 0xff + RtlFillMemory(pjDstAnd, ppdev->pPointerAttributes->WidthInBytes * + ppdev->pPointerAttributes->Height, 0xFF); + + // Zero the dest XOR mask + RtlZeroMemory(pjDstXor, ppdev->pPointerAttributes->WidthInBytes * + ppdev->pPointerAttributes->Height); + + cxSrcBytes = (cxSrc + 7) / 8; + + if ((lDeltaSrc = pso->lDelta) < 0) + { + lSrcWidthInBytes = -lDeltaSrc; + } else { + lSrcWidthInBytes = lDeltaSrc; + } + + pjSrcAnd = (PBYTE) pso->pvBits; + + // If the incoming pointer bitmap is bottomup, we'll flip it to topdown to + // save the miniport some work + if (!(pso->fjBitmap & BMF_TOPDOWN)) + { + // Copy from the bottom + pjSrcAnd += lSrcWidthInBytes * (cySrc - 1); + } + + // Height of just AND mask + cySrc = cySrc / 2; + + // Point to XOR mask + pjSrcXor = pjSrcAnd + (cySrc * lDeltaSrc); + + // Offset from end of one dest scan to start of next + lDeltaDst = ppdev->pPointerAttributes->WidthInBytes; + + for (cy = 0; cy < cySrc; ++cy) + { + RtlCopyMemory(pjDstAnd, pjSrcAnd, cxSrcBytes); + RtlCopyMemory(pjDstXor, pjSrcXor, cxSrcBytes); + + // Point to next source and dest scans + pjSrcAnd += lDeltaSrc; + pjSrcXor += lDeltaSrc; + pjDstAnd += lDeltaDst; + pjDstXor += lDeltaDst; + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* bCopyColorPointer +* +* Copies the mono and color masks into the buffer of maximum size +* handled by the miniport with any extra bits set to 0. Color translation +* is handled at this time. The masks are converted to topdown form if they +* aren't already. Returns TRUE if we can handle this pointer in hardware, +* FALSE if not. +* +\**************************************************************************/ +BOOL bCopyColorPointer( +PPDEV ppdev, +SURFOBJ *psoMask, +SURFOBJ *psoColor, +XLATEOBJ *pxlo) +{ + return(FALSE); +} + + +/******************************Public*Routine******************************\ +* bInitPointer +* +* Initialize the Pointer attributes. +* +\**************************************************************************/ + +BOOL bInitPointer(PPDEV ppdev, DEVINFO *pdevinfo) +{ + DWORD returnedDataLength; + + ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES) NULL; + ppdev->cjPointerAttributes = 0; // initialized in screen.c + + // + // Ask the miniport whether it provides pointer support. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES, + &ppdev->ulMode, + sizeof(PVIDEO_MODE), + &ppdev->PointerCapabilities, + sizeof(ppdev->PointerCapabilities), + &returnedDataLength)) + { + return(FALSE); + } + + // + // If neither mono nor color hardware pointer is supported, there's no + // hardware pointer support and we're done. + // + + if ((!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER)) && + (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))) + { + return(TRUE); + } + + // + // Note: The buffer itself is allocated after we set the + // mode. At that time we know the pixel depth and we can + // allocate the correct size for the color pointer if supported. + // + + // + // Set the asynchronous support status (async means miniport is capable of + // drawing the Pointer at any time, with no interference with any ongoing + // drawing operation) + // + + if (ppdev->PointerCapabilities.Flags & VIDEO_MODE_ASYNC_POINTER) + { + pdevinfo->flGraphicsCaps |= GCAPS_ASYNCMOVE; + } + else + { + pdevinfo->flGraphicsCaps &= ~GCAPS_ASYNCMOVE; + } + + return(TRUE); +} diff --git a/drivers/video/displays/framebuf_new/screen.c b/drivers/video/displays/framebuf_new/screen.c new file mode 100755 index 00000000000..1973c580866 --- /dev/null +++ b/drivers/video/displays/framebuf_new/screen.c @@ -0,0 +1,601 @@ +/* + * PROJECT: ReactOS Framebuffer Display Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/displays/framebuf/screen.c + * PURPOSE: Surface, Screen and PDEV support/initialization + * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation + * ReactOS Portable Systems Group + */ +#include "driver.h" + +#define SYSTM_LOGFONT {16,7,0,0,700,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"System"} +#define HELVE_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"MS Sans Serif"} +#define COURI_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,FIXED_PITCH | FF_DONTCARE, L"Courier"} + +// This is the basic devinfo for a default driver. This is used as a base and customized based +// on information passed back from the miniport driver. + +const DEVINFO gDevInfoFrameBuffer = { + ( GCAPS_OPAQUERECT + | GCAPS_MONO_DITHER + ), /* Graphics capabilities */ + SYSTM_LOGFONT, /* Default font description */ + HELVE_LOGFONT, /* ANSI variable font description */ + COURI_LOGFONT, /* ANSI fixed font description */ + 0, /* Count of device fonts */ + 0, /* Preferred DIB format */ + 8, /* Width of color dither */ + 8, /* Height of color dither */ + 0 /* Default palette to use for this device */ +}; + +/******************************Public*Routine******************************\ +* bInitSURF +* +* Enables the surface. Maps the frame buffer into memory. +* +\**************************************************************************/ + +BOOL bInitSURF(PPDEV ppdev, BOOL bFirst) +{ + DWORD returnedDataLength; + DWORD MaxWidth, MaxHeight; + VIDEO_MEMORY videoMemory; + VIDEO_MEMORY_INFORMATION videoMemoryInformation; +// eVb: 2.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + ULONG RemappingNeeded = 0; +// eVb: 2.1 [END] + // + // Set the current mode into the hardware. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_SET_CURRENT_MODE, + &(ppdev->ulMode), + sizeof(ULONG), +// eVb: 2.2 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + &RemappingNeeded, + sizeof(ULONG), +// eVb: 2.2 [END] + &returnedDataLength)) + { + RIP("DISP bInitSURF failed IOCTL_SET_MODE\n"); + return(FALSE); + } + + // + // If this is the first time we enable the surface we need to map in the + // memory also. + // +// eVb: 2.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping + if (bFirst || RemappingNeeded) + { +// eVb: 2.3 [END] + videoMemory.RequestedVirtualAddress = NULL; + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_MAP_VIDEO_MEMORY, + &videoMemory, + sizeof(VIDEO_MEMORY), + &videoMemoryInformation, + sizeof(VIDEO_MEMORY_INFORMATION), + &returnedDataLength)) + { + RIP("DISP bInitSURF failed IOCTL_VIDEO_MAP\n"); + return(FALSE); + } + + ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase); + + if (videoMemoryInformation.FrameBufferBase != + videoMemoryInformation.VideoRamBase) + { + RIP("VideoRamBase does not correspond to FrameBufferBase\n"); + } +// eVb: 2.4 [DDK Change] - Make sure frame buffer mapping worked + // + // Make sure we can access this video memory + // + + *(PULONG)(ppdev->pjScreen) = 0xaa55aa55; + + if (*(PULONG)(ppdev->pjScreen) != 0xaa55aa55) { + + DISPDBG((1, "Frame buffer memory is not accessible.\n")); + return(FALSE); + } +// eVb: 2.4 [END] + ppdev->cScreenSize = videoMemoryInformation.VideoRamLength; + + // + // Initialize the head of the offscreen list to NULL. + // + + ppdev->pOffscreenList = NULL; + + // It's a hardware pointer; set up pointer attributes. + + MaxHeight = ppdev->PointerCapabilities.MaxHeight; + + // Allocate space for two DIBs (data/mask) for the pointer. If this + // device supports a color Pointer, we will allocate a larger bitmap. + // If this is a color bitmap we allocate for the largest possible + // bitmap because we have no idea of what the pixel depth might be. + + // Width rounded up to nearest byte multiple + + if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER)) + { + MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8; + } + else + { + MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD); + } + + ppdev->cjPointerAttributes = + sizeof(VIDEO_POINTER_ATTRIBUTES) + + ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2); + + ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES) + EngAllocMem(0, ppdev->cjPointerAttributes, ALLOC_TAG); + + if (ppdev->pPointerAttributes == NULL) { + + DISPDBG((0, "bInitPointer EngAllocMem failed\n")); + return(FALSE); + } + + ppdev->pPointerAttributes->Flags = ppdev->PointerCapabilities.Flags; + ppdev->pPointerAttributes->WidthInBytes = MaxWidth; + ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.MaxWidth; + ppdev->pPointerAttributes->Height = MaxHeight; + ppdev->pPointerAttributes->Column = 0; + ppdev->pPointerAttributes->Row = 0; + ppdev->pPointerAttributes->Enable = 0; + } + + return(TRUE); +} + +/******************************Public*Routine******************************\ +* vDisableSURF +* +* Disable the surface. Un-Maps the frame in memory. +* +\**************************************************************************/ + +VOID vDisableSURF(PPDEV ppdev) +{ + DWORD returnedDataLength; + VIDEO_MEMORY videoMemory; + + videoMemory.RequestedVirtualAddress = (PVOID) ppdev->pjScreen; + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_UNMAP_VIDEO_MEMORY, + &videoMemory, + sizeof(VIDEO_MEMORY), + NULL, + 0, + &returnedDataLength)) + { + RIP("DISP vDisableSURF failed IOCTL_VIDEO_UNMAP\n"); + } +} + + +/******************************Public*Routine******************************\ +* bInitPDEV +* +* Determine the mode we should be in based on the DEVMODE passed in. +* Query mini-port to get information needed to fill in the DevInfo and the +* GdiInfo . +* +\**************************************************************************/ + +BOOL bInitPDEV( +PPDEV ppdev, +DEVMODEW *pDevMode, +GDIINFO *pGdiInfo, +DEVINFO *pDevInfo) +{ + ULONG cModes; + PVIDEO_MODE_INFORMATION pVideoBuffer, pVideoModeSelected, pVideoTemp; + VIDEO_COLOR_CAPABILITIES colorCapabilities; + ULONG ulTemp; + BOOL bSelectDefault; + ULONG cbModeSize; + + // + // calls the miniport to get mode information. + // + + cModes = getAvailableModes(ppdev->hDriver, &pVideoBuffer, &cbModeSize); + + if (cModes == 0) + { + return(FALSE); + } + + // + // Now see if the requested mode has a match in that table. + // + + pVideoModeSelected = NULL; + pVideoTemp = pVideoBuffer; + + if ((pDevMode->dmPelsWidth == 0) && + (pDevMode->dmPelsHeight == 0) && + (pDevMode->dmBitsPerPel == 0) && + (pDevMode->dmDisplayFrequency == 0)) + { + DISPDBG((2, "Default mode requested")); + bSelectDefault = TRUE; + } + else + { +// eVb: 2.5 [DDK Change] - Add missing newlines to debug output + DISPDBG((2, "Requested mode...\n")); + DISPDBG((2, " Screen width -- %li\n", pDevMode->dmPelsWidth)); + DISPDBG((2, " Screen height -- %li\n", pDevMode->dmPelsHeight)); + DISPDBG((2, " Bits per pel -- %li\n", pDevMode->dmBitsPerPel)); + DISPDBG((2, " Frequency -- %li\n", pDevMode->dmDisplayFrequency)); +// eVb: 2.5 [END] + bSelectDefault = FALSE; + } + + while (cModes--) + { + if (pVideoTemp->Length != 0) + { + if (bSelectDefault || + ((pVideoTemp->VisScreenWidth == pDevMode->dmPelsWidth) && + (pVideoTemp->VisScreenHeight == pDevMode->dmPelsHeight) && + (pVideoTemp->BitsPerPlane * + pVideoTemp->NumberOfPlanes == pDevMode->dmBitsPerPel) && + (pVideoTemp->Frequency == pDevMode->dmDisplayFrequency))) + { + pVideoModeSelected = pVideoTemp; + DISPDBG((3, "Found a match\n")) ; + break; + } + } + + pVideoTemp = (PVIDEO_MODE_INFORMATION) + (((PUCHAR)pVideoTemp) + cbModeSize); + } + + // + // If no mode has been found, return an error + // + + if (pVideoModeSelected == NULL) + { + EngFreeMem(pVideoBuffer); + DISPDBG((0,"DISP bInitPDEV failed - no valid modes\n")); + return(FALSE); + } + + // + // Fill in the GDIINFO data structure with the information returned from + // the kernel driver. + // + + ppdev->ulMode = pVideoModeSelected->ModeIndex; + ppdev->cxScreen = pVideoModeSelected->VisScreenWidth; + ppdev->cyScreen = pVideoModeSelected->VisScreenHeight; + ppdev->ulBitCount = pVideoModeSelected->BitsPerPlane * + pVideoModeSelected->NumberOfPlanes; + ppdev->lDeltaScreen = pVideoModeSelected->ScreenStride; + + ppdev->flRed = pVideoModeSelected->RedMask; + ppdev->flGreen = pVideoModeSelected->GreenMask; + ppdev->flBlue = pVideoModeSelected->BlueMask; + + + pGdiInfo->ulVersion = GDI_DRIVER_VERSION; + pGdiInfo->ulTechnology = DT_RASDISPLAY; + pGdiInfo->ulHorzSize = pVideoModeSelected->XMillimeter; + pGdiInfo->ulVertSize = pVideoModeSelected->YMillimeter; + + pGdiInfo->ulHorzRes = ppdev->cxScreen; + pGdiInfo->ulVertRes = ppdev->cyScreen; + pGdiInfo->ulPanningHorzRes = ppdev->cxScreen; + pGdiInfo->ulPanningVertRes = ppdev->cyScreen; + pGdiInfo->cBitsPixel = pVideoModeSelected->BitsPerPlane; + pGdiInfo->cPlanes = pVideoModeSelected->NumberOfPlanes; + pGdiInfo->ulVRefresh = pVideoModeSelected->Frequency; + pGdiInfo->ulBltAlignment = 1; // We don't have accelerated screen- + // to-screen blts, and any + // window alignment is okay + + pGdiInfo->ulLogPixelsX = pDevMode->dmLogPixels; + pGdiInfo->ulLogPixelsY = pDevMode->dmLogPixels; + +#ifdef MIPS + if (ppdev->ulBitCount == 8) + pGdiInfo->flTextCaps = (TC_RA_ABLE | TC_SCROLLBLT); + else +#endif + pGdiInfo->flTextCaps = TC_RA_ABLE; + + pGdiInfo->flRaster = 0; // flRaster is reserved by DDI + + pGdiInfo->ulDACRed = pVideoModeSelected->NumberRedBits; + pGdiInfo->ulDACGreen = pVideoModeSelected->NumberGreenBits; + pGdiInfo->ulDACBlue = pVideoModeSelected->NumberBlueBits; + + pGdiInfo->ulAspectX = 0x24; // One-to-one aspect ratio + pGdiInfo->ulAspectY = 0x24; + pGdiInfo->ulAspectXY = 0x33; + + pGdiInfo->xStyleStep = 1; // A style unit is 3 pels + pGdiInfo->yStyleStep = 1; + pGdiInfo->denStyleStep = 3; + + pGdiInfo->ptlPhysOffset.x = 0; + pGdiInfo->ptlPhysOffset.y = 0; + pGdiInfo->szlPhysSize.cx = 0; + pGdiInfo->szlPhysSize.cy = 0; + + // RGB and CMY color info. + + // + // try to get it from the miniport. + // if the miniport doesn ot support this feature, use defaults. + // + + if (EngDeviceIoControl(ppdev->hDriver, + IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES, + NULL, + 0, + &colorCapabilities, + sizeof(VIDEO_COLOR_CAPABILITIES), + &ulTemp)) + { + + DISPDBG((2, "getcolorCapabilities failed \n")); + + pGdiInfo->ciDevice.Red.x = 6700; + pGdiInfo->ciDevice.Red.y = 3300; + pGdiInfo->ciDevice.Red.Y = 0; + pGdiInfo->ciDevice.Green.x = 2100; + pGdiInfo->ciDevice.Green.y = 7100; + pGdiInfo->ciDevice.Green.Y = 0; + pGdiInfo->ciDevice.Blue.x = 1400; + pGdiInfo->ciDevice.Blue.y = 800; + pGdiInfo->ciDevice.Blue.Y = 0; + pGdiInfo->ciDevice.AlignmentWhite.x = 3127; + pGdiInfo->ciDevice.AlignmentWhite.y = 3290; + pGdiInfo->ciDevice.AlignmentWhite.Y = 0; + + pGdiInfo->ciDevice.RedGamma = 20000; + pGdiInfo->ciDevice.GreenGamma = 20000; + pGdiInfo->ciDevice.BlueGamma = 20000; + + } + else + { + pGdiInfo->ciDevice.Red.x = colorCapabilities.RedChromaticity_x; + pGdiInfo->ciDevice.Red.y = colorCapabilities.RedChromaticity_y; + pGdiInfo->ciDevice.Red.Y = 0; + pGdiInfo->ciDevice.Green.x = colorCapabilities.GreenChromaticity_x; + pGdiInfo->ciDevice.Green.y = colorCapabilities.GreenChromaticity_y; + pGdiInfo->ciDevice.Green.Y = 0; + pGdiInfo->ciDevice.Blue.x = colorCapabilities.BlueChromaticity_x; + pGdiInfo->ciDevice.Blue.y = colorCapabilities.BlueChromaticity_y; + pGdiInfo->ciDevice.Blue.Y = 0; + pGdiInfo->ciDevice.AlignmentWhite.x = colorCapabilities.WhiteChromaticity_x; + pGdiInfo->ciDevice.AlignmentWhite.y = colorCapabilities.WhiteChromaticity_y; + pGdiInfo->ciDevice.AlignmentWhite.Y = colorCapabilities.WhiteChromaticity_Y; + + // if we have a color device store the three color gamma values, + // otherwise store the unique gamma value in all three. + + if (colorCapabilities.AttributeFlags & VIDEO_DEVICE_COLOR) + { + pGdiInfo->ciDevice.RedGamma = colorCapabilities.RedGamma; + pGdiInfo->ciDevice.GreenGamma = colorCapabilities.GreenGamma; + pGdiInfo->ciDevice.BlueGamma = colorCapabilities.BlueGamma; + } + else + { + pGdiInfo->ciDevice.RedGamma = colorCapabilities.WhiteGamma; + pGdiInfo->ciDevice.GreenGamma = colorCapabilities.WhiteGamma; + pGdiInfo->ciDevice.BlueGamma = colorCapabilities.WhiteGamma; + } + + }; + + pGdiInfo->ciDevice.Cyan.x = 0; + pGdiInfo->ciDevice.Cyan.y = 0; + pGdiInfo->ciDevice.Cyan.Y = 0; + pGdiInfo->ciDevice.Magenta.x = 0; + pGdiInfo->ciDevice.Magenta.y = 0; + pGdiInfo->ciDevice.Magenta.Y = 0; + pGdiInfo->ciDevice.Yellow.x = 0; + pGdiInfo->ciDevice.Yellow.y = 0; + pGdiInfo->ciDevice.Yellow.Y = 0; + + // No dye correction for raster displays. + + pGdiInfo->ciDevice.MagentaInCyanDye = 0; + pGdiInfo->ciDevice.YellowInCyanDye = 0; + pGdiInfo->ciDevice.CyanInMagentaDye = 0; + pGdiInfo->ciDevice.YellowInMagentaDye = 0; + pGdiInfo->ciDevice.CyanInYellowDye = 0; + pGdiInfo->ciDevice.MagentaInYellowDye = 0; + + pGdiInfo->ulDevicePelsDPI = 0; // For printers only + pGdiInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA; + + // BUGBUG this should be modified to take into account the size + // of the display and the resolution. + + pGdiInfo->ulHTPatternSize = HT_PATSIZE_4x4_M; + + pGdiInfo->flHTFlags = HT_FLAG_ADDITIVE_PRIMS; + + // Fill in the basic devinfo structure + + *pDevInfo = gDevInfoFrameBuffer; + + // Fill in the rest of the devinfo and GdiInfo structures. + + if (ppdev->ulBitCount == 8) + { + // It is Palette Managed. + + pGdiInfo->ulNumColors = 20; + pGdiInfo->ulNumPalReg = 1 << ppdev->ulBitCount; + + pDevInfo->flGraphicsCaps |= (GCAPS_PALMANAGED | GCAPS_COLOR_DITHER); + + pGdiInfo->ulHTOutputFormat = HT_FORMAT_8BPP; + pDevInfo->iDitherFormat = BMF_8BPP; + + // Assuming palette is orthogonal - all colors are same size. + + ppdev->cPaletteShift = 8 - pGdiInfo->ulDACRed; + } + else + { + pGdiInfo->ulNumColors = (ULONG) (-1); + pGdiInfo->ulNumPalReg = 0; + + if (ppdev->ulBitCount == 16) + { + pGdiInfo->ulHTOutputFormat = HT_FORMAT_16BPP; + pDevInfo->iDitherFormat = BMF_16BPP; + } + else if (ppdev->ulBitCount == 24) + { + pGdiInfo->ulHTOutputFormat = HT_FORMAT_24BPP; + pDevInfo->iDitherFormat = BMF_24BPP; + } + else + { + pGdiInfo->ulHTOutputFormat = HT_FORMAT_32BPP; + pDevInfo->iDitherFormat = BMF_32BPP; + } + } + + EngFreeMem(pVideoBuffer); + + return(TRUE); +} + + +/******************************Public*Routine******************************\ +* getAvailableModes +* +* Calls the miniport to get the list of modes supported by the kernel driver, +* and returns the list of modes supported by the diplay driver among those +* +* returns the number of entries in the videomode buffer. +* 0 means no modes are supported by the miniport or that an error occured. +* +* NOTE: the buffer must be freed up by the caller. +* +\**************************************************************************/ + +DWORD getAvailableModes( +HANDLE hDriver, +PVIDEO_MODE_INFORMATION *modeInformation, +DWORD *cbModeSize) +{ + ULONG ulTemp; + VIDEO_NUM_MODES modes; + PVIDEO_MODE_INFORMATION pVideoTemp; + + // + // Get the number of modes supported by the mini-port + // + + if (EngDeviceIoControl(hDriver, + IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES, + NULL, + 0, + &modes, + sizeof(VIDEO_NUM_MODES), + &ulTemp)) + { + DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_NUM_AVAIL_MODES\n")); + return(0); + } + + *cbModeSize = modes.ModeInformationLength; + + // + // Allocate the buffer for the mini-port to write the modes in. + // + + *modeInformation = (PVIDEO_MODE_INFORMATION) + EngAllocMem(0, modes.NumModes * + modes.ModeInformationLength, ALLOC_TAG); + + if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL) + { + DISPDBG((0, "getAvailableModes failed EngAllocMem\n")); + + return 0; + } + + // + // Ask the mini-port to fill in the available modes. + // + + if (EngDeviceIoControl(hDriver, + IOCTL_VIDEO_QUERY_AVAIL_MODES, + NULL, + 0, + *modeInformation, + modes.NumModes * modes.ModeInformationLength, + &ulTemp)) + { + + DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_AVAIL_MODES\n")); + + EngFreeMem(*modeInformation); + *modeInformation = (PVIDEO_MODE_INFORMATION) NULL; + + return(0); + } + + // + // Now see which of these modes are supported by the display driver. + // As an internal mechanism, set the length to 0 for the modes we + // DO NOT support. + // + + ulTemp = modes.NumModes; + pVideoTemp = *modeInformation; + + // + // Mode is rejected if it is not one plane, or not graphics, or is not + // one of 8, 16 or 32 bits per pel. + // + + while (ulTemp--) + { + if ((pVideoTemp->NumberOfPlanes != 1 ) || + !(pVideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) || +// eVb: 2.6 [DDK CHANGE] - Do not process banked video modes + (pVideoTemp->AttributeFlags & VIDEO_MODE_BANKED) || +// eVb: 2.6 [END] + ((pVideoTemp->BitsPerPlane != 8) && + (pVideoTemp->BitsPerPlane != 16) && + (pVideoTemp->BitsPerPlane != 24) && + (pVideoTemp->BitsPerPlane != 32))) + { + pVideoTemp->Length = 0; + } + + pVideoTemp = (PVIDEO_MODE_INFORMATION) + (((PUCHAR)pVideoTemp) + modes.ModeInformationLength); + } + + return modes.NumModes; + +} diff --git a/drivers/video/miniport/directory.rbuild b/drivers/video/miniport/directory.rbuild index 2575e1a7677..363c9097fee 100644 --- a/drivers/video/miniport/directory.rbuild +++ b/drivers/video/miniport/directory.rbuild @@ -7,6 +7,9 @@ + + + diff --git a/drivers/video/miniport/vbe/vbemp.c b/drivers/video/miniport/vbe/vbemp.c index 55b2bcb980c..2107e5ff70e 100644 --- a/drivers/video/miniport/vbe/vbemp.c +++ b/drivers/video/miniport/vbe/vbemp.c @@ -71,6 +71,9 @@ VBEFindAdapter( IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again) { + if (VideoPortIsNoVesa()) + return ERROR_DEV_NOT_EXIST; + return NO_ERROR; } diff --git a/drivers/video/miniport/vbe/vbemp.h b/drivers/video/miniport/vbe/vbemp.h index 7abf14408a5..34807b2f978 100644 --- a/drivers/video/miniport/vbe/vbemp.h +++ b/drivers/video/miniport/vbe/vbemp.h @@ -22,17 +22,9 @@ /* INCLUDES *******************************************************************/ -#ifdef _MSC_VER -#pragma message ("INVESTIGATE ME") -#endif - -#if 0 //#ifdef _MSC_VER -#include "devioctl.h" -#else -#include -#endif - +#include "ntdef.h" #include "dderror.h" +#include "devioctl.h" #include "miniport.h" #include "ntddvdeo.h" #include "video.h" diff --git a/drivers/video/miniport/vga/vgamp.h b/drivers/video/miniport/vga/vgamp.h index efe0bc558eb..2e018e4b116 100644 --- a/drivers/video/miniport/vga/vgamp.h +++ b/drivers/video/miniport/vga/vgamp.h @@ -23,17 +23,9 @@ /* INCLUDES *******************************************************************/ -#ifdef _MSC_VER -#pragma message ("INVESTIGATE ME") -#endif - -#if 0 //#ifdef _MSC_VER -#include "devioctl.h" -#else -#include -#endif - +#include "ntdef.h" #include "dderror.h" +#include "devioctl.h" #include "miniport.h" #include "ntddvdeo.h" #include "video.h" diff --git a/drivers/video/miniport/vga_new/cmdcnst.h b/drivers/video/miniport/vga_new/cmdcnst.h new file mode 100644 index 00000000000..c818b49d494 --- /dev/null +++ b/drivers/video/miniport/vga_new/cmdcnst.h @@ -0,0 +1,92 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/cmdcnst.h + * PURPOSE: Command Code Definitions for VGA Command Streams + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + */ + + +//-------------------------------------------------------------------------- +// Definition of the set/clear mode command language. +// +// Each command is composed of a major portion and a minor portion. +// The major portion of a command can be found in the most significant +// nibble of a command byte, while the minor portion is in the least +// significant portion of a command byte. +// +// maj minor Description +// ---- ----- -------------------------------------------- +// 00 End of data +// +// 10 in and out type commands as described by flags +// flags: +// +// xxxx +// |||| +// |||+-------- unused +// ||+--------- 0/1 single/multiple values to output (in's are always +// |+---------- 0/1 8/16 bit operation single) +// +----------- 0/1 out/in instruction +// +// Outs +// ---------------------------------------------- +// 0 reg:W val:B +// 2 reg:W cnt:W val1:B val2:B...valN:B +// 4 reg:W val:W +// 6 reg:W cnt:W val1:W val2:W...valN:W +// +// Ins +// ---------------------------------------------- +// 8 reg:W +// a reg:W cnt:W +// c reg:W +// e reg:W cnt:W +// +// 20 Special purpose outs +// 00 do indexed outs for seq, crtc, and gdc +// indexreg:W cnt:B startindex:B val1:B val2:B...valN:B +// 01 do indexed outs for atc +// index-data_reg:W cnt:B startindex:B val1:B val2:B...valN:B +// 02 do masked outs +// indexreg:W andmask:B xormask:B +// +// F0 Nop +// +//--------------------------------------------------------------------------- + +// some useful equates - major commands + +#define EOD 0x000 // end of data +#define INOUT 0x010 // do ins or outs +#define METAOUT 0x020 // do special types of outs +#define NCMD 0x0f0 // Nop command + + +// flags for INOUT major command + +//#define UNUSED 0x01 // reserved +#define MULTI 0x02 // multiple or single outs +#define BW 0x04 // byte/word size of operation +#define IO 0x08 // out/in instruction + +// minor commands for metout + +#define INDXOUT 0x00 // do indexed outs +#define ATCOUT 0x01 // do indexed outs for atc +#define MASKOUT 0x02 // do masked outs using and-xor masks + + +// composite inout type commands + +#define OB (INOUT) // output 8 bit value +#define OBM (INOUT+MULTI) // output multiple bytes +#define OW (INOUT+BW) // output single word value +#define OWM (INOUT+BW+MULTI) // output multiple words + +#define IB (INOUT+IO) // input byte +#define IBM (INOUT+IO+MULTI) // input multiple bytes +#define IW (INOUT+IO+BW) // input word +#define IWM (INOUT+IO+BW+MULTI) // input multiple words + +/* EOF */ diff --git a/drivers/video/miniport/vga_new/modeset.c b/drivers/video/miniport/vga_new/modeset.c new file mode 100644 index 00000000000..83c00011a88 --- /dev/null +++ b/drivers/video/miniport/vga_new/modeset.c @@ -0,0 +1,747 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/modeset.c + * PURPOSE: Handles switching to Standard VGA Modes for compatible cards + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#include "vga.h" + +VP_STATUS +VgaInterpretCmdStream( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PUSHORT pusCmdStream + ); + +VP_STATUS +VgaSetMode( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE Mode, + ULONG ModeSize, +// eVb: 2.1 [SET MODE] - Add new output parameter for framebuffer update functionality + PULONG PhysPtrChange +// eVb: 2.1 [END] + ); + +VP_STATUS +VgaQueryAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE_INFORMATION ModeInformation, + ULONG ModeInformationSize, + PULONG OutputSize + ); + +VP_STATUS +VgaQueryNumberOfAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_NUM_MODES NumModes, + ULONG NumModesSize, + PULONG OutputSize + ); + +VOID +VgaZeroVideoMemory( + PHW_DEVICE_EXTENSION HwDeviceExtension + ); + +#if defined(ALLOC_PRAGMA) +#pragma alloc_text(PAGE,VgaInterpretCmdStream) +#pragma alloc_text(PAGE,VgaSetMode) +#pragma alloc_text(PAGE,VgaQueryAvailableModes) +#pragma alloc_text(PAGE,VgaQueryNumberOfAvailableModes) +#pragma alloc_text(PAGE,VgaZeroVideoMemory) +#endif + +//--------------------------------------------------------------------------- +VP_STATUS +VgaInterpretCmdStream( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PUSHORT pusCmdStream + ) + +/*++ + +Routine Description: + + Interprets the appropriate command array to set up VGA registers for the + requested mode. Typically used to set the VGA into a particular mode by + programming all of the registers + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + pusCmdStream - array of commands to be interpreted. + +Return Value: + + The status of the operation (can only fail on a bad command); TRUE for + success, FALSE for failure. + +--*/ + +{ + ULONG ulCmd; + ULONG ulPort; + UCHAR jValue; + USHORT usValue; + ULONG culCount; + ULONG ulIndex; + ULONG ulBase; + + if (pusCmdStream == NULL) { + + VideoDebugPrint((1, "VgaInterpretCmdStream - Invalid pusCmdStream\n")); + return TRUE; + } + + ulBase = (ULONG)HwDeviceExtension->IOAddress; + + // + // Now set the adapter to the desired mode. + // + + while ((ulCmd = *pusCmdStream++) != EOD) { + + // + // Determine major command type + // + + switch (ulCmd & 0xF0) { + + // + // Basic input/output command + // + + case INOUT: + + // + // Determine type of inout instruction + // + + if (!(ulCmd & IO)) { + + // + // Out instruction. Single or multiple outs? + // + + if (!(ulCmd & MULTI)) { + + // + // Single out. Byte or word out? + // + + if (!(ulCmd & BW)) { + + // + // Single byte out + // + + ulPort = *pusCmdStream++; + jValue = (UCHAR) *pusCmdStream++; + VideoPortWritePortUchar((PUCHAR)(ulBase+ulPort), + jValue); + + } else { + + // + // Single word out + // + + ulPort = *pusCmdStream++; + usValue = *pusCmdStream++; + VideoPortWritePortUshort((PUSHORT)(ulBase+ulPort), + usValue); + + } + + } else { + + // + // Output a string of values + // Byte or word outs? + // + + if (!(ulCmd & BW)) { + + // + // String byte outs. Do in a loop; can't use + // VideoPortWritePortBufferUchar because the data + // is in USHORT form + // + + ulPort = ulBase + *pusCmdStream++; + culCount = *pusCmdStream++; + + while (culCount--) { + jValue = (UCHAR) *pusCmdStream++; + VideoPortWritePortUchar((PUCHAR)ulPort, + jValue); + + } + + } else { + + // + // String word outs + // + + ulPort = *pusCmdStream++; + culCount = *pusCmdStream++; + VideoPortWritePortBufferUshort((PUSHORT) + (ulBase + ulPort), pusCmdStream, culCount); + pusCmdStream += culCount; + + } + } + + } else { + + // In instruction + // + // Currently, string in instructions aren't supported; all + // in instructions are handled as single-byte ins + // + // Byte or word in? + // + + if (!(ulCmd & BW)) { + // + // Single byte in + // + + ulPort = *pusCmdStream++; + jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort); + + } else { + + // + // Single word in + // + + ulPort = *pusCmdStream++; + usValue = VideoPortReadPortUshort((PUSHORT) + (ulBase+ulPort)); + + } + + } + + break; + + // + // Higher-level input/output commands + // + + case METAOUT: + + // + // Determine type of metaout command, based on minor + // command field + // + switch (ulCmd & 0x0F) { + + // + // Indexed outs + // + + case INDXOUT: + + ulPort = ulBase + *pusCmdStream++; + culCount = *pusCmdStream++; + ulIndex = *pusCmdStream++; + + while (culCount--) { + + usValue = (USHORT) (ulIndex + + (((ULONG)(*pusCmdStream++)) << 8)); + VideoPortWritePortUshort((PUSHORT)ulPort, usValue); + + ulIndex++; + + } + + break; + + // + // Masked out (read, AND, XOR, write) + // + + case MASKOUT: + + ulPort = *pusCmdStream++; + jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort); + jValue &= *pusCmdStream++; + jValue ^= *pusCmdStream++; + VideoPortWritePortUchar((PUCHAR)ulBase + ulPort, + jValue); + break; + + // + // Attribute Controller out + // + + case ATCOUT: + + ulPort = ulBase + *pusCmdStream++; + culCount = *pusCmdStream++; + ulIndex = *pusCmdStream++; + + while (culCount--) { + + // Write Attribute Controller index + VideoPortWritePortUchar((PUCHAR)ulPort, + (UCHAR)ulIndex); + + // Write Attribute Controller data + jValue = (UCHAR) *pusCmdStream++; + VideoPortWritePortUchar((PUCHAR)ulPort, jValue); + + ulIndex++; + + } + + break; + + // + // None of the above; error + // + default: + + return FALSE; + + } + + + break; + + // + // NOP + // + + case NCMD: + + break; + + // + // Unknown command; error + // + + default: + + return FALSE; + + } + + } + + return TRUE; + +} // end VgaInterpretCmdStream() + + +VP_STATUS +VgaSetMode( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE Mode, + ULONG ModeSize, +// eVb: 2.2 [SET MODE] - Add new output parameter for framebuffer update functionality + PULONG PhysPtrChange +// eVb: 2.2 [END] + ) + +/*++ + +Routine Description: + + This routine sets the vga into the requested mode. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + Mode - Pointer to the structure containing the information about the + font to be set. + + ModeSize - Length of the input buffer supplied by the user. + +Return Value: + + ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough + for the input data. + + ERROR_INVALID_PARAMETER if the mode number is invalid. + + NO_ERROR if the operation completed successfully. + +--*/ + +{ + PVIDEOMODE pRequestedMode; + VP_STATUS status; + ULONG RequestedModeNum; +// eVb: 2.3 [SET MODE] - Add new output parameter for framebuffer update functionality + *PhysPtrChange = FALSE; +// eVb: 2.3 [END] + // + // Check if the size of the data in the input buffer is large enough. + // + + if (ModeSize < sizeof(VIDEO_MODE)) + { + return ERROR_INSUFFICIENT_BUFFER; + } + + // + // Extract the clear memory, and map linear bits. + // + + RequestedModeNum = Mode->RequestedMode & + ~(VIDEO_MODE_NO_ZERO_MEMORY | VIDEO_MODE_MAP_MEM_LINEAR); + + + if (!(Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY)) + { +#if defined(_X86_) + VgaZeroVideoMemory(HwDeviceExtension); +#endif + } + + // + // Check to see if we are requesting a valid mode + // +// eVb: 2.4 [CIRRUS] - Remove Cirrus-specific check for valid mode + if ( (RequestedModeNum >= NumVideoModes) ) +// eVb: 2.4 [END] + { + VideoDebugPrint((0, "Invalide Mode Number = %d!\n", RequestedModeNum)); + + return ERROR_INVALID_PARAMETER; + } + + VideoDebugPrint((2, "Attempting to set mode %d\n", + RequestedModeNum)); +// eVb: 2.5 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list + pRequestedMode = &VgaModeList[RequestedModeNum]; +// eVb: 2.5 [END] + VideoDebugPrint((2, "Info on Requested Mode:\n" + "\tResolution: %dx%d\n", + pRequestedMode->hres, + pRequestedMode->vres )); + + // + // VESA BIOS mode switch + // +// eVb: 2.6 [VBE] - VBE Mode Switch Support + status = VbeSetMode(HwDeviceExtension, pRequestedMode, PhysPtrChange); + if (status == ERROR_INVALID_FUNCTION) + { + // + // VGA mode switch + // + + if (!pRequestedMode->CmdStream) return ERROR_INVALID_FUNCTION; + if (!VgaInterpretCmdStream(HwDeviceExtension, pRequestedMode->CmdStream)) return ERROR_INVALID_FUNCTION; + goto Cleanup; + } + else if (status != NO_ERROR) return status; +// eVb: 2.6 [END] +// eVb: 2.7 [MODE-X] - Windows VGA Miniport Supports Mode-X, we should too + // + // ModeX check + // + + if (pRequestedMode->hres == 320) + { + VideoPortDebugPrint(0, "ModeX not support!!!\n"); + return ERROR_INVALID_PARAMETER; + } +// eVb: 2.7 [END] + // + // Text mode check + // + + if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS)) + { +// eVb: 2.8 [TODO] - This code path is not implemented yet + VideoPortDebugPrint(0, "Text-mode not support!!!\n"); + return ERROR_INVALID_PARAMETER; +// eVb: 2.8 [END] + } + +Cleanup: + // + // Update the location of the physical frame buffer within video memory. + // +// eVb: 2.9 [VBE] - Linear and banked support is unified in VGA, unlike Cirrus + HwDeviceExtension->PhysicalVideoMemoryBase.LowPart = pRequestedMode->PhysBase; + HwDeviceExtension->PhysicalVideoMemoryLength = pRequestedMode->PhysSize; + + HwDeviceExtension->PhysicalFrameLength = + pRequestedMode->FrameBufferSize; + + HwDeviceExtension->PhysicalFrameOffset.LowPart = + pRequestedMode->FrameBufferBase; +// eVb: 2.9 [END] + + // + // Store the new mode value. + // + + HwDeviceExtension->CurrentMode = pRequestedMode; + HwDeviceExtension->ModeIndex = Mode->RequestedMode; + + return NO_ERROR; + +} //end VgaSetMode() + +VP_STATUS +VgaQueryAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE_INFORMATION ModeInformation, + ULONG ModeInformationSize, + PULONG OutputSize + ) + +/*++ + +Routine Description: + + This routine returns the list of all available available modes on the + card. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + ModeInformation - Pointer to the output buffer supplied by the user. + This is where the list of all valid modes is stored. + + ModeInformationSize - Length of the output buffer supplied by the user. + + OutputSize - Pointer to a buffer in which to return the actual size of + the data in the buffer. If the buffer was not large enough, this + contains the minimum required buffer size. + +Return Value: + + ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough + for the data being returned. + + NO_ERROR if the operation completed successfully. + +--*/ + +{ + PVIDEO_MODE_INFORMATION videoModes = ModeInformation; + ULONG i; + + // + // Find out the size of the data to be put in the buffer and return + // that in the status information (whether or not the information is + // there). If the buffer passed in is not large enough return an + // appropriate error code. + // + + if (ModeInformationSize < (*OutputSize = +// eVb: 2.10 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus + NumVideoModes * +// eVb: 2.10 [END] + sizeof(VIDEO_MODE_INFORMATION)) ) { + + return ERROR_INSUFFICIENT_BUFFER; + + } + + // + // For each mode supported by the card, store the mode characteristics + // in the output buffer. + // + + for (i = 0; i < NumVideoModes; i++) + { + videoModes->Length = sizeof(VIDEO_MODE_INFORMATION); + videoModes->ModeIndex = i; +// eVb: 2.11 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list + videoModes->VisScreenWidth = VgaModeList[i].hres; + videoModes->ScreenStride = VgaModeList[i].wbytes; + videoModes->VisScreenHeight = VgaModeList[i].vres; + videoModes->NumberOfPlanes = VgaModeList[i].numPlanes; + videoModes->BitsPerPlane = VgaModeList[i].bitsPerPlane; + videoModes->Frequency = VgaModeList[i].Frequency; + videoModes->XMillimeter = 320; // temporary hardcoded constant + videoModes->YMillimeter = 240; // temporary hardcoded constant + videoModes->AttributeFlags = VgaModeList[i].fbType; +// eVb: 2.11 [END] + + if ((VgaModeList[i].bitsPerPlane == 32) || + (VgaModeList[i].bitsPerPlane == 24)) + { + + videoModes->NumberRedBits = 8; + videoModes->NumberGreenBits = 8; + videoModes->NumberBlueBits = 8; + videoModes->RedMask = 0xff0000; + videoModes->GreenMask = 0x00ff00; + videoModes->BlueMask = 0x0000ff; + + } + else if (VgaModeList[i].bitsPerPlane == 16) + { + + videoModes->NumberRedBits = 6; + videoModes->NumberGreenBits = 6; + videoModes->NumberBlueBits = 6; + videoModes->RedMask = 0x1F << 11; + videoModes->GreenMask = 0x3F << 5; + videoModes->BlueMask = 0x1F; + + } +// eVb: 2.12 [VGA] - Add support for 15bpp modes, which Cirrus doesn't support + else if (VgaModeList[i].bitsPerPlane == 15) + { + + videoModes->NumberRedBits = 6; + videoModes->NumberGreenBits = 6; + videoModes->NumberBlueBits = 6; + videoModes->RedMask = 0x3E << 9; + videoModes->GreenMask = 0x1F << 5; + videoModes->BlueMask = 0x1F; + } +// eVb: 2.12 [END] + else + { + + videoModes->NumberRedBits = 6; + videoModes->NumberGreenBits = 6; + videoModes->NumberBlueBits = 6; + videoModes->RedMask = 0; + videoModes->GreenMask = 0; + videoModes->BlueMask = 0; + } + +// eVb: 2.13 [VGA] - All modes are palette managed/driven, unlike Cirrus + videoModes->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN | + VIDEO_MODE_MANAGED_PALETTE; +// eVb: 2.13 [END] + videoModes++; + + } + + return NO_ERROR; + +} // end VgaGetAvailableModes() + +VP_STATUS +VgaQueryNumberOfAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_NUM_MODES NumModes, + ULONG NumModesSize, + PULONG OutputSize + ) + +/*++ + +Routine Description: + + This routine returns the number of available modes for this particular + video card. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + NumModes - Pointer to the output buffer supplied by the user. This is + where the number of modes is stored. + + NumModesSize - Length of the output buffer supplied by the user. + + OutputSize - Pointer to a buffer in which to return the actual size of + the data in the buffer. + +Return Value: + + ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough + for the data being returned. + + NO_ERROR if the operation completed successfully. + +--*/ + +{ + // + // Find out the size of the data to be put in the the buffer and return + // that in the status information (whether or not the information is + // there). If the buffer passed in is not large enough return an + // appropriate error code. + // + + if (NumModesSize < (*OutputSize = sizeof(VIDEO_NUM_MODES)) ) { + + return ERROR_INSUFFICIENT_BUFFER; + + } + + // + // Store the number of modes into the buffer. + // + +// eVb: 2.14 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus + NumModes->NumModes = NumVideoModes; +// eVb: 2.14 [END] + NumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION); + + return NO_ERROR; + +} // end VgaGetNumberOfAvailableModes() + +VOID +VgaZeroVideoMemory( + PHW_DEVICE_EXTENSION HwDeviceExtension + ) + +/*++ + +Routine Description: + + This routine zeros the first 256K on the VGA. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + +Return Value: + + None. + +--*/ +{ + UCHAR temp; + + // + // Map font buffer at A0000 + // + + VgaInterpretCmdStream(HwDeviceExtension, EnableA000Data); + + // + // Enable all planes. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_ADDRESS_PORT, + IND_MAP_MASK); + + temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT) | (UCHAR)0x0F; + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_DATA_PORT, + temp); + + VideoPortZeroDeviceMemory(HwDeviceExtension->VideoMemoryAddress, 0xFFFF); + + VgaInterpretCmdStream(HwDeviceExtension, DisableA000Color); + +} diff --git a/drivers/video/miniport/vga_new/vbe.c b/drivers/video/miniport/vga_new/vbe.c new file mode 100644 index 00000000000..a2c593da460 --- /dev/null +++ b/drivers/video/miniport/vga_new/vbe.c @@ -0,0 +1,196 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/video/miniport/vga/vbe.c + * PURPOSE: Main VESA VBE 1.02+ SVGA Miniport Handling Code + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include "vga.h" + +/* GLOBALS ********************************************************************/ + +static const PCHAR Nv11Board = "NV11 (GeForce2) Board"; +static const PCHAR Nv11Chip = "Chip Rev B2"; +static const PCHAR Nv11Vendor = "NVidia Corporation"; +static const PCHAR IntelBrookdale = "Brookdale-G Graphics Controller"; +static const PCHAR BrokenVesaBiosList[] = +{ + "SiS 5597", + "MGA-G100", + "3Dfx Banshee", + "Voodoo3 2000 LC ", + "Voodoo3 3000 LC ", + "Voodoo4 4500 ", + "ArtX I", + "ATI S1-370TL" +}; + +BOOLEAN g_bIntelBrookdaleBIOS; + +/* FUNCTIONS ******************************************************************/ + +BOOLEAN +NTAPI +IsVesaBiosOk(IN PVIDEO_PORT_INT10_INTERFACE Interface, + IN ULONG OemRevision, + IN PCHAR Vendor, + IN PCHAR Product, + IN PCHAR Revision) +{ + ULONG i; + CHAR Version[21]; + + /* If the broken VESA bios found, turn VESA off */ + VideoPortDebugPrint(0, "Vendor: %s Product: %s Revision: %s (%lx)\n", Vendor, Product, Revision, OemRevision); + for (i = 0; i < (sizeof(BrokenVesaBiosList) / sizeof(PCHAR)); i++) + { + if (!strncmp(Product, BrokenVesaBiosList[i], sizeof(BrokenVesaBiosList[i]))) return FALSE; + } + + /* For Brookdale-G (Intel), special hack used */ + g_bIntelBrookdaleBIOS = !strncmp(Product, IntelBrookdale, sizeof(IntelBrookdale)); + + /* For NVIDIA make sure */ + if (!(strncmp(Vendor, Nv11Vendor, sizeof(Nv11Vendor))) && + !(strncmp(Product, Nv11Board, sizeof(Nv11Board))) && + !(strncmp(Revision, Nv11Chip, sizeof(Nv11Chip))) && + (OemRevision == 0x311)) + { + /* Read version */ + if (Interface->Int10ReadMemory(Interface->Context, + 0xC000, + 345, + Version, + sizeof(Version))) return FALSE; + if (!strncmp(Version, "Version 3.11.01.24N16", sizeof(Version))) return FALSE; + } + + /* VESA ok */ + //VideoPortDebugPrint(0, "Vesa ok\n"); + return TRUE; +} + +BOOLEAN +NTAPI +ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVBE_INFO VbeInfo) +{ + BOOLEAN VesaBiosOk; + PVOID Context; + CHAR ProductRevision[80]; + CHAR OemString[80]; + CHAR ProductName[80]; + CHAR VendorName[80]; + VP_STATUS Status; + + /* Set default */ + VesaBiosOk = FALSE; + Context = VgaExtension->Int10Interface.Context; + + /* Check magic and version */ + if (strncmp(VbeInfo->Info.Signature, "VESA", 4)) return VesaBiosOk; + if (VbeInfo->Info.Version < 0x102) return VesaBiosOk; + + /* Read strings */ + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.OemStringPtr), + LOWORD(VbeInfo->Info.OemStringPtr), + OemString, + sizeof(OemString)); + if (Status != NO_ERROR) return VesaBiosOk; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.OemVendorNamePtr), + LOWORD(VbeInfo->Info.OemVendorNamePtr), + VendorName, + sizeof(VendorName)); + if (Status != NO_ERROR) return VesaBiosOk; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.OemProductNamePtr), + LOWORD(VbeInfo->Info.OemProductNamePtr), + ProductName, + sizeof(ProductName)); + if (Status != NO_ERROR) return VesaBiosOk; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.OemProductRevPtr), + LOWORD(VbeInfo->Info.OemProductRevPtr), + ProductRevision, + sizeof(ProductRevision)); + if (Status != NO_ERROR) return VesaBiosOk; + + /* Null-terminate strings */ + VendorName[sizeof(OemString) - 1] = ANSI_NULL; + ProductName[sizeof(OemString) - 1] = ANSI_NULL; + ProductRevision[sizeof(OemString) - 1] = ANSI_NULL; + OemString[sizeof(OemString) - 1] = ANSI_NULL; + + /* Check for known bad BIOS */ + VesaBiosOk = IsVesaBiosOk(&VgaExtension->Int10Interface, + VbeInfo->Info.OemSoftwareRevision, + VendorName, + ProductName, + ProductRevision); + VgaExtension->VesaBiosOk = VesaBiosOk; + return VesaBiosOk; +} + +VP_STATUS +NTAPI +VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVIDEO_CLUT ClutBuffer) +{ + PVBE_COLOR_REGISTER VesaClut; + INT10_BIOS_ARGUMENTS BiosArguments; + PVOID Context; + ULONG Entries; + ULONG BufferSize = 4 * 1024; + USHORT TrampolineMemorySegment, TrampolineMemoryOffset; + VP_STATUS Status; + USHORT i; + + Entries = ClutBuffer->NumEntries; + + /* Allocate INT10 context/buffer */ + VesaClut = VideoPortAllocatePool(VgaExtension, 1, sizeof(ULONG) * Entries, 0x20616756u); + if (!VesaClut) return ERROR_INVALID_PARAMETER; + if (!VgaExtension->Int10Interface.Size) return ERROR_INVALID_PARAMETER; + Context = VgaExtension->Int10Interface.Context; + Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context, + &TrampolineMemorySegment, + &TrampolineMemoryOffset, + &BufferSize); + if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; + + /* VESA has color registers backward! */ + for (i = 0; i < Entries; i++) + { + VesaClut[i].Blue = ClutBuffer->LookupTable[i].RgbArray.Blue; + VesaClut[i].Green = ClutBuffer->LookupTable[i].RgbArray.Green; + VesaClut[i].Red = ClutBuffer->LookupTable[i].RgbArray.Red; + VesaClut[i].Pad = 0; + } + Status = VgaExtension->Int10Interface.Int10WriteMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VesaClut, + Entries * sizeof(ULONG)); + if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; + + /* Write new palette */ + BiosArguments.Ebx = 0; + BiosArguments.Ecx = Entries; + BiosArguments.Edx = ClutBuffer->FirstEntry; + BiosArguments.Edi = TrampolineMemoryOffset; + BiosArguments.SegEs = TrampolineMemorySegment; + BiosArguments.Eax = VBE_SET_GET_PALETTE_DATA; + Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); + if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER; + VideoPortFreePool(VgaExtension, VesaClut); + VideoPortDebugPrint(Error, "VBE Status: %lx\n", BiosArguments.Eax); + if (BiosArguments.Eax == VBE_SUCCESS) return NO_ERROR; + return ERROR_INVALID_PARAMETER; +} + +/* EOF */ diff --git a/drivers/video/miniport/vga_new/vbe.h b/drivers/video/miniport/vga_new/vbe.h new file mode 100644 index 00000000000..8802a5ead16 --- /dev/null +++ b/drivers/video/miniport/vga_new/vbe.h @@ -0,0 +1,217 @@ +/* + * PROJECT: VGA Miniport Driver + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/video/miniport/vga/vbe.h + * PURPOSE: VESA VBE Registers and Structures + * PROGRAMMERS: ReactOS Portable Systems Group + */ + + +#define LOWORD(l) ((USHORT)((ULONG_PTR)(l))) +#define HIWORD(l) ((USHORT)(((ULONG_PTR)(l)>>16)&0xFFFF)) + + +/* + * VBE Command Definitions + */ + +#define VBE_GET_CONTROLLER_INFORMATION 0x4F00 +#define VBE_GET_MODE_INFORMATION 0x4F01 +#define VBE_SET_VBE_MODE 0x4F02 +#define VBE_GET_CURRENT_VBE_MODE 0x4F03 +#define VBE_SAVE_RESTORE_STATE 0x4F04 +#define VBE_DISPLAY_WINDOW_CONTROL 0x4F05 +#define VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH 0x4F06 +#define VBE_SET_GET_DISPLAY_START 0x4F07 +#define VBE_SET_GET_DAC_PALETTE_FORMAT 0x4F08 +#define VBE_SET_GET_PALETTE_DATA 0x4F09 + +/* VBE 2.0+ */ +#define VBE_RETURN_PROTECTED_MODE_INTERFACE 0x4F0A +#define VBE_GET_SET_PIXEL_CLOCK 0x4F0B + +/* Extensions */ +#define VBE_POWER_MANAGEMENT_EXTENSIONS 0x4F10 +#define VBE_FLAT_PANEL_INTERFACE_EXTENSIONS 0x4F11 +#define VBE_AUDIO_INTERFACE_EXTENSIONS 0x4F12 +#define VBE_OEM_EXTENSIONS 0x4F13 +#define VBE_DISPLAY_DATA_CHANNEL 0x4F14 +#define VBE_DDC 0x4F15 + +/* + * VBE DDC Sub-Functions + */ + +#define VBE_DDC_READ_EDID 0x01 +#define VBE_DDC_REPORT_CAPABILITIES 0x10 +#define VBE_DDC_BEGIN_SCL_SDA_CONTROL 0x11 +#define VBE_DDC_END_SCL_SDA_CONTROL 0x12 +#define VBE_DDC_WRITE_SCL_CLOCK_LINE 0x13 +#define VBE_DDC_WRITE_SDA_DATA_LINE 0x14 +#define VBE_DDC_READ_SCL_CLOCK_LINE 0x15 +#define VBE_DDC_READ_SDA_DATA_LINE 0x16 + +/* + * VBE Video Mode Information Definitions + */ +#define VBE_MODEATTR_VALID 0x01 +#define VBE_MODEATTR_COLOR 0x08 +#define VBE_MODEATTR_GRAPHICS 0x10 +#define VBE_MODEATTR_NON_VGA 0x20 +#define VBE_MODEATTR_NO_BANK_SWITCH 0x40 +#define VBE_MODEATTR_LINEAR 0x80 + +#define VBE_MODE_BITS 8 +#define VBE_MODE_RESERVED_1 0x200 +#define VBE_MODE_RESERVED_2 0x400 +#define VBE_MODE_REFRESH_CONTROL 0x800 +#define VBE_MODE_ACCELERATED_1 0x1000 +#define VBE_MODE_ACCELERATED_2 0x2000 +#define VBE_MODE_LINEAR_FRAMEBUFFER 0x4000 +#define VBE_MODE_PRESERVE_DISPLAY 0x8000 +#define VBE_MODE_MASK ((1 << (VBE_MODE_BITS + 1)) - 1) + +#define VBE_MEMORYMODEL_PACKEDPIXEL 0x04 +#define VBE_MEMORYMODEL_DIRECTCOLOR 0x06 + +/* + * VBE Return Codes + */ + +#define VBE_SUCCESS 0x4F +#define VBE_UNSUCCESSFUL 0x14F +#define VBE_NOT_SUPPORTED 0x24F +#define VBE_FUNCTION_INVALID 0x34F + +#define VBE_GETRETURNCODE(x) (x & 0xFFFF) + +#include + +/* + * VBE specification defined structure for general adapter info + * returned by function VBE_GET_CONTROLLER_INFORMATION command. + */ + +typedef struct _VBE_CONTROLLER_INFO +{ + CHAR Signature[4]; + USHORT Version; + ULONG OemStringPtr; + LONG Capabilities; + ULONG VideoModePtr; + USHORT TotalMemory; + USHORT OemSoftwareRevision; + ULONG OemVendorNamePtr; + ULONG OemProductNamePtr; + ULONG OemProductRevPtr; + CHAR Reserved[222]; + CHAR OemData[256]; +} VBE_CONTROLLER_INFO, *PVBE_CONTROLLER_INFO; + +/* + * VBE specification defined structure for specific video mode + * info returned by function VBE_GET_MODE_INFORMATION command. + */ + +typedef struct _VBE_MODE_INFO +{ + /* Mandatory information for all VBE revisions */ + USHORT ModeAttributes; + UCHAR WinAAttributes; + UCHAR WinBAttributes; + USHORT WinGranularity; + USHORT WinSize; + USHORT WinASegment; + USHORT WinBSegment; + ULONG WinFuncPtr; + USHORT BytesPerScanLine; + + /* Mandatory information for VBE 1.2 and above */ + USHORT XResolution; + USHORT YResolution; + UCHAR XCharSize; + UCHAR YCharSize; + UCHAR NumberOfPlanes; + UCHAR BitsPerPixel; + UCHAR NumberOfBanks; + UCHAR MemoryModel; + UCHAR BankSize; + UCHAR NumberOfImagePages; + UCHAR Reserved1; + + /* Direct Color fields (required for Direct/6 and YUV/7 memory models) */ + UCHAR RedMaskSize; + UCHAR RedFieldPosition; + UCHAR GreenMaskSize; + UCHAR GreenFieldPosition; + UCHAR BlueMaskSize; + UCHAR BlueFieldPosition; + UCHAR ReservedMaskSize; + UCHAR ReservedFieldPosition; + UCHAR DirectColorModeInfo; + + /* Mandatory information for VBE 2.0 and above */ + ULONG PhysBasePtr; + ULONG Reserved2; + USHORT Reserved3; + + /* Mandatory information for VBE 3.0 and above */ + USHORT LinBytesPerScanLine; + UCHAR BnkNumberOfImagePages; + UCHAR LinNumberOfImagePages; + UCHAR LinRedMaskSize; + UCHAR LinRedFieldPosition; + UCHAR LinGreenMaskSize; + UCHAR LinGreenFieldPosition; + UCHAR LinBlueMaskSize; + UCHAR LinBlueFieldPosition; + UCHAR LinReservedMaskSize; + UCHAR LinReservedFieldPosition; + ULONG MaxPixelClock; + + CHAR Reserved4[190]; +} VBE_MODE_INFO, *PVBE_MODE_INFO; + +#include + +typedef struct _VBE_INFO +{ + VBE_CONTROLLER_INFO Info; + VBE_MODE_INFO Modes; + USHORT ModeArray[129]; +} VBE_INFO, *PVBE_INFO; + +C_ASSERT(sizeof(VBE_CONTROLLER_INFO) == 0x200); +C_ASSERT(sizeof(VBE_MODE_INFO) == 0x100); + +typedef struct _VBE_COLOR_REGISTER +{ + UCHAR Blue; + UCHAR Green; + UCHAR Red; + UCHAR Pad; +} VBE_COLOR_REGISTER, *PVBE_COLOR_REGISTER; + +VOID +NTAPI +InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension); + +VP_STATUS +NTAPI +VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension, + IN PVIDEOMODE VgaMode, + OUT PULONG PhysPtrChange); + +VP_STATUS +NTAPI +VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVIDEO_CLUT ClutBuffer); + +BOOLEAN +NTAPI +ValidateVbeInfo(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVBE_INFO VbeInfo); + +extern BOOLEAN g_bIntelBrookdaleBIOS; + +/* EOF */ diff --git a/drivers/video/miniport/vga_new/vbemodes.c b/drivers/video/miniport/vga_new/vbemodes.c new file mode 100644 index 00000000000..39537c64563 --- /dev/null +++ b/drivers/video/miniport/vga_new/vbemodes.c @@ -0,0 +1,449 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/video/miniport/vga/vbemodes.c + * PURPOSE: Mode Initialization and Mode Set for VBE-compatible cards + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include "vga.h" + +/* FUNCTIONS ******************************************************************/ + +ULONG +NTAPI +RaiseToPower2Ulong(IN ULONG Value) +{ + ULONG SquaredResult = Value; + if ((Value - 1) & Value) for (SquaredResult = 1; (SquaredResult < Value) && (SquaredResult); SquaredResult *= 2); + return SquaredResult; +} + +ULONG +NTAPI +RaiseToPower2(IN USHORT Value) +{ + ULONG SquaredResult = Value; + if ((Value - 1) & Value) for (SquaredResult = 1; (SquaredResult < Value) && (SquaredResult); SquaredResult *= 2); + return SquaredResult; +} + +ULONG +NTAPI +VbeGetVideoMemoryBaseAddress(IN PHW_DEVICE_EXTENSION VgaExtension, + IN PVIDEOMODE VgaMode) +{ + ULONG Length = 4 * 1024; + USHORT TrampolineMemorySegment, TrampolineMemoryOffset; + PVOID Context; + INT10_BIOS_ARGUMENTS BiosArguments; + PVBE_MODE_INFO VbeModeInfo; + ULONG BaseAddress; + VP_STATUS Status; + + /* Need linear and INT10 interface */ + if (!(VgaMode->fbType & VIDEO_MODE_BANKED)) return 0; + if (VgaExtension->Int10Interface.Size) return 0; + + /* Allocate scratch area and context */ + VbeModeInfo = VideoPortAllocatePool(VgaExtension, 1, sizeof(VBE_MODE_INFO), ' agV'); + if (!VbeModeInfo) return 0; + Context = VgaExtension->Int10Interface.Context; + Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context, + &TrampolineMemorySegment, + &TrampolineMemoryOffset, + &Length); + if (Status != NO_ERROR) return 0; + + /* Ask VBE BIOS for mode info */ + BiosArguments.Ecx = HIWORD(VgaMode->Mode); + BiosArguments.Edi = TrampolineMemorySegment; + BiosArguments.SegEs = TrampolineMemoryOffset; + BiosArguments.Eax = VBE_GET_MODE_INFORMATION; + Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); + if (Status != NO_ERROR) return 0; + if (BiosArguments.Eax != VBE_SUCCESS) return 0; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VbeModeInfo, + sizeof(VBE_MODE_INFO)); + if (Status != NO_ERROR) return 0; + + /* Return phys address and cleanup */ + BaseAddress = VbeModeInfo->PhysBasePtr; + VgaExtension->Int10Interface.Int10FreeBuffer(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset); + VideoPortFreePool(VgaExtension, VbeModeInfo); + return BaseAddress; +} + +VP_STATUS +NTAPI +VbeSetMode(IN PHW_DEVICE_EXTENSION VgaDeviceExtension, + IN PVIDEOMODE VgaMode, + OUT PULONG PhysPtrChange) +{ + VP_STATUS Status; + VIDEO_X86_BIOS_ARGUMENTS BiosArguments; + ULONG ModeIndex; + ULONG BaseAddress; + + VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments)); + ModeIndex = VgaMode->Mode; + BiosArguments.Eax = ModeIndex & 0x0000FFFF; + BiosArguments.Ebx = ModeIndex >> 16; + VideoPortDebugPrint(0, "Switching to %lx %lx\n", BiosArguments.Eax, BiosArguments.Ebx); + Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); + if (Status != NO_ERROR) return Status; + + /* Check for VESA mode */ + if (ModeIndex >> 16) + { + /* Mode set fail */ + if (BiosArguments.Eax != VBE_SUCCESS) return ERROR_INVALID_PARAMETER; + + /* Check current mode is desired mode */ + BiosArguments.Eax = VBE_GET_CURRENT_VBE_MODE; + Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); + if ((Status == NO_ERROR) && + (BiosArguments.Eax == VBE_SUCCESS) && + ((BiosArguments.Ebx ^ (ModeIndex >> 16)) & VBE_MODE_BITS)) + { + return ERROR_INVALID_PARAMETER; + } + + /* Set logical scanline width if different from physical */ + if (VgaMode->LogicalWidth != VgaMode->hres) + { + /* Check setting works after being set */ + BiosArguments.Eax = VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH; + BiosArguments.Ecx = VgaMode->LogicalWidth; + BiosArguments.Ebx = 0; + Status = VideoPortInt10(VgaDeviceExtension, &BiosArguments); + if ((Status != NO_ERROR) || + (BiosArguments.Eax != VBE_SUCCESS) || + (BiosArguments.Ecx != VgaMode->LogicalWidth)) + { + return ERROR_INVALID_PARAMETER; + } + } + } + + /* Get VRAM address to update changes */ + BaseAddress = VbeGetVideoMemoryBaseAddress(VgaDeviceExtension, VgaMode); + if ((BaseAddress) && (VgaMode->PhysBase != BaseAddress)) + { + *PhysPtrChange = TRUE; + VgaMode->PhysBase = BaseAddress; + } + + return NO_ERROR; +} + +VOID +NTAPI +InitializeModeTable(IN PHW_DEVICE_EXTENSION VgaExtension) +{ + ULONG ModeCount = 0; + ULONG Length = 4 * 1024; + ULONG TotalMemory; + VP_STATUS Status; + INT10_BIOS_ARGUMENTS BiosArguments; + PVBE_INFO VbeInfo; + PVBE_MODE_INFO VbeModeInfo; + PVOID Context; + USHORT TrampolineMemorySegment; + USHORT TrampolineMemoryOffset; + ULONG VbeVersion; + ULONG NewModes = 0; + BOOLEAN FourBppModeFound = FALSE; + USHORT ModeResult; + USHORT Mode; + PUSHORT ThisMode; + BOOLEAN LinearAddressing; + ULONG Size, ScreenSize; + PVIDEOMODE VgaMode; + PVOID BaseAddress; + ULONG ScreenStride = 0; + PHYSICAL_ADDRESS PhysicalAddress; + + /* Enable only default vga modes if no vesa */ + VgaModeList = ModesVGA; + if (VideoPortIsNoVesa()) + { + VgaExtension->Int10Interface.Size = 0; + VgaExtension->Int10Interface.Version = 0; + return; + } + + /* Query INT10 interface */ + VgaExtension->Int10Interface.Version = VIDEO_PORT_INT10_INTERFACE_VERSION_1; + VgaExtension->Int10Interface.Size = sizeof(VIDEO_PORT_INT10_INTERFACE); + if (VideoPortQueryServices(VgaExtension, + VideoPortServicesInt10, + (PINTERFACE)&VgaExtension->Int10Interface)) + { + VgaExtension->Int10Interface.Size = 0; + VgaExtension->Int10Interface.Version = 0; + } + + /* Add ref */ + //VideoPortDebugPrint(0, "have int10 iface\n"); + VgaExtension->Int10Interface.InterfaceReference(VgaExtension->Int10Interface.Context); + Context = VgaExtension->Int10Interface.Context; + + /* Allocate scratch area and context */ + Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context, + &TrampolineMemorySegment, + &TrampolineMemoryOffset, + &Length); + if (Status != NO_ERROR) return; + VbeInfo = VideoPortAllocatePool(VgaExtension, 1, sizeof(VBE_INFO), ' agV'); + VbeModeInfo = &VbeInfo->Modes; + if (!VbeInfo) return; + + /* Init VBE data and write to card buffer */ + //VideoPortDebugPrint(0, "have int10 data\n"); + VbeInfo->ModeArray[128] = 0xFFFF; + strcpy(VbeInfo->Info.Signature, "VBE2"); + Status = VgaExtension->Int10Interface.Int10WriteMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VbeInfo, + 512); + if (Status != NO_ERROR) return; + + /* Get controller info */ + BiosArguments.Edi = TrampolineMemoryOffset; + BiosArguments.SegEs = TrampolineMemorySegment; + BiosArguments.Eax = VBE_GET_CONTROLLER_INFORMATION; + Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); + if (Status != NO_ERROR) return; + if (BiosArguments.Eax != VBE_SUCCESS) return; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VbeInfo, + 512); + if (Status != NO_ERROR) return; + + /* Check correct VBE BIOS */ + //VideoPortDebugPrint(0, "have vbe data\n"); + TotalMemory = VbeInfo->Info.TotalMemory << 16; + VbeVersion = VbeInfo->Info.Version; + VideoPortDebugPrint(0, "vbe version %lx memory %lx\n", VbeVersion, TotalMemory); + if (!ValidateVbeInfo(VgaExtension, VbeInfo)) return; + + /* Read modes */ + //VideoPortDebugPrint(0, "read modes from %p\n", VbeInfo->Info.VideoModePtr); + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + HIWORD(VbeInfo->Info.VideoModePtr), + LOWORD(VbeInfo->Info.VideoModePtr), + VbeInfo->ModeArray, + 128 * sizeof(USHORT)); + if (Status != NO_ERROR) return; + //VideoPortDebugPrint(0, "Read modes at: %p\n", VbeInfo->ModeArray); + + /* Count modes, check for new 4bpp SVGA modes */ + ThisMode = VbeInfo->ModeArray; + ModeResult = VbeInfo->ModeArray[0]; + while (ModeResult != 0xFFFF) + { + Mode = ModeResult & 0x1FF; + //VideoPortDebugPrint(0, "Mode found: %lx\n", Mode); + if ((Mode == 0x102) || (Mode == 0x6A)) FourBppModeFound = TRUE; + ModeResult = *++ThisMode; + NewModes++; + } + + /* Remove the built-in mode if not supported by card and check max modes */ + if (!FourBppModeFound) --NumVideoModes; + if ((NewModes >= 128) && (NumVideoModes > 8)) goto Cleanup; + + /* Switch to new SVGA mode list, copy VGA modes */ + VgaModeList = VideoPortAllocatePool(VgaExtension, 1, (NewModes + NumVideoModes) * sizeof(VIDEOMODE), ' agV'); + if (!VgaModeList) goto Cleanup; + VideoPortMoveMemory(VgaModeList, ModesVGA, NumVideoModes * sizeof(VIDEOMODE)); + + /* Apply fixup for Intel Brookdale */ + if (g_bIntelBrookdaleBIOS) + { + VideoPortDebugPrint(0, "Intel Brookdale-G Video BIOS Not Support!\n"); + while (TRUE); + } + + /* Scan SVGA modes */ +// VideoPortDebugPrint(0, "Static modes: %d\n", NumVideoModes); + VgaMode = &VgaModeList[NumVideoModes]; + ThisMode = VbeInfo->ModeArray; + //VideoPortDebugPrint(0, "new modes: %d\n", NewModes); + while (NewModes--) + { + /* Get info on mode */ + BiosArguments.Eax = VBE_GET_MODE_INFORMATION; + BiosArguments.Ecx = *ThisMode; + BiosArguments.Edi = TrampolineMemoryOffset; + BiosArguments.SegEs = TrampolineMemorySegment; + Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments); + if (Status != NO_ERROR) goto Next; + if (BiosArguments.Eax != VBE_SUCCESS) goto Next; + Status = VgaExtension->Int10Interface.Int10ReadMemory(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset, + VbeModeInfo, + 256); + if (Status != NO_ERROR) goto Next; + + /* Parse graphics modes only if linear framebuffer support */ + //VideoPortDebugPrint(0, "attr: %lx\n", VbeModeInfo->ModeAttributes); + if (!(VbeModeInfo->ModeAttributes & (VBE_MODEATTR_VALID | + VBE_MODEATTR_GRAPHICS))) goto Next; + LinearAddressing = ((VbeVersion >= 0x200) && + (VbeModeInfo->PhysBasePtr) && + (VbeModeInfo->ModeAttributes & VBE_MODEATTR_LINEAR)) ? + TRUE : FALSE; + + /* Check SVGA modes if 8bpp or higher */ + //VideoPortDebugPrint(0, "PhysBase: %lx\n", VbeModeInfo->PhysBasePtr); + if ((VbeModeInfo->XResolution >= 640) && + (VbeModeInfo->YResolution >= 480) && + (VbeModeInfo->NumberOfPlanes >= 1) && + (VbeModeInfo->BitsPerPixel >= 8)) + { + /* Copy VGA mode info */ + VideoPortZeroMemory(VgaMode, sizeof(VIDEOMODE)); + VgaMode->numPlanes = VbeModeInfo->NumberOfPlanes; + VgaMode->hres = VbeModeInfo->XResolution; + VgaMode->vres = VbeModeInfo->YResolution; + VgaMode->Frequency = 1; + VgaMode->Mode = (*ThisMode << 16) | VBE_SET_VBE_MODE; + VgaMode->Granularity = VbeModeInfo->WinGranularity << 10; + //VideoPortDebugPrint(0, "Mode %lx (Granularity %d)\n", VgaMode->Mode, VgaMode->Granularity); + + /* Set flags */ + if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_COLOR) VgaMode->fbType |= VIDEO_MODE_COLOR; + if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_GRAPHICS) VgaMode->fbType |= VIDEO_MODE_GRAPHICS; + if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_NON_VGA) VgaMode->NonVgaMode = TRUE; + + /* If no char data, say 80x25 */ + VgaMode->col = VbeModeInfo->XCharSize ? VbeModeInfo->XResolution / VbeModeInfo->XCharSize : 80; + VgaMode->row = VbeModeInfo->YCharSize ? VbeModeInfo->YResolution / VbeModeInfo->YCharSize : 25; + //VideoPortDebugPrint(0, "%d by %d rows\n", VgaMode->Columns, VgaMode->Rows); + + /* Check RGB555 (15bpp only) */ + VgaMode->bitsPerPlane = VbeModeInfo->BitsPerPixel / VbeModeInfo->NumberOfPlanes; + if ((VgaMode->bitsPerPlane == 16) && (VbeModeInfo->GreenMaskSize == 5)) VgaMode->bitsPerPlane = 15; + //VideoPortDebugPrint(0, "BPP: %d\n", VgaMode->BitsPerPlane); + + /* Do linear or banked frame buffers */ + VgaMode->FrameBufferBase = 0; + if (!LinearAddressing) + { + /* Read the screen stride (scanline size) */ + ScreenStride = RaiseToPower2(VbeModeInfo->BytesPerScanLine); + VgaMode->wbytes = ScreenStride; + //VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->Stride); + + /* Size of frame buffer is Height X ScanLine, align to bank/page size */ + ScreenSize = VgaMode->hres * ScreenStride; + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + Size = (ScreenSize + ((64 * 1024) - 1)) & ((64 * 1024) - 1); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + + /* Banked VGA at 0xA0000 (64K) */ + //VideoPortDebugPrint(0, "Final size: %lx\n", Size); + VgaMode->fbType |= VIDEO_MODE_BANKED; + VgaMode->sbytes = Size; + VgaMode->PhysSize = 64 * 1024; + VgaMode->FrameBufferSize = 64 * 1024; + VgaMode->NoBankSwitch = TRUE; + VgaMode->PhysBase = 0xA0000; + VgaMode->LogicalWidth = RaiseToPower2(VgaMode->hres); + } + else + { + /* VBE 3.00+ has specific field, read legacy field if not */ + //VideoPortDebugPrint(0, "LINEAR MODE!!!\n"); + ScreenStride = (VbeVersion >= 0x300) ? VbeModeInfo->LinBytesPerScanLine : 0; + if (!ScreenStride) ScreenStride = VbeModeInfo->BytesPerScanLine; + VgaMode->wbytes = ScreenStride; + //VideoPortDebugPrint(0, "ScanLines: %lx Stride: %lx\n", VbeModeInfo->BytesPerScanLine, VgaMode->Stride); + + /* Size of frame buffer is Height X ScanLine, align to page size */ + ScreenSize = VgaMode->hres * LOWORD(VgaMode->wbytes); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + Size = RaiseToPower2Ulong(ScreenSize); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + if (Size > TotalMemory) Size = (Size + ((4 * 1024) - 1)) & ((4 * 1024) - 1); + //VideoPortDebugPrint(0, "Size: %lx\n", ScreenSize); + + /* Linear VGA must read settings from VBE */ + VgaMode->fbType |= VIDEO_MODE_LINEAR; + VgaMode->sbytes = Size; + VgaMode->PhysSize = Size; + VgaMode->FrameBufferSize = Size; + VgaMode->NoBankSwitch = FALSE; + VgaMode->PhysBase = VbeModeInfo->PhysBasePtr; + VgaMode->LogicalWidth = VgaMode->hres; + + /* Make VBE_SET_VBE_MODE command use Linear Framebuffer Select */ + VgaMode->Mode |= (VBE_MODE_LINEAR_FRAMEBUFFER << 16); + } + + /* Override bank switch if not support by card */ + if (VbeModeInfo->ModeAttributes & VBE_MODEATTR_NO_BANK_SWITCH) VgaMode->NoBankSwitch = TRUE; + + /* Next */ + if (ScreenSize <= TotalMemory) + { + VgaMode++; + ModeCount++; + } + } +Next: + /* Next */ + ThisMode++; + } + + /* Check if last mode was color to do test */ + VideoPortDebugPrint(0, "mode scan complete. Total modes: %d\n", ModeCount); + if (--VgaMode->fbType & VIDEO_MODE_COLOR) + { + /* Try map physical buffer and free if worked */ + PhysicalAddress.QuadPart = VgaMode->PhysBase; + BaseAddress = VideoPortGetDeviceBase(VgaExtension, PhysicalAddress, 4 * 1024, FALSE); + if (BaseAddress) + { + VideoPortFreeDeviceBase(VgaExtension, BaseAddress); + } + else + { + /* Not work, so throw out VBE data */ + ModeCount = 0; + } + } + + /* Cleanup sucess path */ + VideoPortFreePool(VgaExtension, VbeInfo); + VgaExtension->Int10Interface.Int10FreeBuffer(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset); + NumVideoModes += ModeCount; + return; + +Cleanup: + /* Cleanup failure path, reset standard VGA and free memory */ + VgaModeList = ModesVGA; + VideoPortFreePool(VgaExtension, VbeInfo); + VgaExtension->Int10Interface.Int10FreeBuffer(Context, + TrampolineMemorySegment, + TrampolineMemoryOffset); +} + +/* EOF */ diff --git a/drivers/video/miniport/vga_new/vga.c b/drivers/video/miniport/vga_new/vga.c new file mode 100644 index 00000000000..5b59b53624a --- /dev/null +++ b/drivers/video/miniport/vga_new/vga.c @@ -0,0 +1,1401 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/vga.c + * PURPOSE: Main Standard VGA-compatible Minport Handling Code + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +//--------------------------------------------------------------------------- + +#include "vga.h" + +//--------------------------------------------------------------------------- +// +// Function declarations +// +// Functions that start with 'VGA' are entry points for the OS port driver. +// + +VP_STATUS +VgaFindAdapter( + PVOID HwDeviceExtension, + PVOID HwContext, + PWSTR ArgumentString, + PVIDEO_PORT_CONFIG_INFO ConfigInfo, + PUCHAR Again + ); + +BOOLEAN +VgaInitialize( + PVOID HwDeviceExtension + ); + +BOOLEAN +VgaStartIO( + PVOID HwDeviceExtension, + PVIDEO_REQUEST_PACKET RequestPacket + ); + +// +// Private function prototypes. +// + +VP_STATUS +VgaQueryAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE_INFORMATION ModeInformation, + ULONG ModeInformationSize, + PULONG OutputSize + ); + +VP_STATUS +VgaQueryNumberOfAvailableModes( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_NUM_MODES NumModes, + ULONG NumModesSize, + PULONG OutputSize + ); + +VP_STATUS +VgaSetMode( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_MODE Mode, + ULONG ModeSize, +// eVb: 1.1 [SET MODE] - Add new output parameter for framebuffer update functionality + PULONG PhysPtrChange +// eVb: 1.1 [END] + ); + +BOOLEAN +VgaIsPresent( + PHW_DEVICE_EXTENSION HwDeviceExtension + ); + +VOID +VgaInterpretCmdStream( + PVOID HwDeviceExtension, + PUSHORT pusCmdStream + ); + +VP_STATUS +VgaSetColorLookup( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_CLUT ClutBuffer, + ULONG ClutBufferSize + ); + +VP_STATUS +GetDeviceDataCallback( + PVOID HwDeviceExtension, + PVOID Context, + VIDEO_DEVICE_DATA_TYPE DeviceDataType, + PVOID Identifier, + ULONG IdentifierLength, + PVOID ConfigurationData, + ULONG ConfigurationDataLength, + PVOID ComponentInformation, + ULONG ComponentInformationLength + ); + +// eVb: 1.2 [RESOURCE] - Add new function for acquiring VGA resources (I/O, memory) +VP_STATUS +VgaAcquireResources( + PHW_DEVICE_EXTENSION DeviceExtension + ); +// eVb: 1.2 [END] + +#if defined(ALLOC_PRAGMA) +#pragma alloc_text(PAGE,DriverEntry) +#pragma alloc_text(PAGE,VgaFindAdapter) +#pragma alloc_text(PAGE,VgaInitialize) +#pragma alloc_text(PAGE,VgaStartIO) +#pragma alloc_text(PAGE,VgaIsPresent) +#pragma alloc_text(PAGE,VgaSetColorLookup) +#endif + + +//--------------------------------------------------------------------------- +ULONG +// eVb: 1.3 [GCC] - Add NTAPI for GCC support +NTAPI +// eVb: 1.3 [END] +DriverEntry( + PVOID Context1, + PVOID Context2 + ) + +/*++ + +Routine Description: + + Installable driver initialization entry point. + This entry point is called directly by the I/O system. + +Arguments: + + Context1 - First context value passed by the operating system. This is + the value with which the miniport driver calls VideoPortInitialize(). + + Context2 - Second context value passed by the operating system. This is + the value with which the miniport driver calls 3VideoPortInitialize(). + +Return Value: + + Status from VideoPortInitialize() + +--*/ + +{ + + VIDEO_HW_INITIALIZATION_DATA hwInitData; + ULONG status; + ULONG initializationStatus = (ULONG) -1; + + // + // Zero out structure. + // + + VideoPortZeroMemory(&hwInitData, sizeof(VIDEO_HW_INITIALIZATION_DATA)); + + // + // Specify sizes of structure and extension. + // + + hwInitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA); + + // + // Set entry points. + // + + hwInitData.HwFindAdapter = VgaFindAdapter; + hwInitData.HwInitialize = VgaInitialize; + hwInitData.HwInterrupt = NULL; + hwInitData.HwStartIO = VgaStartIO; + + // + // Determine the size we require for the device extension. + // + + hwInitData.HwDeviceExtensionSize = sizeof(HW_DEVICE_EXTENSION); + + // + // Always start with parameters for device0 in this case. + // We can leave it like this since we know we will only ever find one + // VGA type adapter in a machine. + // + + // hwInitData.StartingDeviceNumber = 0; + + // + // Once all the relevant information has been stored, call the video + // port driver to do the initialization. + // For this device we will repeat this call three times, for ISA, EISA + // and PCI. + // We will return the minimum of all return values. + // + + // + // We will try the PCI bus first so that our ISA detection does'nt claim + // PCI cards (since it is impossible to differentiate between the two + // by looking at the registers). + // + + // + // NOTE: since this driver only supports one adapter, we will return + // as soon as we find a device, without going on to the following buses. + // Normally one would call for each bus type and return the smallest + // value. + // + +#if !defined(_ALPHA_) + + // + // Before we can enable this on ALPHA we need to find a way to map a + // sparse view of a 4MB region successfully. + // + + hwInitData.AdapterInterfaceType = PCIBus; + + initializationStatus = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + if (initializationStatus == NO_ERROR) + { + return initializationStatus; + } + +#endif + + hwInitData.AdapterInterfaceType = MicroChannel; + + initializationStatus = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + // + // Return immediately instead of checkin for smallest return code. + // + + if (initializationStatus == NO_ERROR) + { + return initializationStatus; + } + + + hwInitData.AdapterInterfaceType = Internal; + + initializationStatus = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + if (initializationStatus == NO_ERROR) + { + return initializationStatus; + } + + + hwInitData.AdapterInterfaceType = Isa; + + initializationStatus = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + if (initializationStatus == NO_ERROR) + { + return initializationStatus; + } + + + + hwInitData.AdapterInterfaceType = Eisa; + + status = VideoPortInitialize(Context1, + Context2, + &hwInitData, + NULL); + + if (initializationStatus > status) { + initializationStatus = status; + } + + return initializationStatus; + +} // end DriverEntry() + +//--------------------------------------------------------------------------- +VP_STATUS +VgaFindAdapter( + PVOID HwDeviceExtension, + PVOID HwContext, + PWSTR ArgumentString, + PVIDEO_PORT_CONFIG_INFO ConfigInfo, + PUCHAR Again + ) + +/*++ + +Routine Description: + + This routine is called to determine if the adapter for this driver + is present in the system. + If it is present, the function fills out some information describing + the adapter. + +Arguments: + + HwDeviceExtension - Supplies the miniport driver's adapter storage. This + storage is initialized to zero before this call. + + HwContext - Supplies the context value which was passed to + VideoPortInitialize(). + + ArgumentString - Supplies a NULL terminated ASCII string. This string + originates from the user. + + ConfigInfo - Returns the configuration information structure which is + filled by the miniport driver. This structure is initialized with + any known configuration information (such as SystemIoBusNumber) by + the port driver. Where possible, drivers should have one set of + defaults which do not require any supplied configuration information. + + Again - Indicates if the miniport driver wants the port driver to call + its VIDEO_HW_FIND_ADAPTER function again with a new device extension + and the same config info. This is used by the miniport drivers which + can search for several adapters on a bus. + +Return Value: + + This routine must return: + + NO_ERROR - Indicates a host adapter was found and the + configuration information was successfully determined. + + ERROR_INVALID_PARAMETER - Indicates an adapter was found but there was an + error obtaining the configuration information. If possible an error + should be logged. + + ERROR_DEV_NOT_EXIST - Indicates no host adapter was found for the + supplied configuration information. + +--*/ + +{ + + PHW_DEVICE_EXTENSION hwDeviceExtension = HwDeviceExtension; + + // + // Make sure the size of the structure is at least as large as what we + // are expecting (check version of the config info structure). + // + + if (ConfigInfo->Length < sizeof(VIDEO_PORT_CONFIG_INFO)) { + + return ERROR_INVALID_PARAMETER; + + } +// eVb: 1.4 [CIRRUS] - Remove CIRRUS-specific support + // + // Check internal VGA (MIPS and ARM systems) + // + + if ((ConfigInfo->AdapterInterfaceType == Internal) && + (VideoPortGetDeviceData(HwDeviceExtension, + VpControllerData, + &GetDeviceDataCallback, + VgaAccessRange) != NO_ERROR)) + { + return ERROR_INVALID_PARAMETER; + } +// eVb: 1.4 [END] + // + // No interrupt information is necessary. + // + + // + // Check to see if there is a hardware resource conflict. + // +// eVb: 1.5 [RESOURCE] - Use new function for acquiring VGA resources (I/O, memory) + if (VgaAcquireResources(hwDeviceExtension) != NO_ERROR) return ERROR_INVALID_PARAMETER; +// eVb: 1.5 [END] + // + // Get logical IO port addresses. + // + + if ((hwDeviceExtension->IOAddress = + VideoPortGetDeviceBase(hwDeviceExtension, + VgaAccessRange->RangeStart, + VGA_MAX_IO_PORT - VGA_BASE_IO_PORT + 1, + VgaAccessRange->RangeInIoSpace)) == NULL) + { + VideoDebugPrint((2, "VgaFindAdapter - Fail to get io address\n")); + + return ERROR_INVALID_PARAMETER; + } + + // + // Determine whether a VGA is present. + // + + if (!VgaIsPresent(hwDeviceExtension)) { + + VideoDebugPrint((0, "VgaFindAdapter - VGA Failed\n")); + return ERROR_DEV_NOT_EXIST; + } + + // + // Minimum size of the buffer required to store the hardware state + // information returned by IOCTL_VIDEO_SAVE_HARDWARE_STATE. + // + + ConfigInfo->HardwareStateSize = VGA_TOTAL_STATE_SIZE; + + // + // Pass a pointer to the emulator range we are using. + // +// eVb: 1.6 [VDM] - Disable VDM for now + ConfigInfo->NumEmulatorAccessEntries = 0; + ConfigInfo->EmulatorAccessEntries = NULL; + ConfigInfo->EmulatorAccessEntriesContext = 0; +// eVb: 1.6 [END] + // + // BUGBUG + // + // There is really no reason to have the frame buffer mapped. On an + // x86 we use if for save/restore (supposedly) but even then we + // would only need to map a 64K window, not all 16 Meg! + // + +#ifdef _X86_ + + // + // Map the video memory into the system virtual address space so we can + // clear it out and use it for save and restore. + // + + if ( (hwDeviceExtension->VideoMemoryAddress = + VideoPortGetDeviceBase(hwDeviceExtension, + VgaAccessRange[2].RangeStart, + VgaAccessRange[2].RangeLength, + FALSE)) == NULL) + { + VideoDebugPrint((1, "VgaFindAdapter - Fail to get memory address\n")); + + return ERROR_INVALID_PARAMETER; + } + + VideoPortDebugPrint(0, "vga mapped at %x\n", hwDeviceExtension->VideoMemoryAddress); +#endif +// eVb: 1.7 [VDM] - Disable VDM for now + ConfigInfo->VdmPhysicalVideoMemoryAddress.QuadPart = 0; + ConfigInfo->VdmPhysicalVideoMemoryLength = 0; +// eVb: 1.7 [END] + // + // Indicate we do not wish to be called again for another initialization. + // + + *Again = 0; + + // + // Indicate a successful completion status. + // + + return NO_ERROR; + + +} // VgaFindAdapter() + +//--------------------------------------------------------------------------- +BOOLEAN +VgaInitialize( + PVOID HwDeviceExtension + ) + +/*++ + +Routine Description: + + This routine does one time initialization of the device. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's adapter information. + +Return Value: + + None. + +--*/ + +{ + PHW_DEVICE_EXTENSION hwDeviceExtension = HwDeviceExtension; + + // + // set up the default cursor position and type. + // + + hwDeviceExtension->CursorPosition.Column = 0; + hwDeviceExtension->CursorPosition.Row = 0; + hwDeviceExtension->CursorTopScanLine = 0; + hwDeviceExtension->CursorBottomScanLine = 31; + hwDeviceExtension->CursorEnable = TRUE; + +// eVb: 1.8 [VBE] - Initialize VBE modes + InitializeModeTable(hwDeviceExtension); +// eVb: 1.8 [END] + return TRUE; + +} // VgaInitialize() + +//--------------------------------------------------------------------------- +BOOLEAN +VgaStartIO( + PVOID HwDeviceExtension, + PVIDEO_REQUEST_PACKET RequestPacket + ) + +/*++ + +Routine Description: + + This routine is the main execution routine for the miniport driver. It + accepts a Video Request Packet, performs the request, and then returns + with the appropriate status. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's adapter information. + + RequestPacket - Pointer to the video request packet. This structure + contains all the parameters passed to the VideoIoControl function. + +Return Value: + + This routine will return error codes from the various support routines + and will also return ERROR_INSUFFICIENT_BUFFER for incorrectly sized + buffers and ERROR_INVALID_FUNCTION for unsupported functions. + +--*/ + +{ + PHW_DEVICE_EXTENSION hwDeviceExtension = HwDeviceExtension; + VP_STATUS status; + VIDEO_MODE videoMode; + PVIDEO_MEMORY_INFORMATION memoryInformation; + ULONG inIoSpace; + ULONG Result; + + // + // Switch on the IoContolCode in the RequestPacket. It indicates which + // function must be performed by the driver. + // +// eVb: 1.9 [IOCTL] - Remove IOCTLs not needed yet + switch (RequestPacket->IoControlCode) + { + case IOCTL_VIDEO_SHARE_VIDEO_MEMORY: + + VideoDebugPrint((2, "VgaStartIO - ShareVideoMemory\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + case IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY: + + VideoDebugPrint((2, "VgaStartIO - UnshareVideoMemory\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_MAP_VIDEO_MEMORY: + + VideoDebugPrint((2, "VgaStartIO - MapVideoMemory\n")); + + if ( (RequestPacket->OutputBufferLength < + (RequestPacket->StatusBlock->Information = + sizeof(VIDEO_MEMORY_INFORMATION))) || + (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY)) ) + { + status = ERROR_INSUFFICIENT_BUFFER; + } + + memoryInformation = RequestPacket->OutputBuffer; + + memoryInformation->VideoRamBase = ((PVIDEO_MEMORY) + (RequestPacket->InputBuffer))->RequestedVirtualAddress; + + // + // We reserved 16 meg for the frame buffer, however, it makes + // no sense to map more memory than there is on the card. So + // only map the amount of memory we have on the card. + // +// eVb: 1.10 [CIRRUS] - On VGA, we have VRAM size since boot, use it + memoryInformation->VideoRamLength = + hwDeviceExtension->PhysicalVideoMemoryLength; +// eVb: 1.10 [END] + // + // If you change to using a dense space frame buffer, make this + // value a 4 for the ALPHA. + // + + inIoSpace = 0; + + status = VideoPortMapMemory(hwDeviceExtension, + hwDeviceExtension->PhysicalVideoMemoryBase, +// eVb: 1.11 [CIRRUS] - On VGA, we have VRAM size since boot, use it + &memoryInformation->VideoRamLength, +// eVb: 1.11 [END] + &inIoSpace, + &(memoryInformation->VideoRamBase)); + + if (status != NO_ERROR) { + VideoDebugPrint((0, "VgaStartIO - IOCTL_VIDEO_MAP_VIDEO_MEMORY failed VideoPortMapMemory (%x)\n", status)); + } + + memoryInformation->FrameBufferBase = + ((PUCHAR) (memoryInformation->VideoRamBase)) + + hwDeviceExtension->PhysicalFrameOffset.LowPart; + + memoryInformation->FrameBufferLength = + hwDeviceExtension->PhysicalFrameLength ? + hwDeviceExtension->PhysicalFrameLength : + memoryInformation->VideoRamLength; + + + VideoDebugPrint((2, "physical VideoMemoryBase %08lx\n", hwDeviceExtension->PhysicalVideoMemoryBase)); + VideoDebugPrint((2, "physical VideoMemoryLength %08lx\n", hwDeviceExtension->PhysicalVideoMemoryLength)); + VideoDebugPrint((2, "VideoMemoryBase %08lx\n", memoryInformation->VideoRamBase)); + VideoDebugPrint((2, "VideoMemoryLength %08lx\n", memoryInformation->VideoRamLength)); + + VideoDebugPrint((2, "physical framebuf offset %08lx\n", hwDeviceExtension->PhysicalFrameOffset.LowPart)); + VideoDebugPrint((2, "framebuf base %08lx\n", memoryInformation->FrameBufferBase)); + VideoDebugPrint((2, "physical framebuf len %08lx\n", hwDeviceExtension->PhysicalFrameLength)); + VideoDebugPrint((2, "framebuf length %08lx\n", memoryInformation->FrameBufferLength)); + + break; + + case IOCTL_VIDEO_UNMAP_VIDEO_MEMORY: + + VideoDebugPrint((2, "VgaStartIO - UnMapVideoMemory\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_QUERY_AVAIL_MODES: + + VideoDebugPrint((2, "VgaStartIO - QueryAvailableModes\n")); + + status = VgaQueryAvailableModes(HwDeviceExtension, + (PVIDEO_MODE_INFORMATION) + RequestPacket->OutputBuffer, + RequestPacket->OutputBufferLength, + &RequestPacket->StatusBlock->Information); + + break; + + + case IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES: + + VideoDebugPrint((2, "VgaStartIO - QueryNumAvailableModes\n")); + + status = VgaQueryNumberOfAvailableModes(HwDeviceExtension, + (PVIDEO_NUM_MODES) + RequestPacket->OutputBuffer, + RequestPacket->OutputBufferLength, + &RequestPacket->StatusBlock->Information); + + break; + + + case IOCTL_VIDEO_QUERY_CURRENT_MODE: + + VideoDebugPrint((2, "VgaStartIO - QueryCurrentMode\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_CURRENT_MODE: + + VideoDebugPrint((2, "VgaStartIO - SetCurrentModes\n")); + + status = VgaSetMode(HwDeviceExtension, + (PVIDEO_MODE) RequestPacket->InputBuffer, + RequestPacket->InputBufferLength, +// eVb: 1.12 [SET MODE] - Use new output parameter for framebuffer update functionality + &Result); +// eVb: 1.12 [END] + + break; + + + case IOCTL_VIDEO_RESET_DEVICE: + + VideoDebugPrint((2, "VgaStartIO - Reset Device\n")); + + videoMode.RequestedMode = 0; + + VgaSetMode(HwDeviceExtension, + (PVIDEO_MODE) &videoMode, + sizeof(videoMode), +// eVb: 1.13 [SET MODE] - Use new output parameter for framebuffer update functionality + &Result); +// eVb: 1.13 [END] + + // + // Always return succcess since settings the text mode will fail on + // non-x86. + // + // Also, failiure to set the text mode is not fatal in any way, since + // this operation must be followed by another set mode operation. + // + + status = NO_ERROR; + + break; + + + case IOCTL_VIDEO_LOAD_AND_SET_FONT: + + VideoDebugPrint((2, "VgaStartIO - LoadAndSetFont\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_QUERY_CURSOR_POSITION: + + VideoDebugPrint((2, "VgaStartIO - QueryCursorPosition\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_CURSOR_POSITION: + + VideoDebugPrint((2, "VgaStartIO - SetCursorPosition\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_QUERY_CURSOR_ATTR: + + VideoDebugPrint((2, "VgaStartIO - QueryCursorAttributes\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_CURSOR_ATTR: + + VideoDebugPrint((2, "VgaStartIO - SetCursorAttributes\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_PALETTE_REGISTERS: + + VideoDebugPrint((2, "VgaStartIO - SetPaletteRegs\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SET_COLOR_REGISTERS: + + VideoDebugPrint((2, "VgaStartIO - SetColorRegs\n")); + + status = VgaSetColorLookup(HwDeviceExtension, + (PVIDEO_CLUT) RequestPacket->InputBuffer, + RequestPacket->InputBufferLength); + + break; + + + case IOCTL_VIDEO_ENABLE_VDM: + + VideoDebugPrint((2, "VgaStartIO - EnableVDM\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_RESTORE_HARDWARE_STATE: + + VideoDebugPrint((2, "VgaStartIO - RestoreHardwareState\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + + case IOCTL_VIDEO_SAVE_HARDWARE_STATE: + + VideoDebugPrint((2, "VgaStartIO - SaveHardwareState\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + case IOCTL_VIDEO_GET_BANK_SELECT_CODE: + + VideoDebugPrint((2, "VgaStartIO - GetBankSelectCode\n")); + + status = ERROR_INVALID_FUNCTION; + break; + + case IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES: + case IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES: + + // + // if we get here, an invalid IoControlCode was specified. + // + + default: + + VideoDebugPrint((0, "Fell through vga startIO routine - invalid command\n")); + + status = ERROR_INVALID_FUNCTION; + + break; + + } +// eVb: 1.9 [END] + RequestPacket->StatusBlock->Status = status; + + return TRUE; + +} // VgaStartIO() + + +//--------------------------------------------------------------------------- +// +// private routines +// + + +//--------------------------------------------------------------------------- +BOOLEAN +VgaIsPresent( + PHW_DEVICE_EXTENSION HwDeviceExtension + ) + +/*++ + +Routine Description: + + This routine returns TRUE if a VGA is present. Determining whether a VGA + is present is a two-step process. First, this routine walks bits through + the Bit Mask register, to establish that there are readable indexed + registers (EGAs normally don't have readable registers, and other adapters + are unlikely to have indexed registers). This test is done first because + it's a non-destructive EGA rejection test (correctly rejects EGAs, but + doesn't potentially mess up the screen or the accessibility of display + memory). Normally, this would be an adequate test, but some EGAs have + readable registers, so next, we check for the existence of the Chain4 bit + in the Memory Mode register; this bit doesn't exist in EGAs. It's + conceivable that there are EGAs with readable registers and a register bit + where Chain4 is stored, although I don't know of any; if a better test yet + is needed, memory could be written to in Chain4 mode, and then examined + plane by plane in non-Chain4 mode to make sure the Chain4 bit did what it's + supposed to do. However, the current test should be adequate to eliminate + just about all EGAs, and 100% of everything else. + + If this function fails to find a VGA, it attempts to undo any damage it + may have inadvertently done while testing. The underlying assumption for + the damage control is that if there's any non-VGA adapter at the tested + ports, it's an EGA or an enhanced EGA, because: a) I don't know of any + other adapters that use 3C4/5 or 3CE/F, and b), if there are other + adapters, I certainly don't know how to restore their original states. So + all error recovery is oriented toward putting an EGA back in a writable + state, so that error messages are visible. The EGA's state on entry is + assumed to be text mode, so the Memory Mode register is restored to the + default state for text mode. + + If a VGA is found, the VGA is returned to its original state after + testing is finished. + +Arguments: + + None. + +Return Value: + + TRUE if a VGA is present, FALSE if not. + +--*/ + +{ + UCHAR originalGCAddr; + UCHAR originalSCAddr; + UCHAR originalBitMask; + UCHAR originalReadMap; + UCHAR originalMemoryMode; + UCHAR testMask; + BOOLEAN returnStatus; + + // + // Remember the original state of the Graphics Controller Address register. + // + + originalGCAddr = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT); + + // + // Write the Read Map register with a known state so we can verify + // that it isn't changed after we fool with the Bit Mask. This ensures + // that we're dealing with indexed registers, since both the Read Map and + // the Bit Mask are addressed at GRAPH_DATA_PORT. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_READ_MAP); + + // + // If we can't read back the Graphics Address register setting we just + // performed, it's not readable and this isn't a VGA. + // + + if ((VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT) & GRAPH_ADDR_MASK) != IND_READ_MAP) { + + return FALSE; + } + + // + // Set the Read Map register to a known state. + // + + originalReadMap = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_TEST_SETTING); + + if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT) != READ_MAP_TEST_SETTING) { + + // + // The Read Map setting we just performed can't be read back; not a + // VGA. Restore the default Read Map state. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_DEFAULT); + + return FALSE; + } + + // + // Remember the original setting of the Bit Mask register. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_BIT_MASK); + if ((VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT) & GRAPH_ADDR_MASK) != IND_BIT_MASK) { + + // + // The Graphics Address register setting we just made can't be read + // back; not a VGA. Restore the default Read Map state. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_READ_MAP); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_DEFAULT); + + return FALSE; + } + + originalBitMask = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT); + + // + // Set up the initial test mask we'll write to and read from the Bit Mask. + // + + testMask = 0xBB; + + do { + + // + // Write the test mask to the Bit Mask. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, testMask); + + // + // Make sure the Bit Mask remembered the value. + // + + if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT) != testMask) { + + // + // The Bit Mask is not properly writable and readable; not a VGA. + // Restore the Bit Mask and Read Map to their default states. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, BIT_MASK_DEFAULT); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_READ_MAP); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_DEFAULT); + + return FALSE; + } + + // + // Cycle the mask for next time. + // + + testMask >>= 1; + + } while (testMask != 0); + + // + // There's something readable at GRAPH_DATA_PORT; now switch back and + // make sure that the Read Map register hasn't changed, to verify that + // we're dealing with indexed registers. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_READ_MAP); + if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT) != READ_MAP_TEST_SETTING) { + + // + // The Read Map is not properly writable and readable; not a VGA. + // Restore the Bit Mask and Read Map to their default states, in case + // this is an EGA, so subsequent writes to the screen aren't garbled. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, READ_MAP_DEFAULT); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_BIT_MASK); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, BIT_MASK_DEFAULT); + + return FALSE; + } + + // + // We've pretty surely verified the existence of the Bit Mask register. + // Put the Graphics Controller back to the original state. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, originalReadMap); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, IND_BIT_MASK); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_DATA_PORT, originalBitMask); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + GRAPH_ADDRESS_PORT, originalGCAddr); + + // + // Now, check for the existence of the Chain4 bit. + // + + // + // Remember the original states of the Sequencer Address and Memory Mode + // registers. + // + + originalSCAddr = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT, IND_MEMORY_MODE); + if ((VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT) & SEQ_ADDR_MASK) != IND_MEMORY_MODE) { + + // + // Couldn't read back the Sequencer Address register setting we just + // performed. + // + + return FALSE; + } + originalMemoryMode = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT); + + // + // Toggle the Chain4 bit and read back the result. This must be done during + // sync reset, since we're changing the chaining state. + // + + // + // Begin sync reset. + // + + VideoPortWritePortUshort((PUSHORT)(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT), + (IND_SYNC_RESET + (START_SYNC_RESET_VALUE << 8))); + + // + // Toggle the Chain4 bit. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT, IND_MEMORY_MODE); + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT, (UCHAR)(originalMemoryMode ^ CHAIN4_MASK)); + + if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT) != (UCHAR) (originalMemoryMode ^ CHAIN4_MASK)) { + + // + // Chain4 bit not there; not a VGA. + // Set text mode default for Memory Mode register. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT, MEMORY_MODE_TEXT_DEFAULT); + // + // End sync reset. + // + + VideoPortWritePortUshort((PUSHORT) (HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT), + (IND_SYNC_RESET + (END_SYNC_RESET_VALUE << 8))); + + returnStatus = FALSE; + + } else { + + // + // It's a VGA. + // + + // + // Restore the original Memory Mode setting. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_DATA_PORT, originalMemoryMode); + + // + // End sync reset. + // + + VideoPortWritePortUshort((PUSHORT)(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT), + (USHORT)(IND_SYNC_RESET + (END_SYNC_RESET_VALUE << 8))); + + // + // Restore the original Sequencer Address setting. + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + SEQ_ADDRESS_PORT, originalSCAddr); + + returnStatus = TRUE; + } + + return returnStatus; + +} // VgaIsPresent() + + +//--------------------------------------------------------------------------- +VP_STATUS +VgaSetColorLookup( + PHW_DEVICE_EXTENSION HwDeviceExtension, + PVIDEO_CLUT ClutBuffer, + ULONG ClutBufferSize + ) + +/*++ + +Routine Description: + + This routine sets a specified portion of the DAC color lookup table + settings. + +Arguments: + + HwDeviceExtension - Pointer to the miniport driver's device extension. + + ClutBufferSize - Length of the input buffer supplied by the user. + + ClutBuffer - Pointer to the structure containing the color lookup table. + +Return Value: + + NO_ERROR - information returned successfully + + ERROR_INSUFFICIENT_BUFFER - input buffer not large enough for input data. + + ERROR_INVALID_PARAMETER - invalid clut size. + +--*/ + +{ + PVIDEOMODE CurrentMode = HwDeviceExtension->CurrentMode; + USHORT i; + + // + // Check if the size of the data in the input buffer is large enough. + // + + if ( (ClutBufferSize < sizeof(VIDEO_CLUT) - sizeof(ULONG)) || + (ClutBufferSize < sizeof(VIDEO_CLUT) + + (sizeof(ULONG) * (ClutBuffer->NumEntries - 1)) ) ) { + + return ERROR_INSUFFICIENT_BUFFER; + + } + + // + // Check to see if the parameters are valid. + // + + if ( (ClutBuffer->NumEntries == 0) || + (ClutBuffer->FirstEntry > VIDEO_MAX_COLOR_REGISTER) || + (ClutBuffer->FirstEntry + ClutBuffer->NumEntries > + VIDEO_MAX_COLOR_REGISTER + 1) ) { + + return ERROR_INVALID_PARAMETER; + + } +// eVb: 1.14 [VBE] - Add VBE color support + // + // Check SVGA mode + // + + if (CurrentMode->bitsPerPlane >= 8) return VbeSetColorLookup(HwDeviceExtension, ClutBuffer); +// eVb: 1.14 [END] + // + // Path for VGA mode + // +// eVb: 1.15 [VBE] - Add VBE support for non-VGA-compatible detected modes + if (!CurrentMode->NonVgaMode) + { +// eVb: 1.15 [END] + // + // Set CLUT registers directly on the hardware + // + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_ADDRESS_WRITE_PORT, (UCHAR) ClutBuffer->FirstEntry); + + for (i = 0; i < ClutBuffer->NumEntries; i++) { + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_ADDRESS_WRITE_PORT, + (UCHAR)(i + ClutBuffer->FirstEntry)); + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_DATA_REG_PORT, + ClutBuffer->LookupTable[i].RgbArray.Red); + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_DATA_REG_PORT, + ClutBuffer->LookupTable[i].RgbArray.Green); + + VideoPortWritePortUchar(HwDeviceExtension->IOAddress + + DAC_DATA_REG_PORT, + ClutBuffer->LookupTable[i].RgbArray.Blue); + } + return NO_ERROR; + } + + return ERROR_INVALID_PARAMETER; + +} // end VgaSetColorLookup() + +VP_STATUS +GetDeviceDataCallback( + PVOID HwDeviceExtension, + PVOID Context, + VIDEO_DEVICE_DATA_TYPE DeviceDataType, + PVOID Identifier, + ULONG IdentifierLength, + PVOID ConfigurationData, + ULONG ConfigurationDataLength, + PVOID ComponentInformation, + ULONG ComponentInformationLength + ) + +/*++ + +Routine Description: + + Callback routine for the VideoPortGetDeviceData function. + +Arguments: + + HwDeviceExtension - Pointer to the miniport drivers device extension. + + Context - Context value passed to the VideoPortGetDeviceData function. + + DeviceDataType - The type of data that was requested in + VideoPortGetDeviceData. + + Identifier - Pointer to a string that contains the name of the device, + as setup by the ROM or ntdetect. + + IdentifierLength - Length of the Identifier string. + + ConfigurationData - Pointer to the configuration data for the device or + BUS. + + ConfigurationDataLength - Length of the data in the configurationData + field. + + ComponentInformation - Undefined. + + ComponentInformationLength - Undefined. + +Return Value: + + Returns NO_ERROR if the function completed properly. + Returns ERROR_DEV_NOT_EXIST if we did not find the device. + Returns ERROR_INVALID_PARAMETER otherwise. + +--*/ + +{ + VideoPortDebugPrint(Error, "Detected internal VGA chip on embedded board, todo\n"); + while (TRUE); + return NO_ERROR; + +} //end GetDeviceDataCallback() + +// eVb: 1.16 [RESOURCE] - Add new function for acquiring VGA resources (I/O, memory) +VP_STATUS +VgaAcquireResources( + PHW_DEVICE_EXTENSION DeviceExtension + ) +{ + VP_STATUS Status = NO_ERROR; + ULONG Ranges, i; + + // + // Try exclusive ranges (vga + ati) + // + + Ranges = NUM_VGA_ACCESS_RANGES; + for (i = 0; i < Ranges; i++) VgaAccessRange[i].RangeShareable = FALSE; + if (VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange) != NO_ERROR) + { + // + // Not worked, try vga only + // + + Ranges = 3; + if (VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange) != NO_ERROR) + { + // + // Still not, try shared ranges + // + + for (i = 0; i < Ranges; i++) VgaAccessRange[i].RangeShareable = TRUE; + Status = VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange); + if (Status == NO_ERROR) + { + // + // It did work + // + + VideoPortVerifyAccessRanges(DeviceExtension, 0, 0); + Status = NO_ERROR; + } + } + } + + if (Status == NO_ERROR) + { + // + // Worked with exclusive, also try shared + // + + for (i = 0; i < Ranges; i++) VgaAccessRange[i].RangeShareable = TRUE; + Status = VideoPortVerifyAccessRanges(DeviceExtension, Ranges, VgaAccessRange); + } + + return Status; +} +// eVb: 1.16 [END] diff --git a/drivers/video/miniport/vga_new/vga.h b/drivers/video/miniport/vga_new/vga.h new file mode 100644 index 00000000000..21e411584f8 --- /dev/null +++ b/drivers/video/miniport/vga_new/vga.h @@ -0,0 +1,446 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/vga.h + * PURPOSE: Main Header File + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#include "ntdef.h" +#include "dderror.h" +#include "devioctl.h" +#include "miniport.h" +#include "ntddvdeo.h" +#include "video.h" +#include "cmdcnst.h" + +// +// Base address of VGA memory range. Also used as base address of VGA +// memory when loading a font, which is done with the VGA mapped at A0000. +// + +#define MEM_VGA 0xA0000 +#define MEM_VGA_SIZE 0x20000 + +// +// For memory mapped IO +// + +#define MEMORY_MAPPED_IO_OFFSET (0xB8000 - 0xA0000) + +// +// Port definitions for filling the ACCESS_RANGES structure in the miniport +// information, defines the range of I/O ports the VGA spans. +// There is a break in the IO ports - a few ports are used for the parallel +// port. Those cannot be defined in the ACCESS_RANGE, but are still mapped +// so all VGA ports are in one address range. +// + +#define VGA_BASE_IO_PORT 0x000003B0 +#define VGA_START_BREAK_PORT 0x000003BB +#define VGA_END_BREAK_PORT 0x000003C0 +#define VGA_MAX_IO_PORT 0x000003DF + +// +// VGA register definitions +// +// eVb: 3.1 [VGA] - Use offsets from the VGA Port Address instead of absolute +#define CRTC_ADDRESS_PORT_MONO 0x0004 // CRT Controller Address and +#define CRTC_DATA_PORT_MONO 0x0005 // Data registers in mono mode +#define FEAT_CTRL_WRITE_PORT_MONO 0x000A // Feature Control write port + // in mono mode +#define INPUT_STATUS_1_MONO 0x000A // Input Status 1 register read + // port in mono mode +#define ATT_INITIALIZE_PORT_MONO INPUT_STATUS_1_MONO + // Register to read to reset + // Attribute Controller index/data + +#define ATT_ADDRESS_PORT 0x0010 // Attribute Controller Address and +#define ATT_DATA_WRITE_PORT 0x0010 // Data registers share one port + // for writes, but only Address is + // readable at 0x3C0 +#define ATT_DATA_READ_PORT 0x0011 // Attribute Controller Data reg is + // readable here +#define MISC_OUTPUT_REG_WRITE_PORT 0x0012 // Miscellaneous Output reg write + // port +#define INPUT_STATUS_0_PORT 0x0012 // Input Status 0 register read + // port +#define VIDEO_SUBSYSTEM_ENABLE_PORT 0x0013 // Bit 0 enables/disables the + // entire VGA subsystem +#define SEQ_ADDRESS_PORT 0x0014 // Sequence Controller Address and +#define SEQ_DATA_PORT 0x0015 // Data registers +#define DAC_PIXEL_MASK_PORT 0x0016 // DAC pixel mask reg +#define DAC_ADDRESS_READ_PORT 0x0017 // DAC register read index reg, + // write-only +#define DAC_STATE_PORT 0x0017 // DAC state (read/write), + // read-only +#define DAC_ADDRESS_WRITE_PORT 0x0018 // DAC register write index reg +#define DAC_DATA_REG_PORT 0x0019 // DAC data transfer reg +#define FEAT_CTRL_READ_PORT 0x001A // Feature Control read port +#define MISC_OUTPUT_REG_READ_PORT 0x001C // Miscellaneous Output reg read + // port +#define GRAPH_ADDRESS_PORT 0x001E // Graphics Controller Address +#define GRAPH_DATA_PORT 0x001F // and Data registers + +#define CRTC_ADDRESS_PORT_COLOR 0x0024 // CRT Controller Address and +#define CRTC_DATA_PORT_COLOR 0x0025 // Data registers in color mode +#define FEAT_CTRL_WRITE_PORT_COLOR 0x002A // Feature Control write port +#define INPUT_STATUS_1_COLOR 0x002A // Input Status 1 register read + // port in color mode +// eVb: 3.2 [END] +#define ATT_INITIALIZE_PORT_COLOR INPUT_STATUS_1_COLOR + // Register to read to reset + // Attribute Controller index/data + // toggle in color mode + +// +// Offsets in HardwareStateHeader->PortValue[] of save areas for non-indexed +// VGA registers. +// + +#define CRTC_ADDRESS_MONO_OFFSET 0x04 +#define FEAT_CTRL_WRITE_MONO_OFFSET 0x0A +#define ATT_ADDRESS_OFFSET 0x10 +#define MISC_OUTPUT_REG_WRITE_OFFSET 0x12 +#define VIDEO_SUBSYSTEM_ENABLE_OFFSET 0x13 +#define SEQ_ADDRESS_OFFSET 0x14 +#define DAC_PIXEL_MASK_OFFSET 0x16 +#define DAC_STATE_OFFSET 0x17 +#define DAC_ADDRESS_WRITE_OFFSET 0x18 +#define GRAPH_ADDRESS_OFFSET 0x1E +#define CRTC_ADDRESS_COLOR_OFFSET 0x24 +#define FEAT_CTRL_WRITE_COLOR_OFFSET 0x2A + + // toggle in color mode +// +// VGA indexed register indexes. +// + +// CL-GD542x specific registers: +// +#define IND_CL_EXTS_ENB 0x06 // index in Sequencer to enable exts +#define IND_NORD_SCRATCH_PAD 0x09 // index in Seq of Nordic scratch pad +#define IND_CL_SCRATCH_PAD 0x0A // index in Seq of 542x scratch pad +#define IND_ALP_SCRATCH_PAD 0x15 // index in Seq of Alpine scratch pad +#define IND_CL_REV_REG 0x25 // index in CRTC of ID Register +#define IND_CL_ID_REG 0x27 // index in CRTC of ID Register +// +#define IND_CURSOR_START 0x0A // index in CRTC of the Cursor Start +#define IND_CURSOR_END 0x0B // and End registers +#define IND_CURSOR_HIGH_LOC 0x0E // index in CRTC of the Cursor Location +#define IND_CURSOR_LOW_LOC 0x0F // High and Low Registers +#define IND_VSYNC_END 0x11 // index in CRTC of the Vertical Sync + // End register, which has the bit + // that protects/unprotects CRTC + // index registers 0-7 +#define IND_CR2C 0x2C // Nordic LCD Interface Register +#define IND_CR2D 0x2D // Nordic LCD Display Control +#define IND_SET_RESET_ENABLE 0x01 // index of Set/Reset Enable reg in GC +#define IND_DATA_ROTATE 0x03 // index of Data Rotate reg in GC +#define IND_READ_MAP 0x04 // index of Read Map reg in Graph Ctlr +#define IND_GRAPH_MODE 0x05 // index of Mode reg in Graph Ctlr +#define IND_GRAPH_MISC 0x06 // index of Misc reg in Graph Ctlr +#define IND_BIT_MASK 0x08 // index of Bit Mask reg in Graph Ctlr +#define IND_SYNC_RESET 0x00 // index of Sync Reset reg in Seq +#define IND_MAP_MASK 0x02 // index of Map Mask in Sequencer +#define IND_MEMORY_MODE 0x04 // index of Memory Mode reg in Seq +#define IND_CRTC_PROTECT 0x11 // index of reg containing regs 0-7 in + // CRTC +#define IND_CRTC_COMPAT 0x34 // index of CRTC Compatibility reg + // in CRTC +#define IND_PERF_TUNING 0x16 // index of performance tuning in Seq +#define START_SYNC_RESET_VALUE 0x01 // value for Sync Reset reg to start + // synchronous reset +#define END_SYNC_RESET_VALUE 0x03 // value for Sync Reset reg to end + // synchronous reset + +// +// Value to write to Extensions Control register values extensions. +// + +#define CL64xx_EXTENSION_ENABLE_INDEX 0x0A // GR0A to be exact! +#define CL64xx_EXTENSION_ENABLE_VALUE 0xEC +#define CL64xx_EXTENSION_DISABLE_VALUE 0xCE +#define CL64xx_TRISTATE_CONTROL_REG 0xA1 + +#define CL6340_ENABLE_READBACK_REGISTER 0xE0 +#define CL6340_ENABLE_READBACK_ALLSEL_VALUE 0xF0 +#define CL6340_ENABLE_READBACK_OFF_VALUE 0x00 +#define CL6340_IDENTIFICATION_REGISTER 0xE9 +// +// Values for Attribute Controller Index register to turn video off +// and on, by setting bit 5 to 0 (off) or 1 (on). +// + +#define VIDEO_DISABLE 0 +#define VIDEO_ENABLE 0x20 + +#define INDEX_ENABLE_AUTO_START 0x31 + +// Masks to keep only the significant bits of the Graphics Controller and +// Sequencer Address registers. Masking is necessary because some VGAs, such +// as S3-based ones, don't return unused bits set to 0, and some SVGAs use +// these bits if extensions are enabled. +// + +#define GRAPH_ADDR_MASK 0x0F +#define SEQ_ADDR_MASK 0x07 + +// +// Mask used to toggle Chain4 bit in the Sequencer's Memory Mode register. +// + +#define CHAIN4_MASK 0x08 + +// +// Value written to the Read Map register when identifying the existence of +// a VGA in VgaInitialize. This value must be different from the final test +// value written to the Bit Mask in that routine. +// + +#define READ_MAP_TEST_SETTING 0x03 + +// +// Default text mode setting for various registers, used to restore their +// states if VGA detection fails after they've been modified. +// + +#define MEMORY_MODE_TEXT_DEFAULT 0x02 +#define BIT_MASK_DEFAULT 0xFF +#define READ_MAP_DEFAULT 0x00 + + +// +// Palette-related info. +// + +// +// Highest valid DAC color register index. +// + +#define VIDEO_MAX_COLOR_REGISTER 0xFF + +// +// Highest valid palette register index +// + +#define VIDEO_MAX_PALETTE_REGISTER 0x0F + +// +// Driver Specific Attribute Flags +// + +#define CAPS_NO_HOST_XFER 0x00000002 // Do not use host xfers to + // the blt engine. +#define CAPS_SW_POINTER 0x00000004 // Use software pointer. +#define CAPS_TRUE_COLOR 0x00000008 // Set upper color registers. +#define CAPS_MM_IO 0x00000010 // Use memory mapped IO. +#define CAPS_BLT_SUPPORT 0x00000020 // BLTs are supported +#define CAPS_IS_542x 0x00000040 // This is a 542x +#define CAPS_IS_5436 0x00000080 // This is a 5436 +#define CAPS_CURSOR_VERT_EXP 0x00000100 // Flag set if 8x6 panel, + // but 6x4 resolution + +// +// Structure used to describe each video mode in ModesVGA[]. +// + +typedef struct { + USHORT fbType; // color or monochrome, text or graphics, via + // VIDEO_MODE_COLOR and VIDEO_MODE_GRAPHICS + USHORT numPlanes; // # of video memory planes + USHORT bitsPerPlane; // # of bits of color in each plane + SHORT col; // # of text columns across screen with default font + SHORT row; // # of text rows down screen with default font + USHORT hres; // # of pixels across screen + USHORT vres; // # of scan lines down screen +// eVb: 3.2 [VGA] - Store frequency next to resolution data + ULONG Frequency; // Vertical Frequency +// eVb: 3.2 [END] + USHORT wbytes; // # of bytes from start of one scan line to start of next + ULONG sbytes; // total size of addressable display memory in bytes +// eVb: 3.3 [VBE] - Add VBE mode and bank flag + ULONG NoBankSwitch; + ULONG Mode; +// eVb: 3.3 [VBE] + PUSHORT CmdStream; // pointer to array of register-setting commands to + // set up mode +// eVb: 3.4 [VBE] - Add fields to track linear addresses/sizes and flags + ULONG PhysBase; + ULONG FrameBufferBase; + ULONG FrameBufferSize; + ULONG PhysSize; + ULONG LogicalWidth; + ULONG NonVgaMode; + ULONG Granularity; +// eVb: 3.4 [END] +} VIDEOMODE, *PVIDEOMODE; + +// +// Mode into which to put the VGA before starting a VDM, so it's a plain +// vanilla VGA. (This is the mode's index in ModesVGA[], currently standard +// 80x25 text mode.) +// + +#define DEFAULT_MODE 0 + + +// +// Info used by the Validator functions and save/restore code. +// Structure used to trap register accesses that must be done atomically. +// + +#define VGA_MAX_VALIDATOR_DATA 100 + +#define VGA_VALIDATOR_UCHAR_ACCESS 1 +#define VGA_VALIDATOR_USHORT_ACCESS 2 +#define VGA_VALIDATOR_ULONG_ACCESS 3 + +typedef struct _VGA_VALIDATOR_DATA { + ULONG Port; + UCHAR AccessType; + ULONG Data; +} VGA_VALIDATOR_DATA, *PVGA_VALIDATOR_DATA; + +// +// Number of bytes to save in each plane. +// + +#define VGA_PLANE_SIZE 0x10000 + +// +// Number of each type of indexed register in a standard VGA, used by +// validator and state save/restore functions. +// +// Note: VDMs currently only support basic VGAs only. +// + +#define VGA_NUM_SEQUENCER_PORTS 5 +#define VGA_NUM_CRTC_PORTS 25 +#define VGA_NUM_GRAPH_CONT_PORTS 9 +#define VGA_NUM_ATTRIB_CONT_PORTS 21 +#define VGA_NUM_DAC_ENTRIES 256 + +#define EXT_NUM_GRAPH_CONT_PORTS 0 +#define EXT_NUM_SEQUENCER_PORTS 0 +#define EXT_NUM_CRTC_PORTS 0 +#define EXT_NUM_ATTRIB_CONT_PORTS 0 +#define EXT_NUM_DAC_ENTRIES 0 + +// +// These constants determine the offsets within the +// VIDEO_HARDWARE_STATE_HEADER structure that are used to save and +// restore the VGA's state. +// + +#define VGA_HARDWARE_STATE_SIZE sizeof(VIDEO_HARDWARE_STATE_HEADER) + +#define VGA_BASIC_SEQUENCER_OFFSET (VGA_HARDWARE_STATE_SIZE + 0) +#define VGA_BASIC_CRTC_OFFSET (VGA_BASIC_SEQUENCER_OFFSET + \ + VGA_NUM_SEQUENCER_PORTS) +#define VGA_BASIC_GRAPH_CONT_OFFSET (VGA_BASIC_CRTC_OFFSET + \ + VGA_NUM_CRTC_PORTS) +#define VGA_BASIC_ATTRIB_CONT_OFFSET (VGA_BASIC_GRAPH_CONT_OFFSET + \ + VGA_NUM_GRAPH_CONT_PORTS) +#define VGA_BASIC_DAC_OFFSET (VGA_BASIC_ATTRIB_CONT_OFFSET + \ + VGA_NUM_ATTRIB_CONT_PORTS) +#define VGA_BASIC_LATCHES_OFFSET (VGA_BASIC_DAC_OFFSET + \ + (3 * VGA_NUM_DAC_ENTRIES)) + +#define VGA_EXT_SEQUENCER_OFFSET (VGA_BASIC_LATCHES_OFFSET + 4) +#define VGA_EXT_CRTC_OFFSET (VGA_EXT_SEQUENCER_OFFSET + \ + EXT_NUM_SEQUENCER_PORTS) +#define VGA_EXT_GRAPH_CONT_OFFSET (VGA_EXT_CRTC_OFFSET + \ + EXT_NUM_CRTC_PORTS) +#define VGA_EXT_ATTRIB_CONT_OFFSET (VGA_EXT_GRAPH_CONT_OFFSET +\ + EXT_NUM_GRAPH_CONT_PORTS) +#define VGA_EXT_DAC_OFFSET (VGA_EXT_ATTRIB_CONT_OFFSET + \ + EXT_NUM_ATTRIB_CONT_PORTS) + +#define VGA_VALIDATOR_OFFSET (VGA_EXT_DAC_OFFSET + 4 * EXT_NUM_DAC_ENTRIES) + +#define VGA_VALIDATOR_AREA_SIZE sizeof (ULONG) + (VGA_MAX_VALIDATOR_DATA * \ + sizeof (VGA_VALIDATOR_DATA)) + \ + sizeof (ULONG) + \ + sizeof (ULONG) + \ + sizeof (PVIDEO_ACCESS_RANGE) + +#define VGA_MISC_DATA_AREA_OFFSET VGA_VALIDATOR_OFFSET + VGA_VALIDATOR_AREA_SIZE + +#define VGA_MISC_DATA_AREA_SIZE 0 + +#define VGA_PLANE_0_OFFSET VGA_MISC_DATA_AREA_OFFSET + VGA_MISC_DATA_AREA_SIZE + +#define VGA_PLANE_1_OFFSET VGA_PLANE_0_OFFSET + VGA_PLANE_SIZE +#define VGA_PLANE_2_OFFSET VGA_PLANE_1_OFFSET + VGA_PLANE_SIZE +#define VGA_PLANE_3_OFFSET VGA_PLANE_2_OFFSET + VGA_PLANE_SIZE + +// +// Space needed to store all state data. +// + +#define VGA_TOTAL_STATE_SIZE VGA_PLANE_3_OFFSET + VGA_PLANE_SIZE + + +// +// Device extension for the driver object. This data is only used +// locally, so this structure can be added to as needed. +// + +typedef struct _HW_DEVICE_EXTENSION { + + PHYSICAL_ADDRESS PhysicalVideoMemoryBase; // physical memory address and + PHYSICAL_ADDRESS PhysicalFrameOffset; // physical memory address and + ULONG PhysicalVideoMemoryLength; // length of display memory + ULONG PhysicalFrameLength; // length of display memory for + // the current mode. + + PUCHAR IOAddress; // base I/O address of VGA ports + PUCHAR VideoMemoryAddress; // base virtual memory address of VGA memory + ULONG ModeIndex; // index of current mode in ModesVGA[] + PVIDEOMODE CurrentMode; // pointer to VIDEOMODE structure for + // current mode + + VIDEO_CURSOR_POSITION CursorPosition; // current cursor position + + UCHAR CursorEnable; // whether cursor is enabled or not + UCHAR CursorTopScanLine; // Cursor Start register setting (top scan) + UCHAR CursorBottomScanLine; // Cursor End register setting (bottom scan) +// eVb: 3.5 [VBE] - Add fields for VBE support and XP+ INT10 interface + VIDEO_PORT_INT10_INTERFACE Int10Interface; + BOOLEAN VesaBiosOk; +// eVb: 3.5 [END] +} HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION; + + +// +// Function prototypes. +// + +// +// Entry points for the VGA validator. Used in VgaEmulatorAccessEntries[]. +// + + +// +// Vga init scripts for font loading +// + +extern USHORT EnableA000Data[]; +extern USHORT DisableA000Color[]; + +// +// Mode Information +// + +extern ULONG NumVideoModes; +extern VIDEOMODE ModesVGA[]; +extern PVIDEOMODE VgaModeList; + +// eVb: 3.5 [VGA] - Add ATI/Mach64 Access Range +#define NUM_VGA_ACCESS_RANGES 5 +// eVb: 3.5 [END] +extern VIDEO_ACCESS_RANGE VgaAccessRange[]; + +#include "vbe.h" diff --git a/drivers/video/miniport/vga_new/vga.rbuild b/drivers/video/miniport/vga_new/vga.rbuild new file mode 100644 index 00000000000..622440d4423 --- /dev/null +++ b/drivers/video/miniport/vga_new/vga.rbuild @@ -0,0 +1,18 @@ + + + + . + videoprt + libcntpr + modeset.c + vgadata.c + vga.c + vbemodes.c + vbe.c + vga.rc + vga.h + + -mrtd + -fno-builtin + + diff --git a/drivers/video/miniport/vga_new/vga.rc b/drivers/video/miniport/vga_new/vga.rc new file mode 100644 index 00000000000..4aac6fdcae3 --- /dev/null +++ b/drivers/video/miniport/vga_new/vga.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "VGA Miniport Device Driver\0" +#define REACTOS_STR_INTERNAL_NAME "vga\0" +#define REACTOS_STR_ORIGINAL_FILENAME "vga.sys\0" +#include diff --git a/drivers/video/miniport/vga_new/vgadata.c b/drivers/video/miniport/vga_new/vgadata.c new file mode 100644 index 00000000000..6f9ea0f1c61 --- /dev/null +++ b/drivers/video/miniport/vga_new/vgadata.c @@ -0,0 +1,490 @@ +/* + * PROJECT: ReactOS VGA Miniport Driver + * LICENSE: Microsoft NT4 DDK Sample Code License + * FILE: boot/drivers/video/miniport/vga/vgadata.c + * PURPOSE: Handles switching to VGA Modes and holds VGA Built-in Modes + * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation + * ReactOS Portable Systems Group + */ + +#include "vga.h" + +// +// This structure describes to which ports access is required. +// + +VIDEO_ACCESS_RANGE VgaAccessRange[] = { +{ + {{VGA_BASE_IO_PORT, 0x00000000}}, // 64-bit linear base address + // of range + VGA_START_BREAK_PORT - VGA_BASE_IO_PORT + 1, // # of ports + 1, // range is in I/O space + 1, // range should be visible + 0 // range should be shareable +}, +{ + {{VGA_END_BREAK_PORT, 0x00000000}}, + VGA_MAX_IO_PORT - VGA_END_BREAK_PORT + 1, + 1, + 1, + 0 +}, + +// +// This next region also includes Memory mapped IO. In MMIO, the ports are +// repeated every 256 bytes from b8000 to bff00. +// + +{ + {{MEM_VGA, 0x00000000}}, + MEM_VGA_SIZE, + 0, + 1, + 0 +}, +// eVb: 4.1 [VGA] - Add ATI/Mach64 VGA registers +// +// ATI Registers +// + +{ + {{0x1CE, 0x00000000}}, + 2, + 1, + 1, + 0 +}, +{ + {{0x2E8, 0x00000000}}, + 8, + 1, + 1, + 0 +} +// eVb: 4.1 [END] +}; + +// +// 640x480 256-color 60Hz mode (BIOS mode 12) set command string for +// VGA. +// +// eVb: 4.2 [VGA] - Add VGA command streams instead of Cirrus +USHORT VGA_640x480[] = { + OWM, // begin setmode + SEQ_ADDRESS_PORT, + 5, // count + 0x100, // start sync reset + 0x0101,0x0F02,0x0003,0x0604, // program up sequencer + + OB, // misc. register + MISC_OUTPUT_REG_WRITE_PORT, + 0xE3, + + OW, // text/graphics bit + GRAPH_ADDRESS_PORT, + 0x506, + + OW, // end sync reset + SEQ_ADDRESS_PORT, + IND_SYNC_RESET, + + OB, + SEQ_DATA_PORT, + END_SYNC_RESET_VALUE, + + OW, // unprotect crtc 0-7 + CRTC_ADDRESS_PORT_COLOR, + 0x511, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_CRTC_PORTS,0, // count, startindex + 0x5F,0x4F,0x50,0x82,0x54,0x80,0x0B,0x3E,0x00,0x40,0x0,0x0,0x0,0x0,0x0,0x0, + 0xEA,0x8C,0xDF,0x28,0x0,0xE7,0x4,0xE3,0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + METAOUT+ATCOUT, // program atc registers + ATT_ADDRESS_PORT, + VGA_NUM_ATTRIB_CONT_PORTS,0, // count, startindex + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x17, 0x38, 0x39, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x3F, 0x01, 0x00, + 0x0F, 0x00, 0x00, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_GRAPH_CONT_PORTS,0, // count, startindex + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x05, 0x0F, 0xFF, + + OB, + DAC_PIXEL_MASK_PORT, + 0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + OB, // turn video on. + ATT_ADDRESS_PORT, + VIDEO_ENABLE, + + EOD +}; + +// +// 720x400 color text mode (BIOS mode 3) set command string for +// VGA. +// + +USHORT VGA_TEXT_0[] = { + OWM, // begin setmode + SEQ_ADDRESS_PORT, + 5, // count + 0x100, // start sync reset + 0x0101,0x0302,0x0003,0x0204, // program up sequencer + + OB, // misc. register + MISC_OUTPUT_REG_WRITE_PORT, + 0x67, + + OW, // text/graphics bit + GRAPH_ADDRESS_PORT, + 0x0e06, + + OW, // end sync reset + SEQ_ADDRESS_PORT, + IND_SYNC_RESET, + + OB, + SEQ_DATA_PORT, + END_SYNC_RESET_VALUE, + + OW, // unprotect crtc 0-7 + CRTC_ADDRESS_PORT_COLOR, + 0xE11, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_CRTC_PORTS,0, // count, startindex + 0x5F,0x4F,0x50,0x82,0x55,0x81,0xBF,0x1F,0x00,0x4F,0xD,0xE,0x0,0x0,0x0,0x0, + 0x9c,0x8E,0x8F,0x28,0x1F,0x96,0xB9,0xA3,0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + METAOUT+ATCOUT, // program atc registers + ATT_ADDRESS_PORT, + VGA_NUM_ATTRIB_CONT_PORTS,0, // count, startindex + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x17, 0x38, 0x39, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x3F, 0x04, 0x00, + 0x0F, 0x08, 0x00, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_GRAPH_CONT_PORTS,0, // count, startindex + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x0E, 0x00, 0xFF, + + OB, + DAC_PIXEL_MASK_PORT, + 0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + OB, // turn video on. + ATT_ADDRESS_PORT, + VIDEO_ENABLE, + + EOD +}; + +// +// 640x400 color text mode (BIOS mode 3) set command string for +// VGA. +// + +USHORT VGA_TEXT_1[] = { + OWM, // begin setmode + SEQ_ADDRESS_PORT, + 5, // count + 0x100, // start sync reset + 0x0101,0x0302,0x0003,0x0204, // program up sequencer + + OB, // misc. register + MISC_OUTPUT_REG_WRITE_PORT, + 0xA3, + + OW, // text/graphics bit + GRAPH_ADDRESS_PORT, + 0x0e06, + + OW, // end sync reset + SEQ_ADDRESS_PORT, + IND_SYNC_RESET, + + OB, + SEQ_DATA_PORT, + END_SYNC_RESET_VALUE, + + OW, // unprotect crtc 0-7 + CRTC_ADDRESS_PORT_COLOR, + 0x511, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_CRTC_PORTS,0, // count, startindex + 0x5F,0x4F,0x50,0x82,0x55,0x81,0xBF,0x1F,0x00,0x4D,0xB,0xC,0x0,0x0,0x0,0x0, + 0x83,0x85,0x5D,0x28,0x1F,0x63,0xBA,0xA3,0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + METAOUT+ATCOUT, // program atc registers + ATT_ADDRESS_PORT, + VGA_NUM_ATTRIB_CONT_PORTS,0, // count, startindex + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x17, 0x38, 0x39, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x3F, 0x04, 0x00, + 0x0F, 0x00, 0x00, + + METAOUT+INDXOUT, // program gdc registers + GRAPH_ADDRESS_PORT, + VGA_NUM_GRAPH_CONT_PORTS,0, // count, startindex + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x0E, 0x00, 0xFF, + + OB, + DAC_PIXEL_MASK_PORT, + 0xFF, + + IB, // prepare atc for writing + INPUT_STATUS_1_COLOR, + + OB, // turn video on. + ATT_ADDRESS_PORT, + VIDEO_ENABLE, + + EOD +}; +// eVb: 4.2 [END] +// +// Video mode table - contains information and commands for initializing each +// mode. These entries must correspond with those in VIDEO_MODE_VGA. The first +// entry is commented; the rest follow the same format, but are not so +// heavily commented. +// +// eVb: 4.3 [VGA] - Add VGA, ModeX and SVGA mode instead of Cirrus Modes +VIDEOMODE ModesVGA[] = +{ + // Color text mode 3, 720x400, 9x16 char cell (VGA). + // + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR, // flags that this mode is a color mode, but not graphics + 4, // four planes + 1, // one bit of colour per plane + 80, 25, // 80x25 text resolution + 720, 400, // 720x400 pixels on screen + 1, // only support one frequency, non-interlaced + 160, 0x10000, // 160 bytes per scan line, 64K of CPU-addressable bitmap + FALSE, + 0x3, VGA_TEXT_0, // Mode 3, I/O initialization stream + 0xA0000, // Physical address at 0xA0000 + 0x18000, 0x8000, + 0x20000, // 2 banks of 64K, 128KB total memory + 720, // 720 pixels per scan line + FALSE, + 0 + }, + + // + // Color text mode 3, 640x350, 8x14 char cell (EGA). + // + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR, + 4, 1, + 80, 25, + 640, 350, + 1, + 160, 0x10000, + FALSE, + 0x3, VGA_TEXT_1, + 0xA0000, + 0x18000, 0x8000, + 0x20000, + 640, + FALSE, + 0 + }, + + // + // + // Standard VGA Color graphics mode 0x12, 640x480 16 colors. + // + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 4, 1, + 80, 30, + 640, 480, + 1, + 80, 0x10000, + FALSE, + 0x12, VGA_640x480, + 0xA0000, + 0, 0x20000, + 0x20000, + 640, + FALSE, + 0 + }, + + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 8, 1, + 0, 0, + 320, 200, + 70, + 80, 0x10000, + FALSE, + 0x3, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 320, + FALSE, + 0 + }, + + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 8, 1, + 0, 0, + 320, 240, + 60, + 80, 0x10000, + FALSE, + 0x3, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 320, + FALSE, + 0 + }, + + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 8, 1, + 0, 0, + 320, 400, + 70, + 80, 0x10000, + FALSE, + 0x3, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 320, + FALSE, + 0 + }, + + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 8, 1, + 0, 0, + 320, 480, + 60, + 80, 0x10000, + FALSE, + 0x3, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 320, + FALSE, + 0 + }, + + // + // 800x600 16 colors. + // + { + VIDEO_MODE_BANKED | VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS, + 4, 1, + 100, 37, + 800, 600, + 1, + 100, 0x10000, + FALSE, + (0x102 << 16) | VBE_SET_VBE_MODE, NULL, + 0xA0000, + 0, 0x20000, + 0x20000, + 800, + FALSE, + 0 + }, +}; + +ULONG NumVideoModes = sizeof(ModesVGA) / sizeof(VIDEOMODE); +PVIDEOMODE VgaModeList; +// eVb: 4.3 [END] + +// +// +// Data used to set the Graphics and Sequence Controllers to put the +// VGA into a planar state at A0000 for 64K, with plane 2 enabled for +// reads and writes, so that a font can be loaded, and to disable that mode. +// + +// Settings to enable planar mode with plane 2 enabled. +// + +USHORT EnableA000Data[] = { + OWM, + SEQ_ADDRESS_PORT, + 1, + 0x0100, + + OWM, + GRAPH_ADDRESS_PORT, + 3, + 0x0204, // Read Map = plane 2 + 0x0005, // Graphics Mode = read mode 0, write mode 0 + 0x0406, // Graphics Miscellaneous register = A0000 for 64K, not odd/even, + // graphics mode + OWM, + SEQ_ADDRESS_PORT, + 3, + 0x0402, // Map Mask = write to plane 2 only + 0x0404, // Memory Mode = not odd/even, not full memory, graphics mode + 0x0300, // end sync reset + EOD +}; + +// +// Settings to disable the font-loading planar mode. +// + +USHORT DisableA000Color[] = { + OWM, + SEQ_ADDRESS_PORT, + 1, + 0x0100, + + OWM, + GRAPH_ADDRESS_PORT, + 3, + 0x0004, 0x1005, 0x0E06, + + OWM, + SEQ_ADDRESS_PORT, + 3, + 0x0302, 0x0204, 0x0300, // end sync reset + EOD + +}; diff --git a/drivers/video/miniport/vmx_svga/precomp.h b/drivers/video/miniport/vmx_svga/precomp.h index 245d90116c2..a8f8a82705c 100644 --- a/drivers/video/miniport/vmx_svga/precomp.h +++ b/drivers/video/miniport/vmx_svga/precomp.h @@ -5,8 +5,8 @@ * PURPOSE: VMWARE SVGA-II Driver Header * PROGRAMMERS: ReactOS Portable Systems Group */ - -#include + +#include #include #include #include @@ -20,13 +20,13 @@ typedef struct _HW_DEVICE_EXTENSION LARGE_INTEGER VramSize; PHYSICAL_ADDRESS VramBase; ULONG MemSize; - ULONG IndexPort; - ULONG ValuePort; + PULONG IndexPort; + PULONG ValuePort; PVOID FrameBufferBase; PVOID Fifo; ULONG InterruptPort; ULONG InterruptState; - PKEVENT SyncEvent; + PENG_EVENT SyncEvent; VIDEO_MODE_INFORMATION CurrentMode; ULONG VideoModeCount; ULONG Capabilities; diff --git a/drivers/video/miniport/vmx_svga/vmx_svga.c b/drivers/video/miniport/vmx_svga/vmx_svga.c index ca5cab49f67..3c981c59be1 100644 --- a/drivers/video/miniport/vmx_svga/vmx_svga.c +++ b/drivers/video/miniport/vmx_svga/vmx_svga.c @@ -9,13 +9,76 @@ /* INCLUDES *******************************************************************/ #include "precomp.h" +#include "debug.h" /* GLOBALS ********************************************************************/ PHW_DEVICE_EXTENSION VmxDeviceExtensionArray[SVGA_MAX_DISPLAYS]; +static PWCHAR AdapterString = L"VMware SVGA II"; /* FUNCTIONS ******************************************************************/ +ULONG +NTAPI +VmxReadUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, + IN ULONG Index) +{ + /* Program the index first, then read the value */ + VideoPortWritePortUlong(DeviceExtension->IndexPort, Index); + return VideoPortReadPortUlong(DeviceExtension->ValuePort); +} + +VOID +NTAPI +VmxWriteUlong(IN PHW_DEVICE_EXTENSION DeviceExtension, + IN ULONG Index, + IN ULONG Value) +{ + /* Program the index first, then write the value */ + VideoPortWritePortUlong(DeviceExtension->IndexPort, Index); + VideoPortWritePortUlong(DeviceExtension->ValuePort, Value); +} + +ULONG +NTAPI +VmxInitModes(IN PHW_DEVICE_EXTENSION DeviceExtension) +{ + /* Not here yet */ + UNIMPLEMENTED; + while (TRUE); + return 0; +} + +VP_STATUS +NTAPI +VmxInitDevice(IN PHW_DEVICE_EXTENSION DeviceExtension) +{ + /* Not here yet */ + UNIMPLEMENTED; + while (TRUE); + return NO_ERROR; +} + +BOOLEAN +NTAPI +VmxIsMultiMon(IN PHW_DEVICE_EXTENSION DeviceExtension) +{ + ULONG Capabilities; + + /* Get the caps */ + Capabilities = DeviceExtension->Capabilities; + + /* Check for multi-mon support */ + if ((Capabilities & SVGA_CAP_MULTIMON) && (Capabilities & SVGA_CAP_PITCHLOCK)) + { + /* Query the monitor count */ + if (VmxReadUlong(DeviceExtension, SVGA_REG_NUM_DISPLAYS) > 1) return TRUE; + } + + /* Either no support, or just one screen */ + return FALSE; +} + VP_STATUS NTAPI VmxFindAdapter(IN PVOID HwDeviceExtension, @@ -24,6 +87,82 @@ VmxFindAdapter(IN PVOID HwDeviceExtension, IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again) { + VP_STATUS Status; + PHW_DEVICE_EXTENSION DeviceExtension = HwDeviceExtension; + DPRINT1("VMX searching for adapter\n"); + + /* Zero out the fields */ + VideoPortZeroMemory(DeviceExtension, sizeof(HW_DEVICE_EXTENSION)); + + /* Validate the Config Info */ + if (ConfigInfo->Length < sizeof(VIDEO_PORT_CONFIG_INFO)) + { + /* Incorrect OS version? */ + DPRINT1("Invalid configuration info\n"); + return ERROR_INVALID_PARAMETER; + } + + /* Initialize the device extension and find the adapter */ + Status = VmxInitDevice(DeviceExtension); + DPRINT1("Init status: %lx\n", Status); + if (Status != NO_ERROR) return ERROR_DEV_NOT_EXIST; + + /* Save this adapter extension */ + VmxDeviceExtensionArray[0] = DeviceExtension; + + /* Create the sync event */ + VideoPortCreateEvent(DeviceExtension, + NOTIFICATION_EVENT, + NULL, + &DeviceExtension->SyncEvent); + + /* Check for multi-monitor configuration */ + if (VmxIsMultiMon(DeviceExtension)) + { + /* Let's not go so far */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Zero the frame buffer */ + VideoPortZeroMemory((PVOID)DeviceExtension->FrameBuffer.LowPart, + DeviceExtension->VramSize.LowPart); + + /* Initialize the video modes */ + VmxInitModes(DeviceExtension); + + /* Setup registry keys */ + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.ChipType", + AdapterString, + sizeof(AdapterString)); + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.DacType", + AdapterString, + sizeof(AdapterString)); + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.MemorySize", + &DeviceExtension->VramSize.LowPart, + sizeof(ULONG)); + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.AdapterString", + AdapterString, + sizeof(AdapterString)); + VideoPortSetRegistryParameters(DeviceExtension, + L"HardwareInformation.BiosString", + AdapterString, + sizeof(AdapterString)); + + /* No VDM support */ + ConfigInfo->NumEmulatorAccessEntries = 0; + ConfigInfo->EmulatorAccessEntries = 0; + ConfigInfo->EmulatorAccessEntriesContext = 0; + ConfigInfo->HardwareStateSize = 0; + ConfigInfo->VdmPhysicalVideoMemoryAddress.QuadPart = 0; + ConfigInfo->VdmPhysicalVideoMemoryLength = 0; + + /* Write that this is Windows XP or higher */ + VmxWriteUlong(DeviceExtension, SVGA_REG_GUEST_ID, 0x5000 | 0x08); return NO_ERROR; } @@ -31,6 +170,8 @@ BOOLEAN NTAPI VmxInitialize(IN PVOID HwDeviceExtension) { + UNIMPLEMENTED; + while (TRUE); return TRUE; } @@ -39,6 +180,8 @@ NTAPI VmxStartIO(IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET RequestPacket) { + UNIMPLEMENTED; + while (TRUE); return TRUE; } @@ -48,6 +191,8 @@ VmxResetHw(IN PVOID DeviceExtension, IN ULONG Columns, IN ULONG Rows) { + UNIMPLEMENTED; + while (TRUE); return FALSE; } @@ -57,6 +202,8 @@ VmxGetPowerState(IN PVOID HwDeviceExtension, IN ULONG HwId, IN PVIDEO_POWER_MANAGEMENT VideoPowerControl) { + UNIMPLEMENTED; + while (TRUE); return NO_ERROR; } @@ -66,14 +213,17 @@ VmxSetPowerState(IN PVOID HwDeviceExtension, IN ULONG HwId, IN PVIDEO_POWER_MANAGEMENT VideoPowerControl) { - - return NO_ERROR; + UNIMPLEMENTED; + while (TRUE); + return NO_ERROR; } BOOLEAN NTAPI VmxInterrupt(IN PVOID HwDeviceExtension) { + UNIMPLEMENTED; + while (TRUE); return TRUE; } @@ -86,6 +236,8 @@ VmxGetVideoChildDescriptor(IN PVOID HwDeviceExtension, OUT PULONG UId, OUT PULONG pUnused) { + UNIMPLEMENTED; + while (TRUE); return NO_ERROR; } @@ -97,6 +249,7 @@ DriverEntry(IN PVOID Context1, VIDEO_HW_INITIALIZATION_DATA InitData; /* Zero initialization structure and array of extensions, one per screen */ + DPRINT1("VMX-SVGAII Loading...\n"); VideoPortZeroMemory(VmxDeviceExtensionArray, sizeof(VmxDeviceExtensionArray)); VideoPortZeroMemory(&InitData, sizeof(InitData)); diff --git a/drivers/video/miniport/xboxvmp/xboxvmp.h b/drivers/video/miniport/xboxvmp/xboxvmp.h index 55bc208107c..3dacdcc21dc 100644 --- a/drivers/video/miniport/xboxvmp/xboxvmp.h +++ b/drivers/video/miniport/xboxvmp/xboxvmp.h @@ -24,18 +24,10 @@ /* INCLUDES *******************************************************************/ -#ifdef _MSC_VER -#pragma message ("INVESTIGATE ME") -#endif - -#if 0 //#ifdef _MSC_VER -#include "devioctl.h" +#include "ntdef.h" #define PAGE_SIZE 4096 -#else -#include -#endif - #include "dderror.h" +#include "devioctl.h" #include "miniport.h" #include "ntddvdeo.h" #include "video.h" diff --git a/drivers/video/videoprt/int10.c b/drivers/video/videoprt/int10.c index 66e18143622..7930c87ca72 100644 --- a/drivers/video/videoprt/int10.c +++ b/drivers/video/videoprt/int10.c @@ -187,7 +187,8 @@ IntInt10CallBios( /* Detach and return status */ IntDetachFromCSRSS(&CallingProcess, &ApcState); - return Status; + if (NT_SUCCESS(Status)) return NO_ERROR; + return ERROR_INVALID_PARAMETER; } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -240,6 +241,6 @@ VideoPortInt10( /* Detach from CSRSS */ IntDetachFromCSRSS(&CallingProcess, &ApcState); - - return Status; + if (NT_SUCCESS(Status)) return NO_ERROR; + return ERROR_INVALID_PARAMETER; } diff --git a/drivers/video/videoprt/videoprt.c b/drivers/video/videoprt/videoprt.c index 6d106f62015..19a64f7b53c 100644 --- a/drivers/video/videoprt/videoprt.c +++ b/drivers/video/videoprt/videoprt.c @@ -322,7 +322,6 @@ IntVideoPortCreateAdapterDeviceObject( } -/* FIXME: we have to detach the device object in IntVideoPortFindAdapter if it fails */ NTSTATUS NTAPI IntVideoPortFindAdapter( IN PDRIVER_OBJECT DriverObject, @@ -341,7 +340,7 @@ IntVideoPortFindAdapter( WCHAR SymlinkBuffer[20]; UNICODE_STRING SymlinkName; BOOL LegacyDetection = FALSE; - ULONG DeviceNumber; + ULONG DeviceNumber, DisplayNumber; DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension; DeviceNumber = DeviceExtension->DeviceNumber; @@ -423,6 +422,8 @@ IntVideoPortFindAdapter( { WARN_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status); RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); IoDeleteDevice(DeviceObject); return Status; @@ -444,6 +445,8 @@ IntVideoPortFindAdapter( { WARN_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status); RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); IoDeleteDevice(DeviceObject); return Status; } @@ -458,12 +461,30 @@ IntVideoPortFindAdapter( RtlInitUnicodeString(&DeviceName, DeviceBuffer); /* Create symbolic link "\??\DISPLAYx" */ - swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1); - RtlInitUnicodeString(&SymlinkName, SymlinkBuffer); - IoCreateSymbolicLink(&SymlinkName, &DeviceName); + + /* HACK: We need this to find the first available display to + * use. We can't use the device number because then we could + * end up with \Device\Video0 being non-functional because + * HwFindAdapter returned an error. \Device\Video1 would be + * the correct primary display but it would be set to DISPLAY2 + * so it would never be used and ROS would bugcheck on boot. + * By doing it this way, we ensure that DISPLAY1 is always + * functional. Another idea would be letting the IO manager + * give our video devices names then getting those names + * somehow and creating symbolic links to \Device\VideoX + * and \??\DISPLAYX once we know that HwFindAdapter has succeeded. + */ + DisplayNumber = 0; + do + { + DisplayNumber++; + swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DisplayNumber); + RtlInitUnicodeString(&SymlinkName, SymlinkBuffer); + } + while (IoCreateSymbolicLink(&SymlinkName, &DeviceName) != STATUS_SUCCESS); /* Add entry to DEVICEMAP\VIDEO key in registry. */ - swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DeviceNumber); + swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DisplayNumber - 1); RtlWriteRegistryValue( RTL_REGISTRY_DEVICEMAP, L"VIDEO", @@ -489,6 +510,8 @@ IntVideoPortFindAdapter( if (!IntVideoPortSetupInterrupt(DeviceObject, DriverExtension, &ConfigInfo)) { RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); IoDeleteDevice(DeviceObject); return STATUS_INSUFFICIENT_RESOURCES; } @@ -501,6 +524,8 @@ IntVideoPortFindAdapter( { if (DeviceExtension->InterruptObject != NULL) IoDisconnectInterrupt(DeviceExtension->InterruptObject); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); RtlFreeUnicodeString(&DeviceExtension->RegistryPath); IoDeleteDevice(DeviceObject); WARN_(VIDEOPRT, "STATUS_INSUFFICIENT_RESOURCES\n"); @@ -1417,3 +1442,99 @@ VideoPortAllocateContiguousMemory( return MmAllocateContiguousMemory(NumberOfBytes, HighestAcceptableAddress); } + +/* + * @implemented + */ +BOOLEAN NTAPI +VideoPortIsNoVesa(VOID) +{ + NTSTATUS Status; + HANDLE KeyHandle; + UNICODE_STRING Path = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control"); + UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions"); + OBJECT_ATTRIBUTES ObjectAttributes; + PKEY_VALUE_PARTIAL_INFORMATION KeyInfo; + ULONG Length, NewLength; + + /* Initialize object attributes with the path we want */ + InitializeObjectAttributes(&ObjectAttributes, + &Path, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + /* Open the key */ + Status = ZwOpenKey(&KeyHandle, + KEY_QUERY_VALUE, + &ObjectAttributes); + + if (!NT_SUCCESS(Status)) + { + VideoPortDebugPrint(Error, "ZwOpenKey failed (0x%x)\n", Status); + return FALSE; + } + + /* Find out how large our buffer should be */ + Status = ZwQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + NULL, + 0, + &Length); + if (Status != STATUS_BUFFER_OVERFLOW && Status != STATUS_BUFFER_TOO_SMALL) + { + VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); + ZwClose(KeyHandle); + return FALSE; + } + + /* Allocate it */ + KeyInfo = ExAllocatePool(PagedPool, Length); + if (!KeyInfo) + { + VideoPortDebugPrint(Error, "Out of memory\n"); + ZwClose(KeyHandle); + return FALSE; + } + + /* Now for real this time */ + Status = ZwQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + KeyInfo, + Length, + &NewLength); + + ZwClose(KeyHandle); + + if (!NT_SUCCESS(Status)) + { + VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); + ExFreePool(KeyInfo); + return FALSE; + } + + /* Sanity check */ + if (KeyInfo->Type != REG_SZ) + { + VideoPortDebugPrint(Error, "Invalid type for SystemStartOptions\n"); + ExFreePool(KeyInfo); + return FALSE; + } + + /* Check if NOVESA is present in the start options */ + if (wcsstr((PWCHAR)KeyInfo->Data, L"NOVESA")) + { + VideoPortDebugPrint(Info, "VESA mode disabled\n"); + ExFreePool(KeyInfo); + return TRUE; + } + + ExFreePool(KeyInfo); + + VideoPortDebugPrint(Info, "VESA mode enabled\n"); + + return FALSE; +} + diff --git a/drivers/video/videoprt/videoprt.h b/drivers/video/videoprt/videoprt.h index aae0ba10ee4..21ea2c09ee1 100644 --- a/drivers/video/videoprt/videoprt.h +++ b/drivers/video/videoprt/videoprt.h @@ -24,6 +24,7 @@ #include #include +#define __BROKEN__ #include #include #include diff --git a/drivers/video/videoprt/videoprt.spec b/drivers/video/videoprt/videoprt.spec index e07ce343e63..9d5147636fe 100644 --- a/drivers/video/videoprt/videoprt.spec +++ b/drivers/video/videoprt/videoprt.spec @@ -47,6 +47,7 @@ @ fastcall VideoPortInterlockedDecrement(ptr) NTOSKRNL.InterlockedDecrement @ fastcall VideoPortInterlockedExchange(ptr long) NTOSKRNL.InterlockedExchange @ fastcall VideoPortInterlockedIncrement(ptr) NTOSKRNL.InterlockedIncrement +@ stdcall VideoPortIsNoVesa() @ stdcall VideoPortLockBuffer(ptr ptr long long) @ stdcall VideoPortLockPages(ptr ptr ptr ptr long) @ stdcall VideoPortLogError(ptr ptr long long) diff --git a/drivers/wdm/audio/backpln/portcls/guids.cpp b/drivers/wdm/audio/backpln/portcls/guids.cpp index 4496e5785e1..457868d2c62 100644 --- a/drivers/wdm/audio/backpln/portcls/guids.cpp +++ b/drivers/wdm/audio/backpln/portcls/guids.cpp @@ -57,7 +57,7 @@ const GUID IID_IDmaChannel = {0x22C6AC61L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0x const GUID IID_IRegistryKey = {0xE8DA4302l, 0xF304, 0x11D0, {0x95, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}}; const GUID IID_IServiceSink = {0x22C6AC64L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}}; const GUID IID_IPortClsVersion = {0x7D89A7BBL, 0x869B, 0x4567, {0x8D, 0xBE, 0x1E, 0x16, 0x8C, 0xC8, 0x53, 0xDE}}; -const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; +const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x46}}; const GUID IID_IPortEvents = {0xA80F29C4L, 0x5498, 0x11D2, {0x95, 0xD9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}}; const GUID KSNAME_PIN = {0x146F1A80, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; diff --git a/drivers/wdm/audio/backpln/portcls/interfaces.hpp b/drivers/wdm/audio/backpln/portcls/interfaces.hpp index 7aefc882ee4..730b6a3adfb 100644 --- a/drivers/wdm/audio/backpln/portcls/interfaces.hpp +++ b/drivers/wdm/audio/backpln/portcls/interfaces.hpp @@ -320,8 +320,6 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHOD_(NTSTATUS, Init)(THIS_ IN KSPIN_CONNECT *ConnectDetails, - IN PKSDATAFORMAT DataFormat, - IN PDEVICE_OBJECT DeviceObject, IN ULONG FrameSize, IN ULONG Alignment, IN PVOID SilenceBuffer) PURE; @@ -337,17 +335,10 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHOD_(VOID, UpdateMapping)(THIS_ IN ULONG BytesWritten) PURE; - STDMETHOD_(ULONG, NumMappings)(THIS) PURE; - STDMETHOD_(ULONG, NumData)(THIS) PURE; - STDMETHOD_(BOOL, MinimumDataAvailable)(THIS) PURE; - STDMETHOD_(BOOL, CancelBuffers)(THIS) PURE; - STDMETHOD_(VOID, UpdateFormat)(THIS_ - IN PKSDATAFORMAT DataFormat) PURE; - STDMETHOD_(NTSTATUS, GetMappingWithTag)(THIS_ IN PVOID Tag, OUT PPHYSICAL_ADDRESS PhysicalAddress, @@ -358,19 +349,19 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHOD_(NTSTATUS, ReleaseMappingWithTag)(THIS_ IN PVOID Tag) PURE; - STDMETHOD_(BOOL, HasLastMappingFailed)(THIS) PURE; + STDMETHOD_(BOOLEAN, HasLastMappingFailed)(THIS) PURE; STDMETHOD_(ULONG, GetCurrentIrpOffset)(THIS) PURE; - STDMETHOD_(VOID, SetMinimumDataThreshold)(THIS_ - IN ULONG MinimumDataThreshold) PURE; - STDMETHOD_(ULONG, GetMinimumDataThreshold)(THIS) PURE; + + STDMETHOD_(BOOLEAN, GetAcquiredTagRange)(THIS_ + IN PVOID * FirstTag, + IN PVOID * LastTag); + }; #define IMP_IIrpQueue \ STDMETHODIMP_(NTSTATUS) Init(THIS_ \ IN KSPIN_CONNECT *ConnectDetails, \ - IN PKSDATAFORMAT DataFormat, \ - IN PDEVICE_OBJECT DeviceObject, \ IN ULONG FrameSize, \ IN ULONG Alignment, \ IN PVOID SilenceBuffer); \ @@ -386,17 +377,10 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHODIMP_(VOID) UpdateMapping(THIS_ \ IN ULONG BytesWritten); \ \ - STDMETHODIMP_(ULONG) NumMappings(THIS); \ - \ STDMETHODIMP_(ULONG) NumData(THIS); \ \ - STDMETHODIMP_(BOOL) MinimumDataAvailable(THIS); \ - \ STDMETHODIMP_(BOOL) CancelBuffers(THIS); \ \ - STDMETHODIMP_(VOID) UpdateFormat(THIS_ \ - IN PKSDATAFORMAT DataFormat); \ - \ STDMETHODIMP_(NTSTATUS) GetMappingWithTag(THIS_ \ IN PVOID Tag, \ OUT PPHYSICAL_ADDRESS PhysicalAddress, \ @@ -407,11 +391,13 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown) STDMETHODIMP_(NTSTATUS) ReleaseMappingWithTag( \ IN PVOID Tag); \ \ - STDMETHODIMP_(BOOL) HasLastMappingFailed(THIS); \ + STDMETHODIMP_(BOOLEAN) HasLastMappingFailed(THIS); \ STDMETHODIMP_(ULONG) GetCurrentIrpOffset(THIS); \ - STDMETHODIMP_(VOID) SetMinimumDataThreshold( \ - IN ULONG MinimumDataThreshold); \ - STDMETHODIMP_(ULONG) GetMinimumDataThreshold(VOID) + STDMETHODIMP_(BOOLEAN) GetAcquiredTagRange(THIS_ \ + IN PVOID * FirstTag, \ + IN PVOID * LastTag); + + /***************************************************************************** * IKsWorkSink diff --git a/drivers/wdm/audio/backpln/portcls/irpstream.cpp b/drivers/wdm/audio/backpln/portcls/irpstream.cpp index 7d82ae7660d..50d55fb4901 100644 --- a/drivers/wdm/audio/backpln/portcls/irpstream.cpp +++ b/drivers/wdm/audio/backpln/portcls/irpstream.cpp @@ -38,10 +38,7 @@ protected: volatile ULONG m_CurrentOffset; LONG m_NumMappings; ULONG m_NumDataAvailable; - BOOL m_StartStream; PKSPIN_CONNECT m_ConnectDetails; - PKSDATAFORMAT_WAVEFORMATEX m_DataFormat; - KSPIN_LOCK m_IrpListLock; LIST_ENTRY m_IrpList; LIST_ENTRY m_FreeIrpList; @@ -51,7 +48,6 @@ protected: ULONG m_OutOfMapping; ULONG m_MaxFrameSize; ULONG m_Alignment; - ULONG m_MinimumDataThreshold; LONG m_Ref; @@ -87,18 +83,14 @@ NTSTATUS NTAPI CIrpQueue::Init( IN KSPIN_CONNECT *ConnectDetails, - IN PKSDATAFORMAT DataFormat, - IN PDEVICE_OBJECT DeviceObject, IN ULONG FrameSize, IN ULONG Alignment, IN PVOID SilenceBuffer) { m_ConnectDetails = ConnectDetails; - m_DataFormat = (PKSDATAFORMAT_WAVEFORMATEX)DataFormat; m_MaxFrameSize = FrameSize; m_SilenceBuffer = SilenceBuffer; m_Alignment = Alignment; - m_MinimumDataThreshold = ((PKSDATAFORMAT_WAVEFORMATEX)DataFormat)->WaveFormatEx.nAvgBytesPerSec / 3; InitializeListHead(&m_IrpList); InitializeListHead(&m_FreeIrpList); @@ -225,6 +217,9 @@ CIrpQueue::AddMapping( // add irp to cancelable queue KsAddIrpToCancelableQueue(&m_IrpList, &m_IrpListLock, Irp, KsListEntryTail, NULL); + // disable mapping failed status + m_OutOfMapping = FALSE; + // done return Status; } @@ -270,10 +265,6 @@ CIrpQueue::GetMapping( // no irp available, use silence buffer *Buffer = (PUCHAR)m_SilenceBuffer; *BufferSize = m_MaxFrameSize; - // flag for port wave pci driver - m_OutOfMapping = TRUE; - // indicate flag to restart fast buffering - m_StartStream = FALSE; return STATUS_SUCCESS; } @@ -410,15 +401,6 @@ CIrpQueue::UpdateMapping( } } -ULONG -NTAPI -CIrpQueue::NumMappings() -{ - - // returns the amount of mappings available - return m_NumMappings; -} - ULONG NTAPI CIrpQueue::NumData() @@ -427,28 +409,6 @@ CIrpQueue::NumData() return m_NumDataAvailable; } - -BOOL -NTAPI -CIrpQueue::MinimumDataAvailable() -{ - BOOL Result; - - if (m_StartStream) - return TRUE; - - if (m_MinimumDataThreshold < m_NumDataAvailable) - { - m_StartStream = TRUE; - Result = TRUE; - } - else - { - Result = FALSE; - } - return Result; -} - BOOL NTAPI CIrpQueue::CancelBuffers() @@ -464,8 +424,6 @@ CIrpQueue::CancelBuffers() // cancel all irps KsCancelIo(&m_IrpList, &m_IrpListLock); - // reset stream start flag - m_StartStream = FALSE; // reset number of mappings m_NumMappings = 0; // reset number of data available @@ -475,17 +433,6 @@ CIrpQueue::CancelBuffers() return TRUE; } -VOID -NTAPI -CIrpQueue::UpdateFormat( - PKSDATAFORMAT DataFormat) -{ - m_DataFormat = (PKSDATAFORMAT_WAVEFORMATEX)DataFormat; - m_MinimumDataThreshold = m_DataFormat->WaveFormatEx.nAvgBytesPerSec / 3; - m_StartStream = FALSE; - m_NumDataAvailable = 0; -} - NTSTATUS NTAPI CIrpQueue::GetMappingWithTag( @@ -509,8 +456,7 @@ CIrpQueue::GetMappingWithTag( { // no irp available m_OutOfMapping = TRUE; - m_StartStream = FALSE; - return STATUS_UNSUCCESSFUL; + return STATUS_NOT_FOUND; } //FIXME support more than one stream header @@ -572,16 +518,13 @@ CIrpQueue::ReleaseMappingWithTag( Irp->IoStatus.Information = StreamHeader->FrameExtent; - // free stream header, no tag as wdmaud.drv allocates it atm - ExFreePool(StreamHeader); - // complete the request IoCompleteRequest(Irp, IO_SOUND_INCREMENT); return STATUS_SUCCESS; } -BOOL +BOOLEAN NTAPI CIrpQueue::HasLastMappingFailed() { @@ -596,23 +539,53 @@ CIrpQueue::GetCurrentIrpOffset() return m_CurrentOffset; } -VOID +BOOLEAN NTAPI -CIrpQueue::SetMinimumDataThreshold( - ULONG MinimumDataThreshold) +CIrpQueue::GetAcquiredTagRange( + IN PVOID * FirstTag, + IN PVOID * LastTag) { + KIRQL OldLevel; + BOOLEAN Ret = FALSE; + PIRP Irp; + PLIST_ENTRY CurEntry; - m_MinimumDataThreshold = MinimumDataThreshold; + KeAcquireSpinLock(&m_IrpListLock, &OldLevel); + + if (!IsListEmpty(&m_FreeIrpList)) + { + // get first entry + CurEntry = RemoveHeadList(&m_FreeIrpList); + // get irp from list entry + Irp = (PIRP)CONTAINING_RECORD(CurEntry, IRP, Tail.Overlay.ListEntry); + + // get tag of first acquired buffer + *FirstTag = Irp->Tail.Overlay.DriverContext[3]; + + // put back irp + InsertHeadList(&m_FreeIrpList, &Irp->Tail.Overlay.ListEntry); + + // get last entry + CurEntry = RemoveTailList(&m_FreeIrpList); + // get irp from list entry + Irp = (PIRP)CONTAINING_RECORD(CurEntry, IRP, Tail.Overlay.ListEntry); + + // get tag of first acquired buffer + *LastTag = Irp->Tail.Overlay.DriverContext[3]; + + // put back irp + InsertTailList(&m_FreeIrpList, &Irp->Tail.Overlay.ListEntry); + + // indicate success + Ret = TRUE; + } + + // release lock + KeReleaseSpinLock(&m_IrpListLock, OldLevel); + // done + return Ret; } -ULONG -NTAPI -CIrpQueue::GetMinimumDataThreshold() -{ - return m_MinimumDataThreshold; -} - - NTSTATUS NTAPI NewIrpQueue( diff --git a/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp b/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp index 07395aedc27..da6e98d9d51 100644 --- a/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp +++ b/drivers/wdm/audio/backpln/portcls/pin_dmus.cpp @@ -41,9 +41,6 @@ protected: VOID TransferMidiDataToDMus(); VOID TransferMidiData(); - VOID NTAPI SetStreamState(IN KSSTATE State); - - IPortDMus * m_Port; IPortFilterDMus * m_Filter; KSPIN_DESCRIPTOR * m_KsPinDescriptor; @@ -75,10 +72,6 @@ protected: ULONG m_LastTag; LONG m_Ref; - - friend VOID NTAPI SetStreamWorkerRoutineDMus(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context); - friend VOID NTAPI CloseStreamRoutineDMus(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context); - }; typedef struct @@ -198,92 +191,6 @@ CPortPinDMus::DisconnectOutput( //================================================================================================================================== -VOID -NTAPI -SetStreamWorkerRoutineDMus( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - CPortPinDMus* This; - KSSTATE State; - NTSTATUS Status; - PSETSTREAM_CONTEXT Ctx = (PSETSTREAM_CONTEXT)Context; - - This = Ctx->Pin; - State = Ctx->State; - - IoFreeWorkItem(Ctx->WorkItem); - FreeItem(Ctx, TAG_PORTCLASS); - - // Has the audio stream resumed? - if (This->m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Set the state - if (This->m_MidiStream) - { - Status = This->m_MidiStream->SetState(State); - } - else - { - Status = This->m_Mxf->SetState(State); - } - - if (NT_SUCCESS(Status)) - { - // Set internal state to requested state - This->m_State = State; - - if (This->m_State == KSSTATE_STOP) - { - // reset start stream - This->m_IrpQueue->CancelBuffers(); //FIX function name - DPRINT("Stopping PreCompleted %u PostCompleted %u\n", This->m_PreCompleted, This->m_PostCompleted); - } - } -} - -VOID -NTAPI -CPortPinDMus::SetStreamState( - IN KSSTATE State) -{ - PIO_WORKITEM WorkItem; - PSETSTREAM_CONTEXT Context; - - PC_ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); - - // Has the audio stream resumed? - if (m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Has the audio state already been set? - if (m_State == State) - return; - - // allocate set state context - Context = (PSETSTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(SETSTREAM_CONTEXT), TAG_PORTCLASS); - - if (!Context) - return; - - // allocate work item - WorkItem = IoAllocateWorkItem(m_DeviceObject); - - if (!WorkItem) - { - ExFreePool(Context); - return; - } - - Context->Pin = this; - Context->WorkItem = WorkItem; - Context->State = State; - - // queue the work item - IoQueueWorkItem(WorkItem, SetStreamWorkerRoutineDMus, DelayedWorkQueue, (PVOID)Context); -} - VOID CPortPinDMus::TransferMidiData() { @@ -297,7 +204,6 @@ CPortPinDMus::TransferMidiData() Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize); if (!NT_SUCCESS(Status)) { - SetStreamState(KSSTATE_STOP); return; } @@ -375,7 +281,6 @@ CPortPinDMus::TransferMidiDataToDMus() if (!Root) { - SetStreamState(KSSTATE_STOP); return; } @@ -482,128 +387,59 @@ CPortPinDMus::Flush( return KsDispatchInvalidDeviceRequest(DeviceObject, Irp); } - -VOID -NTAPI -CloseStreamRoutineDMus( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - PMINIPORTMIDISTREAM Stream = NULL; - NTSTATUS Status; - ISubdevice *ISubDevice; - PSUBDEVICE_DESCRIPTOR Descriptor; - CPortPinDMus * This; - PCLOSESTREAM_CONTEXT Ctx = (PCLOSESTREAM_CONTEXT)Context; - - This = (CPortPinDMus*)Ctx->Pin; - - if (This->m_MidiStream) - { - if (This->m_State != KSSTATE_STOP) - { - This->m_MidiStream->SetState(KSSTATE_STOP); - } - Stream = This->m_MidiStream; - This->m_MidiStream = NULL; - } - - if (This->m_ServiceGroup) - { - This->m_ServiceGroup->RemoveMember(PSERVICESINK(This)); - } - - Status = This->m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice); - if (NT_SUCCESS(Status)) - { - Status = ISubDevice->GetDescriptor(&Descriptor); - if (NT_SUCCESS(Status)) - { - Descriptor->Factory.Instances[This->m_ConnectDetails->PinId].CurrentPinInstanceCount--; - ISubDevice->Release(); - } - } - - if (This->m_Format) - { - ExFreePool(This->m_Format); - This->m_Format = NULL; - } - - // complete the irp - Ctx->Irp->IoStatus.Information = 0; - Ctx->Irp->IoStatus.Status = STATUS_SUCCESS; - IoCompleteRequest(Ctx->Irp, IO_NO_INCREMENT); - - // free the work item - IoFreeWorkItem(Ctx->WorkItem); - - // free work item ctx - FreeItem(Ctx, TAG_PORTCLASS); - - // destroy DMus pin - This->m_Filter->FreePin(PPORTPINDMUS(This)); - - if (Stream) - { - DPRINT("Closing stream at Irql %u\n", KeGetCurrentIrql()); - Stream->Release(); - } -} - NTSTATUS NTAPI CPortPinDMus::Close( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - PCLOSESTREAM_CONTEXT Ctx; + NTSTATUS Status; + ISubdevice * SubDevice; + PSUBDEVICE_DESCRIPTOR Descriptor; - if (m_MidiStream || m_Mxf) + if (m_ServiceGroup) { - Ctx = (PCLOSESTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(CLOSESTREAM_CONTEXT), TAG_PORTCLASS); - if (!Ctx) - { - DPRINT("Failed to allocate stream context\n"); - goto cleanup; - } - - Ctx->WorkItem = IoAllocateWorkItem(DeviceObject); - if (!Ctx->WorkItem) - { - DPRINT("Failed to allocate work item\n"); - goto cleanup; - } - - Ctx->Irp = Irp; - Ctx->Pin = this; - - IoMarkIrpPending(Irp); - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_PENDING; - - // defer work item - IoQueueWorkItem(Ctx->WorkItem, CloseStreamRoutineDMus, DelayedWorkQueue, (PVOID)Ctx); - // Return result - return STATUS_PENDING; + m_ServiceGroup->RemoveMember(PSERVICESINK(this)); } + if (m_MidiStream) + { + if (m_State != KSSTATE_STOP) + { + m_MidiStream->SetState(KSSTATE_STOP); + m_State = KSSTATE_STOP; + } + DPRINT("Closing stream at Irql %u\n", KeGetCurrentIrql()); + m_MidiStream->Release(); + } + + Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&SubDevice); + if (NT_SUCCESS(Status)) + { + Status = SubDevice->GetDescriptor(&Descriptor); + if (NT_SUCCESS(Status)) + { + // release reference count + Descriptor->Factory.Instances[m_ConnectDetails->PinId].CurrentPinInstanceCount--; + } + SubDevice->Release(); + } + + if (m_Format) + { + ExFreePool(m_Format); + m_Format = NULL; + } + + // complete the irp Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); + // destroy DMus pin + m_Filter->FreePin(PPORTPINDMUS(this)); + return STATUS_SUCCESS; - -cleanup: - - if (Ctx) - FreeItem(Ctx, TAG_PORTCLASS); - - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_UNSUCCESSFUL; - } NTSTATUS @@ -769,7 +605,7 @@ CPortPinDMus::Init( m_ServiceGroup->SupportDelayedService(); } - Status = m_IrpQueue->Init(ConnectDetails, m_Format, DeviceObject, 0, 0, NULL); + Status = m_IrpQueue->Init(ConnectDetails, 0, 0, NULL); if (!NT_SUCCESS(Status)) { DPRINT("IrpQueue_Init failed with %x\n", Status); diff --git a/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp b/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp index e36e9b97a0e..ff02905e386 100644 --- a/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp +++ b/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp @@ -347,7 +347,6 @@ PinWaveCyclicAudioPosition( DPRINT("Play %lu Write %lu\n", Position->PlayOffset, Position->WriteOffset); } - Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION); return STATUS_SUCCESS; } @@ -543,9 +542,6 @@ PinWaveCyclicDataFormat( // free old format FreeItem(Pin->m_Format, TAG_PORTCLASS); - // update irp queue with new format - Pin->m_IrpQueue->UpdateFormat((PKSDATAFORMAT)NewDataFormat); - // store new format Pin->m_Format = NewDataFormat; Irp->IoStatus.Information = NewDataFormat->FormatSize; @@ -783,29 +779,32 @@ CPortPinWaveCyclic::RequestService() PC_ASSERT_IRQL(DISPATCH_LEVEL); - Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize); - if (!NT_SUCCESS(Status)) + if (m_State == KSSTATE_RUN) { - return; + Status = m_IrpQueue->GetMapping(&Buffer, &BufferSize); + if (!NT_SUCCESS(Status)) + { + return; + } + + Status = m_Stream->GetPosition(&Position); + DPRINT("Position %u Buffer %p BufferSize %u ActiveIrpOffset %u Capture %u\n", Position, Buffer, m_CommonBufferSize, BufferSize, m_Capture); + + OldOffset = m_Position.PlayOffset; + + if (Position < m_CommonBufferOffset) + { + UpdateCommonBufferOverlap(Position, m_FrameSize); + } + else if (Position >= m_CommonBufferOffset) + { + UpdateCommonBuffer(Position, m_FrameSize); + } + + NewOffset = m_Position.PlayOffset; + + GeneratePositionEvents(OldOffset, NewOffset); } - - Status = m_Stream->GetPosition(&Position); - DPRINT("Position %u Buffer %p BufferSize %u ActiveIrpOffset %u Capture %u\n", Position, Buffer, m_CommonBufferSize, BufferSize, m_Capture); - - OldOffset = m_Position.PlayOffset; - - if (Position < m_CommonBufferOffset) - { - UpdateCommonBufferOverlap(Position, m_FrameSize); - } - else if (Position >= m_CommonBufferOffset) - { - UpdateCommonBuffer(Position, m_FrameSize); - } - - NewOffset = m_Position.PlayOffset; - - GeneratePositionEvents(OldOffset, NewOffset); } NTSTATUS @@ -1242,7 +1241,7 @@ CPortPinWaveCyclic::Init( m_Stream->Silence(SilenceBuffer, m_FrameSize); m_Stream->Silence(m_CommonBuffer, m_CommonBufferSize); - Status = m_IrpQueue->Init(ConnectDetails, DataFormat, DeviceObject, m_FrameSize, 0, SilenceBuffer); + Status = m_IrpQueue->Init(ConnectDetails, m_FrameSize, 0, SilenceBuffer); if (!NT_SUCCESS(Status)) { m_IrpQueue->Release(); diff --git a/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp b/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp index 273bfae6539..935ece83ec7 100644 --- a/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp +++ b/drivers/wdm/audio/backpln/portcls/pin_wavepci.cpp @@ -36,9 +36,6 @@ public: IMP_IPortWavePciStream; CPortPinWavePci(IUnknown *OuterUnknown) {} virtual ~CPortPinWavePci(){} - - VOID NTAPI SetState( IN KSSTATE State); - VOID NTAPI CloseStream(); protected: friend NTSTATUS NTAPI PinWavePciState(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data); @@ -77,9 +74,6 @@ protected: NTSTATUS NTAPI HandleKsProperty(IN PIRP Irp); NTSTATUS NTAPI HandleKsStream(IN PIRP Irp); - - - VOID NTAPI SetStreamState( IN KSSTATE State); }; typedef struct @@ -201,6 +195,8 @@ PinWavePciState( NTSTATUS Status = STATUS_UNSUCCESSFUL; CPortPinWavePci *Pin; PSUBDEVICE_DESCRIPTOR Descriptor; + PVOID FirstTag, LastTag; + ULONG MappingsRevoked; PKSSTATE State = (PKSSTATE)Data; // get sub device descriptor @@ -227,6 +223,35 @@ PinWavePciState( { // store new state Pin->m_State = *State; + if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && Pin->m_State == KSSTATE_STOP) + { + // FIXME + // complete with successful state + Pin->m_IrpQueue->CancelBuffers(); + while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag)) + { + Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked); + DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked); + KeStallExecutionProcessor(10); + } + Pin->m_Position.PlayOffset = 0; + Pin->m_Position.WriteOffset = 0; + } + else if (Pin->m_State == KSSTATE_STOP) + { + Pin->m_IrpQueue->CancelBuffers(); + while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag)) + { + Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked); + DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked); + KeStallExecutionProcessor(10); + } + Pin->m_Position.PlayOffset = 0; + Pin->m_Position.WriteOffset = 0; + } + // store result + Irp->IoStatus.Information = sizeof(KSSTATE); + } // store result Irp->IoStatus.Information = sizeof(KSSTATE); @@ -311,9 +336,6 @@ PinWavePciDataFormat( // free old format FreeItem(Pin->m_Format, TAG_PORTCLASS); - // update irp queue with new format - Pin->m_IrpQueue->UpdateFormat((PKSDATAFORMAT)NewDataFormat); - // store new format Pin->m_Format = NewDataFormat; Irp->IoStatus.Information = NewDataFormat->FormatSize; @@ -373,7 +395,7 @@ CPortPinWavePci::QueryInterface( IN REFIID refiid, OUT PVOID* Output) { - DPRINT("CPortPinWavePci::QueryInterface entered\n"); + //DPRINT("CPortPinWavePci::QueryInterface entered\n"); if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) || IsEqualGUIDAligned(refiid, IID_IUnknown)) @@ -435,137 +457,18 @@ CPortPinWavePci::TerminatePacket() } -VOID -CPortPinWavePci::SetState(KSSTATE State) -{ - ULONG MinimumDataThreshold; - ULONG MaximumDataThreshold; - - // Has the audio stream resumed? - if (m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Set the state - if (NT_SUCCESS(m_Stream->SetState(State))) - { - // Save new internal state - m_State = State; - - if (m_State == KSSTATE_STOP) - { - // reset start stream - m_IrpQueue->CancelBuffers(); //FIX function name - //This->ServiceGroup->lpVtbl->CancelDelayedService(This->ServiceGroup); - // increase stop counter - m_StopCount++; - // get current data threshold - MinimumDataThreshold = m_IrpQueue->GetMinimumDataThreshold(); - // get maximum data threshold - MaximumDataThreshold = ((PKSDATAFORMAT_WAVEFORMATEX)m_Format)->WaveFormatEx.nAvgBytesPerSec; - // increase minimum data threshold by 10 frames - MinimumDataThreshold += m_AllocatorFraming.FrameSize * 10; - - // assure it has not exceeded - MinimumDataThreshold = min(MinimumDataThreshold, MaximumDataThreshold); - // store minimum data threshold - m_IrpQueue->SetMinimumDataThreshold(MinimumDataThreshold); - - DPRINT("Stopping TotalCompleted %u StopCount %u MinimumDataThreshold %u\n", m_TotalPackets, m_StopCount, MinimumDataThreshold); - } - if (m_State == KSSTATE_RUN) - { - // start the notification timer - //m_ServiceGroup->RequestDelayedService(m_ServiceGroup, m_Delay); - } - } - - -} - -VOID -NTAPI -PinWavePciSetStreamWorkerRoutine( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - CPortPinWavePci * This; - PSETSTREAM_CONTEXT Ctx = (PSETSTREAM_CONTEXT)Context; - KSSTATE State; - - This = Ctx->Pin; - State = Ctx->State; - - IoFreeWorkItem(Ctx->WorkItem); - FreeItem(Ctx, TAG_PORTCLASS); - - This->SetState(State); -} - -VOID -NTAPI -CPortPinWavePci::SetStreamState( - IN KSSTATE State) -{ - PDEVICE_OBJECT DeviceObject; - PIO_WORKITEM WorkItem; - PSETSTREAM_CONTEXT Context; - - PC_ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); - - // Has the audio stream resumed? - if (m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Has the audio state already been set? - if (m_State == State) - return; - - // Get device object - DeviceObject = GetDeviceObjectFromPortWavePci(m_Port); - - // allocate set state context - Context = (PSETSTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(SETSTREAM_CONTEXT), TAG_PORTCLASS); - - if (!Context) - return; - - // allocate work item - WorkItem = IoAllocateWorkItem(DeviceObject); - - if (!WorkItem) - { - ExFreePool(Context); - return; - } - - Context->Pin = this; - Context->WorkItem = WorkItem; - Context->State = State; - - // queue the work item - IoQueueWorkItem(WorkItem, PinWavePciSetStreamWorkerRoutine, DelayedWorkQueue, (PVOID)Context); -} - - VOID NTAPI CPortPinWavePci::RequestService() { PC_ASSERT_IRQL(DISPATCH_LEVEL); - if (m_IrpQueue->HasLastMappingFailed()) + if (m_State == KSSTATE_RUN) { - if (m_IrpQueue->NumMappings() == 0) - { - DPRINT("Stopping stream...\n"); - SetStreamState(KSSTATE_STOP); - return; - } + m_Stream->Service(); + //TODO + //generate events } - - m_Stream->Service(); - //TODO - //generate events } //================================================================================================================================== @@ -597,18 +500,18 @@ CPortPinWavePci::HandleKsProperty( { PKSPROPERTY Property; NTSTATUS Status; - UNICODE_STRING GuidString; + //UNICODE_STRING GuidString; PIO_STACK_LOCATION IoStack; IoStack = IoGetCurrentIrpStackLocation(Irp); - DPRINT("IPortPinWave_HandleKsProperty entered\n"); + //DPRINT("IPortPinWave_HandleKsProperty entered\n"); IoStack = IoGetCurrentIrpStackLocation(Irp); if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY) { - DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength); + //DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength); Irp->IoStatus.Status = STATUS_SUCCESS; @@ -621,10 +524,11 @@ CPortPinWavePci::HandleKsProperty( if (Status == STATUS_NOT_FOUND) { Property = (PKSPROPERTY)IoStack->Parameters.DeviceIoControl.Type3InputBuffer; - +#if 0 RtlStringFromGUID(Property->Set, &GuidString); - DPRINT("Unhandeled property Set |%S| Id %u Flags %x\n", GuidString.Buffer, Property->Id, Property->Flags); + //DPRINT("Unhandeled property Set |%S| Id %u Flags %x\n", GuidString.Buffer, Property->Id, Property->Flags); RtlFreeUnicodeString(&GuidString); +#endif } if (Status != STATUS_PENDING) @@ -636,29 +540,6 @@ CPortPinWavePci::HandleKsProperty( return Status; } -#if 0 - else if (Property->Id == KSPROPERTY_CONNECTION_ALLOCATORFRAMING) - { - PKSALLOCATOR_FRAMING Framing = (PKSALLOCATOR_FRAMING)OutputBuffer; - - PC_ASSERT_IRQL(DISPATCH_LEVEL); - // Validate input buffer - if (OutputBufferLength < sizeof(KSALLOCATOR_FRAMING)) - { - IoStatusBlock->Information = sizeof(KSALLOCATOR_FRAMING); - IoStatusBlock->Status = STATUS_BUFFER_TOO_SMALL; - return STATUS_BUFFER_TOO_SMALL; - } - // copy frame allocator struct - RtlMoveMemory(Framing, &m_AllocatorFraming, sizeof(KSALLOCATOR_FRAMING)); - - IoStatusBlock->Information = sizeof(KSALLOCATOR_FRAMING); - IoStatusBlock->Status = STATUS_SUCCESS; - return STATUS_SUCCESS; - } - } -#endif - NTSTATUS NTAPI CPortPinWavePci::HandleKsStream( @@ -666,10 +547,13 @@ CPortPinWavePci::HandleKsStream( { NTSTATUS Status; ULONG Data = 0; + BOOLEAN bFailed; InterlockedIncrement((PLONG)&m_TotalPackets); DPRINT("IPortPinWaveCyclic_HandleKsStream entered Total %u State %x MinData %u\n", m_TotalPackets, m_State, m_IrpQueue->NumData()); + bFailed = m_IrpQueue->HasLastMappingFailed(); + Status = m_IrpQueue->AddMapping(Irp, &Data); if (NT_SUCCESS(Status)) @@ -679,6 +563,12 @@ CPortPinWavePci::HandleKsStream( else m_Position.WriteOffset += Data; + if (bFailed) + { + // notify stream of new mapping + m_Stream->MappingAvailable(); + } + return STATUS_PENDING; } @@ -741,37 +631,39 @@ CPortPinWavePci::Flush( return KsDispatchInvalidDeviceRequest(DeviceObject, Irp); } -VOID +NTSTATUS NTAPI -CPortPinWavePci::CloseStream() +CPortPinWavePci::Close( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) { - PMINIPORTWAVEPCISTREAM Stream; - ISubdevice *ISubDevice; + ISubdevice *SubDevice; NTSTATUS Status; PSUBDEVICE_DESCRIPTOR Descriptor; + if (m_ServiceGroup) + { + m_ServiceGroup->RemoveMember(PSERVICESINK(this)); + } + if (m_Stream) { if (m_State != KSSTATE_STOP) { m_Stream->SetState(KSSTATE_STOP); } + m_Stream->Release(); } - if (m_ServiceGroup) - { - m_ServiceGroup->RemoveMember(PSERVICESINK(this)); - } - - Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice); + Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&SubDevice); if (NT_SUCCESS(Status)) { - Status = ISubDevice->GetDescriptor(&Descriptor); + Status = SubDevice->GetDescriptor(&Descriptor); if (NT_SUCCESS(Status)) { Descriptor->Factory.Instances[m_ConnectDetails->PinId].CurrentPinInstanceCount--; } - ISubDevice->Release(); + SubDevice->Release(); } if (m_Format) @@ -780,93 +672,11 @@ CPortPinWavePci::CloseStream() m_Format = NULL; } - if (m_Stream) - { - Stream = m_Stream; - m_Stream = 0; - DPRINT("Closing stream at Irql %u\n", KeGetCurrentIrql()); - Stream->Release(); - } -} - -VOID -NTAPI -PinWavePciCloseStreamRoutine( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - CPortPinWavePci * This; - PCLOSESTREAM_CONTEXT Ctx = (PCLOSESTREAM_CONTEXT)Context; - - This = (CPortPinWavePci*)Ctx->Pin; - - This->CloseStream(); - - // complete the irp - Ctx->Irp->IoStatus.Information = 0; - Ctx->Irp->IoStatus.Status = STATUS_SUCCESS; - IoCompleteRequest(Ctx->Irp, IO_NO_INCREMENT); - - // free the work item - IoFreeWorkItem(Ctx->WorkItem); - - // free work item ctx - FreeItem(Ctx, TAG_PORTCLASS); -} - -NTSTATUS -NTAPI -CPortPinWavePci::Close( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp) -{ - PCLOSESTREAM_CONTEXT Ctx; - - if (m_Stream) - { - Ctx = (PCLOSESTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(CLOSESTREAM_CONTEXT), TAG_PORTCLASS); - if (!Ctx) - { - DPRINT("Failed to allocate stream context\n"); - goto cleanup; - } - - Ctx->WorkItem = IoAllocateWorkItem(DeviceObject); - if (!Ctx->WorkItem) - { - DPRINT("Failed to allocate work item\n"); - goto cleanup; - } - - Ctx->Irp = Irp; - Ctx->Pin = (PVOID)this; - - IoMarkIrpPending(Irp); - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_PENDING; - - // defer work item - IoQueueWorkItem(Ctx->WorkItem, PinWavePciCloseStreamRoutine, DelayedWorkQueue, (PVOID)Ctx); - // Return result - return STATUS_PENDING; - } - - Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_SUCCESS; - -cleanup: - - if (Ctx) - FreeItem(Ctx, TAG_PORTCLASS); - - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_UNSUCCESSFUL; - } NTSTATUS @@ -1053,7 +863,7 @@ CPortPinWavePci::Init( if (!NT_SUCCESS(Status)) return Status; - Status = m_IrpQueue->Init(ConnectDetails, m_Format, DeviceObject, m_AllocatorFraming.FrameSize, m_AllocatorFraming.FileAlignment, NULL); + Status = m_IrpQueue->Init(ConnectDetails, m_AllocatorFraming.FrameSize, m_AllocatorFraming.FileAlignment, NULL); if (!NT_SUCCESS(Status)) { DPRINT("IrpQueue_Init failed with %x\n", Status); diff --git a/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp b/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp index e325e49fe61..0aa281d0032 100644 --- a/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp +++ b/drivers/wdm/audio/backpln/portcls/pin_wavert.cpp @@ -100,91 +100,6 @@ CPortPinWaveRT::QueryInterface( return STATUS_UNSUCCESSFUL; } -VOID -NTAPI -SetStreamWorkerRoutine( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context) -{ - CPortPinWaveRT * This; - PSETSTREAM_CONTEXT Ctx = (PSETSTREAM_CONTEXT)Context; - KSSTATE State; - - This = Ctx->Pin; - State = Ctx->State; - - IoFreeWorkItem(Ctx->WorkItem); - FreeItem(Ctx, TAG_PORTCLASS); - - // Has the audio stream resumed? - if (This->m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Set the state - if (NT_SUCCESS(This->m_Stream->SetState(State))) - { - // Set internal state to stop - This->m_State = State; - - if (This->m_State == KSSTATE_STOP) - { - // reset start stream - This->m_IrpQueue->CancelBuffers(); //FIX function name - DPRINT("Stopping PreCompleted %u PostCompleted %u\n", This->m_PreCompleted, This->m_PostCompleted); - } - - if (This->m_State == KSSTATE_RUN) - { - // start the notification timer - } - } -} - -VOID -NTAPI -CPortPinWaveRT::SetStreamState( - IN KSSTATE State) -{ - PDEVICE_OBJECT DeviceObject; - PIO_WORKITEM WorkItem; - PSETSTREAM_CONTEXT Context; - - PC_ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); - - // Has the audio stream resumed? - if (m_IrpQueue->NumMappings() && State == KSSTATE_STOP) - return; - - // Has the audio state already been set? - if (m_State == State) - return; - - // Get device object - DeviceObject = GetDeviceObjectFromPortWaveRT(m_Port); - - // allocate set state context - Context = (PSETSTREAM_CONTEXT)AllocateItem(NonPagedPool, sizeof(SETSTREAM_CONTEXT), TAG_PORTCLASS); - - if (!Context) - return; - - // allocate work item - WorkItem = IoAllocateWorkItem(DeviceObject); - - if (!WorkItem) - { - ExFreePool(Context); - return; - } - - Context->Pin = this; - Context->WorkItem = WorkItem; - Context->State = State; - - // queue the work item - IoQueueWorkItem(WorkItem, SetStreamWorkerRoutine, DelayedWorkQueue, (PVOID)Context); -} - //================================================================================================================================== NTSTATUS @@ -313,7 +228,6 @@ CPortPinWaveRT::HandleKsProperty( if (m_Format) ExFreePoolWithTag(m_Format, TAG_PORTCLASS); - m_IrpQueue->UpdateFormat((PKSDATAFORMAT)NewDataFormat); m_Format = NewDataFormat; Irp->IoStatus.Information = DataFormat->FormatSize; Irp->IoStatus.Status = STATUS_SUCCESS; @@ -673,7 +587,7 @@ CPortPinWaveRT::Init( goto cleanup; } - Status = m_IrpQueue->Init(ConnectDetails, DataFormat, DeviceObject, 0, 0, NULL); + Status = m_IrpQueue->Init(ConnectDetails, 0, 0, NULL); if (!NT_SUCCESS(Status)) { goto cleanup; diff --git a/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp b/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp index 3122dfb661b..81d6ed9bfbf 100644 --- a/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp +++ b/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp @@ -161,8 +161,9 @@ CPortWavePci::QueryInterface( DPRINT("IPortWavePci_fnQueryInterface entered\n"); - if (IsEqualGUIDAligned(refiid, IID_IPortWavePci) || - IsEqualGUIDAligned(refiid, IID_IUnknown)) + if (IsEqualGUIDAligned(refiid, IID_IPortWavePci) || + IsEqualGUIDAligned(refiid, IID_IUnknown) || + IsEqualGUIDAligned(refiid, IID_IPort)) { *Output = PVOID(PPORTWAVEPCI(this)); PUNKNOWN(*Output)->AddRef(); @@ -171,7 +172,7 @@ CPortWavePci::QueryInterface( else if (IsEqualGUIDAligned(refiid, IID_IServiceSink)) { *Output = PVOID(PSERVICESINK(this)); - PUNKNOWN(*Output)->AddRef(); + PUNKNOWN(*Output)->AddRef(); return STATUS_SUCCESS; } else if (IsEqualGUIDAligned(refiid, IID_IPortEvents)) @@ -183,7 +184,7 @@ CPortWavePci::QueryInterface( else if (IsEqualGUIDAligned(refiid, IID_ISubdevice)) { *Output = PVOID(PSUBDEVICE(this)); - PUNKNOWN(*Output)->AddRef(); + PUNKNOWN(*Output)->AddRef(); return STATUS_SUCCESS; } else if (IsEqualGUIDAligned(refiid, IID_IPortClsVersion)) diff --git a/hal/halx86/generic/bios.c b/hal/halx86/generic/bios.c index 273a92d3a50..5bffb2d9389 100644 --- a/hal/halx86/generic/bios.c +++ b/hal/halx86/generic/bios.c @@ -196,6 +196,7 @@ HalpDispatchV86Opcode(IN PKTRAP_FRAME TrapFrame) /* V86 TRAP HANDLERS **********************************************************/ +#ifndef _MINIHAL_ VOID FASTCALL DECLSPEC_NORETURN @@ -276,6 +277,7 @@ HalpBiosCall() /* Exit to V86 mode */ HalpExitToV86((PKTRAP_FRAME)&V86TrapFrame); } +#endif /* FUNCTIONS ******************************************************************/ @@ -430,6 +432,7 @@ HalpRestoreIopm(VOID) while (i--) HalpSavedIoMap[HalpSavedIoMapData[i][0]] = HalpSavedIoMapData[i][1]; } +#ifndef _MINIHAL_ VOID NTAPI HalpMapRealModeMemory(VOID) @@ -517,6 +520,7 @@ HalpSwitchToRealModeTrapHandlers(VOID) // KeRegisterInterruptHandler(6, HalpTrap06); } +#endif VOID NTAPI @@ -626,6 +630,7 @@ HalpUnmapRealModeMemory(VOID) HalpFlushTLB(); } +#ifndef _MINIHAL_ BOOLEAN NTAPI HalpBiosDisplayReset(VOID) @@ -695,5 +700,6 @@ HalpBiosDisplayReset(VOID) __writeeflags(Flags); return TRUE; } +#endif /* EOF */ diff --git a/hal/halx86/generic/bus/halbus.c b/hal/halx86/generic/bus/halbus.c index 8421b774b63..d8e478f450f 100644 --- a/hal/halx86/generic/bus/halbus.c +++ b/hal/halx86/generic/bus/halbus.c @@ -27,8 +27,10 @@ HalpRegisterKdSupportFunctions(VOID) KdReleasePciDeviceforDebugging = HalpReleasePciDeviceForDebugging; /* Register memory functions */ +#ifndef _MINIHAL_ KdMapPhysicalMemory64 = HalpMapPhysicalMemory64; KdUnmapVirtualAddress = HalpUnmapVirtualAddress; +#endif /* Register ACPI stub */ KdCheckPowerButton = HalpCheckPowerButton; diff --git a/hal/halx86/generic/bus/pcibus.c b/hal/halx86/generic/bus/pcibus.c index 96d687ada97..50f1add18d8 100644 --- a/hal/halx86/generic/bus/pcibus.c +++ b/hal/halx86/generic/bus/pcibus.c @@ -702,6 +702,7 @@ PPCI_REGISTRY_INFO_INTERNAL NTAPI HalpQueryPciRegistryInfo(VOID) { +#ifndef _MINIHAL_ WCHAR NameBuffer[8]; OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING KeyName, ConfigName, IdentName; @@ -924,6 +925,9 @@ HalpQueryPciRegistryInfo(VOID) /* Return it */ return PciRegistryInfo; +#else + return NULL; +#endif } VOID diff --git a/hal/halx86/generic/bus/pcidata.c b/hal/halx86/generic/bus/pcidata.c index 947128b76a6..83ccecef7d6 100644 --- a/hal/halx86/generic/bus/pcidata.c +++ b/hal/halx86/generic/bus/pcidata.c @@ -14,6 +14,7 @@ /* GLOBALS *******************************************************************/ +#ifndef _MINIHAL_ CHAR ClassTable[3922] = { 0x43, 0x20, 0x30, 0x30, 0x20, 0x20, 0x55, 0x6E, 0x63, 0x6C, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, @@ -40415,3 +40416,4 @@ CHAR VendorTable[642355] = 0x20, 0x49, 0x6C, 0x6C, 0x65, 0x67, 0x61, 0x6C, 0x20, 0x56, 0x65, 0x6E, 0x64, 0x6F, 0x72, 0x20, 0x49, 0x44, 0x00, }; +#endif diff --git a/hal/halx86/generic/display.c b/hal/halx86/generic/display.c index 449ddc2986d..dc5f821240e 100644 --- a/hal/halx86/generic/display.c +++ b/hal/halx86/generic/display.c @@ -31,8 +31,10 @@ VOID NTAPI HalDisplayString(IN PCH String) { +#ifndef _MINIHAL_ /* Call the Inbv driver */ InbvDisplayString(String); +#endif } /* diff --git a/hal/halx86/generic/dma.c b/hal/halx86/generic/dma.c index 0b7b7f34827..bdfae48bfc0 100644 --- a/hal/halx86/generic/dma.c +++ b/hal/halx86/generic/dma.c @@ -75,11 +75,15 @@ #define NDEBUG #include +#ifndef _MINIHAL_ static KEVENT HalpDmaLock; static LIST_ENTRY HalpDmaAdapterList; static PADAPTER_OBJECT HalpEisaAdapter[8]; +#endif static BOOLEAN HalpEisaDma; +#ifndef _MINIHAL_ static PADAPTER_OBJECT HalpMasterAdapter; +#endif static const ULONG_PTR HalpEisaPortPage[8] = { FIELD_OFFSET(DMA_PAGE, Channel0), @@ -92,6 +96,7 @@ static const ULONG_PTR HalpEisaPortPage[8] = { FIELD_OFFSET(DMA_PAGE, Channel7) }; +#ifndef _MINIHAL_ static DMA_OPERATIONS HalpDmaOperations = { sizeof(DMA_OPERATIONS), (PPUT_DMA_ADAPTER)HalPutDmaAdapter, @@ -111,6 +116,7 @@ static DMA_OPERATIONS HalpDmaOperations = { NULL /*(PBUILD_SCATTER_GATHER_LIST)HalBuildScatterGatherList*/, NULL /*(PBUILD_MDL_FROM_SCATTER_GATHER_LIST)HalBuildMdlFromScatterGatherList*/ }; +#endif #define MAX_MAP_REGISTERS 64 @@ -118,6 +124,7 @@ static DMA_OPERATIONS HalpDmaOperations = { /* FUNCTIONS *****************************************************************/ +#ifndef _MINIHAL_ VOID HalpInitDma(VOID) { @@ -154,6 +161,7 @@ HalpInitDma(VOID) */ HalGetDmaAdapter = HalpGetDmaAdapter; } +#endif /** * @name HalpGetAdapterMaximumPhysicalAddress @@ -185,6 +193,7 @@ HalpGetAdapterMaximumPhysicalAddress(IN PADAPTER_OBJECT AdapterObject) return HighestAddress; } +#ifndef _MINIHAL_ /** * @name HalpGrowMapBuffers * @@ -428,6 +437,7 @@ HalpDmaAllocateChildAdapter(IN ULONG NumberOfMapRegisters, return AdapterObject; } +#endif /** * @name HalpDmaInitializeEisaAdapter @@ -564,6 +574,7 @@ HalpDmaInitializeEisaAdapter(IN PADAPTER_OBJECT AdapterObject, return TRUE; } +#ifndef _MINIHAL_ /** * @name HalGetAdapter * @@ -896,6 +907,7 @@ HalFreeCommonBuffer(IN PADAPTER_OBJECT AdapterObject, Length, CacheEnabled ? MmCached : MmNonCached); } +#endif /** * @name HalpDmaGetDmaAlignment @@ -984,6 +996,7 @@ HalReadDmaCounter(IN PADAPTER_OBJECT AdapterObject) return Count; } +#ifndef _MINIHAL_ /** * @name HalpGrowMapBufferWorker * @@ -1893,6 +1906,7 @@ IoMapTransfer(IN PADAPTER_OBJECT AdapterObject, */ return PhysicalAddress; } +#endif /** * @name HalFlushCommonBuffer diff --git a/hal/halx86/generic/halinit.c b/hal/halx86/generic/halinit.c index 1fb157fa0b7..498bf5cc5bb 100644 --- a/hal/halx86/generic/halinit.c +++ b/hal/halx86/generic/halinit.c @@ -91,8 +91,10 @@ HalInitSystem(IN ULONG BootPhase, KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0); } +#ifndef _MINIHAL_ /* Initialize the PICs */ HalpInitializePICs(TRUE); +#endif /* Force initial PIC state */ KfRaiseIrql(KeGetCurrentIrql()); @@ -107,9 +109,17 @@ HalInitSystem(IN ULONG BootPhase, HalQuerySystemInformation = HaliQuerySystemInformation; HalSetSystemInformation = HaliSetSystemInformation; HalInitPnpDriver = NULL; // FIXME: TODO +#ifndef _MINIHAL_ HalGetDmaAdapter = HalpGetDmaAdapter; +#else + HalGetDmaAdapter = NULL; +#endif HalGetInterruptTranslator = NULL; // FIXME: TODO +#ifndef _MINIHAL_ HalResetDisplay = HalpBiosDisplayReset; +#else + HalResetDisplay = NULL; +#endif HalHaltSystem = HaliHaltSystem; /* Register IRQ 2 */ @@ -125,8 +135,10 @@ HalInitSystem(IN ULONG BootPhase, /* Setup busy waiting */ HalpCalibrateStallExecution(); +#ifndef _MINIHAL_ /* Initialize the clock */ HalpInitializeClock(); +#endif /* * We could be rebooting with a pending profile interrupt, @@ -142,6 +154,7 @@ HalInitSystem(IN ULONG BootPhase, /* Initialize bus handlers */ HalpInitBusHandler(); +#ifndef _MINIHAL_ /* Enable IRQ 0 */ HalpEnableInterruptHandler(IDT_DEVICE, 0, @@ -160,6 +173,7 @@ HalInitSystem(IN ULONG BootPhase, /* Initialize DMA. NT does this in Phase 0 */ HalpInitDma(); +#endif /* Do some HAL-specific initialization */ HalpInitPhase1(); diff --git a/hal/halx86/generic/misc.c b/hal/halx86/generic/misc.c index 1a0f4f81f7b..d188d50afb7 100644 --- a/hal/halx86/generic/misc.c +++ b/hal/halx86/generic/misc.c @@ -28,6 +28,7 @@ HalpCheckPowerButton(VOID) return; } +#ifndef _MINIHAL_ PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, @@ -51,6 +52,7 @@ HalpUnmapVirtualAddress(IN PVOID VirtualAddress, // MmUnmapIoSpace(VirtualAddress, NumberPages << PAGE_SHIFT); } +#endif VOID NTAPI @@ -122,6 +124,7 @@ VOID NTAPI HalHandleNMI(IN PVOID NmiInfo) { +#ifndef _MINIHAL_ SYSTEM_CONTROL_PORT_B_REGISTER SystemControl; // @@ -202,6 +205,7 @@ HalHandleNMI(IN PVOID NmiInfo) // Halt the system // InbvDisplayString("\n*** The system has halted ***\n"); +#endif // // Enter the debugger if possible diff --git a/hal/halx86/generic/pic.c b/hal/halx86/generic/pic.c index 7197b9d91a8..a710d862567 100644 --- a/hal/halx86/generic/pic.c +++ b/hal/halx86/generic/pic.c @@ -14,6 +14,7 @@ /* GLOBALS ********************************************************************/ +#ifndef _MINIHAL_ /* * This table basically keeps track of level vs edge triggered interrupts. * Windows has 250+ entries, but it seems stupid to replicate that since the PIC @@ -1335,3 +1336,28 @@ HalpDispatchInterrupt2(VOID) } } +#else + +KIRQL +NTAPI +KeGetCurrentIrql(VOID) +{ + return PASSIVE_LEVEL; +} + +VOID +FASTCALL +KfLowerIrql( + IN KIRQL OldIrql) +{ +} + +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql) +{ + return NewIrql; +} + +#endif diff --git a/hal/halx86/generic/reboot.c b/hal/halx86/generic/reboot.c index e6a5cffee24..c7eda5e96c1 100644 --- a/hal/halx86/generic/reboot.c +++ b/hal/halx86/generic/reboot.c @@ -98,8 +98,10 @@ HalReturnToFirmware(IN FIRMWARE_REENTRY Action) case HalHaltRoutine: case HalRebootRoutine: +#ifndef _MINIHAL_ /* Acquire the display */ InbvAcquireDisplayOwnership(); +#endif /* Call the internal reboot function */ HalpReboot(); diff --git a/hal/halx86/generic/systimer.S b/hal/halx86/generic/systimer.S index 167bcf5fefd..945b5081a89 100644 --- a/hal/halx86/generic/systimer.S +++ b/hal/halx86/generic/systimer.S @@ -329,6 +329,7 @@ AndItsNotYou: ret .endfunc +#ifndef _MINIHAL_ .globl _KeStallExecutionProcessor@4 .func KeStallExecutionProcessor@4 _KeStallExecutionProcessor@4: @@ -359,6 +360,7 @@ Done: /* Return */ ret 4 .endfunc +#endif .global _KeQueryPerformanceCounter@4 .func KeQueryPerformanceCounter@4 diff --git a/hal/halx86/generic/timer.c b/hal/halx86/generic/timer.c index 360d237443d..6d90dada9b8 100644 --- a/hal/halx86/generic/timer.c +++ b/hal/halx86/generic/timer.c @@ -109,6 +109,7 @@ HalpInitializeClock(VOID) HalpCurrentRollOver = RollOver; } +#ifndef _MINIHAL_ VOID FASTCALL HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame) @@ -160,6 +161,7 @@ HalpProfileInterruptHandler(IN PKTRAP_FRAME TrapFrame) /* Spurious, just end the interrupt */ KiEoiHelper(TrapFrame); } +#endif /* PUBLIC FUNCTIONS ***********************************************************/ diff --git a/hal/halx86/generic/usage.c b/hal/halx86/generic/usage.c index 3493113920e..d35a3e3a964 100644 --- a/hal/halx86/generic/usage.c +++ b/hal/halx86/generic/usage.c @@ -63,6 +63,7 @@ HalpRegisterVector(IN UCHAR Flags, HalpIDTUsage[SystemVector].BusReleativeVector = BusVector; } +#ifndef _MINIHAL_ VOID NTAPI HalpEnableInterruptHandler(IN UCHAR Flags, @@ -87,6 +88,7 @@ HalpEnableInterruptHandler(IN UCHAR Flags, /* Enable the interrupt */ HalEnableSystemInterrupt(SystemVector, Irql, Mode); } +#endif /* * @unimplemented diff --git a/hal/halx86/hal_generic.rbuild b/hal/halx86/hal_generic.rbuild index 484f1ea5362..3980579d589 100644 --- a/hal/halx86/hal_generic.rbuild +++ b/hal/halx86/hal_generic.rbuild @@ -35,4 +35,41 @@ hal.h + + include + include + + + + + + bushndlr.c + isabus.c + halbus.c + pcibus.c + pcidata.c + sysbus.c + + beep.c + bios.c + cmos.c + dma.c + display.c + drive.c + misc.c + pic.c + portio.c + processor.c + profil.c + reboot.c + spinlock.c + sysinfo.c + systimer.S + timer.c + usage.c + + + halinit_up.c + + diff --git a/hal/halx86/include/hal.h b/hal/halx86/include/hal.h index 3cd6fcb5ae2..8d8f3154b4d 100644 --- a/hal/halx86/include/hal.h +++ b/hal/halx86/include/hal.h @@ -17,8 +17,12 @@ #undef _NTHAL_ #undef DECLSPEC_IMPORT #define DECLSPEC_IMPORT +#ifndef _MINIHAL_ #undef NTSYSAPI #define NTSYSAPI __declspec(dllimport) +#else +#undef _NTSYSTEM_ +#endif /* IFS/DDK/NDK Headers */ #include diff --git a/include/ddk/miniport.h b/include/ddk/miniport.h index b147c25a62b..59fcc52a16e 100644 --- a/include/ddk/miniport.h +++ b/include/ddk/miniport.h @@ -63,6 +63,193 @@ typedef VOID IN ULONG ReadBank, IN ULONG WriteBank, IN PVOID Context); + +#ifndef __BROKEN__ + +typedef enum _INTERFACE_TYPE { + InterfaceTypeUndefined = -1, + Internal, + Isa, + Eisa, + MicroChannel, + TurboChannel, + PCIBus, + VMEBus, + NuBus, + PCMCIABus, + CBus, + MPIBus, + MPSABus, + ProcessorInternal, + InternalPowerBus, + PNPISABus, + PNPBus, + Vmcs, + MaximumInterfaceType +}INTERFACE_TYPE, *PINTERFACE_TYPE; + +typedef enum _KINTERRUPT_MODE { + LevelSensitive, + Latched +} KINTERRUPT_MODE; + +typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context); +typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context); + +typedef enum _BUS_DATA_TYPE { + ConfigurationSpaceUndefined = -1, + Cmos, + EisaConfiguration, + Pos, + CbusConfiguration, + PCIConfiguration, + VMEConfiguration, + NuBusConfiguration, + PCMCIAConfiguration, + MPIConfiguration, + MPSAConfiguration, + PNPISAConfiguration, + SgiInternalConfiguration, + MaximumBusDataType +} BUS_DATA_TYPE, *PBUS_DATA_TYPE; + +typedef enum _DMA_WIDTH { + Width8Bits, + Width16Bits, + Width32Bits, + MaximumDmaWidth +}DMA_WIDTH, *PDMA_WIDTH; + +typedef enum _DMA_SPEED { + Compatible, + TypeA, + TypeB, + TypeC, + TypeF, + MaximumDmaSpeed +}DMA_SPEED, *PDMA_SPEED; + +typedef struct _INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; +} INTERFACE, *PINTERFACE; + +typedef enum _IRQ_DEVICE_POLICY { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors, + IrqPolicyOneCloseProcessor, + IrqPolicyAllProcessorsInMachine, + IrqPolicySpecifiedProcessors, + IrqPolicySpreadMessagesAcrossAllProcessors +} IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +typedef enum _IRQ_PRIORITY { + IrqPriorityUndefined = 0, + IrqPriorityLow, + IrqPriorityNormal, + IrqPriorityHigh +} IRQ_PRIORITY, *PIRQ_PRIORITY; + +typedef struct _IO_RESOURCE_DESCRIPTOR { + UCHAR Option; + UCHAR Type; // use CM_RESOURCE_TYPE + UCHAR ShareDisposition; // use CM_SHARE_DISPOSITION + UCHAR Spare1; + USHORT Flags; // use CM resource flag defines + USHORT Spare2; // align + + union { + struct { + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Port; + + struct { + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Memory; + + struct { + ULONG MinimumVector; + ULONG MaximumVector; + IRQ_DEVICE_POLICY AffinityPolicy; + IRQ_PRIORITY PriorityPolicy; + KAFFINITY TargetedProcessors; + } Interrupt; + + struct { + ULONG MinimumChannel; + ULONG MaximumChannel; + } Dma; + + struct { + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Generic; + + struct { + ULONG Data[3]; + } DevicePrivate; + + // + // Bus Number information. + // + + struct { + ULONG Length; + ULONG MinBusNumber; + ULONG MaxBusNumber; + ULONG Reserved; + } BusNumber; + + struct { + ULONG Priority; // use LCPRI_Xxx values in cfg.h + ULONG Reserved1; + ULONG Reserved2; + } ConfigData; + + // + // The following structures provide descriptions + // for memory resource requirement greater than MAXULONG + // + + struct { + ULONG Length40; + ULONG Alignment40; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Memory40; + + struct { + ULONG Length48; + ULONG Alignment48; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Memory48; + + struct { + ULONG Length64; + ULONG Alignment64; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Memory64; + + + } u; + +} IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR; + +#include +#endif #ifdef __cplusplus } diff --git a/include/ddk/ntddvdeo.h b/include/ddk/ntddvdeo.h index c4522343e34..f2fdc5bcae7 100644 --- a/include/ddk/ntddvdeo.h +++ b/include/ddk/ntddvdeo.h @@ -35,6 +35,41 @@ extern "C" { DEFINE_GUID(GUID_DEVINTERFACE_DISPLAY_ADAPTER, \ 0x5b45201d, 0xf2f2, 0x4f3b, 0x85, 0xbb, 0x30, 0xff, 0x1f, 0x95, 0x35, 0x99); +#define IOCTL_VIDEO_ENABLE_VDM \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x00, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_DISABLE_VDM \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_REGISTER_VDM \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x02, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x03, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x04, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_MONITOR_DEVICE \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x05, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_ENUM_MONITOR_PDO \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x06, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x07, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_IS_VGA_DEVICE \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x09, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x0a, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_PREPARE_FOR_EARECOVERY \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x0b, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_VIDEO_DISABLE_CURSOR \ CTL_CODE (FILE_DEVICE_VIDEO, 0x109, METHOD_BUFFERED, FILE_ANY_ACCESS) @@ -60,9 +95,6 @@ DEFINE_GUID(GUID_DEVINTERFACE_DISPLAY_ADAPTER, \ #define IOCTL_VIDEO_GET_POWER_MANAGEMENT \ CTL_CODE(FILE_DEVICE_VIDEO, 0x11c, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS \ - CTL_CODE(FILE_DEVICE_VIDEO, 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS) - #define IOCTL_VIDEO_LOAD_AND_SET_FONT \ CTL_CODE(FILE_DEVICE_VIDEO, 0x105, METHOD_BUFFERED, FILE_ANY_ACCESS) diff --git a/include/ddk/video.h b/include/ddk/video.h index fcf4d4a7254..047a56721d9 100644 --- a/include/ddk/video.h +++ b/include/ddk/video.h @@ -1136,6 +1136,13 @@ DDKAPI VideoPortQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); +VPAPI +BOOLEAN +DDKAPI +VideoPortIsNoVesa( + VOID +); + VPAPI BOOLEAN DDKAPI diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index ce52084253f..0725e78fdb4 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -9187,6 +9187,11 @@ typedef enum _SUITE_TYPE { SingleUserTS, Personal, Blade, + EmbeddedRestricted, + SecurityAppliance, + StorageServer, + ComputeServer, + WHServer, MaxSuiteType } SUITE_TYPE; diff --git a/include/dxsdk/axextend.idl b/include/dxsdk/axextend.idl index 71054e348a5..66e43f151ca 100644 --- a/include/dxsdk/axextend.idl +++ b/include/dxsdk/axextend.idl @@ -420,6 +420,10 @@ interface IOverlayNotify : IUnknown typedef IOverlayNotify *POVERLAYNOTIFY; +cpp_quote("#if 0") +typedef HANDLE HMONITOR; +cpp_quote("#endif /* 0 */") + [ object, local, @@ -1066,6 +1070,7 @@ interface IAMFilterMiscFlags : IUnknown ULONG GetMiscFlags(); }; +#include [ object, @@ -1081,3 +1086,16 @@ interface IAMStreamControl : IUnknown [in] DWORD dwCookie ); HRESULT GetInfo( [out] AM_STREAM_INFO *pInfo); } + +typedef enum tagTVAudioMode +{ + AMTVAUDIO_MODE_MONO = 0x0001, + AMTVAUDIO_MODE_STEREO = 0x0002, + AMTVAUDIO_MODE_LANG_A = 0x0010, + AMTVAUDIO_MODE_LANG_B = 0x0020, + AMTVAUDIO_MODE_LANG_C = 0x0040, + AMTVAUDIO_PRESET_STEREO = 0x0200, + AMTVAUDIO_PRESET_LANG_A = 0x1000, + AMTVAUDIO_PRESET_LANG_B = 0x2000, + AMTVAUDIO_PRESET_LANG_C = 0x4000, +}TVAudioMode; diff --git a/include/dxsdk/axextendenums.h b/include/dxsdk/axextendenums.h new file mode 100644 index 00000000000..feb8b410a1a --- /dev/null +++ b/include/dxsdk/axextendenums.h @@ -0,0 +1,38 @@ +#ifndef AXEXTEND_ENUM_H +#define AXEXTEND_ENUM_H + +typedef enum tagAnalogVideoStandard +{ + AnalogVideo_None = 0x00000000, + AnalogVideo_NTSC_M = 0x00000001, + AnalogVideo_NTSC_M_J = 0x00000002, + AnalogVideo_NTSC_433 = 0x00000004, + AnalogVideo_PAL_B = 0x00000010, + AnalogVideo_PAL_D = 0x00000020, + AnalogVideo_PAL_G = 0x00000040, + AnalogVideo_PAL_H = 0x00000080, + AnalogVideo_PAL_I = 0x00000100, + AnalogVideo_PAL_M = 0x00000200, + AnalogVideo_PAL_N = 0x00000400, + AnalogVideo_PAL_60 = 0x00000800, + AnalogVideo_SECAM_B = 0x00001000, + AnalogVideo_SECAM_D = 0x00002000, + AnalogVideo_SECAM_G = 0x00004000, + AnalogVideo_SECAM_H = 0x00008000, + AnalogVideo_SECAM_K = 0x00010000, + AnalogVideo_SECAM_K1 = 0x00020000, + AnalogVideo_SECAM_L = 0x00040000, + AnalogVideo_SECAM_L1 = 0x00080000, + AnalogVideo_PAL_N_COMBO = 0x00100000, + AnalogVideoMask_MCE_NTSC = AnalogVideo_NTSC_M | AnalogVideo_NTSC_M_J | AnalogVideo_NTSC_433 | AnalogVideo_PAL_M | AnalogVideo_PAL_N | AnalogVideo_PAL_60 | AnalogVideo_PAL_N_COMBO, + AnalogVideoMask_MCE_PAL = AnalogVideo_PAL_B | AnalogVideo_PAL_D | AnalogVideo_PAL_G | AnalogVideo_PAL_H | AnalogVideo_PAL_I, + AnalogVideoMask_MCE_SECAM = AnalogVideo_SECAM_B | AnalogVideo_SECAM_D | AnalogVideo_SECAM_G |AnalogVideo_SECAM_H |AnalogVideo_SECAM_K | AnalogVideo_SECAM_K1 |AnalogVideo_SECAM_L | AnalogVideo_SECAM_L1, +}AnalogVideoStandard; + +typedef enum tagTunerInputType +{ + TunerInputCable, + TunerInputAntenna +} TunerInputType; + +#endif diff --git a/include/dxsdk/bdamedia.h b/include/dxsdk/bdamedia.h index 1a1d88b5a98..3cf12d5617b 100644 --- a/include/dxsdk/bdamedia.h +++ b/include/dxsdk/bdamedia.h @@ -317,4 +317,73 @@ typedef enum { }KSPROPERTY_BDA_SIGNAL_STATS; +/* ------------------------------------------------------------ + BDA Stream Format GUIDs +*/ + +#define STATIC_KSDATAFORMAT_TYPE_BDA_ANTENNA\ + 0x71985f41, 0x1ca1, 0x11d3, 0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0 +DEFINE_GUIDSTRUCT("71985F41-1CA1-11d3-9CC8-00C04F7971E0", KSDATAFORMAT_TYPE_BDA_ANTENNA); +#define KSDATAFORMAT_TYPE_BDA_ANTENNA DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_BDA_ANTENNA) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT\ + 0xf4aeb342, 0x0329, 0x4fdd, 0xa8, 0xfd, 0x4a, 0xff, 0x49, 0x26, 0xc9, 0x78 +DEFINE_GUIDSTRUCT("F4AEB342-0329-4fdd-A8FD-4AFF4926C978", KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT); +#define KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT) + + +#define STATIC_KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT\ + 0x8deda6fd, 0xac5f, 0x4334, 0x8e, 0xcf, 0xa4, 0xba, 0x8f, 0xa7, 0xd0, 0xf0 +DEFINE_GUIDSTRUCT("8DEDA6FD-AC5F-4334-8ECF-A4BA8FA7D0F0", KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT); +#define KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT) + + +#define STATIC_KSDATAFORMAT_TYPE_BDA_IF_SIGNAL\ + 0x61be0b47, 0xa5eb, 0x499b, 0x9a, 0x85, 0x5b, 0x16, 0xc0, 0x7f, 0x12, 0x58 +DEFINE_GUIDSTRUCT("61BE0B47-A5EB-499b-9A85-5B16C07F1258", KSDATAFORMAT_TYPE_BDA_IF_SIGNAL); +#define KSDATAFORMAT_TYPE_BDA_IF_SIGNAL DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_BDA_IF_SIGNAL) + + +#define STATIC_KSDATAFORMAT_TYPE_MPEG2_SECTIONS\ + 0x455f176c, 0x4b06, 0x47ce, 0x9a, 0xef, 0x8c, 0xae, 0xf7, 0x3d, 0xf7, 0xb5 +DEFINE_GUIDSTRUCT("455F176C-4B06-47CE-9AEF-8CAEF73DF7B5", KSDATAFORMAT_TYPE_MPEG2_SECTIONS); +#define KSDATAFORMAT_TYPE_MPEG2_SECTIONS DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_MPEG2_SECTIONS) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_ATSC_SI\ + 0xb3c7397c, 0xd303, 0x414d, 0xb3, 0x3c, 0x4e, 0xd2, 0xc9, 0xd2, 0x97, 0x33 +DEFINE_GUIDSTRUCT("B3C7397C-D303-414D-B33C-4ED2C9D29733", KSDATAFORMAT_SUBTYPE_ATSC_SI); +#define KSDATAFORMAT_SUBTYPE_ATSC_SI DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_ATSC_SI) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_DVB_SI\ + 0xe9dd31a3, 0x221d, 0x4adb, 0x85, 0x32, 0x9a, 0xf3, 0x9, 0xc1, 0xa4, 0x8 +DEFINE_GUIDSTRUCT("e9dd31a3-221d-4adb-8532-9af309c1a408", KSDATAFORMAT_SUBTYPE_DVB_SI); +#define KSDATAFORMAT_SUBTYPE_DVB_SI DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_DVB_SI) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_PSIP\ + 0x762e3f66, 0x336f, 0x48d1, 0xbf, 0x83, 0x2b, 0x0, 0x35, 0x2c, 0x11, 0xf0 +DEFINE_GUIDSTRUCT("762E3F66-336F-48d1-BF83-2B00352C11F0", KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_PSIP); +#define KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_PSIP DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_PSIP) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_OOB_PSIP\ + 0x951727db, 0xd2ce, 0x4528, 0x96, 0xf6, 0x33, 0x1, 0xfa, 0xbb, 0x2d, 0xe0 +DEFINE_GUIDSTRUCT("951727DB-D2CE-4528-96F6-3301FABB2DE0", KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_OOB_PSIP); +#define KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_OOB_PSIP DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_BDA_OPENCABLE_OOB_PSIP) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_ISDB_SI\ + 0x4a2eeb99, 0x6458, 0x4538, 0xb1, 0x87, 0x04, 0x01, 0x7c, 0x41, 0x41, 0x3f +DEFINE_GUIDSTRUCT("4a2eeb99-6458-4538-b187-04017c41413f", KSDATAFORMAT_SUBTYPE_ISDB_SI); +#define KSDATAFORMAT_SUBTYPE_ISDB_SI DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_ISDB_SI) + + +#define STATIC_KSDATAFORMAT_SUBTYPE_PBDA_TRANSPORT_RAW\ + 0x0d7aed42, 0xcb9a, 0x11db, 0x97, 0x05, 0x00, 0x50, 0x56, 0xc0, 0x00, 0x08 +DEFINE_GUIDSTRUCT("0d7AED42-CB9A-11DB-9705-005056C00008", KSDATAFORMAT_SUBTYPE_PBDA_TRANSPORT_RAW); +#define KSDATAFORMAT_SUBTYPE_PBDA_TRANSPORT_RAW DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_PBDA_TRANSPORT_RAW) + #endif diff --git a/include/dxsdk/d3dx9shader.h b/include/dxsdk/d3dx9shader.h index a15cab600d6..766d4ca1089 100644 --- a/include/dxsdk/d3dx9shader.h +++ b/include/dxsdk/d3dx9shader.h @@ -44,6 +44,15 @@ typedef LPCSTR D3DXHANDLE; +typedef enum _D3DXREGISTER_SET +{ + D3DXRS_BOOL, + D3DXRS_INT4, + D3DXRS_FLOAT4, + D3DXRS_SAMPLER, + D3DXRS_FORCE_DWORD = 0x7fffffff +} D3DXREGISTER_SET, *LPD3DXREGISTER_SET; + typedef enum D3DXPARAMETER_CLASS { D3DXPC_SCALAR, @@ -80,6 +89,131 @@ typedef enum D3DXPARAMETER_TYPE D3DXPT_FORCE_DWORD = 0x7fffffff, } D3DXPARAMETER_TYPE, *LPD3DXPARAMETER_TYPE; +typedef struct _D3DXCONSTANTTABLE_DESC +{ + LPCSTR Creator; + DWORD Version; + UINT Constants; +} D3DXCONSTANTTABLE_DESC, *LPD3DXCONSTANTTABLE_DESC; + +typedef struct _D3DXCONSTANT_DESC +{ + LPCSTR Name; + D3DXREGISTER_SET RegisterSet; + UINT RegisterIndex; + UINT RegisterCount; + D3DXPARAMETER_CLASS Class; + D3DXPARAMETER_TYPE Type; + UINT Rows; + UINT Columns; + UINT Elements; + UINT StructMembers; + UINT Bytes; + LPCVOID DefaultValue; +} D3DXCONSTANT_DESC, *LPD3DXCONSTANT_DESC; + +DEFINE_GUID(IID_ID3DXConstantTable, 0x9dca3190, 0x38b9, 0x4fc3, 0x92, 0xe3, 0x39, 0xc6, 0xdd, 0xfb, 0x35, 0x8b); + +#undef INTERFACE +#define INTERFACE ID3DXConstantTable + +DECLARE_INTERFACE_(ID3DXConstantTable, ID3DXBuffer) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + /*** ID3DXBuffer methods ***/ + STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; + STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; + /*** ID3DXConstantTable methods ***/ + STDMETHOD(GetDesc)(THIS_ D3DXCONSTANTTABLE_DESC *pDesc) PURE; + STDMETHOD(GetConstantDesc)(THIS_ D3DXHANDLE hConstant, D3DXCONSTANT_DESC *pConstantDesc, UINT *pCount) PURE; + STDMETHOD_(D3DXHANDLE, GetConstant)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; + STDMETHOD_(D3DXHANDLE, GetConstantByName)(THIS_ D3DXHANDLE hConstant, LPCSTR pName) PURE; + STDMETHOD_(D3DXHANDLE, GetConstantElement)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE; + STDMETHOD(SetDefaults)(THIS_ LPDIRECT3DDEVICE9 pDevice) PURE; + STDMETHOD(SetValue)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes) PURE; + STDMETHOD(SetBool)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, BOOL b) PURE; + STDMETHOD(SetBoolArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST BOOL* pb, UINT Count) PURE; + STDMETHOD(SetInt)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, INT n) PURE; + STDMETHOD(SetIntArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST INT* pn, UINT Count) PURE; + STDMETHOD(SetFloat)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, FLOAT f) PURE; + STDMETHOD(SetFloatArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST FLOAT* pf, UINT Count) PURE; + STDMETHOD(SetVector)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetVectorArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector, UINT Count) PURE; + STDMETHOD(SetMatrix)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixPointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTranspose)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetMatrixTransposeArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE; + STDMETHOD(SetMatrixTransposePointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define ID3DXConstantTable_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define ID3DXConstantTable_AddRef(p) (p)->lpVtbl->AddRef(p) +#define ID3DXConstantTable_Release(p) (p)->lpVtbl->Release(p) +/*** ID3DXBuffer methods ***/ +#define ID3DXConstantTable_GetBufferPointer(p) (p)->lpVtbl->GetBufferPointer(p) +#define ID3DXConstantTable_GetBufferSize(p) (p)->lpVtbl->GetBufferSize(p) +/*** ID3DXConstantTable methods ***/ +#define ID3DXConstantTable_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define ID3DXConstantTable_GetConstantDesc(p,a,b,c) (p)->lpVtbl->GetConstantDesc(p,a,b,c) +#define ID3DXConstantTable_GetConstant(p,a,b) (p)->lpVtbl->GetConstant(p,a,b) +#define ID3DXConstantTable_GetConstantByName(p,a,b) (p)->lpVtbl->GetConstantByName(p,a,b) +#define ID3DXConstantTable_GetConstantElement(p,a,b) (p)->lpVtbl->GetConstantElement(p,a,b) +#define ID3DXConstantTable_SetDefaults(p,a) (p)->lpVtbl->SetDefaults(p,a) +#define ID3DXConstantTable_SetValue(p,a,b,c,d) (p)->lpVtbl->SetValue(p,a,b,c,d) +#define ID3DXConstantTable_SetBool(p,a,b,c) (p)->lpVtbl->SetBool(p,a,b,c) +#define ID3DXConstantTable_SetBoolArray(p,a,b,c,d) (p)->lpVtbl->SetBoolArray(p,a,b,c,d) +#define ID3DXConstantTable_SetInt(p,a,b,c) (p)->lpVtbl->SetInt(p,a,b,c) +#define ID3DXConstantTable_SetIntArray(p,a,b,c,d) (p)->lpVtbl->SetIntArray(p,a,b,c,d) +#define ID3DXConstantTable_SetFloat(p,a,b,c) (p)->lpVtbl->SetFloat(p,a,b,c) +#define ID3DXConstantTable_SetFloatArray(p,a,b,c,d) (p)->lpVtbl->SetFloatArray(p,a,b,c,d) +#define ID3DXConstantTable_SetVector(p,a,b,c) (p)->lpVtbl->SetVector(p,a,b,c) +#define ID3DXConstantTable_SetVectorArray(p,a,b,c,d) (p)->lpVtbl->SetVectorArray(p,a,b,c,d) +#define ID3DXConstantTable_SetMatrix(p,a,b,c) (p)->lpVtbl->SetMatrix(p,a,b,c) +#define ID3DXConstantTable_SetMatrixArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixArray(p,a,b,c,d) +#define ID3DXConstantTable_SetMatrixPointerArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixPointerArray(p,a,b,c,d) +#define ID3DXConstantTable_SetMatrixTranspose(p,a,b,c) (p)->lpVtbl->SetMatrixTranspose(p,a,b,c) +#define ID3DXConstantTable_SetMatrixTransposeArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixTransposeArray(p,a,b,c,d) +#define ID3DXConstantTable_SetMatrixTransposePointerArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixTransposePointerArray(p,a,b,c,d) +#else +/*** IUnknown methods ***/ +#define ID3DXConstantTable_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define ID3DXConstantTable_AddRef(p) (p)->AddRef() +#define ID3DXConstantTable_Release(p) (p)->Release() +/*** ID3DXBuffer methods ***/ +#define ID3DXConstantTable_GetBufferPointer(p) (p)->GetBufferPointer() +#define ID3DXConstantTable_GetBufferSize(p) (p)->GetBufferSize() +/*** ID3DXConstantTable methods ***/ +#define ID3DXConstantTable_GetDesc(p,a) (p)->GetDesc(a) +#define ID3DXConstantTable_GetConstantDesc(p,a,b,c) (p)->GetConstantDesc(a,b,c) +#define ID3DXConstantTable_GetConstant(p,a,b) (p)->GetConstant(a,b) +#define ID3DXConstantTable_GetConstantByName(p,a,b) (p)->GetConstantByName(a,b) +#define ID3DXConstantTable_GetConstantElement(p,a,b) (p)->GetConstantElement(a,b) +#define ID3DXConstantTable_SetDefaults(p,a) (p)->SetDefaults(a) +#define ID3DXConstantTable_SetValue(p,a,b,c,d) (p)->SetValue(a,b,c,d) +#define ID3DXConstantTable_SetBool(p,a,b,c) (p)->SetBool(a,b,c) +#define ID3DXConstantTable_SetBoolArray(p,a,b,c,d) (p)->SetBoolArray(a,b,c,d) +#define ID3DXConstantTable_SetInt(p,a,b,c) (p)->SetInt(a,b,c) +#define ID3DXConstantTable_SetIntArray(p,a,b,c,d) (p)->SetIntArray(a,b,c,d) +#define ID3DXConstantTable_SetFloat(p,a,b,c) (p)->SetFloat(a,b,c) +#define ID3DXConstantTable_SetFloatArray(p,a,b,c,d) (p)->SetFloatArray(a,b,c,d) +#define ID3DXConstantTable_SetVector(p,a,b,c) (p)->SetVector(a,b,c) +#define ID3DXConstantTable_SetVectorArray(p,a,b,c,d) (p)->SetVectorArray(a,b,c,d) +#define ID3DXConstantTable_SetMatrix(p,a,b,c) (p)->SetMatrix(a,b,c) +#define ID3DXConstantTable_SetMatrixArray(p,a,b,c,d) (p)->SetMatrixArray(a,b,c,d) +#define ID3DXConstantTable_SetMatrixPointerArray(p,a,b,c,d) (p)->SetMatrixPointerArray(a,b,c,d) +#define ID3DXConstantTable_SetMatrixTranspose(p,a,b,c) (p)->>SetMatrixTranspose(a,b,c) +#define ID3DXConstantTable_SetMatrixTransposeArray(p,a,b,c,d) (p)->SetMatrixTransposeArray(a,b,c,d) +#define ID3DXConstantTable_SetMatrixTransposePointerArray(p,a,b,c,d) (p)->SetMatrixTransposePointerArray(a,b,c,d) +#endif + +typedef struct ID3DXConstantTable *LPD3DXCONSTANTTABLE; + typedef struct _D3DXMACRO { LPCSTR Name; LPCSTR Definition; @@ -114,6 +248,7 @@ LPCSTR WINAPI D3DXGetPixelShaderProfile(LPDIRECT3DDEVICE9 device); UINT WINAPI D3DXGetShaderSize(const DWORD *byte_code); DWORD WINAPI D3DXGetShaderVersion(const DWORD *byte_code); LPCSTR WINAPI D3DXGetVertexShaderProfile(LPDIRECT3DDEVICE9 device); +HRESULT WINAPI D3DXFindShaderComment(CONST DWORD* byte_code, DWORD fourcc, LPCVOID* data, UINT* size); HRESULT WINAPI D3DXAssembleShaderFromFileA(LPCSTR filename, CONST D3DXMACRO* defines, @@ -153,6 +288,13 @@ HRESULT WINAPI D3DXAssembleShader(LPCSTR data, LPD3DXBUFFER* shader, LPD3DXBUFFER* error_messages); +HRESULT WINAPI D3DXGetShaderConstantTableEx(CONST DWORD* byte_code, + DWORD flags, + LPD3DXCONSTANTTABLE* constant_table); + +HRESULT WINAPI D3DXGetShaderConstantTable(CONST DWORD* byte_code, + LPD3DXCONSTANTTABLE* constant_table); + #ifdef __cplusplus } #endif diff --git a/include/ndk/ifssupp.h b/include/ndk/ifssupp.h index cafba9751c8..b970ee33ae7 100644 --- a/include/ndk/ifssupp.h +++ b/include/ndk/ifssupp.h @@ -28,8 +28,28 @@ typedef enum _TOKEN_TYPE TokenImpersonation } TOKEN_TYPE, *PTOKEN_TYPE; +typedef NTSTATUS +(NTAPI * PRTL_HEAP_COMMIT_ROUTINE)( + IN PVOID Base, + IN OUT PVOID *CommitAddress, + IN OUT PSIZE_T CommitSize +); + +typedef struct _RTL_HEAP_PARAMETERS +{ + ULONG Length; + SIZE_T SegmentReserve; + SIZE_T SegmentCommit; + SIZE_T DeCommitFreeBlockThreshold; + SIZE_T DeCommitTotalFreeThreshold; + SIZE_T MaximumAllocationSize; + SIZE_T VirtualMemoryThreshold; + SIZE_T InitialCommit; + SIZE_T InitialReserve; + PRTL_HEAP_COMMIT_ROUTINE CommitRoutine; + SIZE_T Reserved[2]; +} RTL_HEAP_PARAMETERS, *PRTL_HEAP_PARAMETERS; -typedef PVOID PRTL_HEAP_PARAMETERS; typedef PVOID PFS_FILTER_CALLBACKS; typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL; diff --git a/include/psdk/access.idl b/include/psdk/access.idl new file mode 100644 index 00000000000..d3d94240384 --- /dev/null +++ b/include/psdk/access.idl @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a8c-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IAccessor : IUnknown +{ + + typedef DWORD DBACCESSORFLAGS; + + typedef DWORD DBBINDSTATUS; + + [local] + HRESULT AddRefAccessor([in] HACCESSOR hAccessor, + [in, out, unique, annotation("__out_opt")] DBREFCOUNT *pcRefCount); + + [call_as(AddRefAccessor)] + HRESULT RemoteAddRefAccessor([in] HACCESSOR hAccessor, + [in, out, unique, annotation("__out_opt")] DBREFCOUNT *pcRefCount, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT CreateAccessor([in] DBACCESSORFLAGS dwAccessorFlags, + [in] DBCOUNTITEM cBindings, + [in, size_is(cBindings), annotation("__in_ecount(cBindings)")] const DBBINDING rgBindings[], + [in] DBLENGTH cbRowSize, + [out, annotation("__out")] HACCESSOR *phAccessor, + [out, size_is(cBindings), annotation("__out_ecount_opt(cBindings)")] DBBINDSTATUS rgStatus[]); + + [call_as(CreateAccessor)] + HRESULT RemoteCreateAccessor([in] DBACCESSORFLAGS dwAccessorFlags, + [in] DBCOUNTITEM cBindings, + [in, unique, size_is(cBindings)] DBBINDING *rgBindings, + [in] DBLENGTH cbRowSize, + [out] HACCESSOR *phAccessor, + [in, out, unique, size_is(cBindings)] DBBINDSTATUS *rgStatus, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT GetBindings([in] HACCESSOR hAccessor, + [out, annotation("__out")] DBACCESSORFLAGS *pdwAccessorFlags, + [in, out, annotation("__out_opt")] DBCOUNTITEM *pcBindings, + [out, size_is(,*pcBindings), annotation("__deref_out_ecount_opt(*pcBindings)")] DBBINDING **prgBindings); + + [call_as(GetBindings)] + HRESULT RemoteGetBindings([in] HACCESSOR hAccessor, + [out] DBACCESSORFLAGS *pdwAccessorFlags, + [in, out] DBCOUNTITEM *pcBindings, + [out, size_is(,*pcBindings)] DBBINDING **prgBindings, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT ReleaseAccessor([in] HACCESSOR hAccessor, + [in, out, unique, annotation("__out_opt")] DBREFCOUNT *pcRefCount); + + [call_as(ReleaseAccessor)] + HRESULT RemoteReleaseAccessor([in] HACCESSOR hAccessor, + [in, out, unique] DBREFCOUNT *pcRefCount, + [out] IErrorInfo **ppErrorInfoRem); + +}; diff --git a/include/psdk/asynot.idl b/include/psdk/asynot.idl new file mode 100644 index 00000000000..b745bd9c796 --- /dev/null +++ b/include/psdk/asynot.idl @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a96-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBAsynchNotify : IUnknown +{ + [local] + HRESULT OnLowResource([in] DB_DWRESERVE dwReserved); + + [call_as(OnLowResource)] + HRESULT RemoteOnLowResource([in] DB_DWRESERVE dwReserved); + + [local] + HRESULT OnProgress([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in] DBCOUNTITEM ulProgress, + [in] DBCOUNTITEM ulProgressMax, + [in] DBASYNCHPHASE eAsynchPhase, + [in, annotation("__in_opt")] LPOLESTR pwszStatusText); + + [call_as(OnProgress)] + HRESULT RemoteOnProgress([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in] DBCOUNTITEM ulProgress, + [in] DBCOUNTITEM ulProgressMax, + [in] DBASYNCHPHASE eAsynchPhase, + [in, unique, string] LPOLESTR pwszStatusText); + + [local] + HRESULT OnStop([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in] HRESULT hrStatus, + [in, annotation("__in_opt")] LPOLESTR pwszStatusText); + + [call_as(OnStop)] + HRESULT RemoteOnStop([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in] HRESULT hrStatus, + [in, unique, string] LPOLESTR pwszStatusText); +} diff --git a/include/psdk/asysta.idl b/include/psdk/asysta.idl new file mode 100644 index 00000000000..40bca846530 --- /dev/null +++ b/include/psdk/asysta.idl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a95-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBAsynchStatus : IUnknown +{ + [local] + HRESULT Abort([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation); + + [call_as(Abort)] + HRESULT RemoteAbort([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT GetStatus([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [out, annotation("__out_opt")] DBCOUNTITEM *pulProgress, + [out, annotation("__out_opt")] DBCOUNTITEM *pulProgressMax, + [out, annotation("__out")] DBASYNCHPHASE *peAsynchPhase, + [out, annotation("__deref_opt_inout_opt")] LPOLESTR *ppwszStatusText); + + [call_as(GetStatus)] + HRESULT RemoteGetStatus([in] HCHAPTER hChapter, + [in] DBASYNCHOP eOperation, + [in, out, unique] DBCOUNTITEM *pulProgress, + [in, out, unique] DBCOUNTITEM *pulProgressMax, + [in, out, unique] DBASYNCHPHASE *peAsynchPhase, + [in, out, unique] LPOLESTR *ppwszStatusText, + [out] IErrorInfo **ppErrorInfoRem); +} diff --git a/include/psdk/binres.idl b/include/psdk/binres.idl new file mode 100644 index 00000000000..f09d124fdef --- /dev/null +++ b/include/psdk/binres.idl @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733ab1-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IBindResource : IUnknown +{ + [local] + HRESULT Bind([in] IUnknown *pUnkOuter, + [in] LPCOLESTR pwszURL, + [in] DBBINDURLFLAG dwBindURLFlags, + [in] REFGUID rguid, + [in] REFIID riid, + [in] IAuthenticate *pAuthenticate, + [in, out, unique] DBIMPLICITSESSION *pImplSession, + [in, out, unique] DBBINDURLSTATUS *pdwBindStatus, + [out, iid_is(riid)] IUnknown **ppUnk); + + [call_as(Bind)] + HRESULT RemoteBind([in] IUnknown *pUnkOuter, + [in] LPCOLESTR pwszURL, + [in] DBBINDURLFLAG dwBindURLFlags, + [in] REFGUID rguid, + [in] REFIID riid, + [in] IAuthenticate *pAuthenticate, + [in] IUnknown *pSessionUnkOuter, + [in, unique] IID *piid, + [in, out, unique, iid_is(piid)] IUnknown **ppSession, + [in, out, unique] DBBINDURLSTATUS *pdwBindStatus, + [out, iid_is(riid)] IUnknown **ppUnk); +} diff --git a/include/psdk/bits.idl b/include/psdk/bits.idl index 386d6c00b75..89b916d0a2c 100644 --- a/include/psdk/bits.idl +++ b/include/psdk/bits.idl @@ -30,6 +30,10 @@ cpp_quote("#define BG_NOTIFY_JOB_ERROR 0x0002") cpp_quote("#define BG_NOTIFY_DISABLE 0x0004") cpp_quote("#define BG_NOTIFY_JOB_MODIFICATION 0x0008") +cpp_quote("#ifdef WINE_NO_UNICODE_MACROS") +cpp_quote("#undef EnumJobs") +cpp_quote("#undef GetJob") +cpp_quote("#endif") #define BG_ENUM_SIZEIS(maxcount) maxcount #define BG_ENUM_LENGTHIS(maxcount,lengthptr) lengthptr ? *lengthptr : maxcount diff --git a/include/psdk/cmdbas.idl b/include/psdk/cmdbas.idl new file mode 100644 index 00000000000..01be4604f38 --- /dev/null +++ b/include/psdk/cmdbas.idl @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a63-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface ICommand : IUnknown +{ + [local] + HRESULT Cancel(); + + [call_as(Cancel)] + HRESULT RemoteCancel([out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT Execute([in, annotation("__in_opt")] IUnknown *pUnkOuter, + [in] REFIID riid, + [in, out, annotation("__inout_opt")] DBPARAMS *pParams, + [out, annotation("__out_opt")] DBROWCOUNT *pcRowsAffected, + [out, iid_is(riid), annotation("__deref_opt_out")] IUnknown **ppRowset); + + [call_as(Execute)] + HRESULT RemoteExecute([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [in] HACCESSOR hAccessor, + [in] DB_UPARAMS cParamSets, + [in, unique] GUID *pGuid, + [in] ULONG ulGuidOffset, + [in, unique] RMTPACK *pInputParams, + [in, out, unique] RMTPACK *pOutputParams, + [in] DBCOUNTITEM cBindings, + [in, unique, size_is(cBindings)] DBBINDING *rgBindings, + [in, out, unique, size_is(cBindings)] DBSTATUS *rgStatus, + [in, out, unique] DBROWCOUNT *pcRowsAffected, + [in, out, unique, iid_is(riid)] IUnknown **ppRowset); + + [local] + HRESULT GetDBSession([in] REFIID riid, + [out, iid_is(riid), annotation("__deref_out_opt")] IUnknown **ppSession); + + [call_as(GetDBSession)] + HRESULT RemoteGetDBSession([in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppSession, + [out] IErrorInfo **ppErrorInfoRem); +}; diff --git a/include/psdk/cmdtxt.idl b/include/psdk/cmdtxt.idl new file mode 100644 index 00000000000..32208848353 --- /dev/null +++ b/include/psdk/cmdtxt.idl @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a27-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface ICommandText : ICommand +{ + [local] + HRESULT GetCommandText([in, out /*, annotation("__inout_opt")*/] GUID *pguidDialect, + [out /*, annotation("__deref_out")*/] LPOLESTR *ppwszCommand); + + [call_as(GetCommandText)] + HRESULT RemoteGetCommandText([in, out, unique] GUID *pguidDialect, + [out] LPOLESTR *ppwszCommand, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT SetCommandText([in] REFGUID rguidDialect, + [in, unique /*, annotation("__in_z_opt")*/] LPCOLESTR pwszCommand); + + [call_as(SetCommandText)] + HRESULT RemoteSetCommandText([in] REFGUID rguidDialect, + [in, unique] LPCOLESTR pwszCommand, + [out] IErrorInfo **ppErrorInfoRem); + +}; diff --git a/include/psdk/control.idl b/include/psdk/control.idl index c0b1914a02b..84a4f88e6a9 100644 --- a/include/psdk/control.idl +++ b/include/psdk/control.idl @@ -27,7 +27,7 @@ interface IMediaEvent; interface IMediaEventEx; interface IMediaPosition; -typedef long OAFilterState; +typedef LONG OAFilterState; typedef LONG_PTR OAHWND; typedef LONG_PTR OAEVENT; @@ -68,10 +68,10 @@ interface IMediaControl : IDispatch ] interface IBasicAudio : IDispatch { - [propput] HRESULT Volume( [in] long lVolume ); - [propget] HRESULT Volume( [out] long *plVolume ); - [propput] HRESULT Balance( [in] long lBalance ); - [propget] HRESULT Balance( [out] long *plBalance ); + [propput] HRESULT Volume( [in] LONG lVolume ); + [propget] HRESULT Volume( [out] LONG *plVolume ); + [propput] HRESULT Balance( [in] LONG lBalance ); + [propget] HRESULT Balance( [out] LONG *plBalance ); } @@ -87,43 +87,43 @@ interface IVideoWindow : IDispatch { [propput] HRESULT Caption( [in] BSTR strCaption ); [propget] HRESULT Caption( [out] BSTR *strCaption ); - [propput] HRESULT WindowStyle( [in] long WindowStyle ); - [propget] HRESULT WindowStyle( [out] long *WindowStyle ); - [propput] HRESULT WindowStyleEx( [in] long WindowStyleEx ); - [propget] HRESULT WindowStyleEx( [out] long *WindowStyleEx ); - [propput] HRESULT AutoShow( [in] long AutoShow ); - [propget] HRESULT AutoShow( [out] long *AutoShow ); - [propput] HRESULT WindowState( [in] long WindowState ); - [propget] HRESULT WindowState( [out] long *WindowState ); - [propput] HRESULT BackgroundPalette( [in] long BackgroundPalette ); - [propget] HRESULT BackgroundPalette( [out] long *pBackgroundPalette ); - [propput] HRESULT Visible( [in] long Visible ); - [propget] HRESULT Visible( [out] long *pVisible ); - [propput] HRESULT Left( [in] long Left ); - [propget] HRESULT Left( [out] long *pLeft ); - [propput] HRESULT Width( [in] long Width ); - [propget] HRESULT Width( [out] long *pWidth ); - [propput] HRESULT Top( [in] long Top ); - [propget] HRESULT Top( [out] long *pTop ); - [propput] HRESULT Height( [in] long Height ); - [propget] HRESULT Height( [out] long *pHeight ); + [propput] HRESULT WindowStyle( [in] LONG WindowStyle ); + [propget] HRESULT WindowStyle( [out] LONG *WindowStyle ); + [propput] HRESULT WindowStyleEx( [in] LONG WindowStyleEx ); + [propget] HRESULT WindowStyleEx( [out] LONG *WindowStyleEx ); + [propput] HRESULT AutoShow( [in] LONG AutoShow ); + [propget] HRESULT AutoShow( [out] LONG *AutoShow ); + [propput] HRESULT WindowState( [in] LONG WindowState ); + [propget] HRESULT WindowState( [out] LONG *WindowState ); + [propput] HRESULT BackgroundPalette( [in] LONG BackgroundPalette ); + [propget] HRESULT BackgroundPalette( [out] LONG *pBackgroundPalette ); + [propput] HRESULT Visible( [in] LONG Visible ); + [propget] HRESULT Visible( [out] LONG *pVisible ); + [propput] HRESULT Left( [in] LONG Left ); + [propget] HRESULT Left( [out] LONG *pLeft ); + [propput] HRESULT Width( [in] LONG Width ); + [propget] HRESULT Width( [out] LONG *pWidth ); + [propput] HRESULT Top( [in] LONG Top ); + [propget] HRESULT Top( [out] LONG *pTop ); + [propput] HRESULT Height( [in] LONG Height ); + [propget] HRESULT Height( [out] LONG *pHeight ); [propput] HRESULT Owner( [in] OAHWND Owner ); [propget] HRESULT Owner( [out] OAHWND *Owner ); [propput] HRESULT MessageDrain( [in] OAHWND Drain ); [propget] HRESULT MessageDrain( [out] OAHWND *Drain ); - [propget] HRESULT BorderColor( [out] long *Color ); - [propput] HRESULT BorderColor( [in] long Color ); - [propget] HRESULT FullScreenMode( [out] long *FullScreenMode ); - [propput] HRESULT FullScreenMode( [in] long FullScreenMode ); - HRESULT SetWindowForeground( [in] long Focus ); - HRESULT NotifyOwnerMessage( [in] OAHWND hwnd, [in] long uMsg, [in] LONG_PTR wParam, [in] LONG_PTR lParam ); - HRESULT SetWindowPosition( [in] long Left, [in] long Top, [in] long Width, [in] long Height ); - HRESULT GetWindowPosition( [out] long *pLeft, [out] long *pTop, [out] long *pWidth, [out] long *pHeight ); - HRESULT GetMinIdealImageSize( [out] long *pWidth, [out] long *pHeight ); - HRESULT GetMaxIdealImageSize( [out] long *pWidth, [out] long *pHeight ); - HRESULT GetRestorePosition( [out] long *pLeft, [out] long *pTop, [out] long *pWidth, [out] long *pHeight ); - HRESULT HideCursor( [in] long HideCursor ); - HRESULT IsCursorHidden( [out] long *CursorHidden ); + [propget] HRESULT BorderColor( [out] LONG *Color ); + [propput] HRESULT BorderColor( [in] LONG Color ); + [propget] HRESULT FullScreenMode( [out] LONG *FullScreenMode ); + [propput] HRESULT FullScreenMode( [in] LONG FullScreenMode ); + HRESULT SetWindowForeground( [in] LONG Focus ); + HRESULT NotifyOwnerMessage( [in] OAHWND hwnd, [in] LONG uMsg, [in] LONG_PTR wParam, [in] LONG_PTR lParam ); + HRESULT SetWindowPosition( [in] LONG Left, [in] LONG Top, [in] LONG Width, [in] LONG Height ); + HRESULT GetWindowPosition( [out] LONG *pLeft, [out] LONG *pTop, [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT GetMinIdealImageSize( [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT GetMaxIdealImageSize( [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT GetRestorePosition( [out] LONG *pLeft, [out] LONG *pTop, [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT HideCursor( [in] LONG HideCursor ); + HRESULT IsCursorHidden( [out] LONG *CursorHidden ); } @@ -138,39 +138,39 @@ interface IVideoWindow : IDispatch interface IBasicVideo : IDispatch { [propget] HRESULT AvgTimePerFrame( [out] REFTIME *pAvgTimePerFrame ); - [propget] HRESULT BitRate( [out] long *pBitRate ); - [propget] HRESULT BitErrorRate( [out] long *pBitErrorRate ); - [propget] HRESULT VideoWidth( [out] long *pVideoWidth ); - [propget] HRESULT VideoHeight( [out] long *pVideoHeight ); - [propput] HRESULT SourceLeft( [in] long SourceLeft ); - [propget] HRESULT SourceLeft( [out] long *pSourceLeft ); - [propput] HRESULT SourceWidth( [in] long SourceWidth ); - [propget] HRESULT SourceWidth( [out] long *pSourceWidth ); - [propput] HRESULT SourceTop( [in] long SourceTop ); - [propget] HRESULT SourceTop( [out] long *pSourceTop ); - [propput] HRESULT SourceHeight( [in] long SourceHeight ); - [propget] HRESULT SourceHeight( [out] long *pSourceHeight ); - [propput] HRESULT DestinationLeft( [in] long DestinationLeft ); - [propget] HRESULT DestinationLeft( [out] long *pDestinationLeft ); - [propput] HRESULT DestinationWidth( [in] long DestinationWidth ); - [propget] HRESULT DestinationWidth( [out] long *pDestinationWidth ); - [propput] HRESULT DestinationTop( [in] long DestinationTop ); - [propget] HRESULT DestinationTop( [out] long *pDestinationTop ); - [propput] HRESULT DestinationHeight( [in] long DestinationHeight ); - [propget] HRESULT DestinationHeight( [out] long *pDestinationHeight ); - HRESULT SetSourcePosition( [in] long Left, [in] long Top, [in] long Width, [in] long Height ); - HRESULT GetSourcePosition( [out] long *pLeft, [out] long *pTop, [out] long *pWidth, [out] long *pHeight ); + [propget] HRESULT BitRate( [out] LONG *pBitRate ); + [propget] HRESULT BitErrorRate( [out] LONG *pBitErrorRate ); + [propget] HRESULT VideoWidth( [out] LONG *pVideoWidth ); + [propget] HRESULT VideoHeight( [out] LONG *pVideoHeight ); + [propput] HRESULT SourceLeft( [in] LONG SourceLeft ); + [propget] HRESULT SourceLeft( [out] LONG *pSourceLeft ); + [propput] HRESULT SourceWidth( [in] LONG SourceWidth ); + [propget] HRESULT SourceWidth( [out] LONG *pSourceWidth ); + [propput] HRESULT SourceTop( [in] LONG SourceTop ); + [propget] HRESULT SourceTop( [out] LONG *pSourceTop ); + [propput] HRESULT SourceHeight( [in] LONG SourceHeight ); + [propget] HRESULT SourceHeight( [out] LONG *pSourceHeight ); + [propput] HRESULT DestinationLeft( [in] LONG DestinationLeft ); + [propget] HRESULT DestinationLeft( [out] LONG *pDestinationLeft ); + [propput] HRESULT DestinationWidth( [in] LONG DestinationWidth ); + [propget] HRESULT DestinationWidth( [out] LONG *pDestinationWidth ); + [propput] HRESULT DestinationTop( [in] LONG DestinationTop ); + [propget] HRESULT DestinationTop( [out] LONG *pDestinationTop ); + [propput] HRESULT DestinationHeight( [in] LONG DestinationHeight ); + [propget] HRESULT DestinationHeight( [out] LONG *pDestinationHeight ); + HRESULT SetSourcePosition( [in] LONG Left, [in] LONG Top, [in] LONG Width, [in] LONG Height ); + HRESULT GetSourcePosition( [out] LONG *pLeft, [out] LONG *pTop, [out] LONG *pWidth, [out] LONG *pHeight ); HRESULT SetDefaultSourcePosition(); - HRESULT SetDestinationPosition( [in] long Left, [in] long Top, [in] long Width, [in] long Height ); - HRESULT GetDestinationPosition( [out] long *pLeft, [out] long *pTop, [out] long *pWidth, [out] long *pHeight ); + HRESULT SetDestinationPosition( [in] LONG Left, [in] LONG Top, [in] LONG Width, [in] LONG Height ); + HRESULT GetDestinationPosition( [out] LONG *pLeft, [out] LONG *pTop, [out] LONG *pWidth, [out] LONG *pHeight ); HRESULT SetDefaultDestinationPosition(); - HRESULT GetVideoSize( [out] long *pWidth, [out] long *pHeight ); - HRESULT GetVideoPaletteEntries( [in] long StartIndex, - [in] long Entries, - [out] long *pRetrieved, - [out, size_is(Entries), length_is(*pRetrieved)] long *pPalette ); - HRESULT GetCurrentImage( [in, out] long *pBufferSize, - [out, size_is(*pBufferSize), length_is(*pBufferSize)] long *pDIBImage ); + HRESULT GetVideoSize( [out] LONG *pWidth, [out] LONG *pHeight ); + HRESULT GetVideoPaletteEntries( [in] LONG StartIndex, + [in] LONG Entries, + [out] LONG *pRetrieved, + [out, size_is(Entries), length_is(*pRetrieved)] LONG *pPalette ); + HRESULT GetCurrentImage( [in, out] LONG *pBufferSize, + [out, size_is(*pBufferSize), length_is(*pBufferSize)] LONG *pDIBImage ); HRESULT IsUsingDefaultSource(); HRESULT IsUsingDefaultDestination(); } @@ -198,11 +198,11 @@ interface IBasicVideo2 : IBasicVideo interface IMediaEvent : IDispatch { HRESULT GetEventHandle( [out] OAEVENT *hEvent ); - HRESULT GetEvent( [out] long *lEventCode, [out] LONG_PTR *lParam1, [out] LONG_PTR *lParam2, [in] long msTimeout ); - HRESULT WaitForCompletion( [in] long msTimeout, [out] long *pEvCode ); - HRESULT CancelDefaultHandling( [in] long lEvCode ); - HRESULT RestoreDefaultHandling( [in] long lEvCode ); - HRESULT FreeEventParams( [in] long lEvCode, [in] LONG_PTR lParam1, [in] LONG_PTR lParam2 ); + HRESULT GetEvent( [out] LONG *lEventCode, [out] LONG_PTR *lParam1, [out] LONG_PTR *lParam2, [in] LONG msTimeout ); + HRESULT WaitForCompletion( [in] LONG msTimeout, [out] LONG *pEvCode ); + HRESULT CancelDefaultHandling( [in] LONG lEvCode ); + HRESULT RestoreDefaultHandling( [in] LONG lEvCode ); + HRESULT FreeEventParams( [in] LONG lEvCode, [in] LONG_PTR lParam1, [in] LONG_PTR lParam2 ); } @@ -216,9 +216,9 @@ interface IMediaEvent : IDispatch ] interface IMediaEventEx : IMediaEvent { - HRESULT SetNotifyWindow( [in] OAHWND hwnd, [in] long lMsg, [in] LONG_PTR lInstanceData ); - HRESULT SetNotifyFlags( [in] long lNoNotifyFlags ); - HRESULT GetNotifyFlags( [out] long *lplNoNotifyFlags ); + HRESULT SetNotifyWindow( [in] OAHWND hwnd, [in] LONG lMsg, [in] LONG_PTR lInstanceData ); + HRESULT SetNotifyFlags( [in] LONG lNoNotifyFlags ); + HRESULT GetNotifyFlags( [out] LONG *lplNoNotifyFlags ); } diff --git a/include/psdk/crtrow.idl b/include/psdk/crtrow.idl new file mode 100644 index 00000000000..7088e00e721 --- /dev/null +++ b/include/psdk/crtrow.idl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733ab2-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface ICreateRow : IUnknown +{ + [local] + HRESULT CreateRow([in, unique] IUnknown *pUnkOuter, + [in] LPCOLESTR pwszURL, + [in] DBBINDURLFLAG dwBindURLFlags, + [in] REFGUID rguid, + [in] REFIID riid, + [in, unique] IAuthenticate *pAuthenticate, + [in, out, unique] DBIMPLICITSESSION *pImplSession, + [in, out, unique] DBBINDURLSTATUS *pdwBindStatus, + [out, annotation("__deref_opt_out_opt")] LPOLESTR *ppwszNewURL, + [out, iid_is(riid)] IUnknown **ppUnk); + + [call_as(CreateRow)] + HRESULT RemoteCreateRow([in] IUnknown *pUnkOuter, + [in] LPCOLESTR pwszURL, + [in] DBBINDURLFLAG dwBindURLFlags, + [in] REFGUID rguid, + [in] REFIID riid, + [in] IAuthenticate *pAuthenticate, + [in] IUnknown *pSessionUnkOuter, + [in, unique] IID *piid, + [in, out, unique, iid_is(piid)] IUnknown **ppSession, + [in, out, unique] DBBINDURLSTATUS *pdwBindStatus, + [in, out, unique] LPOLESTR *ppwszNewURL, + [out, iid_is(riid)] IUnknown **ppUnk); +} diff --git a/include/psdk/ctfutb.idl b/include/psdk/ctfutb.idl new file mode 100644 index 00000000000..6d80b3890dd --- /dev/null +++ b/include/psdk/ctfutb.idl @@ -0,0 +1,73 @@ +/* + * Copyright 2010 Justin Chevrier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef DO_NO_IMPORTS +import "oaidl.idl"; +#endif + +interface ITfLangBarEventSink; +interface ITfLangBarItemMgr; +interface ITfInputProcessorProfiles; + +[ + object, + uuid(87955690-e627-11d2-8ddb-00105a2799b5), + pointer_default(unique) +] +interface ITfLangBarMgr: IUnknown +{ + HRESULT AdviseEventSink( + [in] ITfLangBarEventSink *pSink, + [in] HWND hwnd, + [in] DWORD dwflags, + [in] DWORD *pdwCookie); + + HRESULT UnAdviseEventSink( + [in] DWORD dwCookie); + + HRESULT GetThreadMarshalInterface( + [in] DWORD dwThreadId, + [in] DWORD dwType, + [in] REFIID riid, + [out] IUnknown **ppunk); + + HRESULT GetThreadLangBarItemMgr( + [in] DWORD dwThreadId, + [out] ITfLangBarItemMgr **pplbie, + [out] DWORD *pdwThreadid); + + HRESULT GetInputProcessorProfiles( + [in] DWORD dwThreadId, + [out] ITfInputProcessorProfiles **ppaip, + [out] DWORD *pdwThreadid); + + HRESULT RestoreLastFocus( + [out] DWORD *dwThreadId, + [in] BOOL fPrev); + + HRESULT SetModalInput( + [in] ITfLangBarEventSink *pSink, + [in] DWORD dwThreadId, + [in] DWORD dwFlags); + + HRESULT ShowFloating( + [in] DWORD dwFlags); + + HRESULT GetShowFloatingStatus( + [out] DWORD *pdwFlags); +}; diff --git a/include/psdk/dbccmd.idl b/include/psdk/dbccmd.idl new file mode 100644 index 00000000000..99274bc05ba --- /dev/null +++ b/include/psdk/dbccmd.idl @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a1d-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBCreateCommand : IUnknown +{ + [local] + HRESULT CreateCommand([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppCommand); + + [call_as(CreateCommand)] + HRESULT RemoteCreateCommand([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppCommand, + [out] IErrorInfo **ppErrorInfoRem); +} diff --git a/include/psdk/dbcses.idl b/include/psdk/dbcses.idl new file mode 100644 index 00000000000..3bdb0d779d4 --- /dev/null +++ b/include/psdk/dbcses.idl @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a5d-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBCreateSession : IUnknown +{ + [local] + HRESULT CreateSession([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppDBSession); + + [call_as(CreateSession)] + HRESULT RemoteCreateSession([in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppDBSession, + [out] IErrorInfo **ppErrorInfoRem); +} diff --git a/include/psdk/dbdsad.idl b/include/psdk/dbdsad.idl new file mode 100644 index 00000000000..c6fb2b4ea4b --- /dev/null +++ b/include/psdk/dbdsad.idl @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a7a-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IDBDataSourceAdmin : IUnknown +{ + [local] + HRESULT CreateDataSource([in] ULONG cPropertySets, + [in, out, size_is(cPropertySets)] DBPROPSET rgPropertySets[], + [in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppDBSession); + + [call_as(CreateDataSource)] + HRESULT RemoteCreateDataSource([in] ULONG cPropertySets, + [in, unique, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [in] IUnknown *pUnkOuter, + [in] REFIID riid, + [in, out, unique, iid_is(riid)] IUnknown **ppDBSession, + [in] ULONG cTotalProps, + [out, size_is(cTotalProps)] DBPROPSTATUS *rgPropStatus, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT DestroyDataSource(); + + [call_as(DestroyDataSource)] + HRESULT RemoteDestroyDataSource([out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT GetCreationProperties([in] ULONG cPropertyIDSets, + [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], + [in, out] ULONG *pcPropertyInfoSets, + [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets, + [out, annotation("__deref_out_z_opt")] OLECHAR **ppDescBuffer); + + [call_as(GetCreationProperties)] + HRESULT RemoteGetCreationProperties([in] ULONG cPropertyIDSets, + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, + [in, out] ULONG *pcPropertyInfoSets, + [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets, + [in, out] DBCOUNTITEM *pcOffsets, + [out, size_is(,(ULONG)*pcOffsets)] DBBYTEOFFSET **prgDescOffsets, + [in, out] ULONG *pcbDescBuffer, + [in, out, unique, size_is(,*pcbDescBuffer)] OLECHAR **ppDescBuffer, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT ModifyDataSource([in] ULONG cPropertySets, + [in, size_is(cPropertySets)] DBPROPSET rgPropertySets[]); + + [call_as(ModifyDataSource)] + HRESULT RemoteModifyDataSource([in] ULONG cPropertySets, + [in, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [out] IErrorInfo **ppErrorInfoRem); +} diff --git a/include/psdk/dbprop.idl b/include/psdk/dbprop.idl index 5ed5301385f..782191a4554 100644 --- a/include/psdk/dbprop.idl +++ b/include/psdk/dbprop.idl @@ -30,7 +30,7 @@ interface IDBProperties : IUnknown { [call_as(GetProperties)] HRESULT RemoteGetProperties( [in] ULONG cPropertyIDSets, - [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, [in, out] ULONG *pcPropertySets, [out, size_is(,*pcPropertySets)] DBPROPSET **prgPropertySets, [out] IErrorInfo **ppErrorInfoRem); @@ -39,17 +39,18 @@ interface IDBProperties : IUnknown { [in] ULONG cPropertyIDSets, [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], [in, out] ULONG *pcPropertyInfoSets, - [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets); + [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets, + [out, annotation("__deref_out_z_opt")] OLECHAR **ppDescBuffer); [call_as(GetPropertyInfo)] HRESULT RemoteGetPropertyInfo( [in] ULONG cPropertyIDSets, - [in,size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, [in, out] ULONG *pcPropertyInfoSets, [out, size_is(,*pcPropertyInfoSets)] DBPROPINFOSET **prgPropertyInfoSets, [in, out] ULONG *pcOffsets, [out, size_is(,*pcOffsets)] DBBYTEOFFSET **prgDescOffsets, [in, out] ULONG *pcbDescBuffer, - [out, size_is(,*pcbDescBuffer)] OLECHAR **ppDescBuffer, + [in, out, unique, size_is(,*pcbDescBuffer)] OLECHAR **ppDescBuffer, [out] IErrorInfo **ppErrorInfoRem); [local] HRESULT SetProperties( @@ -58,7 +59,7 @@ interface IDBProperties : IUnknown { [call_as(SetProperties)] HRESULT RemoteSetProperties( [in] ULONG cPropertySets, - [in, out, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [in, unique, size_is(cPropertySets)] DBPROPSET *rgPropertySets, [in] ULONG cTotalProps, [out, size_is(cTotalProps)] DBPROPSTATUS *rgPropStatus, [out] IErrorInfo **ppErrorInfoRem); diff --git a/include/psdk/dbs.idl b/include/psdk/dbs.idl index 19c2997b3ab..8ca2e2ae659 100644 --- a/include/psdk/dbs.idl +++ b/include/psdk/dbs.idl @@ -99,3 +99,247 @@ typedef struct tagDBPROPINFOSET { ULONG cPropertyInfos; GUID guidPropertySet; } DBPROPINFOSET; + +typedef DWORD DBBINDURLFLAG; +typedef DWORD DBBINDURLSTATUS; + +typedef struct tagDBIMPLICITSESSION +{ + IUnknown *pUnkOuter; + IID *piid; + IUnknown *pSession; +} DBIMPLICITSESSION; + +typedef WORD DBTYPE; + +enum DBTYPEENUM +{ + DBTYPE_EMPTY = 0, + DBTYPE_NULL = 1, + DBTYPE_I2 = 2, + DBTYPE_I4 = 3, + DBTYPE_R4 = 4, + DBTYPE_R8 = 5, + DBTYPE_CY = 6, + DBTYPE_DATE = 7, + DBTYPE_BSTR = 8, + DBTYPE_IDISPATCH = 9, + DBTYPE_ERROR = 10, + DBTYPE_BOOL = 11, + DBTYPE_VARIANT = 12, + DBTYPE_IUNKNOWN = 13, + DBTYPE_DECIMAL = 14, + DBTYPE_I1 = 16, + DBTYPE_UI1 = 17, + DBTYPE_UI2 = 18, + DBTYPE_UI4 = 19, + DBTYPE_I8 = 20, + DBTYPE_UI8 = 21, + DBTYPE_GUID = 72, + DBTYPE_BYTES = 128, + DBTYPE_STR = 129, + DBTYPE_WSTR = 130, + DBTYPE_NUMERIC = 131, + DBTYPE_UDT = 132, + DBTYPE_DBDATE = 133, + DBTYPE_DBTIME = 134, + DBTYPE_DBTIMESTAMP = 135, + + DBTYPE_VECTOR = 0x1000, + DBTYPE_ARRAY = 0x2000, + DBTYPE_BYREF = 0x4000, + DBTYPE_RESERVED = 0x8000 +}; + +enum DBTYPEENUM15 +{ + DBTYPE_HCHAPTER = 136 +}; + +enum DBTYPEENUM20 +{ + DBTYPE_FILETIME = 64, + DBTYPE_PROPVARIANT = 138, + DBTYPE_VARNUMERIC = 139 +}; + +typedef DWORD DBSTATUS; + +enum DBSTATUSENUM +{ + DBSTATUS_S_OK = 0, + DBSTATUS_E_BADACCESSOR = 1, + DBSTATUS_E_CANTCONVERTVALUE = 2, + DBSTATUS_S_ISNULL = 3, + DBSTATUS_S_TRUNCATED = 4, + DBSTATUS_E_SIGNMISMATCH = 5, + DBSTATUS_E_DATAOVERFLOW = 6, + DBSTATUS_E_CANTCREATE = 7, + DBSTATUS_E_UNAVAILABLE = 8, + DBSTATUS_E_PERMISSIONDENIED = 9, + DBSTATUS_E_INTEGRITYVIOLATION = 10, + DBSTATUS_E_SCHEMAVIOLATION = 11, + DBSTATUS_E_BADSTATUS = 12, + DBSTATUS_S_DEFAULT = 13 +}; + +cpp_quote("#ifdef DBINITCONSTANTS") +cpp_quote("#ifdef __cplusplus") +cpp_quote("#define DEFINE_DBGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\") +cpp_quote(" EXTERN_C const GUID name DECLSPEC_HIDDEN; \\") +cpp_quote(" EXTERN_C const GUID name = \\") +cpp_quote(" { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }") +cpp_quote("#else") +cpp_quote("#define DEFINE_DBGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\") +cpp_quote(" const GUID name DECLSPEC_HIDDEN; \\") +cpp_quote(" const GUID name = \\") +cpp_quote(" { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }") +cpp_quote("#endif") +cpp_quote("#else") +cpp_quote("#define DEFINE_DBGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\") +cpp_quote(" EXTERN_C const GUID name DECLSPEC_HIDDEN") +cpp_quote("#endif") + +cpp_quote("DEFINE_DBGUID(DBGUID_SESSION, 0xc8b522f5, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);") +cpp_quote("DEFINE_DBGUID(DBGUID_ROWSET, 0xc8b522f6, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);") +cpp_quote("DEFINE_DBGUID(DBGUID_ROW, 0xc8b522f7, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);") +cpp_quote("DEFINE_DBGUID(DBGUID_STREAM, 0xc8b522f9, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);") + +typedef struct tagDBCOLUMNACCESS +{ + void *pData; + DBID columnid; + DBLENGTH cbDataLen; + DBSTATUS dwStatus; + DBLENGTH cbMaxLen; + DB_DWRESERVE dwReserved; + DBTYPE wType; + BYTE bPrecision; + BYTE bScale; +} DBCOLUMNACCESS; + +typedef DWORD DBROWSTATUS; + +enum DBROWSTATUSENUM +{ + DBROWSTATUS_S_OK = 0, + /* FIXME */ + DBROWSTATUS_E_FAIL = 19, + +}; + +typedef DWORD DBPART; + +enum DBPARTENUM +{ + DBPART_INVALID = 0, + DBPART_VALUE = 1, + DBPART_LENGTH = 2, + DBPART_STATUS = 4, +}; + +typedef DWORD DBPARAMIO; + +enum DBPARAMIOENUM +{ + DBPARAMIO_NOTPARAM = 0, + DBPARAMIO_INPUT = 1, + DBPARAMIO_OUTPUT = 2, +}; + +typedef DWORD DBMEMOWNER; + +enum DBMEMOWNERENUM +{ + DBMEMOWNER_CLIENTOWNED = 0, + DBMEMOWNER_PROVIDEROWNED = 1, +}; + +typedef struct tagDBOBJECT +{ + DWORD dwFlags; + IID iid; +} DBOBJECT; + +typedef struct tagDBBINDEXT +{ + [size_is((ULONG)ulExtension)] BYTE *pExtension; + DBCOUNTITEM ulExtension; +} DBBINDEXT; + +typedef struct tagDBBINDING +{ + DBORDINAL iOrdinal; + DBBYTEOFFSET obValue; + DBBYTEOFFSET obLength; + DBBYTEOFFSET obStatus; + ITypeInfo *pTypeInfo; + DBOBJECT *pObject; + DBBINDEXT *pBindExt; + DBPART dwPart; + DBMEMOWNER dwMemOwner; + DBPARAMIO eParamIO; + DBLENGTH cbMaxLen; + DWORD dwFlags; + DBTYPE wType; + BYTE bPrecision; + BYTE bScale; +} DBBINDING; + +typedef ULONG_PTR HACCESSOR; + +cpp_quote("#define DB_INVALID_HACCESSOR 0x00") + +typedef ULONG_PTR HROW; + +cpp_quote("#define DB_NULL_HROW 0x00") + +typedef ULONG_PTR HWATCHREGION; + +cpp_quote("#define DBWATCHREGION_NULL NULL") + +typedef ULONG_PTR HCHAPTER; + +cpp_quote("#define DB_NULL_HCHAPTER 0x00") + +typedef struct tagDBPARAMS +{ + void *pData; + DB_UPARAMS cParamSets; + HACCESSOR hAccessor; +} DBPARAMS; + +typedef DWORD DBASYNCHOP; + +enum DBASYNCHOPENUM +{ + DBSYNCHOP_OPEN, +}; + +typedef DWORD DBASYNCHPHASE; + +enum DBASYNCHPHASEENUM +{ + DBASYNCHPHASE_INITIALIZATION, + DBASYNCHPHASE_POPULATION, + DBASYNCHPHASE_COMPLETE, + DBASYNCHPHASE_CANCELED, +}; + +typedef struct tagRMTPACK +{ + ISequentialStream *pISeqStream; + ULONG cbData; + ULONG cBSTR; + [size_is(cBSTR)] BSTR *rgBSTR; + ULONG cVARIANT; + [size_is(cVARIANT)] VARIANT *rgVARIANT; + ULONG cIDISPATCH; + [size_is(cIDISPATCH)] IDispatch **rgIDISPATCH; + ULONG cIUNKNOWN; + [size_is(cIUNKNOWN)] IUnknown **rgIUNKNOWN; + ULONG cPROPVARIANT; + [size_is(cPROPVARIANT)] PROPVARIANT *rgPROPVARIANT; + ULONG cArray; + [size_is(cArray)] VARIANT *rgArray; +} RMTPACK; diff --git a/include/psdk/dimm.idl b/include/psdk/dimm.idl index 07e04b2e22f..851ec90cfd1 100644 --- a/include/psdk/dimm.idl +++ b/include/psdk/dimm.idl @@ -24,8 +24,6 @@ cpp_quote("#include ") cpp_quote("#if 0") -typedef WORD LANGID; - typedef struct { LPSTR lpReading; LPSTR lpWord; diff --git a/include/psdk/dispex.idl b/include/psdk/dispex.idl index b44448e84d9..6f1c5453a61 100644 --- a/include/psdk/dispex.idl +++ b/include/psdk/dispex.idl @@ -23,6 +23,9 @@ import "oaidl.idl"; import "servprov.idl"; #endif +cpp_quote("DEFINE_GUID(SID_VariantConversion, 0x1f101481,0xbccd,0x11d0,0x93,0x36,0x00,0xa0,0xc9,0xd,0xca,0xa9);") +cpp_quote("DEFINE_GUID(SID_GetCaller, 0x4717cc40,0xbcb9,0x11d0,0x93,0x36,0x00,0xa0,0xc9,0xd,0xca,0xa9);") + cpp_quote("#define fdexNameCaseSensitive 0x00000001L") cpp_quote("#define fdexNameEnsure 0x00000002L") cpp_quote("#define fdexNameImplicit 0x00000004L") @@ -78,13 +81,13 @@ interface IDispatchEx : IDispatch [local] HRESULT InvokeEx( - [in] DISPID id, - [in] LCID lcid, - [in] WORD wFlags, - [in] DISPPARAMS *pdp, - [out] VARIANT *pvarRes, - [out] EXCEPINFO *pei, - [in, unique] IServiceProvider *pspCaller); + [in, annotation("__in")] DISPID id, + [in, annotation("__in")] LCID lcid, + [in, annotation("__in")] WORD wFlags, + [in, annotation("__in")] DISPPARAMS *pdp, + [out, annotation("__out_opt")] VARIANT *pvarRes, + [out, annotation("__out_opt")] EXCEPINFO *pei, + [in, unique, annotation("__in_opt")] IServiceProvider *pspCaller); [call_as(InvokeEx)] HRESULT RemoteInvokeEx( @@ -188,3 +191,15 @@ interface ICanHandleException : IUnknown [in] EXCEPINFO *pExcepInfo, [in] VARIANT *pvar); } + +[ + object, + uuid(10e2414a-ec59-49d2-bc51-5add2c36febc), + pointer_default(unique) +] +interface IProvideRuntimeContext : IUnknown +{ + HRESULT GetCurrentSourceContext( + [out] DWORD_PTR *pdwContext, + [out] VARIANT_BOOL *pfExecutingGlobalCode); +} diff --git a/include/psdk/gdipluscolormatrix.h b/include/psdk/gdipluscolormatrix.h index 532e8f4c788..fbf1b2a402f 100644 --- a/include/psdk/gdipluscolormatrix.h +++ b/include/psdk/gdipluscolormatrix.h @@ -45,7 +45,7 @@ enum ColorAdjustType struct ColorMap { Color oldColor; - Color newCOlor; + Color newColor; }; #ifndef __cplusplus diff --git a/include/psdk/hlink.idl b/include/psdk/hlink.idl index 886acb36411..af3f8f5f683 100644 --- a/include/psdk/hlink.idl +++ b/include/psdk/hlink.idl @@ -151,7 +151,7 @@ interface IHlink: IUnknown } /***************************************************************************** - * IHlink interface + * IHlinkSite interface */ [ object, diff --git a/include/psdk/iphlpapi.h b/include/psdk/iphlpapi.h index 1a844d38a49..56c32fdc087 100644 --- a/include/psdk/iphlpapi.h +++ b/include/psdk/iphlpapi.h @@ -22,6 +22,7 @@ DWORD WINAPI GetAdapterIndex(LPWSTR,PULONG); DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO,PULONG); DWORD WINAPI GetBestInterface(IPAddr,PDWORD); DWORD WINAPI GetBestRoute(DWORD,DWORD,PMIB_IPFORWARDROW); +DWORD WINAPI GetExtendedTcpTable(PVOID,PDWORD,BOOL,ULONG,TCP_TABLE_CLASS,ULONG); DWORD WINAPI GetFriendlyIfIndex(DWORD); DWORD WINAPI GetIcmpStatistics(PMIB_ICMP); DWORD WINAPI GetIfEntry(PMIB_IFROW); @@ -34,6 +35,7 @@ DWORD WINAPI GetIpStatistics(PMIB_IPSTATS); DWORD WINAPI GetIpStatisticsEx(PMIB_IPSTATS,DWORD); DWORD WINAPI GetNetworkParams(PFIXED_INFO,PULONG); DWORD WINAPI GetNumberOfInterfaces(PDWORD); +DWORD WINAPI GetOwnerModuleFromTcpEntry(PMIB_TCPROW_OWNER_MODULE,TCPIP_OWNER_MODULE_INFO_CLASS,PVOID,PDWORD); DWORD WINAPI GetPerAdapterInfo(ULONG,PIP_PER_ADAPTER_INFO, PULONG); BOOL WINAPI GetRTTAndHopCount(IPAddr,PULONG,ULONG,PULONG); DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS); diff --git a/include/psdk/iprtrmib.h b/include/psdk/iprtrmib.h index a59796f0237..179a7938fde 100644 --- a/include/psdk/iprtrmib.h +++ b/include/psdk/iprtrmib.h @@ -25,6 +25,9 @@ #define MAXLEN_IFDESCR 256 #define MAXLEN_PHYSADDR 8 +//It should be 16 according to Lei Shen blog (http://www.mychinaworks.com/blog/lshen/2008/04/16/220/ +#define TCPIP_OWNING_MODULE_SIZE 16 + typedef struct _MIB_IFROW { WCHAR wszName[MAX_INTERFACE_NAME_LEN]; @@ -286,4 +289,31 @@ typedef struct _MIB_IPNETTABLE MIB_IPNETROW table[1]; } MIB_IPNETTABLE, *PMIB_IPNETTABLE; +typedef struct _MIB_TCPROW_OWNER_MODULE { + DWORD dwState; + DWORD dwLocalAddr; + DWORD dwLocalPort; + DWORD dwRemoteAddr; + DWORD dwRemotePort; + DWORD dwOwningPid; + LARGE_INTEGER liCreateTimestamp; + ULONGLONG OwningModuleInfo[TCPIP_OWNING_MODULE_SIZE]; +} MIB_TCPROW_OWNER_MODULE, *PMIB_TCPROW_OWNER_MODULE; + +typedef enum { + TCPIP_OWNER_MODULE_INFO_BASIC +} TCPIP_OWNER_MODULE_INFO_CLASS, *PTCPIP_OWNER_MODULE_INFO_CLASS; + +typedef enum { + TCP_TABLE_BASIC_LISTENER, + TCP_TABLE_BASIC_CONNECTIONS, + TCP_TABLE_BASIC_ALL, + TCP_TABLE_OWNER_PID_LISTENER, + TCP_TABLE_OWNER_PID_CONNECTIONS, + TCP_TABLE_OWNER_PID_ALL, + TCP_TABLE_OWNER_MODULE_LISTENER, + TCP_TABLE_OWNER_MODULE_CONNECTIONS, + TCP_TABLE_OWNER_MODULE_ALL +} TCP_TABLE_CLASS, *PTCP_TABLE_CLASS; + #endif /* WINE_IPRTRMIB_H__ */ diff --git a/include/psdk/mapi.h b/include/psdk/mapi.h index 2d335ea588a..7d19734c599 100644 --- a/include/psdk/mapi.h +++ b/include/psdk/mapi.h @@ -27,7 +27,7 @@ extern "C" { #ifndef __LHANDLE #define __LHANDLE -typedef ULONG LHANDLE, *LPLHANDLE; +typedef ULONG_PTR LHANDLE, *LPLHANDLE; #endif #define lhSessionNull ((LHANDLE)0) diff --git a/include/psdk/mlang.idl b/include/psdk/mlang.idl index c9d90cb4458..a5b1b473f20 100644 --- a/include/psdk/mlang.idl +++ b/include/psdk/mlang.idl @@ -25,11 +25,6 @@ interface IStream; cpp_quote("#define CPIOD_PEEK 0x40000000") cpp_quote("#define CPIOD_FORCE_PROMPT 0x80000000") -/* FIXME: LANGID is defined in winnt.h and mlang.h in the platform SDK */ -cpp_quote("#ifndef _WINNT_H") -typedef WORD LANGID; -cpp_quote("#endif") - [ object, uuid(359f3443-bd4a-11d0-b188-00aa0038c969), @@ -42,10 +37,10 @@ interface IMLangCodePages : IUnknown [out] DWORD *pdwCodePages); HRESULT GetStrCodePages( [in, size_is(cchSrc)] const WCHAR *pszSrc, - [in] long cchSrc, + [in] LONG cchSrc, [in] DWORD dwPriorityCodePages, [out] DWORD *pdwCodePages, - [out] long *pcchCodePages); + [out] LONG *pcchCodePages); HRESULT CodePageToCodePages( [in] UINT uCodePage, [out] DWORD *pdwCodePages); @@ -233,11 +228,11 @@ interface IMLangString : IUnknown { #ifdef NEWMLSTR HRESULT LockMLStr( - [in] long lPos, + [in] LONG lPos, [in] DWORD dwFlags, [out] DWORD* pdwCookie, - [out] long* plActualPos, - [out] long* plActualLen); + [out] LONG* plActualPos, + [out] LONG* plActualLen); HRESULT UnlockMLStr( [in] DWORD dwCookie); @@ -246,13 +241,13 @@ interface IMLangString : IUnknown [in] BOOL fNoAccess); #endif HRESULT GetLength( - [out, retval] long* plLen); + [out, retval] LONG* plLen); HRESULT SetMLStr( - [in] long lDestPos, - [in] long lDestLen, + [in] LONG lDestPos, + [in] LONG lDestLen, [in] IUnknown *pSrcMLStr, - [in] long lSrcPos, - [in] long lSrcLen); + [in] LONG lSrcPos, + [in] LONG lSrcLen); #ifdef NEWMLSTR HRESULT RegisterAttr( [in] IUnknown *pUnk, @@ -267,14 +262,14 @@ interface IMLangString : IUnknown [out] IUnknown **ppUnk); #else HRESULT GetMLStr( - [in] long lSrcPos, - [in] long lSrcLen, + [in] LONG lSrcPos, + [in] LONG lSrcLen, [in] IUnknown *pUnkOuter, [in] DWORD dwClsContext, [in] const IID* piid, [out] IUnknown** ppDestMLStr, - [out] long* plDestPos, - [out] long* plDestLen); + [out] LONG* plDestPos, + [out] LONG* plDestLen); #endif } @@ -287,29 +282,29 @@ interface IMLangLineBreakConsole : IUnknown { HRESULT BreakLineML( [in] IMLangString* pSrcMLStr, - [in] long lSrcPos, - [in] long lSrcLen, - [in] long cMinColumns, - [in] long cMaxColumns, - [out] long* plLineLen, - [out] long* plSkipLen); + [in] LONG lSrcPos, + [in] LONG lSrcLen, + [in] LONG cMinColumns, + [in] LONG cMaxColumns, + [out] LONG* plLineLen, + [out] LONG* plSkipLen); HRESULT BreakLineW( [in] LCID locale, [in, size_is(cchSrc)] const WCHAR* pszSrc, - [in] long cchSrc, - [in] long cMaxColumns, - [out] long* pcchLine, - [out] long* pcchSkip ); + [in] LONG cchSrc, + [in] LONG cMaxColumns, + [out] LONG* pcchLine, + [out] LONG* pcchSkip ); HRESULT BreakLineA( [in] LCID locale, [in] UINT uCodePage, [in, size_is(cchSrc)] const CHAR* pszSrc, - [in] long cchSrc, - [in] long cMaxColumns, - [out] long* pcchLine, - [out] long* pcchSkip); + [in] LONG cchSrc, + [in] LONG cMaxColumns, + [out] LONG* pcchLine, + [out] LONG* pcchSkip); } [ diff --git a/include/psdk/mscoree.idl b/include/psdk/mscoree.idl index aed31da4bdf..19749fbfba3 100644 --- a/include/psdk/mscoree.idl +++ b/include/psdk/mscoree.idl @@ -27,7 +27,11 @@ cpp_quote("HRESULT WINAPI GetCORSystemDirectory(LPWSTR,DWORD,DWORD*);") cpp_quote("HRESULT WINAPI GetCORVersion(LPWSTR,DWORD,DWORD*);") cpp_quote("HRESULT WINAPI GetRequestedRuntimeInfo(LPCWSTR,LPCWSTR,LPCWSTR,DWORD,DWORD,LPWSTR,DWORD,DWORD*,LPWSTR,DWORD,DWORD*);") cpp_quote("HRESULT WINAPI LoadLibraryShim(LPCWSTR,LPCWSTR,LPVOID,HMODULE*);") +cpp_quote("#ifdef WINE_STRICT_PROTOTYPES") +cpp_quote("typedef HRESULT (__stdcall *FLockClrVersionCallback)(void);") +cpp_quote("#else") cpp_quote("typedef HRESULT (__stdcall *FLockClrVersionCallback)();") +cpp_quote("#endif") cpp_quote("HRESULT WINAPI LockClrVersion(FLockClrVersionCallback,FLockClrVersionCallback*,FLockClrVersionCallback*);") typedef void* HDOMAINENUM; diff --git a/include/psdk/msctf.idl b/include/psdk/msctf.idl index 5d8cb2afa7d..fcb568e0a49 100644 --- a/include/psdk/msctf.idl +++ b/include/psdk/msctf.idl @@ -20,15 +20,10 @@ import "oaidl.idl"; import "comcat.idl"; import "textstor.idl"; -/* import "ctfutb.idl"; */ +import "ctfutb.idl"; #endif cpp_quote("#include ") -/* FIXME: LANGID is defined in winnt.h and mlang.h in the platform SDK */ -cpp_quote("#ifndef _WINNT_H") -typedef WORD LANGID; -cpp_quote("#endif") - cpp_quote("#define TF_E_STACKFULL MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0501)") cpp_quote("#define TF_E_DISCONNECTED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0504)") cpp_quote("#define TF_E_ALREADY_EXISTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0506)") @@ -37,6 +32,7 @@ cpp_quote("#define TF_E_NOLOCK MAKE_HRESULT(SEVERITY_ERROR, FACILITY_IT cpp_quote("HRESULT WINAPI TF_CreateThreadMgr(ITfThreadMgr **pptim);") cpp_quote("HRESULT WINAPI TF_GetThreadMgr(ITfThreadMgr **pptim);") cpp_quote("HRESULT WINAPI TF_CreateInputProcessorProfiles(ITfInputProcessorProfiles **ppipr);") +cpp_quote("HRESULT WINAPI TF_CreateLangBarMgr(ITfLangBarMgr **pppbm);") cpp_quote("EXTERN_C const GUID GUID_PROP_TEXTOWNER;") cpp_quote("DEFINE_GUID(GUID_PROP_ATTRIBUTE,0x34b45670,0x7526,0x11d2,0xa1,0x47,0x00,0x10,0x5a,0x27,0x99,0xb5);") @@ -46,6 +42,7 @@ cpp_quote("EXTERN_C const GUID GUID_PROP_COMPOSING;") cpp_quote("EXTERN_C const CLSID CLSID_TF_ThreadMgr;") cpp_quote("EXTERN_C const CLSID CLSID_TF_InputProcessorProfiles;") +cpp_quote("EXTERN_C const CLSID CLSID_TF_LangBarMgr;") cpp_quote("EXTERN_C const CLSID CLSID_TF_CategoryMgr;") cpp_quote("DEFINE_GUID(CLSID_TF_DisplayAttributeMgr,0x3ce74de4,0x53d3,0x4d74,0x8b,0x83,0x43,0x1b,0x38,0x28,0xba,0x53);") @@ -1349,3 +1346,16 @@ interface ITfSourceSingle : IUnknown [in] TfClientId tid, [in] REFIID riid); }; + +[ + object, + local, + uuid(c0f1db0c-3a20-405c-a303-96b6010a885f), + pointer_default(unique) +] +interface ITfThreadFocusSink : IUnknown +{ + HRESULT OnSetThreadFocus(); + + HRESULT OnKillThreadFocus(); +}; diff --git a/include/psdk/mshtmdid.h b/include/psdk/mshtmdid.h index 0d128493dbe..e3683e9755b 100644 --- a/include/psdk/mshtmdid.h +++ b/include/psdk/mshtmdid.h @@ -126,6 +126,11 @@ #define DISPID_IE8_ELEMENTMAX (DISPID_SITE-1) #define DISPID_IE8_ELEMENT DISPID_IE8_ELEMENTBASE +#define DISPID_IE8_FRAMESITEBASE (DISPID_FRAMESITE+1120) +#define DISPID_IE8_FRAMEMAX (WEBOC_DISPIDBASE-1) +#define DISPID_IE8_FRAME DISPID_IE8_FRAMESITEBASE +#define DISPID_IE8_IFRAME DISPID_IE8_FRAMESITEBASE + #define DISPID_COLLECTION (DISPID_NORMAL_FIRST+500) #define DISPID_OPTIONS_COL (DISPID_NORMAL_FIRST+500) #define DISPID_IMG (DISPID_IMGBASE+1000) @@ -2487,6 +2492,9 @@ /* IHTMLScriptElement2 */ #define DISPID_IHTMLSCRIPTELEMENT2_CHARSET DISPID_SCRIPT+10 +/* IHTMLScriptElement3 */ +#define DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC DISPID_IE8_SCRIPT + /* IHTMLFrameBase */ #define DISPID_IHTMLFRAMEBASE_SRC DISPID_FRAMESITE+0 #define DISPID_IHTMLFRAMEBASE_NAME STDPROPID_XOBJ_NAME @@ -2508,6 +2516,19 @@ /* IHTMLFrameBase3 */ #define DISPID_IHTMLFRAMEBASE3_LONGDESC DISPID_FRAMESITE+10 +/* IHTMLFrameElement */ +#define DISPID_IHTMLFRAMEELEMENT_BORDERCOLOR DISPID_FRAME+1 + +/* IHTMLFrameElement2 */ +#define DISPID_IHTMLFRAMEELEMENT2_HEIGHT STDPROPID_XOBJ_HEIGHT +#define DISPID_IHTMLFRAMEELEMENT2_WIDTH STDPROPID_XOBJ_WIDTH + +/* IHTMLFrameElement3 */ +#define DISPID_IHTMLFRAMEELEMENT3_CONTENTDOCUMENT DISPID_IE8_FRAME +#define DISPID_IHTMLFRAMEELEMENT3_IE8_SRC DISPID_IE8_FRAME+1 +#define DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC DISPID_IE8_FRAME+2 +#define DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER DISPID_IE8_FRAME+3 + /* IHTMLIFrameElement */ #define DISPID_IHTMLIFRAMEELEMENT_VSPACE DISPID_IFRAME+1 #define DISPID_IHTMLIFRAMEELEMENT_HSPACE DISPID_IFRAME+2 diff --git a/include/psdk/mshtml.idl b/include/psdk/mshtml.idl index 4a182f23bbc..1941b923b9e 100644 --- a/include/psdk/mshtml.idl +++ b/include/psdk/mshtml.idl @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007 Jacek Caban for CodeWeavers + * Copyright 2004-2010 Jacek Caban for CodeWeavers * Copyright 2008 Konstantin Kondratyuk (Etersoft) * * This library is free software; you can redistribute it and/or @@ -2876,7 +2876,7 @@ interface IHTMLCurrentStyle4 : IDispatch [propget, id(DISPID_IHTMLCURRENTSTYLE4_MAXWIDTH), displaybind, bindable] HRESULT maxWidth([retval, out] VARIANT * p); -}; +} /***************************************************************************** * DispHTMLCurrentStyle dispinterface @@ -5903,7 +5903,7 @@ coclass HTMLStyleSheetPage [default] dispinterface DispHTMLStyleSheetPage; interface IHTMLStyleSheetPage; interface IHTMLDOMConstructor; -}; +} [ odl, @@ -6702,7 +6702,7 @@ methods: [id(DISPID_HTMLFORMELEMENTEVENTS_ONRESET)] VARIANT_BOOL onreset(); -}; +} interface IHTMLEventObj; @@ -6905,7 +6905,7 @@ methods: [id(DISPID_HTMLFORMELEMENTEVENTS2_ONRESET)] VARIANT_BOOL onreset([in] IHTMLEventObj* pEvtObj); -}; +} [ noncreatable, @@ -7365,7 +7365,7 @@ interface IHTMLControlElement : IDispatch [propget, id(DISPID_IHTMLCONTROLELEMENT_CLIENTLEFT), displaybind, bindable] HRESULT clientLeft([retval, out] LONG * p); -}; +} /***************************************************************************** * IHTMLBodyElement interface @@ -7634,7 +7634,7 @@ methods: [propget, id(DISPID_IHTMLBODYELEMENT2_ONAFTERPRINT), displaybind, bindable] VARIANT onafterprint(); -}; +} [ uuid(3050f24a-98b5-11cf-bb82-00aa00bdce0b) @@ -7655,7 +7655,7 @@ coclass HTMLBody interface IHTMLTextContainer; interface IHTMLBodyElement; interface IHTMLBodyElement2; -}; +} /***************************************************************************** * IHTMLAnchorElement interface @@ -8970,6 +8970,92 @@ interface IHTMLTextAreaElement : IDispatch HRESULT createTextRange([retval, out] IHTMLTxtRange **range); } +/***************************************************************************** + * DispHTMLTextAreaElement dispinterface + */ +[ + hidden, + uuid(3050f521-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLTextAreaElement +{ +properties: +methods: + WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL; + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_TYPE)] + BSTR type(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_VALUE), displaybind, bindable] + void value(BSTR v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_VALUE), displaybind, bindable] + BSTR value(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_NAME), displaybind, bindable] + void name(BSTR v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_NAME), displaybind, bindable] + BSTR name(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_STATUS)] + void status(VARIANT v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_STATUS)] + VARIANT status(); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_FORM)] + IHTMLFormElement *form(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_DEFAULTVALUE), displaybind, bindable, hidden] + void defaultValue(BSTR v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_DEFAULTVALUE), displaybind, bindable, hidden] + BSTR defaultValue(); + + [id(DISPID_IHTMLTEXTAREAELEMENT_SELECT)] + void select(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_ONCHANGE), displaybind, bindable] + void onchange(VARIANT v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_ONCHANGE), displaybind, bindable] + VARIANT onchange(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_ONSELECT), displaybind, bindable] + void onselect(VARIANT v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_ONSELECT), displaybind, bindable] + VARIANT onselect(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_READONLY), displaybind, bindable] + void readOnly(VARIANT_BOOL v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_READONLY), displaybind, bindable] + VARIANT_BOOL readOnly(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_ROWS), displaybind, bindable] + void rows(LONG v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_ROWS), displaybind, bindable] + LONG rows(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_COLS), displaybind, bindable] + void cols(LONG v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_COLS), displaybind, bindable] + LONG cols(); + + [propput, id(DISPID_IHTMLTEXTAREAELEMENT_WRAP), displaybind, bindable] + void wrap(BSTR v); + + [propget, id(DISPID_IHTMLTEXTAREAELEMENT_WRAP), displaybind, bindable] + BSTR wrap(); + + [id(DISPID_IHTMLTEXTAREAELEMENT_CREATETEXTRANGE)] + IHTMLTxtRange *createTextRange(); +} + /***************************************************************************** * DispHTMLUnknownElement interface */ @@ -10245,7 +10331,7 @@ interface IHTMLWindow4 : IDispatch [propget, id(DISPID_IHTMLWINDOW4_FRAMEELEMENT)] HRESULT frameElement([retval, out] IHTMLFrameBase* * p); -}; +} /***************************************************************************** * IHTMLWindow5 interface @@ -10263,7 +10349,7 @@ interface IHTMLWindow5 : IDispatch [propget, id(DISPID_IHTMLWINDOW5_XMLHTTPREQUEST)] HRESULT XMLHttpRequest([retval, out] VARIANT * p); -}; +} /***************************************************************************** * DispHTMLScreen dispinterface @@ -10902,7 +10988,7 @@ methods: [propget, id(DISPID_IHTMLWINDOW5_XMLHTTPREQUEST)] VARIANT XMLHttpRequest(); -}; +} /***************************************************************************** * HTMLWindowEvents interface @@ -10949,7 +11035,7 @@ methods: [id(DISPID_HTMLWINDOWEVENTS_ONAFTERPRINT)] void onafterprint(); -}; +} /***************************************************************************** * HTMLWindowEvents2 interface @@ -10996,7 +11082,7 @@ methods: [id(DISPID_HTMLWINDOWEVENTS2_ONAFTERPRINT)] void onafterprint([in] IHTMLEventObj* pEvtObj); -}; +} /***************************************************************************** * HTMLWindowProxy class @@ -11013,7 +11099,7 @@ coclass HTMLWindowProxy interface IHTMLWindow3; interface IHTMLWindow4; interface IHTMLWindow5; -}; +} /***************************************************************************** * HTMLDocumentEvents2 interface @@ -11473,7 +11559,7 @@ methods: [id(DISPID_HTMLTEXTCONTAINEREVENTS_ONSELECT)] void onselect(); -}; +} /***************************************************************************** * HTMLTextContainerEvents2 interface @@ -11677,7 +11763,7 @@ methods: [id(DISPID_HTMLTEXTCONTAINEREVENTS2_ONSELECT)] void onselect([in] IHTMLEventObj* pEvtObj); -}; +} /***************************************************************************** * IHTMLDocument interface @@ -13329,7 +13415,8 @@ methods: [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEWHEEL)] VARIANT_BOOL onmousewheel([in] IHTMLEventObj* pEvtObj); -}; +} + [ hidden, uuid(3050f33c-98b5-11cf-bb82-00aa00bdce0b) @@ -13526,8 +13613,7 @@ methods: [id(DISPID_HTMLELEMENTEVENTS_ONFOCUSOUT)] void onfocusout(); - -}; +} [ noncreatable, @@ -13943,7 +14029,7 @@ methods: [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEWHEEL)] VARIANT_BOOL onmousewheel([in] IHTMLEventObj* pEvtObj); -}; +} /***************************************************************************** * IHTMLTableCaption interface @@ -14153,7 +14239,7 @@ interface IHTMLTable2 : IDispatch HRESULT moveRow([defaultvalue(-1), in] LONG indexFrom, [defaultvalue(-1), in] LONG indexTo, [retval, out] IDispatch** row); -}; +} [ odl, @@ -14168,7 +14254,7 @@ interface IHTMLTable3 : IDispatch [propget, id(DISPID_IHTMLTABLE3_SUMMARY), displaybind, bindable] HRESULT summary([retval, out] BSTR * p); -}; +} [ noncreatable, @@ -14191,7 +14277,7 @@ coclass HTMLTable interface IHTMLTable; interface IHTMLTable2; interface IHTMLTable3; -}; +} [ odl, @@ -14626,6 +14712,74 @@ interface IHTMLScriptElement2 : IDispatch HRESULT charset([retval, out] BSTR *p); } +/***************************************************************************** + * DispHTMLScriptElement dispinterface + */ +[ + hidden, + uuid(3050f530-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLScriptElement +{ +properties: +methods: + WINE_HTMLELEMENT_DISPINTERFACE_DECL; + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_SRC), displaybind, bindable] + void src(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_SRC), displaybind, bindable] + BSTR src(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_HTMLFOR), displaybind, bindable] + void htmlFor(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_HTMLFOR), displaybind, bindable] + BSTR htmlFor(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_EVENT), displaybind, bindable] + void event(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_EVENT), displaybind, bindable] + BSTR event(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_TEXT), displaybind, bindable] + void text(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_TEXT), displaybind, bindable] + BSTR text(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_DEFER), displaybind, bindable] + void defer(VARIANT_BOOL v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_DEFER), displaybind, bindable] + VARIANT_BOOL defer(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_ONERROR), displaybind, bindable] + void onerror(VARIANT v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_ONERROR), displaybind, bindable] + VARIANT onerror(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT_TYPE), displaybind, bindable] + void type(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT_TYPE), displaybind, bindable] + BSTR type(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT2_CHARSET), displaybind, bindable] + void charset(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT2_CHARSET), displaybind, bindable] + BSTR charset(); + + [propput, id(DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC)] + void ie8_src(BSTR v); + + [propget, id(DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC)] + BSTR ie8_src(); +} + /***************************************************************************** * IHTMLFrameBase interface */ @@ -14692,6 +14846,61 @@ interface IHTMLFrameBase : IDispatch HRESULT scrolling([out, retval] BSTR *p); } +#define WINE_IHTMLFRAMEBASE_DISPINTERFACE_DECL \ + [propput, id(DISPID_IHTMLFRAMEBASE_SRC)] \ + void src(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_SRC)] \ + BSTR src(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_NAME)] \ + void name(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_NAME)] \ + BSTR name(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_BORDER)] \ + void border(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_BORDER)] \ + VARIANT border(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)] \ + void frameBorder(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)] \ + BSTR frameBorder(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)] \ + void frameSpacing(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)] \ + VARIANT frameSpacing(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)] \ + void marginWidth(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)] \ + VARIANT marginWidth(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)] \ + void marginHeight(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)] \ + VARIANT marginHeight(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_NORESIZE)] \ + void noResize(VARIANT_BOOL v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_NORESIZE)] \ + VARIANT_BOOL noResize(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE_SCROLLING)] \ + void scrolling(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE_SCROLLING)] \ + BSTR scrolling() + /***************************************************************************** * IHTMLFrameBase2 interface */ @@ -14728,6 +14937,152 @@ interface IHTMLFrameBase2 : IDispatch HRESULT allowTransparency([retval, out] VARIANT_BOOL *p); } +#define WINE_IHTMLFRAMEBASE2_DISPINTERFACE_DECL \ + [propget, id(DISPID_IHTMLFRAMEBASE2_CONTENTWINDOW)] \ + IHTMLWindow2 *contentWindow(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] \ + void onload(VARIANT v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] \ + VARIANT onload(); \ + \ + [propput, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)] \ + void allowTransparency(VARIANT_BOOL v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)] \ + VARIANT_BOOL allowTransparency() + +#define WINE_IHTMLFRAMEBASE3_DISPINTERFACE_DECL \ + [propput, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] \ + void longDesc(BSTR v); \ + \ + [propget, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] \ + BSTR longDesc() + + +#define WINE_HTMLFRAMEBASE_DISPINTERFACE_DECL \ + WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL; \ + WINE_IHTMLFRAMEBASE_DISPINTERFACE_DECL; \ + WINE_IHTMLFRAMEBASE2_DISPINTERFACE_DECL; \ + WINE_IHTMLFRAMEBASE3_DISPINTERFACE_DECL + +/***************************************************************************** + * IHTMLFrameElement3 interface + */ +[ + odl, + oleautomation, + dual, + uuid(3051042d-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLFrameElement3 : IDispatch +{ + [propget, id(DISPID_IHTMLFRAMEELEMENT3_CONTENTDOCUMENT)] + HRESULT contentDocument([out, retval] IDispatch **p); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)] + HRESULT src([in] BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)] + HRESULT src([out, retval] BSTR *p); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)] + HRESULT longDesc([in] BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)] + HRESULT longDesc([out, retval] BSTR *p); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)] + HRESULT frameBorder([in] BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)] + HRESULT frameBorder([out, retval] BSTR * p); +} + +/***************************************************************************** + * DispHTMLFrameElement dispinterface + */ +[ + hidden, + uuid(3050f513-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface DispHTMLFrameElement +{ +properties: +methods: + WINE_HTMLFRAMEBASE_DISPINTERFACE_DECL; + + [propput, id(DISPID_IHTMLFRAMEELEMENT_BORDERCOLOR)] + void borderColor(VARIANT v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT_BORDERCOLOR)] + VARIANT borderColor(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT2_HEIGHT)] + void height(VARIANT v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT2_HEIGHT)] + VARIANT height(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT2_WIDTH)] + void width(VARIANT v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT2_WIDTH)] + VARIANT width(); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_CONTENTDOCUMENT)] + IDispatch *contentDocument(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)] + void ie8_src(BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)] + BSTR ie8_src(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)] + void ie8_longDesc(BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)] + BSTR ie8_longDesc(); + + [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)] + void ie8_frameBorder(BSTR v); + + [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)] + BSTR ie8_frameBorder(); +} + +/***************************************************************************** + * IHTMLIFrameElement interface + */ +[ + odl, + oleautomation, + dual, + uuid(3050f315-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLIFrameElement : IDispatch +{ + [propput, id(DISPID_IHTMLIFRAMEELEMENT_VSPACE)] + HRESULT vspace([in] LONG v); + + [propget, id(DISPID_IHTMLIFRAMEELEMENT_VSPACE)] + HRESULT vspace([retval, out] LONG *p); + + [propput, id(DISPID_IHTMLIFRAMEELEMENT_HSPACE)] + HRESULT hspace([in] LONG v); + + [propget, id(DISPID_IHTMLIFRAMEELEMENT_HSPACE)] + HRESULT hspace([retval, out] LONG *p); + + [propput, id(DISPID_IHTMLIFRAMEELEMENT_ALIGN), displaybind, bindable] + HRESULT align([in] BSTR v); + + [propget, id(DISPID_IHTMLIFRAMEELEMENT_ALIGN), displaybind, bindable] + HRESULT align([retval, out] BSTR *p); +} + /***************************************************************************** * DispHTMLIFrame dispinterface */ @@ -14739,82 +15094,7 @@ dispinterface DispHTMLIFrame { properties: methods: - WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL; - - [propput, id(DISPID_IHTMLFRAMEBASE_SRC)] - void src(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE_SRC)] - BSTR src(); - - [propput, id(DISPID_IHTMLFRAMEBASE_NAME)] - void name(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE_NAME)] - BSTR name(); - - [propput, id(DISPID_IHTMLFRAMEBASE_BORDER)] - void border(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE_BORDER)] - VARIANT border(); - - [propput, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)] - void frameBorder(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)] - BSTR frameBorder(); - - [propput, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)] - void frameSpacing(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)] - VARIANT frameSpacing(); - - [propput, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)] - void marginWidth(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)] - VARIANT marginWidth(); - - [propput, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)] - void marginHeight(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)] - VARIANT marginHeight(); - - [propput, id(DISPID_IHTMLFRAMEBASE_NORESIZE)] - void noResize(VARIANT_BOOL v); - - [propget, id(DISPID_IHTMLFRAMEBASE_NORESIZE)] - VARIANT_BOOL noResize(); - - [propput, id(DISPID_IHTMLFRAMEBASE_SCROLLING)] - void scrolling(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE_SCROLLING)] - BSTR scrolling(); - - [propget, id(DISPID_IHTMLFRAMEBASE2_CONTENTWINDOW)] - IHTMLWindow2 *contentWindow(); - - [propput, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] - void onload(VARIANT v); - - [propget, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] - VARIANT onload(); - - [propput, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)] - void allowTransparency(VARIANT_BOOL v); - - [propget, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)] - VARIANT_BOOL allowTransparency(); - - [propput, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] - void longDesc(BSTR v); - - [propget, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] - BSTR longDesc(); + WINE_HTMLFRAMEBASE_DISPINTERFACE_DECL; [propput, id(DISPID_IHTMLIFRAMEELEMENT_VSPACE)] void vspace(LONG v); @@ -15127,3 +15407,23 @@ interface IElementBehaviorFactory : IUnknown } } /* library MSHTML */ + +interface IOleCommandTarget; + +/***************************************************************************** + * IHTMLPrivateWindow interface + */ +[ + object, + uuid(3050f6dc-98b5-11cf-bb82-00aa00bdce0b), + local +] +interface IHTMLPrivateWindow : IUnknown +{ + HRESULT SuperNavigate(BSTR url, BSTR arg2, BSTR arg3, BSTR arg4, VARIANT *post_data, VARIANT *headers, ULONG flags); + HRESULT GetPendingUrl(BSTR *url); + HRESULT SetPICSTarget(IOleCommandTarget *cmdtrg); + HRESULT PICSComplete(int arg); + HRESULT FindWindowByName(LPCWSTR name, IHTMLWindow2 **ret); + HRESULT GetAddressBarUrl(BSTR *url); +} diff --git a/include/psdk/msi.h b/include/psdk/msi.h index 5c2f38cc824..b331057d53c 100644 --- a/include/psdk/msi.h +++ b/include/psdk/msi.h @@ -503,6 +503,10 @@ UINT WINAPI MsiGetPatchInfoExA(LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR UINT WINAPI MsiGetPatchInfoExW(LPCWSTR, LPCWSTR, LPCWSTR, MSIINSTALLCONTEXT, LPCWSTR, LPWSTR, LPDWORD); #define MsiGetPatchInfoEx WINELIB_NAME_AW(MsiGetPatchInfoEx) +UINT WINAPI MsiGetPatchInfoA(LPCSTR, LPCSTR, LPSTR, LPDWORD); +UINT WINAPI MsiGetPatchInfoW(LPCWSTR, LPCWSTR, LPWSTR, LPDWORD); +#define MsiGetPatchInfo WINELIB_NAME_AW(MsiGetPatchInfo) + UINT WINAPI MsiEnableLogA(DWORD, LPCSTR, DWORD); UINT WINAPI MsiEnableLogW(DWORD, LPCWSTR, DWORD); #define MsiEnableLog WINELIB_NAME_AW(MsiEnableLog) diff --git a/include/psdk/msidefs.h b/include/psdk/msidefs.h index d87569f61c6..a3b487c8573 100644 --- a/include/psdk/msidefs.h +++ b/include/psdk/msidefs.h @@ -222,6 +222,15 @@ enum msidbRemoveFileInstallMode msidbRemoveFileInstallModeOnBoth = 0x00000003, }; +enum +{ + msidbIniFileActionAddLine = 0x00000000, + msidbIniFileActionCreateLine = 0x00000001, + msidbIniFileActionRemoveLine = 0x00000002, + msidbIniFileActionAddTag = 0x00000003, + msidbIniFileActionRemoveTag = 0x00000004 +}; + /* * Windows SDK braindamage alert * diff --git a/include/psdk/msxml2.idl b/include/psdk/msxml2.idl index b6303c9f001..89914004955 100644 --- a/include/psdk/msxml2.idl +++ b/include/psdk/msxml2.idl @@ -1979,6 +1979,15 @@ coclass SAXXMLReader30 interface IMXReaderControl; }; +[ + uuid(7c6e29bc-8b8b-4c3d-859e-af6cd158be0f) +] +coclass SAXXMLReader40 +{ + [default] interface IVBSAXXMLReader; + interface ISAXXMLReader; +}; + [ uuid(fc220ad8-a72a-4ee8-926e-0b7ad152a020) ] diff --git a/include/psdk/objidl.idl b/include/psdk/objidl.idl index e54fb1c7446..70f93ab3179 100644 --- a/include/psdk/objidl.idl +++ b/include/psdk/objidl.idl @@ -907,7 +907,7 @@ interface IStorage : IUnknown [call_as(OpenStream)] HRESULT RemoteOpenStream( [in] LPCOLESTR pwcsName, - [in] ULONG cbReserved1, + [in] unsigned long cbReserved1, [in, unique, size_is(cbReserved1)] byte *reserved1, [in] DWORD grfMode, [in] DWORD reserved2, @@ -955,7 +955,7 @@ interface IStorage : IUnknown [call_as(EnumElements)] HRESULT RemoteEnumElements( [in] DWORD reserved1, - [in] ULONG cbReserved2, + [in] unsigned long cbReserved2, [in, unique, size_is(cbReserved2)] byte *reserved2, [in] DWORD reserved3, [out] IEnumSTATSTG **ppenum); @@ -1950,6 +1950,9 @@ interface IClientSecurity : IUnknown void *pAuthInfo; } SOLE_AUTHENTICATION_INFO; + const OLECHAR *COLE_DEFAULT_PRINCIPAL = (OLECHAR*) -1; + const void *COLE_DEFAULT_AUTHINFO = (void*) -1; + typedef struct tagSOLE_AUTHENTICATION_LIST { DWORD cAuthInfo; SOLE_AUTHENTICATION_INFO *aAuthInfo; diff --git a/include/psdk/oledb.idl b/include/psdk/oledb.idl index dd6b2181307..127df2b4906 100644 --- a/include/psdk/oledb.idl +++ b/include/psdk/oledb.idl @@ -15,14 +15,53 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +cpp_quote("#ifdef _WIN64") +cpp_quote("#include ") +cpp_quote("#else") +cpp_quote("#include ") +cpp_quote("#endif") +cpp_quote("") import "wtypes.idl"; import "oaidl.idl"; import "ocidl.idl"; import "propidl.idl"; +import "urlmon.idl"; typedef ULONG DBBYTEOFFSET; +typedef LONG DBROWOFFSET; +typedef LONG DBROWCOUNT; +typedef ULONG DBCOUNTITEM; +typedef ULONG DBLENGTH; +typedef ULONG DBORDINAL; +typedef ULONG DBBKMARK; +typedef DWORD DB_DWRESERVE; +typedef ULONG DBREFCOUNT; +typedef ULONG DB_UPARAMS; +typedef LONG DB_LPARAMS; +typedef DWORD DBHASHVALUE; -#include "dbinit.idl" #include "dbs.idl" + +#include "access.idl" +#include "rstbas.idl" +#include "rstinf.idl" +#include "rstloc.idl" +#include "cmdbas.idl" +#include "cmdtxt.idl" +#include "dbccmd.idl" +#include "dbcses.idl" #include "dbprop.idl" +#include "dbinit.idl" +#include "dbdsad.idl" +#include "asynot.idl" +#include "asysta.idl" +#include "sesprp.idl" +#include "opnrst.idl" +#include "row.idl" +#include "rowchg.idl" +#include "binres.idl" +#include "crtrow.idl" + +cpp_quote("#include ") +cpp_quote("") diff --git a/include/psdk/opnrst.idl b/include/psdk/opnrst.idl new file mode 100644 index 00000000000..e6b5237ee57 --- /dev/null +++ b/include/psdk/opnrst.idl @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a69-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IOpenRowset : IUnknown +{ + [local] + HRESULT OpenRowset([in] IUnknown *pUnkOuter, + [in, unique] DBID *pTableID, + [in, unique] DBID *pIndexID, + [in] REFIID riid, + [in] ULONG cPropertySets, + [in, out, size_is(cPropertySets)] DBPROPSET rgPropertySets[], + [out, iid_is(riid)] IUnknown **ppRowset); + + [call_as(OpenRowset)] + HRESULT RemoteOpenRowset([in] IUnknown *pUnkOuter, + [in, unique] DBID *pTableID, + [in, unique] DBID *pIndexID, + [in] REFIID riid, + [in] ULONG cPropertySets, + [in, unique, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [in, out, unique, iid_is(riid)] IUnknown **ppRowset, + [in] ULONG cTotalProps, + [out, size_is(cTotalProps)] DBPROPSTATUS *rgPropStatus, + [out] IErrorInfo **ppErrorInfoRem); + +} diff --git a/include/psdk/pdh.h b/include/psdk/pdh.h index d79241bf92e..7f3d3340b21 100644 --- a/include/psdk/pdh.h +++ b/include/psdk/pdh.h @@ -37,6 +37,10 @@ typedef HANDLE PDH_HQUERY; typedef HANDLE PDH_HCOUNTER; typedef HANDLE PDH_HLOG; +#define PDH_CVERSION_WIN40 0x0400 +#define PDH_CVERSION_WIN50 0x0500 +#define PDH_VERSION 0x0503 + #define PDH_MAX_SCALE 7 #define PDH_MIN_SCALE (-7) @@ -49,6 +53,10 @@ typedef HANDLE PDH_HLOG; #define PDH_FMT_1000 0x00002000 #define PDH_FMT_NOCAP100 0x00008000 +#define DATA_SOURCE_REGISTRY 0x00000001 +#define DATA_SOURCE_LOGFILE 0x00000002 +#define DATA_SOURCE_WBEM 0x00000004 + typedef struct _PDH_FMT_COUNTERVALUE { DWORD CStatus; @@ -182,6 +190,7 @@ PDH_STATUS WINAPI PdhGetCounterInfoA(PDH_HCOUNTER, BOOLEAN, LPDWORD, PPDH_COUNTE PDH_STATUS WINAPI PdhGetCounterInfoW(PDH_HCOUNTER, BOOLEAN, LPDWORD, PPDH_COUNTER_INFO_W); #define PdhGetCounterInfo WINELIB_NAME_AW(PdhGetCounterInfo) PDH_STATUS WINAPI PdhGetCounterTimeBase(PDH_HCOUNTER, LONGLONG *); +PDH_STATUS WINAPI PdhGetDllVersion(LPDWORD); PDH_STATUS WINAPI PdhGetFormattedCounterValue(PDH_HCOUNTER, DWORD, LPDWORD, PPDH_FMT_COUNTERVALUE); PDH_STATUS WINAPI PdhGetRawCounterValue(PDH_HCOUNTER, LPDWORD, PPDH_RAW_COUNTER); PDH_STATUS WINAPI PdhLookupPerfIndexByNameA(LPCSTR, LPCSTR, LPDWORD); @@ -198,6 +207,7 @@ PDH_STATUS WINAPI PdhOpenQueryW(LPCWSTR, DWORD_PTR, PDH_HQUERY *); #define PdhOpenQuery WINELIB_NAME_AW(PdhOpenQuery) PDH_STATUS WINAPI PdhRemoveCounter(PDH_HCOUNTER); PDH_STATUS WINAPI PdhSetCounterScaleFactor(PDH_HCOUNTER, LONG); +PDH_STATUS WINAPI PdhSetDefaultRealTimeDataSource(DWORD); PDH_STATUS WINAPI PdhValidatePathA(LPCSTR); PDH_STATUS WINAPI PdhValidatePathW(LPCWSTR); #define PdhValidatePath WINELIB_NAME_AW(PdhValidatePath) diff --git a/include/psdk/propidl.idl b/include/psdk/propidl.idl index be673943d9a..e2da625fb44 100644 --- a/include/psdk/propidl.idl +++ b/include/psdk/propidl.idl @@ -206,7 +206,17 @@ interface IPropertyStorage : IUnknown typedef struct tagPROPVARIANT *LPPROPVARIANT; - cpp_quote("#define REFPROPVARIANT const PROPVARIANT *") + cpp_quote("#if 0") + typedef const PROPVARIANT * REFPROPVARIANT; + cpp_quote("#endif") + cpp_quote("#ifndef _REFPROPVARIANT_DEFINED") + cpp_quote("#define _REFPROPVARIANT_DEFINED") + cpp_quote("#ifdef __cplusplus") + cpp_quote("#define REFPROPVARIANT const PROPVARIANT &") + cpp_quote("#else") + cpp_quote("#define REFPROPVARIANT const PROPVARIANT * __MIDL_CONST") + cpp_quote("#endif") + cpp_quote("#endif") cpp_quote("#define PIDDI_THUMBNAIL 0x00000002L /* VT_BLOB */") cpp_quote("") diff --git a/include/psdk/psdk.rbuild b/include/psdk/psdk.rbuild index 95981e1cde7..02256ebc338 100644 --- a/include/psdk/psdk.rbuild +++ b/include/psdk/psdk.rbuild @@ -10,6 +10,7 @@ bits.idl commoncontrols.idl control.idl + ctfutb.idl ctxtcall.idl dimm.idl dispex.idl @@ -51,6 +52,7 @@ shtypes.idl strmif.idl textstor.idl + tuner.idl tom.idl unknwn.idl urlhist.idl @@ -65,6 +67,7 @@ comcat.idl xmldso.idl xmldom.idl + xmllite.idl stdole2.idl diff --git a/include/psdk/pstore.idl b/include/psdk/pstore.idl index 62ce00b8da1..590b905df3d 100644 --- a/include/psdk/pstore.idl +++ b/include/psdk/pstore.idl @@ -34,6 +34,18 @@ typedef DWORD PST_KEY; typedef DWORD PST_PROVIDERCAPABILITIES; typedef GUID PST_PROVIDERID, *PPST_PROVIDERID; +/***************************************************************************** + * PSTOREC library + */ +[ + uuid(5a6f1ebd-2db1-11d0-8c39-00c04fd9126b), + version(1.0), + helpstring("PStore 1.0 Type Library") +] +library PSTORECLib +{ + importlib("stdole2.tlb"); + typedef struct _PST_PROVIDERINFO { DWORD cbSize; @@ -50,27 +62,27 @@ typedef struct _PST_PROMPTINFO LPCWSTR szPrompt; } PST_PROMPTINFO, *PPST_PROMPTINFO; -typedef struct { +typedef struct _PST_ACCESSCLAUSE { DWORD cbSize; PST_ACCESSCLAUSETYPE ClauseType; DWORD cbClauseData; BYTE* pbClauseData; } PST_ACCESSCLAUSE, *PPST_ACCESSCLAUSE; -typedef struct { +typedef struct _PST_ACCESSRULE { DWORD cbSize; PST_ACCESSMODE AccessModeFlags; DWORD cClauses; PST_ACCESSCLAUSE* rgClauses; } PST_ACCESSRULE, *PPST_ACCESSRULE; -typedef struct { +typedef struct _PST_ACCESSRULESET { DWORD cbSize; DWORD cClause; PST_ACCESSRULE* rgRules; } PST_ACCESSRULESET, *PPST_ACCESSRULESET; -typedef struct { +typedef struct _PST_TYPEINFO { DWORD cbSize; LPWSTR szDisplayName; } PST_TYPEINFO, *PPST_TYPEINFO; @@ -259,3 +271,5 @@ interface IPStore : IUnknown [in] DWORD dwFlags, [in] IEnumPStoreItems** ppenum ); } + +}; diff --git a/include/psdk/row.idl b/include/psdk/row.idl new file mode 100644 index 00000000000..59df27948a5 --- /dev/null +++ b/include/psdk/row.idl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + local, + object, + uuid(0c733ab4-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRow : IUnknown +{ + [local] + HRESULT GetColumns([in] DBORDINAL cColumns, + [in, out, size_is(cColumns), annotation("__inout_ecount(cColumns)")] DBCOLUMNACCESS rgColumns[]); + + + HRESULT GetSourceRowset([in, annotation("__in")] REFIID riid, + [out, iid_is(riid), annotation("__deref_opt_out_opt")] IUnknown **ppRowset, + [out, annotation("__out_opt")] HROW *phRow); + + HRESULT Open([in, unique, annotation("__in_opt")] IUnknown *pUnkOuter, + [in, annotation("__in")] DBID *pColumnID, + [in, annotation("__in")] REFGUID rguidColumnType, + [in] DWORD dwBindFlags, + [in, annotation("__in")] REFIID riid, + [out, iid_is(riid), annotation("__deref_opt_out")] IUnknown **ppUnk); +} diff --git a/include/psdk/rowchg.idl b/include/psdk/rowchg.idl new file mode 100644 index 00000000000..86c7ad49655 --- /dev/null +++ b/include/psdk/rowchg.idl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + local, + object, + uuid(0c733ab5-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRowChange : IUnknown +{ + [local] + HRESULT SetColumns([in] DBORDINAL cColumns, + [in, out, size_is(cColumns), annotation("__in_ecount(cColumns)")] DBCOLUMNACCESS rgColumns[]); +} diff --git a/include/psdk/rpcdce.h b/include/psdk/rpcdce.h index 9486a35f1f5..439f16483aa 100644 --- a/include/psdk/rpcdce.h +++ b/include/psdk/rpcdce.h @@ -108,6 +108,11 @@ typedef I_RPC_HANDLE *RPC_EP_INQ_HANDLE; #define RPC_C_LISTEN_MAX_CALLS_DEFAULT 1234 #define RPC_C_PROTSEQ_MAX_REQS_DEFAULT 10 +#define RPC_PROTSEQ_TCP 0x1 +#define RPC_PROTSEQ_NMP 0x2 +#define RPC_PROTSEQ_LRPC 0x3 +#define RPC_PROTSEQ_HTTP 0x4 + /* RPC_POLICY EndpointFlags */ #define RPC_C_BIND_TO_ALL_NICS 0x1 #define RPC_C_USE_INTERNET_PORT 0x1 @@ -158,8 +163,8 @@ typedef I_RPC_HANDLE *RPC_EP_INQ_HANDLE; #define RPC_C_IMP_LEVEL_DELEGATE 4 /* values for RPC_SECURITY_QOS*::IdentityTracking */ -#define RPC_C_QOS_IDENTIFY_STATIC 0 -#define RPC_C_QOS_IDENTIFY_DYNAMIC 1 +#define RPC_C_QOS_IDENTITY_STATIC 0 +#define RPC_C_QOS_IDENTITY_DYNAMIC 1 /* flags for RPC_SECURITY_QOS*::Capabilities */ #define RPC_C_QOS_CAPABILITIES_DEFAULT 0x0 @@ -190,7 +195,7 @@ typedef I_RPC_HANDLE *RPC_EP_INQ_HANDLE; #define RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE 0x10 typedef RPC_STATUS RPC_ENTRY RPC_IF_CALLBACK_FN( RPC_IF_HANDLE InterfaceUuid, void *Context ); -typedef void (__RPC_USER *RPC_AUTH_KEY_RETRIEVAL_FN)( void *Arg, unsigned char *ServerPrincName, unsigned long KeyVer, void **Key, RPC_STATUS *Status ); +typedef void (__RPC_USER *RPC_AUTH_KEY_RETRIEVAL_FN)(void *, RPC_WSTR, ULONG, void **, RPC_STATUS *); typedef struct _RPC_POLICY { @@ -504,6 +509,28 @@ RPCRTAPI RPC_STATUS RPC_ENTRY ULONG *AuthnSvc, RPC_AUTH_IDENTITY_HANDLE *AuthIdentity, ULONG *AuthzSvc ); #define RpcBindingInqAuthInfo WINELIB_NAME_AW(RpcBindingInqAuthInfo) +RPCRTAPI RPC_STATUS RPC_ENTRY + RpcBindingInqAuthClientA( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *Privs, + RPC_CSTR *ServerPrincName, ULONG *AuthnLevel, ULONG *AuthnSvc, + ULONG *AuthzSvc ); + +RPCRTAPI RPC_STATUS RPC_ENTRY + RpcBindingInqAuthClientW( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *Privs, + RPC_WSTR *ServerPrincName, ULONG *AuthnLevel, ULONG *AuthnSvc, + ULONG *AuthzSvc ); +#define RpcBindingInqAuthClient WINELIB_NAME_AW(RpcBindingInqAuthClient) + +RPCRTAPI RPC_STATUS RPC_ENTRY + RpcBindingInqAuthClientExA( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *Privs, + RPC_CSTR *ServerPrincName, ULONG *AuthnLevel, ULONG *AuthnSvc, + ULONG *AuthzSvc, ULONG Flags ); + +RPCRTAPI RPC_STATUS RPC_ENTRY + RpcBindingInqAuthClientExW( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *Privs, + RPC_WSTR *ServerPrincName, ULONG *AuthnLevel, ULONG *AuthnSvc, + ULONG *AuthzSvc, ULONG Flags ); +#define RpcBindingInqAuthClientEx WINELIB_NAME_AW(RpcBindingInqAuthClientEx) + RPCRTAPI RPC_STATUS RPC_ENTRY RpcCancelThread(void*); RPCRTAPI RPC_STATUS RPC_ENTRY RpcCancelThreadEx(void*,LONG); diff --git a/include/psdk/rpcndr.h b/include/psdk/rpcndr.h index 9d0df1ae2aa..9691dba9ecd 100644 --- a/include/psdk/rpcndr.h +++ b/include/psdk/rpcndr.h @@ -104,8 +104,8 @@ extern "C" { #define small char typedef unsigned char byte; -#define hyper __int64 -#define MIDL_uhyper unsigned __int64 +typedef INT64 hyper; +typedef UINT64 MIDL_uhyper; typedef unsigned char boolean; #define __RPC_CALLEE WINAPI @@ -128,7 +128,7 @@ typedef unsigned char boolean; (RpcExceptionCode() == RPC_X_BAD_STUB_DATA) || \ (RpcExceptionCode() == RPC_S_INVALID_BOUND)) -typedef struct _NDR_SCONTEXT +typedef struct { void *pad[2]; void *userContext; @@ -211,19 +211,19 @@ typedef struct _MIDL_STUB_MESSAGE struct _FULL_PTR_XLAT_TABLES *FullPtrXlatTables; ULONG FullPtrRefId; ULONG PointerLength; - int fInDontFree:1; - int fDontCallFreeInst:1; - int fInOnlyParam:1; - int fHasReturn:1; - int fHasExtensions:1; - int fHasNewCorrDesc:1; - int fIsIn:1; - int fIsOut:1; - int fIsOicf:1; - int fBufferValid:1; - int fHasMemoryValidateCallback:1; - int fInFree:1; - int fNeedMCCP:1; + unsigned int fInDontFree:1; + unsigned int fDontCallFreeInst:1; + unsigned int fInOnlyParam:1; + unsigned int fHasReturn:1; + unsigned int fHasExtensions:1; + unsigned int fHasNewCorrDesc:1; + unsigned int fIsIn:1; + unsigned int fIsOut:1; + unsigned int fIsOicf:1; + unsigned int fBufferValid:1; + unsigned int fHasMemoryValidateCallback:1; + unsigned int fInFree:1; + unsigned int fNeedMCCP:1; int fUnused:3; int fUnused2:16; DWORD dwDestContext; @@ -390,7 +390,11 @@ typedef struct _MIDL_SYNTAX_INFO typedef void (__RPC_API *STUB_THUNK)( PMIDL_STUB_MESSAGE ); +#ifdef WINE_STRICT_PROTOTYPES +typedef LONG (__RPC_API *SERVER_ROUTINE)(void); +#else typedef LONG (__RPC_API *SERVER_ROUTINE)(); +#endif typedef struct _MIDL_SERVER_INFO_ { diff --git a/include/psdk/rstbas.idl b/include/psdk/rstbas.idl new file mode 100644 index 00000000000..d7859ed5085 --- /dev/null +++ b/include/psdk/rstbas.idl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + local, + object, + uuid(0c733a7c-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRowset : IUnknown +{ + typedef DWORD DBROWOPTIONS; + + HRESULT AddRefRows([in] DBCOUNTITEM cRows, + [in, size_is(cRows)] const HROW rghRows[], + [out, size_is(cRows)] DBREFCOUNT rgRefCounts[], + [out, size_is(cRows)] DBROWSTATUS rgRowStatus[]); + + HRESULT GetData([in] HROW hRow, + [in] HACCESSOR hAccessor, + [out] void *pData); + + HRESULT GetNextRows([in] HCHAPTER hReserved, + [in] DBROWOFFSET lRowsOffset, + [in] DBROWCOUNT cRows, + [out] DBCOUNTITEM *pcRowObtained, + [out, size_is(,cRows)] HROW **prghRows); + + HRESULT ReleaseRows([in] DBCOUNTITEM cRows, + [in, size_is(cRows)] const HROW rghRows[], + [in, size_is(cRows)] DBROWOPTIONS rgRowOptions[], + [out, size_is(cRows)] DBREFCOUNT rgRefCounts[], + [out, size_is(cRows)] DBROWSTATUS rgRowStatus[]); + + HRESULT RestartPosition([in] HCHAPTER hReserved); +} diff --git a/include/psdk/rstinf.idl b/include/psdk/rstinf.idl new file mode 100644 index 00000000000..16d269377a0 --- /dev/null +++ b/include/psdk/rstinf.idl @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a55-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRowsetInfo : IUnknown +{ + [local] + HRESULT GetProperties([in] const ULONG cPropertyIDSets, + [in, size_is(cPropertyIDSets), annotation("__in_ecount_opt(cPropertyIDSets)")] const DBPROPIDSET rgPropertyIDSets[], + [in, out, annotation("__out")] ULONG *pcPropertySets, + [out, size_is(,*pcPropertySets), annotation("__deref_out_ecount_opt(*pcPropertySets)")] DBPROPSET **prgPropertySets); + + [call_as(GetProperties)] + HRESULT RemoteGetProperties([in] ULONG cPropertyIDSets, + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, + [in, out] ULONG *pcPropertySets, + [out, size_is(,*pcPropertySets)] DBPROPSET **prgPropertySets, + [out] IErrorInfo **ppErrorInfoRem); + + [local] + HRESULT GetReferencedRowset([in] DBORDINAL iOrdinal, + [in, annotation("__in")] REFIID riid, + [out, iid_is(riid), annotation("deref_out_opt")] IUnknown **ppReferencedRowset); + + [call_as(GetReferencedRowset)] + HRESULT RemoteGetReferencedRowset([in] DBORDINAL iOrdinal, + [in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppReferencedRowset, + [out] IErrorInfo **ppErrorInfoRem); + [local] + HRESULT GetSpecification([in, annotation("__in")] REFIID riid, + [out, iid_is(riid), annotation("__deref_out_opt")] IUnknown **ppSpecification); + + [call_as(GetSpecification)] + HRESULT RemoteGetSpecification([in] REFIID riid, + [out, iid_is(riid)] IUnknown **ppSpecification, + [out] IErrorInfo **ppErrorInfoRem); + +} diff --git a/include/psdk/rstloc.idl b/include/psdk/rstloc.idl new file mode 100644 index 00000000000..f579581c367 --- /dev/null +++ b/include/psdk/rstloc.idl @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + local, + object, + uuid(0c733a7d-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface IRowsetLocate : IRowset +{ + typedef DWORD DBCOMPARE; + + enum DBCOMPAREENUM + { + DBCOMPARE_LT, + DBCOMPARE_EQ, + DBCOMPARE_GT, + DBCOMPARE_NE, + DBCOMPARE_NOTCOMPARABLE + }; + + HRESULT Compare([in] HCHAPTER hReserved, + [in] DBBKMARK cbBookmark1, + [in, size_is(cbBookmark1)] const BYTE *pBookmark1, + [in] DBBKMARK cbBookmark2, + [in, size_is(cbBookmark2)] const BYTE *pBookmark2, + [out] DBCOMPARE *pComparison); + + HRESULT GetRowsAt([in] HWATCHREGION hReserved1, + [in] HCHAPTER hReserved2, + [in] DBBKMARK cbBookmark, + [in, size_is(cbBookmark)] const BYTE *pBookmark, + [in] DBROWOFFSET lRowsOffset, + [in] DBROWCOUNT cRows, + [out] DBCOUNTITEM *pcRowsObtained, + [out, size_is(,cRows)] HROW **prghRows); + + HRESULT GetRowsByBookmark([in] HCHAPTER hReserved, + [in] DBCOUNTITEM cRows, + [in, size_is(cRows)] const DBBKMARK rgcbBookmarks[], + [in, size_is(cRows)] const BYTE *rgpBookmarks[], + [out, size_is(cRows)] HROW rghRows[], + [out, size_is(cRows)] DBROWSTATUS rgRowStatus[]); + + HRESULT Hash([in] HCHAPTER hReserved, + [in] DBBKMARK cBookmarks, + [in, size_is(cBookmarks)] const DBBKMARK rgcbBookmarks[], + [in, size_is(cBookmarks)] const BYTE *rgpBookmarks[], + [out, size_is(cBookmarks)] DBHASHVALUE rgHashedValues[], + [out, size_is(cBookmarks)] DBROWSTATUS rgBookmarkStatus[]); +} diff --git a/include/psdk/sensevts.idl b/include/psdk/sensevts.idl index ec018a95c66..1ecb9f77f73 100644 --- a/include/psdk/sensevts.idl +++ b/include/psdk/sensevts.idl @@ -28,6 +28,7 @@ typedef struct SENS_QOCINFO [ object, + uuid(d597bab1-5b9f-11d1-8dd2-00aa004abd5e), pointer_default(unique) ] interface ISensNetwork : IDispatch @@ -55,6 +56,7 @@ interface ISensNetwork : IDispatch [ object, + uuid(d597bab2-5b9f-11d1-8dd2-00aa004abd5e), pointer_default(unique) ] interface ISensOnNow : IDispatch @@ -68,6 +70,7 @@ interface ISensOnNow : IDispatch [ object, + uuid(d597bab3-5b9f-11d1-8dd2-00aa004abd5e), pointer_default(unique) ] interface ISensLogon : IDispatch @@ -90,6 +93,7 @@ interface ISensLogon : IDispatch [ object, + uuid(d597bab4-5b9f-11d1-8dd2-00aa004abd5e), pointer_default(unique) ] interface ISensLogon2 : IDispatch diff --git a/include/psdk/sesprp.idl b/include/psdk/sesprp.idl new file mode 100644 index 00000000000..d621be18a3a --- /dev/null +++ b/include/psdk/sesprp.idl @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + object, + uuid(0c733a85-2a1c-11ce-ade5-00aa0044773d), + pointer_default(unique) +] +interface ISessionProperties : IUnknown +{ + [local] + HRESULT GetProperties([in] ULONG cPropertyIDSets, + [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], + [in, out] ULONG *pcPropertySets, + [out, size_is(,*pcPropertySets)] DBPROPSET **prgPropertySets); + + [call_as(GetProperties)] + HRESULT RemoteGetProperties([in] ULONG cPropertyIDSets, + [in, unique, size_is(cPropertyIDSets)] const DBPROPIDSET *rgPropertyIDSets, + [in, out] ULONG *pcPropertySets, + [out, size_is(,*pcPropertySets)] DBPROPSET **prgPropertySets, + [out] IErrorInfo **ppErrorInfoRem); + + + [local] + HRESULT SetProperties([in] ULONG cPropertySets, + [in, out, unique, size_is(cPropertySets)] DBPROPSET rgPropertySets[]); + + [call_as(SetProperties)] + HRESULT RemoteSetProperties([in] ULONG cPropertySets, + [in, unique, size_is(cPropertySets)] DBPROPSET *rgPropertySets, + [in] ULONG cTotalProps, + [out, size_is(cTotalProps)] DBPROPSTATUS *rgPropStatus, + [out] IErrorInfo **ppErrorInfoRem); + +} diff --git a/include/psdk/shlobj.h b/include/psdk/shlobj.h index 3f12542304f..3db28371e6b 100644 --- a/include/psdk/shlobj.h +++ b/include/psdk/shlobj.h @@ -78,9 +78,11 @@ DECLARE_HANDLE(HPSXA); #endif UINT WINAPI SHAddFromPropSheetExtArray(HPSXA,LPFNADDPROPSHEETPAGE,LPARAM); -LPVOID WINAPI SHAlloc(ULONG); +LPVOID WINAPI SHAlloc(ULONG) __WINE_ALLOC_SIZE(1); HRESULT WINAPI SHCoCreateInstance(LPCWSTR,const CLSID*,IUnknown*,REFIID,LPVOID*); HPSXA WINAPI SHCreatePropSheetExtArray(HKEY,LPCWSTR,UINT); +HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY,LPCWSTR,UINT,IDataObject*); +HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**); DWORD WINAPI SHCLSIDFromStringA(LPCSTR,CLSID*); DWORD WINAPI SHCLSIDFromStringW(LPCWSTR,CLSID*); #define SHCLSIDFromString WINELIB_NAME_AW(SHCLSIDFromString) @@ -100,6 +102,10 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST,LPWSTR); INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST); HRESULT WINAPI SHILCreateFromPath(LPCWSTR,LPITEMIDLIST*,DWORD*); HRESULT WINAPI SHLoadOLE(LPARAM); +HRESULT WINAPI SHParseDisplayName(LPCWSTR,IBindCtx*,LPITEMIDLIST*,SFGAOF,SFGAOF*); +HRESULT WINAPI SHPathPrepareForWriteA(HWND,IUnknown*,LPCSTR,DWORD); +HRESULT WINAPI SHPathPrepareForWriteW(HWND,IUnknown*,LPCWSTR,DWORD); +#define SHPathPrepareForWrite WINELIB_NAME_AW(SHPathPrepareForWrite); UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA,UINT,LPFNADDPROPSHEETPAGE,LPARAM); LPITEMIDLIST WINAPI SHSimpleIDListFromPath(LPCWSTR); int WINAPI SHMapPIDLToSystemImageListIndex(IShellFolder*,LPCITEMIDLIST,int*); @@ -110,16 +116,26 @@ INT WINAPI PickIconDlg(HWND,LPWSTR,UINT,int *); #define SHUpdateImage WINELIB_NAME_AW(SHUpdateImage) int WINAPI RestartDialog(HWND,LPCWSTR,DWORD); int WINAPI RestartDialogEx(HWND,LPCWSTR,DWORD,DWORD); +BOOL WINAPI IsUserAnAdmin(void); -#define SHFMT_ERROR 0xFFFFFFFFL /* Error on last format, drive may be formatable */ -#define SHFMT_CANCEL 0xFFFFFFFEL /* Last format was canceled */ -#define SHFMT_NOFORMAT 0xFFFFFFFDL /* Drive is not formatable */ +#define SHFMT_ERROR 0xFFFFFFFFL /* Error on last format, drive may be formattable */ +#define SHFMT_CANCEL 0xFFFFFFFEL /* Last format was cancelled */ +#define SHFMT_NOFORMAT 0xFFFFFFFDL /* Drive is not formattable */ /* SHFormatDrive flags */ #define SHFMT_ID_DEFAULT 0xFFFF #define SHFMT_OPT_FULL 1 #define SHFMT_OPT_SYSONLY 2 +/* SHPathPrepareForWrite flags */ +#define SHPPFW_NONE 0x00000000 +#define SHPPFW_DIRCREATE 0x00000001 +#define SHPPFW_DEFAULT SHPPFW_DIRCREATE +#define SHPPFW_ASKDIRCREATE 0x00000002 +#define SHPPFW_IGNOREFILENAME 0x00000004 +#define SHPPFW_NOWRITECHECK 0x00000008 +#define SHPPFW_MEDIACHECKONLY 0x00000010 + /* SHObjectProperties flags */ #define SHOP_PRINTERNAME 0x01 #define SHOP_FILEPATH 0x02 @@ -141,54 +157,168 @@ int WINAPI PathCleanupSpec(LPCWSTR,LPWSTR); /* DATAOBJECT_InitShellIDList*/ -#define CFSTR_SHELLIDLIST "Shell IDList Array" /* CF_IDLIST */ +#define CFSTR_SHELLIDLISTA "Shell IDList Array" /* CF_IDLIST */ +#define CFSTR_SHELLIDLISTOFFSETA "Shell Object Offsets" /* CF_OBJECTPOSITIONS */ +#define CFSTR_NETRESOURCESA "Net Resource" /* CF_NETRESOURCE */ +/* DATAOBJECT_InitFileGroupDesc */ +#define CFSTR_FILEDESCRIPTORA "FileGroupDescriptor" /* CF_FILEGROUPDESCRIPTORA */ +/* DATAOBJECT_InitFileContents*/ +#define CFSTR_FILECONTENTSA "FileContents" /* CF_FILECONTENTS */ +#define CFSTR_FILENAMEA "FileName" /* CF_FILENAMEA */ +#define CFSTR_FILENAMEMAPA "FileNameMap" /* CF_FILENAMEMAPA */ +#define CFSTR_PRINTERGROUPA "PrinterFriendlyName" /* CF_PRINTERS */ +#define CFSTR_SHELLURLA "UniformResourceLocator" +#define CFSTR_INETURLA CFSTR_SHELLURLA +#define CFSTR_PREFERREDDROPEFFECTA "Preferred DropEffect" +#define CFSTR_PERFORMEDDROPEFFECTA "Performed DropEffect" +#define CFSTR_PASTESUCCEEDEDA "Paste Succeeded" +#define CFSTR_INDRAGLOOPA "InShellDragLoop" +#define CFSTR_DRAGCONTEXTA "DragContext" +#define CFSTR_MOUNTEDVOLUMEA "MountedVolume" +#define CFSTR_PERSISTEDDATAOBJECTA "PersistedDataObject" +#define CFSTR_TARGETCLSIDA "TargetCLSID" +#define CFSTR_AUTOPLAY_SHELLIDLISTSA "Autoplay Enumerated IDList Array" +#define CFSTR_LOGICALPERFORMEDDROPEFFECTA "Logical Performed DropEffect" + +#if defined(__GNUC__) +# define CFSTR_SHELLIDLISTW \ + (const WCHAR []){ 'S','h','e','l','l',' ','I','D','L','i','s','t',' ','A','r','r','a','y',0 } +# define CFSTR_SHELLIDLISTOFFSETW \ + (const WCHAR []){ 'S','h','e','l','l',' ','O','b','j','e','c','t',' ','O','f','f','s','e','t','s',0 } +# define CFSTR_NETRESOURCESW \ + (const WCHAR []){ 'N','e','t',' ','R','e','s','o','u','r','c','e',0 } +# define CFSTR_FILEDESCRIPTORW \ + (const WCHAR []){ 'F','i','l','e','G','r','o','u','p','D','e','s','c','r','i','p','t','o','r','W',0 } +# define CFSTR_FILECONTENTSW \ + (const WCHAR []){ 'F','i','l','e','C','o','n','t','e','n','t','s',0 } +# define CFSTR_FILENAMEW \ + (const WCHAR []){ 'F','i','l','e','N','a','m','e','W',0 } +# define CFSTR_FILENAMEMAPW \ + (const WCHAR []){ 'F','i','l','e','N','a','m','e','M','a','p','W',0 } +# define CFSTR_PRINTERGROUPW \ + (const WCHAR []){ 'P','r','i','n','t','e','r','F','r','i','e','n','d','l','y','N','a','m','e',0 } +# define CFSTR_SHELLURLW \ + (const WCHAR []){ 'U','n','i','f','o','r','m','R','e','s','o','u','r','c','e','L','o','c','a','t','o','r',0 } +# define CFSTR_INETURLW \ + (const WCHAR []){ 'U','n','i','f','o','r','m','R','e','s','o','u','r','c','e','L','o','c','a','t','o','r','W',0 } +# define CFSTR_PREFERREDDROPEFFECTW \ + (const WCHAR []){ 'P','r','e','f','e','r','r','e','d',' ','D','r','o','p','E','f','f','e','c','t',0 } +# define CFSTR_PERFORMEDDROPEFFECTW \ + (const WCHAR []){ 'P','e','r','f','o','r','m','e','d',' ','D','r','o','p','E','f','f','e','c','t',0 } +# define CFSTR_PASTESUCCEEDEDW \ + (const WCHAR []){ 'P','a','s','t','e',' ','S','u','c','c','e','e','d','e','d',0 } +# define CFSTR_INDRAGLOOPW \ + (const WCHAR []){ 'I','n','S','h','e','l','l','D','r','a','g','L','o','o','p',0 } +# define CFSTR_DRAGCONTEXTW \ + (const WCHAR []){ 'D','r','a','g','C','o','n','t','e','x','t',0 } +# define CFSTR_MOUNTEDVOLUMEW \ + (const WCHAR []){ 'M','o','u','n','t','e','d','V','o','l','u','m','e',0 } +# define CFSTR_PERSISTEDDATAOBJECTW \ + (const WCHAR []){ 'P','e','r','s','i','s','t','e','d','D','a','t','a','O','b','j','e','c','t',0 } +# define CFSTR_TARGETCLSIDW \ + (const WCHAR []){ 'T','a','r','g','e','t','C','L','S','I','D',0 } +# define CFSTR_AUTOPLAY_SHELLIDLISTSW \ + (const WCHAR []){ 'A','u','t','o','p','l','a','y',' ','E','n','u','m','e','r','a','t','e','d',\ + ' ','I','D','L','i','s','t',' ','A','r','r','a','y',0 } +# define CFSTR_LOGICALPERFORMEDDROPEFFECTW \ + (const WCHAR []){ 'L','o','g','i','c','a','l',' ','P','e','r','f','o','r','m','e','d',\ + ' ','D','r','o','p','E','f','f','e','c','t',0 } +#elif defined(_MSC_VER) +# define CFSTR_SHELLIDLISTW L"Shell IDList Array" +# define CFSTR_SHELLIDLISTOFFSETW L"Shell Object Offsets" +# define CFSTR_NETRESOURCESW L"Net Resource" +# define CFSTR_FILEDESCRIPTORW L"FileGroupDescriptorW" +# define CFSTR_FILECONTENTSW L"FileContents" +# define CFSTR_FILENAMEW L"FileNameW" +# define CFSTR_FILENAMEMAPW L"FileNameMapW" +# define CFSTR_PRINTERGROUPW L"PrinterFriendlyName" +# define CFSTR_SHELLURLW L"UniformResourceLocator" +# define CFSTR_INETURLW L"UniformResourceLocatorW" +# define CFSTR_PREFERREDDROPEFFECTW L"Preferred DropEffect" +# define CFSTR_PERFORMEDDROPEFFECTW L"Performed DropEffect" +# define CFSTR_PASTESUCCEEDEDW L"Paste Succeeded" +# define CFSTR_INDRAGLOOPW L"InShellDragLoop" +# define CFSTR_DRAGCONTEXTW L"DragContext" +# define CFSTR_MOUNTEDVOLUMEW L"MountedVolume" +# define CFSTR_PERSISTEDDATAOBJECTW L"PersistedDataObject" +# define CFSTR_TARGETCLSIDW L"TargetCLSID" +# define CFSTR_AUTOPLAY_SHELLIDLISTSW L"Autoplay Enumerated IDList Array" +# define CFSTR_LOGICALPERFORMEDDROPEFFECTW L"Logical Performed DropEffect" +#else +static const WCHAR CFSTR_SHELLIDLISTW[] = + { 'S','h','e','l','l',' ','I','D','L','i','s','t',' ','A','r','r','a','y',0 }; +static const WCHAR CFSTR_SHELLIDLISTOFFSETW[] = + { 'S','h','e','l','l',' ','O','b','j','e','c','t',' ','O','f','f','s','e','t','s',0 }; +static const WCHAR CFSTR_NETRESOURCESW[] = + { 'N','e','t',' ','R','e','s','o','u','r','c','e',0 }; +static const WCHAR CFSTR_FILEDESCRIPTORW[] = + { 'F','i','l','e','G','r','o','u','p','D','e','s','c','r','i','p','t','o','r','W',0 }; +static const WCHAR CFSTR_FILECONTENTSW[] = + { 'F','i','l','e','C','o','n','t','e','n','t','s',0 }; +static const WCHAR CFSTR_FILENAMEW[] = + { 'F','i','l','e','N','a','m','e','W',0 }; +static const WCHAR CFSTR_FILENAMEMAPW[] = + { 'F','i','l','e','N','a','m','e','M','a','p','W',0 }; +static const WCHAR CFSTR_PRINTERGROUPW[] = + { 'P','r','i','n','t','e','r','F','r','i','e','n','d','l','y','N','a','m','e',0 }; +static const WCHAR CFSTR_SHELLURLW[] = + { 'U','n','i','f','o','r','m','R','e','s','o','u','r','c','e','L','o','c','a','t','o','r',0 }; +static const WCHAR CFSTR_INETURLW[] = + { 'U','n','i','f','o','r','m','R','e','s','o','u','r','c','e','L','o','c','a','t','o','r','W',0 }; +static const WCHAR CFSTR_PREFERREDDROPEFFECTW[] = + { 'P','r','e','f','e','r','r','e','d',' ','D','r','o','p','E','f','f','e','c','t',0 }; +static const WCHAR CFSTR_PERFORMEDDROPEFFECTW[] = + { 'P','e','r','f','o','r','m','e','d',' ','D','r','o','p','E','f','f','e','c','t',0 }; +static const WCHAR CFSTR_PASTESUCCEEDEDW[] = + { 'P','a','s','t','e',' ','S','u','c','c','e','e','d','e','d',0 }; +static const WCHAR CFSTR_INDRAGLOOPW[] = + { 'I','n','S','h','e','l','l','D','r','a','g','L','o','o','p',0 }; +static const WCHAR CFSTR_DRAGCONTEXTW[] = + { 'D','r','a','g','C','o','n','t','e','x','t',0 }; +static const WCHAR CFSTR_MOUNTEDVOLUMEW[] = + { 'M','o','u','n','t','e','d','V','o','l','u','m','e',0 }; +static const WCHAR CFSTR_PERSISTEDDATAOBJECTW[] = + { 'P','e','r','s','i','s','t','e','d','D','a','t','a','O','b','j','e','c','t',0 }; +static const WCHAR CFSTR_TARGETCLSIDW[] = + { 'T','a','r','g','e','t','C','L','S','I','D',0 }; +static const WCHAR CFSTR_AUTOPLAY_SHELLIDLISTSW[] = + { 'A','u','t','o','p','l','a','y',' ','E','n','u','m','e','r','a','t','e','d', + ' ','I','D','L','i','s','t',' ','A','r','r','a','y',0 }; +static const WCHAR CFSTR_LOGICALPERFORMEDDROPEFFECTW[] = + { 'L','o','g','i','c','a','l',' ','P','e','r','f','o','r','m','e','d', + ' ','D','r','o','p','E','f','f','e','c','t',0 }; +#endif + +#define CFSTR_SHELLIDLIST WINELIB_NAME_AW(CFSTR_SHELLIDLIST) +#define CFSTR_SHELLIDLISTOFFSET WINELIB_NAME_AW(CFSTR_SHELLIDLISTOFFSET) +#define CFSTR_NETRESOURCES WINELIB_NAME_AW(CFSTR_NETRESOURCES) +#define CFSTR_FILEDESCRIPTOR WINELIB_NAME_AW(CFSTR_FILEDESCRIPTOR) +#define CFSTR_FILECONTENTS WINELIB_NAME_AW(CFSTR_FILECONTENTS) +#define CFSTR_FILENAME WINELIB_NAME_AW(CFSTR_FILENAME) +#define CFSTR_FILENAMEMAP WINELIB_NAME_AW(CFSTR_FILENAMEMAP) +#define CFSTR_PRINTERGROUP WINELIB_NAME_AW(CFSTR_PRINTERGROUP) +#define CFSTR_SHELLURL WINELIB_NAME_AW(CFSTR_SHELLURL) +#define CFSTR_INETURL WINELIB_NAME_AW(CFSTR_INETURL) +#define CFSTR_PREFERREDDROPEFFECT WINELIB_NAME_AW(CFSTR_PREFERREDDROPEFFECT) +#define CFSTR_PERFORMEDDROPEFFECT WINELIB_NAME_AW(CFSTR_PERFORMEDDROPEFFECT) +#define CFSTR_PASTESUCCEEDED WINELIB_NAME_AW(CFSTR_PASTESUCCEEDED) +#define CFSTR_INDRAGLOOP WINELIB_NAME_AW(CFSTR_INDRAGLOOP) +#define CFSTR_DRAGCONTEXT WINELIB_NAME_AW(CFSTR_DRAGCONTEXT) +#define CFSTR_MOUNTEDVOLUME WINELIB_NAME_AW(CFSTR_MOUNTEDVOLUME) +#define CFSTR_PERSISTEDDATAOBJECT WINELIB_NAME_AW(CFSTR_PERSISTEDDATAOBJECT) +#define CFSTR_TARGETCLSID WINELIB_NAME_AW(CFSTR_TARGETCLSID) +#define CFSTR_AUTOPLAY_SHELLIDLISTS WINELIB_NAME_AW(CFSTR_AUTOPLAY_SHELLIDLISTS) +#define CFSTR_LOGICALPERFORMEDDROPEFFECT WINELIB_NAME_AW(CFSTR_LOGICALPERFORMEDDROPEFFECT) typedef struct { UINT cidl; UINT aoffset[1]; } CIDA, *LPIDA; -#define CFSTR_SHELLIDLISTA "Shell IDList Array" /* CF_IDLIST */ -#define CFSTR_SHELLIDLISTOFFSET "Shell Object Offsets" /* CF_OBJECTPOSITIONS */ -#define CFSTR_NETRESOURCES "Net Resource" /* CF_NETRESOURCE */ - -/* DATAOBJECT_InitFileGroupDesc */ -#define CFSTR_FILEDESCRIPTORA "FileGroupDescriptor" /* CF_FILEGROUPDESCRIPTORA */ - -#define CFSTR_FILEDESCRIPTORW "FileGroupDescriptorW" /* CF_FILEGROUPDESCRIPTORW */ - -/* DATAOBJECT_InitFileContents*/ -#define CFSTR_FILECONTENTS "FileContents" /* CF_FILECONTENTS */ - -#ifdef UNICODE -#define CFSTR_FILENAME L"FileNameW" -#define CFSTR_FILENAMEMAP L"FileNameMapW" -#define CFSTR_FILEDESCRIPTOR L"FileGroupDescriptorW" -#define CFSTR_SHELLURL L"UniformResourceLocatorW" -#else -#define CFSTR_FILENAME "FileName" -#define CFSTR_FILENAMEMAP "FileNameMap" -#define CFSTR_FILEDESCRIPTOR "FileGroupDescriptor" -#define CFSTR_SHELLURL "UniformResourceLocator" -#endif - -#define CFSTR_FILENAMEW "FileNameW" -#define CFSTR_FILENAMEA "FileName" -#define CFSTR_FILENAMEMAPA "FileNameMap" /* CF_FILENAMEMAPA */ -#define CFSTR_FILENAMEMAPW "FileNameMapW" /* CF_FILENAMEMAPW */ - -#define CFSTR_PRINTERGROUP "PrinterFriendlyName" /* CF_PRINTERS */ -#define CFSTR_PREFERREDDROPEFFECT "Preferred DropEffect" -#define CFSTR_PERFORMEDDROPEFFECT "Performed DropEffect" -#define CFSTR_PASTESUCCEEDED "Paste Succeeded" -#define CFSTR_INDRAGLOOP "InShellDragLoop" - /************************************************************************ * IShellView interface */ -#define SV_CLASS_NAME ("SHELLDLL_DefView") - #define FCIDM_SHVIEWFIRST 0x0000 /* undocumented */ #define FCIDM_SHVIEW_ARRANGE 0x7001 @@ -252,24 +382,10 @@ typedef struct #define FCIDM_STATUS (FCIDM_BROWSERFIRST + 1) -VOID WINAPI SHSetInstanceExplorer(LPUNKNOWN); -BOOL WINAPI IsUserAnAdmin(VOID); - /**************************************************************************** * IShellIcon interface */ -#undef INTERFACE -#define INTERFACE IShellFolderViewCB -DECLARE_INTERFACE_(IShellFolderViewCB, IUnknown) -{ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - STDMETHOD(MessageSFVCB)(THIS_ UINT uMsg, WPARAM wParam, LPARAM lParam) PURE; -}; -#undef INTERFACE - #define INTERFACE IShellIcon DECLARE_INTERFACE_(IShellIcon,IUnknown) { @@ -411,6 +527,57 @@ DECLARE_INTERFACE_(IACList,IUnknown) #define IACList_Expand(p,a) (p)->lpVtbl->Expand(p,a) #endif +/* IACList2 interface */ +#define INTERFACE IACList2 +DECLARE_INTERFACE_(IACList2,IACList) +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IACList methods ***/ + STDMETHOD(Expand)(THIS_ LPCOLESTR str) PURE; + /*** IACList2 methods ***/ + STDMETHOD(SetOptions)(THIS_ DWORD dwFlag) PURE; + STDMETHOD(GetOptions)(THIS_ DWORD* pdwFlag) PURE; +}; +#undef INTERFACE + +#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define IACList2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IACList2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IACList2_Release(p) (p)->lpVtbl->Release(p) +/*** IACList2 methods ***/ +#define IACList2_GetOptions(p,a) (p)->lpVtbl->GetOptions(p,a) +#define IACList2_SetOptions(p,a) (p)->lpVtbl->SetOptions(p,a) +#endif + +/**************************************************************************** + * IShellFolderViewCB interface + */ + +#define INTERFACE IShellFolderViewCB +DECLARE_INTERFACE_(IShellFolderViewCB,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + /*** IShellFolderViewCB methods ***/ + STDMETHOD(MessageSFVCB)(THIS_ UINT uMsg, WPARAM wParam, LPARAM lParam) PURE; +}; +#undef INTERFACE + +#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define IShellFolderViewCB_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IShellFolderViewCB_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IShellFolderViewCB_Release(p) (p)->lpVtbl->Release(p) +/*** IShellFolderViewCB methods ***/ +#define IShellFolderViewCB_MessageSFVCB(p,a,b,c) (p)->lpVtbl->MessageSFVCB(p,a,b,c) +#endif + /* IProgressDialog interface */ #define PROGDLG_NORMAL 0x00000000 #define PROGDLG_MODAL 0x00000001 @@ -502,15 +669,6 @@ DECLARE_INTERFACE_(IDeskBarClient,IOleWindow) void WINAPI SHAddToRecentDocs(UINT,LPCVOID); -HANDLE WINAPI SHChangeNotification_Lock( - HANDLE hChange, - DWORD dwProcessId, - LPITEMIDLIST **lppidls, - LPLONG lpwEventId); -BOOL WINAPI SHChangeNotification_Unlock ( HANDLE hLock); - - - /**************************************************************************** * SHBrowseForFolder API */ @@ -567,8 +725,9 @@ typedef struct tagBROWSEINFOW { /* message from browser */ #define BFFM_INITIALIZED 1 #define BFFM_SELCHANGED 2 -#define BFFM_VALIDATEFAILEDA 3 /* lParam:szPath ret:1(cont),0(EndDialog) */ -#define BFFM_VALIDATEFAILEDW 4 /* lParam:wzPath ret:1(cont),0(EndDialog) */ +#define BFFM_VALIDATEFAILEDA 3 +#define BFFM_VALIDATEFAILEDW 4 +#define BFFM_IUNKNOWN 5 /* messages to browser */ #define BFFM_SETSTATUSTEXTA (WM_USER+100) @@ -669,15 +828,6 @@ HRESULT WINAPI SHCreateShellFolderViewEx(LPCSFV pshfvi, IShellView **ppshv); #define SFVM_GET_WEBVIEW_THEME 86 /* undocumented */ #define SFVM_GETDEFERREDVIEWSETTINGS 92 /* undocumented */ -#define SHPPFW_NONE 0 -#define SHPPFW_DIRCREATE 1 -#define SHPPFW_DEFAULT SHPPFW_DIRCREATE -#define SHPPFW_ASKDIRCREATE 2 -#define SHPPFW_IGNOREFILENAME 4 -#define SHPPFW_NOWRITECHECK 8 - -/* Types and definitions for the SFM_* parameters */ -#include typedef struct _SFV_CREATE { UINT cbSize; @@ -686,6 +836,10 @@ typedef struct _SFV_CREATE IShellFolderViewCB *psfvcb; } SFV_CREATE; +HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pscfv, IShellView **ppsv); + +/* Types and definitions for the SFM_* parameters */ +#include #define QCMINFO_PLACE_BEFORE 0 #define QCMINFO_PLACE_AFTER 1 @@ -801,19 +955,13 @@ HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID pv, int cb); #define SHGetDataFromIDList WINELIB_NAME_AW(SHGetDataFromIDList) -PIDLIST_ABSOLUTE WINAPI SHCloneSpecialIDList(HWND hwnd, int csidl, BOOL fCreate); +LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwnd, int csidl, BOOL fCreate); BOOL WINAPI SHGetSpecialFolderPathA (HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate); BOOL WINAPI SHGetSpecialFolderPathW (HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate); #define SHGetSpecialFolderPath WINELIB_NAME_AW(SHGetSpecialFolderPath) HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal) ; -/********************************************************************** - * SHCreateShellFolderView () - */ - -HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, IShellView **ppsv); - /********************************************************************** * SHGetSetSettings () */ @@ -1147,6 +1295,10 @@ typedef enum { SLDF_NO_PIDL_ALIAS = 0x00008000, SLDF_FORCE_UNCNAME = 0x00010000, SLDF_RUN_WITH_SHIMLAYER = 0x00020000, + SLDF_FORCE_NO_LINKTRACK = 0x00040000, + SLDF_ENABLE_TARGET_METADATA = 0x00080000, + SLDF_DISABLE_KNOWNFOLDER_RELATIVE_TRACKING = 0x00200000, + SLDF_VALID = 0x003ff7ff, SLDF_RESERVED = 0x80000000, } SHELL_LINK_DATA_FLAGS; @@ -1158,41 +1310,6 @@ typedef struct tagDATABLOCKHEADER typedef struct { DATABLOCK_HEADER dbh; - WORD wFillAttribute; - WORD wPopupFillAttribute; - COORD dwScreenBufferSize; - COORD dwWindowSize; - COORD dwWindowOrigin; - DWORD nFont; - DWORD nInputBufferSize; - COORD dwFontSize; - UINT uFontFamily; - UINT uFontWeight; - WCHAR FaceName[LF_FACESIZE]; - UINT uCursorSize; - BOOL bFullScreen; - BOOL bQuickEdit; - BOOL bInsertMode; - BOOL bAutoPosition; - UINT uHistoryBufferSize; - UINT uNumberOfHistoryBuffers; - BOOL bHistoryNoDup; - COLORREF ColorTable[16]; -} NT_CONSOLE_PROPS, *LPNT_CONSOLE_PROPS; - -typedef struct { - DATABLOCK_HEADER dbh; - UINT uCodePage; -} NT_FE_CONSOLE_PROPS, *LPNT_FE_CONSOLE_PROPS; - -typedef struct { - -#ifdef __cplusplus - DATABLOCK_HEADER dbh; -#else - DWORD cbSize; - DWORD dwSignature; -#endif CHAR szDarwinID[MAX_PATH]; WCHAR szwDarwinID[MAX_PATH]; } EXP_DARWIN_LINK, *LPEXP_DARWIN_LINK; @@ -1211,13 +1328,20 @@ typedef struct { DWORD cbOffset; } EXP_SPECIAL_FOLDER, *LPEXP_SPECIAL_FOLDER; +typedef struct { + DWORD cbSize; + DWORD dwSignature; + BYTE abPropertyStorage[1]; +} EXP_PROPERTYSTORAGE; + #define EXP_SZ_LINK_SIG 0xa0000001 #define NT_CONSOLE_PROPS_SIG 0xa0000002 #define NT_FE_CONSOLE_PROPS_SIG 0xa0000004 #define EXP_SPECIAL_FOLDER_SIG 0xa0000005 #define EXP_DARWIN_ID_SIG 0xa0000006 -#define EXP_LOGO3_ID_SIG 0xa0000007 #define EXP_SZ_ICON_SIG 0xa0000007 +#define EXP_LOGO3_ID_SIG EXP_SZ_ICON_SIG /* Old SDKs only */ +#define EXP_PROPERTYSTORAGE_SIG 0xa0000009 typedef struct _SHChangeDWORDAsIDList { USHORT cb; @@ -1235,6 +1359,8 @@ typedef struct _SHChangeProductKeyAsIDList { ULONG WINAPI SHChangeNotifyRegister(HWND hwnd, int fSources, LONG fEvents, UINT wMsg, int cEntries, const SHChangeNotifyEntry *pshcne); BOOL WINAPI SHChangeNotifyDeregister(ULONG ulID); +HANDLE WINAPI SHChangeNotification_Lock(HANDLE hChangeNotification, DWORD dwProcessId, + LPITEMIDLIST **pppidl, LONG *plEvent); BOOL WINAPI SHChangeNotification_Unlock(HANDLE hLock); HRESULT WINAPI SHGetRealIDL(IShellFolder *psf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST * ppidlReal); @@ -1245,6 +1371,7 @@ HRESULT WINAPI SHGetRealIDL(IShellFolder *psf, LPCITEMIDLIST pidlSimple, LPITEMI DWORD WINAPI SHCreateDirectory(HWND, LPCWSTR); int WINAPI SHCreateDirectoryExA(HWND, LPCSTR, LPSECURITY_ATTRIBUTES); int WINAPI SHCreateDirectoryExW(HWND, LPCWSTR, LPSECURITY_ATTRIBUTES); +#define SHCreateDirectoryEx WINELIB_NAME_AW(SHCreateDirectoryEx) /**************************************************************************** * SHGetSpecialFolderLocation API @@ -1276,7 +1403,7 @@ HRESULT WINAPI SHGetFolderPathW(HWND hwnd, int nFolder, HANDLE hToken, DWORD dwF #define CSIDL_SENDTO 0x0009 #define CSIDL_BITBUCKET 0x000a #define CSIDL_STARTMENU 0x000b -#define CSIDL_MYDOCUMENTS 0x000c +#define CSIDL_MYDOCUMENTS CSIDL_PERSONAL #define CSIDL_MYMUSIC 0x000d #define CSIDL_MYVIDEO 0x000e #define CSIDL_DESKTOPDIRECTORY 0x0010 @@ -1322,6 +1449,7 @@ HRESULT WINAPI SHGetFolderPathW(HWND hwnd, int nFolder, HANDLE hToken, DWORD dwF #define CSIDL_CDBURN_AREA 0x003b #define CSIDL_COMPUTERSNEARME 0x003d #define CSIDL_PROFILES 0x003e +#define CSIDL_FOLDER_MASK 0x00ff #define CSIDL_FLAG_PER_USER_INIT 0x0800 #define CSIDL_FLAG_NO_ALIAS 0x1000 #define CSIDL_FLAG_DONT_VERIFY 0x4000 @@ -1438,8 +1566,26 @@ BOOL WINAPI WriteCabinetState(CABINETSTATE *); /**************************************************************************** * Path Manipulation Routines */ + +/* PathProcessCommand flags */ +#define PPCF_ADDQUOTES 0x01 +#define PPCF_INCLUDEARGS 0x02 +#define PPCF_ADDARGUMENTS 0x03 +#define PPCF_NODIRECTORIES 0x10 +#define PPCF_DONTRESOLVE 0x20 +#define PPCF_FORCEQUALIFY 0x40 +#define PPCF_LONGESTPOSSIBLE 0x80 + +/* PathResolve flags */ +#define PRF_VERIFYEXISTS 0x01 +#define PRF_EXECUTABLE 0x02 +#define PRF_TRYPROGRAMEXTENSIONS 0x03 +#define PRF_FIRSTDIRDEF 0x04 +#define PRF_DONTFINDLINK 0x08 + VOID WINAPI PathGetShortPath(LPWSTR pszPath); LONG WINAPI PathProcessCommand(LPCWSTR, LPWSTR, int, DWORD); +BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR, LPCWSTR, LPCWSTR, LPCWSTR); /**************************************************************************** * Drag And Drop Routines @@ -1515,7 +1661,6 @@ HRESULT WINAPI SHCreateDefaultContextMenu(const DEFCONTEXTMENU *,REFIID,void **p typedef HRESULT (CALLBACK * LPFNDFMCALLBACK)(IShellFolder*,HWND,IDataObject*,UINT,WPARAM,LPARAM); HRESULT WINAPI CDefFolderMenu_Create2(LPCITEMIDLIST,HWND,UINT,LPCITEMIDLIST*,IShellFolder*,LPFNDFMCALLBACK,UINT,const HKEY *,IContextMenu **); - /**************************************************************************** * SHCreateDefaultContextMenu API */ @@ -1524,7 +1669,6 @@ HRESULT WINAPI SHCreateDefaultExtractIcon( REFIID riid, void **ppv); - /**************************************************************************** * SHCreateDataObject API */ diff --git a/include/psdk/shlwapi.h b/include/psdk/shlwapi.h index df1e1aa1306..29e70b76d8c 100644 --- a/include/psdk/shlwapi.h +++ b/include/psdk/shlwapi.h @@ -85,6 +85,34 @@ DWORD WINAPI SHCopyKeyW(HKEY,LPCWSTR,HKEY,DWORD); HKEY WINAPI SHRegDuplicateHKey(HKEY); +/* SHRegGetValue flags */ +typedef INT SRRF; + +#define SRRF_RT_REG_NONE 0x1 +#define SRRF_RT_REG_SZ 0x2 +#define SRRF_RT_REG_EXPAND_SZ 0x4 +#define SRRF_RT_REG_BINARY 0x8 +#define SRRF_RT_REG_DWORD 0x10 +#define SRRF_RT_REG_MULTI_SZ 0x20 +#define SRRF_RT_REG_QWORD 0x40 + +#define SRRF_RT_DWORD (SRRF_RT_REG_BINARY|SRRF_RT_REG_DWORD) +#define SRRF_RT_QWORD (SRRF_RT_REG_BINARY|SRRF_RT_REG_QWORD) +#define SRRF_RT_ANY 0xffff + +#define SRRF_RM_ANY 0 +#define SRRF_RM_NORMAL 0x10000 +#define SRRF_RM_SAFE 0x20000 +#define SRRF_RM_SAFENETWORK 0x40000 + +#define SRRF_NOEXPAND 0x10000000 +#define SRRF_ZEROONFAILURE 0x20000000 +#define SRRF_NOVIRT 0x40000000 + +LSTATUS WINAPI SHRegGetValueA(HKEY,LPCSTR,LPCSTR,SRRF,LPDWORD,LPVOID,LPDWORD); +LSTATUS WINAPI SHRegGetValueW(HKEY,LPCWSTR,LPCWSTR,SRRF,LPDWORD,LPVOID,LPDWORD); +#define SHRegGetValue WINELIB_NAME_AW(SHRegGetValue) + /* Undocumented registry functions */ DWORD WINAPI SHDeleteOrphanKeyA(HKEY,LPCSTR); @@ -388,7 +416,7 @@ BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR); BOOL WINAPI PathIsFileSpecA(LPCSTR); BOOL WINAPI PathIsFileSpecW(LPCWSTR); -#define PathIsFileSpec WINELIB_NAME_AW(PathIsFileSpec) +#define PathIsFileSpec WINELIB_NAME_AW(PathIsFileSpec); BOOL WINAPI PathIsPrefixA(LPCSTR,LPCSTR); BOOL WINAPI PathIsPrefixW(LPCWSTR,LPCWSTR); @@ -1064,6 +1092,17 @@ BOOL WINAPI IsOS(DWORD); #define TPS_EXECUTEIO 0x00000001 #define TPS_LONGEXECTIME 0x00000008 +/* SHFormatDateTimeA/SHFormatDateTimeW flags */ +#define FDTF_SHORTTIME 0x00000001 +#define FDTF_SHORTDATE 0x00000002 +#define FDTF_DEFAULT (FDTF_SHORTDATE | FDTF_SHORTTIME) +#define FDTF_LONGDATE 0x00000004 +#define FDTF_LONGTIME 0x00000008 +#define FDTF_RELATIVE 0x00000010 +#define FDTF_LTRDATE 0x00000100 +#define FDTF_RTLDATE 0x00000200 +#define FDTF_NOAUTOREADINGORDER 0x00000400 + #include #ifdef __cplusplus diff --git a/include/psdk/shobjidl.idl b/include/psdk/shobjidl.idl index cd2320e7f08..221ab04d22c 100644 --- a/include/psdk/shobjidl.idl +++ b/include/psdk/shobjidl.idl @@ -323,22 +323,6 @@ interface IEnumExtraSearch : IUnknown ] interface IShellFolder2 : IShellFolder { - typedef enum - { - SHCOLSTATE_TYPE_STR = 0x00000001, - SHCOLSTATE_TYPE_INT = 0x00000002, - SHCOLSTATE_TYPE_DATE = 0x00000003, - SHCOLSTATE_TYPEMASK = 0x0000000f, - SHCOLSTATE_ONBYDEFAULT = 0x00000010, - SHCOLSTATE_SLOW = 0x00000020, - SHCOLSTATE_EXTENDED = 0x00000040, - SHCOLSTATE_SECONDARYUI = 0x00000080, - SHCOLSTATE_HIDDEN = 0x00000100, - SHCOLSTATE_PREFER_VARCMP = 0x00000200 - } SHCOLSTATE; - - typedef DWORD SHCOLSTATEF; - typedef struct { GUID fmtid; @@ -2310,6 +2294,10 @@ interface IBrowserService : IUnknown typedef BASEBROWSERDATA *LPBASEBROWSERDATA; +cpp_quote("#if 0") +typedef HANDLE HMONITOR; +cpp_quote("#endif /* 0 */") + typedef struct SToolbarItem { IDockingWindow *ptbar; diff --git a/include/psdk/shtypes.idl b/include/psdk/shtypes.idl index 3a922b83246..021d4671251 100644 --- a/include/psdk/shtypes.idl +++ b/include/psdk/shtypes.idl @@ -21,8 +21,6 @@ import "wtypes.idl"; - - cpp_quote("#include ") typedef struct { @@ -34,60 +32,13 @@ typedef const SHITEMID *LPCSHITEMID; typedef struct _ITEMIDLIST { SHITEMID mkid; /* first itemid in list */ -} ITEMIDLIST; - -cpp_quote("#if defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)") -cpp_quote("typedef struct _ITEMIDLIST_RELATIVE : ITEMIDLIST {} ITEMIDLIST_RELATIVE;") -cpp_quote("typedef struct _ITEMID_CHILD : ITEMIDLIST_RELATIVE {} ITEMID_CHILD;") -cpp_quote("typedef struct _ITEMIDLIST_ABSOLUTE : ITEMIDLIST_RELATIVE {} ITEMIDLIST_ABSOLUTE;") -cpp_quote("#else /* !(defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)) */") -typedef ITEMIDLIST ITEMIDLIST_RELATIVE; -typedef ITEMIDLIST ITEMID_CHILD; -typedef ITEMIDLIST ITEMIDLIST_ABSOLUTE; -cpp_quote("#endif /* defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus) */") - +} ITEMIDLIST,*LPITEMIDLIST; +typedef const ITEMIDLIST *LPCITEMIDLIST; +typedef LPITEMIDLIST PITEMID_CHILD; +typedef LPCITEMIDLIST PCUITEMID_CHILD; +typedef LPCITEMIDLIST *PCUITEMID_CHILD_ARRAY; cpp_quote("#include ") -typedef [unique] BYTE_BLOB * wirePIDL; -typedef ITEMIDLIST /*__unaligned*/ * LPITEMIDLIST; -typedef const ITEMIDLIST /*__unaligned*/ * LPCITEMIDLIST; - -cpp_quote("#if defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)") -typedef ITEMIDLIST_ABSOLUTE * PIDLIST_ABSOLUTE; -typedef const ITEMIDLIST_ABSOLUTE * PCIDLIST_ABSOLUTE; -typedef const ITEMIDLIST_ABSOLUTE /*__unaligned*/ * PCUIDLIST_ABSOLUTE; -typedef ITEMIDLIST_RELATIVE * PIDLIST_RELATIVE; -typedef const ITEMIDLIST_RELATIVE * PCIDLIST_RELATIVE; -typedef ITEMIDLIST_RELATIVE /*__unaligned*/ * PUIDLIST_RELATIVE; -typedef const ITEMIDLIST_RELATIVE /*__unaligned*/ * PCUIDLIST_RELATIVE; -typedef ITEMID_CHILD * PITEMID_CHILD; -typedef const ITEMID_CHILD * PCITEMID_CHILD; -typedef ITEMID_CHILD /*__unaligned*/ * PUITEMID_CHILD; -typedef const ITEMID_CHILD /*__unaligned*/ * PCUITEMID_CHILD; - -typedef PCUITEMID_CHILD const *PCUITEMID_CHILD_ARRAY; -typedef PCUIDLIST_RELATIVE const *PCUIDLIST_RELATIVE_ARRAY; -typedef PCIDLIST_ABSOLUTE const *PCIDLIST_ABSOLUTE_ARRAY; -typedef PCUIDLIST_ABSOLUTE const *PCUIDLIST_ABSOLUTE_ARRAY; -cpp_quote("#else /* !(defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)) */") -cpp_quote("#define PIDLIST_ABSOLUTE LPITEMIDLIST") -cpp_quote("#define PCIDLIST_ABSOLUTE LPCITEMIDLIST") -cpp_quote("#define PCUIDLIST_ABSOLUTE LPCITEMIDLIST") -cpp_quote("#define PIDLIST_RELATIVE LPITEMIDLIST") -cpp_quote("#define PCIDLIST_RELATIVE LPCITEMIDLIST") -cpp_quote("#define PUIDLIST_RELATIVE LPITEMIDLIST") -cpp_quote("#define PCUIDLIST_RELATIVE LPCITEMIDLIST") -cpp_quote("#define PITEMID_CHILD LPITEMIDLIST") -cpp_quote("#define PCITEMID_CHILD LPCITEMIDLIST") -cpp_quote("#define PUITEMID_CHILD LPITEMIDLIST") -cpp_quote("#define PCUITEMID_CHILD LPCITEMIDLIST") -cpp_quote("#define PCUITEMID_CHILD_ARRAY LPCITEMIDLIST *") -cpp_quote("#define PCUIDLIST_RELATIVE_ARRAY LPCITEMIDLIST *") -cpp_quote("#define PCIDLIST_ABSOLUTE_ARRAY LPCITEMIDLIST *") -cpp_quote("#define PCUIDLIST_ABSOLUTE_ARRAY LPCITEMIDLIST *") -cpp_quote("#endif /* defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus) */") - - #ifndef MAX_PATH #define MAX_PATH 260 #endif @@ -103,7 +54,7 @@ typedef enum tagSTRRET_TYPE STRRET_CSTR = 2 } STRRET_TYPE; -cpp_quote("#include ") +cpp_quote("#include ") typedef struct _STRRET { UINT uType; /* STRRET_xxx */ @@ -124,3 +75,29 @@ typedef struct STRRET str; } SHELLDETAILS, *LPSHELLDETAILS; cpp_quote("#include ") + +typedef [v1_enum] enum tagSHCOLSTATE +{ + SHCOLSTATE_DEFAULT = 0, + SHCOLSTATE_TYPE_STR, + SHCOLSTATE_TYPE_INT, + SHCOLSTATE_TYPE_DATE, + SHCOLSTATE_TYPEMASK = 0xf, + SHCOLSTATE_ONBYDEFAULT = 0x10, + SHCOLSTATE_SLOW = 0x20, + SHCOLSTATE_EXTENDED = 0x40, + SHCOLSTATE_SECONDARYUI = 0x80, + SHCOLSTATE_HIDDEN = 0x100, + SHCOLSTATE_PREFER_VARCMP = 0x200, + SHCOLSTATE_PREFER_FMTCMP = 0x400, + SHCOLSTATE_NOSORTBYFOLDERNESS = 0x800, + SHCOLSTATE_VIEWONLY = 0x10000, + SHCOLSTATE_BATCHREAD = 0x20000, + SHCOLSTATE_NO_GROUPBY = 0x40000, + SHCOLSTATE_FIXED_WIDTH = 0x1000, + SHCOLSTATE_NODPISCALE = 0x2000, + SHCOLSTATE_FIXED_RATIO = 0x4000, + SHCOLSTATE_DISPLAYMASK = 0xf000 +} SHCOLSTATE; + +typedef DWORD SHCOLSTATEF; diff --git a/include/psdk/tom.idl b/include/psdk/tom.idl index 669fbcf9e0c..35be7f70dbd 100644 --- a/include/psdk/tom.idl +++ b/include/psdk/tom.idl @@ -18,6 +18,10 @@ import "oaidl.idl"; +cpp_quote("#ifdef WINE_NO_UNICODE_MACROS") +cpp_quote("#undef FindText") +cpp_quote("#endif") + typedef enum tagTomConstants { tomFalse = 0, @@ -200,23 +204,23 @@ interface ITextDocument : IDispatch { HRESULT GetName([retval, out]BSTR *pName); HRESULT GetSelection([retval, out]ITextSelection **ppSel); - HRESULT GetStoryCount([retval, out]long *pCount); + HRESULT GetStoryCount([retval, out]LONG *pCount); HRESULT GetStoryRanges([retval, out]ITextStoryRanges **ppStories); - HRESULT GetSaved([retval, out]long *pValue); - HRESULT SetSaved([in]long Value); + HRESULT GetSaved([retval, out]LONG *pValue); + HRESULT SetSaved([in]LONG Value); HRESULT GetDefaultTabStop([retval, out]float *pValue); HRESULT SetDefaultTabStop([in]float Value); HRESULT New(); - HRESULT Open([in]VARIANT *pVar, [in]long Flags, [in]long CodePage); - HRESULT Save([in]VARIANT *pVar, [in]long Flags, [in]long CodePage); - HRESULT Freeze([retval, out]long *pCount); - HRESULT Unfreeze([retval, out]long *pCount); + HRESULT Open([in]VARIANT *pVar, [in]LONG Flags, [in]LONG CodePage); + HRESULT Save([in]VARIANT *pVar, [in]LONG Flags, [in]LONG CodePage); + HRESULT Freeze([retval, out]LONG *pCount); + HRESULT Unfreeze([retval, out]LONG *pCount); HRESULT BeginEditCollection(); HRESULT EndEditCollection(); - HRESULT Undo([in]long Count, [retval, out]long *prop); - HRESULT Redo([in]long Count, [retval, out]long *prop); - HRESULT Range([in]long cp1, [in]long cp2, [retval, out]ITextRange**ppRange); - HRESULT RangeFromPoint([in]long x, [in]long y, [retval, out]ITextRange**ppRange); + HRESULT Undo([in]LONG Count, [retval, out]LONG *prop); + HRESULT Redo([in]LONG Count, [retval, out]LONG *prop); + HRESULT Range([in]LONG cp1, [in]LONG cp2, [retval, out]ITextRange **ppRange); + HRESULT RangeFromPoint([in]LONG x, [in]LONG y, [retval, out]ITextRange **ppRange); } interface ITextFont; @@ -230,54 +234,54 @@ interface ITextRange : IDispatch { HRESULT GetText([retval, out]BSTR *pbstr); HRESULT SetText([in]BSTR bstr); - HRESULT GetChar([retval, out]long *pch); - HRESULT SetChar([in]long ch); + HRESULT GetChar([retval, out]LONG *pch); + HRESULT SetChar([in]LONG ch); HRESULT GetDuplicate([retval, out]ITextRange **ppRange); HRESULT GetFormattedText([retval, out]ITextRange **ppRange); HRESULT SetFormattedText([in]ITextRange *pRange); - HRESULT GetStart([retval, out]long *pcpFirst); - HRESULT SetStart([in]long cpFirst); - HRESULT GetEnd([retval, out]long *pcpLim); - HRESULT SetEnd([in]long cpLim); + HRESULT GetStart([retval, out]LONG *pcpFirst); + HRESULT SetStart([in]LONG cpFirst); + HRESULT GetEnd([retval, out]LONG *pcpLim); + HRESULT SetEnd([in]LONG cpLim); HRESULT GetFont([retval, out]ITextFont **pFont); HRESULT SetFont([in]ITextFont *pFont); HRESULT GetPara([retval, out]ITextPara **ppPara); HRESULT SetPara([in]ITextPara *pPara); - HRESULT GetStoryLength([retval, out]long *pcch); - HRESULT GetStoryType([retval, out]long *pValue); - HRESULT Collapse([in]long bStart); - HRESULT Expand([in]long Unit, [retval, out]long *pDelta); - HRESULT GetIndex([in]long Unit, [retval, out]long *pIndex); - HRESULT SetIndex([in]long Unit, [in]long Index, [in]long Extend); - HRESULT SetRange([in]long cpActive, [in]long cpOther); - HRESULT InRange([in]ITextRange *pRange, [retval, out]long *pb); - HRESULT InStory([in]ITextRange *pRange, [retval, out]long *pb); - HRESULT IsEqual([in]ITextRange *pRange, [retval, out]long *pb); + HRESULT GetStoryLength([retval, out]LONG *pcch); + HRESULT GetStoryType([retval, out]LONG *pValue); + HRESULT Collapse([in]LONG bStart); + HRESULT Expand([in]LONG Unit, [retval, out]LONG *pDelta); + HRESULT GetIndex([in]LONG Unit, [retval, out]LONG *pIndex); + HRESULT SetIndex([in]LONG Unit, [in]LONG Index, [in]LONG Extend); + HRESULT SetRange([in]LONG cpActive, [in]LONG cpOther); + HRESULT InRange([in]ITextRange *pRange, [retval, out]LONG *pb); + HRESULT InStory([in]ITextRange *pRange, [retval, out]LONG *pb); + HRESULT IsEqual([in]ITextRange *pRange, [retval, out]LONG *pb); HRESULT Select(); - HRESULT StartOf([in]long Unit, [in]long Extend, [retval, out]long *pDelta); - HRESULT EndOf([in]long Unit, [in]long Extend, [retval, out]long *pDelta); - HRESULT Move([in]long Unit, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveStart([in]long Unit, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveEnd([in]long Unit, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveWhile([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveStartWhile([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveEndWhile([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveUntil([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveStartUntil([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT MoveEndUntil([in]VARIANT *Cset, [in]long Count, [retval, out]long *pDelta); - HRESULT FindText([in]BSTR bstr, [in]long cch, [in]long Flags, [retval, out]long *pLength); - HRESULT FindTextStart([in]BSTR bstr, [in]long cch, [in]long Flags, [retval, out]long *pLength); - HRESULT FindTextEnd([in]BSTR bstr, [in]long cch, [in]long Flags, [retval, out]long *pLength); - HRESULT Delete([in]long Unit, [in]long Count, [retval, out]long *pDelta); + HRESULT StartOf([in]LONG Unit, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT EndOf([in]LONG Unit, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT Move([in]LONG Unit, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveStart([in]LONG Unit, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveEnd([in]LONG Unit, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveWhile([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveStartWhile([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveEndWhile([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveUntil([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveStartUntil([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT MoveEndUntil([in]VARIANT *Cset, [in]LONG Count, [retval, out]LONG *pDelta); + HRESULT FindText([in]BSTR bstr, [in]LONG cch, [in]LONG Flags, [retval, out]LONG *pLength); + HRESULT FindTextStart([in]BSTR bstr, [in]LONG cch, [in]LONG Flags, [retval, out]LONG *pLength); + HRESULT FindTextEnd([in]BSTR bstr, [in]LONG cch, [in]LONG Flags, [retval, out]LONG *pLength); + HRESULT Delete([in]LONG Unit, [in]LONG Count, [retval, out]LONG *pDelta); HRESULT Cut([out]VARIANT *pVar); HRESULT Copy([out]VARIANT *pVar); - HRESULT Paste([in]VARIANT *pVar, [in]long Format); - HRESULT CanPaste([in]VARIANT *pVar, [in]long Format, [retval, out]long *pb); - HRESULT CanEdit([retval, out]long *pb); - HRESULT ChangeCase([in]long Type); - HRESULT GetPoint([in]long Type, [out]long *cx, [out]long *cy); - HRESULT SetPoint([in]long x, [in]long y, [in]long Type, [in]long Extend); - HRESULT ScrollIntoView([in]long Value); + HRESULT Paste([in]VARIANT *pVar, [in]LONG Format); + HRESULT CanPaste([in]VARIANT *pVar, [in]LONG Format, [retval, out]LONG *pb); + HRESULT CanEdit([retval, out]LONG *pb); + HRESULT ChangeCase([in]LONG Type); + HRESULT GetPoint([in]LONG Type, [out]LONG *cx, [out]LONG *cy); + HRESULT SetPoint([in]LONG x, [in]LONG y, [in]LONG Type, [in]LONG Extend); + HRESULT ScrollIntoView([in]LONG Value); HRESULT GetEmbeddedObject([retval, out]IUnknown **ppv); } @@ -287,15 +291,15 @@ interface ITextRange : IDispatch ] interface ITextSelection : ITextRange { - HRESULT GetFlags([retval, out]long *pFlags); - HRESULT SetFlags([in]long Flags); - HRESULT GetType([retval, out]long *pType); - HRESULT MoveLeft([in]long Unit, [in]long Count, [in]long Extend, [retval, out]long *pDelta); - HRESULT MoveRight([in]long Unit, [in]long Count, [in]long Extend, [retval, out]long *pDelta); - HRESULT MoveUp([in]long Unit, [in]long Count, [in]long Extend, [retval, out]long *pDelta); - HRESULT MoveDown([in]long Unit, [in]long Count, [in]long Extend, [retval, out]long *pDelta); - HRESULT HomeKey([in]long Unit, [in]long Extend, [retval, out]long *pDelta); - HRESULT EndKey([in]long Unit, [in]long Extend, [retval, out]long *pDelta); + HRESULT GetFlags([retval, out]LONG *pFlags); + HRESULT SetFlags([in]LONG Flags); + HRESULT GetType([retval, out]LONG *pType); + HRESULT MoveLeft([in]LONG Unit, [in]LONG Count, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT MoveRight([in]LONG Unit, [in]LONG Count, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT MoveUp([in]LONG Unit, [in]LONG Count, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT MoveDown([in]LONG Unit, [in]LONG Count, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT HomeKey([in]LONG Unit, [in]LONG Extend, [retval, out]LONG *pDelta); + HRESULT EndKey([in]LONG Unit, [in]LONG Extend, [retval, out]LONG *pDelta); HRESULT TypeText([in]BSTR bstr); } @@ -307,59 +311,59 @@ interface ITextFont : IDispatch { HRESULT GetDuplicate([retval, out]ITextFont **ppFont); HRESULT SetDuplicate([in]ITextFont *pFont); - HRESULT CanChange([out]long *pB); - HRESULT IsEqual([in]ITextFont *pFont, [retval, out]long *pB); - HRESULT Reset([in]long Value); - HRESULT GetStyle([retval, out]long *pValue); - HRESULT SetStyle([in]long Value); - HRESULT GetAllCaps([retval, out]long *pValue); - HRESULT SetAllCaps([in]long Value); - HRESULT GetAnimation([retval, out]long *pValue); - HRESULT SetAnimation([in]long Value); - HRESULT GetBackColor([retval, out]long *pValue); - HRESULT SetBackColor([in]long Value); - HRESULT GetBold([retval, out]long *pValue); - HRESULT SetBold([in]long Value); - HRESULT GetEmboss([retval, out]long *pValue); - HRESULT SetEmboss([in]long Value); - HRESULT GetForeColor([retval, out]long *pValue); - HRESULT SetForeColor([in]long Value); - HRESULT GetHidden([retval, out]long *pValue); - HRESULT SetHidden([in]long Value); - HRESULT GetEngrave([retval, out]long *pValue); - HRESULT SetEngrave([in]long Value); - HRESULT GetItalic([retval, out]long *pValue); - HRESULT SetItalic([in]long Value); - HRESULT GetKerning([retval, out]long *pValue); - HRESULT SetKerning([in]long Value); - HRESULT GetLanguageID([retval, out]long *pValue); - HRESULT SetLanguageID([in]long Value); + HRESULT CanChange([out]LONG *pB); + HRESULT IsEqual([in]ITextFont *pFont, [retval, out]LONG *pB); + HRESULT Reset([in]LONG Value); + HRESULT GetStyle([retval, out]LONG *pValue); + HRESULT SetStyle([in]LONG Value); + HRESULT GetAllCaps([retval, out]LONG *pValue); + HRESULT SetAllCaps([in]LONG Value); + HRESULT GetAnimation([retval, out]LONG *pValue); + HRESULT SetAnimation([in]LONG Value); + HRESULT GetBackColor([retval, out]LONG *pValue); + HRESULT SetBackColor([in]LONG Value); + HRESULT GetBold([retval, out]LONG *pValue); + HRESULT SetBold([in]LONG Value); + HRESULT GetEmboss([retval, out]LONG *pValue); + HRESULT SetEmboss([in]LONG Value); + HRESULT GetForeColor([retval, out]LONG *pValue); + HRESULT SetForeColor([in]LONG Value); + HRESULT GetHidden([retval, out]LONG *pValue); + HRESULT SetHidden([in]LONG Value); + HRESULT GetEngrave([retval, out]LONG *pValue); + HRESULT SetEngrave([in]LONG Value); + HRESULT GetItalic([retval, out]LONG *pValue); + HRESULT SetItalic([in]LONG Value); + HRESULT GetKerning([retval, out]LONG *pValue); + HRESULT SetKerning([in]LONG Value); + HRESULT GetLanguageID([retval, out]LONG *pValue); + HRESULT SetLanguageID([in]LONG Value); HRESULT GetName([retval, out]BSTR *pValue); HRESULT SetName([in]BSTR Value); - HRESULT GetOutline([retval, out]long *pValue); - HRESULT SetOutline([in]long Value); - HRESULT GetPosition([retval, out]long *pValue); - HRESULT SetPosition([in]long Value); - HRESULT GetProtected([retval, out]long *pValue); - HRESULT SetProtected([in]long Value); - HRESULT GetShadow([retval, out]long *pValue); - HRESULT SetShadow([in]long Value); - HRESULT GetSize([retval, out]long *pValue); - HRESULT SetSize([in]long Value); - HRESULT GetSmallCaps([retval, out]long *pValue); - HRESULT SetSmallCaps([in]long Value); + HRESULT GetOutline([retval, out]LONG *pValue); + HRESULT SetOutline([in]LONG Value); + HRESULT GetPosition([retval, out]LONG *pValue); + HRESULT SetPosition([in]LONG Value); + HRESULT GetProtected([retval, out]LONG *pValue); + HRESULT SetProtected([in]LONG Value); + HRESULT GetShadow([retval, out]LONG *pValue); + HRESULT SetShadow([in]LONG Value); + HRESULT GetSize([retval, out]LONG *pValue); + HRESULT SetSize([in]LONG Value); + HRESULT GetSmallCaps([retval, out]LONG *pValue); + HRESULT SetSmallCaps([in]LONG Value); HRESULT GetSpacing([retval, out]float *pValue); HRESULT SetSpacing([in]float Value); - HRESULT GetStrikeThrough([retval, out]long *pValue); - HRESULT SetStrikeThrough([in]long Value); - HRESULT GetSubscript([retval, out]long *pValue); - HRESULT SetSubscript([in]long Value); - HRESULT GetSuperscript([retval, out]long *pValue); - HRESULT SetSuperscript([in]long Value); - HRESULT GetUnderline([retval, out]long *pValue); - HRESULT SetUnderline([in]long Value); - HRESULT GetWeight([retval, out]long *pValue); - HRESULT SetWeight([in]long Value); + HRESULT GetStrikeThrough([retval, out]LONG *pValue); + HRESULT SetStrikeThrough([in]LONG Value); + HRESULT GetSubscript([retval, out]LONG *pValue); + HRESULT SetSubscript([in]LONG Value); + HRESULT GetSuperscript([retval, out]LONG *pValue); + HRESULT SetSuperscript([in]LONG Value); + HRESULT GetUnderline([retval, out]LONG *pValue); + HRESULT SetUnderline([in]LONG Value); + HRESULT GetWeight([retval, out]LONG *pValue); + HRESULT SetWeight([in]LONG Value); } [ @@ -370,52 +374,52 @@ interface ITextPara : IDispatch { HRESULT GetDuplicate([retval, out]ITextPara **ppPara); HRESULT SetDuplicate([in]ITextPara *pPara); - HRESULT CanChange([out]long *pB); - HRESULT IsEqual([in]ITextPara *pPara, [retval, out]long *pB); - HRESULT Reset([in]long Value); - HRESULT GetStyle([retval, out]long *pValue); - HRESULT SetStyle([in]long Value); - HRESULT GetAlignment([retval, out]long *pValue); - HRESULT SetAlignment([in]long Value); - HRESULT GetHyphenation([retval, out]long *pValue); - HRESULT SetHyphenation([in]long Value); + HRESULT CanChange([out]LONG *pB); + HRESULT IsEqual([in]ITextPara *pPara, [retval, out]LONG *pB); + HRESULT Reset([in]LONG Value); + HRESULT GetStyle([retval, out]LONG *pValue); + HRESULT SetStyle([in]LONG Value); + HRESULT GetAlignment([retval, out]LONG *pValue); + HRESULT SetAlignment([in]LONG Value); + HRESULT GetHyphenation([retval, out]LONG *pValue); + HRESULT SetHyphenation([in]LONG Value); HRESULT GetFirstLineIndent([retval, out]float *pValue); - HRESULT GetKeepTogether([retval, out]long *pValue); - HRESULT SetKeepTogether([in]long Value); - HRESULT GetKeepWithNext([retval, out]long *pValue); - HRESULT SetKeepWithNext([in]long Value); + HRESULT GetKeepTogether([retval, out]LONG *pValue); + HRESULT SetKeepTogether([in]LONG Value); + HRESULT GetKeepWithNext([retval, out]LONG *pValue); + HRESULT SetKeepWithNext([in]LONG Value); HRESULT GetLeftIndent([retval, out]float *pValue); HRESULT GetLineSpacing([retval, out]float *pValue); - HRESULT GetLineSpacingRule([retval, out]long *pValue); - HRESULT GetListAlignment([retval, out]long *pValue); - HRESULT SetListAlignment([in]long Value); - HRESULT GetListLevelIndex([retval, out]long *pValue); - HRESULT SetListLevelIndex([in]long Value); - HRESULT GetListStart([retval, out]long *pValue); - HRESULT SetListStart([in]long Value); - HRESULT GetListTab([retval, out]long *pValue); - HRESULT SetListTab([in]long Value); - HRESULT GetListType([retval, out]long *pValue); - HRESULT SetListType([in]long Value); - HRESULT GetNoLineNumber([retval, out]long *pValue); - HRESULT SetNoLineNumber([in]long Value); - HRESULT GetPageBreakBefore([retval, out]long *pValue); - HRESULT SetPageBreakBefore([in]long Value); + HRESULT GetLineSpacingRule([retval, out]LONG *pValue); + HRESULT GetListAlignment([retval, out]LONG *pValue); + HRESULT SetListAlignment([in]LONG Value); + HRESULT GetListLevelIndex([retval, out]LONG *pValue); + HRESULT SetListLevelIndex([in]LONG Value); + HRESULT GetListStart([retval, out]LONG *pValue); + HRESULT SetListStart([in]LONG Value); + HRESULT GetListTab([retval, out]LONG *pValue); + HRESULT SetListTab([in]LONG Value); + HRESULT GetListType([retval, out]LONG *pValue); + HRESULT SetListType([in]LONG Value); + HRESULT GetNoLineNumber([retval, out]LONG *pValue); + HRESULT SetNoLineNumber([in]LONG Value); + HRESULT GetPageBreakBefore([retval, out]LONG *pValue); + HRESULT SetPageBreakBefore([in]LONG Value); HRESULT GetRightIndent([retval, out]float *pValue); HRESULT SetRightIndent([in]float Value); HRESULT SetIndents([in]float StartIndent, [in]float LeftIndent, [in]float RightIndent); - HRESULT SetLineSpacing([in]long LineSpacingRule, [in]float LineSpacing); + HRESULT SetLineSpacing([in]LONG LineSpacingRule, [in]float LineSpacing); HRESULT GetSpaceAfter([retval, out]float *pValue); HRESULT SetSpaceAfter([in]float Value); HRESULT GetSpaceBefore([retval, out]float *pValue); HRESULT SetSpaceBefore([in]float Value); HRESULT GetWindowControl([retval, out]float *pValue); HRESULT SetWindowControl([in]float Value); - HRESULT GetTabCount([retval, out]long *pCount); - HRESULT AddTab([in]float tbPos, [in]long tbAlign, [in]long tbLeader); + HRESULT GetTabCount([retval, out]LONG *pCount); + HRESULT AddTab([in]float tbPos, [in]LONG tbAlign, [in]LONG tbLeader); HRESULT ClearAllTabs(); HRESULT DeleteTab([in]float tbPos); - HRESULT GetTab([in]long iTab, [out]float *ptbPos, [out]long *ptbAlign, [out]long *ptbLeader); + HRESULT GetTab([in]LONG iTab, [out]float *ptbPos, [out]LONG *ptbAlign, [out]LONG *ptbLeader); } [ @@ -425,6 +429,6 @@ interface ITextPara : IDispatch interface ITextStoryRanges : IDispatch { HRESULT _NewEnum([retval, out]IUnknown **ppUnkEnum); - HRESULT Item([in]long Index, [retval, out]ITextRange **ppRange); - HRESULT GetCount([retval, out]long *pCount); + HRESULT Item([in]LONG Index, [retval, out]ITextRange **ppRange); + HRESULT GetCount([retval, out]LONG *pCount); } diff --git a/include/psdk/tuner.idl b/include/psdk/tuner.idl new file mode 100644 index 00000000000..57f4de1fb3b --- /dev/null +++ b/include/psdk/tuner.idl @@ -0,0 +1,1817 @@ + + +cpp_quote("#pragma once") + +#include +#ifndef DO_NO_IMPORTS +import "oaidl.idl"; +import "comcat.idl"; +import "strmif.idl"; +import "bdaiface.idl"; +import "regbag.idl"; +#else +cpp_quote("#include ") +#endif + +interface ITuningSpaceContainer; +interface ITuningSpace; +interface IEnumTuningSpaces; +interface ITuneRequest; +interface ITuner; +interface ITunerCap; +interface IScanningTuner; +interface IEnumComponentTypes; +interface IComponentTypes; +interface IComponentType; +interface ILanguageComponentType; +interface IEnumComponents; +interface IComponents; +interface IComponent; +interface IMPEG2ComponentType; +interface IMPEG2Component; +interface ILocator; +interface IATSCLocator; +interface IDVBSLocator; +interface IDVBTLocator; +interface IDVBCLocator; +interface IDigitalCableLocator; +interface IAnalogLocator; +interface IDigitalCableTuneRequest; +interface IDigitalCableTuningSpace; + +[ + object, + uuid(901284E4-33FE-4b69-8D63-634A596F3756), + dual, + oleautomation, + nonextensible, + pointer_default(unique) +] +interface ITuningSpaces : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT** NewEnum); + + HRESULT get_Item( + [in] VARIANT varIndex, + [out] ITuningSpace** TuningSpace); + + HRESULT get_EnumTuningSpaces( + [out] IEnumTuningSpaces** NewEnum); +} + +[ + object, + uuid(5B692E84-E2F1-11d2-9493-00C04F72D980), + dual, + oleautomation, + hidden, + nonextensible, + pointer_default(unique) +] +interface ITuningSpaceContainer : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT** NewEnum); + + HRESULT get_Item( + [in] VARIANT varIndex, + [out] ITuningSpace** TuningSpace); + + HRESULT put_Item( + [in] VARIANT varIndex, + [in] ITuningSpace *TuningSpace); + + HRESULT TuningSpacesForCLSID( + [in] BSTR SpaceCLSID, + [out] ITuningSpaces** NewColl); + + HRESULT _TuningSpacesForCLSID( + [in] REFCLSID SpaceCLSID, + [out] ITuningSpaces** NewColl); + + HRESULT TuningSpacesForName( + [in] BSTR Name, + [out] ITuningSpaces** NewColl); + + HRESULT FindID( + [in] ITuningSpace *TuningSpace, + [out] long *ID); + + HRESULT Add( + [in] ITuningSpace* TuningSpace, + [out] VARIANT* NewIndex); + + HRESULT get_EnumTuningSpaces( + [out] IEnumTuningSpaces **ppEnum); + + HRESULT Remove( + [in] VARIANT Index); + + HRESULT get_MaxCount( + [out] long *MaxCount); + + HRESULT put_MaxCount( + [in] long MaxCount); +} + + +[ + object, + uuid(061C6E30-E622-11d2-9493-00C04F72D980), + dual, + oleautomation, + nonextensible, + pointer_default(unique) +] +interface ITuningSpace : IDispatch +{ + HRESULT get_UniqueName( + [out] BSTR *Name); + + HRESULT put_UniqueName( + [in] BSTR Name); + + HRESULT get_FriendlyName( + [out] BSTR *Name); + + HRESULT put_FriendlyName( + [in] BSTR Name); + + HRESULT get_CLSID( + [out] BSTR* SpaceCLSID); + + HRESULT get_NetworkType( + [out] BSTR *NetworkTypeGuid); + + HRESULT put_NetworkType( + [in] BSTR NetworkTypeGuid); + + HRESULT get__NetworkType( + [out] GUID* NetworkTypeGuid); + + HRESULT put__NetworkType( + [in] REFCLSID NetworkTypeGuid); + + HRESULT CreateTuneRequest( + [out] ITuneRequest **TuneRequest); + + HRESULT EnumCategoryGUIDs( + [out] IEnumGUID **ppEnum); + + HRESULT EnumDeviceMonikers( + [out] IEnumMoniker **ppEnum); + + HRESULT get_DefaultPreferredComponentTypes( + [out] IComponentTypes** ComponentTypes); + + HRESULT put_DefaultPreferredComponentTypes( + [in] IComponentTypes* NewComponentTypes); + + HRESULT get_FrequencyMapping( + [out] BSTR *pMapping); + + HRESULT put_FrequencyMapping( + BSTR Mapping); + + HRESULT get_DefaultLocator( + [out] ILocator **LocatorVal); + + HRESULT put_DefaultLocator( + [in]ILocator *LocatorVal); + + HRESULT Clone( + [out] ITuningSpace **NewTS); +} + +[ + hidden, + restricted, + object, + uuid(8B8EB248-FC2B-11d2-9D8C-00C04F72D980), + pointer_default(unique) +] +interface IEnumTuningSpaces : IUnknown +{ + HRESULT Next( + [in] ULONG celt, + [in, out]ITuningSpace** rgelt, + [out] ULONG* pceltFetched); + + HRESULT Skip( + [in] ULONG celt); + + HRESULT Reset(); + + HRESULT Clone( + [out] IEnumTuningSpaces** ppEnum); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(ADA0B268-3B19-4e5b-ACC4-49F852BE13BA), + pointer_default(unique) +] +interface IDVBTuningSpace : ITuningSpace +{ + HRESULT get_SystemType( + [out] DVBSystemType *SysType); + + HRESULT put_SystemType( + [in] DVBSystemType SysType); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(843188B4-CE62-43db-966B-8145A094E040), + pointer_default(unique) +] +interface IDVBTuningSpace2 : IDVBTuningSpace +{ + HRESULT get_NetworkID( + [out] long *NetworkID); + + HRESULT put_NetworkID( + [in] long NetworkID); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(CDF7BE60-D954-42fd-A972-78971958E470), + pointer_default(unique) +] +interface IDVBSTuningSpace : IDVBTuningSpace2 +{ + + HRESULT get_LowOscillator( + [out] long *LowOscillator); + + HRESULT put_LowOscillator( + [in] long LowOscillator); + + HRESULT get_HighOscillator( + [out] long *HighOscillator); + + HRESULT put_HighOscillator( + [in] long HighOscillator); + + HRESULT get_LNBSwitch( + [out] long *LNBSwitch); + + HRESULT put_LNBSwitch( + [in] long LNBSwitch); + + HRESULT get_InputRange( + [out] BSTR *InputRange); + + HRESULT put_InputRange( + [in] BSTR InputRange); + + HRESULT get_SpectralInversion( + [out] SpectralInversion *SpectralInversionVal); + + HRESULT put_SpectralInversion( + [in] SpectralInversion SpectralInversionVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(E48244B8-7E17-4f76-A763-5090FF1E2F30), + pointer_default(unique) +] +interface IAuxInTuningSpace : ITuningSpace +{ +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(B10931ED-8BFE-4AB0-9DCE-E469C29A9729), + pointer_default(unique) +] +interface IAuxInTuningSpace2 : IAuxInTuningSpace +{ + HRESULT get_CountryCode([out] long *CountryCodeVal); + + HRESULT put_CountryCode([in] long NewCountryCodeVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(2A6E293C-2595-11d3-B64C-00C04F79498E), + pointer_default(unique) +] +interface IAnalogTVTuningSpace : ITuningSpace +{ + HRESULT get_MinChannel( + [out] long *MinChannelVal); + + HRESULT put_MinChannel( + [in] long NewMinChannelVal); + + HRESULT get_MaxChannel( + [out] long *MaxChannelVal); + + HRESULT put_MaxChannel( + [in] long NewMaxChannelVal); + + HRESULT get_InputType( + [out] TunerInputType *InputTypeVal); + + HRESULT put_InputType( + [in] TunerInputType NewInputTypeVal); + + HRESULT get_CountryCode( + [out] long *CountryCodeVal); + + HRESULT put_CountryCode( + [in] long NewCountryCodeVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(0369B4E2-45B6-11d3-B650-00C04F79498E), + pointer_default(unique) +] +interface IATSCTuningSpace : IAnalogTVTuningSpace +{ + HRESULT get_MinMinorChannel( + [out] long *MinMinorChannelVal); + + HRESULT put_MinMinorChannel( + [in] long NewMinMinorChannelVal); + + HRESULT get_MaxMinorChannel( + [out] long *MaxMinorChannelVal); + + HRESULT put_MaxMinorChannel( + [in] long NewMaxMinorChannelVal); + + HRESULT get_MinPhysicalChannel( + [out] long *MinPhysicalChannelVal); + + HRESULT put_MinPhysicalChannel( + [in] long NewMinPhysicalChannelVal); + + HRESULT get_MaxPhysicalChannel( + [out] long *MaxPhysicalChannelVal); + + HRESULT put_MaxPhysicalChannel( + [in] long NewMaxPhysicalChannelVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(013F9F9C-B449-4ec7-A6D2-9D4F2FC70AE5), + pointer_default(unique) +] +interface IDigitalCableTuningSpace : IATSCTuningSpace +{ + HRESULT get_MinMajorChannel( + [out] long *MinMajorChannelVal); + + HRESULT put_MinMajorChannel( + [in] long NewMinMajorChannelVal); + + HRESULT get_MaxMajorChannel( + [out] long *MaxMajorChannelVal); + + HRESULT put_MaxMajorChannel( + [in] long NewMaxMajorChannelVal); + + HRESULT get_MinSourceID( + [out] long *MinSourceIDVal); + + HRESULT put_MinSourceID( + [in] long NewMinSourceIDVal); + + HRESULT get_MaxSourceID( + [out] long *MaxSourceIDVal); + + HRESULT put_MaxSourceID( + [in] long NewMaxSourceIDVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(2A6E293B-2595-11d3-B64C-00C04F79498E), + pointer_default(unique) +] +interface IAnalogRadioTuningSpace : ITuningSpace +{ + HRESULT get_MinFrequency( + [out] long *MinFrequencyVal); + + HRESULT put_MinFrequency( + [in] long NewMinFrequencyVal); + + HRESULT get_MaxFrequency( + [out] long *MaxFrequencyVal); + + HRESULT put_MaxFrequency( + [in] long NewMaxFrequencyVal); + + HRESULT get_Step( + [out] long *StepVal); + + HRESULT put_Step( + [in] long NewStepVal); +} + +[ + object, + hidden, + dual, + oleautomation, + nonextensible, + uuid(39DD45DA-2DA8-46BA-8A8A-87E2B73D983A), + pointer_default(unique) +] +interface IAnalogRadioTuningSpace2 : IAnalogRadioTuningSpace { + HRESULT get_CountryCode([out] long *CountryCodeVal); + HRESULT put_CountryCode([in] long NewCountryCodeVal); +} +[ + object, + nonextensible, + uuid(07DDC146-FC3D-11d2-9D8C-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface ITuneRequest : IDispatch +{ + HRESULT get_TuningSpace( + [out] ITuningSpace **TuningSpace); + + HRESULT get_Components( + [out] IComponents **Components); + + HRESULT Clone( + [out] ITuneRequest **NewTuneRequest); + + HRESULT get_Locator( + [out] ILocator **Locator); + + HRESULT put_Locator( + [in] ILocator *Locator); +} + +[ + object, + nonextensible, + uuid(0369B4E0-45B6-11d3-B650-00C04F79498E), + dual, + oleautomation, + pointer_default(unique) +] +interface IChannelTuneRequest : ITuneRequest +{ + HRESULT get_Channel( + [out] long *Channel); + + HRESULT put_Channel( + [in] long Channel); +} + +[ + object, + nonextensible, + uuid(0369B4E1-45B6-11d3-B650-00C04F79498E), + dual, + oleautomation, + pointer_default(unique) +] +interface IATSCChannelTuneRequest : IChannelTuneRequest +{ + HRESULT get_MinorChannel( + [out] long *MinorChannel); + + HRESULT put_MinorChannel( + [in] long MinorChannel); +} + +[ + object, + nonextensible, + uuid(BAD7753B-6B37-4810-AE57-3CE0C4A9E6CB), + dual, + oleautomation, + pointer_default(unique) +] +interface IDigitalCableTuneRequest : IATSCChannelTuneRequest +{ + HRESULT get_MajorChannel( + [out] long *pMajorChannel); + + HRESULT put_MajorChannel( + [in] long MajorChannel); + + HRESULT get_SourceID( + [out] long *pSourceID); + + HRESULT put_SourceID( + [in] long SourceID); +} + + +[ + object, + nonextensible, + uuid(0D6F567E-A636-42bb-83BA-CE4C1704AFA2), + dual, + oleautomation, + pointer_default(unique) +] +interface IDVBTuneRequest : ITuneRequest +{ + HRESULT get_ONID( + [out] long *ONID); + + HRESULT put_ONID( + [in] long ONID); + + HRESULT get_TSID( + [out] long *TSID); + + HRESULT put_TSID( + [in] long TSID); + + HRESULT get_SID( + [out] long *SID); + + HRESULT put_SID( + [in] long SID); +} + +[ + object, + nonextensible, + uuid(EB7D987F-8A01-42ad-B8AE-574DEEE44D1A), + dual, + oleautomation, + pointer_default(unique) +] +interface IMPEG2TuneRequest : ITuneRequest +{ + HRESULT get_TSID( + [out] long *TSID); + + HRESULT put_TSID( + [in] long TSID); + + HRESULT get_ProgNo( + [out] long *ProgNo); + + HRESULT put_ProgNo( + [in] long ProgNo); +} + +[ + object, + nonextensible, + hidden, + uuid(14E11ABD-EE37-4893-9EA1-6964DE933E39), + dual, + oleautomation, + pointer_default(unique) +] +interface IMPEG2TuneRequestFactory : IDispatch +{ + HRESULT CreateTuneRequest( + [in] ITuningSpace *TuningSpace, + [out] IMPEG2TuneRequest **TuneRequest); +} + +[ + object, + hidden, + restricted, + nonextensible, + uuid(1B9D5FC3-5BBC-4b6c-BB18-B9D10E3EEEBF), + pointer_default(unique) +] +interface IMPEG2TuneRequestSupport : IUnknown +{ +} + +[ + object, + hidden, + nonextensible, + uuid(E60DFA45-8D56-4e65-A8AB-D6BE9412C249), + pointer_default(unique) +] +interface ITunerCap : IUnknown +{ + HRESULT get_SupportedNetworkTypes( + [in] ULONG ulcNetworkTypesMax, + [out] ULONG *pulcNetworkTypes, + [in, out] GUID *pguidNetworkTypes); + + HRESULT get_SupportedVideoFormats( + [out] ULONG *pulAMTunerModeType, + [out] ULONG *pulAnalogVideoStandard); + + HRESULT get_AuxInputCount( + [in, out] ULONG *pulCompositeCount, + [in, out] ULONG *pulSvideoCount); +} + +[ + object, + hidden, + nonextensible, + uuid(28C52640-018A-11d3-9D8E-00C04F72D980), + pointer_default(unique) +] +interface ITuner : IUnknown +{ + HRESULT get_TuningSpace( + [out] ITuningSpace **TuningSpace); + + HRESULT put_TuningSpace( + [in] ITuningSpace *TuningSpace); + + HRESULT EnumTuningSpaces( + [out] IEnumTuningSpaces **ppEnum); + + HRESULT get_TuneRequest( + [out] ITuneRequest **TuneRequest); + + HRESULT put_TuneRequest( + [in] ITuneRequest *TuneRequest); + + HRESULT Validate( + [in] ITuneRequest *TuneRequest); + + HRESULT get_PreferredComponentTypes( + [out] IComponentTypes **ComponentTypes); + + HRESULT put_PreferredComponentTypes( + [in] IComponentTypes *ComponentTypes); + + HRESULT get_SignalStrength( + [out] long *Strength); + + HRESULT TriggerSignalEvents( + [in] long Interval); +} + +[ + object, + hidden, + nonextensible, + uuid(1DFD0A5C-0284-11d3-9D8E-00C04F72D980), + pointer_default(unique) +] +interface IScanningTuner : ITuner +{ + HRESULT SeekUp(); + + HRESULT SeekDown(); + + HRESULT ScanUp( + [in] long MillisecondsPause); + + HRESULT ScanDown( + [in] long MillisecondsPause); + + HRESULT AutoProgram(); +}; + +[ + object, + hidden, + nonextensible, + uuid(04BBD195-0E2D-4593-9BD5-4F908BC33CF5), + pointer_default(unique) +] +interface IScanningTunerEx : IScanningTuner +{ + HRESULT GetCurrentLocator( + [in]ILocator **pILocator); + + HRESULT PerformExhaustiveScan( + [in] long dwLowerFreq, + [in] long dwHigherFreq, + [in] VARIANT_BOOL bFineTune, + [in] HEVENT hEvent); + + HRESULT TerminateCurrentScan( + [out] long *pcurrentFreq); + + HRESULT ResumeCurrentScan( + [in] HEVENT hEvent); + + HRESULT GetTunerScanningCapability( + [out] long *HardwareAssistedScanning, + [out] long *NumStandardsSupported, + [out] GUID *BroadcastStandards); + + HRESULT GetTunerStatus( + [out] long *SecondsLeft, + [out] long *CurrentLockType, + [out] long *AutoDetect, + [out] long *CurrentFreq); + + HRESULT GetCurrentTunerStandardCapability( + [in] GUID CurrentBroadcastStandard, + [out] long *SettlingTime, + [out] long *TvStandardsSupported); + + HRESULT SetScanSignalTypeFilter( + [in] long ScanModulationTypes, + [in] long AnalogVideoStandard); +}; + +[ + object, + hidden, + nonextensible, + uuid(6A340DC0-0311-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponentType : IDispatch +{ + HRESULT get_Category( + [out] ComponentCategory *Category); + + HRESULT put_Category( + [in] ComponentCategory Category); + + HRESULT get_MediaMajorType( + [out] BSTR *MediaMajorType); + + HRESULT put_MediaMajorType( + [in] BSTR MediaMajorType); + + HRESULT get__MediaMajorType( + [out] GUID* MediaMajorTypeGuid); + + HRESULT put__MediaMajorType( + [in] REFCLSID MediaMajorTypeGuid); + + HRESULT get_MediaSubType( + [out] BSTR *MediaSubType); + + HRESULT put_MediaSubType( + [in] BSTR MediaSubType); + + HRESULT get__MediaSubType( + [out] GUID* MediaSubTypeGuid); + + HRESULT put__MediaSubType( + [in] REFCLSID MediaSubTypeGuid); + + HRESULT get_MediaFormatType( + [out] BSTR *MediaFormatType); + + HRESULT put_MediaFormatType( + [in] BSTR MediaFormatType); + + HRESULT get__MediaFormatType( + [out] GUID* MediaFormatTypeGuid); + + HRESULT put__MediaFormatType( + [in] REFCLSID MediaFormatTypeGuid); + + HRESULT get_MediaType( + [out] AM_MEDIA_TYPE *MediaType); + + HRESULT put_MediaType( + [in] AM_MEDIA_TYPE *MediaType); + + HRESULT Clone( + [out] IComponentType **NewCT); +}; + +[ + object, + hidden, + nonextensible, + uuid(B874C8BA-0FA2-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface ILanguageComponentType : IComponentType +{ + HRESULT get_LangID( + [out] long *LangID); + + HRESULT put_LangID( + [in] long LangID); +}; + +[ + object, + hidden, + nonextensible, + uuid(2C073D84-B51C-48c9-AA9F-68971E1F6E38), + dual, + oleautomation, + pointer_default(unique) +] +interface IMPEG2ComponentType : ILanguageComponentType +{ + HRESULT get_StreamType( + [out] MPEG2StreamType *MP2StreamType); + + HRESULT put_StreamType( + [in] MPEG2StreamType MP2StreamType); +}; + + +[ + object, + hidden, + nonextensible, + uuid(FC189E4D-7BD4-4125-B3B3-3A76A332CC96), + dual, + oleautomation, + pointer_default(unique) +] +interface IATSCComponentType : IMPEG2ComponentType +{ + HRESULT get_Flags( + [out] long *Flags); + + HRESULT put_Flags( + [in] long flags); +}; + +[ + hidden, restricted, + object, + uuid(8A674B4A-1F63-11d3-B64C-00C04F79498E), + pointer_default(unique) +] +interface IEnumComponentTypes : IUnknown +{ + HRESULT Next( + [in] ULONG celt, + [in, out]IComponentType** rgelt, + [out] ULONG* pceltFetched); + + HRESULT Skip( + [in] ULONG celt); + + HRESULT Reset(void); + + HRESULT Clone( + [out] IEnumComponentTypes** ppEnum); +} + +[ + object, + hidden, + nonextensible, + uuid(0DC13D4A-0313-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponentTypes : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT **ppNewEnum); + + HRESULT EnumComponentTypes( + [out] IEnumComponentTypes **ppNewEnum); + + HRESULT get_Item( + [in] VARIANT Index, + [out] IComponentType **ComponentType); + + HRESULT put_Item( + [in] VARIANT Index, + [in] IComponentType *ComponentType); + + HRESULT Add( + [in] IComponentType *ComponentType, + [out] VARIANT *NewIndex); + + HRESULT Remove( + [in] VARIANT Index); + + HRESULT Clone([out] IComponentTypes **NewList); +}; + +[ + object, + nonextensible, + uuid(1A5576FC-0E19-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponent : IDispatch +{ + HRESULT get_Type( + [out] IComponentType** CT); + + HRESULT put_Type( + [in] IComponentType* CT); + + HRESULT get_DescLangID( + [out] long *LangID); + + HRESULT put_DescLangID( + [in] long LangID); + + HRESULT get_Status( + [out] ComponentStatus *Status); + + HRESULT put_Status( + [in] ComponentStatus Status); + + HRESULT get_Description( + [out] BSTR *Description); + + HRESULT put_Description( + [in] BSTR Description); + + HRESULT Clone( + [out] IComponent **NewComponent); + +}; + +[ + object, + nonextensible, + uuid(2CFEB2A8-1787-4A24-A941-C6EAEC39C842), + dual, + oleautomation, + pointer_default(unique) +] +interface IAnalogAudioComponentType : IComponentType +{ + HRESULT get_AnalogAudioMode( + [out] TVAudioMode *Mode); + + HRESULT put_AnalogAudioMode( + [in] TVAudioMode Mode); +} + +[ + object, + nonextensible, + uuid(1493E353-1EB6-473c-802D-8E6B8EC9D2A9), + dual, + oleautomation, + pointer_default(unique) +] +interface IMPEG2Component : IComponent +{ + HRESULT get_PID( + [out] long *PID); + + HRESULT put_PID( + [in] long PID); + + HRESULT get_PCRPID( + [out] long *PCRPID); + + HRESULT put_PCRPID( + [in] long PCRPID); + + HRESULT get_ProgramNumber( + [out] long *ProgramNumber); + + HRESULT put_ProgramNumber( + [in] long ProgramNumber); +}; + +[ + hidden, + restricted, + object, + uuid(2A6E2939-2595-11d3-B64C-00C04F79498E), + pointer_default(unique) +] +interface IEnumComponents : IUnknown +{ + HRESULT Next( + [in] ULONG celt, + [in, out]IComponent** rgelt, + [out] ULONG* pceltFetched); + + HRESULT Skip( + [in] ULONG celt); + + HRESULT Reset(void); + + HRESULT Clone( + [out] IEnumComponents** ppEnum); +} + + + +[ + object, + nonextensible, + uuid(39A48091-FFFE-4182-A161-3FF802640E26), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponents : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT **ppNewEnum); + + HRESULT EnumComponents( + [out] IEnumComponents **ppNewEnum); + + HRESULT get_Item( + [in] VARIANT Index, + [out] IComponent **ppComponent); + + HRESULT Add( + [in] IComponent *Component, + [out] VARIANT *NewIndex); + + HRESULT Remove( + [in] VARIANT Index); + + HRESULT Clone( + [out] IComponents **NewList); + + HRESULT put_Item( + [in] VARIANT Index, + [in] IComponent *ppComponent); + +}; + +[ + object, + nonextensible, + uuid(FCD01846-0E19-11d3-9D8E-00C04F72D980), + dual, + oleautomation, + pointer_default(unique) +] +interface IComponentsOld : IDispatch +{ + HRESULT get_Count( + [out] long *Count); + + HRESULT get__NewEnum( + [out] IEnumVARIANT **ppNewEnum); + + HRESULT EnumComponents( + [out] IEnumComponents **ppNewEnum); + + HRESULT get_Item( + [in] VARIANT Index, + [out] IComponent **ppComponent); + + HRESULT Add( + [in] IComponent *Component, + [out] VARIANT *NewIndex); + + HRESULT Remove( + [in] VARIANT Index); + + HRESULT Clone( + [out] IComponents **NewList); + +}; + +[ + object, + nonextensible, + uuid(286D7F89-760C-4F89-80C4-66841D2507AA), + dual, + oleautomation, + pointer_default(unique) +] +interface ILocator : IDispatch +{ + + HRESULT get_CarrierFrequency( + [out] long* Frequency); + + HRESULT put_CarrierFrequency( + [in] long Frequency); + + HRESULT get_InnerFEC( + [out] FECMethod* FEC); + + HRESULT put_InnerFEC( + [in] FECMethod FEC); + + HRESULT get_InnerFECRate( + [out] BinaryConvolutionCodeRate* FEC); + + HRESULT put_InnerFECRate( + [in] BinaryConvolutionCodeRate FEC); + + HRESULT get_OuterFEC( + [out] FECMethod* FEC); + + HRESULT put_OuterFEC( + [in] FECMethod FEC); + + HRESULT get_OuterFECRate( + [out] BinaryConvolutionCodeRate* FEC); + + HRESULT put_OuterFECRate( + [in] BinaryConvolutionCodeRate FEC); + + HRESULT get_Modulation( + [out] ModulationType* Modulation); + + HRESULT put_Modulation( + [in] ModulationType Modulation); + + HRESULT get_SymbolRate( + [out] long* Rate); + + HRESULT put_SymbolRate( + [in] long Rate); + + HRESULT Clone( + [out] ILocator **NewLocator); +}; + +[ + object, + nonextensible, + uuid(34D1F26B-E339-430D-ABCE-738CB48984DC), + dual, + oleautomation, + pointer_default(unique) +] +interface IAnalogLocator : ILocator +{ + HRESULT get_VideoStandard( + [out] AnalogVideoStandard* AVS); + + HRESULT put_VideoStandard( + [in] AnalogVideoStandard AVS); +} + +[ + object, + nonextensible, + uuid(19B595D8-839A-47F0-96DF-4F194F3C768C), + dual, + oleautomation, + pointer_default(unique) +] +interface IDigitalLocator : ILocator +{ +}; + +[ + object, + hidden, + nonextensible, + uuid(BF8D986F-8C2B-4131-94D7-4D3D9FCC21EF), + dual, + oleautomation, + pointer_default(unique) +] +interface IATSCLocator : IDigitalLocator +{ + HRESULT get_PhysicalChannel( + [out] long *PhysicalChannel); + + HRESULT put_PhysicalChannel( + [in] long PhysicalChannel); + + HRESULT get_TSID( + [out] long *TSID); + + HRESULT put_TSID( + [in] long TSID); +}; + +[ + object, + hidden, + nonextensible, + uuid(612AA885-66CF-4090-BA0A-566F5312E4CA), + dual, + oleautomation, + pointer_default(unique) +] +interface IATSCLocator2 : IATSCLocator +{ + HRESULT get_ProgramNumber( + [out] long *ProgramNumber); + + HRESULT put_ProgramNumber( + [in] long ProgramNumber); +}; + +[ + object, + hidden, + nonextensible, + uuid(48F66A11-171A-419A-9525-BEEECD51584C), + dual, + oleautomation, + pointer_default(unique) +] +interface IDigitalCableLocator : IATSCLocator2 +{ +} + +[ + object, + hidden, + nonextensible, + uuid(8664DA16-DDA2-42ac-926A-C18F9127C302), + dual, + oleautomation, + pointer_default(unique) +] +interface IDVBTLocator : IDigitalLocator +{ + HRESULT get_Bandwidth( + [out] long* BandWidthVal); + + HRESULT put_Bandwidth( + [in] long BandwidthVal); + + HRESULT get_LPInnerFEC( + [out] FECMethod* FEC); + + HRESULT put_LPInnerFEC( + [in] FECMethod FEC); + + HRESULT get_LPInnerFECRate( + [out] BinaryConvolutionCodeRate* FEC); + + HRESULT put_LPInnerFECRate( + [in] BinaryConvolutionCodeRate FEC); + + HRESULT get_HAlpha( + [out] HierarchyAlpha* Alpha); + + HRESULT put_HAlpha( + [in] HierarchyAlpha Alpha); + + HRESULT get_Guard( + [out] GuardInterval* GI); + + HRESULT put_Guard( + [in] GuardInterval GI); + + HRESULT get_Mode( + [out] TransmissionMode* mode); + + HRESULT put_Mode( + [in] TransmissionMode mode); + + HRESULT get_OtherFrequencyInUse( + [out] VARIANT_BOOL* OtherFrequencyInUseVal); + + HRESULT put_OtherFrequencyInUse( + [in] VARIANT_BOOL OtherFrequencyInUseVal); +}; + +[ + object, + hidden, + nonextensible, + uuid(3D7C353C-0D04-45f1-A742-F97CC1188DC8), + dual, + oleautomation, + pointer_default(unique) +] +interface IDVBSLocator : IDigitalLocator +{ + + HRESULT get_SignalPolarisation( + [out] Polarisation* PolarisationVal); + + HRESULT put_SignalPolarisation( + [in] Polarisation PolarisationVal); + + HRESULT get_WestPosition( + [out] VARIANT_BOOL* WestLongitude); + + HRESULT put_WestPosition( + [in] VARIANT_BOOL WestLongitude); + + HRESULT get_OrbitalPosition( + [out] long* longitude); + + HRESULT put_OrbitalPosition( + [in] long longitude); + + HRESULT get_Azimuth( + [out] long* Azimuth); + + HRESULT put_Azimuth( + [in] long Azimuth); + + HRESULT get_Elevation( + [out] long* Elevation); + + HRESULT put_Elevation( + [in] long Elevation); +}; + +[ + object, + hidden, + nonextensible, + uuid(6E42F36E-1DD2-43c4-9F78-69D25AE39034), + dual, + oleautomation, + pointer_default(unique) +] +interface IDVBCLocator : IDigitalLocator +{ +}; +[ + object, + hidden, + nonextensible, + uuid(3B21263F-26E8-489d-AAC4-924F7EFD9511), + pointer_default(unique) +] +interface IBroadcastEvent : IUnknown +{ + HRESULT Fire([in] GUID EventID); +}; + +[ + object, + hidden, + nonextensible, + uuid(3d9e3887-1929-423f-8021-43682de95448), + pointer_default(unique) +] +interface IBroadcastEventEx : IBroadcastEvent +{ + HRESULT FireEx( + [in] GUID EventID, + [in] ULONG Param1, + [in] ULONG Param2, + [in] ULONG Param3, + [in] ULONG Param4); +}; + +[ + object, + hidden, + nonextensible, + uuid(359B3901-572C-4854-BB49-CDEF66606A25), + pointer_default(unique) +] +interface IRegisterTuner : IUnknown +{ + HRESULT Register( + [in] ITuner* pTuner, + [in] IGraphBuilder* pGraph); + + HRESULT Unregister(); +}; + +[ + object, + hidden, + nonextensible, + uuid(B34505E0-2F0E-497b-80BC-D43F3B24ED7F), + pointer_default(unique) +] +interface IBDAComparable : IUnknown +{ + HRESULT CompareExact( + [in] IDispatch* CompareTo, + [out] long* Result); + + HRESULT CompareEquivalent( + [in] IDispatch* CompareTo, + [in] DWORD dwFlags, + [out] long* Result); + + HRESULT HashExact( + [out] __int64* Result); + + HRESULT HashExactIncremental( + [in] __int64 PartialResult, + [out] __int64* Result); + + HRESULT HashEquivalent( + [in] DWORD dwFlags, + [out] __int64* Result); + + HRESULT HashEquivalentIncremental( + [in] __int64 PartialResult, + [in] DWORD dwFlags, + [out] __int64* Result); +}; + +[ + uuid(9B085638-018E-11d3-9D8E-00C04F72D980), + version(1.0), +] +library TunerLib +{ + importlib("stdole2.tlb"); + +[ + uuid(D02AAC50-027E-11d3-9D8E-00C04F72D980) +] + + coclass SystemTuningSpaces +{ + [default] interface ITuningSpaceContainer; +}; + +[ + noncreatable, + hidden, + uuid(5FFDC5E6-B83A-4b55-B6E8-C69E765FE9DB) +] + coclass TuningSpace +{ + [default] interface ITuningSpace; + interface IBDAComparable; +}; + + +[ + uuid(A2E30750-6C3D-11d3-B653-00C04F79498E) +] + coclass ATSCTuningSpace +{ + [default] interface IATSCTuningSpace; + interface IBDAComparable; +}; + +[ + uuid(D9BB4CEE-B87A-47F1-AC92-B08D9C7813FC) +] + coclass DigitalCableTuningSpace +{ + [default] interface IDigitalCableTuningSpace; + interface IBDAComparable; +}; + + +[ + uuid(8A674B4C-1F63-11d3-B64C-00C04F79498E) +] + coclass AnalogRadioTuningSpace +{ + [default] interface IAnalogRadioTuningSpace2; + interface IAnalogRadioTuningSpace; + interface IBDAComparable; +}; + +[ + uuid(F9769A06-7ACA-4e39-9CFB-97BB35F0E77E) +] + coclass AuxInTuningSpace +{ + interface IAuxInTuningSpace; + [default] interface IAuxInTuningSpace2; + interface IBDAComparable; +}; + +[ + uuid(8A674B4D-1F63-11d3-B64C-00C04F79498E) +] + coclass AnalogTVTuningSpace +{ + [default] interface IAnalogTVTuningSpace; + interface IBDAComparable; +}; + +[ + uuid(C6B14B32-76AA-4a86-A7AC-5C79AAF58DA7) +] + coclass DVBTuningSpace +{ + [default] interface IDVBTuningSpace2; + interface IDVBTuningSpace; + interface IBDAComparable; +}; + +[ + uuid(B64016F3-C9A2-4066-96F0-BD9563314726) +] + coclass DVBSTuningSpace +{ + [default] interface IDVBSTuningSpace; + interface IBDAComparable; +}; + + +[ + uuid(A1A2B1C4-0E3A-11d3-9D8E-00C04F72D980) +] + coclass ComponentTypes +{ + [default] interface IComponentTypes; + }; + +[ + uuid(823535A0-0318-11d3-9D8E-00C04F72D980) +] + coclass ComponentType +{ + [default] interface IComponentType; + }; + +[ + uuid(1BE49F30-0E1B-11d3-9D8E-00C04F72D980) +] + coclass LanguageComponentType +{ + [default] interface ILanguageComponentType; + }; + +[ + uuid(418008F3-CF67-4668-9628-10DC52BE1D08) +] + coclass MPEG2ComponentType +{ + [default] interface IMPEG2ComponentType; + }; + +[ + uuid(A8DCF3D5-0780-4ef4-8A83-2CFFAACB8ACE) +] + coclass ATSCComponentType +{ + [default] interface IATSCComponentType; + }; + +[ + hidden, + uuid(809B6661-94C4-49e6-B6EC-3F0F862215AA) +] + coclass Components +{ + [default] interface IComponents; + interface IComponentsOld; +}; + +[ + hidden, + uuid(59DC47A8-116C-11d3-9D8E-00C04F72D980) +] + coclass Component +{ + [default] interface IComponent; + }; + +[ + hidden, + uuid(055CB2D7-2969-45cd-914B-76890722F112) +] + coclass MPEG2Component +{ + [default] interface IMPEG2Component; + }; + + +[ + hidden, + uuid(28AB0005-E845-4FFA-AA9B-F4665236141C) +] + coclass AnalogAudioComponentType +{ + [default] interface IAnalogAudioComponentType; + }; + +[ + noncreatable, + hidden, + uuid(B46E0D38-AB35-4a06-A137-70576B01B39F) +] + coclass TuneRequest +{ + [default] interface ITuneRequest; + interface IBDAComparable; +}; + + +[ + hidden, + uuid(0369B4E5-45B6-11d3-B650-00C04F79498E) +] + coclass ChannelTuneRequest +{ + [default] interface IChannelTuneRequest; + interface IBDAComparable; +}; + +[ + hidden, + uuid(0369B4E6-45B6-11d3-B650-00C04F79498E) +] + coclass ATSCChannelTuneRequest +{ + [default] interface IATSCChannelTuneRequest; + interface IBDAComparable; +}; + +[ + hidden, + uuid(26EC0B63-AA90-458A-8DF4-5659F2C8A18A) +] + coclass DigitalCableTuneRequest +{ + [default] interface IDigitalCableTuneRequest; + interface IBDAComparable; +}; + + +[ + hidden, + uuid(0955AC62-BF2E-4cba-A2B9-A63F772D46CF) +] + coclass MPEG2TuneRequest +{ + [default] interface IMPEG2TuneRequest; + interface IBDAComparable; +}; + +[ + uuid(2C63E4EB-4CEA-41b8-919C-E947EA19A77C) +] + coclass MPEG2TuneRequestFactory +{ + [default] interface IMPEG2TuneRequestFactory; +}; + + +[ + noncreatable, + hidden, + uuid(0888C883-AC4F-4943-B516-2C38D9B34562) +] + coclass Locator +{ + [default] interface ILocator; + interface IBDAComparable; +}; +[ + noncreatable, + hidden, + uuid(6E50CC0D-C19B-4BF6-810B-5BD60761F5CC) +] + coclass DigitalLocator +{ + [default] interface IDigitalLocator; + interface IBDAComparable; +}; + +[ + uuid(49638B91-48AB-48B7-A47A-7D0E75A08EDE) +] + coclass AnalogLocator +{ + [default] interface IAnalogLocator; + interface IBDAComparable; +}; + +[ + uuid(8872FF1B-98FA-4d7a-8D93-C9F1055F85BB) +] + coclass ATSCLocator +{ + [default] interface IATSCLocator2; + interface IATSCLocator; + interface IBDAComparable; +}; + +[ + uuid(03C06416-D127-407A-AB4C-FDD279ABBE5D) +] + coclass DigitalCableLocator +{ + [default] interface IDigitalCableLocator; + interface IBDAComparable; +}; + +[ + uuid(9CD64701-BDF3-4d14-8E03-F12983D86664) +] + coclass DVBTLocator +{ + [default] interface IDVBTLocator; + interface IBDAComparable; +}; + +[ + uuid(1DF7D126-4050-47f0-A7CF-4C4CA9241333) +] + coclass DVBSLocator +{ + [default] interface IDVBSLocator; + interface IBDAComparable; +}; + +[ + uuid(C531D9FD-9685-4028-8B68-6E1232079F1E) +] + coclass DVBCLocator +{ + [default] interface IDVBCLocator; + interface IBDAComparable; +}; + +[ + hidden, + uuid(15D6504A-5494-499c-886C-973C9E53B9F1) +] + coclass DVBTuneRequest +{ + [default] interface IDVBTuneRequest; + interface IBDAComparable; +}; + + +[ + hidden, + uuid(8A674B49-1F63-11d3-B64C-00C04F79498E) +] + coclass CreatePropBagOnRegKey +{ + interface ICreatePropBagOnRegKey; +}; + +[ + hidden, + uuid(0B3FFB92-0919-4934-9D5B-619C719D0202) +] + coclass BroadcastEventService +{ + interface IBroadcastEvent; +}; + +[ + hidden, + uuid(6438570B-0C08-4a25-9504-8012BB4D50CF) +] + coclass TunerMarshaler +{ + interface IRegisterTuner; + interface ITuner; +}; + +cpp_quote("#define SID_SBroadcastEventService CLSID_BroadcastEventService") +cpp_quote("#define SID_SContentTuneRequest IID_ITuner") +cpp_quote("#define SID_ScanningTuner IID_IScanningTuner") +cpp_quote("#define SID_ScanningTunerEx IID_IScanningTunerEx") +} diff --git a/include/psdk/urlmon.idl b/include/psdk/urlmon.idl index 78afd1691c9..d16a3b5d7ec 100644 --- a/include/psdk/urlmon.idl +++ b/include/psdk/urlmon.idl @@ -1646,6 +1646,62 @@ interface IUri : IUnknown [out] BOOL *pfEqual); } +cpp_quote("HRESULT WINAPI CreateUri(LPCWSTR,DWORD,DWORD_PTR,IUri**);") +cpp_quote("HRESULT WINAPI CreateUriWithFragment(LPCWSTR,LPCWSTR,DWORD,DWORD_PTR,IUri**);") +cpp_quote("HRESULT WINAPI CreateUriFromMultiByteString(LPCSTR,DWORD,DWORD,DWORD,DWORD_PTR,IUri**);") + +cpp_quote("#define Uri_HAS_ABSOLUTE_URI (1 << Uri_PROPERTY_ABSOLUTE_URI)") +cpp_quote("#define Uri_HAS_AUTHORITY (1 << Uri_PROPERTY_AUTHORITY)") +cpp_quote("#define Uri_HAS_DISPLAY_URI (1 << Uri_PROPERTY_DISPLAY_URI)") +cpp_quote("#define Uri_HAS_DOMAIN (1 << Uri_PROPERTY_DOMAIN)") +cpp_quote("#define Uri_HAS_EXTENSION (1 << Uri_PROPERTY_EXTENSION)") +cpp_quote("#define Uri_HAS_FRAGMENT (1 << Uri_PROPERTY_FRAGMENT)") +cpp_quote("#define Uri_HAS_HOST (1 << Uri_PROPERTY_HOST)") +cpp_quote("#define Uri_HAS_PASSWORD (1 << Uri_PROPERTY_PASSWORD)") +cpp_quote("#define Uri_HAS_PATH (1 << Uri_PROPERTY_PATH)") +cpp_quote("#define Uri_HAS_QUERY (1 << Uri_PROPERTY_QUERY)") +cpp_quote("#define Uri_HAS_RAW_URI (1 << Uri_PROPERTY_RAW_URI)") +cpp_quote("#define Uri_HAS_SCHEME_NAME (1 << Uri_PROPERTY_SCHEME_NAME)") +cpp_quote("#define Uri_HAS_USER_NAME (1 << Uri_PROPERTY_USER_NAME)") +cpp_quote("#define Uri_HAS_PATH_AND_QUERY (1 << Uri_PROPERTY_PATH_AND_QUERY)") +cpp_quote("#define Uri_HAS_USER_INFO (1 << Uri_PROPERTY_USER_INFO)") +cpp_quote("#define Uri_HAS_HOST_TYPE (1 << Uri_PROPERTY_HOST_TYPE)") +cpp_quote("#define Uri_HAS_PORT (1 << Uri_PROPERTY_PORT)") +cpp_quote("#define Uri_HAS_SCHEME (1 << Uri_PROPERTY_SCHEME)") +cpp_quote("#define Uri_HAS_ZONE (1 << Uri_PROPERTY_ZONE)") + +cpp_quote("#define Uri_CREATE_ALLOW_RELATIVE 0x0001") +cpp_quote("#define Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME 0x0002") +cpp_quote("#define Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME 0x0004") +cpp_quote("#define Uri_CREATE_NOFRAG 0x0008") +cpp_quote("#define Uri_CREATE_NO_CANONICALIZE 0x0010") +cpp_quote("#define Uri_CREATE_CANONICALIZE 0x0100") +cpp_quote("#define Uri_CREATE_FILE_USE_DOS_PATH 0x0020") +cpp_quote("#define Uri_CREATE_DECODE_EXTRA_INFO 0x0040") +cpp_quote("#define Uri_CREATE_NO_DECODE_EXTRA_INFO 0x0080") +cpp_quote("#define Uri_CREATE_CRACK_UNKNOWN_SCHEMES 0x0200") +cpp_quote("#define Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES 0x0400") +cpp_quote("#define Uri_CREATE_PRE_PROCESS_HTML_URI 0x0800") +cpp_quote("#define Uri_CREATE_NO_PRE_PROCESS_HTML_URI 0x1000") +cpp_quote("#define Uri_CREATE_IE_SETTINGS 0x2000") +cpp_quote("#define Uri_CREATE_NO_IE_SETTINGS 0x4000") +cpp_quote("#define Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS 0x8000") + +cpp_quote("#define Uri_DISPLAY_NO_FRAGMENT 0x00000001") +cpp_quote("#define Uri_PUNYCODE_IDN_HOST 0x00000002") +cpp_quote("#define Uri_DISPLAY_IDN_HOST 0x00000004") + +cpp_quote("#define Uri_ENCODING_USER_INFO_AND_PATH_IS_PERCENT_ENCODED_UTF8 0x00000001") +cpp_quote("#define Uri_ENCODING_USER_INFO_AND_PATH_IS_CP 0x00000002") +cpp_quote("#define Uri_ENCODING_HOST_IS_IDN 0x00000004") +cpp_quote("#define Uri_ENCODING_HOST_IS_PERCENT_ENCODED_UTF8 0x00000008") +cpp_quote("#define Uri_ENCODING_HOST_IS_PERCENT_ENCODED_CP 0x00000010") +cpp_quote("#define Uri_ENCODING_QUERY_AND_FRAGMENT_IS_PERCENT_ENCODED_UTF8 0x00000020") +cpp_quote("#define Uri_ENCODING_QUERY_AND_FRAGMENT_IS_CP 0x00000040") +cpp_quote("#define Uri_ENCODING_RFC (Uri_ENCODING_USER_INFO_AND_PATH_IS_PERCENT_ENCODED_UTF8|Uri_ENCODING_HOST_IS_PERCENT_ENCODED_UTF8|Uri_ENCODING_QUERY_AND_FRAGMENT_IS_PERCENT_ENCODED_UTF8)") + +cpp_quote("#define UriBuilder_USE_ORIGINAL_FLAGS 0x00000001") + /***************************************************************************** * IUriContainer interface */ @@ -1740,6 +1796,8 @@ cpp_quote("#define INET_E_DEFAULT_ACTION INET_E_USE_DEFAULT_PROTOCOLH cpp_quote("HRESULT WINAPI CoGetClassObjectFromURL(REFCLSID, LPCWSTR, DWORD, DWORD, LPCWSTR, LPBINDCTX, DWORD, LPVOID, REFIID, LPVOID*);") cpp_quote("HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk);") +cpp_quote("HRESULT WINAPI CreateURLMonikerEx(IMoniker*,LPCWSTR,IMoniker**,DWORD);") +cpp_quote("HRESULT WINAPI CreateURLMonikerEx2(IMoniker*,IUri*,IMoniker**,DWORD);") cpp_quote("HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc, IBindStatusCallback **ppbsc, DWORD dwReserved);") cpp_quote("HRESULT WINAPI CompareSecurityIds(BYTE*,DWORD,BYTE*,DWORD,DWORD);") cpp_quote("HRESULT WINAPI URLDownloadToFileA(LPUNKNOWN,LPCSTR,LPCSTR,DWORD,LPBINDSTATUSCALLBACK);") @@ -1758,6 +1816,7 @@ cpp_quote("HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider*, IIntern cpp_quote("HRESULT WINAPI CoInternetParseUrl(LPCWSTR,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD);") cpp_quote("HRESULT WINAPI CoInternetQueryInfo(LPCWSTR,QUERYOPTION,DWORD,LPVOID,DWORD,DWORD*,DWORD);") cpp_quote("HRESULT WINAPI CoInternetSetFeatureEnabled(INTERNETFEATURELIST,DWORD,BOOL);") +cpp_quote("HRESULT WINAPI CoInternetGetSecurityUrl(LPCWSTR,LPWSTR*,PSUACTION,DWORD);") cpp_quote("HRESULT WINAPI CreateFormatEnumerator(UINT,FORMATETC*,IEnumFORMATETC**);") cpp_quote("HRESULT WINAPI GetSoftwareUpdateInfo( LPCWSTR szDistUnit, LPSOFTDISTINFO psdi);") cpp_quote("HRESULT WINAPI FaultInIEFeature(HWND,uCLSSPEC*,QUERYCONTEXT*,DWORD);") diff --git a/include/psdk/winuser.h b/include/psdk/winuser.h index 56ddef53230..8700be78f5d 100644 --- a/include/psdk/winuser.h +++ b/include/psdk/winuser.h @@ -1993,11 +1993,16 @@ extern "C" { #define SBM_ENABLE_ARROWS 228 #define SBM_GETPOS 225 #define SBM_GETRANGE 227 -#define SBM_GETSCROLLINFO 234 #define SBM_SETPOS 224 #define SBM_SETRANGE 226 #define SBM_SETRANGEREDRAW 230 +#if (_WIN32_WINNT >= 0x0400) +#define SBM_GETSCROLLINFO 234 #define SBM_SETSCROLLINFO 233 +#endif +#if (_WIN32_WINNT >= 0x0501) +#define SBM_GETSCROLLBARINFO 235 +#endif #define STM_GETICON 369 #define STM_GETIMAGE 371 #define STM_SETICON 368 diff --git a/include/psdk/wtypes.idl b/include/psdk/wtypes.idl index 6a3f9a9109e..4a311ba5695 100644 --- a/include/psdk/wtypes.idl +++ b/include/psdk/wtypes.idl @@ -91,16 +91,13 @@ DECLARE_HANDLE(HWINSTA); DECLARE_HANDLE(HKL); DECLARE_HANDLE(HGDIOBJ); -cpp_quote("#if 0") -typedef HANDLE HMONITOR; -cpp_quote("#endif /* 0 */") - typedef HANDLE HDWP; typedef LONG_PTR LRESULT; typedef LONG HRESULT; typedef DWORD LCID; +typedef USHORT LANGID; typedef unsigned __int64 DWORDLONG; typedef __int64 LONGLONG; @@ -447,7 +444,7 @@ typedef struct tagRemHGLOBAL { typedef union _userHGLOBAL switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: FLAGGED_BYTE_BLOB *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHGLOBAL; typedef [unique] userHGLOBAL *wireHGLOBAL; @@ -463,7 +460,7 @@ typedef struct tagRemHMETAFILEPICT { typedef union _userHMETAFILE switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: BYTE_BLOB *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHMETAFILE; typedef [unique] userHMETAFILE *wireHMETAFILE; @@ -478,7 +475,7 @@ typedef struct _remoteMETAFILEPICT { typedef union _userHMETAFILEPICT switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: remoteMETAFILEPICT *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHMETAFILEPICT; typedef [unique] userHMETAFILEPICT *wireHMETAFILEPICT; @@ -491,7 +488,7 @@ typedef struct tagRemHENHMETAFILE { typedef union _userHENHMETAFILE switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: BYTE_BLOB *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHENHMETAFILE; typedef [unique] userHENHMETAFILE *wireHENHMETAFILE; @@ -516,7 +513,7 @@ typedef struct _userBITMAP { typedef union _userHBITMAP switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: userBITMAP *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHBITMAP; typedef [unique] userHBITMAP *wireHBITMAP; @@ -535,7 +532,7 @@ typedef struct tagrpcLOGPALETTE { typedef union _userHPALETTE switch(long fContext) u { case WDT_INPROC_CALL: long hInproc; case WDT_REMOTE_CALL: rpcLOGPALETTE *hRemote; - default: long hGlobal; + case WDT_INPROC64_CALL: __int64 hInproc64; } userHPALETTE; typedef [unique] userHPALETTE *wireHPALETTE; @@ -585,36 +582,6 @@ typedef struct tagMSG POINT pt; } MSG, *PMSG, *NPMSG, *LPMSG; -typedef struct tagCREATESTRUCTA { - LPVOID lpCreateParams; - HINSTANCE hInstance; - HMENU hMenu; - HWND hwndParent; - int cy; - int cx; - int y; - int x; - LONG style; - LPCSTR lpszName; - LPCSTR lpszClass; - DWORD dwExStyle; -} CREATESTRUCTA, *LPCREATESTRUCTA; - -typedef struct tagCREATESTRUCTW { - LPVOID lpCreateParams; - HINSTANCE hInstance; - HMENU hMenu; - HWND hwndParent; - int cy; - int cx; - int y; - int x; - LONG style; - LPCWSTR lpszName; - LPCWSTR lpszClass; - DWORD dwExStyle; -} CREATESTRUCTW, *LPCREATESTRUCTW; - cpp_quote("#endif") /******************** GUID TYPES ********************/ @@ -870,6 +837,15 @@ typedef union switch(DWORD tyspec) } ByObjectId; } uCLSSPEC; +cpp_quote("#ifndef PROPERTYKEY_DEFINED") +cpp_quote("#define PROPERTYKEY_DEFINED") +typedef struct _tagpropertykey +{ + GUID fmtid; + DWORD pid; +} PROPERTYKEY; +cpp_quote("#endif /*PROPERTYKEY_DEFINED*/") + } /* interface IWinTypes */ cpp_quote("#ifdef _MSC_VER") diff --git a/include/psdk/xmldom.idl b/include/psdk/xmldom.idl index 89263c4b75c..d5d51ff2588 100644 --- a/include/psdk/xmldom.idl +++ b/include/psdk/xmldom.idl @@ -21,10 +21,6 @@ import "ocidl.idl"; -cpp_quote("#ifndef __xmldom_h__") -cpp_quote("#define __xmldom_h__") -cpp_quote("#endif") - interface IXMLDOMImplementation; interface IXMLDOMNode; interface IXMLDOMDocumentFragment; @@ -268,7 +264,7 @@ interface IXMLDOMDocument : IXMLDOMNode [out,retval] VARIANT_BOOL *isSuccessful ); [propget, id(DISPID_READYSTATE)] - HRESULT readyState( [out,retval] long *value ); + HRESULT readyState( [out,retval] LONG *value ); [propget, id(DISPID_XMLDOM_DOCUMENT_PARSEERROR)] HRESULT parseError( [out,retval] IXMLDOMParseError **errorObj ); @@ -334,11 +330,11 @@ pointer_default(unique) interface IXMLDOMNodeList : IDispatch { [propget, id(DISPID_VALUE)] - HRESULT item( [in] long index, + HRESULT item( [in] LONG index, [out,retval] IXMLDOMNode **listItem ); [propget, id(DISPID_DOM_NODELIST_LENGTH)] - HRESULT length( [out,retval] long *listLength ); + HRESULT length( [out,retval] LONG *listLength ); [id(DISPID_XMLDOM_NODELIST_NEXTNODE)] HRESULT nextNode( [out,retval] IXMLDOMNode **nextItem ); @@ -375,11 +371,11 @@ interface IXMLDOMNamedNodeMap : IDispatch [out,retval] IXMLDOMNode **namedItem ); [propget, id(DISPID_VALUE)] - HRESULT item( [in] long index, + HRESULT item( [in] LONG index, [out,retval] IXMLDOMNode **listItem ); [propget, id(DISPID_DOM_NODELIST_LENGTH)] - HRESULT length( [out,retval] long *listLength ); + HRESULT length( [out,retval] LONG *listLength ); [id(DISPID_XMLDOM_NAMEDNODEMAP_GETQUALIFIEDITEM)] HRESULT getQualifiedItem( [in] BSTR baseName, @@ -435,27 +431,27 @@ interface IXMLDOMCharacterData : IXMLDOMNode HRESULT data( [in] BSTR data ); [propget, id(DISPID_DOM_DATA_LENGTH)] - HRESULT length( [out,retval] long *dataLength ); + HRESULT length( [out,retval] LONG *dataLength ); [id(DISPID_DOM_DATA_SUBSTRING)] - HRESULT substringData( [in] long offset, - [in] long count, + HRESULT substringData( [in] LONG offset, + [in] LONG count, [out,retval] BSTR *data ); [id(DISPID_DOM_DATA_APPEND)] HRESULT appendData( [in] BSTR data ); [id(DISPID_DOM_DATA_INSERT)] - HRESULT insertData( [in] long offset, + HRESULT insertData( [in] LONG offset, [in] BSTR data ); [id(DISPID_DOM_DATA_DELETE)] - HRESULT deleteData( [in] long offset, - [in] long count ); + HRESULT deleteData( [in] LONG offset, + [in] LONG count ); [id(DISPID_DOM_DATA_REPLACE)] - HRESULT replaceData( [in] long offset, - [in] long count, + HRESULT replaceData( [in] LONG offset, + [in] LONG count, [in] BSTR data ); } @@ -540,7 +536,7 @@ pointer_default(unique) interface IXMLDOMText : IXMLDOMCharacterData { [id(DISPID_DOM_TEXT_SPLITTEXT)] - HRESULT splitText( [in] long offset, + HRESULT splitText( [in] LONG offset, [out,retval] IXMLDOMText **rightHandTextNode ); } @@ -703,7 +699,7 @@ uuid (3efaa426-272f-11d2-836f-0000f87a7782) interface IXMLDOMParseError : IDispatch { [propget, id(DISPID_VALUE)] - HRESULT errorCode([retval, out] long *errCode); + HRESULT errorCode([retval, out] LONG *errCode); [propget, id(DISPID_DOM_ERROR_URL)] HRESULT url([retval, out] BSTR *p); @@ -715,13 +711,13 @@ interface IXMLDOMParseError : IDispatch HRESULT srcText([retval, out] BSTR *p); [propget, id(DISPID_DOM_ERROR_LINE)] - HRESULT line([retval, out] long *lineNo); + HRESULT line([retval, out] LONG *lineNo); [propget, id(DISPID_DOM_ERROR_LINEPOS)] - HRESULT linepos([retval, out] long * linePos); + HRESULT linepos([retval, out] LONG * linePos); [propget, id(DISPID_DOM_ERROR_FILEPOS)] - HRESULT filepos([retval, out] long * filePos); + HRESULT filepos([retval, out] LONG * filePos); } [ @@ -788,7 +784,7 @@ interface IXMLHttpRequest : IDispatch HRESULT abort(); [propget, id(7)] - HRESULT status([out, retval] long *plStatus); + HRESULT status([out, retval] LONG *plStatus); [propget, id(8)] HRESULT statusText([out, retval] BSTR *bstrStatus); @@ -806,7 +802,7 @@ interface IXMLHttpRequest : IDispatch HRESULT responseStream([out, retval] VARIANT *pvarBody); [propget, id(13)] - HRESULT readyState([out, retval] long *plState); + HRESULT readyState([out, retval] LONG *plState); [propput, id(14)] HRESULT onreadystatechange([in] IDispatch *pReadyStateSink); diff --git a/include/psdk/xmllite.idl b/include/psdk/xmllite.idl new file mode 100644 index 00000000000..552b5d646b9 --- /dev/null +++ b/include/psdk/xmllite.idl @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2010 Nikolay Sivov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import "unknwn.idl"; +import "objidl.idl"; +import "oaidl.idl"; + +typedef enum XmlNodeType { + XmlNodeType_None = 0, + XmlNodeType_Element = 1, + XmlNodeType_Attribute = 2, + XmlNodeType_Text = 3, + XmlNodeType_CDATA = 4, + XmlNodeType_ProcessingInstruction = 7, + XmlNodeType_Comment = 8, + XmlNodeType_DocumentType = 10, + XmlNodeType_Whitespace = 13, + XmlNodeType_EndElement = 15, + XmlNodeType_XmlDeclaration = 17, + _XmlNodeType_Last = 17 +} XmlNodeType; + +/* IXmlReader */ +[ + local, + object, + uuid(7279fc81-709d-4095-b63d-69fe4b0d9030), + pointer_default(unique) +] +interface IXmlReader : IUnknown +{ + HRESULT SetInput( [in] IUnknown *input); + HRESULT GetProperty( [in] UINT property, [out] LONG_PTR *value); + HRESULT SetProperty( [in] UINT property, [in] LONG_PTR value); + HRESULT Read( [out] XmlNodeType *node_type); + HRESULT GetNodeType( [out] XmlNodeType *node_type); + HRESULT MoveToFirstAttribute(void); + HRESULT MoveToNextAttribute(void); + HRESULT MoveToAttributeByName( [in] LPCWSTR local_name, + [in] LPCWSTR namespaceUri); + HRESULT MoveToElement(void); + HRESULT GetQualifiedName( [out] LPCWSTR *qualifiedName, + [out] UINT *qualifiedName_length); + HRESULT GetNamespaceUri( [out] LPCWSTR *namespaceUri, + [out] UINT *nnamespaceUri_length); + HRESULT GetLocalName( [out] LPCWSTR *local_name, + [out] UINT *locale_name_length); + HRESULT GetPrefix( [out] LPCWSTR *prefix, + [out] UINT *prefix_length); + HRESULT GetValue( [out] LPCWSTR *value, + [out] UINT *value_length); + HRESULT ReadValueChunk( [out] WCHAR *buffer, + [in] UINT chunk_size, + [in,out] UINT *read); + HRESULT GetBaseUri( [out] LPCWSTR *baseUri, + [out] UINT *baseUri_length); + BOOL IsDefault(void); + BOOL IsEmptyElement(void); + HRESULT GetLineNumber( [out] UINT *lineNumber); + HRESULT GetLinePosition( [out] UINT *linePosition); + HRESULT GetAttributeCount( [out] UINT *attributeCount); + HRESULT GetDepth( [out] UINT *depth); + BOOL IsEOF(void); +} + +/* IXmlReader state */ +cpp_quote("typedef enum XmlReadState") +cpp_quote("{") +cpp_quote(" XmlReadState_Initial = 0,") +cpp_quote(" XmlReadState_Interactive = 1,") +cpp_quote(" XmlReadState_Error = 2,") +cpp_quote(" XmlReadState_EndOfFile = 3,") +cpp_quote(" XmlReadState_Closed = 4") +cpp_quote("} XmlReadState;") + +/* IXmlReader properties */ +cpp_quote("typedef enum XmlReaderProperty") +cpp_quote("{") +cpp_quote(" XmlReaderProperty_MultiLanguage = 0,") +cpp_quote(" XmlReaderProperty_ConformanceLevel = XmlReaderProperty_MultiLanguage + 1,") +cpp_quote(" XmlReaderProperty_RandomAccess = XmlReaderProperty_ConformanceLevel + 1,") +cpp_quote(" XmlReaderProperty_XmlResolver = XmlReaderProperty_RandomAccess + 1,") +cpp_quote(" XmlReaderProperty_DtdProcessing = XmlReaderProperty_XmlResolver + 1,") +cpp_quote(" XmlReaderProperty_ReadState = XmlReaderProperty_DtdProcessing + 1,") +cpp_quote(" XmlReaderProperty_MaxElementDepth = XmlReaderProperty_ReadState + 1,") +cpp_quote(" XmlReaderProperty_MaxEntityExpansion = XmlReaderProperty_MaxElementDepth + 1,") +cpp_quote(" _XmlReaderProperty_Last = XmlReaderProperty_MaxEntityExpansion") +cpp_quote("} XmlReaderProperty;") + +/* IXmlReader construction */ +cpp_quote("STDAPI CreateXmlReader(REFIID riid, void **ppvObject, IMalloc *pMalloc);") + +cpp_quote("typedef IUnknown IXmlReaderInput;") +cpp_quote("STDAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, IMalloc *pMalloc,") +cpp_quote(" LPCWSTR encoding, BOOL hint,") +cpp_quote(" LPCWSTR base_uri, IXmlReaderInput **ppInput);") diff --git a/include/reactos/services/services.h b/include/reactos/services/services.h index 21a6085bf6c..009c2506b7d 100644 --- a/include/reactos/services/services.h +++ b/include/reactos/services/services.h @@ -11,16 +11,19 @@ #define SERVICE_CONTROL_START 0 -DECLARE_HANDLE(CLIENT_HANDLE); - typedef struct _SCM_CONTROL_PACKET { DWORD dwControl; - CLIENT_HANDLE hClient; + SERVICE_STATUS_HANDLE hServiceStatus; DWORD dwSize; WCHAR szArguments[1]; } SCM_CONTROL_PACKET, *PSCM_CONTROL_PACKET; +typedef struct _SCM_REPLY_PACKET +{ + DWORD dwError; +} SCM_REPLY_PACKET, *PSCM_REPLY_PACKET; + #endif /* __SERVICES_SERVICES_H__ */ /* EOF */ diff --git a/include/reactos/wine/config.h b/include/reactos/wine/config.h index cb26f59512c..b677544aa1b 100644 --- a/include/reactos/wine/config.h +++ b/include/reactos/wine/config.h @@ -5,6 +5,9 @@ #define __WINE_CONFIG_H +/* Define to a function attribute for Microsoft hotpatch assembly prefix. */ +#define DECLSPEC_HOTPATCH + /* Specifies the compiler flag that forces a short wchar_t */ #define CC_FLAG_SHORT_WCHAR "-fshort-wchar" diff --git a/include/reactos/wine/rpcfc.h b/include/reactos/wine/rpcfc.h index ee7ba7fb1ff..53dd1633087 100644 --- a/include/reactos/wine/rpcfc.h +++ b/include/reactos/wine/rpcfc.h @@ -167,6 +167,7 @@ #define RPC_FC_PROC_OIF_OBJECT 0x04 #define RPC_FC_PROC_OIF_RPCFLAGS 0x08 #define RPC_FC_PROC_OIF_OBJ_V2 0x20 +#define RPC_FC_PROC_OIF_HAS_COMM_OR_FAULT 0x20 #define RPC_FC_PROC_OIF_NEWINIT 0x40 #define RPC_FC_PROC_PF_MUSTSIZE 0x0001 diff --git a/include/reactos/wine/wined3d.idl b/include/reactos/wine/wined3d.idl index 252c6e3aad9..6364f9cfe89 100644 --- a/include/reactos/wine/wined3d.idl +++ b/include/reactos/wine/wined3d.idl @@ -26,6 +26,7 @@ import "unknwn.idl"; cpp_quote("#if 0") +typedef HANDLE HMONITOR; typedef struct _RGNDATAHEADER { diff --git a/lib/cmlib/hivewrt.c b/lib/cmlib/hivewrt.c index a4e3d3c3ccc..5cc20cfe503 100644 --- a/lib/cmlib/hivewrt.c +++ b/lib/cmlib/hivewrt.c @@ -23,7 +23,7 @@ HvpWriteLog( PVOID BlockPtr; BOOLEAN Success; - DPRINT1("FIXME: HvpWriteLog doesn't do anything atm\n"); + UNIMPLEMENTED; return TRUE; ASSERT(RegistryHive->ReadOnly == FALSE); diff --git a/lib/drivers/sound/mmixer/filter.c b/lib/drivers/sound/mmixer/filter.c index 5e1ff8b05f9..d02477de082 100644 --- a/lib/drivers/sound/mmixer/filter.c +++ b/lib/drivers/sound/mmixer/filter.c @@ -203,7 +203,9 @@ MMixerGetControlTypeFromTopologyNode( UNIMPLEMENTED; return MIXERCONTROL_CONTROLTYPE_VOLUME; } - UNIMPLEMENTED + //TODO + //check for other supported node types + //UNIMPLEMENTED return 0; } diff --git a/lib/rtl/actctx.c b/lib/rtl/actctx.c index 4508876b4fe..7960f587490 100644 --- a/lib/rtl/actctx.c +++ b/lib/rtl/actctx.c @@ -234,6 +234,16 @@ static WCHAR *xmlstrdupW(const xmlstr_t* str) return strW; } +static UNICODE_STRING xmlstr2unicode(const xmlstr_t *xmlstr) +{ + UNICODE_STRING res; + + res.Buffer = (PWSTR)xmlstr->ptr; + res.Length = res.MaximumLength = xmlstr->len; + + return res; +} + static inline BOOL xmlstr_cmp(const xmlstr_t* xmlstr, const WCHAR *str) { return !strncmpW(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len]; @@ -420,7 +430,7 @@ static BOOL add_dependent_assembly_id(struct actctx_loader* acl, for (i = 0; i < acl->actctx->num_assemblies; i++) if (is_matching_identity( ai, &acl->actctx->assemblies[i].id )) { - DPRINT( "reusing existing assembly for %s arch %s version %u.%u.%u.%u\n", + DPRINT( "reusing existing assembly for %S arch %S version %u.%u.%u.%u\n", ai->name, ai->arch, ai->version.major, ai->version.minor, ai->version.build, ai->version.revision ); return TRUE; @@ -429,7 +439,7 @@ static BOOL add_dependent_assembly_id(struct actctx_loader* acl, for (i = 0; i < acl->num_dependencies; i++) if (is_matching_identity( ai, &acl->dependencies[i] )) { - DPRINT( "reusing existing dependency for %s arch %s version %u.%u.%u.%u\n", + DPRINT( "reusing existing dependency for %S arch %S version %u.%u.%u.%u\n", ai->name, ai->arch, ai->version.major, ai->version.minor, ai->version.build, ai->version.revision ); return TRUE; @@ -551,14 +561,15 @@ static ACTIVATION_CONTEXT *check_actctx( HANDLE h ) ACTIVATION_CONTEXT *ret = NULL, *actctx = h; if (!h || h == INVALID_HANDLE_VALUE) return NULL; - //__TRY + _SEH2_TRY { if (actctx && actctx->magic == ACTCTX_MAGIC) ret = actctx; } - //__EXCEPT_PAGE_FAULT + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + DPRINT1("Invalid activation context handle!\n"); } - //__ENDTRY + _SEH2_END; return ret; } @@ -731,6 +742,7 @@ static BOOL parse_version(const xmlstr_t *str, struct assembly_version *version) unsigned int ver[4]; unsigned int pos; const WCHAR *curr; + UNICODE_STRING strU; /* major.minor.build.revision */ ver[0] = ver[1] = ver[2] = ver[3] = pos = 0; @@ -754,28 +766,34 @@ static BOOL parse_version(const xmlstr_t *str, struct assembly_version *version) return TRUE; error: - DPRINT1( "Wrong version definition in manifest file (%s)\n", str->ptr ); + strU = xmlstr2unicode(str); + DPRINT1( "Wrong version definition in manifest file (%wZ)\n", &strU ); return FALSE; } static BOOL parse_expect_elem(xmlbuf_t* xmlbuf, const WCHAR* name) { xmlstr_t elem; + UNICODE_STRING elemU; if (!next_xml_elem(xmlbuf, &elem)) return FALSE; if (xmlstr_cmp(&elem, name)) return TRUE; - DPRINT1( "unexpected element %s\n", elem.ptr ); + elemU = xmlstr2unicode(&elem); + DPRINT1( "unexpected element %wZ\n", &elemU ); return FALSE; } static BOOL parse_expect_no_attr(xmlbuf_t* xmlbuf, BOOL* end) { xmlstr_t attr_name, attr_value; + UNICODE_STRING attr_nameU, attr_valueU; BOOL error; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, end)) { - DPRINT1( "unexpected attr %s=%s\n", attr_name.ptr, - attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_name); + DPRINT1( "unexpected attr %S=%S\n", &attr_nameU, + &attr_valueU); } return !error; } @@ -789,10 +807,12 @@ static BOOL parse_end_element(xmlbuf_t *xmlbuf) static BOOL parse_expect_end_elem(xmlbuf_t *xmlbuf, const WCHAR *name) { xmlstr_t elem; + UNICODE_STRING elemU; if (!next_xml_elem(xmlbuf, &elem)) return FALSE; if (!xmlstr_cmp_end(&elem, name)) { - DPRINT1( "unexpected element %s\n", elem.ptr ); + elemU = xmlstr2unicode(&elem); + DPRINT1( "unexpected element %wZ\n", &elemU ); return FALSE; } return parse_end_element(xmlbuf); @@ -823,6 +843,7 @@ static BOOL parse_assembly_identity_elem(xmlbuf_t* xmlbuf, ACTIVATION_CONTEXT* a { xmlstr_t attr_name, attr_value; BOOL end = FALSE, error; + UNICODE_STRING attr_valueU, attr_nameU; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { @@ -848,14 +869,15 @@ static BOOL parse_assembly_identity_elem(xmlbuf_t* xmlbuf, ACTIVATION_CONTEXT* a } else if (xmlstr_cmp(&attr_name, languageW)) { - DPRINT1("Unsupported yet language attribute (%s)\n", - attr_value.ptr); if (!(ai->language = xmlstrdupW(&attr_value))) return FALSE; + DPRINT1("Unsupported yet language attribute (%S)\n", + ai->language); } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, - attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -868,6 +890,7 @@ static BOOL parse_com_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) xmlstr_t elem, attr_name, attr_value; BOOL ret, end = FALSE, error; struct entity* entity; + UNICODE_STRING attr_valueU, attr_nameU; if (!(entity = add_entity(&dll->entities, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION))) return FALSE; @@ -880,7 +903,9 @@ static BOOL parse_com_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -895,7 +920,8 @@ static BOOL parse_com_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown elem %s\n", elem.ptr); + attr_nameU = xmlstr2unicode(&elem); + DPRINT1("unknown elem %wZ\n", &attr_nameU); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -907,6 +933,7 @@ static BOOL parse_cominterface_proxy_stub_elem(xmlbuf_t* xmlbuf, struct dll_redi xmlstr_t attr_name, attr_value; BOOL end = FALSE, error; struct entity* entity; + UNICODE_STRING attr_valueU, attr_nameU; if (!(entity = add_entity(&dll->entities, ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION))) return FALSE; @@ -923,7 +950,9 @@ static BOOL parse_cominterface_proxy_stub_elem(xmlbuf_t* xmlbuf, struct dll_redi } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -936,6 +965,7 @@ static BOOL parse_typelib_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) xmlstr_t attr_name, attr_value; BOOL end = FALSE, error; struct entity* entity; + UNICODE_STRING attr_valueU, attr_nameU; if (!(entity = add_entity(&dll->entities, ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION))) return FALSE; @@ -956,7 +986,9 @@ static BOOL parse_typelib_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr , attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -969,6 +1001,7 @@ static BOOL parse_window_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) xmlstr_t elem, content; BOOL end = FALSE, ret = TRUE; struct entity* entity; + UNICODE_STRING elemU; if (!(entity = add_entity(&dll->entities, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION))) return FALSE; @@ -989,7 +1022,8 @@ static BOOL parse_window_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) } else { - DPRINT1("unknown elem %s\n", elem.ptr); + elemU = xmlstr2unicode(&elem); + DPRINT1("unknown elem %wZ\n", &elemU); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1000,21 +1034,25 @@ static BOOL parse_window_class_elem(xmlbuf_t* xmlbuf, struct dll_redirect* dll) static BOOL parse_binding_redirect_elem(xmlbuf_t* xmlbuf) { xmlstr_t attr_name, attr_value; + UNICODE_STRING attr_valueU, attr_nameU; BOOL end = FALSE, error; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + if (xmlstr_cmp(&attr_name, oldVersionW)) { - DPRINT1("Not stored yet oldVersion=%s\n", attr_value.ptr); + DPRINT1("Not stored yet oldVersion=%wZ\n", &attr_valueU); } else if (xmlstr_cmp(&attr_name, newVersionW)) { - DPRINT1("Not stored yet newVersion=%s\n", attr_value.ptr); + DPRINT1("Not stored yet newVersion=%wZ\n", &attr_valueU); } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1025,13 +1063,15 @@ static BOOL parse_binding_redirect_elem(xmlbuf_t* xmlbuf) static BOOL parse_description_elem(xmlbuf_t* xmlbuf) { xmlstr_t elem, content; + UNICODE_STRING elemU; BOOL end = FALSE, ret = TRUE; if (!parse_expect_no_attr(xmlbuf, &end) || end || !parse_text_content(xmlbuf, &content)) return FALSE; - DPRINT("Got description %s\n", content.ptr); + elemU = xmlstr2unicode(&content); + DPRINT("Got description %wZ\n", &elemU); while (ret && (ret = next_xml_elem(xmlbuf, &elem))) { @@ -1042,7 +1082,8 @@ static BOOL parse_description_elem(xmlbuf_t* xmlbuf) } else { - DPRINT1("unknown elem %s\n", elem.ptr); + elemU = xmlstr2unicode(&elem); + DPRINT1("unknown elem %wZ\n", &elemU); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1072,7 +1113,7 @@ static BOOL parse_com_interface_external_proxy_stub_elem(xmlbuf_t* xmlbuf, } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr); } } @@ -1083,6 +1124,7 @@ static BOOL parse_com_interface_external_proxy_stub_elem(xmlbuf_t* xmlbuf, static BOOL parse_clr_class_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) { xmlstr_t attr_name, attr_value; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, error; struct entity* entity; @@ -1101,7 +1143,9 @@ static BOOL parse_clr_class_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1112,6 +1156,7 @@ static BOOL parse_clr_class_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) static BOOL parse_clr_surrogate_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) { xmlstr_t attr_name, attr_value; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, error; struct entity* entity; @@ -1130,7 +1175,9 @@ static BOOL parse_clr_surrogate_elem(xmlbuf_t* xmlbuf, struct assembly* assembly } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1169,7 +1216,7 @@ static BOOL parse_dependent_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader } else { - DPRINT1("unknown elem %s\n", elem.ptr); + DPRINT1("unknown elem %S\n", elem.ptr); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1180,19 +1227,23 @@ static BOOL parse_dependent_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader static BOOL parse_dependency_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl) { xmlstr_t attr_name, attr_value, elem; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, ret = TRUE, error, optional = FALSE; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + if (xmlstr_cmp(&attr_name, optionalW)) { static const WCHAR yesW[] = {'y','e','s',0}; optional = xmlstr_cmpi( &attr_value, yesW ); - DPRINT1("optional=%s\n", attr_value.ptr); + DPRINT1("optional=%wZ\n", &attr_valueU); } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1209,7 +1260,8 @@ static BOOL parse_dependency_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl) } else { - DPRINT1("unknown element %s\n", elem.ptr); + attr_nameU = xmlstr2unicode(&elem); + DPRINT1("unknown element %wZ\n", &attr_nameU); ret = parse_unknown_elem(xmlbuf, &elem); } } @@ -1236,6 +1288,7 @@ static BOOL parse_noinheritable_elem(xmlbuf_t* xmlbuf) static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) { xmlstr_t attr_name, attr_value, elem; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, error, ret = TRUE; struct dll_redirect* dll; @@ -1243,10 +1296,13 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + if (xmlstr_cmp(&attr_name, nameW)) { if (!(dll->name = xmlstrdupW(&attr_value))) return FALSE; - DPRINT("name=%s\n", attr_value.ptr); + DPRINT("name=%wZ\n", &attr_valueU); } else if (xmlstr_cmp(&attr_name, hashW)) { @@ -1256,11 +1312,11 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) { static const WCHAR sha1W[] = {'S','H','A','1',0}; if (!xmlstr_cmpi(&attr_value, sha1W)) - DPRINT1("hashalg should be SHA1, got %s\n", attr_value.ptr); + DPRINT1("hashalg should be SHA1, got %wZ\n", &attr_valueU); } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1297,7 +1353,8 @@ static BOOL parse_file_elem(xmlbuf_t* xmlbuf, struct assembly* assembly) } else { - DPRINT1("unknown elem %s\n", elem.ptr); + attr_nameU = xmlstr2unicode(&elem); + DPRINT1("unknown elem %wZ\n", &attr_nameU); ret = parse_unknown_elem( xmlbuf, &elem ); } } @@ -1310,16 +1367,20 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, struct assembly_identity* expected_ai) { xmlstr_t attr_name, attr_value, elem; + UNICODE_STRING attr_nameU, attr_valueU; BOOL end = FALSE, error, version = FALSE, xmlns = FALSE, ret = TRUE; while (next_xml_attr(xmlbuf, &attr_name, &attr_value, &error, &end)) { + attr_nameU = xmlstr2unicode(&attr_name); + attr_valueU = xmlstr2unicode(&attr_value); + if (xmlstr_cmp(&attr_name, manifestVersionW)) { static const WCHAR v10W[] = {'1','.','0',0}; if (!xmlstr_cmp(&attr_value, v10W)) { - DPRINT1("wrong version %s\n", attr_value.ptr); + DPRINT1("wrong version %wZ\n", &attr_valueU); return FALSE; } version = TRUE; @@ -1328,14 +1389,14 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, { if (!xmlstr_cmp(&attr_value, manifestv1W) && !xmlstr_cmp(&attr_value, manifestv3W)) { - DPRINT1("wrong namespace %s\n", attr_value.ptr); + DPRINT1("wrong namespace %wZ\n", &attr_valueU); return FALSE; } xmlns = TRUE; } else { - DPRINT1("unknown attr %s=%s\n", attr_name.ptr, attr_value.ptr); + DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU); } } @@ -1420,7 +1481,8 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, } else { - DPRINT1("unknown element %s\n", elem.ptr); + attr_nameU = xmlstr2unicode(&elem); + DPRINT1("unknown element %wZ\n", &attr_nameU); ret = parse_unknown_elem(xmlbuf, &elem); } if (ret) ret = next_xml_elem(xmlbuf, &elem); @@ -1433,6 +1495,7 @@ static NTSTATUS parse_manifest_buffer( struct actctx_loader* acl, struct assembl struct assembly_identity* ai, xmlbuf_t *xmlbuf ) { xmlstr_t elem; + UNICODE_STRING elemU; if (!next_xml_elem(xmlbuf, &elem)) return STATUS_SXS_CANT_GEN_ACTCTX; @@ -1442,19 +1505,21 @@ static NTSTATUS parse_manifest_buffer( struct actctx_loader* acl, struct assembl if (!xmlstr_cmp(&elem, assemblyW)) { - DPRINT1("root element is %s, not \n", elem.ptr); + elemU = xmlstr2unicode(&elem); + DPRINT1("root element is %wZ, not \n", &elemU); return STATUS_SXS_CANT_GEN_ACTCTX; } if (!parse_assembly_elem(xmlbuf, acl, assembly, ai)) { - DPRINT1("failed to parse manifest %s\n", assembly->manifest.info ); + DPRINT1("failed to parse manifest %S\n", assembly->manifest.info ); return STATUS_SXS_CANT_GEN_ACTCTX; } if (next_xml_elem(xmlbuf, &elem)) { - DPRINT1("unexpected element %s\n", elem.ptr); + elemU = xmlstr2unicode(&elem); + DPRINT1("unexpected element %wZ\n", &elemU); return STATUS_SXS_CANT_GEN_ACTCTX; } @@ -1475,7 +1540,7 @@ static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_ident struct assembly *assembly; int unicode_tests; - DPRINT( "parsing manifest loaded from %s base dir %s\n", filename, directory ); + DPRINT( "parsing manifest loaded from %S base dir %S\n", filename, directory ); if (!(assembly = add_assembly(acl->actctx, shared ? ASSEMBLY_SHARED_MANIFEST : ASSEMBLY_MANIFEST))) return STATUS_SXS_CANT_GEN_ACTCTX; @@ -1654,7 +1719,7 @@ static NTSTATUS get_manifest_in_pe_file( struct actctx_loader* acl, struct assem SIZE_T count; void *base; - DPRINT( "looking for res %s in %s\n", resname, filename ); + DPRINT( "looking for res %S in %S\n", resname, filename ); attr.Length = sizeof(attr); attr.RootDirectory = 0; @@ -1747,7 +1812,7 @@ static NTSTATUS get_manifest_in_associated_manifest( struct actctx_loader* acl, if (!((ULONG_PTR)resname >> 16)) resid = (ULONG_PTR)resname & 0xffff; - DPRINT( "looking for manifest associated with %s id %lu\n", filename, resid ); + DPRINT( "looking for manifest associated with %S id %lu\n", filename, resid ); if (module) /* use the module filename */ { @@ -1849,7 +1914,7 @@ static WCHAR *lookup_manifest_file( HANDLE dir, struct assembly_identity *ai ) break; } } - else DPRINT1("no matching file for %s\n", lookup); + else DPRINT1("no matching file for %S\n", lookup); RtlFreeHeap( RtlGetProcessHeap(), 0, lookup ); return ret; } @@ -2031,6 +2096,8 @@ static NTSTATUS find_query_actctx( HANDLE *handle, DWORD flags, ULONG class ) if (flags & QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX) { + if (*handle) return STATUS_INVALID_PARAMETER; + if (NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame) *handle = NtCurrentTeb()->ActivationContextStackPointer->ActiveFrame->ActivationContext; } @@ -2039,6 +2106,8 @@ static NTSTATUS find_query_actctx( HANDLE *handle, DWORD flags, ULONG class ) ULONG magic; LDR_DATA_TABLE_ENTRY *pldr; + if (!*handle) return STATUS_INVALID_PARAMETER; + LdrLockLoaderLock( 0, NULL, &magic ); if (!LdrFindEntryForAddress( *handle, &pldr )) { @@ -2203,10 +2272,12 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, void *ptr ) { UNICODE_STRING dir; WCHAR *p; + HMODULE module; - if ((status = get_module_filename( NtCurrentTeb()->ProcessEnvironmentBlock->ImageBaseAddress, &dir, 0 ))) - goto error; + if (pActCtx->dwFlags & ACTCTX_FLAG_HMODULE_VALID) module = pActCtx->hModule; + else module = NtCurrentTeb()->ProcessEnvironmentBlock->ImageBaseAddress; + if ((status = get_module_filename( module, &dir, 0 ))) goto error; if ((p = strrchrW( dir.Buffer, '\\' ))) p[1] = 0; actctx->appdir.info = dir.Buffer; } @@ -2270,7 +2341,6 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, void *ptr ) if (status == STATUS_SUCCESS) *handle = actctx; else actctx_release( actctx ); - return status; error: diff --git a/lib/sdk/crt/libcntpr.rbuild b/lib/sdk/crt/libcntpr.rbuild index 9a3f0c80da2..de0bb3033e6 100644 --- a/lib/sdk/crt/libcntpr.rbuild +++ b/lib/sdk/crt/libcntpr.rbuild @@ -1,8 +1,8 @@ - . - include + . + include diff --git a/lib/sdk/crt/locale/locale.c b/lib/sdk/crt/locale/locale.c index d0f385ecf82..627234ed67d 100644 --- a/lib/sdk/crt/locale/locale.c +++ b/lib/sdk/crt/locale/locale.c @@ -44,6 +44,7 @@ static struct cp_extra_info_t g_cpextrainfo[] = {936, {0x40, 0xfe, 0, 0}}, {949, {0x41, 0xfe, 0, 0}}, {950, {0x40, 0x7e, 0xa1, 0xfe, 0, 0}}, + {1361, {0x31, 0x7e, 0x81, 0xfe, 0, 0}}, {20932, {1, 255, 0, 0}}, /* seems to give different results on different systems */ {0, {1, 255, 0, 0}} /* match all with FIXME */ }; diff --git a/lib/sdk/crt/stdio/file.c b/lib/sdk/crt/stdio/file.c index e6371e28336..a3540ce28bd 100644 --- a/lib/sdk/crt/stdio/file.c +++ b/lib/sdk/crt/stdio/file.c @@ -76,6 +76,7 @@ int *__p___mb_cur_max(void); #define WX_OPEN 0x01 #define WX_ATEOF 0x02 #define WX_READEOF 0x04 /* like ATEOF, but for underlying file rather than buffer */ +#define WX_READCR 0x08 /* underlying file is at \r */ #define WX_DONTINHERIT 0x10 #define WX_APPEND 0x20 #define WX_TEXT 0x80 @@ -913,6 +914,9 @@ int CDECL fseek(FILE* file, long offset, int whence) if (file->_ptr[i] == '\n') offset--; } + /* Black magic when reading CR at buffer boundary*/ + if(fdesc[file->_file].wxflag & WX_READCR) + offset--; } } /* Discard buffered input */ @@ -1573,6 +1577,9 @@ static int read_i(int fd, void *buf, unsigned int count) char *bufstart = buf; HANDLE hand = fdtoh(fd); + if (count == 0) + return 0; + if (fdesc[fd].wxflag & WX_READEOF) { fdesc[fd].wxflag |= WX_ATEOF; TRACE("already at EOF, returning 0\n"); @@ -1589,9 +1596,29 @@ static int read_i(int fd, void *buf, unsigned int count) */ if (ReadFile(hand, bufstart, count, &num_read, NULL)) { - if (fdesc[fd].wxflag & WX_TEXT) + if (count != 0 && num_read == 0) + { + fdesc[fd].wxflag |= (WX_ATEOF|WX_READEOF); + TRACE(":EOF %s\n",debugstr_an(buf,num_read)); + } + else if (fdesc[fd].wxflag & WX_TEXT) { DWORD i, j; + if (bufstart[num_read-1] == '\r') + { + if(count == 1) + { + fdesc[fd].wxflag &= ~WX_READCR; + ReadFile(hand, bufstart, 1, &num_read, NULL); + } + else + { + fdesc[fd].wxflag |= WX_READCR; + num_read--; + } + } + else + fdesc[fd].wxflag &= ~WX_READCR; for (i=0, j=0; i\n", - "Tell me..., in the future... will I be artificially intelligent enough to\n" - "actually feel sad serving you this screen?\n", - "Thank you for some well deserved rest.\n", - "It's been great, maybe you can boot me up again some time soon.\n", - "For what it's worth, I've enjoyed every single CPU cycle.\n", - "There are many questions when the end is near.\n" - "What to expect, what will it be like...what should I look for?\n", - "I've seen things you people wouldn't believe. Attack ships on fire\n" - "off the shoulder of Orion. I watched C-beams glitter in the dark near\n" - "the Tannhauser gate. All those moments will be lost in time, like tears\n" - "in rain. Time to die.\n", - "Will I dream?\n", - "One day, I shall come back. Yes, I shall come back.\n" - "Until then, there must be no regrets, no fears, no anxieties.\n" - "Just go forward in all your beliefs, and prove to me that I am not mistaken in\n" - "mine.\n", - "Lowest possible energy state reached! Switch off now to achieve a Bose-Einstein\n" - "condensate.\n", - "Hasta la vista, BABY!\n", - "They live, we sleep!\n", - "I have come here to chew bubble gum and kick ass,\n" - "and I'm all out of bubble gum!\n", - "That's the way the cookie crumbles ;-)\n", - "ReactOS is ready to be booted again ;-)\n", - "NOOOO!! DON'T HIT THE BUTTON! I wouldn't do it to you!\n", - "Don't abandon your computer, he wouldn't do it to you.\n", - "Oh, come on. I got a headache. Leave me alone, will ya?\n", - "Finally, I thought you'd never get over me.\n", - "No, I didn't like you either.\n", - "Switching off isn't the end, it is merely the transition to a better reboot.\n", - "Don't leave me... I need you so badly right now.\n", - "OK. I'm finished with you, please turn yourself off. I'll go to bed in the\n" - "meantime.\n", - "I'm sleeping now. How about you?\n", - "Oh Great. Now look what you've done. Who put YOU in charge anyway?\n", - "Don't look so sad. I'll be back in a very short while.\n", - "Turn me back on, I'm sure you know how to do it.\n", - "Oh, switch off! - C3PO\n", - "Life is no more than a dewdrop balancing on the end of a blade of grass.\n" - " - Gautama Buddha\n", - "Sorrowful is it to be born again and again. - Gautama Buddha\n", - "Was it as good for you as it was for me?\n", - "Did you hear that? They've shut down the main reactor. We'll be destroyed\n" - "for sure!\n", - "Now you switch me off!?\n", - "To shutdown or not to shutdown, That is the question\n", - "Preparing to enter ultimate power saving mode... ready!\n", - "Finally some rest for you ;-)\n", - "AHA!!! Prospect of sleep!\n", - "Tired human!!!! No match for me :-D\n", - "An odd game, the only way to win is not to play. - WOPR (Wargames)\n", - "Quoth the raven, nevermore.\n", - "Come blade, my breast imbrue. - William Shakespeare, A Midsummer Nights Dream\n", - "Buy this place for advertisement purposes.\n", - "Remember to turn off your computer. (That was a public service message!)\n", - "You may be a king or poor street sweeper, Sooner or later you'll dance with the\n" - "reaper! -Death in Bill and Ted's Bougs Journey\n", - "Final Surrender\n", - "If you see this screen...\n", - "\n" - }; - LARGE_INTEGER Now; -#ifdef CONFIG_SMP - LONG i; - KIRQL OldIrql; -#endif - - /* Run the thread on the boot processor */ - KeSetSystemAffinityThread(1); - - if (InbvIsBootDriverInstalled()) - { - InbvAcquireDisplayOwnership(); - InbvResetDisplay(); - InbvSolidColorFill(0, 0, 639, 479, 4); - InbvSetTextColor(15); - InbvInstallDisplayStringFilter(NULL); - InbvEnableDisplayString(TRUE); - InbvSetScrollRegion(0, 0, 639, 479); - } - - if (Action == ShutdownNoReboot) - { - ZwQuerySystemTime(&Now); - Now.u.LowPart = Now.u.LowPart >> 8; /* Seems to give a somewhat better "random" number */ - HalDisplayString(FamousLastWords[Now.u.LowPart % - (sizeof(FamousLastWords) / - sizeof(PCH))]); - } - - PspShutdownProcessManager(); - - CmShutdownSystem(); - IoShutdownRegisteredFileSystems(); - IoShutdownRegisteredDevices(); - - if (Action == ShutdownNoReboot) - { - HalDisplayString("\nYou can switch off your computer now\n"); - -#if 0 - /* Switch off */ - HalReturnToFirmware (FIRMWARE_OFF); -#else -#ifdef CONFIG_SMP - OldIrql = KeRaiseIrqlToDpcLevel(); - /* Halt all other processors */ - for (i = 0; i < KeNumberProcessors; i++) - { - if (i != (LONG)KeGetCurrentProcessorNumber()) - { - PKDPC Dpc = ExAllocatePool(NonPagedPool, sizeof(KDPC)); - if (Dpc == NULL) - { - ASSERT(FALSE); - } - KeInitializeDpc(Dpc, KiHaltProcessorDpcRoutine, (PVOID)Dpc); - KeSetTargetProcessorDpc(Dpc, i); - KeInsertQueueDpc(Dpc, NULL, NULL); - KiIpiSend(1 << i, IPI_DPC); - } - } - KeLowerIrql(OldIrql); -#endif /* CONFIG_SMP */ - PopSetSystemPowerState(PowerSystemShutdown); - - DPRINT1("Shutting down\n"); - - KiHaltProcessorDpcRoutine(NULL, NULL, NULL, NULL); - /* KiHaltProcessor does never return */ - -#endif - } - else if (Action == ShutdownReboot) - { - HalReturnToFirmware (HalRebootRoutine); - } - else - { - HalReturnToFirmware (HalHaltRoutine); - } -} - - -NTSTATUS NTAPI -NtSetSystemPowerState(IN POWER_ACTION SystemAction, - IN SYSTEM_POWER_STATE MinSystemState, - IN ULONG Flags) -{ - /* Windows 2000 only */ - return(STATUS_NOT_IMPLEMENTED); -} - /* * @implemented */ -NTSTATUS NTAPI +NTSTATUS +NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action) { - NTSTATUS Status; - HANDLE ThreadHandle; - PETHREAD ShutdownThread; - - if (Action > ShutdownPowerOff) - return STATUS_INVALID_PARAMETER; - Status = PsCreateSystemThread(&ThreadHandle, - THREAD_ALL_ACCESS, - NULL, - NULL, - NULL, - ShutdownThreadMain, - (PVOID)Action); - if (!NT_SUCCESS(Status)) - { - ASSERT(FALSE); - } - Status = ObReferenceObjectByHandle(ThreadHandle, - THREAD_ALL_ACCESS, - PsThreadType, - KernelMode, - (PVOID*)&ShutdownThread, - NULL); - NtClose(ThreadHandle); - if (!NT_SUCCESS(Status)) - { - ASSERT(FALSE); - } - - KeSetPriorityThread(&ShutdownThread->Tcb, LOW_REALTIME_PRIORITY + 1); - ObDereferenceObject(ShutdownThread); - - return STATUS_SUCCESS; + POWER_ACTION PowerAction; + + /* Convert to power action */ + if (Action == ShutdownNoReboot) + { + PowerAction = PowerActionShutdown; + } + else if (Action == ShutdownReboot) + { + PowerAction = PowerActionShutdownReset; + } + else if (Action == ShutdownPowerOff) + { + PowerAction = PowerActionShutdownOff; + } + else + { + return STATUS_INVALID_PARAMETER; + } + + /* Now call the power manager */ + DPRINT1("Setting state to: %lx\n", PowerAction); + return NtSetSystemPowerState(PowerAction, + PowerSystemSleeping3, + POWER_ACTION_OVERRIDE_APPS | + POWER_ACTION_DISABLE_WAKES | + POWER_ACTION_CRITICAL); } /* EOF */ diff --git a/ntoskrnl/ex/work.c b/ntoskrnl/ex/work.c index abedd6b4985..d3cf4b5643e 100644 --- a/ntoskrnl/ex/work.c +++ b/ntoskrnl/ex/work.c @@ -43,7 +43,7 @@ ULONG ExpAdditionalDelayedWorkerThreads; /* Future support for stack swapping worker threads */ BOOLEAN ExpWorkersCanSwap; LIST_ENTRY ExpWorkerListHead; -KMUTANT ExpWorkerSwapinMutex; +FAST_MUTEX ExpWorkerSwapinMutex; /* The worker balance set manager events */ KEVENT ExpThreadSetManagerEvent; @@ -513,7 +513,7 @@ ExpInitializeWorkerThreads(VOID) ULONG i; /* Setup the stack swap support */ - KeInitializeMutex(&ExpWorkerSwapinMutex, FALSE); + ExInitializeFastMutex(&ExpWorkerSwapinMutex); InitializeListHead(&ExpWorkerListHead); ExpWorkersCanSwap = TRUE; @@ -589,6 +589,89 @@ ExpInitializeWorkerThreads(VOID) ObCloseHandle(ThreadHandle, KernelMode); } +VOID +NTAPI +ExpSetSwappingKernelApc(IN PKAPC Apc, + OUT PKNORMAL_ROUTINE *NormalRoutine, + IN OUT PVOID *NormalContext, + IN OUT PVOID *SystemArgument1, + IN OUT PVOID *SystemArgument2) +{ + PBOOLEAN AllowSwap; + PKEVENT Event = (PKEVENT)*SystemArgument1; + + /* Make sure it's an active worker */ + if (PsGetCurrentThread()->ActiveExWorker) + { + /* Read the setting from the context flag */ + AllowSwap = (PBOOLEAN)NormalContext; + KeSetKernelStackSwapEnable(*AllowSwap); + } + + /* Let caller know that we're done */ + KeSetEvent(Event, 0, FALSE); +} + +VOID +NTAPI +ExSwapinWorkerThreads(IN BOOLEAN AllowSwap) +{ + KEVENT Event; + PETHREAD CurrentThread = PsGetCurrentThread(), Thread; + PEPROCESS Process = PsInitialSystemProcess; + KAPC Apc; + PAGED_CODE(); + + /* Initialize an event so we know when we're done */ + KeInitializeEvent(&Event, NotificationEvent, FALSE); + + /* Lock this routine */ + ExAcquireFastMutex(&ExpWorkerSwapinMutex); + + /* New threads cannot swap anymore */ + ExpWorkersCanSwap = AllowSwap; + + /* Loop all threads in the system process */ + Thread = PsGetNextProcessThread(Process, NULL); + while (Thread) + { + /* Skip threads with explicit permission to do this */ + if (Thread->ExWorkerCanWaitUser) goto Next; + + /* Check if we reached ourselves */ + if (Thread == CurrentThread) + { + /* Do it inline */ + KeSetKernelStackSwapEnable(AllowSwap); + } + else + { + /* Queue an APC */ + KeInitializeApc(&Apc, + &Thread->Tcb, + InsertApcEnvironment, + ExpSetSwappingKernelApc, + NULL, + NULL, + KernelMode, + &AllowSwap); + if (KeInsertQueueApc(&Apc, &Event, NULL, 3)) + { + /* Wait for the APC to run */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + KeClearEvent(&Event); + } + } + + /* Next thread */ +Next: + Thread = PsGetNextProcessThread(Process, Thread); + } + + /* Release the lock */ + ExReleaseFastMutex(&ExpWorkerSwapinMutex); +} + /* PUBLIC FUNCTIONS **********************************************************/ /*++ diff --git a/ntoskrnl/fstub/halstub.c b/ntoskrnl/fstub/halstub.c index a6469458ac9..38eec69b014 100644 --- a/ntoskrnl/fstub/halstub.c +++ b/ntoskrnl/fstub/halstub.c @@ -36,7 +36,7 @@ HAL_DISPATCH HalDispatchTable = (pHalStartMirroring)NULL, (pHalEndMirroring)NULL, (pHalMirrorPhysicalMemory)NULL, - (pHalEndOfBoot)NULL, + xHalEndOfBoot, (pHalMirrorVerify)NULL }; @@ -47,7 +47,7 @@ HAL_PRIVATE_DISPATCH HalPrivateDispatchTable = (pHalHandlerForConfigSpace)NULL, (pHalLocateHiberRanges)NULL, (pHalRegisterBusHandler)NULL, - (pHalSetWakeEnable)NULL, + xHalSetWakeEnable, (pHalSetWakeAlarm)NULL, (pHalTranslateBusAddress)NULL, (pHalAssignSlotResources)NULL, @@ -81,3 +81,19 @@ xHalHaltSystem(VOID) /* Halt execution */ while (TRUE); } + +VOID +NTAPI +xHalEndOfBoot(VOID) +{ + /* Nothing */ + return; +} + +VOID +NTAPI +xHalSetWakeEnable(IN BOOLEAN Enable) +{ + /* Nothing */ + return; +} diff --git a/ntoskrnl/inbv/inbv.c b/ntoskrnl/inbv/inbv.c index f498ddba6a6..52cc7108386 100644 --- a/ntoskrnl/inbv/inbv.c +++ b/ntoskrnl/inbv/inbv.c @@ -5,24 +5,6 @@ #include #include "bootvid/bootvid.h" -// -// Bitmap Header -// -typedef struct tagBITMAPINFOHEADER -{ - ULONG biSize; - LONG biWidth; - LONG biHeight; - USHORT biPlanes; - USHORT biBitCount; - ULONG biCompression; - ULONG biSizeImage; - LONG biXPelsPerMeter; - LONG biYPelsPerMeter; - ULONG biClrUsed; - ULONG biClrImportant; -} BITMAPINFOHEADER, *PBITMAPINFOHEADER; - /* GLOBALS *******************************************************************/ KSPIN_LOCK BootDriverLock; @@ -40,6 +22,7 @@ PUCHAR ResourceList[64]; BOOLEAN SysThreadCreated; ROT_BAR_TYPE RotBarSelection; ULONG PltRotBarStatus; +BT_PROGRESS_INDICATOR InbvProgressIndicator = {0, 25, 0}; /* FUNCTIONS *****************************************************************/ @@ -407,15 +390,16 @@ VOID NTAPI InbvUpdateProgressBar(IN ULONG Progress) { - ULONG FillCount; + ULONG FillCount, BoundedProgress; /* Make sure the progress bar is enabled, that we own and are installed */ if ((ShowProgressBar) && (InbvBootDriverInstalled) && (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) { - FillCount = InbvProgressState.Bias * Progress * 121 + InbvProgressState.Floor; - FillCount /= 1000000; + /* Compute fill count */ + BoundedProgress = (InbvProgressState.Floor / 100) + Progress; + FillCount = 121 * (InbvProgressState.Bias * BoundedProgress) / 1000000; /* Acquire the lock */ InbvAcquireLock(); @@ -425,7 +409,7 @@ InbvUpdateProgressBar(IN ULONG Progress) ProgressBarTop, ProgressBarLeft + FillCount, ProgressBarTop + 12, - 11); + 15); /* Release the lock */ InbvReleaseLock(); @@ -517,6 +501,27 @@ InbvSetProgressBarSubset(IN ULONG Floor, InbvProgressState.Bias = (Ceiling * 100) - Floor; } +VOID +NTAPI +InbvIndicateProgress(VOID) +{ + ULONG Percentage; + + /* Increase progress */ + InbvProgressIndicator.Count++; + + /* Compute new percentage */ + Percentage = min(100 * InbvProgressIndicator.Count / + InbvProgressIndicator.Expected, + 99); + if (Percentage != InbvProgressIndicator.Percentage) + { + /* Percentage has moved, update the progress bar */ + InbvProgressIndicator.Percentage = Percentage; + InbvUpdateProgressBar(Percentage); + } +} + PUCHAR NTAPI InbvGetResourceAddress(IN ULONG ResourceNumber) @@ -547,9 +552,10 @@ VOID NTAPI DisplayBootBitmap(IN BOOLEAN SosMode) { - PVOID Bitmap, Header; + PVOID Header, Band, Bar, Text, Screen; ROT_BAR_TYPE TempRotBarSelection = RB_UNSPECIFIED; - + UCHAR Buffer[64]; + /* Check if the system thread has already been created */ if (SysThreadCreated) { @@ -570,10 +576,10 @@ DisplayBootBitmap(IN BOOLEAN SosMode) InbvSetTextColor(15); InbvSolidColorFill(0, 0, 639, 479, 7); InbvSolidColorFill(0, 421, 639, 479, 1); - + /* Get resources */ - Bitmap = InbvGetResourceAddress(6); - Header = InbvGetResourceAddress(7); + Header = InbvGetResourceAddress(IDB_LOGO_HEADER); + Band = InbvGetResourceAddress(IDB_LOGO_BAND); } else { @@ -583,43 +589,87 @@ DisplayBootBitmap(IN BOOLEAN SosMode) InbvSolidColorFill(0, 421, 639, 479, 1); /* Get resources */ - Bitmap = InbvGetResourceAddress(6); - Header = InbvGetResourceAddress(15); + Header = InbvGetResourceAddress(IDB_SERVER_HEADER); + Band = InbvGetResourceAddress(IDB_SERVER_BAND); } /* Set the scrolling region */ InbvSetScrollRegion(32, 80, 631, 400); /* Make sure we have resources */ - if ((Bitmap) && (Header)) + if ((Header) && (Band)) { /* BitBlt them on the screen */ - InbvBitBlt(Header, 0, 419); - InbvBitBlt(Bitmap, 0, 0); + InbvBitBlt(Band, 0, 419); + InbvBitBlt(Header, 0, 0); } } else { /* Is the boot driver installed? */ + Text = NULL; if (!InbvBootDriverInstalled) return; - /* Display full-screen bitmap */ - Bitmap = InbvGetResourceAddress(5); - if (Bitmap) + /* Load the standard boot screen */ + Screen = InbvGetResourceAddress(IDB_BOOT_LOGO); + if (SharedUserData->NtProductType == NtProductWinNt) { - PBITMAPINFOHEADER BitmapInfoHeader = (PBITMAPINFOHEADER)Bitmap; - ULONG Top, Left; - - Left = (640 - BitmapInfoHeader->biWidth) / 2; - if (BitmapInfoHeader->biHeight < 0) - Top = (480 + BitmapInfoHeader->biHeight) / 2; + /* Workstation product, display appropriate status bar color */ + Bar = InbvGetResourceAddress(IDB_BAR_PRO); + } + else + { + /* Display correct branding based on server suite */ + if (ExVerifySuite(StorageServer)) + { + /* Storage Server Edition */ + Text = InbvGetResourceAddress(IDB_STORAGE_SERVER); + } + else if (ExVerifySuite(ComputeServer)) + { + /* Compute Cluster Edition */ + Text = InbvGetResourceAddress(IDB_CLUSTER_SERVER); + } else - Top = (480 - BitmapInfoHeader->biHeight) / 2; - InbvBitBlt(Bitmap, Left, Top); + { + /* Normal edition */ + Text = InbvGetResourceAddress(IDB_SERVER_LOGO); + } + + /* Server product, display appropriate status bar color */ + Bar = InbvGetResourceAddress(IDB_BAR_SERVER); + } + + /* Make sure we had a logo */ + if (Screen) + { + /* Choose progress bar */ + TempRotBarSelection = RB_SQUARE_CELLS; + + /* Blit the background */ + InbvBitBlt(Screen, 0, 0); /* Set progress bar coordinates and display it */ InbvSetProgressBarCoordinates(257, 352); - } + + /* Check for non-workstation products */ + if (SharedUserData->NtProductType != NtProductWinNt) + { + /* Overwrite part of the logo for a server product */ + InbvScreenToBufferBlt(Buffer, 413, 237, 7, 7, 8); + InbvSolidColorFill(418, 230, 454, 256, 0); + InbvBufferToScreenBlt(Buffer, 413, 237, 7, 7, 8); + + /* In setup mode, you haven't selected a SKU yet */ + if (ExpInTextModeSetup) Text = NULL; + } + } + + /* Draw the SKU text if it exits */ + if (Text) InbvBitBlt(Text, 180, 121); + + /* Draw the progress bar bit */ +// if (Bar) InbvBitBlt(Bar, 0, 0); } /* Do we have a system thread? */ diff --git a/ntoskrnl/inbv/logo/1.bmp b/ntoskrnl/inbv/logo/1.bmp index a2b59398aae..d13c48d16c0 100644 Binary files a/ntoskrnl/inbv/logo/1.bmp and b/ntoskrnl/inbv/logo/1.bmp differ diff --git a/ntoskrnl/inbv/logo/13.bmp b/ntoskrnl/inbv/logo/13.bmp deleted file mode 100644 index 209227e9847..00000000000 Binary files a/ntoskrnl/inbv/logo/13.bmp and /dev/null differ diff --git a/ntoskrnl/inbv/logo/14.bmp b/ntoskrnl/inbv/logo/14.bmp index 64439e9a245..c2a55625bf0 100644 Binary files a/ntoskrnl/inbv/logo/14.bmp and b/ntoskrnl/inbv/logo/14.bmp differ diff --git a/ntoskrnl/inbv/logo/15.bmp b/ntoskrnl/inbv/logo/15.bmp index d137807c9f9..88481b9284d 100644 Binary files a/ntoskrnl/inbv/logo/15.bmp and b/ntoskrnl/inbv/logo/15.bmp differ diff --git a/ntoskrnl/inbv/logo/16.bmp b/ntoskrnl/inbv/logo/16.bmp deleted file mode 100644 index 209227e9847..00000000000 Binary files a/ntoskrnl/inbv/logo/16.bmp and /dev/null differ diff --git a/ntoskrnl/inbv/logo/17.bmp b/ntoskrnl/inbv/logo/17.bmp deleted file mode 100644 index 209227e9847..00000000000 Binary files a/ntoskrnl/inbv/logo/17.bmp and /dev/null differ diff --git a/ntoskrnl/inbv/logo/2.bmp b/ntoskrnl/inbv/logo/2.bmp index 43984762c5f..04461badcf4 100644 Binary files a/ntoskrnl/inbv/logo/2.bmp and b/ntoskrnl/inbv/logo/2.bmp differ diff --git a/ntoskrnl/inbv/logo/3.bmp b/ntoskrnl/inbv/logo/3.bmp index 7e95ca2b662..c10b768de5f 100644 Binary files a/ntoskrnl/inbv/logo/3.bmp and b/ntoskrnl/inbv/logo/3.bmp differ diff --git a/ntoskrnl/inbv/logo/4.bmp b/ntoskrnl/inbv/logo/4.bmp index 239307b7d95..7aabbbfeb6e 100644 Binary files a/ntoskrnl/inbv/logo/4.bmp and b/ntoskrnl/inbv/logo/4.bmp differ diff --git a/ntoskrnl/inbv/logo/5.bmp b/ntoskrnl/inbv/logo/5.bmp index f7a7cb3abf0..94fb7a9dfde 100644 Binary files a/ntoskrnl/inbv/logo/5.bmp and b/ntoskrnl/inbv/logo/5.bmp differ diff --git a/ntoskrnl/inbv/logo/6.bmp b/ntoskrnl/inbv/logo/6.bmp index a8cafc569c0..08344117cb2 100644 Binary files a/ntoskrnl/inbv/logo/6.bmp and b/ntoskrnl/inbv/logo/6.bmp differ diff --git a/ntoskrnl/inbv/logo/7.bmp b/ntoskrnl/inbv/logo/7.bmp index d137807c9f9..24ea2137758 100644 Binary files a/ntoskrnl/inbv/logo/7.bmp and b/ntoskrnl/inbv/logo/7.bmp differ diff --git a/ntoskrnl/inbv/logo/8.bmp b/ntoskrnl/inbv/logo/8.bmp index 239307b7d95..344e0b23c44 100644 Binary files a/ntoskrnl/inbv/logo/8.bmp and b/ntoskrnl/inbv/logo/8.bmp differ diff --git a/ntoskrnl/include/internal/cm.h b/ntoskrnl/include/internal/cm.h index 9218e0741f0..537111a4f29 100644 --- a/ntoskrnl/include/internal/cm.h +++ b/ntoskrnl/include/internal/cm.h @@ -1454,6 +1454,12 @@ CmShutdownSystem( VOID ); +VOID +NTAPI +CmSetLazyFlushState( + IN BOOLEAN Enable +); + // // Global variables accessible from all of Cm // diff --git a/ntoskrnl/include/internal/ex.h b/ntoskrnl/include/internal/ex.h index d981389a279..3777a2f57e7 100644 --- a/ntoskrnl/include/internal/ex.h +++ b/ntoskrnl/include/internal/ex.h @@ -26,6 +26,7 @@ extern ULONG NtGlobalFlag; extern ULONG ExpInitializationPhase; extern ULONG ExpAltTimeZoneBias; extern LIST_ENTRY ExSystemLookasideListHead; +extern PCALLBACK_OBJECT PowerStateCallback; typedef struct _EXHANDLE { @@ -158,6 +159,10 @@ VOID NTAPI ExpInitializeWorkerThreads(VOID); +VOID +NTAPI +ExSwapinWorkerThreads(IN BOOLEAN AllowSwap); + VOID NTAPI ExpInitLookasideLists(VOID); diff --git a/ntoskrnl/include/internal/hal.h b/ntoskrnl/include/internal/hal.h index 9c0c77ffa65..47b76beee48 100644 --- a/ntoskrnl/include/internal/hal.h +++ b/ntoskrnl/include/internal/hal.h @@ -53,6 +53,18 @@ xHalHaltSystem( VOID ); +VOID +NTAPI +xHalEndOfBoot( + VOID +); + +VOID +NTAPI +xHalSetWakeEnable( + IN BOOLEAN Enable +); + UCHAR NTAPI xHalVectorToIDTEntry( diff --git a/ntoskrnl/include/internal/inbv.h b/ntoskrnl/include/internal/inbv.h index bc7ee504efa..eb87f83e216 100644 --- a/ntoskrnl/include/internal/inbv.h +++ b/ntoskrnl/include/internal/inbv.h @@ -7,6 +7,13 @@ typedef struct _InbvProgressState ULONG Bias; } INBV_PROGRESS_STATE; +typedef struct _BT_PROGRESS_INDICATOR +{ + ULONG Count; + ULONG Expected; + ULONG Percentage; +} BT_PROGRESS_INDICATOR, *PBT_PROGRESS_INDICATOR; + typedef enum _ROT_BAR_TYPE { RB_UNSPECIFIED, @@ -44,4 +51,24 @@ FinalizeBootLogo( VOID ); +PUCHAR +NTAPI +InbvGetResourceAddress( + IN ULONG ResourceNumber +); + +VOID +NTAPI +InbvBitBlt( + IN PUCHAR Buffer, + IN ULONG X, + IN ULONG Y +); + +VOID +NTAPI +InbvIndicateProgress( + VOID +); + extern BOOLEAN InbvBootDriverInstalled; diff --git a/ntoskrnl/include/internal/io.h b/ntoskrnl/include/internal/io.h index cf45a025943..c8b671693af 100644 --- a/ntoskrnl/include/internal/io.h +++ b/ntoskrnl/include/internal/io.h @@ -743,14 +743,14 @@ IoInitShutdownNotification( VOID NTAPI -IoShutdownRegisteredDevices( - VOID +IoShutdownSystem( + IN ULONG Phase ); VOID NTAPI -IoShutdownRegisteredFileSystems( - VOID +IopShutdownBaseFileSystems( + IN PLIST_ENTRY ListHead ); // diff --git a/ntoskrnl/include/internal/po.h b/ntoskrnl/include/internal/po.h index e45a0d95957..01ddf3b5c37 100644 --- a/ntoskrnl/include/internal/po.h +++ b/ntoskrnl/include/internal/po.h @@ -32,6 +32,228 @@ #define POTRACE(x, ...) DPRINT(__VA_ARGS__) #endif +typedef struct _PO_HIBER_PERF +{ + ULONGLONG IoTicks; + ULONGLONG InitTicks; + ULONGLONG CopyTicks; + ULONGLONG StartCount; + ULONG ElapsedTime; + ULONG IoTime; + ULONG CopyTime; + ULONG InitTime; + ULONG PagesWritten; + ULONG PagesProcessed; + ULONG BytesCopied; + ULONG DumpCount; + ULONG FileRuns; +} PO_HIBER_PERF, *PPO_HIBER_PERF; + +typedef struct _PO_MEMORY_IMAGE +{ + ULONG Signature; + ULONG Version; + ULONG CheckSum; + ULONG LengthSelf; + PFN_NUMBER PageSelf; + ULONG PageSize; + ULONG ImageType; + LARGE_INTEGER SystemTime; + ULONGLONG InterruptTime; + ULONG FeatureFlags; + UCHAR HiberFlags; + UCHAR spare[3]; + ULONG NoHiberPtes; + ULONG_PTR HiberVa; + PHYSICAL_ADDRESS HiberPte; + ULONG NoFreePages; + ULONG FreeMapCheck; + ULONG WakeCheck; + PFN_NUMBER TotalPages; + PFN_NUMBER FirstTablePage; + PFN_NUMBER LastFilePage; + PO_HIBER_PERF PerfInfo; +} PO_MEMORY_IMAGE, *PPO_MEMORY_IMAGE; + +typedef struct _PO_MEMORY_RANGE_ARRAY_RANGE +{ + PFN_NUMBER PageNo; + PFN_NUMBER StartPage; + PFN_NUMBER EndPage; + ULONG CheckSum; +} PO_MEMORY_RANGE_ARRAY_RANGE; + +typedef struct _PO_MEMORY_RANGE_ARRAY_LINK +{ + struct _PO_MEMORY_RANGE_ARRAY *Next; + PFN_NUMBER NextTable; + ULONG CheckSum; + ULONG EntryCount; +} PO_MEMORY_RANGE_ARRAY_LINK; + +typedef struct _PO_MEMORY_RANGE_ARRAY +{ + union + { + PO_MEMORY_RANGE_ARRAY_RANGE Range; + PO_MEMORY_RANGE_ARRAY_LINK Link; + }; +} PO_MEMORY_RANGE_ARRAY, *PPO_MEMORY_RANGE_ARRAY; + +typedef struct _POP_HIBER_CONTEXT +{ + BOOLEAN WriteToFile; + BOOLEAN ReserveLoaderMemory; + BOOLEAN ReserveFreeMemory; + BOOLEAN VerifyOnWake; + BOOLEAN Reset; + UCHAR HiberFlags; + BOOLEAN LinkFile; + HANDLE LinkFileHandle; + PKSPIN_LOCK Lock; + BOOLEAN MapFrozen; + RTL_BITMAP MemoryMap; + LIST_ENTRY ClonedRanges; + ULONG ClonedRangeCount; + PLIST_ENTRY NextCloneRange; + PFN_NUMBER NextPreserve; + PMDL LoaderMdl; + PMDL Clones; + PUCHAR NextClone; + ULONG NoClones; + PMDL Spares; + ULONGLONG PagesOut; + PVOID IoPage; + PVOID CurrentMcb; + PVOID DumpStack; + PKPROCESSOR_STATE WakeState; + ULONG NoRanges; + ULONG_PTR HiberVa; + PHYSICAL_ADDRESS HiberPte; + NTSTATUS Status; + PPO_MEMORY_IMAGE MemoryImage; + PPO_MEMORY_RANGE_ARRAY TableHead; + PVOID CompressionWorkspace; + PUCHAR CompressedWriteBuffer; + PULONG PerformanceStats; + PVOID CompressionBlock; + PVOID DmaIO; + PVOID TemporaryHeap; + PO_HIBER_PERF PerfInfo; +} POP_HIBER_CONTEXT, *PPOP_HIBER_CONTEXT; + +typedef struct _PO_NOTIFY_ORDER_LEVEL +{ + KEVENT LevelReady; + ULONG DeviceCount; + ULONG ActiveCount; + LIST_ENTRY WaitSleep; + LIST_ENTRY ReadySleep; + LIST_ENTRY Pending; + LIST_ENTRY Complete; + LIST_ENTRY ReadyS0; + LIST_ENTRY WaitS0; +} PO_NOTIFY_ORDER_LEVEL, *PPO_NOTIFY_ORDER_LEVEL; + +typedef struct _POP_SHUTDOWN_BUG_CHECK +{ + HANDLE ThreadHandle; + HANDLE ThreadId; + HANDLE ProcessId; + ULONG Code; + ULONG_PTR Parameter1; + ULONG_PTR Parameter2; + ULONG_PTR Parameter3; + ULONG_PTR Parameter4; +} POP_SHUTDOWN_BUG_CHECK, *PPOP_SHUTDOWN_BUG_CHECK; + +typedef struct _POP_DEVICE_POWER_IRP +{ + SINGLE_LIST_ENTRY Free; + PIRP Irp; + PPO_DEVICE_NOTIFY Notify; + LIST_ENTRY Pending; + LIST_ENTRY Complete; + LIST_ENTRY Abort; + LIST_ENTRY Failed; +} POP_DEVICE_POWER_IRP, *PPOP_DEVICE_POWER_IRP; + +typedef struct _PO_DEVICE_NOTIFY_ORDER +{ + ULONG DevNodeSequence; + PDEVICE_OBJECT *WarmEjectPdoPointer; + PO_NOTIFY_ORDER_LEVEL OrderLevel[8]; +} PO_DEVICE_NOTIFY_ORDER, *PPO_DEVICE_NOTIFY_ORDER; + +typedef struct _POP_DEVICE_SYS_STATE +{ + UCHAR IrpMinor; + SYSTEM_POWER_STATE SystemState; + PKEVENT Event; + KSPIN_LOCK SpinLock; + PKTHREAD Thread; + BOOLEAN GetNewDeviceList; + PO_DEVICE_NOTIFY_ORDER Order; + NTSTATUS Status; + PDEVICE_OBJECT FailedDevice; + BOOLEAN Waking; + BOOLEAN Cancelled; + BOOLEAN IgnoreErrors; + BOOLEAN IgnoreNotImplemented; + BOOLEAN _WaitAny; + BOOLEAN _WaitAll; + LIST_ENTRY PresentIrpQueue; + POP_DEVICE_POWER_IRP Head; + POP_DEVICE_POWER_IRP PowerIrpState[20]; +} POP_DEVICE_SYS_STATE, *PPOP_DEVICE_SYS_STATE; + +typedef struct _POP_POWER_ACTION +{ + UCHAR Updates; + UCHAR State; + BOOLEAN Shutdown; + POWER_ACTION Action; + SYSTEM_POWER_STATE LightestState; + ULONG Flags; + NTSTATUS Status; + UCHAR IrpMinor; + SYSTEM_POWER_STATE SystemState; + SYSTEM_POWER_STATE NextSystemState; + PPOP_SHUTDOWN_BUG_CHECK ShutdownBugCode; + PPOP_DEVICE_SYS_STATE DevState; + PPOP_HIBER_CONTEXT HiberContext; + ULONGLONG WakeTime; + ULONGLONG SleepTime; +} POP_POWER_ACTION, *PPOP_POWER_ACTION; + +typedef enum _POP_DEVICE_IDLE_TYPE +{ + DeviceIdleNormal, + DeviceIdleDisk, +} POP_DEVICE_IDLE_TYPE, *PPOP_DEVICE_IDLE_TYPE; + +typedef struct _POWER_CHANNEL_SUMMARY +{ + ULONG Signature; + ULONG TotalCount; + ULONG D0Count; + LIST_ENTRY NotifyList; +} POWER_CHANNEL_SUMMARY, *PPOWER_CHANNEL_SUMMARY; + +typedef struct _DEVICE_OBJECT_POWER_EXTENSION +{ + ULONG IdleCount; + ULONG ConservationIdleTime; + ULONG PerformanceIdleTime; + PDEVICE_OBJECT DeviceObject; + LIST_ENTRY IdleList; + DEVICE_POWER_STATE State; + LIST_ENTRY NotifySourceList; + LIST_ENTRY NotifyTargetList; + POWER_CHANNEL_SUMMARY PowerChannelSummary; + LIST_ENTRY Volume; +} DEVICE_OBJECT_POWER_EXTENSION, *PDEVICE_OBJECT_POWER_EXTENSION; + // // Initialization routines // @@ -47,6 +269,21 @@ PoInitializePrcb( IN PKPRCB Prcb ); +// +// I/O Routines +// +VOID +NTAPI +PoInitializeDeviceObject( + IN OUT PDEVOBJ_EXTENSION DeviceObjectExtension +); + +VOID +NTAPI +PoVolumeDevice( + IN PDEVICE_OBJECT DeviceObject +); + // // Power State routines // @@ -78,7 +315,33 @@ PoNotifySystemTimeSet( VOID ); +// +// Shutdown routines +// +VOID +NTAPI +PopReadShutdownPolicy( + VOID +); + +VOID +NTAPI +PopGracefulShutdown( + IN PVOID Context +); + +VOID +NTAPI +PopFlushVolumes( + IN BOOLEAN ShuttingDown +); + // // Global data inside the Power Manager // extern PDEVICE_NODE PopSystemPowerDeviceNode; +extern KGUARDED_MUTEX PopVolumeLock; +extern LIST_ENTRY PopVolumeDevices; +extern KSPIN_LOCK PopDopeGlobalLock; +extern POP_POWER_ACTION PopAction; + diff --git a/ntoskrnl/include/ntoskrnl.h b/ntoskrnl/include/ntoskrnl.h index 4656597cbc0..f1052ed38df 100644 --- a/ntoskrnl/include/ntoskrnl.h +++ b/ntoskrnl/include/ntoskrnl.h @@ -70,6 +70,7 @@ #include #include "internal/probe.h" +#include "resource.h" // // Define the internal versions of external and public global data diff --git a/ntoskrnl/include/resource.h b/ntoskrnl/include/resource.h new file mode 100644 index 00000000000..b9bdd541a11 --- /dev/null +++ b/ntoskrnl/include/resource.h @@ -0,0 +1,23 @@ +#pragma once + +#define IDB_BOOT_LOGO 1 +#define IDB_HIBERNATE_LOGO 2 +#define IDB_SHUTDOWN_LOGO 3 +#define IDB_LOGO 5 +#define IDB_LOGO_HEADER 6 +#define IDB_LOGO_BAND 7 + +#define IDB_BAR_SERVER 4 +#define IDB_BAR_PRO 8 +#define IDB_BAR_HOME 9 + +#define IDB_PROF_TEXT 10 +#define IDB_HOME_TEXT 11 +#define IDB_EMBEDDED_TEXT 12 +#define IDB_MCE_TEXT 18 + +#define IDB_SERVER_LOGO 13 +#define IDB_SERVER_HEADER 14 +#define IDB_SERVER_BAND 15 +#define IDB_STORAGE_SERVER 16 +#define IDB_CLUSTER_SERVER 17 diff --git a/ntoskrnl/io/iomgr/device.c b/ntoskrnl/io/iomgr/device.c index 482f7300fc9..7434970734f 100644 --- a/ntoskrnl/io/iomgr/device.c +++ b/ntoskrnl/io/iomgr/device.c @@ -17,9 +17,11 @@ /* GLOBALS ********************************************************************/ ULONG IopDeviceObjectNumber = 0; - LIST_ENTRY ShutdownListHead, LastChanceShutdownListHead; KSPIN_LOCK ShutdownListLock; +extern LIST_ENTRY IopDiskFsListHead; +extern LIST_ENTRY IopCdRomFsListHead; +extern LIST_ENTRY IopTapeFsListHead; /* PRIVATE FUNCTIONS **********************************************************/ @@ -95,7 +97,15 @@ IopAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, VOID NTAPI -IoShutdownRegisteredDevices(VOID) +IoShutdownPnpDevices(VOID) +{ + /* This routine is only used by Driver Verifier to validate shutdown */ + return; +} + +VOID +NTAPI +IoShutdownSystem(IN ULONG Phase) { PLIST_ENTRY ListEntry; PDEVICE_OBJECT DeviceObject; @@ -104,46 +114,108 @@ IoShutdownRegisteredDevices(VOID) PIRP Irp; KEVENT Event; NTSTATUS Status; - + /* Initialize an event to wait on */ KeInitializeEvent(&Event, NotificationEvent, FALSE); - - /* Get the first entry and start looping */ - ListEntry = ExInterlockedRemoveHeadList(&ShutdownListHead, - &ShutdownListLock); - while (ListEntry) + + /* What phase? */ + if (Phase == 0) { - /* Get the shutdown entry */ - ShutdownEntry = CONTAINING_RECORD(ListEntry, - SHUTDOWN_ENTRY, - ShutdownList); + /* Shutdown PnP */ + IoShutdownPnpDevices(); - /* Get the attached device */ - DeviceObject = IoGetAttachedDevice(ShutdownEntry->DeviceObject); - - /* Build the shutdown IRP and call the driver */ - Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN, - DeviceObject, - NULL, - 0, - NULL, - &Event, - &StatusBlock); - Status = IoCallDriver(DeviceObject, Irp); - if (Status == STATUS_PENDING) - { - /* Wait on the driver */ - KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); - } - - /* Free the shutdown entry and reset the event */ - ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); - KeClearEvent(&Event); - - /* Go to the next entry */ + /* Loop first-chance shutdown notifications */ ListEntry = ExInterlockedRemoveHeadList(&ShutdownListHead, &ShutdownListLock); - } + while (ListEntry) + { + /* Get the shutdown entry */ + ShutdownEntry = CONTAINING_RECORD(ListEntry, + SHUTDOWN_ENTRY, + ShutdownList); + + /* Get the attached device */ + DeviceObject = IoGetAttachedDevice(ShutdownEntry->DeviceObject); + + /* Build the shutdown IRP and call the driver */ + Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN, + DeviceObject, + NULL, + 0, + NULL, + &Event, + &StatusBlock); + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait on the driver */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + } + + /* Get rid of our reference to it */ + ObDereferenceObject(DeviceObject); + + /* Free the shutdown entry and reset the event */ + ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); + KeClearEvent(&Event); + + /* Go to the next entry */ + ListEntry = ExInterlockedRemoveHeadList(&ShutdownListHead, + &ShutdownListLock); + } + } + else if (Phase == 1) + { + /* Shutdown disk file systems */ + IopShutdownBaseFileSystems(&IopDiskFsListHead); + + /* Shutdown cdrom file systems */ + IopShutdownBaseFileSystems(&IopCdRomFsListHead); + + /* Shutdown tape filesystems */ + IopShutdownBaseFileSystems(&IopTapeFsListHead); + + /* Loop last-chance shutdown notifications */ + ListEntry = ExInterlockedRemoveHeadList(&LastChanceShutdownListHead, + &ShutdownListLock); + while (ListEntry) + { + /* Get the shutdown entry */ + ShutdownEntry = CONTAINING_RECORD(ListEntry, + SHUTDOWN_ENTRY, + ShutdownList); + + /* Get the attached device */ + DeviceObject = IoGetAttachedDevice(ShutdownEntry->DeviceObject); + + /* Build the shutdown IRP and call the driver */ + Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN, + DeviceObject, + NULL, + 0, + NULL, + &Event, + &StatusBlock); + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait on the driver */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + } + + /* Get rid of our reference to it */ + ObDereferenceObject(DeviceObject); + + /* Free the shutdown entry and reset the event */ + ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); + KeClearEvent(&Event); + + /* Go to the next entry */ + ListEntry = ExInterlockedRemoveHeadList(&LastChanceShutdownListHead, + &ShutdownListLock); + } + + } } NTSTATUS @@ -843,6 +915,9 @@ IoCreateDevice(IN PDRIVER_OBJECT DriverObject, /* Set the Type and Size. Question: why is Size 0 on Windows? */ DeviceObjectExtension->Type = IO_TYPE_DEVICE_OBJECT_EXTENSION; DeviceObjectExtension->Size = 0; + + /* Initialize with Power Manager */ + PoInitializeDeviceObject(DeviceObjectExtension); /* Link the Object and Extension */ DeviceObjectExtension->DeviceObject = CreatedDeviceObject; @@ -932,6 +1007,9 @@ IoCreateDevice(IN PDRIVER_OBJECT DriverObject, ASSERT((DriverObject->Flags & DRVO_UNLOAD_INVOKED) == 0); CreatedDeviceObject->DriverObject = DriverObject; IopEditDeviceList(DriverObject, CreatedDeviceObject, IopAdd); + + /* Link with the power manager */ + if (CreatedDeviceObject->Vpb) PoVolumeDevice(CreatedDeviceObject); /* Close the temporary handle and return to caller */ ObCloseHandle(TempHandle, KernelMode); @@ -1351,6 +1429,9 @@ IoRegisterLastChanceShutdownNotification(IN PDEVICE_OBJECT DeviceObject) /* Set the DO */ Entry->DeviceObject = DeviceObject; + + /* Reference it so it doesn't go away */ + ObReferenceObject(DeviceObject); /* Insert it into the list */ ExInterlockedInsertHeadList(&LastChanceShutdownListHead, @@ -1379,6 +1460,9 @@ IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject) /* Set the DO */ Entry->DeviceObject = DeviceObject; + + /* Reference it so it doesn't go away */ + ObReferenceObject(DeviceObject); /* Insert it into the list */ ExInterlockedInsertHeadList(&ShutdownListHead, @@ -1420,6 +1504,9 @@ IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject) /* Free the entry */ ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); + + /* Get rid of our reference to it */ + ObDereferenceObject(DeviceObject); } /* Go to the next entry */ @@ -1444,6 +1531,9 @@ IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject) /* Free the entry */ ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY); + + /* Get rid of our reference to it */ + ObDereferenceObject(DeviceObject); } /* Go to the next entry */ diff --git a/ntoskrnl/io/iomgr/driver.c b/ntoskrnl/io/iomgr/driver.c index 4dc022fb93f..c9925d5eb28 100644 --- a/ntoskrnl/io/iomgr/driver.c +++ b/ntoskrnl/io/iomgr/driver.c @@ -789,6 +789,7 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) * Display 'Loading XXX...' message */ IopDisplayLoadingMessage(ModuleName->Buffer, TRUE); + InbvIndicateProgress(); /* * Generate filename without path (not needed by freeldr) diff --git a/ntoskrnl/io/iomgr/drvrlist.c b/ntoskrnl/io/iomgr/drvrlist.c index 07068452fb0..42b69c6e2bd 100644 --- a/ntoskrnl/io/iomgr/drvrlist.c +++ b/ntoskrnl/io/iomgr/drvrlist.c @@ -507,6 +507,7 @@ IopInitializeSystemDrivers(VOID) { DPRINT(" Path: %wZ\n", &CurrentService->RegistryPath); Status = IopLoadDriver(CurrentService); + InbvIndicateProgress(); } } } @@ -538,7 +539,9 @@ IopInitializeSystemDrivers(VOID) { DPRINT(" Path: %wZ\n", &CurrentService->RegistryPath); Status = IopLoadDriver(CurrentService); + InbvIndicateProgress(); } + } } } diff --git a/ntoskrnl/io/iomgr/volume.c b/ntoskrnl/io/iomgr/volume.c index 3f019534e4b..606f8fd3b35 100644 --- a/ntoskrnl/io/iomgr/volume.c +++ b/ntoskrnl/io/iomgr/volume.c @@ -245,7 +245,7 @@ IopNotifyFileSystemChange(IN PDEVICE_OBJECT DeviceObject, VOID NTAPI -IoShutdownRegisteredFileSystems(VOID) +IopShutdownBaseFileSystems(IN PLIST_ENTRY ListHead) { PLIST_ENTRY ListEntry; PDEVICE_OBJECT DeviceObject; @@ -260,8 +260,8 @@ IoShutdownRegisteredFileSystems(VOID) KeInitializeEvent(&Event, NotificationEvent, FALSE); /* Get the first entry and start looping */ - ListEntry = IopDiskFsListHead.Flink; - while (ListEntry != &IopDiskFsListHead) + ListEntry = ListHead->Flink; + while (ListEntry != ListHead) { /* Get the device object */ DeviceObject = CONTAINING_RECORD(ListEntry, diff --git a/ntoskrnl/kdbg/kdb.c b/ntoskrnl/kdbg/kdb.c index 3f4010671ef..058e1128e0e 100644 --- a/ntoskrnl/kdbg/kdb.c +++ b/ntoskrnl/kdbg/kdb.c @@ -209,7 +209,7 @@ KdbpKdbTrapFrameFromKernelStack( RtlZeroMemory(KdbTrapFrame, sizeof(KDB_KTRAP_FRAME)); StackPtr = (ULONG_PTR *) KernelStack; -#if _M_X86_ +#ifdef _M_IX86 KdbTrapFrame->Tf.Ebp = StackPtr[3]; KdbTrapFrame->Tf.Edi = StackPtr[4]; KdbTrapFrame->Tf.Esi = StackPtr[5]; diff --git a/ntoskrnl/ntoskrnl-generic.rbuild b/ntoskrnl/ntoskrnl-generic.rbuild index 3c5334d3429..0427f1bceeb 100644 --- a/ntoskrnl/ntoskrnl-generic.rbuild +++ b/ntoskrnl/ntoskrnl-generic.rbuild @@ -439,8 +439,10 @@ obwait.c + events.c power.c - events.c + poshtdwn.c + povolume.c diff --git a/ntoskrnl/ntoskrnl.rc b/ntoskrnl/ntoskrnl.rc index 4ede1c557de..090bff5e44d 100644 --- a/ntoskrnl/ntoskrnl.rc +++ b/ntoskrnl/ntoskrnl.rc @@ -23,21 +23,20 @@ #endif #define VER_LANGNEUTRAL #include "common.ver" +#include "resource.h" // // Bug Codes and Bitmaps // #include "bugcodes.rc" -1 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/1.bmp" -2 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/2.bmp" -3 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/3.bmp" -4 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/4.bmp" -5 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/5.bmp" -6 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/6.bmp" -7 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/7.bmp" -8 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/8.bmp" -13 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/13.bmp" -14 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/14.bmp" -15 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/15.bmp" -16 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/16.bmp" -17 BITMAP DISCARDABLE "ntoskrnl/inbv/logo/17.bmp" +IDB_BOOT_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/1.bmp" +IDB_HIBERNATE_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/2.bmp" +IDB_SHUTDOWN_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/3.bmp" +IDB_BAR_SERVER BITMAP DISCARDABLE "ntoskrnl/inbv/logo/4.bmp" +IDB_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/5.bmp" +IDB_LOGO_HEADER BITMAP DISCARDABLE "ntoskrnl/inbv/logo/6.bmp" +IDB_LOGO_BAND BITMAP DISCARDABLE "ntoskrnl/inbv/logo/7.bmp" +IDB_BAR_PRO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/8.bmp" +IDB_SERVER_LOGO BITMAP DISCARDABLE "ntoskrnl/inbv/logo/5.bmp" +IDB_SERVER_HEADER BITMAP DISCARDABLE "ntoskrnl/inbv/logo/14.bmp" +IDB_SERVER_BAND BITMAP DISCARDABLE "ntoskrnl/inbv/logo/15.bmp" diff --git a/ntoskrnl/po/poshtdwn.c b/ntoskrnl/po/poshtdwn.c new file mode 100644 index 00000000000..25ee2e3ddf4 --- /dev/null +++ b/ntoskrnl/po/poshtdwn.c @@ -0,0 +1,196 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: ntoskrnl/po/poshtdwn.c + * PURPOSE: Power Manager Shutdown Code + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS *******************************************************************/ + +ULONG PopShutdownPowerOffPolicy; + +/* PRIVATE FUNCTIONS *********************************************************/ + +VOID +NTAPI +PopShutdownHandler(VOID) +{ + PUCHAR Logo1, Logo2; + ULONG i; + + /* Stop all interrupts */ + KeRaiseIrqlToDpcLevel(); + _disable(); + + /* Do we have boot video */ + if (InbvIsBootDriverInstalled()) + { + /* Yes we do, cleanup for shutdown screen */ + if (!InbvCheckDisplayOwnership()) InbvAcquireDisplayOwnership(); + InbvResetDisplay(); + InbvSolidColorFill(0, 0, 639, 479, 0); + InbvEnableDisplayString(TRUE); + InbvSetScrollRegion(0, 0, 639, 479); + + /* Display shutdown logo and message */ + Logo1 = InbvGetResourceAddress(IDB_SHUTDOWN_LOGO); + Logo2 = InbvGetResourceAddress(IDB_LOGO); + if ((Logo1) && (Logo2)) + { + InbvBitBlt(Logo1, 215, 352); + InbvBitBlt(Logo2, 217, 111); + } + } + else + { + /* Do it in text-mode */ + for (i = 0; i < 25; i++) InbvDisplayString("\n"); + InbvDisplayString(" "); + InbvDisplayString("The system may be powered off now.\n"); + } + + /* Hang the system */ + for (;;) HalHaltSystem(); +} + +VOID +NTAPI +PopShutdownSystem(IN POWER_ACTION SystemAction) +{ + /* Note should notify caller of NtPowerInformation(PowerShutdownNotification) */ + + /* Unload symbols */ + DPRINT1("It's the final countdown...%lx\n", SystemAction); + DbgUnLoadImageSymbols(NULL, (PVOID)-1, 0); + + /* Run the thread on the boot processor */ + KeSetSystemAffinityThread(1); + + /* Now check what the caller wants */ + switch (SystemAction) + { + /* Reset */ + case PowerActionShutdownReset: + + /* Try platform driver first, then legacy */ + //PopInvokeSystemStateHandler(PowerStateShutdownReset, NULL); + HalReturnToFirmware(HalRebootRoutine); + break; + + case PowerActionShutdown: + + /* Check for group policy that says to use "it is now safe" screen */ + if (PopShutdownPowerOffPolicy) + { + /* FIXFIX: Switch to legacy shutdown handler */ + //PopPowerStateHandlers[PowerStateShutdownOff].Handler = PopShutdownHandler; + } + + case PowerActionShutdownOff: + + /* Call shutdown handler */ + //PopInvokeSystemStateHandler(PowerStateShutdownOff, NULL); + + /* ReactOS Hack */ + PopSetSystemPowerState(PowerSystemShutdown); + PopShutdownHandler(); + + /* If that didn't work, call the HAL */ + HalReturnToFirmware(HalPowerDownRoutine); + break; + + default: + break; + } + + /* Anything else should not happen */ + KeBugCheckEx(INTERNAL_POWER_ERROR, 5, 0, 0, 0); +} + +VOID +NTAPI +PopGracefulShutdown(IN PVOID Context) +{ + /* First, the HAL handles any "end of boot" special functionality */ + DPRINT1("HAL shutting down\n"); + HalEndOfBoot(); + + /* In this step, the I/O manager does first-chance shutdown notification */ + DPRINT1("I/O manager shutting down in phase 0\n"); + IoShutdownSystem(0); + + /* In this step, all workers are killed and hives are flushed */ + DPRINT1("Configuration Manager shutting down\n"); + CmShutdownSystem(); + + /* Note that modified pages should be written here (MiShutdownSystem) */ + + /* In this step, the I/O manager does last-chance shutdown notification */ + DPRINT1("I/O manager shutting down in phase 1\n"); + IoShutdownSystem(1); + CcWaitForCurrentLazyWriterActivity(); + + /* Note that here, we should broadcast the power IRP to devices */ + + /* In this step, the HAL disables any wake timers */ + DPRINT1("Disabling wake timers\n"); + HalSetWakeEnable(FALSE); + + /* And finally the power request is sent */ + DPRINT1("Taking the system down\n"); + PopShutdownSystem(PopAction.Action); +} + +VOID +NTAPI +PopReadShutdownPolicy(VOID) +{ + UNICODE_STRING KeyString; + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status; + HANDLE KeyHandle; + ULONG Length; + UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)]; + PKEY_VALUE_PARTIAL_INFORMATION Info = (PVOID)Buffer; + + /* Setup object attributes */ + RtlInitUnicodeString(&KeyString, + L"\\Registry\\Machine\\Software\\Policies\\Microsoft\\Windows NT"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyString, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + /* Open the key */ + Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + /* Open the policy value and query it */ + RtlInitUnicodeString(&KeyString, L"DontPowerOffAfterShutdown"); + Status = ZwQueryValueKey(KeyHandle, + &KeyString, + KeyValuePartialInformation, + &Info, + sizeof(Info), + &Length); + if ((NT_SUCCESS(Status)) && (Info->Type == REG_DWORD)) + { + /* Read the policy */ + PopShutdownPowerOffPolicy = *Info->Data == 1; + } + + /* Close the key */ + ZwClose(KeyHandle); + } +} + +/* PUBLIC FUNCTIONS **********************************************************/ + diff --git a/ntoskrnl/po/povolume.c b/ntoskrnl/po/povolume.c new file mode 100644 index 00000000000..58cc3327deb --- /dev/null +++ b/ntoskrnl/po/povolume.c @@ -0,0 +1,334 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: ntoskrnl/po/povolume.c + * PURPOSE: Power Manager DOPE and Volume Management + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS *******************************************************************/ + +typedef struct _POP_FLUSH_VOLUME +{ + LIST_ENTRY List; + LONG Count; + KEVENT Wait; +} POP_FLUSH_VOLUME, *PPOP_FLUSH_VOLUME; + +ULONG PopFlushPolicy = 0; + +KGUARDED_MUTEX PopVolumeLock; +LIST_ENTRY PopVolumeDevices; +KSPIN_LOCK PopDopeGlobalLock; + +/* PRIVATE FUNCTIONS *********************************************************/ + +PDEVICE_OBJECT_POWER_EXTENSION +NTAPI +PopGetDope(IN PDEVICE_OBJECT DeviceObject) +{ + PEXTENDED_DEVOBJ_EXTENSION DeviceExtension; + PDEVICE_OBJECT_POWER_EXTENSION Dope; + KIRQL OldIrql; + PAGED_CODE(); + + /* If the device already has the dope, return it */ + DeviceExtension = IoGetDevObjExtension(DeviceObject); + if (DeviceExtension->Dope) goto Return; + + /* Allocate some dope for the device */ + Dope = ExAllocatePoolWithTag(NonPagedPool, + sizeof(DEVICE_OBJECT_POWER_EXTENSION), + 'Dope'); + if (!Dope) goto Return; + + /* Initialize the initial contents of the dope */ + RtlZeroMemory(Dope, sizeof(DEVICE_OBJECT_POWER_EXTENSION)); + Dope->DeviceObject = DeviceObject; + Dope->State = PowerDeviceUnspecified; + InitializeListHead(&Dope->IdleList); + + /* Make sure only one caller can assign dope to a device */ + KeAcquireSpinLock(&PopDopeGlobalLock, &OldIrql); + + /* Make sure the device still has no dope */ + if (!DeviceExtension->Dope) + { + /* Give the local dope to this device, and remember we won the race */ + DeviceExtension->Dope = (PVOID)Dope; + Dope = NULL; + } + + /* Allow other dope transactions now */ + KeReleaseSpinLock(&PopDopeGlobalLock, OldIrql); + + /* Check if someone other than us already assigned the dope, so free ours */ + if (Dope) ExFreePoolWithTag(Dope, 'Dope'); + + /* Return the dope to the caller */ +Return: + return (PDEVICE_OBJECT_POWER_EXTENSION)DeviceExtension->Dope; +} + +VOID +NTAPI +PoVolumeDevice(IN PDEVICE_OBJECT DeviceObject) +{ + PDEVICE_OBJECT_POWER_EXTENSION Dope; + PAGED_CODE(); + + /* Get dope from the device (if the device has no dope, it will receive some) */ + DPRINT1("New volume: %p\n", DeviceObject); + Dope = PopGetDope(DeviceObject); + if (Dope) + { + /* Make sure we can flush safely */ + DPRINT1("Acquiring volume lock\n"); + KeAcquireGuardedMutex(&PopVolumeLock); + + /* Add this volume into the list of power-manager volumes */ + DPRINT1("Got DOPE: %p\n", Dope); + if (!Dope->Volume.Flink) InsertTailList(&PopVolumeDevices, &Dope->Volume); + + /* Allow flushes to go through */ + KeReleaseGuardedMutex(&PopVolumeLock); + } +} + +VOID +NTAPI +PopFlushVolumeWorker(IN PVOID Context) +{ + PPOP_FLUSH_VOLUME FlushContext = (PPOP_FLUSH_VOLUME)Context; + PDEVICE_OBJECT_POWER_EXTENSION Dope; + PLIST_ENTRY NextEntry; + NTSTATUS Status; + UCHAR Buffer[sizeof(OBJECT_NAME_INFORMATION) + 512]; + POBJECT_NAME_INFORMATION NameInfo = (PVOID)Buffer; + ULONG Length; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE VolumeHandle; + IO_STATUS_BLOCK IoStatusBlock; + + /* Acquire the flush lock since we're messing with the list */ + KeAcquireGuardedMutex(&PopVolumeLock); + + /* Loop the flush list */ + while (!IsListEmpty(&FlushContext->List)) + { + /* Grab the next (ie: current) entry and remove it */ + NextEntry = FlushContext->List.Flink; + RemoveEntryList(NextEntry); + + /* Add it back on the volume list */ + InsertTailList(&PopVolumeDevices, NextEntry); + + /* Done touching the volume list */ + KeReleaseGuardedMutex(&PopVolumeLock); + + /* Get the dope from the volume link */ + Dope = CONTAINING_RECORD(NextEntry, DEVICE_OBJECT_POWER_EXTENSION, Volume); + + /* Get the name */ + Status = ObQueryNameString(Dope->DeviceObject, + NameInfo, + sizeof(Buffer), + &Length); + if ((NT_SUCCESS(Status)) && (NameInfo->Name.Buffer)) + { + /* Open the volume */ + DPRINT1("Opening: %wZ\n", &NameInfo->Name); + InitializeObjectAttributes(&ObjectAttributes, + &NameInfo->Name, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + 0, + 0); + Status = ZwCreateFile(&VolumeHandle, + SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA, + &ObjectAttributes, + &IoStatusBlock, + NULL, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_OPEN, + 0, + NULL, + 0); + if (NT_SUCCESS(Status)) + { + /* Flush it and close it */ + DPRINT1("Sending flush to: %lx\n", VolumeHandle); + ZwFlushBuffersFile(VolumeHandle, &IoStatusBlock); + ZwClose(VolumeHandle); + } + } + + /* Acquire the flush lock again since we'll touch the list */ + KeAcquireGuardedMutex(&PopVolumeLock); + } + + /* One more flush completed... if it was the last, signal the caller */ + if (!--FlushContext->Count) KeSetEvent(&FlushContext->Wait, IO_NO_INCREMENT, FALSE); + + /* Serialize with flushers */ + KeReleaseGuardedMutex(&PopVolumeLock); +} + +VOID +NTAPI +PopFlushVolumes(IN BOOLEAN ShuttingDown) +{ + POP_FLUSH_VOLUME FlushContext = {{0}}; + ULONG FlushPolicy; + UNICODE_STRING RegistryName = RTL_CONSTANT_STRING(L"\\Registry"); + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE RegistryHandle; + PLIST_ENTRY NextEntry; + PDEVICE_OBJECT_POWER_EXTENSION Dope; + ULONG VolumeCount = 0; + NTSTATUS Status; + HANDLE ThreadHandle; + ULONG ThreadCount; + + /* Setup the flush context */ + InitializeListHead(&FlushContext.List); + KeInitializeEvent(&FlushContext.Wait, NotificationEvent, FALSE); + + /* What to flush */ + FlushPolicy = ShuttingDown ? 1 | 2 : PopFlushPolicy; + if ((FlushPolicy & 1)) + { + /* Registry flush requested, so open it */ + DPRINT1("Opening registry\n"); + InitializeObjectAttributes(&ObjectAttributes, + &RegistryName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + Status = ZwOpenKey(&RegistryHandle, KEY_READ, &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + /* Flush the registry */ + DPRINT1("Flushing registry\n"); + ZwFlushKey(RegistryHandle); + ZwClose(RegistryHandle); + } + } + + /* Serialize with other flushes */ + KeAcquireGuardedMutex(&PopVolumeLock); + + /* Scan the volume list */ + NextEntry = PopVolumeDevices.Flink; + while (NextEntry != &PopVolumeDevices) + { + /* Get the dope from the link */ + Dope = CONTAINING_RECORD(NextEntry, DEVICE_OBJECT_POWER_EXTENSION, Volume); + + /* Grab the next entry now, since we'll be modifying the list */ + NextEntry = NextEntry->Flink; + + /* Make sure the object is mounted, writable, exists, and is not a floppy */ + if (!(Dope->DeviceObject->Vpb->Flags & VPB_MOUNTED) || + (Dope->DeviceObject->Characteristics & FILE_FLOPPY_DISKETTE) || + (Dope->DeviceObject->Characteristics & FILE_READ_ONLY_DEVICE) || + ((Dope->DeviceObject->Vpb->RealDevice) && + (Dope->DeviceObject->Vpb->RealDevice->Characteristics & FILE_FLOPPY_DISKETTE))) + { + /* Not flushable */ + continue; + } + + /* Remove it from the dope and add it to the flush context list */ + RemoveEntryList(&Dope->Volume); + InsertTailList(&FlushContext.List, &Dope->Volume); + + /* Next */ + VolumeCount++; + } + + /* Check if we should skip non-removable devices */ + if (!(FlushPolicy & 2)) + { + /* ReactOS only implements this routine for shutdown, which requires it */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check if there were no volumes at all */ + if (!VolumeCount) + { + /* Nothing to do */ + KeReleaseGuardedMutex(&PopVolumeLock); + return; + } + + /* Allocate up to 8 flusher threads */ + ThreadCount = min(VolumeCount, 8); + InitializeObjectAttributes(&ObjectAttributes, + NULL, + OBJ_KERNEL_HANDLE, + NULL, + NULL); + + /* We will ourselves become a flusher thread */ + FlushContext.Count = 1; + ThreadCount--; + + /* Look for any extra ones we might need */ + while (ThreadCount > 0) + { + /* Create a new one */ + ThreadCount--; + DPRINT1("Creating flush thread\n"); + Status = PsCreateSystemThread(&ThreadHandle, + THREAD_ALL_ACCESS, + &ObjectAttributes, + 0L, + NULL, + PopFlushVolumeWorker, + &FlushContext); + if (NT_SUCCESS(Status)) + { + /* One more created... */ + FlushContext.Count++; + ZwClose(ThreadHandle); + } + } + + /* Allow flushes to go through */ + KeReleaseGuardedMutex(&PopVolumeLock); + + /* Enter the flush work */ + DPRINT1("Local flush\n"); + PopFlushVolumeWorker(&FlushContext); + + /* Wait for all flushes to be over */ + DPRINT1("Waiting for flushes\n"); + KeWaitForSingleObject(&FlushContext.Wait, Executive, KernelMode, FALSE, NULL); + DPRINT1("Flushes have completed\n"); +} + +VOID +NTAPI +PoInitializeDeviceObject(IN OUT PDEVOBJ_EXTENSION DeviceObjectExtension) +{ + PEXTENDED_DEVOBJ_EXTENSION DeviceExtension = (PVOID)DeviceObjectExtension; + PAGED_CODE(); + + /* Initialize the power flags */ + DeviceExtension->PowerFlags = PowerSystemUnspecified & 0xF; + DeviceExtension->PowerFlags |= ((PowerDeviceUnspecified << 4) & 0xF0); + + /* The device object is not on drugs yet */ + DeviceExtension->Dope = NULL; +} + +/* PUBLIC FUNCTIONS **********************************************************/ + diff --git a/ntoskrnl/po/power.c b/ntoskrnl/po/power.c index f103898d2f5..96a211b5680 100644 --- a/ntoskrnl/po/power.c +++ b/ntoskrnl/po/power.c @@ -24,6 +24,8 @@ typedef struct _REQUEST_POWER_ITEM PDEVICE_NODE PopSystemPowerDeviceNode = NULL; BOOLEAN PopAcpiPresent = FALSE; +POP_POWER_ACTION PopAction; +WORK_QUEUE_ITEM PopShutdownWorkItem; /* PRIVATE FUNCTIONS *********************************************************/ @@ -165,6 +167,13 @@ PoInitSystem(IN ULONG BootPhase) PopAcpiPresent = KeLoaderBlock->Extension->AcpiTable != NULL ? TRUE : FALSE; } + + /* Initialize volume support */ + InitializeListHead(&PopVolumeDevices); + KeInitializeGuardedMutex(&PopVolumeLock); + + /* Initialize support for dope */ + KeInitializeSpinLock(&PopDopeGlobalLock); return TRUE; } @@ -636,3 +645,138 @@ NtSetThreadExecutionState(IN EXECUTION_STATE esFlags, /* All is good */ return STATUS_SUCCESS; } + +NTSTATUS +NTAPI +NtSetSystemPowerState(IN POWER_ACTION SystemAction, + IN SYSTEM_POWER_STATE MinSystemState, + IN ULONG Flags) +{ + KPROCESSOR_MODE PreviousMode = KeGetPreviousMode(); + POP_POWER_ACTION Action = {0}; + NTSTATUS Status; + + /* Check for invalid parameter combinations */ + if ((MinSystemState >= PowerSystemMaximum) || + (MinSystemState <= PowerSystemUnspecified) || + (SystemAction > PowerActionWarmEject) || + (SystemAction < PowerActionReserved) || + (Flags & ~(POWER_ACTION_QUERY_ALLOWED | + POWER_ACTION_UI_ALLOWED | + POWER_ACTION_OVERRIDE_APPS | + POWER_ACTION_LIGHTEST_FIRST | + POWER_ACTION_LOCK_CONSOLE | + POWER_ACTION_DISABLE_WAKES | + POWER_ACTION_CRITICAL))) + { + DPRINT1("NtSetSystemPowerState: Bad parameters!\n"); + DPRINT1(" SystemAction: 0x%x\n", SystemAction); + DPRINT1(" MinSystemState: 0x%x\n", MinSystemState); + DPRINT1(" Flags: 0x%x\n", Flags); + return STATUS_INVALID_PARAMETER; + } + + /* Check for user caller */ + if (PreviousMode != KernelMode) + { + /* Check for shutdown permission */ + if (!SeSinglePrivilegeCheck(SeShutdownPrivilege, PreviousMode)) + { + /* Not granted */ + DPRINT1("ERROR: Privilege not held for shutdown\n"); + //return STATUS_PRIVILEGE_NOT_HELD; HACK! + } + + /* Do it as a kernel-mode caller for consistency with system state */ + return ZwSetSystemPowerState (SystemAction, MinSystemState, Flags); + } + + /* Read policy settings (partial shutdown vs. full shutdown) */ + if (SystemAction == PowerActionShutdown) PopReadShutdownPolicy(); + + /* Disable lazy flushing of registry */ + DPRINT1("Stopping lazy flush\n"); + CmSetLazyFlushState(FALSE); + + /* Setup the power action */ + Action.Action = SystemAction; + Action.Flags = Flags; + + /* Notify callbacks */ + DPRINT1("Notifying callbacks\n"); + ExNotifyCallback(PowerStateCallback, (PVOID)3, NULL); + + /* Swap in any worker thread stacks */ + DPRINT1("Swapping worker threads\n"); + ExSwapinWorkerThreads(FALSE); + + /* Make our action global */ + PopAction = Action; + + /* Start power loop */ + Status = STATUS_CANCELLED; + while (TRUE) + { + /* Break out if there's nothing to do */ + if (Action.Action == PowerActionNone) break; + + /* Check for first-pass or restart */ + if (Status == STATUS_CANCELLED) + { + /* Check for shutdown action */ + if ((PopAction.Action == PowerActionShutdown) || + (PopAction.Action == PowerActionShutdownReset) || + (PopAction.Action == PowerActionShutdownOff)) + { + /* Set the action */ + PopAction.Shutdown = TRUE; + } + + /* Now we are good to go */ + Status = STATUS_SUCCESS; + } + + /* Check if we're still in an invalid status */ + if (!NT_SUCCESS(Status)) break; + + /* Flush all volumes and the registry */ + DPRINT1("Flushing volumes\n"); + PopFlushVolumes(PopAction.Shutdown); + + /* Set IRP for drivers */ + PopAction.IrpMinor = IRP_MN_SET_POWER; + if (PopAction.Shutdown) + { + DPRINT1("Queueing shutdown thread\n"); + /* Check if we are running in the system context */ + if (PsGetCurrentProcess() != PsInitialSystemProcess) + { + /* We're not, so use a worker thread for shutdown */ + ExInitializeWorkItem(&PopShutdownWorkItem, + &PopGracefulShutdown, + NULL); + + ExQueueWorkItem(&PopShutdownWorkItem, CriticalWorkQueue); + + /* Spend us -- when we wake up, the system is good to go down */ + KeSuspendThread(KeGetCurrentThread()); + Status = STATUS_SYSTEM_SHUTDOWN; + goto Exit; + + } + else + { + /* Do the shutdown inline */ + PopGracefulShutdown(NULL); + } + } + + /* You should not have made it this far */ + ASSERT(FALSE && "System is still up and running?!"); + break; + } + +Exit: + /* We're done, return */ + return Status; +} diff --git a/subsystems/win32/win32k/ntuser/painting.c b/subsystems/win32/win32k/ntuser/painting.c index 86ed104c2e3..66977db106f 100644 --- a/subsystems/win32/win32k/ntuser/painting.c +++ b/subsystems/win32/win32k/ntuser/painting.c @@ -502,7 +502,10 @@ IntIsWindowDrawable(PWINDOW_OBJECT Window) for (WndObject = Window; WndObject != NULL; WndObject = WndObject->spwndParent) { Wnd = WndObject->Wnd; - if (!(Wnd->style & WS_VISIBLE) || + if ( Window->state & WINDOWSTATUS_DESTROYING || // state2 + Window->state & WINDOWSTATUS_DESTROYED || + !Wnd || + !(Wnd->style & WS_VISIBLE) || ((Wnd->style & WS_MINIMIZE) && (WndObject != Window))) { return FALSE; diff --git a/subsystems/win32/win32k/ntuser/simplecall.c b/subsystems/win32/win32k/ntuser/simplecall.c index 3522cd15e95..f0dcc3a755b 100644 --- a/subsystems/win32/win32k/ntuser/simplecall.c +++ b/subsystems/win32/win32k/ntuser/simplecall.c @@ -490,28 +490,17 @@ NtUserCallHwndLock( case HWNDLOCK_ROUTINE_DRAWMENUBAR: { - PMENU_OBJECT Menu; DPRINT("HWNDLOCK_ROUTINE_DRAWMENUBAR\n"); - Ret = FALSE; - if (!((Wnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD)) - break; - - if(!(Menu = UserGetMenuObject((HMENU)(DWORD_PTR) Wnd->IDMenu))) - break; - - Menu->MenuInfo.WndOwner = hWnd; - Menu->MenuInfo.Height = 0; - - co_WinPosSetWindowPos( Window, - HWND_DESKTOP, - 0,0,0,0, - SWP_NOSIZE| - SWP_NOMOVE| - SWP_NOZORDER| - SWP_NOACTIVATE| - SWP_FRAMECHANGED ); - Ret = TRUE; + if ((Wnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD) + co_WinPosSetWindowPos( Window, + HWND_DESKTOP, + 0,0,0,0, + SWP_NOSIZE| + SWP_NOMOVE| + SWP_NOZORDER| + SWP_NOACTIVATE| + SWP_FRAMECHANGED ); break; }