LCOV - code coverage report
Current view: top level - hw/test - run-port80h.c (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 60 60 100.0 %
Date: 2024-01-02 21:04:04 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
       2                 :            : /*
       3                 :            :  * Test result of our LPC port 80h boot progress code
       4                 :            :  *
       5                 :            :  * Copyright 2018-2019 IBM Corp.
       6                 :            :  */
       7                 :            : 
       8                 :            : #include <stdio.h>
       9                 :            : #include <stdarg.h>
      10                 :            : #include <stdint.h>
      11                 :            : #include <assert.h>
      12                 :            : 
      13                 :            : #define __unused __attribute__((unused))
      14                 :            : 
      15                 :            : #define __LPC_H
      16                 :            : 
      17                 :            : uint8_t port80;
      18                 :            : uint16_t port8x;
      19                 :            : 
      20                 :         48 : static int64_t lpc_probe_write(int addr_type __unused, uint32_t addr,
      21                 :            :                         uint32_t data, uint32_t sz)
      22                 :            : {
      23                 :         48 :         assert((addr - 0x80) <= 2);
      24                 :         48 :         assert(sz == 1);
      25                 :         48 :         if (addr == 0x80)
      26                 :         16 :                 port80 = data;
      27                 :         48 :         if (addr == 0x81)
      28                 :         16 :                 port8x = data << 8 | (port8x & 0xff);
      29                 :         48 :         if (addr == 0x82)
      30                 :         16 :                 port8x = (port8x & 0xff00) | data;
      31                 :         48 :         return 0;
      32                 :            : }
      33                 :            : 
      34                 :            : #include "op-panel.h"
      35                 :            : 
      36                 :            : void op_display_lpc(enum op_severity s, enum op_module m, uint16_t c);
      37                 :            : 
      38                 :            : #include "../lpc-port80h.c"
      39                 :            : #include "../../core/test/stubs.c"
      40                 :            : 
      41                 :            : enum proc_chip_quirks proc_chip_quirks;
      42                 :            : 
      43                 :          1 : int main(void)
      44                 :            : {
      45                 :          1 :         op_display_lpc(OP_LOG, OP_MOD_INIT, 0x00);
      46                 :          1 :         assert(port80 == 0x80);
      47                 :          1 :         assert(port8x == 0x8000);
      48                 :          1 :         op_display_lpc(OP_WARN, OP_MOD_INIT, 0x00);
      49                 :          1 :         assert(port80 == 0x82);
      50                 :          1 :         assert(port8x == 0x8002);
      51                 :          1 :         op_display_lpc(OP_ERROR, OP_MOD_INIT, 0x00);
      52                 :          1 :         assert(port80 == 0x81);
      53                 :          1 :         assert(port8x == 0x8001);
      54                 :          1 :         op_display_lpc(OP_FATAL, OP_MOD_INIT, 0x00);
      55                 :          1 :         assert(port80 == 0x83);
      56                 :          1 :         assert(port8x == 0x8003);
      57                 :          1 :         op_display_lpc(OP_FATAL, OP_MOD_INIT, 0x0f);
      58                 :          1 :         assert(port80 == 0xBF);
      59                 :          1 :         assert(port8x == 0x803F);
      60                 :          1 :         op_display_lpc(OP_LOG, OP_MOD_INIT, 0x0f);
      61                 :          1 :         assert(port80 == 0xBC);
      62                 :          1 :         assert(port8x == 0x803C);
      63                 :          1 :         op_display_lpc(OP_FATAL, OP_MOD_CORE, 0x6666);
      64                 :          1 :         assert(port80 == 0xBF);
      65                 :          1 :         assert(port8x == 0x803F);
      66                 :          1 :         op_display_lpc(OP_LOG, OP_MOD_INIT, 0x01);
      67                 :          1 :         assert(port80 == 0x84);
      68                 :          1 :         assert(port8x == 0x8004);
      69                 :          1 :         op_display_lpc(OP_LOG, OP_MOD_CPU, 0x05);
      70                 :          1 :         assert(port80 == 0xC4);
      71                 :          1 :         assert(port8x == 0xC014);
      72                 :          1 :         op_display_lpc(OP_LOG, OP_MOD_LOCK, 0x07);
      73                 :          1 :         assert(port80 == 0xDC);
      74                 :          1 :         assert(port8x == 0xD01C);
      75                 :          1 :         op_display_lpc(OP_FATAL, OP_MOD_LOCK, 0x07);
      76                 :          1 :         assert(port80 == 0xDF);
      77                 :          1 :         assert(port8x == 0xD01F);
      78                 :          1 :         op_display_lpc(OP_FATAL, OP_MOD_MEM, 0x07);
      79                 :          1 :         assert(port80 == 0xEF);
      80                 :          1 :         assert(port8x == 0xE01F);
      81                 :          1 :         op_display_lpc(OP_WARN, OP_MOD_MEM, 0x02);
      82                 :          1 :         assert(port80 == 0xEA);
      83                 :          1 :         assert(port8x == 0xE00A);
      84                 :          1 :         op_display_lpc(OP_WARN, OP_MOD_CHIPTOD, 0x02);
      85                 :          1 :         assert(port80 == 0xFA);
      86                 :          1 :         assert(port8x == 0xF00A);
      87                 :            : 
      88                 :            :         /*
      89                 :            :          * We can't assert that OP_MOD_FSP is invalid as we'd end up
      90                 :            :          * trying to set port80 in the assert parth
      91                 :            :          */
      92                 :          1 :         op_display_lpc(OP_LOG, OP_MOD_FSP, 0x00);
      93                 :          1 :         assert(port80 == 0x80);
      94                 :          1 :         assert(port8x == 0x8000);
      95                 :          1 :         op_display_lpc(OP_LOG, OP_MOD_FSPCON, 0x00);
      96                 :          1 :         assert(port80 == 0x80);
      97                 :          1 :         assert(port8x == 0x8000);
      98                 :          1 :         return 0;
      99                 :            : }

Generated by: LCOV version 1.14