Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Symbian Hardware Abstraction Layer (HAL) APIs

From Wiki
Jump to: navigation, search

The Symbian C++ Hardware Abstraction Layer APIs can be used to query system capabilities, share state data with other applications and register for notification of changes to system states.

Article Metadata
Created: vvsnaresh (15 Apr 2007)
Last edited: hamishwillee (30 May 2013)

These APIs are implemented in two main components:

  • The Hardware Abstraction Layer (HAL)
  • The System Agent Components

HAL provides a very simple to use APIs, which can query the attributes of the device, for example:

  • Manufacturer: manufacturer of the device, hardware and software version number.
  • Processor: processor architecture, ABI and processor speed.
  • Memory: total RAM, free RAM and total ROM.
  • Screen: screen dimension and display color.
  • Keyboard information.

The class HAL (hal.h) derives from HALData (hal_data.h), which contains the definition of the enumeration TAttribute.

Header Required:

#include <hal.h>

Library needed:

LIBRARY hal.lib

The API itself is very small, with only three functions, all provided by the class HAL:

static TInt Get(TAttribute anAttribute, TInt& aValue);
static TInt Set(TAttribute anAttribute, TInt& aValue);
static TInt GetAll(TInt& aNumEntries, SEntry*& aData);

Some examples for getting the device attributes

  1. Getting all the device attributes
    TInt numHalEntries;
    HAL::SEntry* halEntries;
    HAL::GetAll(numHalEntries, halEntries);
  2. Getting one specific attribute, in this case total RAM in bytes.
    TInt ram;
    HAL::Get(HAL::EMemoryRAM, ram);

Some examples for setting the device attributes

TInt err = HAL::Set(HAL::ECaseSwitchDisplayOn, 1);

If a field is not settable, then the return value from the call will be one of the standard system error codes, typically KErrNotSupported.

This page was last modified on 30 May 2013, at 04:40.
32 page views in the last 30 days.