GithubHelp home page GithubHelp logo

pal's Introduction

PAL

Are you working on a bare-metal software project for Intel or ARM?

Are you sick of hunting through a 6000 page .pdf file to find basic facts about the contents of a system register?

Do you hate reading and writing code that sets |= (bitfields && like) << this;? (and accidentally using logical AND instead of bitwise AND in the process?)

Is your software so tightly coupled to your CPU that unit testing seems impossible?

You could use a PAL!

The Bareflank Processor Abstraction Layer transforms facts about your CPU into a software support library. This lets you access and manipulate the low-level details of your hardware through a convinient software API. Supose you are working on a C++ project for the Intel platform, and compiling/assembling with a GNU toolchain:

  1. Install Python > 3.6 and pip install lxml dataclasses colorama

  2. Generate a PAL for your project:

git clone https://github.com/bareflank/pal.git
./pal/pal.py --arch=intel_x64 --language=c++11 --access_mechanism=gas_att
cp -r pal/output </path/to/your/project>
  1. Profit!
#include "pal/control_register/cr0.h"
#include "pal/msr/ia32_feature_control.h"
#include "pal/cpuid/leaf_01_eax.h"

void pal_test(void)
{
    pal::cr0::pg::enable();                      // <-- Enable paging in CR0
    auto msr = pal::ia32_feature_control::get(); // <-- Read the current value of an MSR
    pal::leaf_01_eax::dump();                    // <-- Print the value of a CPUID leaf
}

  1. Reuse the code above in userspace for your unit tests:
./pal/pal.py --arch=intel_x64 --language=c++11 --access_mechanism=test
  1. Explore other built-in configuration options:
./pal/pal --help

Are you using CMake?

PAL has first class CMake support, just use upper-case names for all of PAL's configuration options:

git clone https://github.com/bareflank/pal.git
mkdir build && cd build
cmake ../pal -DARCH=armv8-a -DACCESS_MECHANISM=gas_aarch64
make

Does PAL generate everything from the <insert_vendor_name> manual?

Not yet, but it does support a whole lot. Is the project missing something that you need? Help us add it! There are a few different ways you can contribute new defintions to the project:

  1. Author and contribute a .yml file to the project's data directory. You can copy an exisitng definition as a starting point. One .yml file == one register defintion.

  2. Contribute a new parser for another existing source of information. For example, PAL can generate ARMv8-A register definitons from ARM's offical machine readable spec.

  3. PAL can generate the project's built in .yml files for you, if you can provide a way to parse an existing source of information into a PAL model.

Current status and scope

This project is primarily being developed as a support library for the Bareflank Hypervisor SDK, but we hope that other projects will benefit as well. Scope is currently limited to:

  1. System registers of a CPU.
  2. Intel x86_64
  3. ARMv8-A
  4. C and C++

The project's future wish-list currently consists of support for:

  1. Instructions of a CPU
  2. Registers of peripheral devices (e.g. IOMMU, PCIe, etc)
  3. Additional microarchitectures
  4. Additional programming languages

pal's People

Contributors

jaredwright avatar rianquinn avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.