Skip to content

Commit 0018da4

Browse files
donshengacrnsi
authored andcommitted
HV: add missing @pre for some functions
Add @pre for some functions, and fix outdated @pre statements Tracked-On: #3056 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent b957802 commit 0018da4

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed

hypervisor/dm/vpci/vdev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#include <vm.h>
3131
#include "vpci_priv.h"
3232

33+
/**
34+
* @pre vdev != NULL
35+
*/
3336
uint32_t pci_vdev_read_cfg(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes)
3437
{
3538
uint32_t val;
@@ -49,6 +52,9 @@ uint32_t pci_vdev_read_cfg(const struct pci_vdev *vdev, uint32_t offset, uint32_
4952
return val;
5053
}
5154

55+
/**
56+
* @pre vdev != NULL
57+
*/
5258
void pci_vdev_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val)
5359
{
5460
switch (bytes) {

hypervisor/dm/vpci/vmsi.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ static inline bool msicap_access(const struct pci_vdev *vdev, uint32_t offset)
5757
return ret;
5858
}
5959

60+
/**
61+
* @pre vdev != NULL
62+
* @pre vdev->vpci != NULL
63+
* @pre vdev->vpci->vm != NULL
64+
* @pre vdev->pdev != NULL
65+
*/
6066
static int32_t vmsi_remap(const struct pci_vdev *vdev, bool enable)
6167
{
6268
struct ptirq_msi_info info;
@@ -172,6 +178,11 @@ int32_t vmsi_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, u
172178
return ret;
173179
}
174180

181+
/**
182+
* @pre vdev != NULL
183+
* @pre vdev->vpci != NULL
184+
* @pre vdev->vpci->vm != NULL
185+
*/
175186
void deinit_vmsi(const struct pci_vdev *vdev)
176187
{
177188
if (has_msi_cap(vdev)) {
@@ -194,6 +205,10 @@ static void buf_write32(uint8_t buf[], uint32_t val)
194205
buf[3] = (uint8_t)((val >> 24U) & 0xFFU);
195206
}
196207

208+
/**
209+
* @pre vdev != NULL
210+
* @pre vdev->pdev != NULL
211+
*/
197212
void init_vmsi(struct pci_vdev *vdev)
198213
{
199214
struct pci_pdev *pdev = vdev->pdev;

hypervisor/dm/vpci/vmsix.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,20 @@ static inline bool msixcap_access(const struct pci_vdev *vdev, uint32_t offset)
5353
return ret;
5454
}
5555

56+
/**
57+
* @pre vdev != NULL
58+
*/
5659
static inline bool msixtable_access(const struct pci_vdev *vdev, uint32_t offset)
5760
{
5861
return in_range(offset, vdev->msix.table_offset, vdev->msix.table_count * MSIX_TABLE_ENTRY_SIZE);
5962
}
6063

64+
/**
65+
* @pre vdev != NULL
66+
* @pre vdev->vpci != NULL
67+
* @pre vdev->vpci->vm != NULL
68+
* @pre vdev->pdev != NULL
69+
*/
6170
static int32_t vmsix_remap_entry(const struct pci_vdev *vdev, uint32_t index, bool enable)
6271
{
6372
struct msix_table_entry *pentry;
@@ -92,6 +101,10 @@ static int32_t vmsix_remap_entry(const struct pci_vdev *vdev, uint32_t index, bo
92101
return ret;
93102
}
94103

104+
/**
105+
* @pre vdev != NULL
106+
* @pre vdev->pdev != NULL
107+
*/
95108
static inline void enable_disable_msix(const struct pci_vdev *vdev, bool enable)
96109
{
97110
uint32_t msgctrl;
@@ -105,7 +118,11 @@ static inline void enable_disable_msix(const struct pci_vdev *vdev, bool enable)
105118
pci_pdev_write_cfg(vdev->pdev->bdf, vdev->msix.capoff + PCIR_MSIX_CTRL, 2U, msgctrl);
106119
}
107120

108-
/* Do MSI-X remap for all MSI-X table entries in the target device */
121+
/**
122+
* Do MSI-X remap for all MSI-X table entries in the target device
123+
* @pre vdev != NULL
124+
* @pre vdev->pdev != NULL
125+
*/
109126
static int32_t vmsix_remap(const struct pci_vdev *vdev, bool enable)
110127
{
111128
uint32_t index;
@@ -132,7 +149,11 @@ static int32_t vmsix_remap(const struct pci_vdev *vdev, bool enable)
132149
return ret;
133150
}
134151

135-
/* Do MSI-X remap for one MSI-X table entry only */
152+
/**
153+
* Do MSI-X remap for one MSI-X table entry only
154+
* @pre vdev != NULL
155+
* @pre vdev->pdev != NULL
156+
*/
136157
static int32_t vmsix_remap_one_entry(const struct pci_vdev *vdev, uint32_t index, bool enable)
137158
{
138159
uint32_t msgctrl;
@@ -336,6 +357,7 @@ int32_t vmsix_table_mmio_access_handler(struct io_request *io_req, void *handler
336357

337358
/**
338359
* @pre vdev != NULL
360+
* @pre vdev->pdev != NULL
339361
*/
340362
void init_vmsix(struct pci_vdev *vdev)
341363
{

hypervisor/dm/vpci/vpci.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ static void pci_cfg_clear_cache(struct pci_addr_info *pi)
5151
}
5252

5353
/**
54-
* @pre vm != NULL && vcpu != NULL
54+
* @pre vm != NULL
55+
* @pre vcpu != NULL
5556
*/
5657
static bool pci_cfgaddr_io_read(struct acrn_vm *vm, struct acrn_vcpu *vcpu, uint16_t addr, size_t bytes)
5758
{
@@ -147,7 +148,7 @@ static bool pci_cfgdata_io_read(struct acrn_vm *vm, struct acrn_vcpu *vcpu, uint
147148
/**
148149
* @pre vm != NULL
149150
* @pre vm->vm_id < CONFIG_MAX_VM_NUM
150-
* @pre (get_vm_config(vm->vm_id)->type == PRE_LAUNCHED_VM) || (get_vm_config(vm->vm_id)->type == SOS_VM)
151+
* @pre (get_vm_config(vm->vm_id)->load_order == PRE_LAUNCHED_VM) || (get_vm_config(vm->vm_id)->load_order == SOS_VM)
151152
*/
152153
static bool pci_cfgdata_io_write(struct acrn_vm *vm, uint16_t addr, size_t bytes, uint32_t val)
153154
{

hypervisor/dm/vpci/vpci_priv.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,49 @@ static inline bool in_range(uint32_t value, uint32_t lower, uint32_t len)
3737
return ((value >= lower) && (value < (lower + len)));
3838
}
3939

40+
/**
41+
* @pre vdev != NULL
42+
*/
4043
static inline uint8_t pci_vdev_read_cfg_u8(const struct pci_vdev *vdev, uint32_t offset)
4144
{
4245
return vdev->cfgdata.data_8[offset];
4346
}
4447

48+
/**
49+
* @pre vdev != NULL
50+
*/
4551
static inline uint16_t pci_vdev_read_cfg_u16(const struct pci_vdev *vdev, uint32_t offset)
4652
{
4753
return vdev->cfgdata.data_16[offset >> 1U];
4854
}
4955

56+
/**
57+
* @pre vdev != NULL
58+
*/
5059
static inline uint32_t pci_vdev_read_cfg_u32(const struct pci_vdev *vdev, uint32_t offset)
5160
{
5261
return vdev->cfgdata.data_32[offset >> 2U];
5362
}
5463

64+
/**
65+
* @pre vdev != NULL
66+
*/
5567
static inline void pci_vdev_write_cfg_u8(struct pci_vdev *vdev, uint32_t offset, uint8_t val)
5668
{
5769
vdev->cfgdata.data_8[offset] = val;
5870
}
5971

72+
/**
73+
* @pre vdev != NULL
74+
*/
6075
static inline void pci_vdev_write_cfg_u16(struct pci_vdev *vdev, uint32_t offset, uint16_t val)
6176
{
6277
vdev->cfgdata.data_16[offset >> 1U] = val;
6378
}
6479

80+
/**
81+
* @pre vdev != NULL
82+
*/
6583
static inline void pci_vdev_write_cfg_u32(struct pci_vdev *vdev, uint32_t offset, uint32_t val)
6684
{
6785
vdev->cfgdata.data_32[offset >> 2U] = val;

0 commit comments

Comments
 (0)