mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:12:43 +00:00 
			
		
		
		
	 fe2bd8e3dd
			
		
	
	
		fe2bd8e3dd
		
	
	
	
	
		
			
			The APICTimer, HPET and RTC (the RTC timer is in the context of the PC RTC here) are timers that exist only in x86 platforms, therefore, we move the handling code and the initialization code to the Arch/x86/Time directory. Other related code patterns in the TimeManagement singleton and in the Random.cpp file are guarded with #ifdef to ensure they are only compiled for x86 builds.
		
			
				
	
	
		
			25 lines
		
	
	
	
		
			601 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
	
		
			601 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <Kernel/Arch/x86/IO.h>
 | |
| #include <Kernel/Arch/x86/Time/PIT.h>
 | |
| #include <Kernel/Arch/x86/common/PCSpeaker.h>
 | |
| 
 | |
| void PCSpeaker::tone_on(int frequency)
 | |
| {
 | |
|     IO::out8(PIT_CTL, TIMER2_SELECT | WRITE_WORD | MODE_SQUARE_WAVE);
 | |
|     u16 timer_reload = BASE_FREQUENCY / frequency;
 | |
| 
 | |
|     IO::out8(TIMER2_CTL, LSB(timer_reload));
 | |
|     IO::out8(TIMER2_CTL, MSB(timer_reload));
 | |
| 
 | |
|     IO::out8(0x61, IO::in8(0x61) | 3);
 | |
| }
 | |
| 
 | |
| void PCSpeaker::tone_off()
 | |
| {
 | |
|     IO::out8(0x61, IO::in8(0x61) & ~3);
 | |
| }
 |