2 * Copyright (C) 2009 Dan Carpenter.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
22 static void match_dma_func(const char *fn
, struct expression
*expr
, void *param
)
24 struct expression
*arg
;
28 arg
= get_argument_from_call_expr(expr
->args
, PTR_INT(param
));
29 arg
= strip_expr(arg
);
32 if (arg
->type
== EXPR_PREOP
&& arg
->op
== '&') {
33 if (arg
->unop
->type
!= EXPR_SYMBOL
)
35 name
= expr_to_str(arg
);
36 sm_msg("error: doing dma on the stack (%s)", name
);
40 if (arg
->type
!= EXPR_SYMBOL
)
43 if (!sym
|| sym
->type
!= SYM_ARRAY
)
45 if (get_param_num(arg
) >= 0)
47 name
= expr_to_var(arg
);
48 sm_msg("error: doing dma on the stack (%s)", name
);
52 static void register_funcs_from_file(void)
58 token
= get_tokens_file("kernel.dma_funcs");
61 if (token_type(token
) != TOKEN_STREAMBEGIN
)
64 while (token_type(token
) != TOKEN_STREAMEND
) {
65 if (token_type(token
) != TOKEN_IDENT
)
67 func
= show_ident(token
->ident
);
69 if (token_type(token
) != TOKEN_NUMBER
)
71 arg
= atoi(token
->number
);
72 add_function_hook(func
, &match_dma_func
, INT_PTR(arg
));
78 void check_dma_on_stack(int id
)
80 if (option_project
!= PROJ_KERNEL
)
83 register_funcs_from_file();