mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 12:42:54 +00:00
DM: vrtc code cleanup
- Move the variable local_time from main.c to rtc.c - Change vrtc_init to return int instead of pointer to vrtc. We do track vrtc in struct vmctx. Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
ccc67ceae4
commit
4fcdebc434
@ -577,7 +577,6 @@ main(int argc, char *argv[])
|
||||
{
|
||||
int c, error, gdb_port, err;
|
||||
int max_vcpus, mptgen, memflags;
|
||||
int rtc_localtime;
|
||||
struct vmctx *ctx;
|
||||
size_t memsize;
|
||||
char *optstr;
|
||||
@ -588,7 +587,6 @@ main(int argc, char *argv[])
|
||||
guest_ncpus = 1;
|
||||
memsize = 256 * MB;
|
||||
mptgen = 1;
|
||||
rtc_localtime = 1;
|
||||
memflags = 0;
|
||||
quit_vm_loop = 0;
|
||||
hugetlb = 0;
|
||||
@ -669,7 +667,7 @@ main(int argc, char *argv[])
|
||||
strictio = 1;
|
||||
break;
|
||||
case 'u':
|
||||
rtc_localtime = 0;
|
||||
vrtc_enable_localtime(0);
|
||||
break;
|
||||
case 'U':
|
||||
guest_uuid_str = optarg;
|
||||
@ -785,7 +783,7 @@ main(int argc, char *argv[])
|
||||
ioapic_init(ctx);
|
||||
ioc_init();
|
||||
|
||||
vrtc_init(ctx, rtc_localtime);
|
||||
vrtc_init(ctx);
|
||||
sci_init(ctx);
|
||||
init_bvmcons();
|
||||
monitor_init(ctx);
|
||||
|
@ -144,6 +144,8 @@ static const int month_days[12] = {
|
||||
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
|
||||
};
|
||||
|
||||
static int local_time = 1;
|
||||
|
||||
/*
|
||||
* This inline avoids some unnecessary modulo operations
|
||||
* as compared with the usual macro:
|
||||
@ -1096,8 +1098,14 @@ vrtc_reset(struct vrtc *vrtc)
|
||||
pthread_mutex_unlock(&vrtc->mtx);
|
||||
}
|
||||
|
||||
struct vrtc *
|
||||
vrtc_init(struct vmctx *ctx, int local_time)
|
||||
void
|
||||
vrtc_enable_localtime(int l_time)
|
||||
{
|
||||
local_time = l_time;
|
||||
}
|
||||
|
||||
int
|
||||
vrtc_init(struct vmctx *ctx)
|
||||
{
|
||||
struct vrtc *vrtc;
|
||||
struct rtcdev *rtc;
|
||||
@ -1158,7 +1166,7 @@ vrtc_init(struct vmctx *ctx, int local_time)
|
||||
secs_to_rtc(curtime, vrtc, 0);
|
||||
pthread_mutex_unlock(&vrtc->mtx);
|
||||
|
||||
return vrtc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -36,7 +36,8 @@
|
||||
struct vrtc;
|
||||
struct vmctx;
|
||||
|
||||
struct vrtc *vrtc_init(struct vmctx *ctx, int local_time);
|
||||
int vrtc_init(struct vmctx *ctx);
|
||||
void vrtc_enable_localtime(int l_time);
|
||||
void vrtc_deinit(struct vmctx *ctx);
|
||||
void vrtc_reset(struct vrtc *vrtc);
|
||||
time_t vrtc_get_time(struct vrtc *vrtc);
|
||||
|
@ -34,8 +34,6 @@
|
||||
#include "types.h"
|
||||
#include "vmm.h"
|
||||
|
||||
#include "atkbdc.h"
|
||||
|
||||
/*
|
||||
* API version for out-of-tree consumers for making compile time decisions.
|
||||
*/
|
||||
@ -47,8 +45,6 @@
|
||||
#define ALIGN_UP(x, align) (((x) + ((align)-1)) & ~((align)-1))
|
||||
#define ALIGN_DOWN(x, align) ((x) & ~((align)-1))
|
||||
|
||||
struct iovec;
|
||||
|
||||
struct vmctx {
|
||||
int fd;
|
||||
int vmid;
|
||||
@ -64,8 +60,8 @@ struct vmctx {
|
||||
uuid_t vm_uuid;
|
||||
|
||||
/* fields to track virtual devices */
|
||||
struct atkbdc_base *atkbdc_base;
|
||||
struct vrtc *vrtc;
|
||||
void *atkbdc_base;
|
||||
void *vrtc;
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user