Menu

MyDriverSample

john f davis

This is the process for building a clone of DriverSample called MyDriverSample.

MyDriverSample is just a copy of DriverSample with the exception that it has a new guid and new routines names.

Clone the code and Build

Clone the DriverSample directory

  1. Copy the directory in fw\edk2\DriverSampleDxe to fw\edk2\MyDriverSample.
  2. Change file names from DriverSample to MyDriverSample.
  3. Examine the contents of each of the files in that directory. Look for DriverSample and DRIVER_SAMPLE and replace to MyDriverSample and MY_DRIVER_SAMPLE.
  4. In MyDriverSampleDxe.inf replace the GUID with one from www.GuidGen.com

Update MdeModulePkg to include the new driver

  1. Edit edk2\MdeModulePkg\MdeModulePkg.dsc so that the peer to DriverSample is duplicated.
  2. Notice that NVDataStruc.h includes Guid/MyDriverSampleHii.h now. This file has to be cloned. Chances are these GUIDs will need to be differed. For now leave them as is.

  3. Edit MdeModulePkg\Include\Guid\MyDriverSampleHii.h and MdeModulePkg\MdeModulePkg.dec find the entries corresponding to the #defines there are three of them. In the .h file they look like below.

Example change in the header file.

 //   0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D} 
 #define MY_DRIVER_SAMPLE_FORMSET_GUID 
  { 
    0x304A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D} 
  }

The first number there appears to be part of a GUID for the form. If you notice, the commented out line, which is the original line you can see that I edited the first number to make it unique. A changed to 3. All three duplicated defines need to be changed so the GUID is unique. This number is also used in the .dec file. Here is the lines from that file. You can see how the GUID is changed to correspond to those shown above.

  ## Include/Guid/MyDriverSampleHii.h
  gMyDriverSampleFormSetGuid           = { 0x304A27f4, 0xDF00, 0x4D42, { 0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D }}
  gMyDriverSampleInventoryGuid         = { 0x33f56470, 0x6141, 0x4621, { 0x8f, 0x19, 0x70, 0x4e, 0x57, 0x7a, 0xa9, 0xe8 }}
  gMyEfiIfrRefreshIdOpGuid             = { 0x35E655D9, 0x02A6, 0x46f2, { 0x9E, 0x76, 0xB8, 0xBE, 0x8E, 0x60, 0xAB, 0x22 }}

  #gMyDriverSampleFormSetGuid           = { 0xA04A27f4, 0xDF00, 0x4D42, { 0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D }}
  #gMyDriverSampleInventoryGuid         = { 0xb3f56470, 0x6141, 0x4621, { 0x8f, 0x19, 0x70, 0x4e, 0x57, 0x7a, 0xa9, 0xe8 }}
  #gMyEfiIfrRefreshIdOpGuid             = { 0xF5E655D9, 0x02A6, 0x46f2, { 0x9E, 0x76, 0xB8, 0xBE, 0x8E, 0x60, 0xAB, 0x22 }}
  1. Edit MdeModulePkg/Universal/MyDriverSampleDxe/VfrStrings.uni and change the text to make it unique. In this case, I only changed the driver sample title.

Update the Nt32Pkg

  1. Edit edk2\Nt32Pkg\Nt32Pkg.pdf and clone the DriverSampleDxe entry.
  2. Edit edk2\Nt32Pkg\Nt32Pkg.dsc and clone the DriverSample entry.

Update the EmulatorPkg

  1. Edit edk2\EmulatorPkg\EmulatorPkg.dsc and clone the DriverSample entry.
  2. Edit edk2\EmulatorPkg\EmulatorPkg.fdf and clone the DriverSample entry.

Use build cleanall and build all to build the code. Use build all 2> foo.txt and examine foo.txt to see that you don't have any warnings.

Running the sample driver

Here is how you run the driver.

  1. Issue build run
  2. Wait until timeout occurs and you get Shell> prompt.
  3. Issue exit command. It will show the following screen.

the image
image

  1. Select Device Manager. It will show the following screen.

the image
image

  1. This will list the drivers loaded. There should be similar entires, one is the original "Browser Testcase Engine" that corresponds to DriverSampleDxe and a new one "My Browser Testcase Engine" corresponding to the clone version MyDriverSampleDxe.

the image
image


Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.