nckernel
0.1
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
common
src
cpu_node.c
Go to the documentation of this file.
1
#include <
sys/types.h
>
2
#include <
stdio.h
>
3
#include <
stdlib.h
>
4
#include <
stddef.h
>
5
6
#include <
list.h
>
7
#include <
zone.h
>
8
#include <
cpu_node.h
>
9
10
#include <
debug.h
>
11
12
static
LIST_HEAD
(s_node_list);
13
14
struct
node
*
cpu_node_create
(
int
id
)
15
{
16
struct
node
*
node
;
17
18
node =
cpu_node_find
(
id
);
19
if
(node) {
20
return
node;
21
}
22
23
node =
malloc
(
sizeof
(*node));
24
if
(!node) {
25
return
NULL
;
26
}
27
28
node->
id
=
id
;
29
INIT_LIST_HEAD(&node->
zone_list
);
30
31
list_add_tail(&node->
head
, &s_node_list);
32
return
node;
33
}
34
35
int
cpu_node_destroy
(
struct
node
*
node
)
36
{
37
struct
list_head
*pos;
38
struct
list_head
*n;
39
struct
zone
*
zone
;
40
41
list_for_each_safe
(pos, n, &node->
zone_list
) {
42
list_del(pos);
43
zone =
list_entry
(pos,
struct
zone,
head
);
44
destroy_zone
(zone);
45
}
46
47
list_del(&node->
head
);
48
free
(node);
49
return
0;
50
}
51
52
struct
node
*
cpu_node_find
(
int
id
)
53
{
54
struct
list_head
*pos;
55
struct
node
*
node
;
56
57
node =
NULL
;
58
list_for_each
(pos, &s_node_list) {
59
node =
list_entry
(pos,
struct
node,
head
);
60
if
(node->
id
==
id
) {
61
break
;
62
}
63
64
node =
NULL
;
65
}
66
67
return
node;
68
}
69
70
/* End of a file */
Generated on Thu Nov 7 2013 02:45:25 for nckernel by
1.8.4