1 /* Subroutines for the gcc driver.
2 Copyright (C) 2009 Free Software Foundation, Inc.
3 Contributed by Anatoly Sokolov <aesok@post.ru>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
27 /* Current architecture. */
28 const struct base_arch_s
*avr_current_arch
= NULL
;
31 const struct mcu_type_s
*avr_current_device
= NULL
;
33 /* Initialize avr_current_arch and avr_current_device variables. */
36 avr_set_current_device (const char *name
)
39 if (NULL
!= avr_current_arch
)
42 for (avr_current_device
= avr_mcu_types
; avr_current_device
->name
;
45 if (strcmp (avr_current_device
->name
, name
) == 0)
49 avr_current_arch
= &avr_arch_types
[avr_current_device
->arch
];
52 /* Returns command line parameters that describe the device architecture. */
55 avr_device_to_arch (int argc
, const char **argv
)
60 avr_set_current_device (argv
[0]);
62 return concat ("-m ", avr_current_arch
->arch_name
, NULL
);
65 /* Returns command line parameters that describe start of date section. */
68 avr_device_to_data_start (int argc
, const char **argv
)
70 unsigned long data_section_start
;
71 char data_section_start_str
[16];
76 avr_set_current_device (argv
[0]);
78 if (avr_current_device
->data_section_start
79 == avr_current_arch
->default_data_section_start
)
82 data_section_start
= 0x800000 + avr_current_device
->data_section_start
;
84 snprintf (data_section_start_str
, sizeof(data_section_start_str
) - 1,
85 "0x%lX", data_section_start
);
87 return concat ("-Tdata ", data_section_start_str
, NULL
);
90 /* Returns command line parameters that describe the device startfile. */
93 avr_device_to_startfiles (int argc
, const char **argv
)
98 avr_set_current_device (argv
[0]);
100 return concat ("crt", avr_current_device
->library_name
, ".o%s", NULL
);
103 /* Returns command line parameters that describe the device library. */
106 avr_device_to_devicelib (int argc
, const char **argv
)
111 avr_set_current_device (argv
[0]);
113 return concat ("-l", avr_current_device
->library_name
, NULL
);