[platform][pc] add a routine to read the cmos memory
This commit is contained in:
44
platform/pc/cmos.c
Normal file
44
platform/pc/cmos.c
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Travis Geiselbrecht
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <platform/cmos.h>
|
||||||
|
|
||||||
|
#include <lk/trace.h>
|
||||||
|
#include <lk/debug.h>
|
||||||
|
#include <kernel/spinlock.h>
|
||||||
|
#include <platform/pc.h>
|
||||||
|
|
||||||
|
static spin_lock_t lock = SPIN_LOCK_INITIAL_VALUE;
|
||||||
|
|
||||||
|
uint8_t cmos_read(uint8_t reg) {
|
||||||
|
spin_lock_saved_state_t state;
|
||||||
|
spin_lock_irqsave(&lock, state);
|
||||||
|
|
||||||
|
outp(CMOS_CONTROL_REG, reg | 0x80);
|
||||||
|
uint8_t val = inp(CMOS_DATA_REG);
|
||||||
|
|
||||||
|
spin_unlock_irqrestore(&lock, state);
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
30
platform/pc/include/platform/cmos.h
Normal file
30
platform/pc/include/platform/cmos.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Travis Geiselbrecht
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/* cmos map for PC */
|
||||||
|
#define CMOS_REG_FLOPPY (0x10)
|
||||||
|
|
||||||
|
uint8_t cmos_read(uint8_t reg);
|
||||||
@@ -16,6 +16,10 @@
|
|||||||
#define I8042_STATUS_REG 0x64
|
#define I8042_STATUS_REG 0x64
|
||||||
#define I8042_DATA_REG 0x60
|
#define I8042_DATA_REG 0x60
|
||||||
|
|
||||||
|
/* CMOS/RTC registers */
|
||||||
|
#define CMOS_CONTROL_REG 0x70
|
||||||
|
#define CMOS_DATA_REG 0x71
|
||||||
|
|
||||||
/* CGA registers */
|
/* CGA registers */
|
||||||
#define CGA_INDEX_REG 0x3d4
|
#define CGA_INDEX_REG 0x3d4
|
||||||
#define CGA_DATA_REG 0x3d5
|
#define CGA_DATA_REG 0x3d5
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ MODULE_DEPS += dev/net/e1000
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
MODULE_SRCS += \
|
MODULE_SRCS += \
|
||||||
|
$(LOCAL_DIR)/cmos.c \
|
||||||
$(LOCAL_DIR)/console.c \
|
$(LOCAL_DIR)/console.c \
|
||||||
$(LOCAL_DIR)/debug.c \
|
$(LOCAL_DIR)/debug.c \
|
||||||
$(LOCAL_DIR)/ide.c \
|
$(LOCAL_DIR)/ide.c \
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ static void platform_halt_timers(void) {
|
|||||||
|
|
||||||
status_t platform_set_oneshot_timer(platform_timer_callback callback,
|
status_t platform_set_oneshot_timer(platform_timer_callback callback,
|
||||||
void *arg, lk_time_t interval) {
|
void *arg, lk_time_t interval) {
|
||||||
|
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
|
|
||||||
spin_lock_saved_state_t state;
|
spin_lock_saved_state_t state;
|
||||||
|
|||||||
Reference in New Issue
Block a user