Fix cross compilation (e.g. on Darwin). Following changes to make.tmpl,
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / speaker.h
bloba076fcfb772defe47f060be3ad48cf004859d26b
1 #ifndef GRUB_SPEAKER_HEADER
2 #define GRUB_SPEAKER_HEADER 1
4 #include <grub/cpu/io.h>
5 #include <grub/i386/pit.h>
7 /* The frequency of the PIT clock. */
8 #define GRUB_SPEAKER_PIT_FREQUENCY 0x1234dd
10 static inline void
11 grub_speaker_beep_off (void)
13 unsigned char status;
15 status = grub_inb (GRUB_PIT_SPEAKER_PORT);
16 grub_outb (status & ~(GRUB_PIT_SPK_TMR2 | GRUB_PIT_SPK_DATA),
17 GRUB_PIT_SPEAKER_PORT);
20 static inline void
21 grub_speaker_beep_on (grub_uint16_t pitch)
23 unsigned char status;
24 unsigned int counter;
26 if (pitch < 20)
27 pitch = 20;
28 else if (pitch > 20000)
29 pitch = 20000;
31 counter = GRUB_SPEAKER_PIT_FREQUENCY / pitch;
33 /* Program timer 2. */
34 grub_outb (GRUB_PIT_CTRL_SELECT_2
35 | GRUB_PIT_CTRL_READLOAD_WORD
36 | GRUB_PIT_CTRL_SQUAREWAVE_GEN
37 | GRUB_PIT_CTRL_COUNT_BINARY, GRUB_PIT_CTRL);
38 grub_outb (counter & 0xff, GRUB_PIT_COUNTER_2); /* LSB */
39 grub_outb ((counter >> 8) & 0xff, GRUB_PIT_COUNTER_2); /* MSB */
41 /* Start speaker. */
42 status = grub_inb (GRUB_PIT_SPEAKER_PORT);
43 grub_outb (status | GRUB_PIT_SPK_TMR2 | GRUB_PIT_SPK_DATA,
44 GRUB_PIT_SPEAKER_PORT);
47 #endif