7/28/2024

PanelLib

Introduction

At the very beginning of EfiPy announcement, there is a demo program and introduction for EfiPy capability for graphics function. This program’s kernel is moved to be python library in Efi\StdLib\lib\python36.8\EfiPy2\Lib\PanelLib.py.

Example

Although this library structure is not beautiful enough, but multiple test example feature reused the class in PanelLib.py

from EfiPy2.Lib.PanelLib import EfiPyGfx, EfiPyFont, HintPrompt

And demo functions are divided into scripts. Here are these scripts description…

Efi\Apps\EfiPy2Sample\PanelGrid.py

It uses EfiPyGfx:: Rect() function to show small rectangle in screen.












Efi\Apps\EfiPy2Sample\PanelRuler.py

It uses EfiPyGfx() class to draw vertical and horizontal ruler.













Efi\Apps\EfiPy2Sample\PanelFont.py

It displays fonts with variable color in one screen.













Efi\Apps\EfiPy2Sample\PanelModeList.py

It uses GOP QueryMode() capsuled in EfiPyGfx class to lists available GOP mode.











Efi\Apps\EfiPy2Sample\PanelModeSet.py

It uses GOP SetMode() to set GOP mode number from GOP QueryMode().

7/14/2024

Blog update

Summarize

More than half of post in this blog are old. Some of them are out of date and will be hidden.

Another will be modified then these posts information can be referenced by EfiPy2.

Exception

The fist pot in this blog(EfiPy initial) will be keep for available for tagging the born of EfiPy.

Labels

EfiPy2 as post labels indicated that they are reviewed and run well on EfiPy2 environment.


7/11/2024

What is ctypesCallback.py in Efi/Apps /EfiPy2Sample/

 Background

At the beginning of porting ctypes to EFI environment, there are some validation programs. This is one of them to be used to test CFUNCTYPE if it works or not.

Test point

This script is mainly to declare a c types structure which is used for EFI protocol including member function pointer (EFIPY2_CFUNCTYPE1) and unsigned integer.

This statement is CFUNCTYPE check point.

Status = EfiPy2SampleProtocol.P1Func1 (20, None)

Procedure - python callback function by ctypes

1. Declaire python function (EfiPy2cFunc1 or EfiPy2cFunc2) for callback from ctypes.Structure object.

def EfiPy2cFunc1 (Val1, Val2):

  print ("   EfiPy2cFunc1 Val1:", Val1)

  return 0

2. Create EFIPY2_CFUNCTYPE1 from ctypes.CFUNCTYPE with the same with EfiPy2cFunc1 input/output interface.

EFIPY2_CFUNCTYPE1 = ctypes.CFUNCTYPE (

     ctypes.c_uint64,                 # Return value.

     ctypes.c_uint64,                 # first parameter.

     ctypes.POINTER(ctypes.c_uint32)  # second parameter.

     )

3. And assign an object P1 which is EFIPY2_CFUNCTYPE1 object has callback EfiPy2cFunc1.

P1 = EFIPY2_CFUNCTYPE1 (EfiPy2cFunc1)

Procedure - ctypes structure object with member EFIPY2_CFUNCTYPE1

1. This is ctypes structure EFIPY2_SAMPLEPROTOCOL_CLASS which can be used for EFI protocol
#
# Protocol Structure
#
class EFIPY2_SAMPLEPROTOCOL_CLASS (ctypes.Structure):
  _fields_ = [("P1Func1", EFIPY2_CFUNCTYPE1),
              ("P1Val",   ctypes.c_uint32),
              # ("P1Func2", EFIPY2_CFUNCTYPE2)
             ]
2. Create EFIPY2_SAMPLEPROTOCOL_CLASS's object
EfiPy2SampleProtocol = EFIPY2_SAMPLEPROTOCOL_CLASS (P1, 3)

Go for run

This is the content in previous section Test Point

Status = EfiPy2SampleProtocol.P1Func1 (20, None)

7/10/2024

MsrBasic.py

Quick update

This is the same as CpuIdBasic.py. It  calls corepy library to achieve reading MSR data.

Here is new version of CpuIdBasic.py.

Instruction rdmsr in corepy is missed for months and it is patched in Efi/StdLib/lib/python36.8/corepy/arch/x86_64/isa/x86_64_isa.py

Both CpuId and Msr register query program run in BSP (Boot Strap Processor, not Board Support Package), only.