@@ -20,24 +20,24 @@ struct logmsg {
20
20
21
21
static struct logmsg logmsg ;
22
22
23
- static inline void alloc_earlylog_sbuf (uint32_t cpu_id )
23
+ static inline void alloc_earlylog_sbuf (uint16_t pcpu_id )
24
24
{
25
25
uint32_t ele_size = LOG_ENTRY_SIZE ;
26
26
uint32_t ele_num = ((HVLOG_BUF_SIZE >> 1 ) / phys_cpu_num
27
27
- SBUF_HEAD_SIZE ) / ele_size ;
28
28
29
- per_cpu (earlylog_sbuf , cpu_id ) = sbuf_allocate (ele_num , ele_size );
30
- if (per_cpu (earlylog_sbuf , cpu_id ) == NULL )
31
- printf ("failed to allcate sbuf for hvlog - %d \n" , cpu_id );
29
+ per_cpu (earlylog_sbuf , pcpu_id ) = sbuf_allocate (ele_num , ele_size );
30
+ if (per_cpu (earlylog_sbuf , pcpu_id ) == NULL )
31
+ printf ("failed to allcate sbuf for hvlog - %hu \n" , pcpu_id );
32
32
}
33
33
34
- static inline void free_earlylog_sbuf (uint32_t cpu_id )
34
+ static inline void free_earlylog_sbuf (uint16_t pcpu_id )
35
35
{
36
- if (per_cpu (earlylog_sbuf , cpu_id ) == NULL )
36
+ if (per_cpu (earlylog_sbuf , pcpu_id ) == NULL )
37
37
return ;
38
38
39
- free (per_cpu (earlylog_sbuf , cpu_id ));
40
- per_cpu (earlylog_sbuf , cpu_id ) = NULL ;
39
+ free (per_cpu (earlylog_sbuf , pcpu_id ));
40
+ per_cpu (earlylog_sbuf , pcpu_id ) = NULL ;
41
41
}
42
42
43
43
static int do_copy_earlylog (struct shared_buf * dst_sbuf ,
@@ -69,21 +69,21 @@ static int do_copy_earlylog(struct shared_buf *dst_sbuf,
69
69
70
70
void init_logmsg (__unused uint32_t mem_size , uint32_t flags )
71
71
{
72
- int32_t idx ;
72
+ int16_t pcpu_id ;
73
73
74
74
logmsg .flags = flags ;
75
75
logmsg .seq = 0 ;
76
76
77
77
/* allocate sbuf for log before sos booting */
78
- for (idx = 0 ; idx < phys_cpu_num ; idx ++ )
79
- alloc_earlylog_sbuf (idx );
78
+ for (pcpu_id = 0U ; pcpu_id < phys_cpu_num ; pcpu_id ++ )
79
+ alloc_earlylog_sbuf (pcpu_id );
80
80
}
81
81
82
82
void do_logmsg (uint32_t severity , const char * fmt , ...)
83
83
{
84
84
va_list args ;
85
85
uint64_t timestamp ;
86
- uint32_t cpu_id ;
86
+ uint16_t pcpu_id ;
87
87
bool do_console_log ;
88
88
bool do_mem_log ;
89
89
char * buffer ;
@@ -104,14 +104,14 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
104
104
timestamp = ticks_to_us (timestamp );
105
105
106
106
/* Get CPU ID */
107
- cpu_id = get_cpu_id ();
108
- buffer = per_cpu (logbuf , cpu_id );
107
+ pcpu_id = get_cpu_id ();
108
+ buffer = per_cpu (logbuf , pcpu_id );
109
109
110
110
memset (buffer , 0 , LOG_MESSAGE_MAX_SIZE );
111
111
/* Put time-stamp, CPU ID and severity into buffer */
112
112
snprintf (buffer , LOG_MESSAGE_MAX_SIZE ,
113
- "[%lluus][cpu=%u ][sev=%u][seq=%u]:" ,
114
- timestamp , cpu_id , severity ,
113
+ "[%lluus][cpu=%hu ][sev=%u][seq=%u]:" ,
114
+ timestamp , pcpu_id , severity ,
115
115
atomic_inc_return (& logmsg .seq ));
116
116
117
117
/* Put message into remaining portion of local buffer */
@@ -135,14 +135,14 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
135
135
if (do_mem_log ) {
136
136
int i , msg_len ;
137
137
struct shared_buf * sbuf = (struct shared_buf * )
138
- per_cpu (sbuf , cpu_id )[ACRN_HVLOG ];
139
- struct shared_buf * early_sbuf = per_cpu (earlylog_sbuf , cpu_id );
138
+ per_cpu (sbuf , pcpu_id )[ACRN_HVLOG ];
139
+ struct shared_buf * early_sbuf = per_cpu (earlylog_sbuf , pcpu_id );
140
140
141
141
if (early_sbuf != NULL ) {
142
142
if (sbuf != NULL ) {
143
143
/* switch to sbuf from sos */
144
144
do_copy_earlylog (sbuf , early_sbuf );
145
- free_earlylog_sbuf (cpu_id );
145
+ free_earlylog_sbuf (pcpu_id );
146
146
} else
147
147
/* use earlylog sbuf if no sbuf from sos */
148
148
sbuf = early_sbuf ;
@@ -160,28 +160,28 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
160
160
}
161
161
}
162
162
163
- void print_logmsg_buffer (uint32_t cpu_id )
163
+ void print_logmsg_buffer (uint16_t pcpu_id )
164
164
{
165
165
spinlock_rflags ;
166
166
char buffer [LOG_ENTRY_SIZE + 1 ];
167
167
int read_cnt ;
168
168
struct shared_buf * * sbuf ;
169
169
int is_earlylog = 0 ;
170
170
171
- if (cpu_id >= ( uint32_t ) phys_cpu_num )
171
+ if (pcpu_id >= phys_cpu_num )
172
172
return ;
173
173
174
- if (per_cpu (earlylog_sbuf , cpu_id ) != NULL ) {
175
- sbuf = & per_cpu (earlylog_sbuf , cpu_id );
174
+ if (per_cpu (earlylog_sbuf , pcpu_id ) != NULL ) {
175
+ sbuf = & per_cpu (earlylog_sbuf , pcpu_id );
176
176
is_earlylog = 1 ;
177
177
} else
178
178
sbuf = (struct shared_buf * * )
179
- & per_cpu (sbuf , cpu_id )[ACRN_HVLOG ];
179
+ & per_cpu (sbuf , pcpu_id )[ACRN_HVLOG ];
180
180
181
181
spinlock_irqsave_obtain (& (logmsg .lock ));
182
182
if ((* sbuf ) != NULL )
183
- printf ("CPU%d : head: 0x%x, tail: 0x%x %s\n\r" ,
184
- cpu_id , (* sbuf )-> head , (* sbuf )-> tail ,
183
+ printf ("CPU%hu : head: 0x%x, tail: 0x%x %s\n\r" ,
184
+ pcpu_id , (* sbuf )-> head , (* sbuf )-> tail ,
185
185
(is_earlylog != 0 ) ? "[earlylog]" : "" );
186
186
spinlock_irqrestore_release (& (logmsg .lock ));
187
187
0 commit comments