162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 362306a36Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 462306a36Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 762306a36Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 862306a36Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 962306a36Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1062306a36Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1162306a36Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1262306a36Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * Copyright (C) 2019 Intel Corporation 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_ci#ifndef _UAPI_LINUX_UM_TIMETRAVEL_H 1762306a36Sopenharmony_ci#define _UAPI_LINUX_UM_TIMETRAVEL_H 1862306a36Sopenharmony_ci#include <linux/types.h> 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci/** 2162306a36Sopenharmony_ci * struct um_timetravel_msg - UM time travel message 2262306a36Sopenharmony_ci * 2362306a36Sopenharmony_ci * This is the basic message type, going in both directions. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * This is the message passed between the host (user-mode Linux instance) 2662306a36Sopenharmony_ci * and the calendar (the application on the other side of the socket) in 2762306a36Sopenharmony_ci * order to implement common scheduling. 2862306a36Sopenharmony_ci * 2962306a36Sopenharmony_ci * Whenever UML has an event it will request runtime for it from the 3062306a36Sopenharmony_ci * calendar, and then wait for its turn until it can run, etc. Note 3162306a36Sopenharmony_ci * that it will only ever request the single next runtime, i.e. multiple 3262306a36Sopenharmony_ci * REQUEST messages override each other. 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_cistruct um_timetravel_msg { 3562306a36Sopenharmony_ci /** 3662306a36Sopenharmony_ci * @op: operation value from &enum um_timetravel_ops 3762306a36Sopenharmony_ci */ 3862306a36Sopenharmony_ci __u32 op; 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci /** 4162306a36Sopenharmony_ci * @seq: sequence number for the message - shall be reflected in 4262306a36Sopenharmony_ci * the ACK response, and should be checked while processing 4362306a36Sopenharmony_ci * the response to see if it matches 4462306a36Sopenharmony_ci */ 4562306a36Sopenharmony_ci __u32 seq; 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci /** 4862306a36Sopenharmony_ci * @time: time in nanoseconds 4962306a36Sopenharmony_ci */ 5062306a36Sopenharmony_ci __u64 time; 5162306a36Sopenharmony_ci}; 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci/** 5462306a36Sopenharmony_ci * enum um_timetravel_ops - Operation codes 5562306a36Sopenharmony_ci */ 5662306a36Sopenharmony_cienum um_timetravel_ops { 5762306a36Sopenharmony_ci /** 5862306a36Sopenharmony_ci * @UM_TIMETRAVEL_ACK: response (ACK) to any previous message, 5962306a36Sopenharmony_ci * this usually doesn't carry any data in the 'time' field 6062306a36Sopenharmony_ci * unless otherwise specified below 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_ci UM_TIMETRAVEL_ACK = 0, 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci /** 6562306a36Sopenharmony_ci * @UM_TIMETRAVEL_START: initialize the connection, the time 6662306a36Sopenharmony_ci * field contains an (arbitrary) ID to possibly be able 6762306a36Sopenharmony_ci * to distinguish the connections. 6862306a36Sopenharmony_ci */ 6962306a36Sopenharmony_ci UM_TIMETRAVEL_START = 1, 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci /** 7262306a36Sopenharmony_ci * @UM_TIMETRAVEL_REQUEST: request to run at the given time 7362306a36Sopenharmony_ci * (host -> calendar) 7462306a36Sopenharmony_ci */ 7562306a36Sopenharmony_ci UM_TIMETRAVEL_REQUEST = 2, 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci /** 7862306a36Sopenharmony_ci * @UM_TIMETRAVEL_WAIT: Indicate waiting for the previously requested 7962306a36Sopenharmony_ci * runtime, new requests may be made while waiting (e.g. due to 8062306a36Sopenharmony_ci * interrupts); the time field is ignored. The calendar must process 8162306a36Sopenharmony_ci * this message and later send a %UM_TIMETRAVEL_RUN message when 8262306a36Sopenharmony_ci * the host can run again. 8362306a36Sopenharmony_ci * (host -> calendar) 8462306a36Sopenharmony_ci */ 8562306a36Sopenharmony_ci UM_TIMETRAVEL_WAIT = 3, 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci /** 8862306a36Sopenharmony_ci * @UM_TIMETRAVEL_GET: return the current time from the calendar in the 8962306a36Sopenharmony_ci * ACK message, the time in the request message is ignored 9062306a36Sopenharmony_ci * (host -> calendar) 9162306a36Sopenharmony_ci */ 9262306a36Sopenharmony_ci UM_TIMETRAVEL_GET = 4, 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci /** 9562306a36Sopenharmony_ci * @UM_TIMETRAVEL_UPDATE: time update to the calendar, must be sent e.g. 9662306a36Sopenharmony_ci * before kicking an interrupt to another calendar 9762306a36Sopenharmony_ci * (host -> calendar) 9862306a36Sopenharmony_ci */ 9962306a36Sopenharmony_ci UM_TIMETRAVEL_UPDATE = 5, 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci /** 10262306a36Sopenharmony_ci * @UM_TIMETRAVEL_RUN: run time request granted, current time is in 10362306a36Sopenharmony_ci * the time field 10462306a36Sopenharmony_ci * (calendar -> host) 10562306a36Sopenharmony_ci */ 10662306a36Sopenharmony_ci UM_TIMETRAVEL_RUN = 6, 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci /** 10962306a36Sopenharmony_ci * @UM_TIMETRAVEL_FREE_UNTIL: Enable free-running until the given time, 11062306a36Sopenharmony_ci * this is a message from the calendar telling the host that it can 11162306a36Sopenharmony_ci * freely do its own scheduling for anything before the indicated 11262306a36Sopenharmony_ci * time. 11362306a36Sopenharmony_ci * Note that if a calendar sends this message once, the host may 11462306a36Sopenharmony_ci * assume that it will also do so in the future, if it implements 11562306a36Sopenharmony_ci * wraparound semantics for the time field. 11662306a36Sopenharmony_ci * (calendar -> host) 11762306a36Sopenharmony_ci */ 11862306a36Sopenharmony_ci UM_TIMETRAVEL_FREE_UNTIL = 7, 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci /** 12162306a36Sopenharmony_ci * @UM_TIMETRAVEL_GET_TOD: Return time of day, typically used once at 12262306a36Sopenharmony_ci * boot by the virtual machines to get a synchronized time from 12362306a36Sopenharmony_ci * the simulation. 12462306a36Sopenharmony_ci */ 12562306a36Sopenharmony_ci UM_TIMETRAVEL_GET_TOD = 8, 12662306a36Sopenharmony_ci}; 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci#endif /* _UAPI_LINUX_UM_TIMETRAVEL_H */ 129