2 * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #include "tcg/tcg_attr.h"
17 #include "pts/components/pts_component.h"
18 #include "pts/components/pts_component_manager.h"
19 #include "pts/components/tcg/tcg_comp_func_name.h"
20 #include "pts/components/ita/ita_comp_func_name.h"
21 #include "pts/components/ita/ita_comp_ima.h"
22 #include "pts/components/ita/ita_comp_tboot.h"
23 #include "pts/components/ita/ita_comp_tgrub.h"
26 #include <utils/debug.h>
29 * PTS Functional Component manager
31 pts_component_manager_t
*pts_components
;
34 * Reference count for IMC/IMV instances
36 static refcount_t libpts_ref
= 0;
39 * Described in header.
41 bool libpts_init(void)
45 if (!imcv_pa_tnc_attributes
)
49 imcv_pa_tnc_attributes
->add_vendor(imcv_pa_tnc_attributes
, PEN_TCG
,
50 tcg_attr_create_from_data
, tcg_attr_names
);
52 pts_components
= pts_component_manager_create();
53 pts_components
->add_vendor(pts_components
, PEN_TCG
,
54 pts_tcg_comp_func_names
, PTS_TCG_QUALIFIER_TYPE_SIZE
,
55 pts_tcg_qualifier_flag_names
, pts_tcg_qualifier_type_names
);
56 pts_components
->add_vendor(pts_components
, PEN_ITA
,
57 pts_ita_comp_func_names
, PTS_ITA_QUALIFIER_TYPE_SIZE
,
58 pts_ita_qualifier_flag_names
, pts_ita_qualifier_type_names
);
60 pts_components
->add_component(pts_components
, PEN_ITA
,
61 PTS_ITA_COMP_FUNC_NAME_TGRUB
,
62 pts_ita_comp_tgrub_create
);
63 pts_components
->add_component(pts_components
, PEN_ITA
,
64 PTS_ITA_COMP_FUNC_NAME_TBOOT
,
65 pts_ita_comp_tboot_create
);
66 pts_components
->add_component(pts_components
, PEN_ITA
,
67 PTS_ITA_COMP_FUNC_NAME_IMA
,
68 pts_ita_comp_ima_create
);
70 DBG1(DBG_LIB
, "libpts initialized");
78 * Described in header.
80 void libpts_deinit(void)
82 if (ref_put(&libpts_ref
))
84 pts_components
->remove_vendor(pts_components
, PEN_TCG
);
85 pts_components
->remove_vendor(pts_components
, PEN_ITA
);
86 pts_components
->destroy(pts_components
);
88 if (!imcv_pa_tnc_attributes
)
92 imcv_pa_tnc_attributes
->remove_vendor(imcv_pa_tnc_attributes
, PEN_TCG
);
93 DBG1(DBG_LIB
, "libpts terminated");