-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e93cde
commit 2c5fcee
Showing
10 changed files
with
504 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2008-2014 Travis Geiselbrecht | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files | ||
* (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
#ifndef __LIB_ATOMIC_H | ||
#define __LIB_ATOMIC_H | ||
|
||
#include <Library/UefiBootServicesTableLib.h> | ||
|
||
STATIC inline INTN AtomicAnd(volatile INTN *Address, INTN Value) | ||
{ | ||
EFI_TPL OriginalTPL; | ||
INTN OldValue; | ||
|
||
OriginalTPL = gBS->RaiseTPL(TPL_HIGH_LEVEL); | ||
OldValue = *Address; | ||
*Address &= Value; | ||
gBS->RestoreTPL(OriginalTPL); | ||
|
||
return OldValue; | ||
} | ||
|
||
STATIC inline INTN AtomicOr(volatile INTN *Address, INTN Value) | ||
{ | ||
EFI_TPL OriginalTPL; | ||
INTN OldValue; | ||
|
||
OriginalTPL = gBS->RaiseTPL(TPL_HIGH_LEVEL); | ||
OldValue = *Address; | ||
*Address |= Value; | ||
gBS->RestoreTPL(OriginalTPL); | ||
|
||
return OldValue; | ||
} | ||
|
||
STATIC inline INTN AtomicRead(volatile INTN *Address) { return *Address; } | ||
|
||
STATIC inline VOID AtomicSet(volatile INTN *Address, INTN Value) | ||
{ | ||
*Address = Value; | ||
} | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2008 Travis Geiselbrecht | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files | ||
* (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
#ifndef __LIB_BITMAP_H | ||
#define __LIB_BITMAP_H | ||
|
||
#include <Library/AtomicLib.h> | ||
|
||
#define BIT_SHIFT(x, bit) (((x) >> (bit)) & 1) | ||
#define BITS_SHIFT(x, high, low) \ | ||
(((x) >> (low)) & ((1 << ((high) - (low) + 1)) - 1)) | ||
#define BIT_SET(x, bit) (((x) & (1UL << (bit))) ? 1 : 0) | ||
|
||
#define BITMAP_BITS_PER_WORD (sizeof(UINTN) * 8) | ||
#define BITMAP_NUM_WORDS(x) \ | ||
(((x) + BITMAP_BITS_PER_WORD - 1) / BITMAP_BITS_PER_WORD) | ||
#define BITMAP_WORD(x) ((x) / BITMAP_BITS_PER_WORD) | ||
#define BITMAP_BIT_IN_WORD(x) ((x) & (BITMAP_BITS_PER_WORD - 1)) | ||
|
||
#define BITMAP_BITS_PER_INT (sizeof(UINTN) * 8) | ||
#define BITMAP_BIT_IN_INT(x) ((x) & (BITMAP_BITS_PER_INT - 1)) | ||
#define BITMAP_INT(x) ((x) / BITMAP_BITS_PER_INT) | ||
|
||
#define BIT_MASK(x) \ | ||
(((x) >= sizeof(UINTN) * 8) ? (0UL - 1) : ((1UL << (x)) - 1)) | ||
|
||
STATIC inline INTN BitmapSet(UINTN *bitmap, INTN bit) | ||
{ | ||
UINTN mask = 1UL << BITMAP_BIT_IN_INT(bit); | ||
return AtomicOr(&((INTN *)bitmap)[BITMAP_INT(bit)], mask) & mask ? 1 : 0; | ||
} | ||
|
||
STATIC inline INTN BitmapClear(UINTN *bitmap, INTN bit) | ||
{ | ||
UINTN mask = 1UL << BITMAP_BIT_IN_INT(bit); | ||
|
||
return AtomicAnd(&((INTN *)bitmap)[BITMAP_INT(bit)], ~mask) & mask ? 1 : 0; | ||
} | ||
|
||
STATIC inline INTN BitmapTest(UINTN *bitmap, INTN bit) | ||
{ | ||
return BIT_SET(bitmap[BITMAP_WORD(bit)], BITMAP_BIT_IN_WORD(bit)); | ||
} | ||
|
||
#endif | ||
|
36 changes: 36 additions & 0 deletions
36
Silicon/Samsung/Exynos7885Pkg/Include/Library/KeypadDeviceImplLib.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef __LIBRARY_KEYPAD_DEVICE_IMPL_H__ | ||
#define __LIBRARY_KEYPAD_DEVICE_IMPL_H__ | ||
|
||
#include <Protocol/KeypadDevice.h> | ||
|
||
EFI_STATUS EFIAPI KeypadDeviceImplReset(KEYPAD_DEVICE_PROTOCOL *This); | ||
EFI_STATUS KeypadDeviceImplGetKeys( | ||
KEYPAD_DEVICE_PROTOCOL *This, KEYPAD_RETURN_API *KeypadReturnApi, | ||
UINT64 Delta); | ||
|
||
|
||
typedef enum { | ||
KEYSTATE_RELEASED, | ||
KEYSTATE_PRESSED, | ||
KEYSTATE_LONGPRESS_RELEASE, | ||
} KEY_STATE; | ||
|
||
typedef struct { | ||
// keydata to be send to the driver | ||
EFI_KEY_DATA KeyData; | ||
|
||
// the time the current action has been running | ||
UINT64 Time; | ||
|
||
// the current state of the key | ||
KEY_STATE State; | ||
|
||
// the current key has to repeat sending events | ||
BOOLEAN Repeat; | ||
|
||
// the user did a longpress | ||
BOOLEAN Longpress; | ||
} KEY_CONTEXT; | ||
|
||
#endif | ||
|
37 changes: 37 additions & 0 deletions
37
Silicon/Samsung/Exynos7885Pkg/Include/Protocol/KeypadDevice.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef __PROTOCOL_KEYPAD_DEVICE_H__ | ||
#define __PROTOCOL_KEYPAD_DEVICE_H__ | ||
|
||
#include <Protocol/SimpleTextInEx.h> | ||
|
||
#define KEYPAD_DEVICE_PROTOCOL_GUID \ | ||
{ \ | ||
0xb27625b5, 0x0b6c, 0x4614, \ | ||
{ \ | ||
0xaa, 0x3c, 0x33, 0x13, 0xb5, 0x1d, 0x36, 0x46 \ | ||
} \ | ||
} | ||
|
||
typedef struct _KEYPAD_DEVICE_PROTOCOL KEYPAD_DEVICE_PROTOCOL; | ||
typedef struct _KEYPAD_RETURN_API KEYPAD_RETURN_API; | ||
|
||
typedef VOID(EFIAPI *PUSH_EFI_KEY_BUF_TAIL)( | ||
KEYPAD_RETURN_API *This, EFI_KEY_DATA *KeyData); | ||
|
||
struct _KEYPAD_RETURN_API { | ||
PUSH_EFI_KEY_BUF_TAIL PushEfikeyBufTail; | ||
}; | ||
|
||
typedef EFI_STATUS(EFIAPI *KEYPAD_RESET)(KEYPAD_DEVICE_PROTOCOL *This); | ||
typedef EFI_STATUS(EFIAPI *KEYPAD_GET_KEYS)( | ||
KEYPAD_DEVICE_PROTOCOL *This, KEYPAD_RETURN_API *KeypadReturnApi, | ||
UINT64 Delta); | ||
|
||
struct _KEYPAD_DEVICE_PROTOCOL { | ||
KEYPAD_RESET Reset; | ||
KEYPAD_GET_KEYS GetKeys; | ||
}; | ||
|
||
extern EFI_GUID gExynosKeypadDeviceProtocolGuid; | ||
|
||
#endif | ||
|
Oops, something went wrong.