source: mainline/uspace/drv/platform/ski/ski.c

Last change on this file was 4122410, checked in by Jakub Jermar <jakub@…>, 7 years ago

Improve Doxygen documentaion

This is stil WiP. A number of libraries, drivers and services were
converted to using a more hierarchical and decentralized scheme when it
comes to specifying to which doxygen group they belong.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * Copyright (c) 2017 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/**
30 * @addtogroup ski ski
31 * @{
32 */
33
34/** @file
35 */
36
37#include <assert.h>
38#include <stdio.h>
39#include <errno.h>
40#include <stdlib.h>
41
42#include <ddf/driver.h>
43#include <ddf/log.h>
44
45#define NAME "ski"
46
47static errno_t ski_dev_add(ddf_dev_t *dev);
48
49static driver_ops_t ski_ops = {
50 .dev_add = &ski_dev_add
51};
52
53static driver_t ski_driver = {
54 .name = NAME,
55 .driver_ops = &ski_ops
56};
57
58static errno_t ski_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id)
59{
60 ddf_msg(LVL_NOTE, "Adding function '%s'.", name);
61
62 ddf_fun_t *fnode = NULL;
63 errno_t rc;
64
65 /* Create new device. */
66 fnode = ddf_fun_create(dev, fun_inner, name);
67 if (fnode == NULL) {
68 ddf_msg(LVL_ERROR, "Error creating function '%s'", name);
69 rc = ENOMEM;
70 goto error;
71 }
72
73 /* Add match ID */
74 rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
75 if (rc != EOK) {
76 ddf_msg(LVL_ERROR, "Error adding match ID");
77 goto error;
78 }
79
80 /* Register function. */
81 if (ddf_fun_bind(fnode) != EOK) {
82 ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
83 goto error;
84 }
85
86 return EOK;
87
88error:
89 if (fnode != NULL)
90 ddf_fun_destroy(fnode);
91
92 return rc;
93}
94
95static errno_t ski_add_functions(ddf_dev_t *dev)
96{
97 errno_t rc;
98
99 rc = ski_add_fun(dev, "console", "ski/console");
100 if (rc != EOK)
101 return rc;
102
103 return EOK;
104}
105
106/** Add device. */
107static errno_t ski_dev_add(ddf_dev_t *dev)
108{
109 ddf_msg(LVL_NOTE, "ski_dev_add, device handle = %d",
110 (int)ddf_dev_get_handle(dev));
111
112 /* Register functions. */
113 if (ski_add_functions(dev)) {
114 ddf_msg(LVL_ERROR, "Failed to add functions for ski platform.");
115 }
116
117 return EOK;
118}
119
120int main(int argc, char *argv[])
121{
122 errno_t rc;
123
124 printf(NAME ": Ski platform driver\n");
125
126 rc = ddf_log_init(NAME);
127 if (rc != EOK) {
128 printf(NAME ": Failed initializing logging service");
129 return 1;
130 }
131
132 return ddf_driver_main(&ski_driver);
133}
134
135/**
136 * @}
137 */
Note: See TracBrowser for help on using the repository browser.