GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_create.c Lines: 16 16 100.0 %
Date: 2024-12-05 08:52:37 Branches: 4 4 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Display Management (Display)                                        */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_system.h"
28
#include "gx_display.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_display_create                                  PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function creates the display and calls the display driver      */
44
/*    setup function.                                                     */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    display                               Display control block         */
49
/*    name                                  Name of display               */
50
/*    display_driver_setup                  Display driver setup function */
51
/*    width                                 Display width in pixels       */
52
/*    height                                Display height in pixels      */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    status                                Completion status             */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    memset                                Set control block to zero     */
61
/*    _gx_system_error_process              System error handler          */
62
/*    [dispaly_driver_setup]                Call display driver setup     */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    Application Code                                                    */
67
/*                                                                        */
68
/*  RELEASE HISTORY                                                       */
69
/*                                                                        */
70
/*    DATE              NAME                      DESCRIPTION             */
71
/*                                                                        */
72
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
73
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
74
/*                                            resulting in version 6.1    */
75
/*                                                                        */
76
/**************************************************************************/
77
737
UINT  _gx_display_create(GX_DISPLAY *display, GX_CONST GX_CHAR *name,
78
                         UINT (*display_driver_setup)(GX_DISPLAY *),
79
                         GX_VALUE width, GX_VALUE height)
80
{
81
82
UINT status;
83
84
    /* Clear the display control block.  */
85
737
    memset(display, 0, sizeof(GX_DISPLAY));
86
737
    display -> gx_display_width = width;
87
737
    display -> gx_display_height = height;
88
89
    /* Call the display driver setup function. This function initializes the underlying
90
       hardware and sets up all the primitive drawing function pointers.  */
91
92
737
    status =  display_driver_setup(display);
93
94
    /* Determine if the display driver setup was successful.  */
95
737
    if (status)
96
    {
97
        /* Error setting up display driver - call system error handler.  */
98
1
        _gx_system_error_process(GX_SYSTEM_DRIVER_SETUP_ERROR);
99
100
        /* Return to system error.  */
101
1
        return(GX_SYSTEM_ERROR);
102
    }
103
104
    /* Load the display ID field in the display control block.  */
105
736
    display -> gx_display_id =  GX_DISPLAY_ID;
106
107
    /* Save the display name.  */
108
736
    display -> gx_display_name =  name;
109
110
    /* Place the display on the list of created displays.
111
       First, check for an empty list.  */
112
113
736
    _gx_system_display_created_count++;
114
115
736
    if (_gx_system_display_created_list)
116
    {
117
8
        _gx_system_display_created_list -> gx_display_created_previous = display;
118
8
        display -> gx_display_created_next = _gx_system_display_created_list;
119
    }
120
121
736
    _gx_system_display_created_list =      display;
122
123
    /* Return successful status.  */
124
736
    return(GX_SUCCESS);
125
}
126