1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4 */
5
6 #ifndef __PPC_32_H__
7 #define __PPC_32_H__
8
9 #include <pthread.h>
10
11 #include "utils.h"
12 #include "rbtree.h"
13
14 /* CPU identifiers */
15 #define PPC32_PVR_405 0x40110000
16
17 /* Number of GPR (general purpose registers) */
18 #define PPC32_GPR_NR 32
19
20 /* Number of registers in FPU */
21 #define PPC32_FPU_REG_NR 32
22
23 /* Minimum page size: 4 Kb */
24 #define PPC32_MIN_PAGE_SHIFT 12
25 #define PPC32_MIN_PAGE_SIZE (1 << PPC32_MIN_PAGE_SHIFT)
26 #define PPC32_MIN_PAGE_IMASK (PPC32_MIN_PAGE_SIZE - 1)
27 #define PPC32_MIN_PAGE_MASK 0xFFFFF000
28
29 /* Number of instructions per page */
30 #define PPC32_INSN_PER_PAGE (PPC32_MIN_PAGE_SIZE/sizeof(ppc_insn_t))
31
32 /* Starting point for ROM */
33 #define PPC32_ROM_START 0xfff00100
34 #define PPC32_ROM_SP 0x00006000
35
36 /* Special Purpose Registers (SPR) */
37 #define PPC32_SPR_XER 1
38 #define PPC32_SPR_LR 8 /* Link Register */
39 #define PPC32_SPR_CTR 9 /* Count Register */
40 #define PPC32_SPR_DSISR 18
41 #define PPC32_SPR_DAR 19
42 #define PPC32_SPR_DEC 22 /* Decrementer */
43 #define PPC32_SPR_SDR1 25 /* Page Table Address */
44 #define PPC32_SPR_SRR0 26
45 #define PPC32_SPR_SRR1 27
46 #define PPC32_SPR_TBL_READ 268 /* Time Base Low (read) */
47 #define PPC32_SPR_TBU_READ 269 /* Time Base Up (read) */
48 #define PPC32_SPR_SPRG0 272
49 #define PPC32_SPR_SPRG1 273
50 #define PPC32_SPR_SPRG2 274
51 #define PPC32_SPR_SPRG3 275
52 #define PPC32_SPR_TBL_WRITE 284 /* Time Base Low (write) */
53 #define PPC32_SPR_TBU_WRITE 285 /* Time Base Up (write) */
54 #define PPC32_SPR_PVR 287 /* Processor Version Register */
55 #define PPC32_SPR_HID0 1008
56 #define PPC32_SPR_HID1 1009
57
58 #define PPC405_SPR_PID 945 /* Process Identifier */
59
60 /* Exception vectors */
61 #define PPC32_EXC_SYS_RST 0x00000100 /* System Reset */
62 #define PPC32_EXC_MC_CHK 0x00000200 /* Machine Check */
63 #define PPC32_EXC_DSI 0x00000300 /* Data memory access failure */
64 #define PPC32_EXC_ISI 0x00000400 /* Instruction fetch failure */
65 #define PPC32_EXC_EXT 0x00000500 /* External Interrupt */
66 #define PPC32_EXC_ALIGN 0x00000600 /* Alignment */
67 #define PPC32_EXC_PROG 0x00000700 /* FPU, Illegal instruction, ... */
68 #define PPC32_EXC_NO_FPU 0x00000800 /* FPU unavailable */
69 #define PPC32_EXC_DEC 0x00000900 /* Decrementer */
70 #define PPC32_EXC_SYSCALL 0x00000C00 /* System Call */
71 #define PPC32_EXC_TRACE 0x00000D00 /* Trace */
72 #define PPC32_EXC_FPU_HLP 0x00000E00 /* Floating-Point Assist */
73
74 /* Condition Register (CR) is accessed through 8 fields of 4 bits */
75 #define ppc32_get_cr_field(n) ((n) >> 2)
76 #define ppc32_get_cr_bit(n) (~(n) & 0x03)
77
78 /* Positions of LT, GT, EQ and SO bits in CR fields */
79 #define PPC32_CR_LT_BIT 3
80 #define PPC32_CR_GT_BIT 2
81 #define PPC32_CR_EQ_BIT 1
82 #define PPC32_CR_SO_BIT 0
83
84 /* CR0 (Condition Register Field 0) bits */
85 #define PPC32_CR0_LT_BIT 31
86 #define PPC32_CR0_LT (1 << PPC32_CR0_LT_BIT) /* Negative */
87 #define PPC32_CR0_GT_BIT 30
88 #define PPC32_CR0_GT (1 << PPC32_CR0_GT_BIT) /* Positive */
89 #define PPC32_CR0_EQ_BIT 29
90 #define PPC32_CR0_EQ (1 << PPC32_CR0_EQ_BIT) /* Zero */
91 #define PPC32_CR0_SO_BIT 28
92 #define PPC32_CR0_SO (1 << PPC32_CR0_SO_BIT) /* Summary overflow */
93
94 /* XER register */
95 #define PPC32_XER_SO_BIT 31
96 #define PPC32_XER_SO (1 << PPC32_XER_SO_BIT) /* Summary Overflow */
97 #define PPC32_XER_OV 0x40000000 /* Overflow */
98 #define PPC32_XER_CA_BIT 29
99 #define PPC32_XER_CA (1 << PPC32_XER_CA_BIT) /* Carry */
100 #define PPC32_XER_BC_MASK 0x0000007F /* Byte cnt (lswx/stswx) */
101
102 /* MSR (Machine State Register) */
103 #define PPC32_MSR_POW_MASK 0x00060000 /* Power Management */
104 #define PPC32_MSR_ILE 0x00010000 /* Exception Little-Endian Mode */
105 #define PPC32_MSR_EE 0x00008000 /* External Interrupt Enable */
106 #define PPC32_MSR_PR 0x00004000 /* Privilege Level (0=supervisor) */
107 #define PPC32_MSR_PR_SHIFT 14
108 #define PPC32_MSR_FP 0x00002000 /* Floating-Point Available */
109 #define PPC32_MSR_ME 0x00001000 /* Machine Check Enable */
110 #define PPC32_MSR_FE0 0x00000800 /* Floating-Point Exception Mode 0 */
111 #define PPC32_MSR_SE 0x00000400 /* Single-step trace enable */
112 #define PPC32_MSR_BE 0x00000200 /* Branch Trace Enable */
113 #define PPC32_MSR_FE1 0x00000100 /* Floating-Point Exception Mode 1 */
114 #define PPC32_MSR_IP 0x00000040 /* Exception Prefix */
115 #define PPC32_MSR_IR 0x00000020 /* Instruction address translation */
116 #define PPC32_MSR_DR 0x00000010 /* Data address translation */
117 #define PPC32_MSR_RI 0x00000002 /* Recoverable Exception */
118 #define PPC32_MSR_LE 0x00000001 /* Little-Endian mode enable */
119
120 #define PPC32_RFI_MSR_MASK 0x87c0ff73
121 #define PPC32_EXC_SRR1_MASK 0x0000ff73
122 #define PPC32_EXC_MSR_MASK 0x0006ef32
123
124 /* Number of BAT registers (8 for PowerPC 7448) */
125 #define PPC32_BAT_NR 8
126
127 /* Number of segment registers */
128 #define PPC32_SR_NR 16
129
130 /* Upper BAT register */
131 #define PPC32_UBAT_BEPI_MASK 0xFFFE0000 /* Block Effective Page Index */
132 #define PPC32_UBAT_BEPI_SHIFT 17
133 #define PPC32_UBAT_BL_MASK 0x00001FFC /* Block Length */
134 #define PPC32_UBAT_BL_SHIFT 2
135 #define PPC32_UBAT_XBL_MASK 0x0001FFFC /* Block Length */
136 #define PPC32_UBAT_XBL_SHIFT 2
137 #define PPC32_UBAT_VS 0x00000002 /* Supervisor mode valid bit */
138 #define PPC32_UBAT_VP 0x00000001 /* User mode valid bit */
139 #define PPC32_UBAT_PROT_MASK (PPC32_UBAT_VS|PPC32_UBAT_VP)
140
141 /* Lower BAT register */
142 #define PPC32_LBAT_BRPN_MASK 0xFFFE0000 /* Physical address */
143 #define PPC32_LBAT_BRPN_SHIFT 17
144 #define PPC32_LBAT_WIMG_MASK 0x00000078 /* Memory/cache access mode bits */
145 #define PPC32_LBAT_PP_MASK 0x00000003 /* Protection bits */
146
147 #define PPC32_BAT_ADDR_SHIFT 17
148
149 /* Segment Descriptor */
150 #define PPC32_SD_T 0x80000000
151 #define PPC32_SD_KS 0x40000000 /* Supervisor-state protection key */
152 #define PPC32_SD_KP 0x20000000 /* User-state protection key */
153 #define PPC32_SD_N 0x10000000 /* No-execute protection bit */
154 #define PPC32_SD_VSID_MASK 0x00FFFFFF /* Virtual Segment ID */
155
156 /* SDR1 Register */
157 #define PPC32_SDR1_HTABORG_MASK 0xFFFF0000 /* Physical base address */
158 #define PPC32_SDR1_HTABEXT_MASK 0x0000E000 /* Extended base address */
159 #define PPC32_SDR1_HTABMASK 0x000001FF /* Mask for page table address */
160 #define PPC32_SDR1_HTMEXT_MASK 0x00001FFF /* Extended mask */
161
162 /* Page Table Entry (PTE) size: 64-bits */
163 #define PPC32_PTE_SIZE 8
164
165 /* PTE entry (Up and Lo) */
166 #define PPC32_PTEU_V 0x80000000 /* Valid entry */
167 #define PPC32_PTEU_VSID_MASK 0x7FFFFF80 /* Virtual Segment ID */
168 #define PPC32_PTEU_VSID_SHIFT 7
169 #define PPC32_PTEU_H 0x00000040 /* Hash function */
170 #define PPC32_PTEU_API_MASK 0x0000003F /* Abbreviated Page index */
171 #define PPC32_PTEL_RPN_MASK 0xFFFFF000 /* Physical Page Number */
172 #define PPC32_PTEL_XPN_MASK 0x00000C00 /* Extended Page Number (0-2) */
173 #define PPC32_PTEL_XPN_SHIFT 9
174 #define PPC32_PTEL_R 0x00000100 /* Referenced bit */
175 #define PPC32_PTEL_C 0x00000080 /* Changed bit */
176 #define PPC32_PTEL_WIMG_MASK 0x00000078 /* Mem/cache access mode bits */
177 #define PPC32_PTEL_WIMG_SHIFT 3
178 #define PPC32_PTEL_X_MASK 0x00000004 /* Extended Page Number (3) */
179 #define PPC32_PTEL_X_SHIFT 2
180 #define PPC32_PTEL_PP_MASK 0x00000003 /* Page Protection bits */
181
182 /* DSISR register */
183 #define PPC32_DSISR_NOTRANS 0x40000000 /* No valid translation */
184 #define PPC32_DSISR_STORE 0x02000000 /* Store operation */
185
186 /* PowerPC 405 TLB definitions */
187 #define PPC405_TLBHI_EPN_MASK 0xFFFFFC00 /* Effective Page Number */
188 #define PPC405_TLBHI_SIZE_MASK 0x00000380 /* Page Size */
189 #define PPC405_TLBHI_SIZE_SHIFT 7
190 #define PPC405_TLBHI_V 0x00000040 /* Valid TLB entry */
191 #define PPC405_TLBHI_E 0x00000020 /* Endianness */
192 #define PPC405_TLBHI_U0 0x00000010 /* User-Defined Attribute */
193
194 #define PPC405_TLBLO_RPN_MASK 0xFFFFFC00 /* Real Page Number */
195 #define PPC405_TLBLO_EX 0x00000200 /* Execute Enable */
196 #define PPC405_TLBLO_WR 0x00000100 /* Write Enable */
197 #define PPC405_TLBLO_ZSEL_MASK 0x000000F0 /* Zone Select */
198 #define PPC405_TLBLO_ZSEL_SHIFT 4
199 #define PPC405_TLBLO_W 0x00000008 /* Write-Through */
200 #define PPC405_TLBLO_I 0x00000004 /* Caching Inhibited */
201 #define PPC405_TLBLO_M 0x00000002 /* Memory Coherent */
202 #define PPC405_TLBLO_G 0x00000001 /* Guarded */
203
204 /* Number of TLB entries for PPC405 */
205 #define PPC405_TLB_ENTRIES 64
206
207 struct ppc405_tlb_entry {
208 m_uint32_t tlb_hi,tlb_lo,tid;
209 };
210
211 /* Memory operations */
212 enum {
213 PPC_MEMOP_LOOKUP = 0,
214 PPC_MEMOP_IFETCH,
215
216 /* Load operations */
217 PPC_MEMOP_LBZ,
218 PPC_MEMOP_LHZ,
219 PPC_MEMOP_LWZ,
220
221 /* Load operation with sign-extend */
222 PPC_MEMOP_LHA,
223
224 /* Store operations */
225 PPC_MEMOP_STB,
226 PPC_MEMOP_STH,
227 PPC_MEMOP_STW,
228
229 /* Byte-Reversed operations */
230 PPC_MEMOP_LWBR,
231 PPC_MEMOP_STWBR,
232
233 /* String operations */
234 PPC_MEMOP_LSW,
235 PPC_MEMOP_STSW,
236
237 /* FPU operations */
238 PPC_MEMOP_LFD,
239 PPC_MEMOP_STFD,
240
241 /* ICBI - Instruction Cache Block Invalidate */
242 PPC_MEMOP_ICBI,
243
244 PPC_MEMOP_MAX,
245 };
246
247 /* PowerPC CPU type */
248 typedef struct cpu_ppc cpu_ppc_t;
249
250 /* Memory operation function prototype */
251 typedef fastcall void (*ppc_memop_fn)(cpu_ppc_t *cpu,m_uint32_t vaddr,
252 u_int reg);
253
254 /* BAT type indexes */
255 enum {
256 PPC32_IBAT_IDX = 0,
257 PPC32_DBAT_IDX,
258 };
259
260 /* BAT register */
261 struct ppc32_bat_reg {
262 m_uint32_t reg[2];
263 };
264
265 /* BAT register programming */
266 struct ppc32_bat_prog {
267 int type,index;
268 m_uint32_t hi,lo;
269 };
270
271 /* MTS Instruction Cache and Data Cache */
272 #define PPC32_MTS_ICACHE PPC32_IBAT_IDX
273 #define PPC32_MTS_DCACHE PPC32_DBAT_IDX
274
275 /* FPU Coprocessor definition */
276 typedef struct {
277 m_uint64_t reg[PPC32_FPU_REG_NR];
278 }ppc_fpu_t;
279
280 /* Maximum number of breakpoints */
281 #define PPC32_MAX_BREAKPOINTS 8
282
283 /* PowerPC CPU definition */
284 struct cpu_ppc {
285 /* Execution state */
286 m_uint32_t exec_state;
287
288 /* Instruction address */
289 m_uint32_t ia;
290
291 /* General Purpose registers */
292 m_uint32_t gpr[PPC32_GPR_NR];
293
294 /* Pending IRQ */
295 volatile m_uint32_t irq_pending,irq_check;
296
297 /* XER, Condition Register, Link Register, Count Register */
298 m_uint32_t xer,lr,ctr,reserve;
299 m_uint32_t xer_ca;
300
301 /* Condition Register (CR) fields */
302 u_int cr_fields[8];
303
304 /* MTS caches (Instruction+Data) */
305 mts32_entry_t *mts_cache[2];
306
307 /* Code page translation cache and physical page mapping */
308 ppc32_jit_tcb_t **tcb_virt_hash,**tcb_phys_hash;
309
310 /* Virtual address to physical page translation */
311 fastcall int (*translate)(cpu_ppc_t *cpu,m_uint32_t vaddr,u_int cid,
312 m_uint32_t *phys_page);
313
314 /* Memory access functions */
315 ppc_memop_fn mem_op_fn[PPC_MEMOP_MAX];
316
317 /* Memory lookup function (to load ELF image,...) and Instruction fetch */
318 void *(*mem_op_lookup)(cpu_ppc_t *cpu,m_uint32_t vaddr,u_int cid);
319 void *(*mem_op_ifetch)(cpu_ppc_t *cpu,m_uint32_t vaddr);
320
321 /* MTS slow lookup function */
322 mts32_entry_t *(*mts_slow_lookup)(cpu_ppc_t *cpu,m_uint32_t vaddr,
323 u_int cid,u_int op_code,u_int op_size,
324 u_int op_type,m_uint64_t *data,
325 mts32_entry_t *alt_entry);
326
327 /* IRQ counters */
328 m_uint64_t irq_count,timer_irq_count,irq_fp_count;
329 pthread_mutex_t irq_lock;
330
331 /* Current and free lists of translated code blocks */
332 ppc32_jit_tcb_t *tcb_list,*tcb_last,*tcb_free_list;
333
334 /* Executable page area */
335 void *exec_page_area;
336 size_t exec_page_area_size;
337 size_t exec_page_count,exec_page_alloc;
338 insn_exec_page_t *exec_page_free_list;
339 insn_exec_page_t *exec_page_array;
340
341 /* Idle PC value */
342 volatile m_uint32_t idle_pc;
343
344 /* Timer IRQs */
345 volatile u_int timer_irq_pending,timer_irq_armed;
346 u_int timer_irq_freq;
347 u_int timer_irq_check_itv;
348 u_int timer_drift;
349
350 /* IRQ disable flag */
351 volatile u_int irq_disable;
352
353 /* IBAT (Instruction) and DBAT (Data) registers */
354 struct ppc32_bat_reg bat[2][PPC32_BAT_NR];
355
356 /* Segment registers */
357 m_uint32_t sr[PPC32_SR_NR];
358
359 /* Page Table Address */
360 m_uint32_t sdr1;
361 void *sdr1_hptr;
362
363 /* MSR (Machine state register) */
364 m_uint32_t msr;
365
366 /* Interrupt Registers (SRR0/SRR1) */
367 m_uint32_t srr0,srr1,dsisr,dar;
368
369 /* SPRG registers */
370 m_uint32_t sprg[4];
371
372 /* PVR (Processor Version Register) */
373 m_uint32_t pvr;
374
375 /* Time-Base register */
376 m_uint64_t tb;
377
378 /* Decrementer */
379 m_uint32_t dec;
380
381 /* Hardware Implementation Dependent Registers */
382 m_uint32_t hid0,hid1;
383
384 /* String instruction position (lswi/stswi) */
385 u_int sw_pos;
386
387 /* PowerPC 405 TLB */
388 struct ppc405_tlb_entry ppc405_tlb[PPC405_TLB_ENTRIES];
389 m_uint32_t ppc405_pid;
390
391 /* MPC860 IMMR register */
392 m_uint32_t mpc860_immr;
393
394 /* FPU */
395 ppc_fpu_t fpu;
396
397 /* Generic CPU instance pointer */
398 cpu_gen_t *gen;
399
400 /* VM instance */
401 vm_instance_t *vm;
402
403 /* MTS cache statistics */
404 m_uint64_t mts_misses,mts_lookups;
405
406 /* JIT flush method */
407 u_int jit_flush_method;
408
409 /* Number of compiled pages */
410 u_int compiled_pages;
411
412 /* Fast memory operations use */
413 u_int fast_memop;
414
415 /* Direct block jump */
416 u_int exec_blk_direct_jump;
417
418 /* Current exec page (non-JIT) info */
419 m_uint64_t njm_exec_page;
420 mips_insn_t *njm_exec_ptr;
421
422 /* Performance counter (non-JIT) */
423 m_uint32_t perf_counter;
424
425 /* non-JIT mode instruction counter */
426 m_uint64_t insn_exec_count;
427
428 /* Breakpoints */
429 m_uint32_t breakpoints[PPC32_MAX_BREAKPOINTS];
430 u_int breakpoints_enabled;
431
432 /* JIT host register allocation */
433 char *jit_hreg_seq_name;
434 int ppc_reg_map[PPC32_GPR_NR];
435 struct hreg_map *hreg_map_list,*hreg_lru;
436 struct hreg_map hreg_map[JIT_HOST_NREG];
437 };
438
439 #define PPC32_CR_FIELD_OFFSET(f) \
440 (OFFSET(cpu_ppc_t,cr_fields)+((f) * sizeof(u_int)))
441
442 /* Get the full CR register */
ppc32_get_cr(cpu_ppc_t * cpu)443 static forced_inline m_uint32_t ppc32_get_cr(cpu_ppc_t *cpu)
444 {
445 m_uint32_t cr = 0;
446 int i;
447
448 for(i=0;i<8;i++)
449 cr |= cpu->cr_fields[i] << (28 - (i << 2));
450
451 return(cr);
452 }
453
454 /* Set the CR fields given a CR value */
ppc32_set_cr(cpu_ppc_t * cpu,m_uint32_t cr)455 static forced_inline void ppc32_set_cr(cpu_ppc_t *cpu,m_uint32_t cr)
456 {
457 int i;
458
459 for(i=0;i<8;i++)
460 cpu->cr_fields[i] = (cr >> (28 - (i << 2))) & 0x0F;
461 }
462
463 /* Get a CR bit */
ppc32_read_cr_bit(cpu_ppc_t * cpu,u_int bit)464 static forced_inline m_uint32_t ppc32_read_cr_bit(cpu_ppc_t *cpu,u_int bit)
465 {
466 m_uint32_t res;
467
468 res = cpu->cr_fields[ppc32_get_cr_field(bit)] >> ppc32_get_cr_bit(bit);
469 return(res & 0x01);
470 }
471
472 /* Set a CR bit */
ppc32_set_cr_bit(cpu_ppc_t * cpu,u_int bit)473 static forced_inline void ppc32_set_cr_bit(cpu_ppc_t *cpu,u_int bit)
474 {
475 cpu->cr_fields[ppc32_get_cr_field(bit)] |= 1 << ppc32_get_cr_bit(bit);
476 }
477
478 /* Clear a CR bit */
ppc32_clear_cr_bit(cpu_ppc_t * cpu,u_int bit)479 static forced_inline void ppc32_clear_cr_bit(cpu_ppc_t *cpu,u_int bit)
480 {
481 cpu->cr_fields[ppc32_get_cr_field(bit)] &= ~(1 << ppc32_get_cr_bit(bit));
482 }
483
484 /* Reset a PowerPC CPU */
485 int ppc32_reset(cpu_ppc_t *cpu);
486
487 /* Initialize a PowerPC processor */
488 int ppc32_init(cpu_ppc_t *cpu);
489
490 /* Delete a PowerPC processor */
491 void ppc32_delete(cpu_ppc_t *cpu);
492
493 /* Set the processor version register (PVR) */
494 void ppc32_set_pvr(cpu_ppc_t *cpu,m_uint32_t pvr);
495
496 /* Set idle PC value */
497 void ppc32_set_idle_pc(cpu_gen_t *cpu,m_uint64_t addr);
498
499 /* Timer IRQ */
500 void *ppc32_timer_irq_run(cpu_ppc_t *cpu);
501
502 /* Determine an "idling" PC */
503 int ppc32_get_idling_pc(cpu_gen_t *cpu);
504
505 /* Generate an exception */
506 void ppc32_trigger_exception(cpu_ppc_t *cpu,u_int exc_vector);
507
508 /* Trigger the decrementer exception */
509 void ppc32_trigger_timer_irq(cpu_ppc_t *cpu);
510
511 /* Trigger IRQs */
512 fastcall void ppc32_trigger_irq(cpu_ppc_t *cpu);
513
514 /* Virtual breakpoint */
515 fastcall void ppc32_run_breakpoint(cpu_ppc_t *cpu);
516
517 /* Add a virtual breakpoint */
518 int ppc32_add_breakpoint(cpu_gen_t *cpu,m_uint64_t ia);
519
520 /* Remove a virtual breakpoint */
521 void ppc32_remove_breakpoint(cpu_gen_t *cpu,m_uint64_t ia);
522
523 /* Set a register */
524 void ppc32_reg_set(cpu_gen_t *cpu,u_int reg,m_uint64_t val);
525
526 /* Dump registers of a PowerPC processor */
527 void ppc32_dump_regs(cpu_gen_t *cpu);
528
529 /* Dump MMU registers */
530 void ppc32_dump_mmu(cpu_gen_t *cpu);
531
532 /* Load a raw image into the simulated memory */
533 int ppc32_load_raw_image(cpu_ppc_t *cpu,char *filename,m_uint32_t vaddr);
534
535 /* Load an ELF image into the simulated memory */
536 int ppc32_load_elf_image(cpu_ppc_t *cpu,char *filename,int skip_load,
537 m_uint32_t *entry_point);
538
539 /* Run PowerPC code in step-by-step mode */
540 void *ppc32_exec_run_cpu(cpu_gen_t *gen);
541
542 #endif
543