Concepts

Informative

The model behind the memory driver: its asynchronous job model and job results, memory segmentation, multiple instances, and the optional binary-image packaging. Non-binding; the normative rules live in Mem — Requirements.

Jobs and results

Every operation (read, write, erase, blank-check, …) runs as an asynchronous job. A request returns immediately: it is accepted (E_OK) or rejected (E_NOT_OK, e.g. because a job is already pending — there is no queue, at most one job at a time per instance). The work then proceeds inside Mem_PollFunction; the caller observes progress with Mem_GetJobResult, which returns the result of the most recent job for that instance (each new job overwrites it).

        stateDiagram-v2
   direction LR
   [*] --> MEM_JOB_FINISHED : Mem_Init()
   MEM_JOB_FINISHED --> MEM_JOB_PENDING : job accepted
   MEM_JOB_PENDING --> MEM_JOB_FINISHED : success
   MEM_JOB_PENDING --> MEM_JOB_FAILED : failure
   MEM_JOB_PENDING --> MEM_JOB_PAGE_INCONSISTENT : blank check not blank
   MEM_JOB_PENDING --> MEM_JOB_ERROR_ECC_CORRECTED : correctable ECC
   MEM_JOB_PENDING --> MEM_JOB_ERROR_ECC_UNCORRECTED : uncorrectable ECC
    

Mem_JobResultType

Meaning

MEM_JOB_FINISHED

No job pending; the last job completed successfully.

MEM_JOB_PENDING

A job is in progress.

MEM_JOB_FAILED

The last job failed.

MEM_JOB_PAGE_INCONSISTENT

A blank check found the area not blank.

MEM_JOB_ERROR_ECC_CORRECTED

A correctable ECC error occurred; the job still completed.

MEM_JOB_ERROR_ECC_UNCORRECTED

An uncorrectable ECC error cancelled the job (set via Mem_OnError).

Memory segmentation

The driver works on physical segmentation only. The smallest erasable unit is a sector; the smallest writable unit is a write page. Addresses and lengths passed to the driver MUST be aligned to these units — the driver performs no alignment or buffering. See Key terms for sector / bank / address-area definitions.

Multiple instances

One driver instance can serve several memory instances of the same device, and several driver instances can coexist. Each memory instance is addressed by its Mem_InstanceIdType.

../../../_images/Multiple_Memory_Instance.drawio.png

Multiple memory instances served by one driver instance.

../../../_images/Multiple_Driver_Instance.drawio.png

Multiple driver instances coexisting.

Binary image format

A driver MAY be delivered as a self-contained, relocatable binary image for dynamic activation at runtime. The image begins with a header — a unique id, flags, the header address, and a delimiter address — followed by a service function-pointer table (one entry per API) and a delimiter whose value is the ones’ complement of the unique id (a consistency marker). Services can then be invoked directly or indirectly through the table.

../../../_images/Binary_Image_Format.drawio.png

Binary image layout: header, service function-pointer table, delimiter.

The normative rules for the header and table are CHI-MEM-MUST-22CHI-MEM-MUST-26.

Driving jobs

Because jobs are asynchronous, the integrator MUST call Mem_PollFunction cyclically while a job is pending; it advances the active job and updates the result. Mem_OnError is called by the system’s ECC handler to report an uncorrectable ECC error, which cancels the current job.

Job sequence

The informative view of running a job and handling ECC (CHI-MEM-MUST-04, CHI-MEM-MUST-06, CHI-MEM-MUST-13):

        sequenceDiagram
   participant UPL as UpperLayer
   participant DRV as MemDrv
   participant ECC as ECC circuit

   UPL->>DRV: Mem_Init(NULL_PTR)
   DRV-->>UPL: return (result MEM_JOB_FINISHED)

   Note over UPL,ECC: request a job, then poll for the result
   UPL->>DRV: Mem_Erase(instanceId, address, length)
   DRV-->>UPL: E_OK (result MEM_JOB_PENDING)
   loop until the job finishes
      UPL->>DRV: Mem_PollFunction()
      UPL->>DRV: Mem_GetJobResult(instanceId)
      DRV-->>UPL: current result
   end

   Note over UPL,ECC: uncorrectable ECC during a read
   UPL->>DRV: Mem_Read(instanceId, address, dataPtr, length)
   ECC->>DRV: Mem_OnError(instanceId)
   DRV-->>UPL: result MEM_JOB_ERROR_ECC_UNCORRECTED
    

Key terms

Term

Meaning

Write page

The smallest writable unit of the memory device.

Sector

The smallest erasable unit (uniform or variable sized).

Sector batch

A logical aggregation of uniformly sized sectors.

Sector burst

An aggregation of sectors accessed together for faster erase.

Page burst

An aggregation of write pages accessed together for faster programming.

Bank

A group of sectors mapped to one flash controller, within which read-while-write is not permitted.

Address area

A contiguous logical address space combining one or more physical sectors.