Skip to content

Commit

Permalink
setup: make cpu_frequency value globally available
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Jul 19, 2022
1 parent 57bc46d commit c144c0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@

boot_flags_t boot_flags;

unsigned long cpu_frequency;

#define QEMU_CONSOLE_PORT 0x0e9

static void __text_init init_console(void) {
Expand Down Expand Up @@ -123,15 +125,14 @@ static void __text_init map_bios_area(void) {

static void display_cpu_info(void) {
char cpu_identifier[49];
unsigned long freq;

if (!cpu_vendor_string(cpu_identifier))
return;

printk("CPU: %.48s\n", cpu_identifier);
freq = get_cpu_freq(cpu_identifier);
if (freq > 0)
printk("Frequency: %lu MHz\n", freq / MHZ(1));
cpu_frequency = get_cpu_freq(cpu_identifier);
if (cpu_frequency > 0)
printk("Frequency: %lu MHz\n", cpu_frequency / MHZ(1));
}

static void display_banner(void) { draw_logo(); }
Expand Down
1 change: 1 addition & 0 deletions include/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct boot_flags {
typedef struct boot_flags boot_flags_t;

extern char cpu_identifier[49];
extern unsigned long cpu_frequency;
extern boot_flags_t boot_flags;

/* Static declarations */
Expand Down

0 comments on commit c144c0a

Please sign in to comment.