text
stringlengths
1
1.05M
_ln: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp if(argc != 3){ 7: 83 39 03 cmpl $0x3,(%ecx) { a: ff 71 fc pushl -0x4(%ecx) d: 55 push %ebp e: 89 e5 mov %esp,%ebp 10: 53 push %ebx 11: 51 push %ecx 12: 8b 59 04 mov 0x4(%ecx),%ebx if(argc != 3){ 15: 74 1a je 31 <main+0x31> printf(2, "Usage: ln old new\n"); 17: 52 push %edx 18: 52 push %edx 19: 68 88 07 00 00 push $0x788 1e: 6a 02 push $0x2 20: e8 0b 04 00 00 call 430 <printf> exit(0); 25: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2c: e8 91 02 00 00 call 2c2 <exit> } if(link(argv[1], argv[2]) < 0) 31: 50 push %eax 32: 50 push %eax 33: ff 73 08 pushl 0x8(%ebx) 36: ff 73 04 pushl 0x4(%ebx) 39: e8 e4 02 00 00 call 322 <link> 3e: 83 c4 10 add $0x10,%esp 41: 85 c0 test %eax,%eax 43: 78 0a js 4f <main+0x4f> printf(2, "link %s %s: failed\n", argv[1], argv[2]); exit(0); 45: 83 ec 0c sub $0xc,%esp 48: 6a 00 push $0x0 4a: e8 73 02 00 00 call 2c2 <exit> printf(2, "link %s %s: failed\n", argv[1], argv[2]); 4f: ff 73 08 pushl 0x8(%ebx) 52: ff 73 04 pushl 0x4(%ebx) 55: 68 9b 07 00 00 push $0x79b 5a: 6a 02 push $0x2 5c: e8 cf 03 00 00 call 430 <printf> 61: 83 c4 10 add $0x10,%esp 64: eb df jmp 45 <main+0x45> 66: 66 90 xchg %ax,%ax 68: 66 90 xchg %ax,%ax 6a: 66 90 xchg %ax,%ax 6c: 66 90 xchg %ax,%ax 6e: 66 90 xchg %ax,%ax 00000070 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 70: 55 push %ebp 71: 89 e5 mov %esp,%ebp 73: 53 push %ebx 74: 8b 45 08 mov 0x8(%ebp),%eax 77: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 7a: 89 c2 mov %eax,%edx 7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80: 83 c1 01 add $0x1,%ecx 83: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 87: 83 c2 01 add $0x1,%edx 8a: 84 db test %bl,%bl 8c: 88 5a ff mov %bl,-0x1(%edx) 8f: 75 ef jne 80 <strcpy+0x10> ; return os; } 91: 5b pop %ebx 92: 5d pop %ebp 93: c3 ret 94: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 9a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000000a0 <strcmp>: int strcmp(const char *p, const char *q) { a0: 55 push %ebp a1: 89 e5 mov %esp,%ebp a3: 53 push %ebx a4: 8b 55 08 mov 0x8(%ebp),%edx a7: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) aa: 0f b6 02 movzbl (%edx),%eax ad: 0f b6 19 movzbl (%ecx),%ebx b0: 84 c0 test %al,%al b2: 75 1c jne d0 <strcmp+0x30> b4: eb 2a jmp e0 <strcmp+0x40> b6: 8d 76 00 lea 0x0(%esi),%esi b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; c0: 83 c2 01 add $0x1,%edx while(*p && *p == *q) c3: 0f b6 02 movzbl (%edx),%eax p++, q++; c6: 83 c1 01 add $0x1,%ecx c9: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) cc: 84 c0 test %al,%al ce: 74 10 je e0 <strcmp+0x40> d0: 38 d8 cmp %bl,%al d2: 74 ec je c0 <strcmp+0x20> return (uchar)*p - (uchar)*q; d4: 29 d8 sub %ebx,%eax } d6: 5b pop %ebx d7: 5d pop %ebp d8: c3 ret d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi e0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; e2: 29 d8 sub %ebx,%eax } e4: 5b pop %ebx e5: 5d pop %ebp e6: c3 ret e7: 89 f6 mov %esi,%esi e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000000f0 <strlen>: uint strlen(const char *s) { f0: 55 push %ebp f1: 89 e5 mov %esp,%ebp f3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) f6: 80 39 00 cmpb $0x0,(%ecx) f9: 74 15 je 110 <strlen+0x20> fb: 31 d2 xor %edx,%edx fd: 8d 76 00 lea 0x0(%esi),%esi 100: 83 c2 01 add $0x1,%edx 103: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 107: 89 d0 mov %edx,%eax 109: 75 f5 jne 100 <strlen+0x10> ; return n; } 10b: 5d pop %ebp 10c: c3 ret 10d: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 110: 31 c0 xor %eax,%eax } 112: 5d pop %ebp 113: c3 ret 114: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 11a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000120 <memset>: void* memset(void *dst, int c, uint n) { 120: 55 push %ebp 121: 89 e5 mov %esp,%ebp 123: 57 push %edi 124: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 127: 8b 4d 10 mov 0x10(%ebp),%ecx 12a: 8b 45 0c mov 0xc(%ebp),%eax 12d: 89 d7 mov %edx,%edi 12f: fc cld 130: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 132: 89 d0 mov %edx,%eax 134: 5f pop %edi 135: 5d pop %ebp 136: c3 ret 137: 89 f6 mov %esi,%esi 139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000140 <strchr>: char* strchr(const char *s, char c) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 53 push %ebx 144: 8b 45 08 mov 0x8(%ebp),%eax 147: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 14a: 0f b6 10 movzbl (%eax),%edx 14d: 84 d2 test %dl,%dl 14f: 74 1d je 16e <strchr+0x2e> if(*s == c) 151: 38 d3 cmp %dl,%bl 153: 89 d9 mov %ebx,%ecx 155: 75 0d jne 164 <strchr+0x24> 157: eb 17 jmp 170 <strchr+0x30> 159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 160: 38 ca cmp %cl,%dl 162: 74 0c je 170 <strchr+0x30> for(; *s; s++) 164: 83 c0 01 add $0x1,%eax 167: 0f b6 10 movzbl (%eax),%edx 16a: 84 d2 test %dl,%dl 16c: 75 f2 jne 160 <strchr+0x20> return (char*)s; return 0; 16e: 31 c0 xor %eax,%eax } 170: 5b pop %ebx 171: 5d pop %ebp 172: c3 ret 173: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 179: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000180 <gets>: char* gets(char *buf, int max) { 180: 55 push %ebp 181: 89 e5 mov %esp,%ebp 183: 57 push %edi 184: 56 push %esi 185: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 186: 31 f6 xor %esi,%esi 188: 89 f3 mov %esi,%ebx { 18a: 83 ec 1c sub $0x1c,%esp 18d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 190: eb 2f jmp 1c1 <gets+0x41> 192: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 198: 8d 45 e7 lea -0x19(%ebp),%eax 19b: 83 ec 04 sub $0x4,%esp 19e: 6a 01 push $0x1 1a0: 50 push %eax 1a1: 6a 00 push $0x0 1a3: e8 32 01 00 00 call 2da <read> if(cc < 1) 1a8: 83 c4 10 add $0x10,%esp 1ab: 85 c0 test %eax,%eax 1ad: 7e 1c jle 1cb <gets+0x4b> break; buf[i++] = c; 1af: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 1b3: 83 c7 01 add $0x1,%edi 1b6: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 1b9: 3c 0a cmp $0xa,%al 1bb: 74 23 je 1e0 <gets+0x60> 1bd: 3c 0d cmp $0xd,%al 1bf: 74 1f je 1e0 <gets+0x60> for(i=0; i+1 < max; ){ 1c1: 83 c3 01 add $0x1,%ebx 1c4: 3b 5d 0c cmp 0xc(%ebp),%ebx 1c7: 89 fe mov %edi,%esi 1c9: 7c cd jl 198 <gets+0x18> 1cb: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 1cd: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 1d0: c6 03 00 movb $0x0,(%ebx) } 1d3: 8d 65 f4 lea -0xc(%ebp),%esp 1d6: 5b pop %ebx 1d7: 5e pop %esi 1d8: 5f pop %edi 1d9: 5d pop %ebp 1da: c3 ret 1db: 90 nop 1dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1e0: 8b 75 08 mov 0x8(%ebp),%esi 1e3: 8b 45 08 mov 0x8(%ebp),%eax 1e6: 01 de add %ebx,%esi 1e8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1ea: c6 03 00 movb $0x0,(%ebx) } 1ed: 8d 65 f4 lea -0xc(%ebp),%esp 1f0: 5b pop %ebx 1f1: 5e pop %esi 1f2: 5f pop %edi 1f3: 5d pop %ebp 1f4: c3 ret 1f5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000200 <stat>: int stat(const char *n, struct stat *st) { 200: 55 push %ebp 201: 89 e5 mov %esp,%ebp 203: 56 push %esi 204: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 205: 83 ec 08 sub $0x8,%esp 208: 6a 00 push $0x0 20a: ff 75 08 pushl 0x8(%ebp) 20d: e8 f0 00 00 00 call 302 <open> if(fd < 0) 212: 83 c4 10 add $0x10,%esp 215: 85 c0 test %eax,%eax 217: 78 27 js 240 <stat+0x40> return -1; r = fstat(fd, st); 219: 83 ec 08 sub $0x8,%esp 21c: ff 75 0c pushl 0xc(%ebp) 21f: 89 c3 mov %eax,%ebx 221: 50 push %eax 222: e8 f3 00 00 00 call 31a <fstat> close(fd); 227: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 22a: 89 c6 mov %eax,%esi close(fd); 22c: e8 b9 00 00 00 call 2ea <close> return r; 231: 83 c4 10 add $0x10,%esp } 234: 8d 65 f8 lea -0x8(%ebp),%esp 237: 89 f0 mov %esi,%eax 239: 5b pop %ebx 23a: 5e pop %esi 23b: 5d pop %ebp 23c: c3 ret 23d: 8d 76 00 lea 0x0(%esi),%esi return -1; 240: be ff ff ff ff mov $0xffffffff,%esi 245: eb ed jmp 234 <stat+0x34> 247: 89 f6 mov %esi,%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000250 <atoi>: int atoi(const char *s) { 250: 55 push %ebp 251: 89 e5 mov %esp,%ebp 253: 53 push %ebx 254: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 257: 0f be 11 movsbl (%ecx),%edx 25a: 8d 42 d0 lea -0x30(%edx),%eax 25d: 3c 09 cmp $0x9,%al n = 0; 25f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 264: 77 1f ja 285 <atoi+0x35> 266: 8d 76 00 lea 0x0(%esi),%esi 269: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 270: 8d 04 80 lea (%eax,%eax,4),%eax 273: 83 c1 01 add $0x1,%ecx 276: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 27a: 0f be 11 movsbl (%ecx),%edx 27d: 8d 5a d0 lea -0x30(%edx),%ebx 280: 80 fb 09 cmp $0x9,%bl 283: 76 eb jbe 270 <atoi+0x20> return n; } 285: 5b pop %ebx 286: 5d pop %ebp 287: c3 ret 288: 90 nop 289: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000290 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 290: 55 push %ebp 291: 89 e5 mov %esp,%ebp 293: 56 push %esi 294: 53 push %ebx 295: 8b 5d 10 mov 0x10(%ebp),%ebx 298: 8b 45 08 mov 0x8(%ebp),%eax 29b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 29e: 85 db test %ebx,%ebx 2a0: 7e 14 jle 2b6 <memmove+0x26> 2a2: 31 d2 xor %edx,%edx 2a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 2a8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 2ac: 88 0c 10 mov %cl,(%eax,%edx,1) 2af: 83 c2 01 add $0x1,%edx while(n-- > 0) 2b2: 39 d3 cmp %edx,%ebx 2b4: 75 f2 jne 2a8 <memmove+0x18> return vdst; } 2b6: 5b pop %ebx 2b7: 5e pop %esi 2b8: 5d pop %ebp 2b9: c3 ret 000002ba <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2ba: b8 01 00 00 00 mov $0x1,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <exit>: SYSCALL(exit) 2c2: b8 02 00 00 00 mov $0x2,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <wait>: SYSCALL(wait) 2ca: b8 03 00 00 00 mov $0x3,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <pipe>: SYSCALL(pipe) 2d2: b8 04 00 00 00 mov $0x4,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <read>: SYSCALL(read) 2da: b8 05 00 00 00 mov $0x5,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <write>: SYSCALL(write) 2e2: b8 10 00 00 00 mov $0x10,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <close>: SYSCALL(close) 2ea: b8 15 00 00 00 mov $0x15,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <kill>: SYSCALL(kill) 2f2: b8 06 00 00 00 mov $0x6,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <exec>: SYSCALL(exec) 2fa: b8 07 00 00 00 mov $0x7,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <open>: SYSCALL(open) 302: b8 0f 00 00 00 mov $0xf,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <mknod>: SYSCALL(mknod) 30a: b8 11 00 00 00 mov $0x11,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <unlink>: SYSCALL(unlink) 312: b8 12 00 00 00 mov $0x12,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <fstat>: SYSCALL(fstat) 31a: b8 08 00 00 00 mov $0x8,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <link>: SYSCALL(link) 322: b8 13 00 00 00 mov $0x13,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <mkdir>: SYSCALL(mkdir) 32a: b8 14 00 00 00 mov $0x14,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <chdir>: SYSCALL(chdir) 332: b8 09 00 00 00 mov $0x9,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <dup>: SYSCALL(dup) 33a: b8 0a 00 00 00 mov $0xa,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <getpid>: SYSCALL(getpid) 342: b8 0b 00 00 00 mov $0xb,%eax 347: cd 40 int $0x40 349: c3 ret 0000034a <sbrk>: SYSCALL(sbrk) 34a: b8 0c 00 00 00 mov $0xc,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <sleep>: SYSCALL(sleep) 352: b8 0d 00 00 00 mov $0xd,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <uptime>: SYSCALL(uptime) 35a: b8 0e 00 00 00 mov $0xe,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <memsize>: SYSCALL(memsize) 362: b8 16 00 00 00 mov $0x16,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <set_ps_priority>: SYSCALL(set_ps_priority) 36a: b8 17 00 00 00 mov $0x17,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <set_cfs_priority>: SYSCALL(set_cfs_priority) 372: b8 18 00 00 00 mov $0x18,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <policy>: SYSCALL(policy) 37a: b8 19 00 00 00 mov $0x19,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <proc_info>: 382: b8 1a 00 00 00 mov $0x1a,%eax 387: cd 40 int $0x40 389: c3 ret 38a: 66 90 xchg %ax,%ax 38c: 66 90 xchg %ax,%ax 38e: 66 90 xchg %ax,%ax 00000390 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 390: 55 push %ebp 391: 89 e5 mov %esp,%ebp 393: 57 push %edi 394: 56 push %esi 395: 53 push %ebx 396: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 399: 85 d2 test %edx,%edx { 39b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 39e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 3a0: 79 76 jns 418 <printint+0x88> 3a2: f6 45 08 01 testb $0x1,0x8(%ebp) 3a6: 74 70 je 418 <printint+0x88> x = -xx; 3a8: f7 d8 neg %eax neg = 1; 3aa: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 3b1: 31 f6 xor %esi,%esi 3b3: 8d 5d d7 lea -0x29(%ebp),%ebx 3b6: eb 0a jmp 3c2 <printint+0x32> 3b8: 90 nop 3b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 3c0: 89 fe mov %edi,%esi 3c2: 31 d2 xor %edx,%edx 3c4: 8d 7e 01 lea 0x1(%esi),%edi 3c7: f7 f1 div %ecx 3c9: 0f b6 92 b8 07 00 00 movzbl 0x7b8(%edx),%edx }while((x /= base) != 0); 3d0: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 3d2: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 3d5: 75 e9 jne 3c0 <printint+0x30> if(neg) 3d7: 8b 45 c4 mov -0x3c(%ebp),%eax 3da: 85 c0 test %eax,%eax 3dc: 74 08 je 3e6 <printint+0x56> buf[i++] = '-'; 3de: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 3e3: 8d 7e 02 lea 0x2(%esi),%edi 3e6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 3ea: 8b 7d c0 mov -0x40(%ebp),%edi 3ed: 8d 76 00 lea 0x0(%esi),%esi 3f0: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 3f3: 83 ec 04 sub $0x4,%esp 3f6: 83 ee 01 sub $0x1,%esi 3f9: 6a 01 push $0x1 3fb: 53 push %ebx 3fc: 57 push %edi 3fd: 88 45 d7 mov %al,-0x29(%ebp) 400: e8 dd fe ff ff call 2e2 <write> while(--i >= 0) 405: 83 c4 10 add $0x10,%esp 408: 39 de cmp %ebx,%esi 40a: 75 e4 jne 3f0 <printint+0x60> putc(fd, buf[i]); } 40c: 8d 65 f4 lea -0xc(%ebp),%esp 40f: 5b pop %ebx 410: 5e pop %esi 411: 5f pop %edi 412: 5d pop %ebp 413: c3 ret 414: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 418: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 41f: eb 90 jmp 3b1 <printint+0x21> 421: eb 0d jmp 430 <printf> 423: 90 nop 424: 90 nop 425: 90 nop 426: 90 nop 427: 90 nop 428: 90 nop 429: 90 nop 42a: 90 nop 42b: 90 nop 42c: 90 nop 42d: 90 nop 42e: 90 nop 42f: 90 nop 00000430 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 430: 55 push %ebp 431: 89 e5 mov %esp,%ebp 433: 57 push %edi 434: 56 push %esi 435: 53 push %ebx 436: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 439: 8b 75 0c mov 0xc(%ebp),%esi 43c: 0f b6 1e movzbl (%esi),%ebx 43f: 84 db test %bl,%bl 441: 0f 84 b3 00 00 00 je 4fa <printf+0xca> ap = (uint*)(void*)&fmt + 1; 447: 8d 45 10 lea 0x10(%ebp),%eax 44a: 83 c6 01 add $0x1,%esi state = 0; 44d: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 44f: 89 45 d4 mov %eax,-0x2c(%ebp) 452: eb 2f jmp 483 <printf+0x53> 454: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 458: 83 f8 25 cmp $0x25,%eax 45b: 0f 84 a7 00 00 00 je 508 <printf+0xd8> write(fd, &c, 1); 461: 8d 45 e2 lea -0x1e(%ebp),%eax 464: 83 ec 04 sub $0x4,%esp 467: 88 5d e2 mov %bl,-0x1e(%ebp) 46a: 6a 01 push $0x1 46c: 50 push %eax 46d: ff 75 08 pushl 0x8(%ebp) 470: e8 6d fe ff ff call 2e2 <write> 475: 83 c4 10 add $0x10,%esp 478: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 47b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 47f: 84 db test %bl,%bl 481: 74 77 je 4fa <printf+0xca> if(state == 0){ 483: 85 ff test %edi,%edi c = fmt[i] & 0xff; 485: 0f be cb movsbl %bl,%ecx 488: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 48b: 74 cb je 458 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 48d: 83 ff 25 cmp $0x25,%edi 490: 75 e6 jne 478 <printf+0x48> if(c == 'd'){ 492: 83 f8 64 cmp $0x64,%eax 495: 0f 84 05 01 00 00 je 5a0 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 49b: 81 e1 f7 00 00 00 and $0xf7,%ecx 4a1: 83 f9 70 cmp $0x70,%ecx 4a4: 74 72 je 518 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 4a6: 83 f8 73 cmp $0x73,%eax 4a9: 0f 84 99 00 00 00 je 548 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 4af: 83 f8 63 cmp $0x63,%eax 4b2: 0f 84 08 01 00 00 je 5c0 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 4b8: 83 f8 25 cmp $0x25,%eax 4bb: 0f 84 ef 00 00 00 je 5b0 <printf+0x180> write(fd, &c, 1); 4c1: 8d 45 e7 lea -0x19(%ebp),%eax 4c4: 83 ec 04 sub $0x4,%esp 4c7: c6 45 e7 25 movb $0x25,-0x19(%ebp) 4cb: 6a 01 push $0x1 4cd: 50 push %eax 4ce: ff 75 08 pushl 0x8(%ebp) 4d1: e8 0c fe ff ff call 2e2 <write> 4d6: 83 c4 0c add $0xc,%esp 4d9: 8d 45 e6 lea -0x1a(%ebp),%eax 4dc: 88 5d e6 mov %bl,-0x1a(%ebp) 4df: 6a 01 push $0x1 4e1: 50 push %eax 4e2: ff 75 08 pushl 0x8(%ebp) 4e5: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4e8: 31 ff xor %edi,%edi write(fd, &c, 1); 4ea: e8 f3 fd ff ff call 2e2 <write> for(i = 0; fmt[i]; i++){ 4ef: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 4f3: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 4f6: 84 db test %bl,%bl 4f8: 75 89 jne 483 <printf+0x53> } } } 4fa: 8d 65 f4 lea -0xc(%ebp),%esp 4fd: 5b pop %ebx 4fe: 5e pop %esi 4ff: 5f pop %edi 500: 5d pop %ebp 501: c3 ret 502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 508: bf 25 00 00 00 mov $0x25,%edi 50d: e9 66 ff ff ff jmp 478 <printf+0x48> 512: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 518: 83 ec 0c sub $0xc,%esp 51b: b9 10 00 00 00 mov $0x10,%ecx 520: 6a 00 push $0x0 522: 8b 7d d4 mov -0x2c(%ebp),%edi 525: 8b 45 08 mov 0x8(%ebp),%eax 528: 8b 17 mov (%edi),%edx 52a: e8 61 fe ff ff call 390 <printint> ap++; 52f: 89 f8 mov %edi,%eax 531: 83 c4 10 add $0x10,%esp state = 0; 534: 31 ff xor %edi,%edi ap++; 536: 83 c0 04 add $0x4,%eax 539: 89 45 d4 mov %eax,-0x2c(%ebp) 53c: e9 37 ff ff ff jmp 478 <printf+0x48> 541: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 548: 8b 45 d4 mov -0x2c(%ebp),%eax 54b: 8b 08 mov (%eax),%ecx ap++; 54d: 83 c0 04 add $0x4,%eax 550: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 553: 85 c9 test %ecx,%ecx 555: 0f 84 8e 00 00 00 je 5e9 <printf+0x1b9> while(*s != 0){ 55b: 0f b6 01 movzbl (%ecx),%eax state = 0; 55e: 31 ff xor %edi,%edi s = (char*)*ap; 560: 89 cb mov %ecx,%ebx while(*s != 0){ 562: 84 c0 test %al,%al 564: 0f 84 0e ff ff ff je 478 <printf+0x48> 56a: 89 75 d0 mov %esi,-0x30(%ebp) 56d: 89 de mov %ebx,%esi 56f: 8b 5d 08 mov 0x8(%ebp),%ebx 572: 8d 7d e3 lea -0x1d(%ebp),%edi 575: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 578: 83 ec 04 sub $0x4,%esp s++; 57b: 83 c6 01 add $0x1,%esi 57e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 581: 6a 01 push $0x1 583: 57 push %edi 584: 53 push %ebx 585: e8 58 fd ff ff call 2e2 <write> while(*s != 0){ 58a: 0f b6 06 movzbl (%esi),%eax 58d: 83 c4 10 add $0x10,%esp 590: 84 c0 test %al,%al 592: 75 e4 jne 578 <printf+0x148> 594: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 597: 31 ff xor %edi,%edi 599: e9 da fe ff ff jmp 478 <printf+0x48> 59e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 5a0: 83 ec 0c sub $0xc,%esp 5a3: b9 0a 00 00 00 mov $0xa,%ecx 5a8: 6a 01 push $0x1 5aa: e9 73 ff ff ff jmp 522 <printf+0xf2> 5af: 90 nop write(fd, &c, 1); 5b0: 83 ec 04 sub $0x4,%esp 5b3: 88 5d e5 mov %bl,-0x1b(%ebp) 5b6: 8d 45 e5 lea -0x1b(%ebp),%eax 5b9: 6a 01 push $0x1 5bb: e9 21 ff ff ff jmp 4e1 <printf+0xb1> putc(fd, *ap); 5c0: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 5c3: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 5c6: 8b 07 mov (%edi),%eax write(fd, &c, 1); 5c8: 6a 01 push $0x1 ap++; 5ca: 83 c7 04 add $0x4,%edi putc(fd, *ap); 5cd: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 5d0: 8d 45 e4 lea -0x1c(%ebp),%eax 5d3: 50 push %eax 5d4: ff 75 08 pushl 0x8(%ebp) 5d7: e8 06 fd ff ff call 2e2 <write> ap++; 5dc: 89 7d d4 mov %edi,-0x2c(%ebp) 5df: 83 c4 10 add $0x10,%esp state = 0; 5e2: 31 ff xor %edi,%edi 5e4: e9 8f fe ff ff jmp 478 <printf+0x48> s = "(null)"; 5e9: bb af 07 00 00 mov $0x7af,%ebx while(*s != 0){ 5ee: b8 28 00 00 00 mov $0x28,%eax 5f3: e9 72 ff ff ff jmp 56a <printf+0x13a> 5f8: 66 90 xchg %ax,%ax 5fa: 66 90 xchg %ax,%ax 5fc: 66 90 xchg %ax,%ax 5fe: 66 90 xchg %ax,%ax 00000600 <free>: static Header base; static Header *freep; void free(void *ap) { 600: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 601: a1 60 0a 00 00 mov 0xa60,%eax { 606: 89 e5 mov %esp,%ebp 608: 57 push %edi 609: 56 push %esi 60a: 53 push %ebx 60b: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 60e: 8d 4b f8 lea -0x8(%ebx),%ecx 611: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 618: 39 c8 cmp %ecx,%eax 61a: 8b 10 mov (%eax),%edx 61c: 73 32 jae 650 <free+0x50> 61e: 39 d1 cmp %edx,%ecx 620: 72 04 jb 626 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 622: 39 d0 cmp %edx,%eax 624: 72 32 jb 658 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 626: 8b 73 fc mov -0x4(%ebx),%esi 629: 8d 3c f1 lea (%ecx,%esi,8),%edi 62c: 39 fa cmp %edi,%edx 62e: 74 30 je 660 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 630: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 633: 8b 50 04 mov 0x4(%eax),%edx 636: 8d 34 d0 lea (%eax,%edx,8),%esi 639: 39 f1 cmp %esi,%ecx 63b: 74 3a je 677 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 63d: 89 08 mov %ecx,(%eax) freep = p; 63f: a3 60 0a 00 00 mov %eax,0xa60 } 644: 5b pop %ebx 645: 5e pop %esi 646: 5f pop %edi 647: 5d pop %ebp 648: c3 ret 649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 650: 39 d0 cmp %edx,%eax 652: 72 04 jb 658 <free+0x58> 654: 39 d1 cmp %edx,%ecx 656: 72 ce jb 626 <free+0x26> { 658: 89 d0 mov %edx,%eax 65a: eb bc jmp 618 <free+0x18> 65c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 660: 03 72 04 add 0x4(%edx),%esi 663: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 666: 8b 10 mov (%eax),%edx 668: 8b 12 mov (%edx),%edx 66a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 66d: 8b 50 04 mov 0x4(%eax),%edx 670: 8d 34 d0 lea (%eax,%edx,8),%esi 673: 39 f1 cmp %esi,%ecx 675: 75 c6 jne 63d <free+0x3d> p->s.size += bp->s.size; 677: 03 53 fc add -0x4(%ebx),%edx freep = p; 67a: a3 60 0a 00 00 mov %eax,0xa60 p->s.size += bp->s.size; 67f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 682: 8b 53 f8 mov -0x8(%ebx),%edx 685: 89 10 mov %edx,(%eax) } 687: 5b pop %ebx 688: 5e pop %esi 689: 5f pop %edi 68a: 5d pop %ebp 68b: c3 ret 68c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000690 <malloc>: return freep; } void* malloc(uint nbytes) { 690: 55 push %ebp 691: 89 e5 mov %esp,%ebp 693: 57 push %edi 694: 56 push %esi 695: 53 push %ebx 696: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 699: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 69c: 8b 15 60 0a 00 00 mov 0xa60,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6a2: 8d 78 07 lea 0x7(%eax),%edi 6a5: c1 ef 03 shr $0x3,%edi 6a8: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 6ab: 85 d2 test %edx,%edx 6ad: 0f 84 9d 00 00 00 je 750 <malloc+0xc0> 6b3: 8b 02 mov (%edx),%eax 6b5: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 6b8: 39 cf cmp %ecx,%edi 6ba: 76 6c jbe 728 <malloc+0x98> 6bc: 81 ff 00 10 00 00 cmp $0x1000,%edi 6c2: bb 00 10 00 00 mov $0x1000,%ebx 6c7: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 6ca: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 6d1: eb 0e jmp 6e1 <malloc+0x51> 6d3: 90 nop 6d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6d8: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 6da: 8b 48 04 mov 0x4(%eax),%ecx 6dd: 39 f9 cmp %edi,%ecx 6df: 73 47 jae 728 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 6e1: 39 05 60 0a 00 00 cmp %eax,0xa60 6e7: 89 c2 mov %eax,%edx 6e9: 75 ed jne 6d8 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 6eb: 83 ec 0c sub $0xc,%esp 6ee: 56 push %esi 6ef: e8 56 fc ff ff call 34a <sbrk> if(p == (char*)-1) 6f4: 83 c4 10 add $0x10,%esp 6f7: 83 f8 ff cmp $0xffffffff,%eax 6fa: 74 1c je 718 <malloc+0x88> hp->s.size = nu; 6fc: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 6ff: 83 ec 0c sub $0xc,%esp 702: 83 c0 08 add $0x8,%eax 705: 50 push %eax 706: e8 f5 fe ff ff call 600 <free> return freep; 70b: 8b 15 60 0a 00 00 mov 0xa60,%edx if((p = morecore(nunits)) == 0) 711: 83 c4 10 add $0x10,%esp 714: 85 d2 test %edx,%edx 716: 75 c0 jne 6d8 <malloc+0x48> return 0; } } 718: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 71b: 31 c0 xor %eax,%eax } 71d: 5b pop %ebx 71e: 5e pop %esi 71f: 5f pop %edi 720: 5d pop %ebp 721: c3 ret 722: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 728: 39 cf cmp %ecx,%edi 72a: 74 54 je 780 <malloc+0xf0> p->s.size -= nunits; 72c: 29 f9 sub %edi,%ecx 72e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 731: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 734: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 737: 89 15 60 0a 00 00 mov %edx,0xa60 } 73d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 740: 83 c0 08 add $0x8,%eax } 743: 5b pop %ebx 744: 5e pop %esi 745: 5f pop %edi 746: 5d pop %ebp 747: c3 ret 748: 90 nop 749: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 750: c7 05 60 0a 00 00 64 movl $0xa64,0xa60 757: 0a 00 00 75a: c7 05 64 0a 00 00 64 movl $0xa64,0xa64 761: 0a 00 00 base.s.size = 0; 764: b8 64 0a 00 00 mov $0xa64,%eax 769: c7 05 68 0a 00 00 00 movl $0x0,0xa68 770: 00 00 00 773: e9 44 ff ff ff jmp 6bc <malloc+0x2c> 778: 90 nop 779: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 780: 8b 08 mov (%eax),%ecx 782: 89 0a mov %ecx,(%edx) 784: eb b1 jmp 737 <malloc+0xa7>
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r15 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0xfb9b, %rsi lea addresses_normal_ht+0x13c9b, %rdi nop sub $39663, %rbp mov $11, %rcx rep movsl add $27050, %rsi lea addresses_UC_ht+0x629b, %rsi lea addresses_normal_ht+0xb98b, %rdi nop dec %rbx mov $31, %rcx rep movsw nop nop nop nop nop and %rbp, %rbp lea addresses_UC_ht+0xe293, %r12 nop nop nop nop nop add $13719, %r15 mov $0x6162636465666768, %rdi movq %rdi, (%r12) nop nop nop xor %rbp, %rbp pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r15 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %rax push %rcx push %rdi // Faulty Load lea addresses_D+0x539b, %rcx nop nop nop xor $13166, %rdi movups (%rcx), %xmm3 vpextrq $0, %xmm3, %rax lea oracles, %r14 and $0xff, %rax shlq $12, %rax mov (%r14,%rax,1), %rax pop %rdi pop %rcx pop %rax pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %r8 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x197b6, %r13 mfence mov (%r13), %edx sub $1493, %rax lea addresses_WC_ht+0x19fc0, %r11 nop inc %rcx vmovups (%r11), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %r10 nop nop and $53873, %r8 lea addresses_D_ht+0x8460, %rsi lea addresses_WC_ht+0x3cec, %rdi cmp $41168, %r11 mov $21, %rcx rep movsw nop nop nop inc %r8 lea addresses_WC_ht+0x3148, %rsi lea addresses_WC_ht+0x8fc0, %rdi and %r10, %r10 mov $60, %rcx rep movsb nop nop nop inc %rdi lea addresses_WT_ht+0x3f80, %rdx sub $35373, %r8 mov (%rdx), %r10d nop nop add $36816, %rsi lea addresses_WT_ht+0xb691, %rsi lea addresses_UC_ht+0xb194, %rdi clflush (%rdi) nop nop dec %r8 mov $25, %rcx rep movsq nop nop and %r13, %r13 lea addresses_WT_ht+0x2870, %r13 nop nop nop add $53717, %rdi mov (%r13), %edx cmp $20450, %rax lea addresses_A_ht+0xdbc0, %rsi lea addresses_D_ht+0x3a90, %rdi nop nop nop nop nop inc %r10 mov $75, %rcx rep movsq nop nop nop nop nop add %rdi, %rdi lea addresses_WC_ht+0x11f53, %rdx nop dec %rdi mov (%rdx), %si nop nop nop sub $52838, %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r15 push %r8 push %rbp push %rbx push %rdi // Store mov $0xc90, %r15 add %r8, %r8 mov $0x5152535455565758, %r14 movq %r14, %xmm7 movups %xmm7, (%r15) xor $32699, %r8 // Load lea addresses_UC+0x16590, %rbx sub %r15, %r15 mov (%rbx), %r12 nop nop nop and %r14, %r14 // Store lea addresses_UC+0x79c0, %r8 nop nop sub %rbx, %rbx mov $0x5152535455565758, %r14 movq %r14, %xmm0 vmovups %ymm0, (%r8) nop cmp $10404, %r15 // Load lea addresses_RW+0x1d8a8, %r15 nop sub $3367, %rbp movb (%r15), %bl nop nop nop nop dec %rdi // Store lea addresses_US+0x43c0, %r8 cmp %r15, %r15 mov $0x5152535455565758, %rdi movq %rdi, (%r8) dec %rbx // Load lea addresses_UC+0x1bc40, %r15 add $17656, %rbp vmovups (%r15), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %r8 nop nop nop nop dec %rdi // Store lea addresses_WT+0x1f280, %r12 nop nop nop nop nop sub %r8, %r8 mov $0x5152535455565758, %r14 movq %r14, (%r12) nop nop nop nop nop add $35201, %r8 // Load mov $0xcc0, %rdi xor %rbx, %rbx mov (%rdi), %r8d add %rdi, %rdi // Faulty Load lea addresses_US+0x8bc0, %r8 cmp %rbp, %rbp movb (%r8), %bl lea oracles, %r14 and $0xff, %rbx shlq $12, %rbx mov (%r14,%rbx,1), %rbx pop %rdi pop %rbx pop %rbp pop %r8 pop %r15 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_P'}} {'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC'}} {'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 8, 'NT': True, 'type': 'addresses_US'}} {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WT'}} {'src': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_P'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': True, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 0, 'same': True, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
SECTION code_crt0_sccz80 PUBLIC l_mult ; HL = DE * HL [signed] l_mult: ccmul: LD b,h LD c,l LD HL,0 ccmul1: LD a,c RRCA JP NC,ccmul2 ADD HL,DE ccmul2: XOR a LD a,b RRA LD b,a LD a,c RRA LD c,a OR b RET Z XOR a IF __CPU_8085__ rl de ld a,d ELSE LD a,e RLA LD e,a LD a,d RLA LD d,a ENDIF OR e RET Z JP ccmul1
.MODEL SMALL .STACK 100H .DATA PROMPT DB 'ENTER THE BINARY NUM:$' MSG DB 0DH, 0AH, 'GIVEN BINARY NUM IN REV ORDER:$' .CODE MAIN PROC MOV AX,@DATA MOV DS,AX LEA DX, PROMPT MOV AH, 9 INT 21H XOR BL,BL MOV CX,8 MOV AH,1 @INPUT: INT 21H CMP AL, 0DH JE @END AND AL, 0FH SHL BL,1 OR BL,AL LOOP @INPUT @END: MOV AL,BL MOV CX,8 ;@LOOP: ; SHL AL,4 ; RCR BL,4 ; ;LOOP @LOOP SHR BL,5 ;RCL BL,4 LEA DX, MSG MOV AH,9 INT 21H MOV CX, 8 MOV AH, 2 @OUTPUT: SHL BL, 1 JNC @ZERO MOV DL, 31H JMP @PRINT @ZERO: MOV DL, 30H @PRINT: INT 21H LOOP @OUTPUT MOV AH, 4CH INT 21H MAIN ENDP END MAIN
; A105747: Number of ways to use the elements of {1,..,k}, 0<=k<=2n, once each to form a collection of n (possibly empty) lists, each of length at most 2. ; Submitted by Jamie Morken(s4) ; 1,4,23,216,2937,52108,1136591,29382320,877838673,29753600404,1127881002535,47278107653768,2171286661012617,108417864555606300,5847857079417024031,338841578119273846112 lpb $0 mov $2,$0 sub $0,1 seq $2,1517 ; Bessel polynomials y_n(x) (see A001498) evaluated at 2. add $3,$2 lpe mov $0,$3 add $0,1
// Original test: ./rbatterm/hw4/problem6/xori_2.asm // Author: rbatterm // Test source code follows // test imm zero, reg ones lbi r2, 0 //00000 xori r1, r2, 31 //11111 halt //= 11111
; ; ANSI Video handling for the Commodore 128 (Z80 mode) ; By Stefano Bodrato - 22/08/2001 ; ; set it up with: ; .text_cols = max columns ; .text_rows = max rows ; ; Display a char in location (ansi_ROW),(ansi_COLUMN) ; A=char to display ; ; ; $Id: f_ansi_char.asm,v 1.5 2016/04/04 18:31:22 dom Exp $ ; SECTION code_clib PUBLIC ansi_CHAR PUBLIC text_cols PUBLIC text_rows PUBLIC INVRS PUBLIC ATTR EXTERN ansi_ROW EXTERN ansi_COLUMN .text_cols defb 40 .text_rows defb 25 .ansi_CHAR push af ld hl,$2000 ld a,(ansi_ROW) and a jr z,r_zero ld b,a ld de,40 .r_loop add hl,de djnz r_loop .r_zero ld a,(ansi_COLUMN) ld d,0 ld e,a add hl,de pop af cp 96 jr c,nolower sub 96 jr setout .nolower ; These lines aren't needed when we use the alternate font ; cp 64 ; jr c,noupper ; sub 64 ;.noupper .setout .INVRS or 0 ; This byte is set to 128 when INVERSE is ON ld (hl),a ld de,$1000 sbc hl,de ; Color map location .ATTR ld (hl),1 ; This byte is the current attribute ret
; --------------------------------------------------------------------------- ; Sprite mappings - doors (SBZ) ; --------------------------------------------------------------------------- dc.w byte_89FE-Map_obj2A, byte_8A09-Map_obj2A dc.w byte_8A14-Map_obj2A, byte_8A1F-Map_obj2A dc.w byte_8A2A-Map_obj2A, byte_8A35-Map_obj2A dc.w byte_8A40-Map_obj2A, byte_8A4B-Map_obj2A dc.w byte_8A56-Map_obj2A byte_89FE: dc.b 2 dc.b $E0, 7, 8, 0, $F8 ; door closed dc.b 0, 7, 8, 0, $F8 byte_8A09: dc.b 2 dc.b $DC, 7, 8, 0, $F8 dc.b 4, 7, 8, 0, $F8 byte_8A14: dc.b 2 dc.b $D8, 7, 8, 0, $F8 dc.b 8, 7, 8, 0, $F8 byte_8A1F: dc.b 2 dc.b $D4, 7, 8, 0, $F8 dc.b $C, 7, 8, 0, $F8 byte_8A2A: dc.b 2 dc.b $D0, 7, 8, 0, $F8 dc.b $10, 7, 8, 0, $F8 byte_8A35: dc.b 2 dc.b $CC, 7, 8, 0, $F8 dc.b $14, 7, 8, 0, $F8 byte_8A40: dc.b 2 dc.b $C8, 7, 8, 0, $F8 dc.b $18, 7, 8, 0, $F8 byte_8A4B: dc.b 2 dc.b $C4, 7, 8, 0, $F8 dc.b $1C, 7, 8, 0, $F8 byte_8A56: dc.b 2 dc.b $C0, 7, 8, 0, $F8 ; door fully open dc.b $20, 7, 8, 0, $F8 even
/////////////////////////////////////////////////////////////////////////////// // BSD 3-Clause License // // Copyright (c) 2021, Institut de Robotica i Informatica Industrial (CSIC-UPC) // All rights reserved. /////////////////////////////////////////////////////////////////////////////// #ifndef EAGLE_MPC_TRAJECTORY_HPP_ #define EAGLE_MPC_TRAJECTORY_HPP_ #include <iostream> #include <map> #include <string> #include <vector> #include <Eigen/Dense> #include "boost/enable_shared_from_this.hpp" #include "pinocchio/multibody/model.hpp" #include "pinocchio/parsers/urdf.hpp" #include "crocoddyl/core/actuation/squashing/smooth-sat.hpp" #include "crocoddyl/core/actuation/actuation-squashing.hpp" #include "crocoddyl/core/optctrl/shooting.hpp" #include "crocoddyl/core/diff-action-base.hpp" #include "crocoddyl/multibody/actuations/multicopter-base.hpp" #include "crocoddyl/multibody/states/multibody.hpp" #include "eagle_mpc/multicopter-base-params.hpp" #include "eagle_mpc/stage.hpp" #include "eagle_mpc/utils/params_server.hpp" #include "eagle_mpc/utils/parser_yaml.hpp" #include "eagle_mpc/factory/diff-action.hpp" #include "eagle_mpc/factory/int-action.hpp" namespace eagle_mpc { class Stage; class DifferentialActionModelFactory; class IntegratedActionModelFactory; class Trajectory : public boost::enable_shared_from_this<Trajectory> { public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW ~Trajectory(); static boost::shared_ptr<Trajectory> create(); void autoSetup(const std::string& yaml_path); boost::shared_ptr<crocoddyl::ShootingProblem> createProblem() const; boost::shared_ptr<crocoddyl::ShootingProblem> createProblem(const std::size_t& dt, const bool& squash, const std::string& integration_method) const; void removeStage(const std::size_t& idx_stage); void set_initial_state(const Eigen::VectorXd& initial_state); const std::vector<boost::shared_ptr<Stage>>& get_stages() const; const boost::shared_ptr<pinocchio::Model>& get_robot_model() const; const boost::shared_ptr<MultiCopterBaseParams>& get_platform_params() const; const boost::shared_ptr<crocoddyl::StateMultibody>& get_robot_state() const; const boost::shared_ptr<crocoddyl::ActuationModelMultiCopterBase>& get_actuation() const; const boost::shared_ptr<crocoddyl::SquashingModelSmoothSat>& get_squash() const; const boost::shared_ptr<crocoddyl::ActuationSquashingModel>& get_actuation_squash() const; const std::string& get_robot_model_path() const; const Eigen::VectorXd& get_initial_state() const; const boost::shared_ptr<ParamsServer>& get_params_server() const; const bool& get_has_contact() const; const std::size_t& get_duration() const; private: Trajectory(); std::vector<boost::shared_ptr<Stage>> stages_; boost::shared_ptr<pinocchio::Model> robot_model_; boost::shared_ptr<MultiCopterBaseParams> platform_params_; std::string robot_model_path_; boost::shared_ptr<crocoddyl::StateMultibody> robot_state_; boost::shared_ptr<crocoddyl::ActuationModelMultiCopterBase> actuation_; boost::shared_ptr<crocoddyl::SquashingModelSmoothSat> squash_; boost::shared_ptr<crocoddyl::ActuationSquashingModel> actuation_squash_; Eigen::VectorXd initial_state_; bool has_contact_; std::size_t duration_; boost::shared_ptr<ParamsServer> params_server_; boost::shared_ptr<DifferentialActionModelFactory> dam_factory_; boost::shared_ptr<IntegratedActionModelFactory> iam_factory_; struct ProblemParams { bool use_squash; int dt; std::string integrator; } problem_params_; }; } // namespace eagle_mpc #endif
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r13 push %r9 push %rbp push %rcx push %rdi push %rsi lea addresses_A_ht+0x1115d, %r10 nop nop nop nop add $12886, %rsi mov $0x6162636465666768, %r12 movq %r12, %xmm0 movups %xmm0, (%r10) nop cmp $29020, %rbp lea addresses_D_ht+0x765d, %r13 nop nop nop nop sub $10639, %r11 movw $0x6162, (%r13) nop nop add $33047, %r12 lea addresses_D_ht+0x1c2dd, %r13 clflush (%r13) nop nop nop sub %r11, %r11 movw $0x6162, (%r13) nop nop nop nop nop add %r11, %r11 lea addresses_WT_ht+0x1775d, %rsi nop nop nop nop nop add %r10, %r10 mov $0x6162636465666768, %r13 movq %r13, (%rsi) nop nop nop and $31431, %r9 lea addresses_normal_ht+0x10e7d, %rsi lea addresses_WC_ht+0x125d, %rdi nop nop nop nop nop xor %r9, %r9 mov $121, %rcx rep movsw nop nop nop nop xor $7029, %rbp lea addresses_UC_ht+0x12fdd, %r10 nop nop nop nop inc %r11 mov (%r10), %di nop and %r12, %r12 lea addresses_A_ht+0x1519d, %rsi lea addresses_A_ht+0x1e2dd, %rdi nop nop and %r10, %r10 mov $68, %rcx rep movsq nop nop and %rsi, %rsi pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r13 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r8 push %r9 push %rbp push %rcx push %rdi push %rsi // Store lea addresses_RW+0xbd5d, %rdi and %rbp, %rbp movb $0x51, (%rdi) nop nop nop nop nop inc %r8 // Store lea addresses_normal+0x1eedd, %r8 cmp $50296, %rbp mov $0x5152535455565758, %rdi movq %rdi, %xmm2 vmovups %ymm2, (%r8) nop xor %rbp, %rbp // Store lea addresses_A+0x1d9be, %rbp nop nop nop and $49024, %rsi mov $0x5152535455565758, %rdi movq %rdi, %xmm6 vmovups %ymm6, (%rbp) nop cmp %rcx, %rcx // Store lea addresses_PSE+0xfdd, %r8 nop nop nop and %rcx, %rcx movw $0x5152, (%r8) nop nop nop nop nop add $47602, %r8 // Load lea addresses_UC+0x91dd, %rsi nop nop nop and %r11, %r11 mov (%rsi), %ebp nop sub %r11, %r11 // Store lea addresses_PSE+0xb089, %rcx nop nop dec %rbp movl $0x51525354, (%rcx) and %r9, %r9 // Store lea addresses_PSE+0x64dd, %r11 inc %r9 mov $0x5152535455565758, %r8 movq %r8, (%r11) nop nop xor $3444, %r11 // Faulty Load mov $0x6dd, %rsi nop xor %rcx, %rcx movaps (%rsi), %xmm6 vpextrq $1, %xmm6, %rdi lea oracles, %rsi and $0xff, %rdi shlq $12, %rdi mov (%rsi,%rdi,1), %rdi pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': True, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 8}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': True, 'type': 'addresses_P', 'same': True, 'AVXalign': True, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': True, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 7}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 10}} {'44': 3890, '45': 17932, '00': 7} 45 45 45 44 44 45 44 45 45 45 45 45 45 44 45 44 45 45 45 44 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 44 45 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 44 45 45 45 45 44 45 45 44 45 45 45 45 45 44 45 45 45 45 45 44 44 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 44 45 45 45 44 45 45 44 45 45 44 45 45 44 45 44 45 45 45 44 45 44 45 44 45 45 45 45 45 45 44 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 44 44 45 45 44 45 44 44 45 45 45 44 45 45 45 45 45 44 44 45 45 45 45 45 44 45 44 45 44 45 45 45 44 45 44 45 45 45 44 45 45 45 45 45 45 44 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 45 45 44 44 45 44 45 45 44 44 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 44 45 45 44 44 44 45 45 44 45 45 45 45 45 45 45 45 45 44 45 44 45 45 45 45 45 45 45 44 45 45 45 44 44 45 44 45 44 45 45 44 45 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 44 45 44 45 45 44 45 44 45 44 45 45 45 44 44 45 45 45 44 45 44 45 45 45 45 45 45 44 45 45 45 44 45 45 45 45 44 45 44 45 45 44 45 44 45 45 45 44 45 45 45 45 45 45 45 45 45 44 45 45 45 45 44 45 45 45 45 45 45 44 45 45 45 45 45 44 45 45 45 45 45 45 45 45 44 45 44 44 45 45 45 45 45 45 44 45 45 44 44 44 44 45 45 44 44 44 44 44 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 44 45 45 45 45 44 45 44 45 45 45 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 45 44 45 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 45 44 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 45 44 45 44 45 44 44 45 45 45 45 44 45 45 45 45 45 44 45 45 44 45 45 45 45 45 45 44 45 44 45 45 45 45 45 44 45 44 45 44 45 45 45 45 45 45 45 44 45 44 44 45 45 44 45 45 45 44 45 45 45 45 45 44 45 45 44 44 45 44 45 45 45 45 45 45 45 44 45 45 45 45 45 44 44 45 45 45 45 45 44 45 44 45 45 45 45 45 45 45 45 45 44 45 45 45 45 44 45 45 45 45 45 45 45 45 45 44 45 45 45 44 45 45 45 45 44 44 45 45 44 44 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 44 45 45 45 44 45 45 45 45 45 44 45 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 45 44 45 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 45 45 45 44 45 45 45 44 45 45 45 45 45 45 45 45 44 45 45 45 45 44 45 45 45 45 45 45 44 44 45 45 45 45 45 45 45 45 44 45 45 44 45 45 45 45 45 44 45 44 45 45 45 44 45 45 44 45 45 45 44 45 45 44 45 45 45 45 45 45 45 45 45 45 44 45 45 45 45 44 45 44 45 45 45 45 45 44 45 45 44 45 45 45 45 45 45 45 45 45 45 44 44 45 45 44 45 44 45 45 44 45 45 44 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 44 45 45 45 45 45 44 45 45 45 44 45 45 44 45 45 45 45 44 44 45 44 45 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 44 45 45 45 45 45 44 45 45 45 45 45 44 45 45 45 45 45 45 45 45 45 44 45 44 45 44 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 44 45 */
//***************************************************************************** // Copyright 2017-2019 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //***************************************************************************** // NOTE: This file follows nGraph format style and MLIR naming convention since it does // not expose public API to the rest of nGraph codebase and heavily depends on MLIR API. #pragma once #include "contrib/mlir/compiler/compiler.hpp" #include <mlir/Pass/Pass.h> namespace ngraph { namespace runtime { namespace ngmlir { class MLIRCompiler; } } } namespace mlir { std::unique_ptr<Pass> createDialectLoweringPass(ngraph::runtime::ngmlir::MLIRCompiler* compiler); }
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifdef HAVE_CONFIG_H #include "config/bitdollar-config.h" #endif #include "netaddress.h" #include "netbase.h" #include "hash.h" #include "utilstrencodings.h" #include "tinyformat.h" static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }; static const unsigned char pchOnionCat[] = {0xFD,0x87,0xD8,0x7E,0xEB,0x43}; bool fAllowPrivateNet = DEFAULT_ALLOWPRIVATENET; void CNetAddr::Init() { memset(ip, 0, sizeof(ip)); scopeId = 0; } void CNetAddr::SetIP(const CNetAddr& ipIn) { memcpy(ip, ipIn.ip, sizeof(ip)); } void CNetAddr::SetRaw(Network network, const uint8_t *ip_in) { switch(network) { case NET_IPV4: memcpy(ip, pchIPv4, 12); memcpy(ip+12, ip_in, 4); break; case NET_IPV6: memcpy(ip, ip_in, 16); break; default: assert(!"invalid network"); } } bool CNetAddr::SetSpecial(const std::string &strName) { if (strName.size()>6 && strName.substr(strName.size() - 6, 6) == ".onion") { std::vector<unsigned char> vchAddr = DecodeBase32(strName.substr(0, strName.size() - 6).c_str()); if (vchAddr.size() != 16-sizeof(pchOnionCat)) return false; memcpy(ip, pchOnionCat, sizeof(pchOnionCat)); for (unsigned int i=0; i<16-sizeof(pchOnionCat); i++) ip[i + sizeof(pchOnionCat)] = vchAddr[i]; return true; } return false; } CNetAddr::CNetAddr() { Init(); } CNetAddr::CNetAddr(const struct in_addr& ipv4Addr) { SetRaw(NET_IPV4, (const uint8_t*)&ipv4Addr); } CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr, const uint32_t scope) { SetRaw(NET_IPV6, (const uint8_t*)&ipv6Addr); scopeId = scope; } unsigned int CNetAddr::GetByte(int n) const { return ip[15-n]; } bool CNetAddr::IsIPv4() const { return (memcmp(ip, pchIPv4, sizeof(pchIPv4)) == 0); } bool CNetAddr::IsIPv6() const { return (!IsIPv4() && !IsTor()); } bool CNetAddr::IsRFC1918() const { return IsIPv4() && ( GetByte(3) == 10 || (GetByte(3) == 192 && GetByte(2) == 168) || (GetByte(3) == 172 && (GetByte(2) >= 16 && GetByte(2) <= 31))); } bool CNetAddr::IsRFC2544() const { return IsIPv4() && GetByte(3) == 198 && (GetByte(2) == 18 || GetByte(2) == 19); } bool CNetAddr::IsRFC3927() const { return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); } bool CNetAddr::IsRFC6598() const { return IsIPv4() && GetByte(3) == 100 && GetByte(2) >= 64 && GetByte(2) <= 127; } bool CNetAddr::IsRFC5737() const { return IsIPv4() && ((GetByte(3) == 192 && GetByte(2) == 0 && GetByte(1) == 2) || (GetByte(3) == 198 && GetByte(2) == 51 && GetByte(1) == 100) || (GetByte(3) == 203 && GetByte(2) == 0 && GetByte(1) == 113)); } bool CNetAddr::IsRFC3849() const { return GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x0D && GetByte(12) == 0xB8; } bool CNetAddr::IsRFC3964() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x02); } bool CNetAddr::IsRFC6052() const { static const unsigned char pchRFC6052[] = {0,0x64,0xFF,0x9B,0,0,0,0,0,0,0,0}; return (memcmp(ip, pchRFC6052, sizeof(pchRFC6052)) == 0); } bool CNetAddr::IsRFC4380() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0 && GetByte(12) == 0); } bool CNetAddr::IsRFC4862() const { static const unsigned char pchRFC4862[] = {0xFE,0x80,0,0,0,0,0,0}; return (memcmp(ip, pchRFC4862, sizeof(pchRFC4862)) == 0); } bool CNetAddr::IsRFC4193() const { return ((GetByte(15) & 0xFE) == 0xFC); } bool CNetAddr::IsRFC6145() const { static const unsigned char pchRFC6145[] = {0,0,0,0,0,0,0,0,0xFF,0xFF,0,0}; return (memcmp(ip, pchRFC6145, sizeof(pchRFC6145)) == 0); } bool CNetAddr::IsRFC4843() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && (GetByte(12) & 0xF0) == 0x10); } bool CNetAddr::IsTor() const { return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0); } bool CNetAddr::IsLocal() const { // IPv4 loopback if (IsIPv4() && (GetByte(3) == 127 || GetByte(3) == 0)) return true; // IPv6 loopback (::1/128) static const unsigned char pchLocal[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; if (memcmp(ip, pchLocal, 16) == 0) return true; return false; } bool CNetAddr::IsMulticast() const { return (IsIPv4() && (GetByte(3) & 0xF0) == 0xE0) || (GetByte(15) == 0xFF); } bool CNetAddr::IsValid() const { // Cleanup 3-byte shifted addresses caused by garbage in size field // of addr messages from versions before 0.2.9 checksum. // Two consecutive addr messages look like this: // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26... // so if the first length field is garbled, it reads the second batch // of addr misaligned by 3 bytes. if (memcmp(ip, pchIPv4+3, sizeof(pchIPv4)-3) == 0) return false; // unspecified IPv6 address (::/128) unsigned char ipNone6[16] = {}; if (memcmp(ip, ipNone6, 16) == 0) return false; // documentation IPv6 address if (IsRFC3849()) return false; if (IsIPv4()) { // INADDR_NONE uint32_t ipNone = INADDR_NONE; if (memcmp(ip+12, &ipNone, 4) == 0) return false; // 0 ipNone = 0; if (memcmp(ip+12, &ipNone, 4) == 0) return false; } return true; } bool CNetAddr::IsRoutable() const { if (!IsValid()) return false; if (!fAllowPrivateNet && IsRFC1918()) return false; return !(IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || (IsRFC4193() && !IsTor()) || IsRFC4843() || IsLocal()); } enum Network CNetAddr::GetNetwork() const { if (!IsRoutable()) return NET_UNROUTABLE; if (IsIPv4()) return NET_IPV4; if (IsTor()) return NET_TOR; return NET_IPV6; } std::string CNetAddr::ToStringIP(bool fUseGetnameinfo) const { if (IsTor()) return EncodeBase32(&ip[6], 10) + ".onion"; if (fUseGetnameinfo) { CService serv(*this, 0); struct sockaddr_storage sockaddr; socklen_t socklen = sizeof(sockaddr); if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) { char name[1025] = ""; if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), NULL, 0, NI_NUMERICHOST)) return std::string(name); } } if (IsIPv4()) return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0)); else return strprintf("%x:%x:%x:%x:%x:%x:%x:%x", GetByte(15) << 8 | GetByte(14), GetByte(13) << 8 | GetByte(12), GetByte(11) << 8 | GetByte(10), GetByte(9) << 8 | GetByte(8), GetByte(7) << 8 | GetByte(6), GetByte(5) << 8 | GetByte(4), GetByte(3) << 8 | GetByte(2), GetByte(1) << 8 | GetByte(0)); } std::string CNetAddr::ToString() const { return ToStringIP(); } bool operator==(const CNetAddr& a, const CNetAddr& b) { return (memcmp(a.ip, b.ip, 16) == 0); } bool operator!=(const CNetAddr& a, const CNetAddr& b) { return (memcmp(a.ip, b.ip, 16) != 0); } bool operator<(const CNetAddr& a, const CNetAddr& b) { return (memcmp(a.ip, b.ip, 16) < 0); } bool CNetAddr::GetInAddr(struct in_addr* pipv4Addr) const { if (!IsIPv4()) return false; memcpy(pipv4Addr, ip+12, 4); return true; } bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const { memcpy(pipv6Addr, ip, 16); return true; } // get canonical identifier of an address' group // no two connections will be attempted to addresses with the same group std::vector<unsigned char> CNetAddr::GetGroup() const { std::vector<unsigned char> vchRet; int nClass = NET_IPV6; int nStartByte = 0; int nBits = 16; // all local addresses belong to the same group if (IsLocal()) { nClass = 255; nBits = 0; } // all unroutable addresses belong to the same group if (!IsRoutable()) { nClass = NET_UNROUTABLE; nBits = 0; } // for IPv4 addresses, '1' + the 16 higher-order bits of the IP // includes mapped IPv4, SIIT translated IPv4, and the well-known prefix else if (IsIPv4() || IsRFC6145() || IsRFC6052()) { nClass = NET_IPV4; nStartByte = 12; } // for 6to4 tunnelled addresses, use the encapsulated IPv4 address else if (IsRFC3964()) { nClass = NET_IPV4; nStartByte = 2; } // for Teredo-tunnelled IPv6 addresses, use the encapsulated IPv4 address else if (IsRFC4380()) { vchRet.push_back(NET_IPV4); vchRet.push_back(GetByte(3) ^ 0xFF); vchRet.push_back(GetByte(2) ^ 0xFF); return vchRet; } else if (IsTor()) { nClass = NET_TOR; nStartByte = 6; nBits = 4; } // for he.net, use /36 groups else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x04 && GetByte(12) == 0x70) nBits = 36; // for the rest of the IPv6 network, use /32 groups else nBits = 32; vchRet.push_back(nClass); while (nBits >= 8) { vchRet.push_back(GetByte(15 - nStartByte)); nStartByte++; nBits -= 8; } if (nBits > 0) vchRet.push_back(GetByte(15 - nStartByte) | ((1 << (8 - nBits)) - 1)); return vchRet; } uint64_t CNetAddr::GetHash() const { uint256 hash = Hash(&ip[0], &ip[16]); uint64_t nRet; memcpy(&nRet, &hash, sizeof(nRet)); return nRet; } // private extensions to enum Network, only returned by GetExtNetwork, // and only used in GetReachabilityFrom static const int NET_UNKNOWN = NET_MAX + 0; static const int NET_TEREDO = NET_MAX + 1; int static GetExtNetwork(const CNetAddr *addr) { if (addr == NULL) return NET_UNKNOWN; if (addr->IsRFC4380()) return NET_TEREDO; return addr->GetNetwork(); } /** Calculates a metric for how reachable (*this) is from a given partner */ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const { enum Reachability { REACH_UNREACHABLE, REACH_DEFAULT, REACH_TEREDO, REACH_IPV6_WEAK, REACH_IPV4, REACH_IPV6_STRONG, REACH_PRIVATE }; if (!IsRoutable()) return REACH_UNREACHABLE; int ourNet = GetExtNetwork(this); int theirNet = GetExtNetwork(paddrPartner); bool fTunnel = IsRFC3964() || IsRFC6052() || IsRFC6145(); switch(theirNet) { case NET_IPV4: switch(ourNet) { default: return REACH_DEFAULT; case NET_IPV4: return REACH_IPV4; } case NET_IPV6: switch(ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV4: return REACH_IPV4; case NET_IPV6: return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunnelled } case NET_TOR: switch(ourNet) { default: return REACH_DEFAULT; case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well case NET_TOR: return REACH_PRIVATE; } case NET_TEREDO: switch(ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV6: return REACH_IPV6_WEAK; case NET_IPV4: return REACH_IPV4; } case NET_UNKNOWN: case NET_UNROUTABLE: default: switch(ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV6: return REACH_IPV6_WEAK; case NET_IPV4: return REACH_IPV4; case NET_TOR: return REACH_PRIVATE; // either from Tor, or don't care about our address } } } void CService::Init() { port = 0; } CService::CService() { Init(); } CService::CService(const CNetAddr& cip, unsigned short portIn) : CNetAddr(cip), port(portIn) { } CService::CService(const struct in_addr& ipv4Addr, unsigned short portIn) : CNetAddr(ipv4Addr), port(portIn) { } CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn) { } CService::CService(const struct sockaddr_in& addr) : CNetAddr(addr.sin_addr), port(ntohs(addr.sin_port)) { assert(addr.sin_family == AF_INET); } CService::CService(const struct sockaddr_in6 &addr) : CNetAddr(addr.sin6_addr, addr.sin6_scope_id), port(ntohs(addr.sin6_port)) { assert(addr.sin6_family == AF_INET6); } bool CService::SetSockAddr(const struct sockaddr *paddr) { switch (paddr->sa_family) { case AF_INET: *this = CService(*(const struct sockaddr_in*)paddr); return true; case AF_INET6: *this = CService(*(const struct sockaddr_in6*)paddr); return true; default: return false; } } unsigned short CService::GetPort() const { return port; } bool operator==(const CService& a, const CService& b) { return (CNetAddr)a == (CNetAddr)b && a.port == b.port; } bool operator!=(const CService& a, const CService& b) { return (CNetAddr)a != (CNetAddr)b || a.port != b.port; } bool operator<(const CService& a, const CService& b) { return (CNetAddr)a < (CNetAddr)b || ((CNetAddr)a == (CNetAddr)b && a.port < b.port); } bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const { if (IsIPv4()) { if (*addrlen < (socklen_t)sizeof(struct sockaddr_in)) return false; *addrlen = sizeof(struct sockaddr_in); struct sockaddr_in *paddrin = (struct sockaddr_in*)paddr; memset(paddrin, 0, *addrlen); if (!GetInAddr(&paddrin->sin_addr)) return false; paddrin->sin_family = AF_INET; paddrin->sin_port = htons(port); return true; } if (IsIPv6()) { if (*addrlen < (socklen_t)sizeof(struct sockaddr_in6)) return false; *addrlen = sizeof(struct sockaddr_in6); struct sockaddr_in6 *paddrin6 = (struct sockaddr_in6*)paddr; memset(paddrin6, 0, *addrlen); if (!GetIn6Addr(&paddrin6->sin6_addr)) return false; paddrin6->sin6_scope_id = scopeId; paddrin6->sin6_family = AF_INET6; paddrin6->sin6_port = htons(port); return true; } return false; } std::vector<unsigned char> CService::GetKey() const { std::vector<unsigned char> vKey; vKey.resize(18); memcpy(&vKey[0], ip, 16); vKey[16] = port / 0x100; vKey[17] = port & 0x0FF; return vKey; } std::string CService::ToStringPort() const { return strprintf("%u", port); } std::string CService::ToStringIPPort(bool fUseGetnameinfo) const { if (IsIPv4() || IsTor()) { return ToStringIP(fUseGetnameinfo) + ":" + ToStringPort(); } else { return "[" + ToStringIP(fUseGetnameinfo) + "]:" + ToStringPort(); } } std::string CService::ToString(bool fUseGetnameinfo) const { return ToStringIPPort(fUseGetnameinfo); } void CService::SetPort(unsigned short portIn) { port = portIn; } CSubNet::CSubNet(): valid(false) { memset(netmask, 0, sizeof(netmask)); } CSubNet::CSubNet(const CNetAddr &addr, int32_t mask) { valid = true; network = addr; // Default to /32 (IPv4) or /128 (IPv6), i.e. match single address memset(netmask, 255, sizeof(netmask)); // IPv4 addresses start at offset 12, and first 12 bytes must match, so just offset n const int astartofs = network.IsIPv4() ? 12 : 0; int32_t n = mask; if(n >= 0 && n <= (128 - astartofs*8)) // Only valid if in range of bits of address { n += astartofs*8; // Clear bits [n..127] for (; n < 128; ++n) netmask[n>>3] &= ~(1<<(7-(n&7))); } else valid = false; // Normalize network according to netmask for(int x=0; x<16; ++x) network.ip[x] &= netmask[x]; } CSubNet::CSubNet(const CNetAddr &addr, const CNetAddr &mask) { valid = true; network = addr; // Default to /32 (IPv4) or /128 (IPv6), i.e. match single address memset(netmask, 255, sizeof(netmask)); // IPv4 addresses start at offset 12, and first 12 bytes must match, so just offset n const int astartofs = network.IsIPv4() ? 12 : 0; for(int x=astartofs; x<16; ++x) netmask[x] = mask.ip[x]; // Normalize network according to netmask for(int x=0; x<16; ++x) network.ip[x] &= netmask[x]; } CSubNet::CSubNet(const CNetAddr &addr): valid(addr.IsValid()) { memset(netmask, 255, sizeof(netmask)); network = addr; } bool CSubNet::Match(const CNetAddr &addr) const { if (!valid || !addr.IsValid()) return false; for(int x=0; x<16; ++x) if ((addr.ip[x] & netmask[x]) != network.ip[x]) return false; return true; } static inline int NetmaskBits(uint8_t x) { switch(x) { case 0x00: return 0; break; case 0x80: return 1; break; case 0xc0: return 2; break; case 0xe0: return 3; break; case 0xf0: return 4; break; case 0xf8: return 5; break; case 0xfc: return 6; break; case 0xfe: return 7; break; case 0xff: return 8; break; default: return -1; break; } } std::string CSubNet::ToString() const { /* Parse binary 1{n}0{N-n} to see if mask can be represented as /n */ int cidr = 0; bool valid_cidr = true; int n = network.IsIPv4() ? 12 : 0; for (; n < 16 && netmask[n] == 0xff; ++n) cidr += 8; if (n < 16) { int bits = NetmaskBits(netmask[n]); if (bits < 0) valid_cidr = false; else cidr += bits; ++n; } for (; n < 16 && valid_cidr; ++n) if (netmask[n] != 0x00) valid_cidr = false; /* Format output */ std::string strNetmask; if (valid_cidr) { strNetmask = strprintf("%u", cidr); } else { if (network.IsIPv4()) strNetmask = strprintf("%u.%u.%u.%u", netmask[12], netmask[13], netmask[14], netmask[15]); else strNetmask = strprintf("%x:%x:%x:%x:%x:%x:%x:%x", netmask[0] << 8 | netmask[1], netmask[2] << 8 | netmask[3], netmask[4] << 8 | netmask[5], netmask[6] << 8 | netmask[7], netmask[8] << 8 | netmask[9], netmask[10] << 8 | netmask[11], netmask[12] << 8 | netmask[13], netmask[14] << 8 | netmask[15]); } return network.ToString() + "/" + strNetmask; } bool CSubNet::IsValid() const { return valid; } bool operator==(const CSubNet& a, const CSubNet& b) { return a.valid == b.valid && a.network == b.network && !memcmp(a.netmask, b.netmask, 16); } bool operator!=(const CSubNet& a, const CSubNet& b) { return !(a==b); } bool operator<(const CSubNet& a, const CSubNet& b) { return (a.network < b.network || (a.network == b.network && memcmp(a.netmask, b.netmask, 16) < 0)); }
MOV A,#00H MOV 10H,#10B MOV 11H,#10 MOV 12H,#10H MOV R0,#10H ADD A,R0 ADD A,@R0 INC R0 ADD A,R0 ADD A,@R0 INC R0 ADD A,R0 ADD A,@R0
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r8 push %rbx push %rcx // Faulty Load lea addresses_PSE+0x1d241, %r11 clflush (%r11) nop nop nop nop dec %r14 movups (%r11), %xmm1 vpextrq $0, %xmm1, %rbx lea oracles, %r11 and $0xff, %rbx shlq $12, %rbx mov (%r11,%rbx,1), %rbx pop %rcx pop %rbx pop %r8 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} <gen_prepare_buffer> {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
COMMENT @---------------------------------------------------------------------- Copyright (c) GeoWorks 1988 -- All Rights Reserved PROJECT: PC GEOS MODULE: CommonUI/CSpec FILE: cspecAppDocumentControl.asm ROUTINES: Name Description ---- ----------- GLB OLBuildAppDocumentControl Convert a generic document control to the OL equivalent REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version DESCRIPTION: This file contains routines to handle the Open Look implementation of a generic document control. $Id: cspecAppDocumentControl.asm,v 1.1 97/04/07 10:50:58 newdeal Exp $ ------------------------------------------------------------------------------@ DocInit segment resource COMMENT @---------------------------------------------------------------------- FUNCTION: OLBuildAppDocumentControl DESCRIPTION: Return the specific UI class for a GenDocumentGroup CALLED BY: GLOBAL PASS: *ds:si - instance data ax - MSG_META_RESOLVE_VARIANT_SUPERCLASS cx, dx, bp - ? RETURN: cx:dx - class (cx = 0 for no conversion) DESTROYED: ax, bx, si, di, bp, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 2/89 Initial version ------------------------------------------------------------------------------@ OLBuildAppDocumentControl proc far ; Always convert to OLDocumentGroupClass mov dx, offset OLDocumentGroupClass mov cx, segment OLDocumentGroupClass ret OLBuildAppDocumentControl endp DocInit ends
#include <bits/stdc++.h> #define int long long #define For(i,a,b) for(int i=a;i<=b;i++) using namespace std; const int N=200005; int t, n, m; struct node { int at, w, id; } x[N]; bool cmp(node a, node b) {return a.w<b.w;} bool cmp2(node a, node b) {return a.at<b.at;} signed main() { cin>>t; while(t--) { cin>>n>>m; For(i,1,m) {cin>>x[i].at>>x[i].w; x[i].id=i;} sort(x+1, x+m+1, cmp); int tot=0; For(i,1,2*n) tot+=x[i].w; sort(x+1, x+2*n+1, cmp2); cout<<tot<<'\n'; for(int i=1,j=2*n;i<=j;i++,j--) cout<<x[i].id<<" "<<x[j].id<<'\n'; puts(""); } return 0; }
db 0 ; species ID placeholder db 70, 20, 50, 40, 20, 50 ; hp atk def spd sat sdf db WATER, FAIRY ; type db 190 ; catch rate db 88 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 20 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/marill/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_FAST ; growth rate dn EGG_WATER_1, EGG_FAIRY ; egg groups ; tm/hm learnset tmhm DYNAMICPUNCH, HEADBUTT, CURSE, ROLLOUT, TOXIC, HIDDEN_POWER, SNORE, BLIZZARD, ICY_WIND, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, IRON_TAIL, RETURN, MUD_SLAP, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, SWIFT, DEFENSE_CURL, REST, ATTRACT, SURF, WHIRLPOOL, WATERFALL, ICE_BEAM ; end
GLOBAL enterCritRegion GLOBAL leaveCritRegion enterCritRegion: mov al,1 XCHG al,[rdi] CMP al,0 JNE enterCritRegion RET leaveCritRegion: mov [rdi], BYTE 0 RET
; A171089: a(n) = 2*(Lucas(n)^2 - (-1)^n)). ; 6,4,16,34,96,244,646,1684,4416,11554,30256,79204,207366,542884,1421296,3720994,9741696,25504084,66770566,174807604,457652256,1198149154,3136795216,8212236484,21499914246,56287506244,147362604496,385800307234,1010038317216,2644314644404,6922905616006,18124402203604,47450300994816,124226500780834,325229201347696,851461103262244,2229154108439046,5836001222054884 mov $2,$0 cal $0,240926 ; a(n) = 2 + L(2*n) = 2 + A005248(n), n >= 0, with the Lucas numbers (A000032). mov $1,$0 gcd $2,2 mul $2,2 add $1,$2 sub $1,7 mul $1,2 add $1,4
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All right reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Mike Taylor, Radu Serban // ============================================================================= // // Test for the revolute joint // // ============================================================================= #include <ostream> #include <fstream> #include "chrono/physics/ChSystemNSC.h" #include "chrono/physics/ChBody.h" #include "chrono/utils/ChUtilsInputOutput.h" #include "chrono/utils/ChUtilsValidation.h" #include "chrono_thirdparty/filesystem/path.h" using namespace chrono; // ============================================================================= // Local variables // static const std::string val_dir = "../RESULTS/"; static const std::string out_dir = val_dir + "revolute_joint/"; static const std::string ref_dir = "testing/joints/revolute_joint/"; // ============================================================================= // Prototypes of local functions // bool TestRevolute(const ChVector<>& jointLoc, const ChQuaternion<>& jointRot, double simTimeStep, double outTimeStep, const std::string& testName); bool ValidateReference(const std::string& testName, const std::string& what, double tolerance); bool ValidateConstraints(const std::string& testName, double tolerance); bool ValidateEnergy(const std::string& testName, double tolerance); utils::CSV_writer OutStream(); // ============================================================================= // // Main driver function for running the simulation and validating the results. // int main(int argc, char* argv[]) { std::cout << "BEGIN test_revolute argc=" << argc << std::endl; for (int i = 0; i < argc; i++) std::cout << " argv=" << argv[i] << std::endl; // Create output directory (if it does not already exist) if (!filesystem::create_directory(filesystem::path(val_dir))) { std::cout << "Error creating directory " << val_dir << std::endl; return 1; } if (!filesystem::create_directory(filesystem::path(out_dir))) { std::cout << "Error creating directory " << out_dir << std::endl; return 1; } std::cout << "OUTPUT directory: " << out_dir << std::endl; // Set the simulation and output step sizes double sim_step = 5e-4; double out_step = 1e-2; std::string test_name; bool test_passed = true; // Case 1 - Joint at the origin and aligned with the global Y axis. // Since the axis of rotation of a revolute joint is the Z-axis, the joint // must be rotated -pi/2 about the global X-axis. test_name = "Revolute_Case01"; TestRevolute(ChVector<>(0, 0, 0), Q_from_AngX(-CH_C_PI_2), sim_step, out_step, test_name); test_passed &= ValidateReference(test_name, "Pos", 1e-3); test_passed &= ValidateReference(test_name, "Vel", 1e-4); test_passed &= ValidateReference(test_name, "Acc", 2e-2); test_passed &= ValidateReference(test_name, "Quat", 1e-3); test_passed &= ValidateReference(test_name, "Avel", 1e-2); test_passed &= ValidateReference(test_name, "Aacc", 1e-2); test_passed &= ValidateReference(test_name, "Rforce", 2e-2); test_passed &= ValidateReference(test_name, "Rtorque", 1e-2); test_passed &= ValidateEnergy(test_name, 1e-2); test_passed &= ValidateConstraints(test_name, 1e-5); // Case 2 - Joint at (1,2,3) and aligned with the global axis along Y = Z. // In this case, the joint must be rotated -pi/4 about the global X-axis. test_name = "Revolute_Case02"; TestRevolute(ChVector<>(1, 2, 3), Q_from_AngX(-CH_C_PI_4), sim_step, out_step, test_name); test_passed &= ValidateReference(test_name, "Pos", 1e-3); test_passed &= ValidateReference(test_name, "Vel", 1e-4); test_passed &= ValidateReference(test_name, "Acc", 1e-2); test_passed &= ValidateReference(test_name, "Quat", 1e-3); test_passed &= ValidateReference(test_name, "Avel", 1e-5); test_passed &= ValidateReference(test_name, "Aacc", 1e-2); test_passed &= ValidateReference(test_name, "Rforce", 1e-2); test_passed &= ValidateReference(test_name, "Rtorque", 1e-2); test_passed &= ValidateEnergy(test_name, 1e-2); test_passed &= ValidateConstraints(test_name, 1e-5); // Return 0 if all tests passed and 1 otherwise std::cout << std::endl << "UNIT TEST: " << (test_passed ? "PASSED" : "FAILED") << std::endl; return !test_passed; } // ============================================================================= // // Worker function for performing the simulation with specified parameters. // bool TestRevolute(const ChVector<>& jointLoc, // absolute location of joint const ChQuaternion<>& jointRot, // orientation of joint double simTimeStep, // simulation time step double outTimeStep, // output time step const std::string& testName) // if true, also save animation data { std::cout << "TEST: " << testName << std::endl; // Settings //--------- // There are no units in Chrono, so values must be consistent // (MKS is used in this example) double mass = 1.0; // mass of pendulum double length = 4.0; // length of pendulum ChVector<> inertiaXX(0.04, 0.1, 0.1); // mass moments of inertia of pendulum (centroidal frame) double g = 9.80665; double timeRecord = 5; // simulation length // Create the mechanical system // ---------------------------- // Create a ChronoENGINE physical system: all bodies and constraints will be // handled by this ChSystem object. std::cout << " Create system..." << std::endl; ChSystemNSC my_system; my_system.Set_G_acc(ChVector<>(0.0, 0.0, -g)); my_system.SetTimestepperType(ChTimestepper::Type::EULER_IMPLICIT_LINEARIZED); my_system.SetSolverType(ChSolver::Type::PSOR); my_system.SetSolverMaxIterations(100); my_system.SetSolverForceTolerance(1e-4); // Create the ground body std::cout << " Create bodies..." << std::endl; auto ground = chrono_types::make_shared<ChBody>(); my_system.AddBody(ground); ground->SetBodyFixed(true); // Create the pendulum body in an initial configuration at rest, with an // orientation that matches the specified joint orientation and a position // consistent with the specified joint location. // The pendulum CG is assumed to be at half its length. auto pendulum = chrono_types::make_shared<ChBody>(); my_system.AddBody(pendulum); pendulum->SetPos(jointLoc + jointRot.Rotate(ChVector<>(length / 2, 0, 0))); pendulum->SetRot(jointRot); pendulum->SetMass(mass); pendulum->SetInertiaXX(inertiaXX); // Create revolute joint between pendulum and ground at "loc" in the global // reference frame. The revolute joint's axis of rotation will be the Z axis // of the specified rotation matrix. std::cout << " Create joint..." << std::endl; auto revoluteJoint = chrono_types::make_shared<ChLinkLockRevolute>(); revoluteJoint->Initialize(pendulum, ground, ChCoordsys<>(jointLoc, jointRot)); ////ChSharedPtr<ChLinkRevolute> revoluteJoint(new ChLinkRevolute); ////revoluteJoint->Initialize(pendulum, ground, ChFrame<>(jointLoc, jointRot)); my_system.AddLink(revoluteJoint); // Perform the simulation (record results option) // ------------------------------------------------ std::cout << " Create output streams..." << std::endl; // Create the CSV_Writer output objects (TAB delimited) utils::CSV_writer out_pos = OutStream(); utils::CSV_writer out_vel = OutStream(); utils::CSV_writer out_acc = OutStream(); utils::CSV_writer out_quat = OutStream(); utils::CSV_writer out_avel = OutStream(); utils::CSV_writer out_aacc = OutStream(); utils::CSV_writer out_rfrc = OutStream(); utils::CSV_writer out_rtrq = OutStream(); utils::CSV_writer out_energy = OutStream(); utils::CSV_writer out_cnstr = OutStream(); // Write headers out_pos << "Time" << "X_Pos" << "Y_Pos" << "Z_Pos" << std::endl; out_vel << "Time" << "X_Vel" << "Y_Vel" << "Z_Vel" << std::endl; out_acc << "Time" << "X_Acc" << "Y_Acc" << "Z_Acc" << std::endl; out_quat << "Time" << "e0" << "e1" << "e2" << "e3" << std::endl; out_avel << "Time" << "X_AngVel" << "Y_AngVel" << "Z_AngVel" << std::endl; out_aacc << "Time" << "X_AngAcc" << "Y_AngAcc" << "Z_AngAcc" << std::endl; out_rfrc << "Time" << "X_Force" << "Y_Force" << "Z_Force" << std::endl; out_rtrq << "Time" << "X_Torque" << "Y_Torque" << "Z_Torque" << std::endl; out_energy << "Time" << "Transl_KE" << "Rot_KE" << "Delta_PE" << "KE+PE" << std::endl; out_cnstr << "Time" << "Cnstr_1" << "Cnstr_2" << "Cnstr_3" << "Constraint_4" << "Cnstr_5" << std::endl; // Perform a system assembly to ensure we have the correct accelerations at // the initial time. std::cout << " Perform system assembly..." << std::endl; my_system.DoFullAssembly(); // Total energy at initial time. ChMatrix33<> inertia = pendulum->GetInertia(); ChVector<> angVelLoc = pendulum->GetWvel_loc(); double transKE = 0.5 * mass * pendulum->GetPos_dt().Length2(); double rotKE = 0.5 * Vdot(angVelLoc, inertia * angVelLoc); double deltaPE = mass * g * (pendulum->GetPos().z() - jointLoc.z()); double totalE0 = transKE + rotKE + deltaPE; // Simulation loop double simTime = 0; double outTime = 0; std::cout << " Start simulation loop... timeRecord=" << timeRecord << std::endl; while (simTime <= timeRecord + simTimeStep / 2) { // Ensure that the final data point is recorded. if (simTime >= outTime - simTimeStep / 2) { std::cout << " record output at simTime=" << simTime << std::endl; // CM position, velocity, and acceleration (expressed in global frame). const ChVector<>& position = pendulum->GetPos(); const ChVector<>& velocity = pendulum->GetPos_dt(); out_pos << simTime << position << std::endl; out_vel << simTime << velocity << std::endl; out_acc << simTime << pendulum->GetPos_dtdt() << std::endl; // Orientation, angular velocity, and angular acceleration (expressed in // global frame). out_quat << simTime << pendulum->GetRot() << std::endl; out_avel << simTime << pendulum->GetWvel_par() << std::endl; out_aacc << simTime << pendulum->GetWacc_par() << std::endl; // Reaction Force and Torque: acting on the ground body, as applied at the // joint location and expressed in the global frame. // Chrono returns the reaction force and torque on body 2 (as specified in // the joint Initialize() function), as applied at the joint location and // expressed in the joint frame. Here, the 2nd body is the ground. // joint frame on 2nd body (ground), expressed in the body frame ChCoordsys<> linkCoordsys = revoluteJoint->GetLinkRelativeCoords(); // reaction force and torque on ground, expressed in joint frame ChVector<> reactForce = revoluteJoint->Get_react_force(); ChVector<> reactTorque = revoluteJoint->Get_react_torque(); // reaction force and torque on ground, expressed in ground frame reactForce = linkCoordsys.TransformDirectionLocalToParent(reactForce); reactTorque = linkCoordsys.TransformDirectionLocalToParent(reactTorque); // since the ground body frame coincides with the global (absolute) // frame, the above quantities also represent the reaction force and // torque on ground, expressed in the global frame out_rfrc << simTime << reactForce << std::endl; out_rtrq << simTime << reactTorque << std::endl; // Conservation of Energy // Translational Kinetic Energy (1/2*m*||v||^2) // Rotational Kinetic Energy (1/2 w'*I*w) // Delta Potential Energy (m*g*dz) angVelLoc = pendulum->GetWvel_loc(); transKE = 0.5 * mass * velocity.Length2(); rotKE = 0.5 * Vdot(angVelLoc, inertia * angVelLoc); deltaPE = mass * g * (position.z() - jointLoc.z()); double totalE = transKE + rotKE + deltaPE; out_energy << simTime << transKE << rotKE << deltaPE << totalE - totalE0 << std::endl; // Constraint violations ChVectorDynamic<> C = revoluteJoint->GetConstraintViolation(); out_cnstr << simTime << C(0) << C(1) << C(2) << C(3) << C(4) << std::endl; // Increment output time outTime += outTimeStep; } // Advance simulation by one step my_system.DoStepDynamics(simTimeStep); // Increment simulation time simTime += simTimeStep; } // Write output files std::cout << " Write output files..." << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Pos.txt" << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Vel.txt" << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Acc.txt" << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Quat.txt" << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Avel.txt" << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Aacc.txt" << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Rforce.txt" << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Rtorque.txt" << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Energy.txt" << std::endl; std::cout << " file=" << out_dir + testName + "_CHRONO_Constraints.txt" << std::endl; out_pos.write_to_file(out_dir + testName + "_CHRONO_Pos.txt", testName + "\n\n"); out_vel.write_to_file(out_dir + testName + "_CHRONO_Vel.txt", testName + "\n\n"); out_acc.write_to_file(out_dir + testName + "_CHRONO_Acc.txt", testName + "\n\n"); out_quat.write_to_file(out_dir + testName + "_CHRONO_Quat.txt", testName + "\n\n"); out_avel.write_to_file(out_dir + testName + "_CHRONO_Avel.txt", testName + "\n\n"); out_aacc.write_to_file(out_dir + testName + "_CHRONO_Aacc.txt", testName + "\n\n"); out_rfrc.write_to_file(out_dir + testName + "_CHRONO_Rforce.txt", testName + "\n\n"); out_rtrq.write_to_file(out_dir + testName + "_CHRONO_Rtorque.txt", testName + "\n\n"); out_energy.write_to_file(out_dir + testName + "_CHRONO_Energy.txt", testName + "\n\n"); out_cnstr.write_to_file(out_dir + testName + "_CHRONO_Constraints.txt", testName + "\n\n"); return true; } // ============================================================================= // // Wrapper function for comparing the specified simulation quantities against a // reference file. // bool ValidateReference(const std::string& testName, // name of this test const std::string& what, // identifier for test quantity double tolerance) // validation tolerance { std::string sim_file = out_dir + testName + "_CHRONO_" + what + ".txt"; std::string ref_file = ref_dir + testName + "_ADAMS_" + what + ".txt"; utils::DataVector norms; std::cout << " START validation simulation" << std::endl; std::cout << " sim_file=" << sim_file << std::endl; std::cout << " ref_file=" << ref_file << std::endl; std::cout << " ref_file_full=" << utils::GetValidationDataFile(ref_file) << std::endl; bool check = utils::Validate(sim_file, utils::GetValidationDataFile(ref_file), utils::RMS_NORM, tolerance, norms); std::cout << " validate " << what << (check ? ": Passed" : ": Failed") << " [ "; for (size_t col = 0; col < norms.size(); col++) std::cout << norms[col] << " "; std::cout << " ]" << std::endl; return check; } // Wrapper function for checking constraint violations. // bool ValidateConstraints(const std::string& testName, // name of this test double tolerance) // validation tolerance { std::string sim_file = out_dir + testName + "_CHRONO_Constraints.txt"; utils::DataVector norms; std::cout << " START validation constraints" << std::endl; std::cout << " sim_file=" << sim_file << std::endl; bool check = utils::Validate(sim_file, utils::RMS_NORM, tolerance, norms); std::cout << " validate Constraints" << (check ? ": Passed" : ": Failed") << " [ "; for (size_t col = 0; col < norms.size(); col++) std::cout << norms[col] << " "; std::cout << " ]" << std::endl; return check; } // wrapper function for checking energy conservation. // bool ValidateEnergy(const std::string& testName, // name of this test double tolerance) // validation tolerance { std::string sim_file = out_dir + testName + "_CHRONO_Energy.txt"; utils::DataVector norms; std::cout << " START validation energy" << std::endl; std::cout << " sim_file=" << sim_file << std::endl; utils::Validate(sim_file, utils::RMS_NORM, tolerance, norms); bool check = norms[norms.size() - 1] <= tolerance; std::cout << " validate Energy" << (check ? ": Passed" : ": Failed") << " [ " << norms[norms.size() - 1] << " ]" << std::endl; return check; } // ============================================================================= // // Utility function to create a CSV output stream and set output format options. // utils::CSV_writer OutStream() { utils::CSV_writer out("\t"); out.stream().setf(std::ios::scientific | std::ios::showpos); out.stream().precision(6); return out; }
; $Id: CPUMRCA.asm $ ;; @file ; CPUM - Raw-mode Context Assembly Routines. ; ; ; Copyright (C) 2006-2017 Oracle Corporation ; ; This file is part of VirtualBox Open Source Edition (OSE), as ; available from http://www.virtualbox.org. This file is free software; ; you can redistribute it and/or modify it under the terms of the GNU ; General Public License (GPL) as published by the Free Software ; Foundation, in version 2 as it comes in the "COPYING" file of the ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ; ;******************************************************************************* ;* Header Files * ;******************************************************************************* %include "VMMRC.mac" %include "VBox/vmm/vm.mac" %include "VBox/err.mac" %include "VBox/vmm/stam.mac" %include "CPUMInternal.mac" %include "iprt/x86.mac" %include "VBox/vmm/cpum.mac" ;******************************************************************************* ;* External Symbols * ;******************************************************************************* extern IMPNAME(g_CPUM) ; VMM GC Builtin import extern IMPNAME(g_VM) ; VMM GC Builtin import extern NAME(cpumRCHandleNPAndGP) ; CPUMGC.cpp extern NAME(CPUMRCAssertPreExecutionSanity) ; ; Enables write protection of Hypervisor memory pages. ; !note! Must be commented out for Trap8 debug handler. ; %define ENABLE_WRITE_PROTECTION 1 BEGINCODE ;; ; Handles lazy FPU saving and restoring. ; ; This handler will implement lazy fpu (sse/mmx/stuff) saving. ; Two actions may be taken in this handler since the Guest OS may ; be doing lazy fpu switching. So, we'll have to generate those ; traps which the Guest CPU CTX shall have according to the ; its CR0 flags. If no traps for the Guest OS, we'll save the host ; context and restore the guest context. ; ; @returns 0 if caller should continue execution. ; @returns VINF_EM_RAW_GUEST_TRAP if a guest trap should be generated. ; @param pCpumCpu [ebp+8] Pointer to the CPUMCPU. ; align 16 BEGINPROC cpumHandleLazyFPUAsm push ebp mov ebp, esp push ebx push esi mov ebx, [ebp + 8] %define pCpumCpu ebx %define pXState esi ; ; Figure out what to do. ; ; There are two basic actions: ; 1. Save host fpu and restore guest fpu. ; 2. Generate guest trap. ; ; When entering the hypervisor we'll always enable MP (for proper wait ; trapping) and TS (for intercepting all fpu/mmx/sse stuff). The EM flag ; is taken from the guest OS in order to get proper SSE handling. ; ; ; Actions taken depending on the guest CR0 flags: ; ; 3 2 1 ; TS | EM | MP | FPUInstr | WAIT :: VMM Action ; ------------------------------------------------------------------------ ; 0 | 0 | 0 | Exec | Exec :: Clear TS & MP, Save HC, Load GC. ; 0 | 0 | 1 | Exec | Exec :: Clear TS, Save HC, Load GC. ; 0 | 1 | 0 | #NM | Exec :: Clear TS & MP, Save HC, Load GC; ; 0 | 1 | 1 | #NM | Exec :: Clear TS, Save HC, Load GC. ; 1 | 0 | 0 | #NM | Exec :: Clear MP, Save HC, Load GC. (EM is already cleared.) ; 1 | 0 | 1 | #NM | #NM :: Go to host taking trap there. ; 1 | 1 | 0 | #NM | Exec :: Clear MP, Save HC, Load GC. (EM is already set.) ; 1 | 1 | 1 | #NM | #NM :: Go to host taking trap there. ; ; Before taking any of these actions we're checking if we have already ; loaded the GC FPU. Because if we have, this is an trap for the guest - raw ring-3. ; test dword [pCpumCpu + CPUMCPU.fUseFlags], CPUM_USED_FPU_GUEST jz hlfpua_not_loaded jmp hlfpua_guest_trap ; ; Take action. ; align 16 hlfpua_not_loaded: mov eax, [pCpumCpu + CPUMCPU.Guest.cr0] and eax, X86_CR0_MP | X86_CR0_EM | X86_CR0_TS jmp dword [eax*2 + hlfpuajmp1] align 16 ;; jump table using fpu related cr0 flags as index. hlfpuajmp1: RTCCPTR_DEF hlfpua_switch_fpu_ctx RTCCPTR_DEF hlfpua_switch_fpu_ctx RTCCPTR_DEF hlfpua_switch_fpu_ctx RTCCPTR_DEF hlfpua_switch_fpu_ctx RTCCPTR_DEF hlfpua_switch_fpu_ctx RTCCPTR_DEF hlfpua_guest_trap RTCCPTR_DEF hlfpua_switch_fpu_ctx RTCCPTR_DEF hlfpua_guest_trap ;; and mask for cr0. hlfpu_afFlags: RTCCPTR_DEF ~(X86_CR0_TS | X86_CR0_MP) RTCCPTR_DEF ~(X86_CR0_TS) RTCCPTR_DEF ~(X86_CR0_TS | X86_CR0_MP) RTCCPTR_DEF ~(X86_CR0_TS) RTCCPTR_DEF ~(X86_CR0_MP) RTCCPTR_DEF 0 RTCCPTR_DEF ~(X86_CR0_MP) RTCCPTR_DEF 0 ; ; Action - switch FPU context and change cr0 flags. ; align 16 hlfpua_switch_fpu_ctx: mov ecx, cr0 mov edx, ecx and ecx, [eax*2 + hlfpu_afFlags] ; Calc the new cr0 flags. Do NOT use ECX until we restore it! and edx, ~(X86_CR0_TS | X86_CR0_EM) mov cr0, edx ; Clear flags so we don't trap here. test dword [pCpumCpu + CPUMCPU.fUseFlags], CPUM_USED_FPU_HOST jnz hlfpua_host_done mov eax, [pCpumCpu + CPUMCPU.Host.fXStateMask] mov pXState, [pCpumCpu + CPUMCPU.Host.pXStateRC] or eax, eax jz hlfpua_host_fxsave mov edx, [pCpumCpu + CPUMCPU.Host.fXStateMask + 4] xsave [pXState] jmp hlfpua_host_done hlfpua_host_fxsave: fxsave [pXState] hlfpua_host_done: mov eax, [pCpumCpu + CPUMCPU.Guest.fXStateMask] mov pXState, [pCpumCpu + CPUMCPU.Guest.pXStateRC] or eax, eax jz hlfpua_guest_fxrstor mov edx, [pCpumCpu + CPUMCPU.Guest.fXStateMask + 4] xrstor [pXState] jmp hlfpua_guest_done hlfpua_guest_fxrstor: fxrstor [pXState] hlfpua_guest_done: hlfpua_finished_switch: or dword [pCpumCpu + CPUMCPU.fUseFlags], (CPUM_USED_FPU_HOST | CPUM_USED_FPU_GUEST | CPUM_USED_FPU_SINCE_REM) ; Load new CR0 value. mov cr0, ecx ; load the new cr0 flags. ; return continue execution. pop esi pop ebx xor eax, eax leave ret ; ; Action - Generate Guest trap. ; hlfpua_action_4: hlfpua_guest_trap: pop esi pop ebx mov eax, VINF_EM_RAW_GUEST_TRAP leave ret ENDPROC cpumHandleLazyFPUAsm ;; ; Calls a guest trap/interrupt handler directly ; Assumes a trap stack frame has already been setup on the guest's stack! ; ; @param pRegFrame [esp + 4] Original trap/interrupt context ; @param selCS [esp + 8] Code selector of handler ; @param pHandler [esp + 12] GC virtual address of handler ; @param eflags [esp + 16] Callee's EFLAGS ; @param selSS [esp + 20] Stack selector for handler ; @param pEsp [esp + 24] Stack address for handler ; ; @remark This call never returns! ; ; VMMRCDECL(void) CPUMGCCallGuestTrapHandler(PCPUMCTXCORE pRegFrame, uint32_t selCS, RTGCPTR pHandler, uint32_t eflags, uint32_t selSS, RTGCPTR pEsp); align 16 BEGINPROC_EXPORTED CPUMGCCallGuestTrapHandler mov ebp, esp ; construct iret stack frame push dword [ebp + 20] ; SS push dword [ebp + 24] ; ESP push dword [ebp + 16] ; EFLAGS push dword [ebp + 8] ; CS push dword [ebp + 12] ; EIP ; ; enable WP ; %ifdef ENABLE_WRITE_PROTECTION mov eax, cr0 or eax, X86_CR0_WRITE_PROTECT mov cr0, eax %endif ; restore CPU context (all except cs, eip, ss, esp & eflags; which are restored or overwritten by iret) mov ebp, [ebp + 4] ; pRegFrame mov ebx, [ebp + CPUMCTXCORE.ebx] mov ecx, [ebp + CPUMCTXCORE.ecx] mov edx, [ebp + CPUMCTXCORE.edx] mov esi, [ebp + CPUMCTXCORE.esi] mov edi, [ebp + CPUMCTXCORE.edi] ;; @todo load segment registers *before* enabling WP. TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_GS | CPUM_HANDLER_CTXCORE_IN_EBP mov gs, [ebp + CPUMCTXCORE.gs.Sel] TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_FS | CPUM_HANDLER_CTXCORE_IN_EBP mov fs, [ebp + CPUMCTXCORE.fs.Sel] TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_ES | CPUM_HANDLER_CTXCORE_IN_EBP mov es, [ebp + CPUMCTXCORE.es.Sel] TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_DS | CPUM_HANDLER_CTXCORE_IN_EBP mov ds, [ebp + CPUMCTXCORE.ds.Sel] mov eax, [ebp + CPUMCTXCORE.eax] mov ebp, [ebp + CPUMCTXCORE.ebp] TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_IRET iret ENDPROC CPUMGCCallGuestTrapHandler ;; ; Performs an iret to V86 code ; Assumes a trap stack frame has already been setup on the guest's stack! ; ; @param pRegFrame Original trap/interrupt context ; ; This function does not return! ; ;VMMRCDECL(void) CPUMGCCallV86Code(PCPUMCTXCORE pRegFrame); align 16 BEGINPROC CPUMGCCallV86Code push ebp mov ebp, esp mov ebx, [ebp + 8] ; pRegFrame ; Construct iret stack frame. push dword [ebx + CPUMCTXCORE.gs.Sel] push dword [ebx + CPUMCTXCORE.fs.Sel] push dword [ebx + CPUMCTXCORE.ds.Sel] push dword [ebx + CPUMCTXCORE.es.Sel] push dword [ebx + CPUMCTXCORE.ss.Sel] push dword [ebx + CPUMCTXCORE.esp] push dword [ebx + CPUMCTXCORE.eflags] push dword [ebx + CPUMCTXCORE.cs.Sel] push dword [ebx + CPUMCTXCORE.eip] ; Invalidate all segment registers. mov al, ~CPUMSELREG_FLAGS_VALID and [ebx + CPUMCTXCORE.fs.fFlags], al and [ebx + CPUMCTXCORE.ds.fFlags], al and [ebx + CPUMCTXCORE.es.fFlags], al and [ebx + CPUMCTXCORE.ss.fFlags], al and [ebx + CPUMCTXCORE.gs.fFlags], al and [ebx + CPUMCTXCORE.cs.fFlags], al ; ; enable WP ; %ifdef ENABLE_WRITE_PROTECTION mov eax, cr0 or eax, X86_CR0_WRITE_PROTECT mov cr0, eax %endif ; restore CPU context (all except cs, eip, ss, esp, eflags, ds, es, fs & gs; which are restored or overwritten by iret) mov eax, [ebx + CPUMCTXCORE.eax] mov ecx, [ebx + CPUMCTXCORE.ecx] mov edx, [ebx + CPUMCTXCORE.edx] mov esi, [ebx + CPUMCTXCORE.esi] mov edi, [ebx + CPUMCTXCORE.edi] mov ebp, [ebx + CPUMCTXCORE.ebp] mov ebx, [ebx + CPUMCTXCORE.ebx] TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_IRET iret ENDPROC CPUMGCCallV86Code ;; ; This is a main entry point for resuming (or starting) guest ; code execution. ; ; We get here directly from VMMSwitcher.asm (jmp at the end ; of VMMSwitcher_HostToGuest). ; ; This call never returns! ; ; @param edx Pointer to CPUMCPU structure. ; align 16 BEGINPROC_EXPORTED CPUMGCResumeGuest %ifdef VBOX_STRICT ; Call CPUM to check sanity. push edx mov edx, IMP(g_VM) push edx call NAME(CPUMRCAssertPreExecutionSanity) add esp, 4 pop edx %endif ; ; Setup iretd ; push dword [edx + CPUMCPU.Guest.ss.Sel] push dword [edx + CPUMCPU.Guest.esp] push dword [edx + CPUMCPU.Guest.eflags] push dword [edx + CPUMCPU.Guest.cs.Sel] push dword [edx + CPUMCPU.Guest.eip] ; ; Restore registers. ; TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_ES mov es, [edx + CPUMCPU.Guest.es.Sel] TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_FS mov fs, [edx + CPUMCPU.Guest.fs.Sel] TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_GS mov gs, [edx + CPUMCPU.Guest.gs.Sel] %ifdef VBOX_WITH_STATISTICS ; ; Statistics. ; push edx mov edx, IMP(g_VM) lea edx, [edx + VM.StatTotalQemuToGC] STAM_PROFILE_ADV_STOP edx mov edx, IMP(g_VM) lea edx, [edx + VM.StatTotalInGC] STAM_PROFILE_ADV_START edx pop edx %endif ; ; enable WP ; %ifdef ENABLE_WRITE_PROTECTION mov eax, cr0 or eax, X86_CR0_WRITE_PROTECT mov cr0, eax %endif ; ; Continue restore. ; mov esi, [edx + CPUMCPU.Guest.esi] mov edi, [edx + CPUMCPU.Guest.edi] mov ebp, [edx + CPUMCPU.Guest.ebp] mov ebx, [edx + CPUMCPU.Guest.ebx] mov ecx, [edx + CPUMCPU.Guest.ecx] mov eax, [edx + CPUMCPU.Guest.eax] push dword [edx + CPUMCPU.Guest.ds.Sel] mov edx, [edx + CPUMCPU.Guest.edx] TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_DS pop ds ; restart execution. TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_IRET iretd ENDPROC CPUMGCResumeGuest ;; ; This is a main entry point for resuming (or starting) guest ; code execution for raw V86 mode ; ; We get here directly from VMMSwitcher.asm (jmp at the end ; of VMMSwitcher_HostToGuest). ; ; This call never returns! ; ; @param edx Pointer to CPUMCPU structure. ; align 16 BEGINPROC_EXPORTED CPUMGCResumeGuestV86 %ifdef VBOX_STRICT ; Call CPUM to check sanity. push edx mov edx, IMP(g_VM) push edx call NAME(CPUMRCAssertPreExecutionSanity) add esp, 4 pop edx %endif ; ; Setup iretd ; push dword [edx + CPUMCPU.Guest.gs.Sel] push dword [edx + CPUMCPU.Guest.fs.Sel] push dword [edx + CPUMCPU.Guest.ds.Sel] push dword [edx + CPUMCPU.Guest.es.Sel] push dword [edx + CPUMCPU.Guest.ss.Sel] push dword [edx + CPUMCPU.Guest.esp] push dword [edx + CPUMCPU.Guest.eflags] push dword [edx + CPUMCPU.Guest.cs.Sel] push dword [edx + CPUMCPU.Guest.eip] ; ; Restore registers. ; %ifdef VBOX_WITH_STATISTICS ; ; Statistics. ; push edx mov edx, IMP(g_VM) lea edx, [edx + VM.StatTotalQemuToGC] STAM_PROFILE_ADV_STOP edx mov edx, IMP(g_VM) lea edx, [edx + VM.StatTotalInGC] STAM_PROFILE_ADV_START edx pop edx %endif ; ; enable WP ; %ifdef ENABLE_WRITE_PROTECTION mov eax, cr0 or eax, X86_CR0_WRITE_PROTECT mov cr0, eax %endif ; ; Continue restore. ; mov esi, [edx + CPUMCPU.Guest.esi] mov edi, [edx + CPUMCPU.Guest.edi] mov ebp, [edx + CPUMCPU.Guest.ebp] mov ecx, [edx + CPUMCPU.Guest.ecx] mov ebx, [edx + CPUMCPU.Guest.ebx] mov eax, [edx + CPUMCPU.Guest.eax] mov edx, [edx + CPUMCPU.Guest.edx] ; restart execution. TRPM_NP_GP_HANDLER NAME(cpumRCHandleNPAndGP), CPUM_HANDLER_IRET iretd ENDPROC CPUMGCResumeGuestV86
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 6, 0x90 SHA512_YMM_K: .quad 0x428a2f98d728ae22, 0x7137449123ef65cd, 0x428a2f98d728ae22, 0x7137449123ef65cd .quad 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc .quad 0x3956c25bf348b538, 0x59f111f1b605d019, 0x3956c25bf348b538, 0x59f111f1b605d019 .quad 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118 .quad 0xd807aa98a3030242, 0x12835b0145706fbe, 0xd807aa98a3030242, 0x12835b0145706fbe .quad 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2 .quad 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x72be5d74f27b896f, 0x80deb1fe3b1696b1 .quad 0x9bdc06a725c71235, 0xc19bf174cf692694, 0x9bdc06a725c71235, 0xc19bf174cf692694 .quad 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0xe49b69c19ef14ad2, 0xefbe4786384f25e3 .quad 0xfc19dc68b8cd5b5, 0x240ca1cc77ac9c65, 0xfc19dc68b8cd5b5, 0x240ca1cc77ac9c65 .quad 0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x2de92c6f592b0275, 0x4a7484aa6ea6e483 .quad 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5 .quad 0x983e5152ee66dfab, 0xa831c66d2db43210, 0x983e5152ee66dfab, 0xa831c66d2db43210 .quad 0xb00327c898fb213f, 0xbf597fc7beef0ee4, 0xb00327c898fb213f, 0xbf597fc7beef0ee4 .quad 0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0xc6e00bf33da88fc2, 0xd5a79147930aa725 .quad 0x6ca6351e003826f, 0x142929670a0e6e70, 0x6ca6351e003826f, 0x142929670a0e6e70 .quad 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x27b70a8546d22ffc, 0x2e1b21385c26c926 .quad 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df .quad 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x650a73548baf63de, 0x766a0abb3c77b2a8 .quad 0x81c2c92e47edaee6, 0x92722c851482353b, 0x81c2c92e47edaee6, 0x92722c851482353b .quad 0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xa2bfe8a14cf10364, 0xa81a664bbc423001 .quad 0xc24b8b70d0f89791, 0xc76c51a30654be30, 0xc24b8b70d0f89791, 0xc76c51a30654be30 .quad 0xd192e819d6ef5218, 0xd69906245565a910, 0xd192e819d6ef5218, 0xd69906245565a910 .quad 0xf40e35855771202a, 0x106aa07032bbd1b8, 0xf40e35855771202a, 0x106aa07032bbd1b8 .quad 0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x19a4c116b8d2d0c8, 0x1e376c085141ab53 .quad 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8 .quad 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb .quad 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3 .quad 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x748f82ee5defb2fc, 0x78a5636f43172f60 .quad 0x84c87814a1f0ab72, 0x8cc702081a6439ec, 0x84c87814a1f0ab72, 0x8cc702081a6439ec .quad 0x90befffa23631e28, 0xa4506cebde82bde9, 0x90befffa23631e28, 0xa4506cebde82bde9 .quad 0xbef9a3f7b2c67915, 0xc67178f2e372532b, 0xbef9a3f7b2c67915, 0xc67178f2e372532b .quad 0xca273eceea26619c, 0xd186b8c721c0c207, 0xca273eceea26619c, 0xd186b8c721c0c207 .quad 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178 .quad 0x6f067aa72176fba, 0xa637dc5a2c898a6, 0x6f067aa72176fba, 0xa637dc5a2c898a6 .quad 0x113f9804bef90dae, 0x1b710b35131c471b, 0x113f9804bef90dae, 0x1b710b35131c471b .quad 0x28db77f523047d84, 0x32caab7b40c72493, 0x28db77f523047d84, 0x32caab7b40c72493 .quad 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c .quad 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a .quad 0x5fcb6fab3ad6faec, 0x6c44198c4a475817, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817 SHA512_YMM_BF: .quad 0x1020304050607, 0x8090a0b0c0d0e0f, 0x1020304050607, 0x8090a0b0c0d0e0f .p2align 6, 0x90 .globl UpdateSHA512 .type UpdateSHA512, @function UpdateSHA512: push %rbx push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 sub $(1312), %rsp mov %rsp, %r15 and $(-64), %rsp movslq %edx, %r14 movq %rdi, (8)(%rsp) movq %r14, (16)(%rsp) movq %r15, (24)(%rsp) lea (32)(%rsp), %rsp vmovdqa SHA512_YMM_BF(%rip), %ymm12 movq (%rdi), %rax movq (8)(%rdi), %rbx movq (16)(%rdi), %rcx movq (24)(%rdi), %rdx movq (32)(%rdi), %r8 movq (40)(%rdi), %r9 movq (48)(%rdi), %r10 movq (56)(%rdi), %r11 .p2align 6, 0x90 .Lsha512_block2_loopgas_1: lea (128)(%rsi), %r12 cmp $(128), %r14 cmovbe %rsi, %r12 lea SHA512_YMM_K(%rip), %rbp vmovdqu (%rsi), %xmm0 vmovdqu (16)(%rsi), %xmm1 vmovdqu (32)(%rsi), %xmm2 vmovdqu (48)(%rsi), %xmm3 vmovdqu (64)(%rsi), %xmm4 vmovdqu (80)(%rsi), %xmm5 vmovdqu (96)(%rsi), %xmm6 vmovdqu (112)(%rsi), %xmm7 vinserti128 $(1), (%r12), %ymm0, %ymm0 vinserti128 $(1), (16)(%r12), %ymm1, %ymm1 vinserti128 $(1), (32)(%r12), %ymm2, %ymm2 vinserti128 $(1), (48)(%r12), %ymm3, %ymm3 vinserti128 $(1), (64)(%r12), %ymm4, %ymm4 vinserti128 $(1), (80)(%r12), %ymm5, %ymm5 vinserti128 $(1), (96)(%r12), %ymm6, %ymm6 vinserti128 $(1), (112)(%r12), %ymm7, %ymm7 vpshufb %ymm12, %ymm0, %ymm0 vpshufb %ymm12, %ymm1, %ymm1 vpshufb %ymm12, %ymm2, %ymm2 vpshufb %ymm12, %ymm3, %ymm3 vpshufb %ymm12, %ymm4, %ymm4 vpshufb %ymm12, %ymm5, %ymm5 vpshufb %ymm12, %ymm6, %ymm6 vpshufb %ymm12, %ymm7, %ymm7 vpaddq (%rbp), %ymm0, %ymm8 vmovdqa %ymm8, (%rsp) vpaddq (32)(%rbp), %ymm1, %ymm9 vmovdqa %ymm9, (32)(%rsp) vpaddq (64)(%rbp), %ymm2, %ymm10 vmovdqa %ymm10, (64)(%rsp) vpaddq (96)(%rbp), %ymm3, %ymm11 vmovdqa %ymm11, (96)(%rsp) vpaddq (128)(%rbp), %ymm4, %ymm8 vmovdqa %ymm8, (128)(%rsp) vpaddq (160)(%rbp), %ymm5, %ymm9 vmovdqa %ymm9, (160)(%rsp) vpaddq (192)(%rbp), %ymm6, %ymm10 vmovdqa %ymm10, (192)(%rsp) vpaddq (224)(%rbp), %ymm7, %ymm11 vmovdqa %ymm11, (224)(%rsp) add $(256), %rbp mov %rbx, %rdi xor %r14, %r14 mov %r9, %r12 xor %rcx, %rdi .p2align 6, 0x90 .Lblock1_shed_procgas_1: vpalignr $(8), %ymm0, %ymm1, %ymm8 addq (%rsp), %r11 and %r8, %r12 vpalignr $(8), %ymm4, %ymm5, %ymm11 rorx $(41), %r8, %r13 rorx $(18), %r8, %r15 vpsrlq $(1), %ymm8, %ymm10 add %r14, %rax add %r12, %r11 vpaddq %ymm11, %ymm0, %ymm0 andn %r10, %r8, %r12 xor %r15, %r13 vpsrlq $(7), %ymm8, %ymm11 rorx $(14), %r8, %r14 add %r12, %r11 vpsllq $(56), %ymm8, %ymm9 xor %r14, %r13 mov %rax, %r15 vpxor %ymm10, %ymm11, %ymm8 rorx $(39), %rax, %r12 add %r13, %r11 vpsrlq $(7), %ymm10, %ymm10 xor %rbx, %r15 rorx $(34), %rax, %r14 vpxor %ymm9, %ymm8, %ymm8 rorx $(28), %rax, %r13 add %r11, %rdx vpsllq $(7), %ymm9, %ymm9 and %r15, %rdi xor %r12, %r14 vpxor %ymm10, %ymm8, %ymm8 xor %rbx, %rdi xor %r13, %r14 vpsrlq $(6), %ymm7, %ymm11 add %rdi, %r11 mov %r8, %r12 vpxor %ymm9, %ymm8, %ymm8 addq (8)(%rsp), %r10 and %rdx, %r12 vpsllq $(3), %ymm7, %ymm10 rorx $(41), %rdx, %r13 rorx $(18), %rdx, %rdi vpaddq %ymm8, %ymm0, %ymm0 add %r14, %r11 add %r12, %r10 vpsrlq $(19), %ymm7, %ymm9 andn %r9, %rdx, %r12 xor %rdi, %r13 vpxor %ymm10, %ymm11, %ymm11 rorx $(14), %rdx, %r14 add %r12, %r10 vpsllq $(42), %ymm10, %ymm10 xor %r14, %r13 mov %r11, %rdi vpxor %ymm9, %ymm11, %ymm11 rorx $(39), %r11, %r12 add %r13, %r10 vpsrlq $(42), %ymm9, %ymm9 xor %rax, %rdi rorx $(34), %r11, %r14 vpxor %ymm10, %ymm11, %ymm11 rorx $(28), %r11, %r13 add %r10, %rcx vpxor %ymm9, %ymm11, %ymm11 and %rdi, %r15 xor %r12, %r14 vpaddq %ymm11, %ymm0, %ymm0 xor %rax, %r15 xor %r13, %r14 vpaddq (%rbp), %ymm0, %ymm10 add %r15, %r10 mov %rdx, %r12 vmovdqa %ymm10, (256)(%rsp) vpalignr $(8), %ymm1, %ymm2, %ymm8 addq (32)(%rsp), %r9 and %rcx, %r12 vpalignr $(8), %ymm5, %ymm6, %ymm11 rorx $(41), %rcx, %r13 rorx $(18), %rcx, %r15 vpsrlq $(1), %ymm8, %ymm10 add %r14, %r10 add %r12, %r9 vpaddq %ymm11, %ymm1, %ymm1 andn %r8, %rcx, %r12 xor %r15, %r13 vpsrlq $(7), %ymm8, %ymm11 rorx $(14), %rcx, %r14 add %r12, %r9 vpsllq $(56), %ymm8, %ymm9 xor %r14, %r13 mov %r10, %r15 vpxor %ymm10, %ymm11, %ymm8 rorx $(39), %r10, %r12 add %r13, %r9 vpsrlq $(7), %ymm10, %ymm10 xor %r11, %r15 rorx $(34), %r10, %r14 vpxor %ymm9, %ymm8, %ymm8 rorx $(28), %r10, %r13 add %r9, %rbx vpsllq $(7), %ymm9, %ymm9 and %r15, %rdi xor %r12, %r14 vpxor %ymm10, %ymm8, %ymm8 xor %r11, %rdi xor %r13, %r14 vpsrlq $(6), %ymm0, %ymm11 add %rdi, %r9 mov %rcx, %r12 vpxor %ymm9, %ymm8, %ymm8 addq (40)(%rsp), %r8 and %rbx, %r12 vpsllq $(3), %ymm0, %ymm10 rorx $(41), %rbx, %r13 rorx $(18), %rbx, %rdi vpaddq %ymm8, %ymm1, %ymm1 add %r14, %r9 add %r12, %r8 vpsrlq $(19), %ymm0, %ymm9 andn %rdx, %rbx, %r12 xor %rdi, %r13 vpxor %ymm10, %ymm11, %ymm11 rorx $(14), %rbx, %r14 add %r12, %r8 vpsllq $(42), %ymm10, %ymm10 xor %r14, %r13 mov %r9, %rdi vpxor %ymm9, %ymm11, %ymm11 rorx $(39), %r9, %r12 add %r13, %r8 vpsrlq $(42), %ymm9, %ymm9 xor %r10, %rdi rorx $(34), %r9, %r14 vpxor %ymm10, %ymm11, %ymm11 rorx $(28), %r9, %r13 add %r8, %rax vpxor %ymm9, %ymm11, %ymm11 and %rdi, %r15 xor %r12, %r14 vpaddq %ymm11, %ymm1, %ymm1 xor %r10, %r15 xor %r13, %r14 vpaddq (32)(%rbp), %ymm1, %ymm10 add %r15, %r8 mov %rbx, %r12 vmovdqa %ymm10, (288)(%rsp) vpalignr $(8), %ymm2, %ymm3, %ymm8 addq (64)(%rsp), %rdx and %rax, %r12 vpalignr $(8), %ymm6, %ymm7, %ymm11 rorx $(41), %rax, %r13 rorx $(18), %rax, %r15 vpsrlq $(1), %ymm8, %ymm10 add %r14, %r8 add %r12, %rdx vpaddq %ymm11, %ymm2, %ymm2 andn %rcx, %rax, %r12 xor %r15, %r13 vpsrlq $(7), %ymm8, %ymm11 rorx $(14), %rax, %r14 add %r12, %rdx vpsllq $(56), %ymm8, %ymm9 xor %r14, %r13 mov %r8, %r15 vpxor %ymm10, %ymm11, %ymm8 rorx $(39), %r8, %r12 add %r13, %rdx vpsrlq $(7), %ymm10, %ymm10 xor %r9, %r15 rorx $(34), %r8, %r14 vpxor %ymm9, %ymm8, %ymm8 rorx $(28), %r8, %r13 add %rdx, %r11 vpsllq $(7), %ymm9, %ymm9 and %r15, %rdi xor %r12, %r14 vpxor %ymm10, %ymm8, %ymm8 xor %r9, %rdi xor %r13, %r14 vpsrlq $(6), %ymm1, %ymm11 add %rdi, %rdx mov %rax, %r12 vpxor %ymm9, %ymm8, %ymm8 addq (72)(%rsp), %rcx and %r11, %r12 vpsllq $(3), %ymm1, %ymm10 rorx $(41), %r11, %r13 rorx $(18), %r11, %rdi vpaddq %ymm8, %ymm2, %ymm2 add %r14, %rdx add %r12, %rcx vpsrlq $(19), %ymm1, %ymm9 andn %rbx, %r11, %r12 xor %rdi, %r13 vpxor %ymm10, %ymm11, %ymm11 rorx $(14), %r11, %r14 add %r12, %rcx vpsllq $(42), %ymm10, %ymm10 xor %r14, %r13 mov %rdx, %rdi vpxor %ymm9, %ymm11, %ymm11 rorx $(39), %rdx, %r12 add %r13, %rcx vpsrlq $(42), %ymm9, %ymm9 xor %r8, %rdi rorx $(34), %rdx, %r14 vpxor %ymm10, %ymm11, %ymm11 rorx $(28), %rdx, %r13 add %rcx, %r10 vpxor %ymm9, %ymm11, %ymm11 and %rdi, %r15 xor %r12, %r14 vpaddq %ymm11, %ymm2, %ymm2 xor %r8, %r15 xor %r13, %r14 vpaddq (64)(%rbp), %ymm2, %ymm10 add %r15, %rcx mov %r11, %r12 vmovdqa %ymm10, (320)(%rsp) vpalignr $(8), %ymm3, %ymm4, %ymm8 addq (96)(%rsp), %rbx and %r10, %r12 vpalignr $(8), %ymm7, %ymm0, %ymm11 rorx $(41), %r10, %r13 rorx $(18), %r10, %r15 vpsrlq $(1), %ymm8, %ymm10 add %r14, %rcx add %r12, %rbx vpaddq %ymm11, %ymm3, %ymm3 andn %rax, %r10, %r12 xor %r15, %r13 vpsrlq $(7), %ymm8, %ymm11 rorx $(14), %r10, %r14 add %r12, %rbx vpsllq $(56), %ymm8, %ymm9 xor %r14, %r13 mov %rcx, %r15 vpxor %ymm10, %ymm11, %ymm8 rorx $(39), %rcx, %r12 add %r13, %rbx vpsrlq $(7), %ymm10, %ymm10 xor %rdx, %r15 rorx $(34), %rcx, %r14 vpxor %ymm9, %ymm8, %ymm8 rorx $(28), %rcx, %r13 add %rbx, %r9 vpsllq $(7), %ymm9, %ymm9 and %r15, %rdi xor %r12, %r14 vpxor %ymm10, %ymm8, %ymm8 xor %rdx, %rdi xor %r13, %r14 vpsrlq $(6), %ymm2, %ymm11 add %rdi, %rbx mov %r10, %r12 vpxor %ymm9, %ymm8, %ymm8 addq (104)(%rsp), %rax and %r9, %r12 vpsllq $(3), %ymm2, %ymm10 rorx $(41), %r9, %r13 rorx $(18), %r9, %rdi vpaddq %ymm8, %ymm3, %ymm3 add %r14, %rbx add %r12, %rax vpsrlq $(19), %ymm2, %ymm9 andn %r11, %r9, %r12 xor %rdi, %r13 vpxor %ymm10, %ymm11, %ymm11 rorx $(14), %r9, %r14 add %r12, %rax vpsllq $(42), %ymm10, %ymm10 xor %r14, %r13 mov %rbx, %rdi vpxor %ymm9, %ymm11, %ymm11 rorx $(39), %rbx, %r12 add %r13, %rax vpsrlq $(42), %ymm9, %ymm9 xor %rcx, %rdi rorx $(34), %rbx, %r14 vpxor %ymm10, %ymm11, %ymm11 rorx $(28), %rbx, %r13 add %rax, %r8 vpxor %ymm9, %ymm11, %ymm11 and %rdi, %r15 xor %r12, %r14 vpaddq %ymm11, %ymm3, %ymm3 xor %rcx, %r15 xor %r13, %r14 vpaddq (96)(%rbp), %ymm3, %ymm10 add %r15, %rax mov %r9, %r12 vmovdqa %ymm10, (352)(%rsp) vpalignr $(8), %ymm4, %ymm5, %ymm8 addq (128)(%rsp), %r11 and %r8, %r12 vpalignr $(8), %ymm0, %ymm1, %ymm11 rorx $(41), %r8, %r13 rorx $(18), %r8, %r15 vpsrlq $(1), %ymm8, %ymm10 add %r14, %rax add %r12, %r11 vpaddq %ymm11, %ymm4, %ymm4 andn %r10, %r8, %r12 xor %r15, %r13 vpsrlq $(7), %ymm8, %ymm11 rorx $(14), %r8, %r14 add %r12, %r11 vpsllq $(56), %ymm8, %ymm9 xor %r14, %r13 mov %rax, %r15 vpxor %ymm10, %ymm11, %ymm8 rorx $(39), %rax, %r12 add %r13, %r11 vpsrlq $(7), %ymm10, %ymm10 xor %rbx, %r15 rorx $(34), %rax, %r14 vpxor %ymm9, %ymm8, %ymm8 rorx $(28), %rax, %r13 add %r11, %rdx vpsllq $(7), %ymm9, %ymm9 and %r15, %rdi xor %r12, %r14 vpxor %ymm10, %ymm8, %ymm8 xor %rbx, %rdi xor %r13, %r14 vpsrlq $(6), %ymm3, %ymm11 add %rdi, %r11 mov %r8, %r12 vpxor %ymm9, %ymm8, %ymm8 addq (136)(%rsp), %r10 and %rdx, %r12 vpsllq $(3), %ymm3, %ymm10 rorx $(41), %rdx, %r13 rorx $(18), %rdx, %rdi vpaddq %ymm8, %ymm4, %ymm4 add %r14, %r11 add %r12, %r10 vpsrlq $(19), %ymm3, %ymm9 andn %r9, %rdx, %r12 xor %rdi, %r13 vpxor %ymm10, %ymm11, %ymm11 rorx $(14), %rdx, %r14 add %r12, %r10 vpsllq $(42), %ymm10, %ymm10 xor %r14, %r13 mov %r11, %rdi vpxor %ymm9, %ymm11, %ymm11 rorx $(39), %r11, %r12 add %r13, %r10 vpsrlq $(42), %ymm9, %ymm9 xor %rax, %rdi rorx $(34), %r11, %r14 vpxor %ymm10, %ymm11, %ymm11 rorx $(28), %r11, %r13 add %r10, %rcx vpxor %ymm9, %ymm11, %ymm11 and %rdi, %r15 xor %r12, %r14 vpaddq %ymm11, %ymm4, %ymm4 xor %rax, %r15 xor %r13, %r14 vpaddq (128)(%rbp), %ymm4, %ymm10 add %r15, %r10 mov %rdx, %r12 vmovdqa %ymm10, (384)(%rsp) vpalignr $(8), %ymm5, %ymm6, %ymm8 addq (160)(%rsp), %r9 and %rcx, %r12 vpalignr $(8), %ymm1, %ymm2, %ymm11 rorx $(41), %rcx, %r13 rorx $(18), %rcx, %r15 vpsrlq $(1), %ymm8, %ymm10 add %r14, %r10 add %r12, %r9 vpaddq %ymm11, %ymm5, %ymm5 andn %r8, %rcx, %r12 xor %r15, %r13 vpsrlq $(7), %ymm8, %ymm11 rorx $(14), %rcx, %r14 add %r12, %r9 vpsllq $(56), %ymm8, %ymm9 xor %r14, %r13 mov %r10, %r15 vpxor %ymm10, %ymm11, %ymm8 rorx $(39), %r10, %r12 add %r13, %r9 vpsrlq $(7), %ymm10, %ymm10 xor %r11, %r15 rorx $(34), %r10, %r14 vpxor %ymm9, %ymm8, %ymm8 rorx $(28), %r10, %r13 add %r9, %rbx vpsllq $(7), %ymm9, %ymm9 and %r15, %rdi xor %r12, %r14 vpxor %ymm10, %ymm8, %ymm8 xor %r11, %rdi xor %r13, %r14 vpsrlq $(6), %ymm4, %ymm11 add %rdi, %r9 mov %rcx, %r12 vpxor %ymm9, %ymm8, %ymm8 addq (168)(%rsp), %r8 and %rbx, %r12 vpsllq $(3), %ymm4, %ymm10 rorx $(41), %rbx, %r13 rorx $(18), %rbx, %rdi vpaddq %ymm8, %ymm5, %ymm5 add %r14, %r9 add %r12, %r8 vpsrlq $(19), %ymm4, %ymm9 andn %rdx, %rbx, %r12 xor %rdi, %r13 vpxor %ymm10, %ymm11, %ymm11 rorx $(14), %rbx, %r14 add %r12, %r8 vpsllq $(42), %ymm10, %ymm10 xor %r14, %r13 mov %r9, %rdi vpxor %ymm9, %ymm11, %ymm11 rorx $(39), %r9, %r12 add %r13, %r8 vpsrlq $(42), %ymm9, %ymm9 xor %r10, %rdi rorx $(34), %r9, %r14 vpxor %ymm10, %ymm11, %ymm11 rorx $(28), %r9, %r13 add %r8, %rax vpxor %ymm9, %ymm11, %ymm11 and %rdi, %r15 xor %r12, %r14 vpaddq %ymm11, %ymm5, %ymm5 xor %r10, %r15 xor %r13, %r14 vpaddq (160)(%rbp), %ymm5, %ymm10 add %r15, %r8 mov %rbx, %r12 vmovdqa %ymm10, (416)(%rsp) vpalignr $(8), %ymm6, %ymm7, %ymm8 addq (192)(%rsp), %rdx and %rax, %r12 vpalignr $(8), %ymm2, %ymm3, %ymm11 rorx $(41), %rax, %r13 rorx $(18), %rax, %r15 vpsrlq $(1), %ymm8, %ymm10 add %r14, %r8 add %r12, %rdx vpaddq %ymm11, %ymm6, %ymm6 andn %rcx, %rax, %r12 xor %r15, %r13 vpsrlq $(7), %ymm8, %ymm11 rorx $(14), %rax, %r14 add %r12, %rdx vpsllq $(56), %ymm8, %ymm9 xor %r14, %r13 mov %r8, %r15 vpxor %ymm10, %ymm11, %ymm8 rorx $(39), %r8, %r12 add %r13, %rdx vpsrlq $(7), %ymm10, %ymm10 xor %r9, %r15 rorx $(34), %r8, %r14 vpxor %ymm9, %ymm8, %ymm8 rorx $(28), %r8, %r13 add %rdx, %r11 vpsllq $(7), %ymm9, %ymm9 and %r15, %rdi xor %r12, %r14 vpxor %ymm10, %ymm8, %ymm8 xor %r9, %rdi xor %r13, %r14 vpsrlq $(6), %ymm5, %ymm11 add %rdi, %rdx mov %rax, %r12 vpxor %ymm9, %ymm8, %ymm8 addq (200)(%rsp), %rcx and %r11, %r12 vpsllq $(3), %ymm5, %ymm10 rorx $(41), %r11, %r13 rorx $(18), %r11, %rdi vpaddq %ymm8, %ymm6, %ymm6 add %r14, %rdx add %r12, %rcx vpsrlq $(19), %ymm5, %ymm9 andn %rbx, %r11, %r12 xor %rdi, %r13 vpxor %ymm10, %ymm11, %ymm11 rorx $(14), %r11, %r14 add %r12, %rcx vpsllq $(42), %ymm10, %ymm10 xor %r14, %r13 mov %rdx, %rdi vpxor %ymm9, %ymm11, %ymm11 rorx $(39), %rdx, %r12 add %r13, %rcx vpsrlq $(42), %ymm9, %ymm9 xor %r8, %rdi rorx $(34), %rdx, %r14 vpxor %ymm10, %ymm11, %ymm11 rorx $(28), %rdx, %r13 add %rcx, %r10 vpxor %ymm9, %ymm11, %ymm11 and %rdi, %r15 xor %r12, %r14 vpaddq %ymm11, %ymm6, %ymm6 xor %r8, %r15 xor %r13, %r14 vpaddq (192)(%rbp), %ymm6, %ymm10 add %r15, %rcx mov %r11, %r12 vmovdqa %ymm10, (448)(%rsp) vpalignr $(8), %ymm7, %ymm0, %ymm8 addq (224)(%rsp), %rbx and %r10, %r12 vpalignr $(8), %ymm3, %ymm4, %ymm11 rorx $(41), %r10, %r13 rorx $(18), %r10, %r15 vpsrlq $(1), %ymm8, %ymm10 add %r14, %rcx add %r12, %rbx vpaddq %ymm11, %ymm7, %ymm7 andn %rax, %r10, %r12 xor %r15, %r13 vpsrlq $(7), %ymm8, %ymm11 rorx $(14), %r10, %r14 add %r12, %rbx vpsllq $(56), %ymm8, %ymm9 xor %r14, %r13 mov %rcx, %r15 vpxor %ymm10, %ymm11, %ymm8 rorx $(39), %rcx, %r12 add %r13, %rbx vpsrlq $(7), %ymm10, %ymm10 xor %rdx, %r15 rorx $(34), %rcx, %r14 vpxor %ymm9, %ymm8, %ymm8 rorx $(28), %rcx, %r13 add %rbx, %r9 vpsllq $(7), %ymm9, %ymm9 and %r15, %rdi xor %r12, %r14 vpxor %ymm10, %ymm8, %ymm8 xor %rdx, %rdi xor %r13, %r14 vpsrlq $(6), %ymm6, %ymm11 add %rdi, %rbx mov %r10, %r12 vpxor %ymm9, %ymm8, %ymm8 addq (232)(%rsp), %rax and %r9, %r12 vpsllq $(3), %ymm6, %ymm10 rorx $(41), %r9, %r13 rorx $(18), %r9, %rdi vpaddq %ymm8, %ymm7, %ymm7 add %r14, %rbx add %r12, %rax vpsrlq $(19), %ymm6, %ymm9 andn %r11, %r9, %r12 xor %rdi, %r13 vpxor %ymm10, %ymm11, %ymm11 rorx $(14), %r9, %r14 add %r12, %rax vpsllq $(42), %ymm10, %ymm10 xor %r14, %r13 mov %rbx, %rdi vpxor %ymm9, %ymm11, %ymm11 rorx $(39), %rbx, %r12 add %r13, %rax vpsrlq $(42), %ymm9, %ymm9 xor %rcx, %rdi rorx $(34), %rbx, %r14 vpxor %ymm10, %ymm11, %ymm11 rorx $(28), %rbx, %r13 add %rax, %r8 vpxor %ymm9, %ymm11, %ymm11 and %rdi, %r15 xor %r12, %r14 vpaddq %ymm11, %ymm7, %ymm7 xor %rcx, %r15 xor %r13, %r14 vpaddq (224)(%rbp), %ymm7, %ymm10 add %r15, %rax mov %r9, %r12 vmovdqa %ymm10, (480)(%rsp) add $(256), %rsp add $(256), %rbp cmpl $(1246189591), (-8)(%rbp) jne .Lblock1_shed_procgas_1 addq (%rsp), %r11 and %r8, %r12 rorx $(41), %r8, %r13 rorx $(18), %r8, %r15 add %r14, %rax add %r12, %r11 andn %r10, %r8, %r12 xor %r15, %r13 rorx $(14), %r8, %r14 add %r12, %r11 xor %r14, %r13 mov %rax, %r15 rorx $(39), %rax, %r12 add %r13, %r11 xor %rbx, %r15 rorx $(34), %rax, %r14 rorx $(28), %rax, %r13 add %r11, %rdx and %r15, %rdi xor %r12, %r14 xor %rbx, %rdi xor %r13, %r14 add %rdi, %r11 mov %r8, %r12 addq (8)(%rsp), %r10 and %rdx, %r12 rorx $(41), %rdx, %r13 rorx $(18), %rdx, %rdi add %r14, %r11 add %r12, %r10 andn %r9, %rdx, %r12 xor %rdi, %r13 rorx $(14), %rdx, %r14 add %r12, %r10 xor %r14, %r13 mov %r11, %rdi rorx $(39), %r11, %r12 add %r13, %r10 xor %rax, %rdi rorx $(34), %r11, %r14 rorx $(28), %r11, %r13 add %r10, %rcx and %rdi, %r15 xor %r12, %r14 xor %rax, %r15 xor %r13, %r14 add %r15, %r10 mov %rdx, %r12 addq (32)(%rsp), %r9 and %rcx, %r12 rorx $(41), %rcx, %r13 rorx $(18), %rcx, %r15 add %r14, %r10 add %r12, %r9 andn %r8, %rcx, %r12 xor %r15, %r13 rorx $(14), %rcx, %r14 add %r12, %r9 xor %r14, %r13 mov %r10, %r15 rorx $(39), %r10, %r12 add %r13, %r9 xor %r11, %r15 rorx $(34), %r10, %r14 rorx $(28), %r10, %r13 add %r9, %rbx and %r15, %rdi xor %r12, %r14 xor %r11, %rdi xor %r13, %r14 add %rdi, %r9 mov %rcx, %r12 addq (40)(%rsp), %r8 and %rbx, %r12 rorx $(41), %rbx, %r13 rorx $(18), %rbx, %rdi add %r14, %r9 add %r12, %r8 andn %rdx, %rbx, %r12 xor %rdi, %r13 rorx $(14), %rbx, %r14 add %r12, %r8 xor %r14, %r13 mov %r9, %rdi rorx $(39), %r9, %r12 add %r13, %r8 xor %r10, %rdi rorx $(34), %r9, %r14 rorx $(28), %r9, %r13 add %r8, %rax and %rdi, %r15 xor %r12, %r14 xor %r10, %r15 xor %r13, %r14 add %r15, %r8 mov %rbx, %r12 addq (64)(%rsp), %rdx and %rax, %r12 rorx $(41), %rax, %r13 rorx $(18), %rax, %r15 add %r14, %r8 add %r12, %rdx andn %rcx, %rax, %r12 xor %r15, %r13 rorx $(14), %rax, %r14 add %r12, %rdx xor %r14, %r13 mov %r8, %r15 rorx $(39), %r8, %r12 add %r13, %rdx xor %r9, %r15 rorx $(34), %r8, %r14 rorx $(28), %r8, %r13 add %rdx, %r11 and %r15, %rdi xor %r12, %r14 xor %r9, %rdi xor %r13, %r14 add %rdi, %rdx mov %rax, %r12 addq (72)(%rsp), %rcx and %r11, %r12 rorx $(41), %r11, %r13 rorx $(18), %r11, %rdi add %r14, %rdx add %r12, %rcx andn %rbx, %r11, %r12 xor %rdi, %r13 rorx $(14), %r11, %r14 add %r12, %rcx xor %r14, %r13 mov %rdx, %rdi rorx $(39), %rdx, %r12 add %r13, %rcx xor %r8, %rdi rorx $(34), %rdx, %r14 rorx $(28), %rdx, %r13 add %rcx, %r10 and %rdi, %r15 xor %r12, %r14 xor %r8, %r15 xor %r13, %r14 add %r15, %rcx mov %r11, %r12 addq (96)(%rsp), %rbx and %r10, %r12 rorx $(41), %r10, %r13 rorx $(18), %r10, %r15 add %r14, %rcx add %r12, %rbx andn %rax, %r10, %r12 xor %r15, %r13 rorx $(14), %r10, %r14 add %r12, %rbx xor %r14, %r13 mov %rcx, %r15 rorx $(39), %rcx, %r12 add %r13, %rbx xor %rdx, %r15 rorx $(34), %rcx, %r14 rorx $(28), %rcx, %r13 add %rbx, %r9 and %r15, %rdi xor %r12, %r14 xor %rdx, %rdi xor %r13, %r14 add %rdi, %rbx mov %r10, %r12 addq (104)(%rsp), %rax and %r9, %r12 rorx $(41), %r9, %r13 rorx $(18), %r9, %rdi add %r14, %rbx add %r12, %rax andn %r11, %r9, %r12 xor %rdi, %r13 rorx $(14), %r9, %r14 add %r12, %rax xor %r14, %r13 mov %rbx, %rdi rorx $(39), %rbx, %r12 add %r13, %rax xor %rcx, %rdi rorx $(34), %rbx, %r14 rorx $(28), %rbx, %r13 add %rax, %r8 and %rdi, %r15 xor %r12, %r14 xor %rcx, %r15 xor %r13, %r14 add %r15, %rax mov %r9, %r12 addq (128)(%rsp), %r11 and %r8, %r12 rorx $(41), %r8, %r13 rorx $(18), %r8, %r15 add %r14, %rax add %r12, %r11 andn %r10, %r8, %r12 xor %r15, %r13 rorx $(14), %r8, %r14 add %r12, %r11 xor %r14, %r13 mov %rax, %r15 rorx $(39), %rax, %r12 add %r13, %r11 xor %rbx, %r15 rorx $(34), %rax, %r14 rorx $(28), %rax, %r13 add %r11, %rdx and %r15, %rdi xor %r12, %r14 xor %rbx, %rdi xor %r13, %r14 add %rdi, %r11 mov %r8, %r12 addq (136)(%rsp), %r10 and %rdx, %r12 rorx $(41), %rdx, %r13 rorx $(18), %rdx, %rdi add %r14, %r11 add %r12, %r10 andn %r9, %rdx, %r12 xor %rdi, %r13 rorx $(14), %rdx, %r14 add %r12, %r10 xor %r14, %r13 mov %r11, %rdi rorx $(39), %r11, %r12 add %r13, %r10 xor %rax, %rdi rorx $(34), %r11, %r14 rorx $(28), %r11, %r13 add %r10, %rcx and %rdi, %r15 xor %r12, %r14 xor %rax, %r15 xor %r13, %r14 add %r15, %r10 mov %rdx, %r12 addq (160)(%rsp), %r9 and %rcx, %r12 rorx $(41), %rcx, %r13 rorx $(18), %rcx, %r15 add %r14, %r10 add %r12, %r9 andn %r8, %rcx, %r12 xor %r15, %r13 rorx $(14), %rcx, %r14 add %r12, %r9 xor %r14, %r13 mov %r10, %r15 rorx $(39), %r10, %r12 add %r13, %r9 xor %r11, %r15 rorx $(34), %r10, %r14 rorx $(28), %r10, %r13 add %r9, %rbx and %r15, %rdi xor %r12, %r14 xor %r11, %rdi xor %r13, %r14 add %rdi, %r9 mov %rcx, %r12 addq (168)(%rsp), %r8 and %rbx, %r12 rorx $(41), %rbx, %r13 rorx $(18), %rbx, %rdi add %r14, %r9 add %r12, %r8 andn %rdx, %rbx, %r12 xor %rdi, %r13 rorx $(14), %rbx, %r14 add %r12, %r8 xor %r14, %r13 mov %r9, %rdi rorx $(39), %r9, %r12 add %r13, %r8 xor %r10, %rdi rorx $(34), %r9, %r14 rorx $(28), %r9, %r13 add %r8, %rax and %rdi, %r15 xor %r12, %r14 xor %r10, %r15 xor %r13, %r14 add %r15, %r8 mov %rbx, %r12 addq (192)(%rsp), %rdx and %rax, %r12 rorx $(41), %rax, %r13 rorx $(18), %rax, %r15 add %r14, %r8 add %r12, %rdx andn %rcx, %rax, %r12 xor %r15, %r13 rorx $(14), %rax, %r14 add %r12, %rdx xor %r14, %r13 mov %r8, %r15 rorx $(39), %r8, %r12 add %r13, %rdx xor %r9, %r15 rorx $(34), %r8, %r14 rorx $(28), %r8, %r13 add %rdx, %r11 and %r15, %rdi xor %r12, %r14 xor %r9, %rdi xor %r13, %r14 add %rdi, %rdx mov %rax, %r12 addq (200)(%rsp), %rcx and %r11, %r12 rorx $(41), %r11, %r13 rorx $(18), %r11, %rdi add %r14, %rdx add %r12, %rcx andn %rbx, %r11, %r12 xor %rdi, %r13 rorx $(14), %r11, %r14 add %r12, %rcx xor %r14, %r13 mov %rdx, %rdi rorx $(39), %rdx, %r12 add %r13, %rcx xor %r8, %rdi rorx $(34), %rdx, %r14 rorx $(28), %rdx, %r13 add %rcx, %r10 and %rdi, %r15 xor %r12, %r14 xor %r8, %r15 xor %r13, %r14 add %r15, %rcx mov %r11, %r12 addq (224)(%rsp), %rbx and %r10, %r12 rorx $(41), %r10, %r13 rorx $(18), %r10, %r15 add %r14, %rcx add %r12, %rbx andn %rax, %r10, %r12 xor %r15, %r13 rorx $(14), %r10, %r14 add %r12, %rbx xor %r14, %r13 mov %rcx, %r15 rorx $(39), %rcx, %r12 add %r13, %rbx xor %rdx, %r15 rorx $(34), %rcx, %r14 rorx $(28), %rcx, %r13 add %rbx, %r9 and %r15, %rdi xor %r12, %r14 xor %rdx, %rdi xor %r13, %r14 add %rdi, %rbx mov %r10, %r12 addq (232)(%rsp), %rax and %r9, %r12 rorx $(41), %r9, %r13 rorx $(18), %r9, %rdi add %r14, %rbx add %r12, %rax andn %r11, %r9, %r12 xor %rdi, %r13 rorx $(14), %r9, %r14 add %r12, %rax xor %r14, %r13 mov %rbx, %rdi rorx $(39), %rbx, %r12 add %r13, %rax xor %rcx, %rdi rorx $(34), %rbx, %r14 rorx $(28), %rbx, %r13 add %rax, %r8 and %rdi, %r15 xor %r12, %r14 xor %rcx, %r15 xor %r13, %r14 add %r15, %rax mov %r9, %r12 add %r14, %rax sub $(1024), %rsp movq (-24)(%rsp), %rdi movq (-16)(%rsp), %r14 addq (%rdi), %rax movq %rax, (%rdi) addq (8)(%rdi), %rbx movq %rbx, (8)(%rdi) addq (16)(%rdi), %rcx movq %rcx, (16)(%rdi) addq (24)(%rdi), %rdx movq %rdx, (24)(%rdi) addq (32)(%rdi), %r8 movq %r8, (32)(%rdi) addq (40)(%rdi), %r9 movq %r9, (40)(%rdi) addq (48)(%rdi), %r10 movq %r10, (48)(%rdi) addq (56)(%rdi), %r11 movq %r11, (56)(%rdi) cmp $(256), %r14 jl .Ldonegas_1 add $(16), %rsp lea (1280)(%rsp), %rbp mov %rbx, %rdi xor %r14, %r14 mov %r9, %r12 xor %rcx, %rdi .p2align 6, 0x90 .Lblock2_procgas_1: addq (%rsp), %r11 and %r8, %r12 rorx $(41), %r8, %r13 rorx $(18), %r8, %r15 add %r14, %rax add %r12, %r11 andn %r10, %r8, %r12 xor %r15, %r13 rorx $(14), %r8, %r14 add %r12, %r11 xor %r14, %r13 mov %rax, %r15 rorx $(39), %rax, %r12 add %r13, %r11 xor %rbx, %r15 rorx $(34), %rax, %r14 rorx $(28), %rax, %r13 add %r11, %rdx and %r15, %rdi xor %r12, %r14 xor %rbx, %rdi xor %r13, %r14 add %rdi, %r11 mov %r8, %r12 addq (8)(%rsp), %r10 and %rdx, %r12 rorx $(41), %rdx, %r13 rorx $(18), %rdx, %rdi add %r14, %r11 add %r12, %r10 andn %r9, %rdx, %r12 xor %rdi, %r13 rorx $(14), %rdx, %r14 add %r12, %r10 xor %r14, %r13 mov %r11, %rdi rorx $(39), %r11, %r12 add %r13, %r10 xor %rax, %rdi rorx $(34), %r11, %r14 rorx $(28), %r11, %r13 add %r10, %rcx and %rdi, %r15 xor %r12, %r14 xor %rax, %r15 xor %r13, %r14 add %r15, %r10 mov %rdx, %r12 addq (32)(%rsp), %r9 and %rcx, %r12 rorx $(41), %rcx, %r13 rorx $(18), %rcx, %r15 add %r14, %r10 add %r12, %r9 andn %r8, %rcx, %r12 xor %r15, %r13 rorx $(14), %rcx, %r14 add %r12, %r9 xor %r14, %r13 mov %r10, %r15 rorx $(39), %r10, %r12 add %r13, %r9 xor %r11, %r15 rorx $(34), %r10, %r14 rorx $(28), %r10, %r13 add %r9, %rbx and %r15, %rdi xor %r12, %r14 xor %r11, %rdi xor %r13, %r14 add %rdi, %r9 mov %rcx, %r12 addq (40)(%rsp), %r8 and %rbx, %r12 rorx $(41), %rbx, %r13 rorx $(18), %rbx, %rdi add %r14, %r9 add %r12, %r8 andn %rdx, %rbx, %r12 xor %rdi, %r13 rorx $(14), %rbx, %r14 add %r12, %r8 xor %r14, %r13 mov %r9, %rdi rorx $(39), %r9, %r12 add %r13, %r8 xor %r10, %rdi rorx $(34), %r9, %r14 rorx $(28), %r9, %r13 add %r8, %rax and %rdi, %r15 xor %r12, %r14 xor %r10, %r15 xor %r13, %r14 add %r15, %r8 mov %rbx, %r12 addq (64)(%rsp), %rdx and %rax, %r12 rorx $(41), %rax, %r13 rorx $(18), %rax, %r15 add %r14, %r8 add %r12, %rdx andn %rcx, %rax, %r12 xor %r15, %r13 rorx $(14), %rax, %r14 add %r12, %rdx xor %r14, %r13 mov %r8, %r15 rorx $(39), %r8, %r12 add %r13, %rdx xor %r9, %r15 rorx $(34), %r8, %r14 rorx $(28), %r8, %r13 add %rdx, %r11 and %r15, %rdi xor %r12, %r14 xor %r9, %rdi xor %r13, %r14 add %rdi, %rdx mov %rax, %r12 addq (72)(%rsp), %rcx and %r11, %r12 rorx $(41), %r11, %r13 rorx $(18), %r11, %rdi add %r14, %rdx add %r12, %rcx andn %rbx, %r11, %r12 xor %rdi, %r13 rorx $(14), %r11, %r14 add %r12, %rcx xor %r14, %r13 mov %rdx, %rdi rorx $(39), %rdx, %r12 add %r13, %rcx xor %r8, %rdi rorx $(34), %rdx, %r14 rorx $(28), %rdx, %r13 add %rcx, %r10 and %rdi, %r15 xor %r12, %r14 xor %r8, %r15 xor %r13, %r14 add %r15, %rcx mov %r11, %r12 addq (96)(%rsp), %rbx and %r10, %r12 rorx $(41), %r10, %r13 rorx $(18), %r10, %r15 add %r14, %rcx add %r12, %rbx andn %rax, %r10, %r12 xor %r15, %r13 rorx $(14), %r10, %r14 add %r12, %rbx xor %r14, %r13 mov %rcx, %r15 rorx $(39), %rcx, %r12 add %r13, %rbx xor %rdx, %r15 rorx $(34), %rcx, %r14 rorx $(28), %rcx, %r13 add %rbx, %r9 and %r15, %rdi xor %r12, %r14 xor %rdx, %rdi xor %r13, %r14 add %rdi, %rbx mov %r10, %r12 addq (104)(%rsp), %rax and %r9, %r12 rorx $(41), %r9, %r13 rorx $(18), %r9, %rdi add %r14, %rbx add %r12, %rax andn %r11, %r9, %r12 xor %rdi, %r13 rorx $(14), %r9, %r14 add %r12, %rax xor %r14, %r13 mov %rbx, %rdi rorx $(39), %rbx, %r12 add %r13, %rax xor %rcx, %rdi rorx $(34), %rbx, %r14 rorx $(28), %rbx, %r13 add %rax, %r8 and %rdi, %r15 xor %r12, %r14 xor %rcx, %r15 xor %r13, %r14 add %r15, %rax mov %r9, %r12 add $(128), %rsp cmp %rbp, %rsp jb .Lblock2_procgas_1 add %r14, %rax sub $(1296), %rsp movq (-24)(%rsp), %rdi movq (-16)(%rsp), %r14 addq (%rdi), %rax movq %rax, (%rdi) addq (8)(%rdi), %rbx movq %rbx, (8)(%rdi) addq (16)(%rdi), %rcx movq %rcx, (16)(%rdi) addq (24)(%rdi), %rdx movq %rdx, (24)(%rdi) addq (32)(%rdi), %r8 movq %r8, (32)(%rdi) addq (40)(%rdi), %r9 movq %r9, (40)(%rdi) addq (48)(%rdi), %r10 movq %r10, (48)(%rdi) addq (56)(%rdi), %r11 movq %r11, (56)(%rdi) add $(256), %rsi sub $(256), %r14 movq %r14, (-16)(%rsp) jg .Lsha512_block2_loopgas_1 .Ldonegas_1: movq (-8)(%rsp), %rsp add $(1312), %rsp vzeroupper pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp pop %rbx ret .Lfe1: .size UpdateSHA512, .Lfe1-(UpdateSHA512)
; A153339: Number of zig-zag paths from top to bottom of a rectangle of width 5 with n rows whose color is that of the top right corner ; 3,4,8,12,24,36,72,108,216,324,648,972,1944,2916,5832,8748,17496,26244,52488,78732,157464,236196,472392,708588,1417176,2125764,4251528,6377292,12754584,19131876,38263752,57395628,114791256,172186884,344373768,516560652,1033121304,1549681956,3099363912,4649045868,9298091736,13947137604,27894275208,41841412812,83682825624,125524238436,251048476872,376572715308,753145430616,1129718145924,2259436291848,3389154437772,6778308875544,10167463313316,20334926626632,30502389939948,61004779879896,91507169819844,183014339639688,274521509459532,549043018919064,823564528378596,1647129056757192,2470693585135788,4941387170271576,7412080755407364 add $0,1 cal $0,62318 ; Numbers of the form 3^m - 1 or 2*3^m - 1; i.e., the union of sequences A048473 and A024023. mov $1,$0 div $0,3 add $1,$0 add $1,2
// Copyright (c) 2014-2017 The Dash Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "activemasternode.h" #include "instantx.h" #include "key.h" #include "validation.h" #include "masternode-sync.h" #include "masternodeman.h" #include "messagesigner.h" #include "net.h" #include "protocol.h" #include "spork.h" #include "sync.h" #include "txmempool.h" #include "util.h" #include "consensus/validation.h" #include "validationinterface.h" #ifdef ENABLE_WALLET #include "wallet/wallet.h" #endif // ENABLE_WALLET #include <boost/algorithm/string/replace.hpp> #include <boost/thread.hpp> #ifdef ENABLE_WALLET extern CWallet* pwalletMain; #endif // ENABLE_WALLET extern CTxMemPool mempool; bool fEnableInstantSend = true; int nInstantSendDepth = DEFAULT_INSTANTSEND_DEPTH; int nCompleteTXLocks; CInstantSend instantsend; // Transaction Locks // // step 1) Some node announces intention to lock transaction inputs via "txlreg" message // step 2) Top COutPointLock::SIGNATURES_TOTAL masternodes per each spent outpoint push "txvote" message // step 3) Once there are COutPointLock::SIGNATURES_REQUIRED valid "txvote" messages per each spent outpoint // for a corresponding "txlreg" message, all outpoints from that tx are treated as locked // // CInstantSend // void CInstantSend::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv, CConnman& connman) { if(fLiteMode) return; // disable all Clarity specific functionality if(!sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) return; // NOTE: NetMsgType::TXLOCKREQUEST is handled via ProcessMessage() in main.cpp if (strCommand == NetMsgType::TXLOCKVOTE) // InstantSend Transaction Lock Consensus Votes { if(pfrom->nVersion < MIN_INSTANTSEND_PROTO_VERSION) return; CTxLockVote vote; vRecv >> vote; uint256 nVoteHash = vote.GetHash(); pfrom->setAskFor.erase(nVoteHash); // Ignore any InstantSend messages until masternode list is synced if(!masternodeSync.IsMasternodeListSynced()) return; LOCK(cs_main); #ifdef ENABLE_WALLET if (pwalletMain) LOCK(pwalletMain->cs_wallet); #endif LOCK(cs_instantsend); if(mapTxLockVotes.count(nVoteHash)) return; mapTxLockVotes.insert(std::make_pair(nVoteHash, vote)); ProcessTxLockVote(pfrom, vote, connman); return; } } bool CInstantSend::ProcessTxLockRequest(const CTxLockRequest& txLockRequest, CConnman& connman) { LOCK2(cs_main, cs_instantsend); uint256 txHash = txLockRequest.GetHash(); // Check to see if we conflict with existing completed lock BOOST_FOREACH(const CTxIn& txin, txLockRequest.vin) { std::map<COutPoint, uint256>::iterator it = mapLockedOutpoints.find(txin.prevout); if(it != mapLockedOutpoints.end() && it->second != txLockRequest.GetHash()) { // Conflicting with complete lock, proceed to see if we should cancel them both LogPrintf("CInstantSend::ProcessTxLockRequest -- WARNING: Found conflicting completed Transaction Lock, txid=%s, completed lock txid=%s\n", txLockRequest.GetHash().ToString(), it->second.ToString()); } } // Check to see if there are votes for conflicting request, // if so - do not fail, just warn user BOOST_FOREACH(const CTxIn& txin, txLockRequest.vin) { std::map<COutPoint, std::set<uint256> >::iterator it = mapVotedOutpoints.find(txin.prevout); if(it != mapVotedOutpoints.end()) { BOOST_FOREACH(const uint256& hash, it->second) { if(hash != txLockRequest.GetHash()) { LogPrint("instantsend", "CInstantSend::ProcessTxLockRequest -- Double spend attempt! %s\n", txin.prevout.ToStringShort()); // do not fail here, let it go and see which one will get the votes to be locked // TODO: notify zmq+script } } } } if(!CreateTxLockCandidate(txLockRequest)) { // smth is not right LogPrintf("CInstantSend::ProcessTxLockRequest -- CreateTxLockCandidate failed, txid=%s\n", txHash.ToString()); return false; } LogPrintf("CInstantSend::ProcessTxLockRequest -- accepted, txid=%s\n", txHash.ToString()); // Masternodes will sometimes propagate votes before the transaction is known to the client. // If this just happened - lock inputs, resolve conflicting locks, update transaction status // forcing external script notification. std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash); TryToFinalizeLockCandidate(itLockCandidate->second); return true; } bool CInstantSend::CreateTxLockCandidate(const CTxLockRequest& txLockRequest) { if(!txLockRequest.IsValid()) return false; LOCK(cs_instantsend); uint256 txHash = txLockRequest.GetHash(); std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash); if(itLockCandidate == mapTxLockCandidates.end()) { LogPrintf("CInstantSend::CreateTxLockCandidate -- new, txid=%s\n", txHash.ToString()); CTxLockCandidate txLockCandidate(txLockRequest); // all inputs should already be checked by txLockRequest.IsValid() above, just use them now BOOST_REVERSE_FOREACH(const CTxIn& txin, txLockRequest.vin) { txLockCandidate.AddOutPointLock(txin.prevout); } mapTxLockCandidates.insert(std::make_pair(txHash, txLockCandidate)); } else if (!itLockCandidate->second.txLockRequest) { // i.e. empty Transaction Lock Candidate was created earlier, let's update it with actual data itLockCandidate->second.txLockRequest = txLockRequest; if (itLockCandidate->second.IsTimedOut()) { LogPrintf("CInstantSend::CreateTxLockCandidate -- timed out, txid=%s\n", txHash.ToString()); return false; } LogPrintf("CInstantSend::CreateTxLockCandidate -- update empty, txid=%s\n", txHash.ToString()); // all inputs should already be checked by txLockRequest.IsValid() above, just use them now BOOST_REVERSE_FOREACH(const CTxIn& txin, txLockRequest.vin) { itLockCandidate->second.AddOutPointLock(txin.prevout); } } else { LogPrint("instantsend", "CInstantSend::CreateTxLockCandidate -- seen, txid=%s\n", txHash.ToString()); } return true; } void CInstantSend::CreateEmptyTxLockCandidate(const uint256& txHash) { if (mapTxLockCandidates.find(txHash) != mapTxLockCandidates.end()) return; LogPrintf("CInstantSend::CreateEmptyTxLockCandidate -- new, txid=%s\n", txHash.ToString()); const CTxLockRequest txLockRequest = CTxLockRequest(); mapTxLockCandidates.insert(std::make_pair(txHash, CTxLockCandidate(txLockRequest))); } void CInstantSend::Vote(const uint256& txHash, CConnman& connman) { AssertLockHeld(cs_main); LOCK(cs_instantsend); std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash); if (itLockCandidate == mapTxLockCandidates.end()) return; Vote(itLockCandidate->second, connman); // Let's see if our vote changed smth TryToFinalizeLockCandidate(itLockCandidate->second); } void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman) { if(!fMasterNode) return; if(!sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) return; LOCK2(cs_main, cs_instantsend); uint256 txHash = txLockCandidate.GetHash(); // We should never vote on a Transaction Lock Request that was not (yet) accepted by the mempool if(mapLockRequestAccepted.find(txHash) == mapLockRequestAccepted.end()) return; // check if we need to vote on this candidate's outpoints, // it's possible that we need to vote for several of them std::map<COutPoint, COutPointLock>::iterator itOutpointLock = txLockCandidate.mapOutPointLocks.begin(); while(itOutpointLock != txLockCandidate.mapOutPointLocks.end()) { int nPrevoutHeight = GetUTXOHeight(itOutpointLock->first); if(nPrevoutHeight == -1) { LogPrint("instantsend", "CInstantSend::Vote -- Failed to find UTXO %s\n", itOutpointLock->first.ToStringShort()); return; } int nLockInputHeight = nPrevoutHeight + 4; int nRank; if(!mnodeman.GetMasternodeRank(activeMasternode.outpoint, nRank, nLockInputHeight, MIN_INSTANTSEND_PROTO_VERSION)) { LogPrint("instantsend", "CInstantSend::Vote -- Can't calculate rank for masternode %s\n", activeMasternode.outpoint.ToStringShort()); ++itOutpointLock; continue; } int nSignaturesTotal = COutPointLock::SIGNATURES_TOTAL; if(nRank > nSignaturesTotal) { LogPrint("instantsend", "CInstantSend::Vote -- Masternode not in the top %d (%d)\n", nSignaturesTotal, nRank); ++itOutpointLock; continue; } LogPrint("instantsend", "CInstantSend::Vote -- In the top %d (%d)\n", nSignaturesTotal, nRank); std::map<COutPoint, std::set<uint256> >::iterator itVoted = mapVotedOutpoints.find(itOutpointLock->first); // Check to see if we already voted for this outpoint, // refuse to vote twice or to include the same outpoint in another tx bool fAlreadyVoted = false; if(itVoted != mapVotedOutpoints.end()) { BOOST_FOREACH(const uint256& hash, itVoted->second) { std::map<uint256, CTxLockCandidate>::iterator it2 = mapTxLockCandidates.find(hash); if(it2->second.HasMasternodeVoted(itOutpointLock->first, activeMasternode.outpoint)) { // we already voted for this outpoint to be included either in the same tx or in a competing one, // skip it anyway fAlreadyVoted = true; LogPrintf("CInstantSend::Vote -- WARNING: We already voted for this outpoint, skipping: txHash=%s, outpoint=%s\n", txHash.ToString(), itOutpointLock->first.ToStringShort()); break; } } } if(fAlreadyVoted) { ++itOutpointLock; continue; // skip to the next outpoint } // we haven't voted for this outpoint yet, let's try to do this now CTxLockVote vote(txHash, itOutpointLock->first, activeMasternode.outpoint); if(!vote.Sign()) { LogPrintf("CInstantSend::Vote -- Failed to sign consensus vote\n"); return; } if(!vote.CheckSignature()) { LogPrintf("CInstantSend::Vote -- Signature invalid\n"); return; } // vote constructed sucessfully, let's store and relay it uint256 nVoteHash = vote.GetHash(); mapTxLockVotes.insert(std::make_pair(nVoteHash, vote)); if(itOutpointLock->second.AddVote(vote)) { LogPrintf("CInstantSend::Vote -- Vote created successfully, relaying: txHash=%s, outpoint=%s, vote=%s\n", txHash.ToString(), itOutpointLock->first.ToStringShort(), nVoteHash.ToString()); if(itVoted == mapVotedOutpoints.end()) { std::set<uint256> setHashes; setHashes.insert(txHash); mapVotedOutpoints.insert(std::make_pair(itOutpointLock->first, setHashes)); } else { mapVotedOutpoints[itOutpointLock->first].insert(txHash); if(mapVotedOutpoints[itOutpointLock->first].size() > 1) { // it's ok to continue, just warn user LogPrintf("CInstantSend::Vote -- WARNING: Vote conflicts with some existing votes: txHash=%s, outpoint=%s, vote=%s\n", txHash.ToString(), itOutpointLock->first.ToStringShort(), nVoteHash.ToString()); } } vote.Relay(connman); } ++itOutpointLock; } } //received a consensus vote bool CInstantSend::ProcessTxLockVote(CNode* pfrom, CTxLockVote& vote, CConnman& connman) { // cs_main, cs_wallet and cs_instantsend should be already locked AssertLockHeld(cs_main); #ifdef ENABLE_WALLET if (pwalletMain) AssertLockHeld(pwalletMain->cs_wallet); #endif AssertLockHeld(cs_instantsend); uint256 txHash = vote.GetTxHash(); if(!vote.IsValid(pfrom, connman)) { // could be because of missing MN LogPrint("instantsend", "CInstantSend::ProcessTxLockVote -- Vote is invalid, txid=%s\n", txHash.ToString()); return false; } // relay valid vote asap vote.Relay(connman); // Masternodes will sometimes propagate votes before the transaction is known to the client, // will actually process only after the lock request itself has arrived std::map<uint256, CTxLockCandidate>::iterator it = mapTxLockCandidates.find(txHash); if(it == mapTxLockCandidates.end() || !it->second.txLockRequest) { if(!mapTxLockVotesOrphan.count(vote.GetHash())) { // start timeout countdown after the very first vote CreateEmptyTxLockCandidate(txHash); mapTxLockVotesOrphan[vote.GetHash()] = vote; LogPrint("instantsend", "CInstantSend::ProcessTxLockVote -- Orphan vote: txid=%s masternode=%s new\n", txHash.ToString(), vote.GetMasternodeOutpoint().ToStringShort()); bool fReprocess = true; std::map<uint256, CTxLockRequest>::iterator itLockRequest = mapLockRequestAccepted.find(txHash); if(itLockRequest == mapLockRequestAccepted.end()) { itLockRequest = mapLockRequestRejected.find(txHash); if(itLockRequest == mapLockRequestRejected.end()) { // still too early, wait for tx lock request fReprocess = false; } } if(fReprocess && IsEnoughOrphanVotesForTx(itLockRequest->second)) { // We have enough votes for corresponding lock to complete, // tx lock request should already be received at this stage. LogPrint("instantsend", "CInstantSend::ProcessTxLockVote -- Found enough orphan votes, reprocessing Transaction Lock Request: txid=%s\n", txHash.ToString()); ProcessTxLockRequest(itLockRequest->second, connman); return true; } } else { LogPrint("instantsend", "CInstantSend::ProcessTxLockVote -- Orphan vote: txid=%s masternode=%s seen\n", txHash.ToString(), vote.GetMasternodeOutpoint().ToStringShort()); } // This tracks those messages and allows only the same rate as of the rest of the network // TODO: make sure this works good enough for multi-quorum int nMasternodeOrphanExpireTime = GetTime() + 60*10; // keep time data for 10 minutes if(!mapMasternodeOrphanVotes.count(vote.GetMasternodeOutpoint())) { mapMasternodeOrphanVotes[vote.GetMasternodeOutpoint()] = nMasternodeOrphanExpireTime; } else { int64_t nPrevOrphanVote = mapMasternodeOrphanVotes[vote.GetMasternodeOutpoint()]; if(nPrevOrphanVote > GetTime() && nPrevOrphanVote > GetAverageMasternodeOrphanVoteTime()) { LogPrint("instantsend", "CInstantSend::ProcessTxLockVote -- masternode is spamming orphan Transaction Lock Votes: txid=%s masternode=%s\n", txHash.ToString(), vote.GetMasternodeOutpoint().ToStringShort()); // Misbehaving(pfrom->id, 1); return false; } // not spamming, refresh mapMasternodeOrphanVotes[vote.GetMasternodeOutpoint()] = nMasternodeOrphanExpireTime; } return true; } CTxLockCandidate& txLockCandidate = it->second; if (txLockCandidate.IsTimedOut()) { LogPrint("instantsend", "CInstantSend::ProcessTxLockVote -- too late, Transaction Lock timed out, txid=%s\n", txHash.ToString()); return false; } LogPrint("instantsend", "CInstantSend::ProcessTxLockVote -- Transaction Lock Vote, txid=%s\n", txHash.ToString()); std::map<COutPoint, std::set<uint256> >::iterator it1 = mapVotedOutpoints.find(vote.GetOutpoint()); if(it1 != mapVotedOutpoints.end()) { BOOST_FOREACH(const uint256& hash, it1->second) { if(hash != txHash) { // same outpoint was already voted to be locked by another tx lock request, // let's see if it was the same masternode who voted on this outpoint // for another tx lock request std::map<uint256, CTxLockCandidate>::iterator it2 = mapTxLockCandidates.find(hash); if(it2 !=mapTxLockCandidates.end() && it2->second.HasMasternodeVoted(vote.GetOutpoint(), vote.GetMasternodeOutpoint())) { // yes, it was the same masternode LogPrintf("CInstantSend::ProcessTxLockVote -- masternode sent conflicting votes! %s\n", vote.GetMasternodeOutpoint().ToStringShort()); // mark both Lock Candidates as attacked, none of them should complete, // or at least the new (current) one shouldn't even // if the second one was already completed earlier txLockCandidate.MarkOutpointAsAttacked(vote.GetOutpoint()); it2->second.MarkOutpointAsAttacked(vote.GetOutpoint()); // apply maximum PoSe ban score to this masternode i.e. PoSe-ban it instantly mnodeman.PoSeBan(vote.GetMasternodeOutpoint()); // NOTE: This vote must be relayed further to let all other nodes know about such // misbehaviour of this masternode. This way they should also be able to construct // conflicting lock and PoSe-ban this masternode. } } } // store all votes, regardless of them being sent by malicious masternode or not it1->second.insert(txHash); } else { std::set<uint256> setHashes; setHashes.insert(txHash); mapVotedOutpoints.insert(std::make_pair(vote.GetOutpoint(), setHashes)); } if(!txLockCandidate.AddVote(vote)) { // this should never happen return false; } int nSignatures = txLockCandidate.CountVotes(); int nSignaturesMax = txLockCandidate.txLockRequest.GetMaxSignatures(); LogPrint("instantsend", "CInstantSend::ProcessTxLockVote -- Transaction Lock signatures count: %d/%d, vote hash=%s\n", nSignatures, nSignaturesMax, vote.GetHash().ToString()); TryToFinalizeLockCandidate(txLockCandidate); return true; } void CInstantSend::ProcessOrphanTxLockVotes(CConnman& connman) { LOCK(cs_main); #ifdef ENABLE_WALLET if (pwalletMain) LOCK(pwalletMain->cs_wallet); #endif LOCK(cs_instantsend); std::map<uint256, CTxLockVote>::iterator it = mapTxLockVotesOrphan.begin(); while(it != mapTxLockVotesOrphan.end()) { if(ProcessTxLockVote(NULL, it->second, connman)) { mapTxLockVotesOrphan.erase(it++); } else { ++it; } } } bool CInstantSend::IsEnoughOrphanVotesForTx(const CTxLockRequest& txLockRequest) { // There could be a situation when we already have quite a lot of votes // but tx lock request still wasn't received. Let's scan through // orphan votes to check if this is the case. BOOST_FOREACH(const CTxIn& txin, txLockRequest.vin) { if(!IsEnoughOrphanVotesForTxAndOutPoint(txLockRequest.GetHash(), txin.prevout)) { return false; } } return true; } bool CInstantSend::IsEnoughOrphanVotesForTxAndOutPoint(const uint256& txHash, const COutPoint& outpoint) { // Scan orphan votes to check if this outpoint has enough orphan votes to be locked in some tx. LOCK2(cs_main, cs_instantsend); int nCountVotes = 0; std::map<uint256, CTxLockVote>::iterator it = mapTxLockVotesOrphan.begin(); while(it != mapTxLockVotesOrphan.end()) { if(it->second.GetTxHash() == txHash && it->second.GetOutpoint() == outpoint) { nCountVotes++; if(nCountVotes >= COutPointLock::SIGNATURES_REQUIRED) { return true; } } ++it; } return false; } void CInstantSend::TryToFinalizeLockCandidate(const CTxLockCandidate& txLockCandidate) { if(!sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) return; LOCK(cs_main); #ifdef ENABLE_WALLET if (pwalletMain) LOCK(pwalletMain->cs_wallet); #endif LOCK(cs_instantsend); uint256 txHash = txLockCandidate.txLockRequest.GetHash(); if(txLockCandidate.IsAllOutPointsReady() && !IsLockedInstantSendTransaction(txHash)) { // we have enough votes now LogPrint("instantsend", "CInstantSend::TryToFinalizeLockCandidate -- Transaction Lock is ready to complete, txid=%s\n", txHash.ToString()); if(ResolveConflicts(txLockCandidate)) { LockTransactionInputs(txLockCandidate); UpdateLockedTransaction(txLockCandidate); } } } void CInstantSend::UpdateLockedTransaction(const CTxLockCandidate& txLockCandidate) { // cs_wallet and cs_instantsend should be already locked #ifdef ENABLE_WALLET if (pwalletMain) AssertLockHeld(pwalletMain->cs_wallet); #endif AssertLockHeld(cs_instantsend); uint256 txHash = txLockCandidate.GetHash(); if(!IsLockedInstantSendTransaction(txHash)) return; // not a locked tx, do not update/notify #ifdef ENABLE_WALLET if(pwalletMain && pwalletMain->UpdatedTransaction(txHash)) { // bumping this to update UI nCompleteTXLocks++; // notify an external script once threshold is reached std::string strCmd = GetArg("-instantsendnotify", ""); if(!strCmd.empty()) { boost::replace_all(strCmd, "%s", txHash.GetHex()); boost::thread t(runCommand, strCmd); // thread runs free } } #endif GetMainSignals().NotifyTransactionLock(txLockCandidate.txLockRequest); LogPrint("instantsend", "CInstantSend::UpdateLockedTransaction -- done, txid=%s\n", txHash.ToString()); } void CInstantSend::LockTransactionInputs(const CTxLockCandidate& txLockCandidate) { if(!sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) return; LOCK(cs_instantsend); uint256 txHash = txLockCandidate.GetHash(); if(!txLockCandidate.IsAllOutPointsReady()) return; std::map<COutPoint, COutPointLock>::const_iterator it = txLockCandidate.mapOutPointLocks.begin(); while(it != txLockCandidate.mapOutPointLocks.end()) { mapLockedOutpoints.insert(std::make_pair(it->first, txHash)); ++it; } LogPrint("instantsend", "CInstantSend::LockTransactionInputs -- done, txid=%s\n", txHash.ToString()); } bool CInstantSend::GetLockedOutPointTxHash(const COutPoint& outpoint, uint256& hashRet) { LOCK(cs_instantsend); std::map<COutPoint, uint256>::iterator it = mapLockedOutpoints.find(outpoint); if(it == mapLockedOutpoints.end()) return false; hashRet = it->second; return true; } bool CInstantSend::ResolveConflicts(const CTxLockCandidate& txLockCandidate) { LOCK2(cs_main, cs_instantsend); uint256 txHash = txLockCandidate.GetHash(); // make sure the lock is ready if(!txLockCandidate.IsAllOutPointsReady()) return false; LOCK(mempool.cs); // protect mempool.mapNextTx BOOST_FOREACH(const CTxIn& txin, txLockCandidate.txLockRequest.vin) { uint256 hashConflicting; if(GetLockedOutPointTxHash(txin.prevout, hashConflicting) && txHash != hashConflicting) { // completed lock which conflicts with another completed one? // this means that majority of MNs in the quorum for this specific tx input are malicious! std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash); std::map<uint256, CTxLockCandidate>::iterator itLockCandidateConflicting = mapTxLockCandidates.find(hashConflicting); if(itLockCandidate == mapTxLockCandidates.end() || itLockCandidateConflicting == mapTxLockCandidates.end()) { // safety check, should never really happen LogPrintf("CInstantSend::ResolveConflicts -- ERROR: Found conflicting completed Transaction Lock, but one of txLockCandidate-s is missing, txid=%s, conflicting txid=%s\n", txHash.ToString(), hashConflicting.ToString()); return false; } LogPrintf("CInstantSend::ResolveConflicts -- WARNING: Found conflicting completed Transaction Lock, dropping both, txid=%s, conflicting txid=%s\n", txHash.ToString(), hashConflicting.ToString()); CTxLockRequest txLockRequest = itLockCandidate->second.txLockRequest; CTxLockRequest txLockRequestConflicting = itLockCandidateConflicting->second.txLockRequest; itLockCandidate->second.SetConfirmedHeight(0); // expired itLockCandidateConflicting->second.SetConfirmedHeight(0); // expired CheckAndRemove(); // clean up // AlreadyHave should still return "true" for both of them mapLockRequestRejected.insert(make_pair(txHash, txLockRequest)); mapLockRequestRejected.insert(make_pair(hashConflicting, txLockRequestConflicting)); // TODO: clean up mapLockRequestRejected later somehow // (not a big issue since we already PoSe ban malicious masternodes // and they won't be able to spam) // TODO: ban all malicious masternodes permanently, do not accept anything from them, ever // TODO: notify zmq+script about this double-spend attempt // and let merchant cancel/hold the order if it's not too late... // can't do anything else, fallback to regular txes return false; } else if (mempool.mapNextTx.count(txin.prevout)) { // check if it's in mempool hashConflicting = mempool.mapNextTx[txin.prevout].ptx->GetHash(); if(txHash == hashConflicting) continue; // matches current, not a conflict, skip to next txin // conflicts with tx in mempool LogPrintf("CInstantSend::ResolveConflicts -- ERROR: Failed to complete Transaction Lock, conflicts with mempool, txid=%s\n", txHash.ToString()); return false; } } // FOREACH // No conflicts were found so far, check to see if it was already included in block CTransaction txTmp; uint256 hashBlock; if(GetTransaction(txHash, txTmp, Params().GetConsensus(), hashBlock, true) && hashBlock != uint256()) { LogPrint("instantsend", "CInstantSend::ResolveConflicts -- Done, %s is included in block %s\n", txHash.ToString(), hashBlock.ToString()); return true; } // Not in block yet, make sure all its inputs are still unspent BOOST_FOREACH(const CTxIn& txin, txLockCandidate.txLockRequest.vin) { Coin coin; if(!GetUTXOCoin(txin.prevout, coin)) { // Not in UTXO anymore? A conflicting tx was mined while we were waiting for votes. LogPrintf("CInstantSend::ResolveConflicts -- ERROR: Failed to find UTXO %s, can't complete Transaction Lock\n", txin.prevout.ToStringShort()); return false; } } LogPrint("instantsend", "CInstantSend::ResolveConflicts -- Done, txid=%s\n", txHash.ToString()); return true; } int64_t CInstantSend::GetAverageMasternodeOrphanVoteTime() { LOCK(cs_instantsend); // NOTE: should never actually call this function when mapMasternodeOrphanVotes is empty if(mapMasternodeOrphanVotes.empty()) return 0; std::map<COutPoint, int64_t>::iterator it = mapMasternodeOrphanVotes.begin(); int64_t total = 0; while(it != mapMasternodeOrphanVotes.end()) { total+= it->second; ++it; } return total / mapMasternodeOrphanVotes.size(); } void CInstantSend::CheckAndRemove() { if(!masternodeSync.IsMasternodeListSynced()) return; LOCK(cs_instantsend); std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.begin(); // remove expired candidates while(itLockCandidate != mapTxLockCandidates.end()) { CTxLockCandidate &txLockCandidate = itLockCandidate->second; uint256 txHash = txLockCandidate.GetHash(); if(txLockCandidate.IsExpired(nCachedBlockHeight)) { LogPrintf("CInstantSend::CheckAndRemove -- Removing expired Transaction Lock Candidate: txid=%s\n", txHash.ToString()); std::map<COutPoint, COutPointLock>::iterator itOutpointLock = txLockCandidate.mapOutPointLocks.begin(); while(itOutpointLock != txLockCandidate.mapOutPointLocks.end()) { mapLockedOutpoints.erase(itOutpointLock->first); mapVotedOutpoints.erase(itOutpointLock->first); ++itOutpointLock; } mapLockRequestAccepted.erase(txHash); mapLockRequestRejected.erase(txHash); mapTxLockCandidates.erase(itLockCandidate++); } else { ++itLockCandidate; } } // remove expired votes std::map<uint256, CTxLockVote>::iterator itVote = mapTxLockVotes.begin(); while(itVote != mapTxLockVotes.end()) { if(itVote->second.IsExpired(nCachedBlockHeight)) { LogPrint("instantsend", "CInstantSend::CheckAndRemove -- Removing expired vote: txid=%s masternode=%s\n", itVote->second.GetTxHash().ToString(), itVote->second.GetMasternodeOutpoint().ToStringShort()); mapTxLockVotes.erase(itVote++); } else { ++itVote; } } // remove timed out orphan votes std::map<uint256, CTxLockVote>::iterator itOrphanVote = mapTxLockVotesOrphan.begin(); while(itOrphanVote != mapTxLockVotesOrphan.end()) { if(itOrphanVote->second.IsTimedOut()) { LogPrint("instantsend", "CInstantSend::CheckAndRemove -- Removing timed out orphan vote: txid=%s masternode=%s\n", itOrphanVote->second.GetTxHash().ToString(), itOrphanVote->second.GetMasternodeOutpoint().ToStringShort()); mapTxLockVotes.erase(itOrphanVote->first); mapTxLockVotesOrphan.erase(itOrphanVote++); } else { ++itOrphanVote; } } // remove invalid votes and votes for failed lock attempts itVote = mapTxLockVotes.begin(); while(itVote != mapTxLockVotes.end()) { if(itVote->second.IsFailed()) { LogPrint("instantsend", "CInstantSend::CheckAndRemove -- Removing vote for failed lock attempt: txid=%s masternode=%s\n", itVote->second.GetTxHash().ToString(), itVote->second.GetMasternodeOutpoint().ToStringShort()); mapTxLockVotes.erase(itVote++); } else { ++itVote; } } // remove timed out masternode orphan votes (DOS protection) std::map<COutPoint, int64_t>::iterator itMasternodeOrphan = mapMasternodeOrphanVotes.begin(); while(itMasternodeOrphan != mapMasternodeOrphanVotes.end()) { if(itMasternodeOrphan->second < GetTime()) { LogPrint("instantsend", "CInstantSend::CheckAndRemove -- Removing timed out orphan masternode vote: masternode=%s\n", itMasternodeOrphan->first.ToStringShort()); mapMasternodeOrphanVotes.erase(itMasternodeOrphan++); } else { ++itMasternodeOrphan; } } LogPrintf("CInstantSend::CheckAndRemove -- %s\n", ToString()); } bool CInstantSend::AlreadyHave(const uint256& hash) { LOCK(cs_instantsend); return mapLockRequestAccepted.count(hash) || mapLockRequestRejected.count(hash) || mapTxLockVotes.count(hash); } void CInstantSend::AcceptLockRequest(const CTxLockRequest& txLockRequest) { LOCK(cs_instantsend); mapLockRequestAccepted.insert(make_pair(txLockRequest.GetHash(), txLockRequest)); } void CInstantSend::RejectLockRequest(const CTxLockRequest& txLockRequest) { LOCK(cs_instantsend); mapLockRequestRejected.insert(make_pair(txLockRequest.GetHash(), txLockRequest)); } bool CInstantSend::HasTxLockRequest(const uint256& txHash) { CTxLockRequest txLockRequestTmp; return GetTxLockRequest(txHash, txLockRequestTmp); } bool CInstantSend::GetTxLockRequest(const uint256& txHash, CTxLockRequest& txLockRequestRet) { LOCK(cs_instantsend); std::map<uint256, CTxLockCandidate>::iterator it = mapTxLockCandidates.find(txHash); if(it == mapTxLockCandidates.end()) return false; txLockRequestRet = it->second.txLockRequest; return true; } bool CInstantSend::GetTxLockVote(const uint256& hash, CTxLockVote& txLockVoteRet) { LOCK(cs_instantsend); std::map<uint256, CTxLockVote>::iterator it = mapTxLockVotes.find(hash); if(it == mapTxLockVotes.end()) return false; txLockVoteRet = it->second; return true; } bool CInstantSend::IsInstantSendReadyToLock(const uint256& txHash) { if(!fEnableInstantSend || fLargeWorkForkFound || fLargeWorkInvalidChainFound || !sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) return false; LOCK(cs_instantsend); // There must be a successfully verified lock request // and all outputs must be locked (i.e. have enough signatures) std::map<uint256, CTxLockCandidate>::iterator it = mapTxLockCandidates.find(txHash); return it != mapTxLockCandidates.end() && it->second.IsAllOutPointsReady(); } bool CInstantSend::IsLockedInstantSendTransaction(const uint256& txHash) { if(!fEnableInstantSend || fLargeWorkForkFound || fLargeWorkInvalidChainFound || !sporkManager.IsSporkActive(SPORK_3_INSTANTSEND_BLOCK_FILTERING)) return false; LOCK(cs_instantsend); // there must be a lock candidate std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash); if(itLockCandidate == mapTxLockCandidates.end()) return false; // which should have outpoints if(itLockCandidate->second.mapOutPointLocks.empty()) return false; // and all of these outputs must be included in mapLockedOutpoints with correct hash std::map<COutPoint, COutPointLock>::iterator itOutpointLock = itLockCandidate->second.mapOutPointLocks.begin(); while(itOutpointLock != itLockCandidate->second.mapOutPointLocks.end()) { uint256 hashLocked; if(!GetLockedOutPointTxHash(itOutpointLock->first, hashLocked) || hashLocked != txHash) return false; ++itOutpointLock; } return true; } int CInstantSend::GetTransactionLockSignatures(const uint256& txHash) { if(!fEnableInstantSend) return -1; if(fLargeWorkForkFound || fLargeWorkInvalidChainFound) return -2; if(!sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) return -3; LOCK(cs_instantsend); std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash); if(itLockCandidate != mapTxLockCandidates.end()) { return itLockCandidate->second.CountVotes(); } return -1; } int CInstantSend::GetConfirmations(const uint256 &nTXHash) { return IsLockedInstantSendTransaction(nTXHash) ? nInstantSendDepth : 0; } bool CInstantSend::IsTxLockCandidateTimedOut(const uint256& txHash) { if(!fEnableInstantSend) return false; LOCK(cs_instantsend); std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash); if (itLockCandidate != mapTxLockCandidates.end()) { return !itLockCandidate->second.IsAllOutPointsReady() && itLockCandidate->second.IsTimedOut(); } return false; } void CInstantSend::Relay(const uint256& txHash, CConnman& connman) { LOCK(cs_instantsend); std::map<uint256, CTxLockCandidate>::const_iterator itLockCandidate = mapTxLockCandidates.find(txHash); if (itLockCandidate != mapTxLockCandidates.end()) { itLockCandidate->second.Relay(connman); } } void CInstantSend::UpdatedBlockTip(const CBlockIndex *pindex) { nCachedBlockHeight = pindex->nHeight; } void CInstantSend::SyncTransaction(const CTransaction& tx, const CBlock* pblock) { // Update lock candidates and votes if corresponding tx confirmed // or went from confirmed to 0-confirmed or conflicted. if (tx.IsCoinBase()) return; LOCK2(cs_main, cs_instantsend); uint256 txHash = tx.GetHash(); // When tx is 0-confirmed or conflicted, pblock is NULL and nHeightNew should be set to -1 CBlockIndex* pblockindex = NULL; if(pblock) { uint256 blockHash = pblock->GetHash(); BlockMap::iterator mi = mapBlockIndex.find(blockHash); if(mi == mapBlockIndex.end() || !mi->second) { // shouldn't happen LogPrint("instantsend", "CTxLockRequest::SyncTransaction -- Failed to find block %s\n", blockHash.ToString()); return; } pblockindex = mi->second; } int nHeightNew = pblockindex ? pblockindex->nHeight : -1; LogPrint("instantsend", "CInstantSend::SyncTransaction -- txid=%s nHeightNew=%d\n", txHash.ToString(), nHeightNew); // Check lock candidates std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash); if(itLockCandidate != mapTxLockCandidates.end()) { LogPrint("instantsend", "CInstantSend::SyncTransaction -- txid=%s nHeightNew=%d lock candidate updated\n", txHash.ToString(), nHeightNew); itLockCandidate->second.SetConfirmedHeight(nHeightNew); // Loop through outpoint locks std::map<COutPoint, COutPointLock>::iterator itOutpointLock = itLockCandidate->second.mapOutPointLocks.begin(); while(itOutpointLock != itLockCandidate->second.mapOutPointLocks.end()) { // Check corresponding lock votes std::vector<CTxLockVote> vVotes = itOutpointLock->second.GetVotes(); std::vector<CTxLockVote>::iterator itVote = vVotes.begin(); std::map<uint256, CTxLockVote>::iterator it; while(itVote != vVotes.end()) { uint256 nVoteHash = itVote->GetHash(); LogPrint("instantsend", "CInstantSend::SyncTransaction -- txid=%s nHeightNew=%d vote %s updated\n", txHash.ToString(), nHeightNew, nVoteHash.ToString()); it = mapTxLockVotes.find(nVoteHash); if(it != mapTxLockVotes.end()) { it->second.SetConfirmedHeight(nHeightNew); } ++itVote; } ++itOutpointLock; } } // check orphan votes std::map<uint256, CTxLockVote>::iterator itOrphanVote = mapTxLockVotesOrphan.begin(); while(itOrphanVote != mapTxLockVotesOrphan.end()) { if(itOrphanVote->second.GetTxHash() == txHash) { LogPrint("instantsend", "CInstantSend::SyncTransaction -- txid=%s nHeightNew=%d vote %s updated\n", txHash.ToString(), nHeightNew, itOrphanVote->first.ToString()); mapTxLockVotes[itOrphanVote->first].SetConfirmedHeight(nHeightNew); } ++itOrphanVote; } } std::string CInstantSend::ToString() { LOCK(cs_instantsend); return strprintf("Lock Candidates: %llu, Votes %llu", mapTxLockCandidates.size(), mapTxLockVotes.size()); } // // CTxLockRequest // bool CTxLockRequest::IsValid() const { if(vout.size() < 1) return false; if(vin.size() > WARN_MANY_INPUTS) { LogPrint("instantsend", "CTxLockRequest::IsValid -- WARNING: Too many inputs: tx=%s", ToString()); } LOCK(cs_main); if(!CheckFinalTx(*this)) { LogPrint("instantsend", "CTxLockRequest::IsValid -- Transaction is not final: tx=%s", ToString()); return false; } CAmount nValueIn = 0; BOOST_FOREACH(const CTxIn& txin, vin) { Coin coin; if(!GetUTXOCoin(txin.prevout, coin)) { LogPrint("instantsend", "CTxLockRequest::IsValid -- Failed to find UTXO %s\n", txin.prevout.ToStringShort()); return false; } int nTxAge = chainActive.Height() - coin.nHeight + 1; // 1 less than the "send IX" gui requires, in case of a block propagating the network at the time int nConfirmationsRequired = INSTANTSEND_CONFIRMATIONS_REQUIRED - 1; if(nTxAge < nConfirmationsRequired) { LogPrint("instantsend", "CTxLockRequest::IsValid -- outpoint %s too new: nTxAge=%d, nConfirmationsRequired=%d, txid=%s\n", txin.prevout.ToStringShort(), nTxAge, nConfirmationsRequired, GetHash().ToString()); return false; } nValueIn += coin.out.nValue; } if(nValueIn > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) { LogPrint("instantsend", "CTxLockRequest::IsValid -- Transaction value too high: nValueIn=%d, tx=%s", nValueIn, ToString()); return false; } CAmount nValueOut = GetValueOut(); if(nValueIn - nValueOut < GetMinFee()) { LogPrint("instantsend", "CTxLockRequest::IsValid -- did not include enough fees in transaction: fees=%d, tx=%s", nValueOut - nValueIn, ToString()); return false; } return true; } CAmount CTxLockRequest::GetMinFee() const { CAmount nMinFee = MIN_FEE; return std::max(nMinFee, CAmount(vin.size() * nMinFee)); } int CTxLockRequest::GetMaxSignatures() const { return vin.size() * COutPointLock::SIGNATURES_TOTAL; } // // CTxLockVote // bool CTxLockVote::IsValid(CNode* pnode, CConnman& connman) const { if(!mnodeman.Has(outpointMasternode)) { LogPrint("instantsend", "CTxLockVote::IsValid -- Unknown masternode %s\n", outpointMasternode.ToStringShort()); mnodeman.AskForMN(pnode, outpointMasternode, connman); return false; } Coin coin; if(!GetUTXOCoin(outpoint, coin)) { LogPrint("instantsend", "CTxLockVote::IsValid -- Failed to find UTXO %s\n", outpoint.ToStringShort()); return false; } int nLockInputHeight = coin.nHeight + 4; int nRank; if(!mnodeman.GetMasternodeRank(outpointMasternode, nRank, nLockInputHeight, MIN_INSTANTSEND_PROTO_VERSION)) { //can be caused by past versions trying to vote with an invalid protocol LogPrint("instantsend", "CTxLockVote::IsValid -- Can't calculate rank for masternode %s\n", outpointMasternode.ToStringShort()); return false; } LogPrint("instantsend", "CTxLockVote::IsValid -- Masternode %s, rank=%d\n", outpointMasternode.ToStringShort(), nRank); int nSignaturesTotal = COutPointLock::SIGNATURES_TOTAL; if(nRank > nSignaturesTotal) { LogPrint("instantsend", "CTxLockVote::IsValid -- Masternode %s is not in the top %d (%d), vote hash=%s\n", outpointMasternode.ToStringShort(), nSignaturesTotal, nRank, GetHash().ToString()); return false; } if(!CheckSignature()) { LogPrintf("CTxLockVote::IsValid -- Signature invalid\n"); return false; } return true; } uint256 CTxLockVote::GetHash() const { CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); ss << txHash; ss << outpoint; ss << outpointMasternode; return ss.GetHash(); } bool CTxLockVote::CheckSignature() const { std::string strError; std::string strMessage = txHash.ToString() + outpoint.ToStringShort(); masternode_info_t infoMn; if(!mnodeman.GetMasternodeInfo(outpointMasternode, infoMn)) { LogPrintf("CTxLockVote::CheckSignature -- Unknown Masternode: masternode=%s\n", outpointMasternode.ToString()); return false; } if(!CMessageSigner::VerifyMessage(infoMn.pubKeyMasternode, vchMasternodeSignature, strMessage, strError)) { LogPrintf("CTxLockVote::CheckSignature -- VerifyMessage() failed, error: %s\n", strError); return false; } return true; } bool CTxLockVote::Sign() { std::string strError; std::string strMessage = txHash.ToString() + outpoint.ToStringShort(); if(!CMessageSigner::SignMessage(strMessage, vchMasternodeSignature, activeMasternode.keyMasternode)) { LogPrintf("CTxLockVote::Sign -- SignMessage() failed\n"); return false; } if(!CMessageSigner::VerifyMessage(activeMasternode.pubKeyMasternode, vchMasternodeSignature, strMessage, strError)) { LogPrintf("CTxLockVote::Sign -- VerifyMessage() failed, error: %s\n", strError); return false; } return true; } void CTxLockVote::Relay(CConnman& connman) const { CInv inv(MSG_TXLOCK_VOTE, GetHash()); connman.RelayInv(inv); } bool CTxLockVote::IsExpired(int nHeight) const { // Locks and votes expire nInstantSendKeepLock blocks after the block corresponding tx was included into. return (nConfirmedHeight != -1) && (nHeight - nConfirmedHeight > Params().GetConsensus().nInstantSendKeepLock); } bool CTxLockVote::IsTimedOut() const { return GetTime() - nTimeCreated > INSTANTSEND_LOCK_TIMEOUT_SECONDS; } bool CTxLockVote::IsFailed() const { return (GetTime() - nTimeCreated > INSTANTSEND_FAILED_TIMEOUT_SECONDS) && !instantsend.IsLockedInstantSendTransaction(GetTxHash()); } // // COutPointLock // bool COutPointLock::AddVote(const CTxLockVote& vote) { if(mapMasternodeVotes.count(vote.GetMasternodeOutpoint())) return false; mapMasternodeVotes.insert(std::make_pair(vote.GetMasternodeOutpoint(), vote)); return true; } std::vector<CTxLockVote> COutPointLock::GetVotes() const { std::vector<CTxLockVote> vRet; std::map<COutPoint, CTxLockVote>::const_iterator itVote = mapMasternodeVotes.begin(); while(itVote != mapMasternodeVotes.end()) { vRet.push_back(itVote->second); ++itVote; } return vRet; } bool COutPointLock::HasMasternodeVoted(const COutPoint& outpointMasternodeIn) const { return mapMasternodeVotes.count(outpointMasternodeIn); } void COutPointLock::Relay(CConnman& connman) const { std::map<COutPoint, CTxLockVote>::const_iterator itVote = mapMasternodeVotes.begin(); while(itVote != mapMasternodeVotes.end()) { itVote->second.Relay(connman); ++itVote; } } // // CTxLockCandidate // void CTxLockCandidate::AddOutPointLock(const COutPoint& outpoint) { mapOutPointLocks.insert(make_pair(outpoint, COutPointLock(outpoint))); } void CTxLockCandidate::MarkOutpointAsAttacked(const COutPoint& outpoint) { std::map<COutPoint, COutPointLock>::iterator it = mapOutPointLocks.find(outpoint); if(it != mapOutPointLocks.end()) it->second.MarkAsAttacked(); } bool CTxLockCandidate::AddVote(const CTxLockVote& vote) { std::map<COutPoint, COutPointLock>::iterator it = mapOutPointLocks.find(vote.GetOutpoint()); if(it == mapOutPointLocks.end()) return false; return it->second.AddVote(vote); } bool CTxLockCandidate::IsAllOutPointsReady() const { if(mapOutPointLocks.empty()) return false; std::map<COutPoint, COutPointLock>::const_iterator it = mapOutPointLocks.begin(); while(it != mapOutPointLocks.end()) { if(!it->second.IsReady()) return false; ++it; } return true; } bool CTxLockCandidate::HasMasternodeVoted(const COutPoint& outpointIn, const COutPoint& outpointMasternodeIn) { std::map<COutPoint, COutPointLock>::iterator it = mapOutPointLocks.find(outpointIn); return it !=mapOutPointLocks.end() && it->second.HasMasternodeVoted(outpointMasternodeIn); } int CTxLockCandidate::CountVotes() const { // Note: do NOT use vote count to figure out if tx is locked, use IsAllOutPointsReady() instead int nCountVotes = 0; std::map<COutPoint, COutPointLock>::const_iterator it = mapOutPointLocks.begin(); while(it != mapOutPointLocks.end()) { nCountVotes += it->second.CountVotes(); ++it; } return nCountVotes; } bool CTxLockCandidate::IsExpired(int nHeight) const { // Locks and votes expire nInstantSendKeepLock blocks after the block corresponding tx was included into. return (nConfirmedHeight != -1) && (nHeight - nConfirmedHeight > Params().GetConsensus().nInstantSendKeepLock); } bool CTxLockCandidate::IsTimedOut() const { return GetTime() - nTimeCreated > INSTANTSEND_LOCK_TIMEOUT_SECONDS; } void CTxLockCandidate::Relay(CConnman& connman) const { connman.RelayTransaction(txLockRequest); std::map<COutPoint, COutPointLock>::const_iterator itOutpointLock = mapOutPointLocks.begin(); while(itOutpointLock != mapOutPointLocks.end()) { itOutpointLock->second.Relay(connman); ++itOutpointLock; } }
/*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include <berryISelectionService.h> #include <berryIWorkbenchWindow.h> // Qmitk #include "MyView.h" // Qt #include <QMessageBox> // mitk image #include <mitkImage.h> const std::string MyView::VIEW_ID = "org.mitk.views.myview"; void MyView::SetFocus() { m_Controls.buttonPerformImageProcessing->setFocus(); } void MyView::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); connect(m_Controls.buttonPerformImageProcessing, &QPushButton::clicked, this, &MyView::DoImageProcessing); } void MyView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*source*/, const QList<mitk::DataNode::Pointer> &nodes) { // iterate all selected objects, adjust warning visibility foreach (mitk::DataNode::Pointer node, nodes) { if (node.IsNotNull() && dynamic_cast<mitk::Image *>(node->GetData())) { m_Controls.labelWarning->setVisible(false); m_Controls.buttonPerformImageProcessing->setEnabled(true); return; } } m_Controls.labelWarning->setVisible(true); m_Controls.buttonPerformImageProcessing->setEnabled(false); } void MyView::DoImageProcessing() { QList<mitk::DataNode::Pointer> nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode *node = nodes.front(); if (!node) { // Nothing selected. Inform the user and return QMessageBox::information(nullptr, "Template", "Please load and select an image before starting image processing."); return; } // here we have a valid mitk::DataNode // a node itself is not very useful, we need its data item (the image) mitk::BaseData *data = node->GetData(); if (data) { // test if this data item is an image or not (could also be a surface or something totally different) mitk::Image *image = dynamic_cast<mitk::Image *>(data); if (image) { std::stringstream message; std::string name; message << "Performing image processing for image "; if (node->GetName(name)) { // a property called "name" was found for this DataNode message << "'" << name << "'"; } message << "."; MITK_INFO << message.str(); // actually do something here... } } }
; A003148: a(n+1) = a(n) + 2n*(2n+1)*a(n-1), with a(0) = a(1) = 1. ; Submitted by Jamie Morken(s4) ; 1,1,7,27,321,2265,37575,390915,8281665,114610545,2946939975,51083368875,1542234996225,32192256321225,1114841223671175,27254953356505875,1064057291370698625,29845288035840902625,1296073464766972266375,41049997128507054562875,1961830871913159953330625,69283826162664729436445625,3612350380837831605151554375,140794326182913995889313891875,7950695849554305926226974450625,339098951031768024257893248140625,20613373367395248136136678097234375,955170082410947922990890469972796875 mov $3,1 lpb $0 mov $2,$3 add $3,$1 mov $1,$0 sub $0,1 add $1,$0 bin $1,2 mul $2,2 mul $1,$2 lpe mov $0,$3
; A112414: 3n+7. ; 7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58,61,64,67,70,73,76,79,82,85,88,91,94,97,100,103,106,109,112,115,118,121,124,127,130,133,136,139,142,145,148,151,154,157,160,163,166,169,172,175,178,181,184 mul $0,3 add $0,7
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld b, 97 call lwaitly_b ld a, 99 ldff(45), a ld a, 40 ldff(41), a ld a, 00 ld(8000), a ld a, 01 ld(c000), a ld a, c0 ldff(51), a xor a, a ldff(52), a ldff(54), a ld a, 80 ldff(53), a xor a, a ldff(0f), a ld a, 02 ldff(ff), a ei ld hl, 8000 halt .text@1000 lstatint: ld b, 03 ld a, 00 ldff(55), a .text@109b ldff a, (41) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
/* * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <cugraph/graph.hpp> #include <cugraph/graph_generators.hpp> #include <cugraph/legacy/graph.hpp> #include <cugraph/utilities/graph_traits.hpp> #include <raft/handle.hpp> #include <rmm/device_uvector.hpp> namespace cugraph { namespace cython { enum class numberTypeEnum : int { int32Type, int64Type, floatType, doubleType }; enum class graphTypeEnum : int { // represents unintiialized or NULL ptr null, // represents some legacy Cxx type. This and other LegacyCxx values are not // used for the unique_ptr in a graph_container_t, but instead for when this // enum is used for determining high-level code paths to take to prevent // needing to expose each legacy enum value to cython. LegacyCSR, LegacyCSC, LegacyCOO, // represents that a GraphCxxView* unique_ptr type is present in a // graph_container_t. GraphCSRViewFloat, GraphCSRViewDouble, GraphCSCViewFloat, GraphCSCViewDouble, GraphCOOViewFloat, GraphCOOViewDouble, // represents values present in the graph_container_t to construct a graph_t, // but unlike legacy classes does not mean a graph_t unique_ptr is present in // the container. graph_t, }; // "container" for a graph type instance which insulates the owner from the // specifics of the actual graph type. This is intended to be used in Cython // code that only needs to pass a graph object to another wrapped C++ API. This // greatly simplifies the Cython code since the Cython definition only needs to // define the container and not the various individual graph types in Cython. struct graph_container_t { // FIXME: This union is in place only to support legacy calls, remove when // migration to graph_t types is complete, or when legacy graph objects are // constructed in the call_<<algo> wrappers instead of the // populate_graph_container_legacy() function. union graphPtrUnion { ~graphPtrUnion() {} void* null; std::unique_ptr<legacy::GraphCSRView<int32_t, int32_t, float>> GraphCSRViewFloatPtr; std::unique_ptr<legacy::GraphCSRView<int32_t, int32_t, double>> GraphCSRViewDoublePtr; std::unique_ptr<legacy::GraphCSCView<int32_t, int32_t, float>> GraphCSCViewFloatPtr; std::unique_ptr<legacy::GraphCSCView<int32_t, int32_t, double>> GraphCSCViewDoublePtr; std::unique_ptr<legacy::GraphCOOView<int32_t, int32_t, float>> GraphCOOViewFloatPtr; std::unique_ptr<legacy::GraphCOOView<int32_t, int32_t, double>> GraphCOOViewDoublePtr; }; graph_container_t() : graph_ptr_union{nullptr}, graph_type{graphTypeEnum::null} {} ~graph_container_t() {} // The expected usage of a graph_container_t is for it to be created as part // of a cython wrapper simply for passing a templated instantiation of a // particular graph class from one call to another, and not to exist outside // of the individual wrapper function (deleted when the instance goes out of // scope once the wrapper function returns). Therefore, copys and assignments // to an instance are not supported and these methods are deleted. graph_container_t(const graph_container_t&) = delete; graph_container_t& operator=(const graph_container_t&) = delete; graphPtrUnion graph_ptr_union; graphTypeEnum graph_type; // primitive data used for constructing graph_t instances. void* src_vertices; void* dst_vertices; void* weights; bool is_weighted; void* vertex_partition_offsets; void* segment_offsets; size_t num_segments; size_t num_local_edges; size_t num_global_vertices; size_t num_global_edges; numberTypeEnum vertexType; numberTypeEnum edgeType; numberTypeEnum weightType; bool transposed; bool is_multi_gpu; bool do_expensive_check; int row_comm_size; int col_comm_size; int row_comm_rank; int col_comm_rank; graph_properties_t graph_props; }; /** * @brief Owning struct. Allows returning multiple edge lists and edge offsets. * cython only * * @param number_of_vertices The total number of vertices * @param number_of_edges The total number of edges (number of elements in src_indices, dst_indices and edge_data) * @param number_of_subgraph The number of subgraphs, number of elements in subgraph_offsets - 1 * @param source_indices This array of size E (number of edges) contains * the index of the * source for each edge. Indices must be in the range [0, V-1]. * @param destination_indices This array of size E (number of edges) contains * the index of the * destination for each edge. Indices must be in the range [0, V-1]. * @param edge_data This array size E (number of edges) contains * the weight for each * edge. This array can be null in which case the graph is considered * unweighted. * @param subgraph_offsets This array size number_of_subgraph + 1 contains edge offsets for each subgraph */ struct cy_multi_edgelists_t { size_t number_of_vertices; size_t number_of_edges; size_t number_of_subgraph; std::unique_ptr<rmm::device_buffer> src_indices; std::unique_ptr<rmm::device_buffer> dst_indices; std::unique_ptr<rmm::device_buffer> edge_data; std::unique_ptr<rmm::device_buffer> subgraph_offsets; }; // replacement for std::tuple<,,>, since std::tuple is not // supported in cython // template <typename vertex_t, typename edge_t, typename weight_t> struct major_minor_weights_t { explicit major_minor_weights_t(raft::handle_t const& handle) : shuffled_major_vertices_(0, handle.get_stream()), shuffled_minor_vertices_(0, handle.get_stream()), shuffled_weights_(0, handle.get_stream()) { } rmm::device_uvector<vertex_t>& get_major(void) { return shuffled_major_vertices_; } rmm::device_uvector<vertex_t>& get_minor(void) { return shuffled_minor_vertices_; } rmm::device_uvector<weight_t>& get_weights(void) { return shuffled_weights_; } std::vector<edge_t>& get_edge_counts(void) { return edge_counts_; } std::pair<std::unique_ptr<rmm::device_buffer>, size_t> get_major_wrap( void) // const: triggers errors in Cython autogen-ed C++ { return std::make_pair(std::make_unique<rmm::device_buffer>(shuffled_major_vertices_.release()), sizeof(vertex_t)); } std::pair<std::unique_ptr<rmm::device_buffer>, size_t> get_minor_wrap(void) // const { return std::make_pair(std::make_unique<rmm::device_buffer>(shuffled_minor_vertices_.release()), sizeof(vertex_t)); } std::pair<std::unique_ptr<rmm::device_buffer>, size_t> get_weights_wrap(void) // const { return std::make_pair(std::make_unique<rmm::device_buffer>(shuffled_weights_.release()), sizeof(weight_t)); } std::unique_ptr<std::vector<edge_t>> get_edge_counts_wrap(void) // const { return std::make_unique<std::vector<edge_t>>(edge_counts_); } private: rmm::device_uvector<vertex_t> shuffled_major_vertices_; rmm::device_uvector<vertex_t> shuffled_minor_vertices_; rmm::device_uvector<weight_t> shuffled_weights_; std::vector<edge_t> edge_counts_{}; }; // aggregate for random_walks() return type // to be exposed to cython: // struct random_walk_ret_t { size_t coalesced_sz_v_; size_t coalesced_sz_w_; size_t num_paths_; size_t max_depth_; std::unique_ptr<rmm::device_buffer> d_coalesced_v_; std::unique_ptr<rmm::device_buffer> d_coalesced_w_; std::unique_ptr<rmm::device_buffer> d_sizes_; }; struct random_walk_path_t { std::unique_ptr<rmm::device_buffer> d_v_offsets; std::unique_ptr<rmm::device_buffer> d_w_sizes; std::unique_ptr<rmm::device_buffer> d_w_offsets; }; struct graph_generator_t { std::unique_ptr<rmm::device_buffer> d_source; std::unique_ptr<rmm::device_buffer> d_destination; }; // enum class generator_distribution_t { POWER_LAW = 0, UNIFORM }; // aggregate for random_walks() COO return type // to be exposed to cython: // struct random_walk_coo_t { size_t num_edges_; // total number of COO triplets (for all paths) size_t num_offsets_; // offsets of where each COO set starts for each path; // NOTE: this can differ than num_paths_, // because paths with 0 edges (one vertex) // don't participate to the COO std::unique_ptr<rmm::device_buffer> d_src_; // coalesced set of COO source vertices; |d_src_| = num_edges_ std::unique_ptr<rmm::device_buffer> d_dst_; // coalesced set of COO destination vertices; |d_dst_| = num_edges_ std::unique_ptr<rmm::device_buffer> d_weights_; // coalesced set of COO edge weights; |d_weights_| = num_edges_ std::unique_ptr<rmm::device_buffer> d_offsets_; // offsets where each COO subset for each path starts; |d_offsets_| = num_offsets_ }; // wrapper for renumber_edgelist() return // (unrenumbering maps, etc.) // template <typename vertex_t, typename edge_t> struct renum_tuple_t { explicit renum_tuple_t(raft::handle_t const& handle) : dv_(0, handle.get_stream()), part_() {} rmm::device_uvector<vertex_t>& get_dv(void) { return dv_; } std::pair<std::unique_ptr<rmm::device_buffer>, size_t> get_dv_wrap( void) // const: see above explanation { return std::make_pair(std::make_unique<rmm::device_buffer>(dv_.release()), sizeof(vertex_t)); } cugraph::partition_t<vertex_t>& get_partition(void) { return part_; } vertex_t& get_num_vertices(void) { return nv_; } edge_t& get_num_edges(void) { return ne_; } std::vector<vertex_t>& get_segment_offsets(void) { return segment_offsets_; } std::unique_ptr<std::vector<vertex_t>> get_segment_offsets_wrap() { // const return std::make_unique<std::vector<vertex_t>>(segment_offsets_); } // `partition_t` pass-through getters // int get_part_row_size() const { return part_.get_row_size(); } int get_part_col_size() const { return part_.get_col_size(); } int get_part_comm_rank() const { return part_.get_comm_rank(); } // FIXME: part_.get_vertex_partition_offsets() returns a std::vector // std::unique_ptr<std::vector<vertex_t>> get_partition_offsets_wrap(void) // const { return std::make_unique<std::vector<vertex_t>>(part_.get_vertex_partition_offsets()); } std::pair<vertex_t, vertex_t> get_part_local_vertex_range() const { auto tpl_v = part_.get_local_vertex_range(); return std::make_pair(std::get<0>(tpl_v), std::get<1>(tpl_v)); } vertex_t get_part_local_vertex_first() const { return part_.get_local_vertex_first(); } vertex_t get_part_local_vertex_last() const { return part_.get_local_vertex_last(); } std::pair<vertex_t, vertex_t> get_part_vertex_partition_range(size_t vertex_partition_idx) const { auto tpl_v = part_.get_vertex_partition_range(vertex_partition_idx); return std::make_pair(std::get<0>(tpl_v), std::get<1>(tpl_v)); } vertex_t get_part_vertex_partition_first(size_t vertex_partition_idx) const { return part_.get_vertex_partition_first(vertex_partition_idx); } vertex_t get_part_vertex_partition_last(size_t vertex_partition_idx) const { return part_.get_vertex_partition_last(vertex_partition_idx); } vertex_t get_part_vertex_partition_size(size_t vertex_partition_idx) const { return part_.get_vertex_partition_size(vertex_partition_idx); } size_t get_part_number_of_matrix_partitions() const { return part_.get_number_of_matrix_partitions(); } std::pair<vertex_t, vertex_t> get_part_matrix_partition_major_range(size_t partition_idx) const { auto tpl_v = part_.get_matrix_partition_major_range(partition_idx); return std::make_pair(std::get<0>(tpl_v), std::get<1>(tpl_v)); } vertex_t get_part_matrix_partition_major_first(size_t partition_idx) const { return part_.get_matrix_partition_major_first(partition_idx); } vertex_t get_part_matrix_partition_major_last(size_t partition_idx) const { return part_.get_matrix_partition_major_last(partition_idx); } vertex_t get_part_matrix_partition_major_value_start_offset(size_t partition_idx) const { return part_.get_part_matrix_partition_major_value_start_offset(partition_idx); } std::pair<vertex_t, vertex_t> get_part_matrix_partition_minor_range() const { auto tpl_v = part_.get_matrix_partition_minor_range(); return std::make_pair(std::get<0>(tpl_v), std::get<1>(tpl_v)); } vertex_t get_part_matrix_partition_minor_first() const { return part_.get_matrix_partition_minor_first(); } vertex_t get_part_matrix_partition_minor_last() const { return part_.get_matrix_partition_minor_last(); } private: rmm::device_uvector<vertex_t> dv_; cugraph::partition_t<vertex_t> part_; vertex_t nv_{0}; edge_t ne_{0}; std::vector<vertex_t> segment_offsets_; }; // FIXME: finish description for vertex_partition_offsets // // Factory function for populating an empty graph container with a new graph // object from basic types, and sets the corresponding meta-data. Args are: // // graph_container_t& graph_container // Reference to the graph_container_t instance to // populate. populate_graph_container() can only be called on an "empty" // container (ie. a container that has not been previously populated by // populate_graph_container()) // // graphTypeEnum legacyType // Specifies the type of graph when instantiating a legacy graph type // (GraphCSRViewFloat, etc.). // NOTE: this parameter will be removed when the transition to exclusinve use // of the new 2D graph classes is complete. // // raft::handle_t const& handle // Raft handle to be set on the new graph instance in the container // // void* src_vertices, dst_vertices, weights // Pointer to an array of values representing source and destination vertices, // and edge weights respectively. The value types of the array are specified // using numberTypeEnum values separately (see below). offsets should be size // num_vertices+1, indices should be size num_edges, weights should also be // size num_edges // // void* vertex_partition_offsets // Pointer to an array of vertexType values representing offsets into the // individual partitions for a multi-GPU paritioned graph. The offsets are used for ... // // numberTypeEnum vertexType, edgeType, weightType // numberTypeEnum enum value describing the data type for the vertices, // offsets, and weights arrays respectively. These enum values are used to // instantiate the proper templated graph type and for casting the arrays // accordingly. // // int num_vertices, num_edges // The number of vertices and edges respectively in the graph represented by // the above arrays. // // bool is_weighted // true if the resulting graph object should store edge weights // // bool transposed // true if the resulting graph object should store a transposed adjacency // matrix // // bool multi_gpu // true if the resulting graph object is to be used for a multi-gpu // application void populate_graph_container(graph_container_t& graph_container, raft::handle_t& handle, void* src_vertices, void* dst_vertices, void* weights, void* vertex_partition_offsets, void* segment_offsets, size_t num_segments, numberTypeEnum vertexType, numberTypeEnum edgeType, numberTypeEnum weightType, size_t num_local_edges, size_t num_global_vertices, size_t num_global_edges, bool is_weighted, bool is_symmetric, bool transposed, bool multi_gpu); // FIXME: comment this function // FIXME: Should local_* values be void* as well? void populate_graph_container_legacy(graph_container_t& graph_container, graphTypeEnum legacyType, raft::handle_t const& handle, void* offsets, void* indices, void* weights, numberTypeEnum offsetType, numberTypeEnum indexType, numberTypeEnum weightType, size_t num_global_vertices, size_t num_global_edges, int* local_vertices, int* local_edges, int* local_offsets); // Wrapper for calling Louvain using a graph container template <typename weight_t> std::pair<size_t, weight_t> call_louvain(raft::handle_t const& handle, graph_container_t const& graph_container, void* identifiers, void* parts, size_t max_level, weight_t resolution); // Wrapper for calling Pagerank using a graph container template <typename vertex_t, typename weight_t> void call_pagerank(raft::handle_t const& handle, graph_container_t const& graph_container, vertex_t* identifiers, weight_t* pagerank, vertex_t personalization_subset_size, vertex_t* personalization_subset, weight_t* personalization_values, double alpha, double tolerance, int64_t max_iter, bool has_guess); // Wrapper for calling Katz centrality using a graph container template <typename vertex_t, typename weight_t> void call_katz_centrality(raft::handle_t const& handle, graph_container_t const& graph_container, vertex_t* identifiers, weight_t* katz_centrality, double alpha, double beta, double tolerance, int64_t max_iter, bool normalized, bool has_guess); // Wrapper for calling BFS through a graph container template <typename vertex_t, typename weight_t> void call_bfs(raft::handle_t const& handle, graph_container_t const& graph_container, vertex_t* identifiers, vertex_t* distances, vertex_t* predecessors, vertex_t depth_limit, vertex_t* sources, size_t n_sources, bool direction_optimizing); // Wrapper for calling SSSP through a graph container template <typename vertex_t, typename weight_t> void call_sssp(raft::handle_t const& handle, graph_container_t const& graph_container, vertex_t* identifiers, weight_t* distances, vertex_t* predecessors, const vertex_t source_vertex); // Wrapper for calling egonet through a graph container template <typename vertex_t, typename weight_t> std::unique_ptr<cy_multi_edgelists_t> call_egonet(raft::handle_t const& handle, graph_container_t const& graph_container, vertex_t* source_vertex, vertex_t n_subgraphs, vertex_t radius); // Wrapper for calling WCC through a graph container template <typename vertex_t, typename weight_t> void call_wcc(raft::handle_t const& handle, graph_container_t const& graph_container, vertex_t* components); // Wrapper for calling HITS through a graph container template <typename vertex_t, typename weight_t> void call_hits(raft::handle_t const& handle, graph_container_t const& graph_container, weight_t* hubs, weight_t* authorities, size_t max_iter, weight_t tolerance, const weight_t* starting_value, bool normalized); // Wrapper for calling graph generator template <typename vertex_t> std::unique_ptr<graph_generator_t> call_generate_rmat_edgelist(raft::handle_t const& handle, size_t scale, size_t num_edges, double a, double b, double c, uint64_t seed, bool clip_and_flip, bool scramble_vertex_ids); template <typename vertex_t> std::vector<std::pair<std::unique_ptr<rmm::device_buffer>, std::unique_ptr<rmm::device_buffer>>> call_generate_rmat_edgelists(raft::handle_t const& handle, size_t n_edgelists, size_t min_scale, size_t max_scale, size_t edge_factor, cugraph::generator_distribution_t size_distribution, cugraph::generator_distribution_t edge_distribution, uint64_t seed, bool clip_and_flip, bool scramble_vertex_ids); // wrapper for random_walks. // template <typename vertex_t, typename edge_t> std::enable_if_t<cugraph::is_vertex_edge_combo<vertex_t, edge_t>::value, std::unique_ptr<random_walk_ret_t>> call_random_walks(raft::handle_t const& handle, graph_container_t const& graph_container, vertex_t const* ptr_start_set, edge_t num_paths, edge_t max_depth, bool use_padding); template <typename index_t> std::unique_ptr<random_walk_path_t> call_rw_paths(raft::handle_t const& handle, index_t num_paths, index_t const* vertex_path_sizes); // convertor from random_walks return type to COO: // template <typename vertex_t, typename index_t> std::unique_ptr<random_walk_coo_t> random_walks_to_coo(raft::handle_t const& handle, random_walk_ret_t& rw_ret); // wrapper for shuffling: // template <typename vertex_t, typename edge_t, typename weight_t> std::unique_ptr<major_minor_weights_t<vertex_t, edge_t, weight_t>> call_shuffle( raft::handle_t const& handle, vertex_t* edgelist_major_vertices, // [IN / OUT]: groupby_gpu_id_and_shuffle_values() sorts in-place vertex_t* edgelist_minor_vertices, // [IN / OUT] weight_t* edgelist_weights, // [IN / OUT] edge_t num_edgelist_edges); // Wrapper for calling renumber_edeglist() inplace: // template <typename vertex_t, typename edge_t> std::unique_ptr<renum_tuple_t<vertex_t, edge_t>> call_renumber( raft::handle_t const& handle, vertex_t* shuffled_edgelist_src_vertices /* [INOUT] */, vertex_t* shuffled_edgelist_dst_vertices /* [INOUT] */, std::vector<edge_t> const& edge_counts, bool store_transposed, bool do_expensive_check, bool multi_gpu); // Helper for setting up subcommunicators, typically called as part of the // user-initiated comms initialization in Python. // // raft::handle_t& handle // Raft handle for which the new subcommunicators will be created. The // subcommunicators will then be accessible from the handle passed to the // parallel processes. // // size_t row_comm_size // Number of items in a partition row (ie. pcols), needed for creating the // appropriate number of subcommunicator instances. void init_subcomms(raft::handle_t& handle, size_t row_comm_size); } // namespace cython } // namespace cugraph
; A095694: T(n,3) diagonal of triangle in A095693. ; Submitted by Jon Maiga ; 1,22,130,485,1400,3416,7392,14610,26895,46750,77506,123487,190190,284480,414800,591396,826557,1134870,1533490,2042425,2684836,3487352,4480400 add $0,3 mov $1,$0 bin $0,2 bin $0,3 bin $1,4 mul $1,2 add $1,$0 mov $0,$1
; A048695: Generalized Pellian with second term equal to 8. ; 1,8,17,42,101,244,589,1422,3433,8288,20009,48306,116621,281548,679717,1640982,3961681,9564344,23090369,55745082,134580533,324906148,784392829,1893691806,4571776441,11037244688 lpb $0,1 sub $0,1 add $5,1 mov $2,$5 add $2,5 mov $3,$2 add $3,3 mov $1,$3 add $3,4 add $5,$4 mov $4,$3 sub $4,6 trn $5,4 add $5,$1 mov $1,$4 add $4,3 lpe add $1,1
; Verified: ; 2021-10-21 pass: CPU CGB E - CPU-CGB-06 ; 2021-10-21 fail: CPU CGB B - CPU-CGB-02 ; 2021-10-21 fail: DMG-CPU C (blob) - DMG-CPU-08 ; INCLUDE "hardware.inc" DEF CART_COMPATIBILITY EQU CART_COMPATIBLE_DMG DEF CART_REQUIRES_NON_CGB_MODE EQU 1 DEF EXTEND_L99 EQU 1 INCLUDE "ly/ly.inc"
// Copyright (c) 2018-2021 Pocketnet developers // Distributed under the Apache 2.0 software license, see the accompanying // https://www.apache.org/licenses/LICENSE-2.0 #include "pocketdb/repositories/ChainRepository.h" namespace PocketDb { void ChainRepository::IndexBlock(const string& blockHash, int height, vector<TransactionIndexingInfo>& txs) { TryTransactionStep(__func__, [&]() { int64_t nTime1 = GetTimeMicros(); // Each transaction is processed individually for (const auto& txInfo : txs) { // All transactions must have a blockHash & height relation UpdateTransactionHeight(blockHash, txInfo.BlockNumber, height, txInfo.Hash); // The outputs are needed for the explorer UpdateTransactionOutputs(txInfo, height); // Account and Content must have unique ID // Also all edited transactions must have Last=(0/1) field { if (txInfo.IsAccount()) IndexAccount(txInfo.Hash); if (txInfo.IsContent()) IndexContent(txInfo.Hash); if (txInfo.IsComment()) IndexComment(txInfo.Hash); if (txInfo.IsBlocking()) IndexBlocking(txInfo.Hash); if (txInfo.IsSubscribe()) IndexSubscribe(txInfo.Hash); } } int64_t nTime2 = GetTimeMicros(); // After set height and mark inputs as spent we need recalculcate balances IndexBalances(height); int64_t nTime3 = GetTimeMicros(); LogPrint(BCLog::BENCH, " - IndexBlock: %.2fms + %.2fms = %.2fms\n", 0.001 * double(nTime2 - nTime1), 0.001 * double(nTime3 - nTime2), 0.001 * double(nTime3 - nTime1) ); }); } bool ChainRepository::ClearDatabase() { LogPrintf("Full reindexing database. This can take several days.\n"); LogPrintf("Deleting database indexes..\n"); m_database.DropIndexes(); LogPrintf("Rollback to first block..\n"); RollbackHeight(0); m_database.CreateStructure(); return true; } bool ChainRepository::Rollback(int height) { try { // Update transactions TryTransactionStep(__func__, [&]() { RestoreOldLast(height); RollbackHeight(height); }); return true; } catch (std::exception& ex) { LogPrintf("Error: Rollback to height %d failed with message: %s\n", height, ex.what()); return false; } } tuple<bool, bool> ChainRepository::ExistsBlock(const string& blockHash, int height) { bool exists = false; bool last = true; string sql = R"sql( select ifnull((select 1 from Transactions where BlockHash = ? and Height = ? limit 1), 0)current, ifnull((select 1 from Transactions where Height = ? limit 1), 0)next )sql"; TryTransactionStep(__func__, [&]() { auto stmt = SetupSqlStatement(sql); TryBindStatementText(stmt, 1, blockHash); TryBindStatementInt(stmt, 2, height); TryBindStatementInt(stmt, 3, height + 1); if (sqlite3_step(*stmt) == SQLITE_ROW) { if (auto[ok, value] = TryGetColumnInt(*stmt, 0); ok && value == 1) exists = true; if (auto[ok, value] = TryGetColumnInt(*stmt, 1); ok && value == 1) last = false; } FinalizeSqlStatement(*stmt); }); return {exists, last}; } void ChainRepository::UpdateTransactionHeight(const string& blockHash, int blockNumber, int height, const string& txHash) { auto stmt = SetupSqlStatement(R"sql( UPDATE Transactions SET BlockHash = ?, BlockNum = ?, Height = ? WHERE Hash = ? )sql"); TryBindStatementText(stmt, 1, blockHash); TryBindStatementInt(stmt, 2, blockNumber); TryBindStatementInt(stmt, 3, height); TryBindStatementText(stmt, 4, txHash); TryStepStatement(stmt); auto stmtOuts = SetupSqlStatement(R"sql( UPDATE TxOutputs SET TxHeight = ? WHERE TxHash = ? )sql"); TryBindStatementInt(stmtOuts, 1, height); TryBindStatementText(stmtOuts, 2, txHash); TryStepStatement(stmtOuts); } void ChainRepository::UpdateTransactionOutputs(const TransactionIndexingInfo& txInfo, int height) { for (auto& input : txInfo.Inputs) { auto stmt = SetupSqlStatement(R"sql( UPDATE TxOutputs SET SpentHeight = ?, SpentTxHash = ? WHERE TxHash = ? and Number = ? )sql"); TryBindStatementInt(stmt, 1, height); TryBindStatementText(stmt, 2, txInfo.Hash); TryBindStatementText(stmt, 3, input.first); TryBindStatementInt(stmt, 4, input.second); TryStepStatement(stmt); } } void ChainRepository::IndexBalances(int height) { // Generate new balance records auto stmt = SetupSqlStatement(R"sql( insert into Balances (AddressHash, Last, Height, Value) select saldo.AddressHash, 1, ?, sum(ifnull(saldo.Amount,0)) + ifnull(b.Value,0) from ( select 'unspent', o.AddressHash, sum(o.Value)Amount from TxOutputs o indexed by TxOutputs_TxHeight_AddressHash where o.TxHeight = ? group by o.AddressHash union select 'spent', o.AddressHash, -sum(o.Value)Amount from TxOutputs o indexed by TxOutputs_SpentHeight_AddressHash where o.SpentHeight = ? group by o.AddressHash ) saldo left join Balances b indexed by Balances_AddressHash_Last on b.AddressHash = saldo.AddressHash and b.Last = 1 group by saldo.AddressHash )sql"); TryBindStatementInt(stmt, 1, height); TryBindStatementInt(stmt, 2, height); TryBindStatementInt(stmt, 3, height); TryStepStatement(stmt); // Remove old Last records auto stmtOld = SetupSqlStatement(R"sql( update Balances indexed by Balances_AddressHash_Last_Height set Last = 0 where Balances.Last = 1 and Balances.Height < ? and Balances.AddressHash in ( select b.AddressHash from Balances b indexed by Balances_Height where b.Height = ? ) )sql"); TryBindStatementInt(stmtOld, 1, height); TryBindStatementInt(stmtOld, 2, height); TryStepStatement(stmtOld); } void ChainRepository::IndexAccount(const string& txHash) { // Get new ID or copy previous auto setIdStmt = SetupSqlStatement(R"sql( UPDATE Transactions SET Id = ifnull( -- copy self Id ( select a.Id from Transactions a indexed by Transactions_Type_Last_String1_Height_Id where a.Type in (Transactions.Type) and a.Last = 1 -- String1 = AddressHash and a.String1 = Transactions.String1 and a.Height is not null limit 1 ), ifnull( -- new record ( select max( a.Id ) + 1 from Transactions a indexed by Transactions_Id ), 0 -- for first record ) ), Last = 1 WHERE Hash = ? )sql"); TryBindStatementText(setIdStmt, 1, txHash); TryStepStatement(setIdStmt); // Clear old last records for set new last ClearOldLast(txHash); } void ChainRepository::IndexContent(const string& txHash) { // Get new ID or copy previous auto setIdStmt = SetupSqlStatement(R"sql( UPDATE Transactions SET Id = ifnull( -- copy self Id ( select c.Id from Transactions c indexed by Transactions_Type_Last_String2_Height where c.Type in (200,201,207) and c.Last = 1 -- String2 = RootTxHash and c.String2 = Transactions.String2 and c.Height is not null limit 1 ), -- new record ifnull( ( select max( c.Id ) + 1 from Transactions c indexed by Transactions_Id ), 0 -- for first record ) ), Last = 1 WHERE Hash = ? )sql"); TryBindStatementText(setIdStmt, 1, txHash); TryStepStatement(setIdStmt); // Clear old last records for set new last ClearOldLast(txHash); } void ChainRepository::IndexComment(const string& txHash) { // Get new ID or copy previous auto setIdStmt = SetupSqlStatement(R"sql( UPDATE Transactions SET Id = ifnull( -- copy self Id ( select max( c.Id ) from Transactions c indexed by Transactions_Type_Last_String2_Height where c.Type in (204, 205, 206) and c.Last = 1 -- String2 = RootTxHash and c.String2 = Transactions.String2 and c.Height is not null ), -- new record ifnull( ( select max( c.Id ) + 1 from Transactions c indexed by Transactions_Id ), 0 -- for first record ) ), Last = 1 WHERE Hash = ? )sql"); TryBindStatementText(setIdStmt, 1, txHash); TryStepStatement(setIdStmt); // Clear old last records for set new last ClearOldLast(txHash); } void ChainRepository::IndexBlocking(const string& txHash) { // Set last=1 for new transaction auto setLastStmt = SetupSqlStatement(R"sql( UPDATE Transactions SET Id = ifnull( -- copy self Id ( select a.Id from Transactions a indexed by Transactions_Type_Last_String1_String2_Height where a.Type in (305, 306) and a.Last = 1 -- String1 = AddressHash and a.String1 = Transactions.String1 -- String2 = AddressToHash and a.String2 = Transactions.String2 and a.Height is not null limit 1 ), ifnull( -- new record ( select max( a.Id ) + 1 from Transactions a indexed by Transactions_Id ), 0 -- for first record ) ), Last = 1 WHERE Hash = ? )sql"); TryBindStatementText(setLastStmt, 1, txHash); TryStepStatement(setLastStmt); // Clear old last records for set new last ClearOldLast(txHash); } void ChainRepository::IndexSubscribe(const string& txHash) { // Set last=1 for new transaction auto setLastStmt = SetupSqlStatement(R"sql( UPDATE Transactions SET Id = ifnull( -- copy self Id ( select a.Id from Transactions a indexed by Transactions_Type_Last_String1_String2_Height where a.Type in (302, 303, 304) and a.Last = 1 -- String1 = AddressHash and a.String1 = Transactions.String1 -- String2 = AddressToHash and a.String2 = Transactions.String2 and a.Height is not null limit 1 ), ifnull( -- new record ( select max( a.Id ) + 1 from Transactions a indexed by Transactions_Id ), 0 -- for first record ) ), Last = 1 WHERE Hash = ? )sql"); TryBindStatementText(setLastStmt, 1, txHash); TryStepStatement(setLastStmt); // Clear old last records for set new last ClearOldLast(txHash); } void ChainRepository::ClearOldLast(const string& txHash) { auto stmt = SetupSqlStatement(R"sql( UPDATE Transactions indexed by Transactions_Id_Last SET Last = 0 FROM ( select t.Hash, t.id from Transactions t where t.Hash = ? ) as tInner WHERE Transactions.Id = tInner.Id and Transactions.Last = 1 and Transactions.Hash != tInner.Hash )sql"); TryBindStatementText(stmt, 1, txHash); TryStepStatement(stmt); } void ChainRepository::RestoreOldLast(int height) { int64_t nTime1 = GetTimeMicros(); // Restore old Last transactions auto stmt = SetupSqlStatement(R"sql( update Transactions indexed by Transactions_Height_Id set Last=1 from ( select t1.Id, max(t2.Height)Height from Transactions t1 indexed by Transactions_Last_Id_Height join Transactions t2 indexed by Transactions_Last_Id_Height on t2.Id = t1.Id and t2.Height < ? and t2.Last = 0 where t1.Height >= ? and t1.Last = 1 group by t1.Id )t where Transactions.Id = t.Id and Transactions.Height = t.Height )sql"); TryBindStatementInt(stmt, 1, height); TryBindStatementInt(stmt, 2, height); TryStepStatement(stmt); int64_t nTime2 = GetTimeMicros(); LogPrint(BCLog::BENCH, " - RestoreOldLast (Transactions:Last = 1): %.2fms\n", 0.001 * (nTime2 - nTime1)); // Restore Last for deleting ratings auto stmt2 = SetupSqlStatement(R"sql( update Ratings indexed by Ratings_Type_Id_Height_Value set Last=1 from ( select r1.Type, r1.Id, max(r2.Height)Height from Ratings r1 indexed by Ratings_Type_Id_Last_Height join Ratings r2 indexed by Ratings_Last_Id_Height on r2.Last = 0 and r2.Id = r1.Id and r2.Height < ? where r1.Height >= ? and r1.Last = 1 group by r1.Type, r1.Id )r where Ratings.Type = r.Type and Ratings.Id = r.Id and Ratings.Height = r.Height )sql"); TryBindStatementInt(stmt2, 1, height); TryBindStatementInt(stmt2, 2, height); TryStepStatement(stmt2); int64_t nTime3 = GetTimeMicros(); LogPrint(BCLog::BENCH, " - RestoreOldLast (Ratings:Last = 1): %.2fms\n", 0.001 * (nTime3 - nTime2)); // Restore Last for deleting balances auto stmt3 = SetupSqlStatement(R"sql( update Balances set Last=1 from ( select b1.AddressHash, max(b2.Height)Height from Balances b1 indexed by Balances_AddressHash_Last_Height join Balances b2 indexed by Balances_AddressHash_Last_Height on b2.Last = 0 and b2.AddressHash = b1.AddressHash and b2.Height < ? where b1.Height >= ? and b1.Last = 1 group by b1.AddressHash )b where Balances.AddressHash = b.AddressHash and Balances.Height = b.Height )sql"); TryBindStatementInt(stmt3, 1, height); TryBindStatementInt(stmt3, 2, height); TryStepStatement(stmt3); int64_t nTime4 = GetTimeMicros(); LogPrint(BCLog::BENCH, " - RestoreOldLast (Balances:Last = 1): %.2fms\n", 0.001 * (nTime4 - nTime3)); } void ChainRepository::RollbackHeight(int height) { int64_t nTime1 = GetTimeMicros(); // Rollback general transaction information auto stmt0 = SetupSqlStatement(R"sql( UPDATE Transactions SET BlockHash = null, BlockNum = null, Height = null, Id = null, Last = 0 WHERE Height >= ? )sql"); TryBindStatementInt(stmt0, 1, height); TryStepStatement(stmt0); int64_t nTime2 = GetTimeMicros(); LogPrint(BCLog::BENCH, " - RollbackHeight (Transactions:Height = null): %.2fms\n", 0.001 * (nTime2 - nTime1)); // ---------------------------------------- // Rollback spent transaction outputs auto stmt1 = SetupSqlStatement(R"sql( UPDATE TxOutputs SET SpentHeight = null, SpentTxHash = null WHERE SpentHeight >= ? )sql"); TryBindStatementInt(stmt1, 1, height); TryStepStatement(stmt1); int64_t nTime3 = GetTimeMicros(); LogPrint(BCLog::BENCH, " - RollbackHeight (TxOutputs:SpentHeight = null): %.2fms\n", 0.001 * (nTime3 - nTime2)); // Rollback transaction outputs height auto stmt11 = SetupSqlStatement(R"sql( UPDATE TxOutputs SET TxHeight = null WHERE TxHeight >= ? )sql"); TryBindStatementInt(stmt11, 1, height); TryStepStatement(stmt11); int64_t nTime4 = GetTimeMicros(); LogPrint(BCLog::BENCH, " - RollbackHeight (TxOutputs:TxHeight = null): %.2fms\n", 0.001 * (nTime4 - nTime3)); // ---------------------------------------- // Remove ratings auto stmt21 = SetupSqlStatement(R"sql( delete from Ratings where Height >= ? )sql"); TryBindStatementInt(stmt21, 1, height); TryStepStatement(stmt21); int64_t nTime5 = GetTimeMicros(); LogPrint(BCLog::BENCH, " - RollbackHeight (Ratings delete): %.2fms\n", 0.001 * (nTime5 - nTime4)); // ---------------------------------------- // Remove balances auto stmt31 = SetupSqlStatement(R"sql( delete from Balances where Height >= ? )sql"); TryBindStatementInt(stmt31, 1, height); TryStepStatement(stmt31); int64_t nTime6 = GetTimeMicros(); LogPrint(BCLog::BENCH, " - RollbackHeight (Balances delete): %.2fms\n", 0.001 * (nTime6 - nTime5)); } } // namespace PocketDb
_grep: file format elf32-i386 Disassembly of section .text: 00000000 <main>: } } int main(int argc, char *argv[]) { 0: f3 0f 1e fb endbr32 4: 8d 4c 24 04 lea 0x4(%esp),%ecx 8: 83 e4 f0 and $0xfffffff0,%esp b: ff 71 fc pushl -0x4(%ecx) e: 55 push %ebp f: 89 e5 mov %esp,%ebp 11: 57 push %edi 12: 56 push %esi 13: 53 push %ebx 14: 51 push %ecx 15: 83 ec 18 sub $0x18,%esp 18: 8b 01 mov (%ecx),%eax 1a: 8b 59 04 mov 0x4(%ecx),%ebx 1d: 89 45 e4 mov %eax,-0x1c(%ebp) int fd, i; char *pattern; if(argc <= 1){ 20: 83 f8 01 cmp $0x1,%eax 23: 7e 6b jle 90 <main+0x90> printf(2, "usage: grep pattern [file ...]\n"); exit(); } pattern = argv[1]; 25: 8b 43 04 mov 0x4(%ebx),%eax 28: 83 c3 08 add $0x8,%ebx if(argc <= 2){ 2b: 83 7d e4 02 cmpl $0x2,-0x1c(%ebp) grep(pattern, 0); exit(); } for(i = 2; i < argc; i++){ 2f: be 02 00 00 00 mov $0x2,%esi pattern = argv[1]; 34: 89 45 e0 mov %eax,-0x20(%ebp) if(argc <= 2){ 37: 75 29 jne 62 <main+0x62> 39: eb 68 jmp a3 <main+0xa3> 3b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3f: 90 nop if((fd = open(argv[i], 0)) < 0){ printf(1, "grep: cannot open %s\n", argv[i]); exit(); } grep(pattern, fd); 40: 83 ec 08 sub $0x8,%esp for(i = 2; i < argc; i++){ 43: 83 c6 01 add $0x1,%esi 46: 83 c3 04 add $0x4,%ebx grep(pattern, fd); 49: 50 push %eax 4a: ff 75 e0 pushl -0x20(%ebp) 4d: e8 de 01 00 00 call 230 <grep> close(fd); 52: 89 3c 24 mov %edi,(%esp) 55: e8 71 05 00 00 call 5cb <close> for(i = 2; i < argc; i++){ 5a: 83 c4 10 add $0x10,%esp 5d: 39 75 e4 cmp %esi,-0x1c(%ebp) 60: 7e 29 jle 8b <main+0x8b> if((fd = open(argv[i], 0)) < 0){ 62: 83 ec 08 sub $0x8,%esp 65: 6a 00 push $0x0 67: ff 33 pushl (%ebx) 69: e8 75 05 00 00 call 5e3 <open> 6e: 83 c4 10 add $0x10,%esp 71: 89 c7 mov %eax,%edi 73: 85 c0 test %eax,%eax 75: 79 c9 jns 40 <main+0x40> printf(1, "grep: cannot open %s\n", argv[i]); 77: 50 push %eax 78: ff 33 pushl (%ebx) 7a: 68 98 0a 00 00 push $0xa98 7f: 6a 01 push $0x1 81: e8 8a 06 00 00 call 710 <printf> exit(); 86: e8 18 05 00 00 call 5a3 <exit> } exit(); 8b: e8 13 05 00 00 call 5a3 <exit> printf(2, "usage: grep pattern [file ...]\n"); 90: 51 push %ecx 91: 51 push %ecx 92: 68 78 0a 00 00 push $0xa78 97: 6a 02 push $0x2 99: e8 72 06 00 00 call 710 <printf> exit(); 9e: e8 00 05 00 00 call 5a3 <exit> grep(pattern, 0); a3: 52 push %edx a4: 52 push %edx a5: 6a 00 push $0x0 a7: 50 push %eax a8: e8 83 01 00 00 call 230 <grep> exit(); ad: e8 f1 04 00 00 call 5a3 <exit> b2: 66 90 xchg %ax,%ax b4: 66 90 xchg %ax,%ax b6: 66 90 xchg %ax,%ax b8: 66 90 xchg %ax,%ax ba: 66 90 xchg %ax,%ax bc: 66 90 xchg %ax,%ax be: 66 90 xchg %ax,%ax 000000c0 <matchstar>: return 0; } // matchstar: search for c*re at beginning of text int matchstar(int c, char *re, char *text) { c0: f3 0f 1e fb endbr32 c4: 55 push %ebp c5: 89 e5 mov %esp,%ebp c7: 57 push %edi c8: 56 push %esi c9: 53 push %ebx ca: 83 ec 0c sub $0xc,%esp cd: 8b 5d 08 mov 0x8(%ebp),%ebx d0: 8b 75 0c mov 0xc(%ebp),%esi d3: 8b 7d 10 mov 0x10(%ebp),%edi d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi dd: 8d 76 00 lea 0x0(%esi),%esi do{ // a * matches zero or more instances if(matchhere(re, text)) e0: 83 ec 08 sub $0x8,%esp e3: 57 push %edi e4: 56 push %esi e5: e8 36 00 00 00 call 120 <matchhere> ea: 83 c4 10 add $0x10,%esp ed: 85 c0 test %eax,%eax ef: 75 1f jne 110 <matchstar+0x50> return 1; }while(*text!='\0' && (*text++==c || c=='.')); f1: 0f be 17 movsbl (%edi),%edx f4: 84 d2 test %dl,%dl f6: 74 0c je 104 <matchstar+0x44> f8: 83 c7 01 add $0x1,%edi fb: 39 da cmp %ebx,%edx fd: 74 e1 je e0 <matchstar+0x20> ff: 83 fb 2e cmp $0x2e,%ebx 102: 74 dc je e0 <matchstar+0x20> return 0; } 104: 8d 65 f4 lea -0xc(%ebp),%esp 107: 5b pop %ebx 108: 5e pop %esi 109: 5f pop %edi 10a: 5d pop %ebp 10b: c3 ret 10c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 110: 8d 65 f4 lea -0xc(%ebp),%esp return 1; 113: b8 01 00 00 00 mov $0x1,%eax } 118: 5b pop %ebx 119: 5e pop %esi 11a: 5f pop %edi 11b: 5d pop %ebp 11c: c3 ret 11d: 8d 76 00 lea 0x0(%esi),%esi 00000120 <matchhere>: { 120: f3 0f 1e fb endbr32 124: 55 push %ebp 125: 89 e5 mov %esp,%ebp 127: 57 push %edi 128: 56 push %esi 129: 53 push %ebx 12a: 83 ec 0c sub $0xc,%esp 12d: 8b 4d 08 mov 0x8(%ebp),%ecx 130: 8b 7d 0c mov 0xc(%ebp),%edi if(re[0] == '\0') 133: 0f b6 01 movzbl (%ecx),%eax 136: 84 c0 test %al,%al 138: 75 2b jne 165 <matchhere+0x45> 13a: eb 64 jmp 1a0 <matchhere+0x80> 13c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(re[0] == '$' && re[1] == '\0') 140: 0f b6 37 movzbl (%edi),%esi 143: 80 fa 24 cmp $0x24,%dl 146: 75 04 jne 14c <matchhere+0x2c> 148: 84 c0 test %al,%al 14a: 74 61 je 1ad <matchhere+0x8d> if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 14c: 89 f3 mov %esi,%ebx 14e: 84 db test %bl,%bl 150: 74 3e je 190 <matchhere+0x70> 152: 80 fa 2e cmp $0x2e,%dl 155: 74 04 je 15b <matchhere+0x3b> 157: 38 d3 cmp %dl,%bl 159: 75 35 jne 190 <matchhere+0x70> return matchhere(re+1, text+1); 15b: 83 c7 01 add $0x1,%edi 15e: 83 c1 01 add $0x1,%ecx if(re[0] == '\0') 161: 84 c0 test %al,%al 163: 74 3b je 1a0 <matchhere+0x80> if(re[1] == '*') 165: 0f be d0 movsbl %al,%edx 168: 0f b6 41 01 movzbl 0x1(%ecx),%eax 16c: 3c 2a cmp $0x2a,%al 16e: 75 d0 jne 140 <matchhere+0x20> return matchstar(re[0], re+2, text); 170: 83 ec 04 sub $0x4,%esp 173: 83 c1 02 add $0x2,%ecx 176: 57 push %edi 177: 51 push %ecx 178: 52 push %edx 179: e8 42 ff ff ff call c0 <matchstar> 17e: 83 c4 10 add $0x10,%esp } 181: 8d 65 f4 lea -0xc(%ebp),%esp 184: 5b pop %ebx 185: 5e pop %esi 186: 5f pop %edi 187: 5d pop %ebp 188: c3 ret 189: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 190: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 193: 31 c0 xor %eax,%eax } 195: 5b pop %ebx 196: 5e pop %esi 197: 5f pop %edi 198: 5d pop %ebp 199: c3 ret 19a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1a0: 8d 65 f4 lea -0xc(%ebp),%esp return 1; 1a3: b8 01 00 00 00 mov $0x1,%eax } 1a8: 5b pop %ebx 1a9: 5e pop %esi 1aa: 5f pop %edi 1ab: 5d pop %ebp 1ac: c3 ret return *text == '\0'; 1ad: 89 f0 mov %esi,%eax 1af: 84 c0 test %al,%al 1b1: 0f 94 c0 sete %al 1b4: 0f b6 c0 movzbl %al,%eax 1b7: eb c8 jmp 181 <matchhere+0x61> 1b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000001c0 <match>: { 1c0: f3 0f 1e fb endbr32 1c4: 55 push %ebp 1c5: 89 e5 mov %esp,%ebp 1c7: 56 push %esi 1c8: 53 push %ebx 1c9: 8b 5d 08 mov 0x8(%ebp),%ebx 1cc: 8b 75 0c mov 0xc(%ebp),%esi if(re[0] == '^') 1cf: 80 3b 5e cmpb $0x5e,(%ebx) 1d2: 75 15 jne 1e9 <match+0x29> 1d4: eb 3a jmp 210 <match+0x50> 1d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1dd: 8d 76 00 lea 0x0(%esi),%esi }while(*text++ != '\0'); 1e0: 83 c6 01 add $0x1,%esi 1e3: 80 7e ff 00 cmpb $0x0,-0x1(%esi) 1e7: 74 16 je 1ff <match+0x3f> if(matchhere(re, text)) 1e9: 83 ec 08 sub $0x8,%esp 1ec: 56 push %esi 1ed: 53 push %ebx 1ee: e8 2d ff ff ff call 120 <matchhere> 1f3: 83 c4 10 add $0x10,%esp 1f6: 85 c0 test %eax,%eax 1f8: 74 e6 je 1e0 <match+0x20> return 1; 1fa: b8 01 00 00 00 mov $0x1,%eax } 1ff: 8d 65 f8 lea -0x8(%ebp),%esp 202: 5b pop %ebx 203: 5e pop %esi 204: 5d pop %ebp 205: c3 ret 206: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 20d: 8d 76 00 lea 0x0(%esi),%esi return matchhere(re+1, text); 210: 83 c3 01 add $0x1,%ebx 213: 89 5d 08 mov %ebx,0x8(%ebp) } 216: 8d 65 f8 lea -0x8(%ebp),%esp 219: 5b pop %ebx 21a: 5e pop %esi 21b: 5d pop %ebp return matchhere(re+1, text); 21c: e9 ff fe ff ff jmp 120 <matchhere> 221: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 228: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 22f: 90 nop 00000230 <grep>: { 230: f3 0f 1e fb endbr32 234: 55 push %ebp 235: 89 e5 mov %esp,%ebp 237: 57 push %edi 238: 56 push %esi 239: 53 push %ebx 23a: 83 ec 1c sub $0x1c,%esp m = 0; 23d: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) { 244: 8b 75 08 mov 0x8(%ebp),%esi 247: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 24e: 66 90 xchg %ax,%ax while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){ 250: 8b 4d e4 mov -0x1c(%ebp),%ecx 253: b8 ff 03 00 00 mov $0x3ff,%eax 258: 83 ec 04 sub $0x4,%esp 25b: 29 c8 sub %ecx,%eax 25d: 50 push %eax 25e: 8d 81 80 0e 00 00 lea 0xe80(%ecx),%eax 264: 50 push %eax 265: ff 75 0c pushl 0xc(%ebp) 268: e8 4e 03 00 00 call 5bb <read> 26d: 83 c4 10 add $0x10,%esp 270: 85 c0 test %eax,%eax 272: 0f 8e b8 00 00 00 jle 330 <grep+0x100> m += n; 278: 01 45 e4 add %eax,-0x1c(%ebp) 27b: 8b 4d e4 mov -0x1c(%ebp),%ecx p = buf; 27e: bb 80 0e 00 00 mov $0xe80,%ebx buf[m] = '\0'; 283: c6 81 80 0e 00 00 00 movb $0x0,0xe80(%ecx) while((q = strchr(p, '\n')) != 0){ 28a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 290: 83 ec 08 sub $0x8,%esp 293: 6a 0a push $0xa 295: 53 push %ebx 296: e8 85 01 00 00 call 420 <strchr> 29b: 83 c4 10 add $0x10,%esp 29e: 89 c7 mov %eax,%edi 2a0: 85 c0 test %eax,%eax 2a2: 74 3c je 2e0 <grep+0xb0> if(match(pattern, p)){ 2a4: 83 ec 08 sub $0x8,%esp *q = 0; 2a7: c6 07 00 movb $0x0,(%edi) if(match(pattern, p)){ 2aa: 53 push %ebx 2ab: 56 push %esi 2ac: e8 0f ff ff ff call 1c0 <match> 2b1: 83 c4 10 add $0x10,%esp 2b4: 8d 57 01 lea 0x1(%edi),%edx 2b7: 85 c0 test %eax,%eax 2b9: 75 05 jne 2c0 <grep+0x90> p = q+1; 2bb: 89 d3 mov %edx,%ebx 2bd: eb d1 jmp 290 <grep+0x60> 2bf: 90 nop write(1, p, q+1 - p); 2c0: 89 d0 mov %edx,%eax 2c2: 83 ec 04 sub $0x4,%esp *q = '\n'; 2c5: c6 07 0a movb $0xa,(%edi) write(1, p, q+1 - p); 2c8: 29 d8 sub %ebx,%eax 2ca: 89 55 e0 mov %edx,-0x20(%ebp) 2cd: 50 push %eax 2ce: 53 push %ebx 2cf: 6a 01 push $0x1 2d1: e8 ed 02 00 00 call 5c3 <write> 2d6: 8b 55 e0 mov -0x20(%ebp),%edx 2d9: 83 c4 10 add $0x10,%esp p = q+1; 2dc: 89 d3 mov %edx,%ebx 2de: eb b0 jmp 290 <grep+0x60> if(p == buf) 2e0: 81 fb 80 0e 00 00 cmp $0xe80,%ebx 2e6: 74 38 je 320 <grep+0xf0> if(m > 0){ 2e8: 8b 4d e4 mov -0x1c(%ebp),%ecx 2eb: 85 c9 test %ecx,%ecx 2ed: 0f 8e 5d ff ff ff jle 250 <grep+0x20> m -= p - buf; 2f3: 89 d8 mov %ebx,%eax memmove(buf, p, m); 2f5: 83 ec 04 sub $0x4,%esp m -= p - buf; 2f8: 2d 80 0e 00 00 sub $0xe80,%eax 2fd: 29 c1 sub %eax,%ecx memmove(buf, p, m); 2ff: 51 push %ecx 300: 53 push %ebx 301: 68 80 0e 00 00 push $0xe80 m -= p - buf; 306: 89 4d e4 mov %ecx,-0x1c(%ebp) memmove(buf, p, m); 309: e8 62 02 00 00 call 570 <memmove> 30e: 83 c4 10 add $0x10,%esp 311: e9 3a ff ff ff jmp 250 <grep+0x20> 316: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 31d: 8d 76 00 lea 0x0(%esi),%esi m = 0; 320: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 327: e9 24 ff ff ff jmp 250 <grep+0x20> 32c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } 330: 8d 65 f4 lea -0xc(%ebp),%esp 333: 5b pop %ebx 334: 5e pop %esi 335: 5f pop %edi 336: 5d pop %ebp 337: c3 ret 338: 66 90 xchg %ax,%ax 33a: 66 90 xchg %ax,%ax 33c: 66 90 xchg %ax,%ax 33e: 66 90 xchg %ax,%ax 00000340 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 340: f3 0f 1e fb endbr32 344: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 345: 31 c0 xor %eax,%eax { 347: 89 e5 mov %esp,%ebp 349: 53 push %ebx 34a: 8b 4d 08 mov 0x8(%ebp),%ecx 34d: 8b 5d 0c mov 0xc(%ebp),%ebx while((*s++ = *t++) != 0) 350: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx 354: 88 14 01 mov %dl,(%ecx,%eax,1) 357: 83 c0 01 add $0x1,%eax 35a: 84 d2 test %dl,%dl 35c: 75 f2 jne 350 <strcpy+0x10> ; return os; } 35e: 89 c8 mov %ecx,%eax 360: 5b pop %ebx 361: 5d pop %ebp 362: c3 ret 363: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 36a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000370 <strcmp>: int strcmp(const char *p, const char *q) { 370: f3 0f 1e fb endbr32 374: 55 push %ebp 375: 89 e5 mov %esp,%ebp 377: 53 push %ebx 378: 8b 4d 08 mov 0x8(%ebp),%ecx 37b: 8b 55 0c mov 0xc(%ebp),%edx while(*p && *p == *q) 37e: 0f b6 01 movzbl (%ecx),%eax 381: 0f b6 1a movzbl (%edx),%ebx 384: 84 c0 test %al,%al 386: 75 19 jne 3a1 <strcmp+0x31> 388: eb 26 jmp 3b0 <strcmp+0x40> 38a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 390: 0f b6 41 01 movzbl 0x1(%ecx),%eax p++, q++; 394: 83 c1 01 add $0x1,%ecx 397: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 39a: 0f b6 1a movzbl (%edx),%ebx 39d: 84 c0 test %al,%al 39f: 74 0f je 3b0 <strcmp+0x40> 3a1: 38 d8 cmp %bl,%al 3a3: 74 eb je 390 <strcmp+0x20> return (uchar)*p - (uchar)*q; 3a5: 29 d8 sub %ebx,%eax } 3a7: 5b pop %ebx 3a8: 5d pop %ebp 3a9: c3 ret 3aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 3b0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 3b2: 29 d8 sub %ebx,%eax } 3b4: 5b pop %ebx 3b5: 5d pop %ebp 3b6: c3 ret 3b7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3be: 66 90 xchg %ax,%ax 000003c0 <strlen>: uint strlen(const char *s) { 3c0: f3 0f 1e fb endbr32 3c4: 55 push %ebp 3c5: 89 e5 mov %esp,%ebp 3c7: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) 3ca: 80 3a 00 cmpb $0x0,(%edx) 3cd: 74 21 je 3f0 <strlen+0x30> 3cf: 31 c0 xor %eax,%eax 3d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3d8: 83 c0 01 add $0x1,%eax 3db: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 3df: 89 c1 mov %eax,%ecx 3e1: 75 f5 jne 3d8 <strlen+0x18> ; return n; } 3e3: 89 c8 mov %ecx,%eax 3e5: 5d pop %ebp 3e6: c3 ret 3e7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3ee: 66 90 xchg %ax,%ax for(n = 0; s[n]; n++) 3f0: 31 c9 xor %ecx,%ecx } 3f2: 5d pop %ebp 3f3: 89 c8 mov %ecx,%eax 3f5: c3 ret 3f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3fd: 8d 76 00 lea 0x0(%esi),%esi 00000400 <memset>: void* memset(void *dst, int c, uint n) { 400: f3 0f 1e fb endbr32 404: 55 push %ebp 405: 89 e5 mov %esp,%ebp 407: 57 push %edi 408: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 40b: 8b 4d 10 mov 0x10(%ebp),%ecx 40e: 8b 45 0c mov 0xc(%ebp),%eax 411: 89 d7 mov %edx,%edi 413: fc cld 414: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 416: 89 d0 mov %edx,%eax 418: 5f pop %edi 419: 5d pop %ebp 41a: c3 ret 41b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 41f: 90 nop 00000420 <strchr>: char* strchr(const char *s, char c) { 420: f3 0f 1e fb endbr32 424: 55 push %ebp 425: 89 e5 mov %esp,%ebp 427: 8b 45 08 mov 0x8(%ebp),%eax 42a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for(; *s; s++) 42e: 0f b6 10 movzbl (%eax),%edx 431: 84 d2 test %dl,%dl 433: 75 16 jne 44b <strchr+0x2b> 435: eb 21 jmp 458 <strchr+0x38> 437: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 43e: 66 90 xchg %ax,%ax 440: 0f b6 50 01 movzbl 0x1(%eax),%edx 444: 83 c0 01 add $0x1,%eax 447: 84 d2 test %dl,%dl 449: 74 0d je 458 <strchr+0x38> if(*s == c) 44b: 38 d1 cmp %dl,%cl 44d: 75 f1 jne 440 <strchr+0x20> return (char*)s; return 0; } 44f: 5d pop %ebp 450: c3 ret 451: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return 0; 458: 31 c0 xor %eax,%eax } 45a: 5d pop %ebp 45b: c3 ret 45c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000460 <gets>: char* gets(char *buf, int max) { 460: f3 0f 1e fb endbr32 464: 55 push %ebp 465: 89 e5 mov %esp,%ebp 467: 57 push %edi 468: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 469: 31 f6 xor %esi,%esi { 46b: 53 push %ebx 46c: 89 f3 mov %esi,%ebx 46e: 83 ec 1c sub $0x1c,%esp 471: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 474: eb 33 jmp 4a9 <gets+0x49> 476: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 47d: 8d 76 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 480: 83 ec 04 sub $0x4,%esp 483: 8d 45 e7 lea -0x19(%ebp),%eax 486: 6a 01 push $0x1 488: 50 push %eax 489: 6a 00 push $0x0 48b: e8 2b 01 00 00 call 5bb <read> if(cc < 1) 490: 83 c4 10 add $0x10,%esp 493: 85 c0 test %eax,%eax 495: 7e 1c jle 4b3 <gets+0x53> break; buf[i++] = c; 497: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 49b: 83 c7 01 add $0x1,%edi 49e: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 4a1: 3c 0a cmp $0xa,%al 4a3: 74 23 je 4c8 <gets+0x68> 4a5: 3c 0d cmp $0xd,%al 4a7: 74 1f je 4c8 <gets+0x68> for(i=0; i+1 < max; ){ 4a9: 83 c3 01 add $0x1,%ebx 4ac: 89 fe mov %edi,%esi 4ae: 3b 5d 0c cmp 0xc(%ebp),%ebx 4b1: 7c cd jl 480 <gets+0x20> 4b3: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 4b5: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 4b8: c6 03 00 movb $0x0,(%ebx) } 4bb: 8d 65 f4 lea -0xc(%ebp),%esp 4be: 5b pop %ebx 4bf: 5e pop %esi 4c0: 5f pop %edi 4c1: 5d pop %ebp 4c2: c3 ret 4c3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 4c7: 90 nop 4c8: 8b 75 08 mov 0x8(%ebp),%esi 4cb: 8b 45 08 mov 0x8(%ebp),%eax 4ce: 01 de add %ebx,%esi 4d0: 89 f3 mov %esi,%ebx buf[i] = '\0'; 4d2: c6 03 00 movb $0x0,(%ebx) } 4d5: 8d 65 f4 lea -0xc(%ebp),%esp 4d8: 5b pop %ebx 4d9: 5e pop %esi 4da: 5f pop %edi 4db: 5d pop %ebp 4dc: c3 ret 4dd: 8d 76 00 lea 0x0(%esi),%esi 000004e0 <stat>: int stat(const char *n, struct stat *st) { 4e0: f3 0f 1e fb endbr32 4e4: 55 push %ebp 4e5: 89 e5 mov %esp,%ebp 4e7: 56 push %esi 4e8: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 4e9: 83 ec 08 sub $0x8,%esp 4ec: 6a 00 push $0x0 4ee: ff 75 08 pushl 0x8(%ebp) 4f1: e8 ed 00 00 00 call 5e3 <open> if(fd < 0) 4f6: 83 c4 10 add $0x10,%esp 4f9: 85 c0 test %eax,%eax 4fb: 78 2b js 528 <stat+0x48> return -1; r = fstat(fd, st); 4fd: 83 ec 08 sub $0x8,%esp 500: ff 75 0c pushl 0xc(%ebp) 503: 89 c3 mov %eax,%ebx 505: 50 push %eax 506: e8 f0 00 00 00 call 5fb <fstat> close(fd); 50b: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 50e: 89 c6 mov %eax,%esi close(fd); 510: e8 b6 00 00 00 call 5cb <close> return r; 515: 83 c4 10 add $0x10,%esp } 518: 8d 65 f8 lea -0x8(%ebp),%esp 51b: 89 f0 mov %esi,%eax 51d: 5b pop %ebx 51e: 5e pop %esi 51f: 5d pop %ebp 520: c3 ret 521: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return -1; 528: be ff ff ff ff mov $0xffffffff,%esi 52d: eb e9 jmp 518 <stat+0x38> 52f: 90 nop 00000530 <atoi>: int atoi(const char *s) { 530: f3 0f 1e fb endbr32 534: 55 push %ebp 535: 89 e5 mov %esp,%ebp 537: 53 push %ebx 538: 8b 55 08 mov 0x8(%ebp),%edx int n; n = 0; while('0' <= *s && *s <= '9') 53b: 0f be 02 movsbl (%edx),%eax 53e: 8d 48 d0 lea -0x30(%eax),%ecx 541: 80 f9 09 cmp $0x9,%cl n = 0; 544: b9 00 00 00 00 mov $0x0,%ecx while('0' <= *s && *s <= '9') 549: 77 1a ja 565 <atoi+0x35> 54b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 54f: 90 nop n = n*10 + *s++ - '0'; 550: 83 c2 01 add $0x1,%edx 553: 8d 0c 89 lea (%ecx,%ecx,4),%ecx 556: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx while('0' <= *s && *s <= '9') 55a: 0f be 02 movsbl (%edx),%eax 55d: 8d 58 d0 lea -0x30(%eax),%ebx 560: 80 fb 09 cmp $0x9,%bl 563: 76 eb jbe 550 <atoi+0x20> return n; } 565: 89 c8 mov %ecx,%eax 567: 5b pop %ebx 568: 5d pop %ebp 569: c3 ret 56a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000570 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 570: f3 0f 1e fb endbr32 574: 55 push %ebp 575: 89 e5 mov %esp,%ebp 577: 57 push %edi 578: 8b 45 10 mov 0x10(%ebp),%eax 57b: 8b 55 08 mov 0x8(%ebp),%edx 57e: 56 push %esi 57f: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 582: 85 c0 test %eax,%eax 584: 7e 0f jle 595 <memmove+0x25> 586: 01 d0 add %edx,%eax dst = vdst; 588: 89 d7 mov %edx,%edi 58a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi *dst++ = *src++; 590: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) 591: 39 f8 cmp %edi,%eax 593: 75 fb jne 590 <memmove+0x20> return vdst; } 595: 5e pop %esi 596: 89 d0 mov %edx,%eax 598: 5f pop %edi 599: 5d pop %ebp 59a: c3 ret 0000059b <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 59b: b8 01 00 00 00 mov $0x1,%eax 5a0: cd 40 int $0x40 5a2: c3 ret 000005a3 <exit>: SYSCALL(exit) 5a3: b8 02 00 00 00 mov $0x2,%eax 5a8: cd 40 int $0x40 5aa: c3 ret 000005ab <wait>: SYSCALL(wait) 5ab: b8 03 00 00 00 mov $0x3,%eax 5b0: cd 40 int $0x40 5b2: c3 ret 000005b3 <pipe>: SYSCALL(pipe) 5b3: b8 04 00 00 00 mov $0x4,%eax 5b8: cd 40 int $0x40 5ba: c3 ret 000005bb <read>: SYSCALL(read) 5bb: b8 05 00 00 00 mov $0x5,%eax 5c0: cd 40 int $0x40 5c2: c3 ret 000005c3 <write>: SYSCALL(write) 5c3: b8 10 00 00 00 mov $0x10,%eax 5c8: cd 40 int $0x40 5ca: c3 ret 000005cb <close>: SYSCALL(close) 5cb: b8 15 00 00 00 mov $0x15,%eax 5d0: cd 40 int $0x40 5d2: c3 ret 000005d3 <kill>: SYSCALL(kill) 5d3: b8 06 00 00 00 mov $0x6,%eax 5d8: cd 40 int $0x40 5da: c3 ret 000005db <exec>: SYSCALL(exec) 5db: b8 07 00 00 00 mov $0x7,%eax 5e0: cd 40 int $0x40 5e2: c3 ret 000005e3 <open>: SYSCALL(open) 5e3: b8 0f 00 00 00 mov $0xf,%eax 5e8: cd 40 int $0x40 5ea: c3 ret 000005eb <mknod>: SYSCALL(mknod) 5eb: b8 11 00 00 00 mov $0x11,%eax 5f0: cd 40 int $0x40 5f2: c3 ret 000005f3 <unlink>: SYSCALL(unlink) 5f3: b8 12 00 00 00 mov $0x12,%eax 5f8: cd 40 int $0x40 5fa: c3 ret 000005fb <fstat>: SYSCALL(fstat) 5fb: b8 08 00 00 00 mov $0x8,%eax 600: cd 40 int $0x40 602: c3 ret 00000603 <link>: SYSCALL(link) 603: b8 13 00 00 00 mov $0x13,%eax 608: cd 40 int $0x40 60a: c3 ret 0000060b <mkdir>: SYSCALL(mkdir) 60b: b8 14 00 00 00 mov $0x14,%eax 610: cd 40 int $0x40 612: c3 ret 00000613 <chdir>: SYSCALL(chdir) 613: b8 09 00 00 00 mov $0x9,%eax 618: cd 40 int $0x40 61a: c3 ret 0000061b <dup>: SYSCALL(dup) 61b: b8 0a 00 00 00 mov $0xa,%eax 620: cd 40 int $0x40 622: c3 ret 00000623 <getpid>: SYSCALL(getpid) 623: b8 0b 00 00 00 mov $0xb,%eax 628: cd 40 int $0x40 62a: c3 ret 0000062b <sbrk>: SYSCALL(sbrk) 62b: b8 0c 00 00 00 mov $0xc,%eax 630: cd 40 int $0x40 632: c3 ret 00000633 <sleep>: SYSCALL(sleep) 633: b8 0d 00 00 00 mov $0xd,%eax 638: cd 40 int $0x40 63a: c3 ret 0000063b <uptime>: SYSCALL(uptime) 63b: b8 0e 00 00 00 mov $0xe,%eax 640: cd 40 int $0x40 642: c3 ret 00000643 <getHello>: SYSCALL(getHello) 643: b8 16 00 00 00 mov $0x16,%eax 648: cd 40 int $0x40 64a: c3 ret 0000064b <getProcCount>: SYSCALL(getProcCount) 64b: b8 17 00 00 00 mov $0x17,%eax 650: cd 40 int $0x40 652: c3 ret 00000653 <getReadCount>: 653: b8 18 00 00 00 mov $0x18,%eax 658: cd 40 int $0x40 65a: c3 ret 65b: 66 90 xchg %ax,%ax 65d: 66 90 xchg %ax,%ax 65f: 90 nop 00000660 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 660: 55 push %ebp 661: 89 e5 mov %esp,%ebp 663: 57 push %edi 664: 56 push %esi 665: 53 push %ebx 666: 83 ec 3c sub $0x3c,%esp 669: 89 4d c4 mov %ecx,-0x3c(%ebp) uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 66c: 89 d1 mov %edx,%ecx { 66e: 89 45 b8 mov %eax,-0x48(%ebp) if(sgn && xx < 0){ 671: 85 d2 test %edx,%edx 673: 0f 89 7f 00 00 00 jns 6f8 <printint+0x98> 679: f6 45 08 01 testb $0x1,0x8(%ebp) 67d: 74 79 je 6f8 <printint+0x98> neg = 1; 67f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) x = -xx; 686: f7 d9 neg %ecx } else { x = xx; } i = 0; 688: 31 db xor %ebx,%ebx 68a: 8d 75 d7 lea -0x29(%ebp),%esi 68d: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 690: 89 c8 mov %ecx,%eax 692: 31 d2 xor %edx,%edx 694: 89 cf mov %ecx,%edi 696: f7 75 c4 divl -0x3c(%ebp) 699: 0f b6 92 b8 0a 00 00 movzbl 0xab8(%edx),%edx 6a0: 89 45 c0 mov %eax,-0x40(%ebp) 6a3: 89 d8 mov %ebx,%eax 6a5: 8d 5b 01 lea 0x1(%ebx),%ebx }while((x /= base) != 0); 6a8: 8b 4d c0 mov -0x40(%ebp),%ecx buf[i++] = digits[x % base]; 6ab: 88 14 1e mov %dl,(%esi,%ebx,1) }while((x /= base) != 0); 6ae: 39 7d c4 cmp %edi,-0x3c(%ebp) 6b1: 76 dd jbe 690 <printint+0x30> if(neg) 6b3: 8b 4d bc mov -0x44(%ebp),%ecx 6b6: 85 c9 test %ecx,%ecx 6b8: 74 0c je 6c6 <printint+0x66> buf[i++] = '-'; 6ba: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) buf[i++] = digits[x % base]; 6bf: 89 d8 mov %ebx,%eax buf[i++] = '-'; 6c1: ba 2d 00 00 00 mov $0x2d,%edx while(--i >= 0) 6c6: 8b 7d b8 mov -0x48(%ebp),%edi 6c9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx 6cd: eb 07 jmp 6d6 <printint+0x76> 6cf: 90 nop 6d0: 0f b6 13 movzbl (%ebx),%edx 6d3: 83 eb 01 sub $0x1,%ebx write(fd, &c, 1); 6d6: 83 ec 04 sub $0x4,%esp 6d9: 88 55 d7 mov %dl,-0x29(%ebp) 6dc: 6a 01 push $0x1 6de: 56 push %esi 6df: 57 push %edi 6e0: e8 de fe ff ff call 5c3 <write> while(--i >= 0) 6e5: 83 c4 10 add $0x10,%esp 6e8: 39 de cmp %ebx,%esi 6ea: 75 e4 jne 6d0 <printint+0x70> putc(fd, buf[i]); } 6ec: 8d 65 f4 lea -0xc(%ebp),%esp 6ef: 5b pop %ebx 6f0: 5e pop %esi 6f1: 5f pop %edi 6f2: 5d pop %ebp 6f3: c3 ret 6f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 6f8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) 6ff: eb 87 jmp 688 <printint+0x28> 701: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 708: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 70f: 90 nop 00000710 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 710: f3 0f 1e fb endbr32 714: 55 push %ebp 715: 89 e5 mov %esp,%ebp 717: 57 push %edi 718: 56 push %esi 719: 53 push %ebx 71a: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 71d: 8b 75 0c mov 0xc(%ebp),%esi 720: 0f b6 1e movzbl (%esi),%ebx 723: 84 db test %bl,%bl 725: 0f 84 b4 00 00 00 je 7df <printf+0xcf> ap = (uint*)(void*)&fmt + 1; 72b: 8d 45 10 lea 0x10(%ebp),%eax 72e: 83 c6 01 add $0x1,%esi write(fd, &c, 1); 731: 8d 7d e7 lea -0x19(%ebp),%edi state = 0; 734: 31 d2 xor %edx,%edx ap = (uint*)(void*)&fmt + 1; 736: 89 45 d0 mov %eax,-0x30(%ebp) 739: eb 33 jmp 76e <printf+0x5e> 73b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 73f: 90 nop 740: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 743: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 748: 83 f8 25 cmp $0x25,%eax 74b: 74 17 je 764 <printf+0x54> write(fd, &c, 1); 74d: 83 ec 04 sub $0x4,%esp 750: 88 5d e7 mov %bl,-0x19(%ebp) 753: 6a 01 push $0x1 755: 57 push %edi 756: ff 75 08 pushl 0x8(%ebp) 759: e8 65 fe ff ff call 5c3 <write> 75e: 8b 55 d4 mov -0x2c(%ebp),%edx } else { putc(fd, c); 761: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 764: 0f b6 1e movzbl (%esi),%ebx 767: 83 c6 01 add $0x1,%esi 76a: 84 db test %bl,%bl 76c: 74 71 je 7df <printf+0xcf> c = fmt[i] & 0xff; 76e: 0f be cb movsbl %bl,%ecx 771: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 774: 85 d2 test %edx,%edx 776: 74 c8 je 740 <printf+0x30> } } else if(state == '%'){ 778: 83 fa 25 cmp $0x25,%edx 77b: 75 e7 jne 764 <printf+0x54> if(c == 'd'){ 77d: 83 f8 64 cmp $0x64,%eax 780: 0f 84 9a 00 00 00 je 820 <printf+0x110> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 786: 81 e1 f7 00 00 00 and $0xf7,%ecx 78c: 83 f9 70 cmp $0x70,%ecx 78f: 74 5f je 7f0 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 791: 83 f8 73 cmp $0x73,%eax 794: 0f 84 d6 00 00 00 je 870 <printf+0x160> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 79a: 83 f8 63 cmp $0x63,%eax 79d: 0f 84 8d 00 00 00 je 830 <printf+0x120> putc(fd, *ap); ap++; } else if(c == '%'){ 7a3: 83 f8 25 cmp $0x25,%eax 7a6: 0f 84 b4 00 00 00 je 860 <printf+0x150> write(fd, &c, 1); 7ac: 83 ec 04 sub $0x4,%esp 7af: c6 45 e7 25 movb $0x25,-0x19(%ebp) 7b3: 6a 01 push $0x1 7b5: 57 push %edi 7b6: ff 75 08 pushl 0x8(%ebp) 7b9: e8 05 fe ff ff call 5c3 <write> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 7be: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 7c1: 83 c4 0c add $0xc,%esp 7c4: 6a 01 push $0x1 7c6: 83 c6 01 add $0x1,%esi 7c9: 57 push %edi 7ca: ff 75 08 pushl 0x8(%ebp) 7cd: e8 f1 fd ff ff call 5c3 <write> for(i = 0; fmt[i]; i++){ 7d2: 0f b6 5e ff movzbl -0x1(%esi),%ebx putc(fd, c); 7d6: 83 c4 10 add $0x10,%esp } state = 0; 7d9: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 7db: 84 db test %bl,%bl 7dd: 75 8f jne 76e <printf+0x5e> } } } 7df: 8d 65 f4 lea -0xc(%ebp),%esp 7e2: 5b pop %ebx 7e3: 5e pop %esi 7e4: 5f pop %edi 7e5: 5d pop %ebp 7e6: c3 ret 7e7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 7ee: 66 90 xchg %ax,%ax printint(fd, *ap, 16, 0); 7f0: 83 ec 0c sub $0xc,%esp 7f3: b9 10 00 00 00 mov $0x10,%ecx 7f8: 6a 00 push $0x0 7fa: 8b 5d d0 mov -0x30(%ebp),%ebx 7fd: 8b 45 08 mov 0x8(%ebp),%eax 800: 8b 13 mov (%ebx),%edx 802: e8 59 fe ff ff call 660 <printint> ap++; 807: 89 d8 mov %ebx,%eax 809: 83 c4 10 add $0x10,%esp state = 0; 80c: 31 d2 xor %edx,%edx ap++; 80e: 83 c0 04 add $0x4,%eax 811: 89 45 d0 mov %eax,-0x30(%ebp) 814: e9 4b ff ff ff jmp 764 <printf+0x54> 819: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 10, 1); 820: 83 ec 0c sub $0xc,%esp 823: b9 0a 00 00 00 mov $0xa,%ecx 828: 6a 01 push $0x1 82a: eb ce jmp 7fa <printf+0xea> 82c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, *ap); 830: 8b 5d d0 mov -0x30(%ebp),%ebx write(fd, &c, 1); 833: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 836: 8b 03 mov (%ebx),%eax write(fd, &c, 1); 838: 6a 01 push $0x1 ap++; 83a: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 83d: 57 push %edi 83e: ff 75 08 pushl 0x8(%ebp) putc(fd, *ap); 841: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 844: e8 7a fd ff ff call 5c3 <write> ap++; 849: 89 5d d0 mov %ebx,-0x30(%ebp) 84c: 83 c4 10 add $0x10,%esp state = 0; 84f: 31 d2 xor %edx,%edx 851: e9 0e ff ff ff jmp 764 <printf+0x54> 856: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 85d: 8d 76 00 lea 0x0(%esi),%esi putc(fd, c); 860: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 863: 83 ec 04 sub $0x4,%esp 866: e9 59 ff ff ff jmp 7c4 <printf+0xb4> 86b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 86f: 90 nop s = (char*)*ap; 870: 8b 45 d0 mov -0x30(%ebp),%eax 873: 8b 18 mov (%eax),%ebx ap++; 875: 83 c0 04 add $0x4,%eax 878: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 87b: 85 db test %ebx,%ebx 87d: 74 17 je 896 <printf+0x186> while(*s != 0){ 87f: 0f b6 03 movzbl (%ebx),%eax state = 0; 882: 31 d2 xor %edx,%edx while(*s != 0){ 884: 84 c0 test %al,%al 886: 0f 84 d8 fe ff ff je 764 <printf+0x54> 88c: 89 75 d4 mov %esi,-0x2c(%ebp) 88f: 89 de mov %ebx,%esi 891: 8b 5d 08 mov 0x8(%ebp),%ebx 894: eb 1a jmp 8b0 <printf+0x1a0> s = "(null)"; 896: bb ae 0a 00 00 mov $0xaae,%ebx while(*s != 0){ 89b: 89 75 d4 mov %esi,-0x2c(%ebp) 89e: b8 28 00 00 00 mov $0x28,%eax 8a3: 89 de mov %ebx,%esi 8a5: 8b 5d 08 mov 0x8(%ebp),%ebx 8a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 8af: 90 nop write(fd, &c, 1); 8b0: 83 ec 04 sub $0x4,%esp s++; 8b3: 83 c6 01 add $0x1,%esi 8b6: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 8b9: 6a 01 push $0x1 8bb: 57 push %edi 8bc: 53 push %ebx 8bd: e8 01 fd ff ff call 5c3 <write> while(*s != 0){ 8c2: 0f b6 06 movzbl (%esi),%eax 8c5: 83 c4 10 add $0x10,%esp 8c8: 84 c0 test %al,%al 8ca: 75 e4 jne 8b0 <printf+0x1a0> 8cc: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; 8cf: 31 d2 xor %edx,%edx 8d1: e9 8e fe ff ff jmp 764 <printf+0x54> 8d6: 66 90 xchg %ax,%ax 8d8: 66 90 xchg %ax,%ax 8da: 66 90 xchg %ax,%ax 8dc: 66 90 xchg %ax,%ax 8de: 66 90 xchg %ax,%ax 000008e0 <free>: static Header base; static Header *freep; void free(void *ap) { 8e0: f3 0f 1e fb endbr32 8e4: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 8e5: a1 60 0e 00 00 mov 0xe60,%eax { 8ea: 89 e5 mov %esp,%ebp 8ec: 57 push %edi 8ed: 56 push %esi 8ee: 53 push %ebx 8ef: 8b 5d 08 mov 0x8(%ebp),%ebx 8f2: 8b 10 mov (%eax),%edx bp = (Header*)ap - 1; 8f4: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 8f7: 39 c8 cmp %ecx,%eax 8f9: 73 15 jae 910 <free+0x30> 8fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 8ff: 90 nop 900: 39 d1 cmp %edx,%ecx 902: 72 14 jb 918 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 904: 39 d0 cmp %edx,%eax 906: 73 10 jae 918 <free+0x38> { 908: 89 d0 mov %edx,%eax for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 90a: 8b 10 mov (%eax),%edx 90c: 39 c8 cmp %ecx,%eax 90e: 72 f0 jb 900 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 910: 39 d0 cmp %edx,%eax 912: 72 f4 jb 908 <free+0x28> 914: 39 d1 cmp %edx,%ecx 916: 73 f0 jae 908 <free+0x28> break; if(bp + bp->s.size == p->s.ptr){ 918: 8b 73 fc mov -0x4(%ebx),%esi 91b: 8d 3c f1 lea (%ecx,%esi,8),%edi 91e: 39 fa cmp %edi,%edx 920: 74 1e je 940 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 922: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 925: 8b 50 04 mov 0x4(%eax),%edx 928: 8d 34 d0 lea (%eax,%edx,8),%esi 92b: 39 f1 cmp %esi,%ecx 92d: 74 28 je 957 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 92f: 89 08 mov %ecx,(%eax) freep = p; } 931: 5b pop %ebx freep = p; 932: a3 60 0e 00 00 mov %eax,0xe60 } 937: 5e pop %esi 938: 5f pop %edi 939: 5d pop %ebp 93a: c3 ret 93b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 93f: 90 nop bp->s.size += p->s.ptr->s.size; 940: 03 72 04 add 0x4(%edx),%esi 943: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 946: 8b 10 mov (%eax),%edx 948: 8b 12 mov (%edx),%edx 94a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 94d: 8b 50 04 mov 0x4(%eax),%edx 950: 8d 34 d0 lea (%eax,%edx,8),%esi 953: 39 f1 cmp %esi,%ecx 955: 75 d8 jne 92f <free+0x4f> p->s.size += bp->s.size; 957: 03 53 fc add -0x4(%ebx),%edx freep = p; 95a: a3 60 0e 00 00 mov %eax,0xe60 p->s.size += bp->s.size; 95f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 962: 8b 53 f8 mov -0x8(%ebx),%edx 965: 89 10 mov %edx,(%eax) } 967: 5b pop %ebx 968: 5e pop %esi 969: 5f pop %edi 96a: 5d pop %ebp 96b: c3 ret 96c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000970 <malloc>: return freep; } void* malloc(uint nbytes) { 970: f3 0f 1e fb endbr32 974: 55 push %ebp 975: 89 e5 mov %esp,%ebp 977: 57 push %edi 978: 56 push %esi 979: 53 push %ebx 97a: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 97d: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 980: 8b 3d 60 0e 00 00 mov 0xe60,%edi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 986: 8d 70 07 lea 0x7(%eax),%esi 989: c1 ee 03 shr $0x3,%esi 98c: 83 c6 01 add $0x1,%esi if((prevp = freep) == 0){ 98f: 85 ff test %edi,%edi 991: 0f 84 a9 00 00 00 je a40 <malloc+0xd0> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 997: 8b 07 mov (%edi),%eax if(p->s.size >= nunits){ 999: 8b 48 04 mov 0x4(%eax),%ecx 99c: 39 f1 cmp %esi,%ecx 99e: 73 6d jae a0d <malloc+0x9d> 9a0: 81 fe 00 10 00 00 cmp $0x1000,%esi 9a6: bb 00 10 00 00 mov $0x1000,%ebx 9ab: 0f 43 de cmovae %esi,%ebx p = sbrk(nu * sizeof(Header)); 9ae: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx 9b5: 89 4d e4 mov %ecx,-0x1c(%ebp) 9b8: eb 17 jmp 9d1 <malloc+0x61> 9ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 9c0: 8b 10 mov (%eax),%edx if(p->s.size >= nunits){ 9c2: 8b 4a 04 mov 0x4(%edx),%ecx 9c5: 39 f1 cmp %esi,%ecx 9c7: 73 4f jae a18 <malloc+0xa8> 9c9: 8b 3d 60 0e 00 00 mov 0xe60,%edi 9cf: 89 d0 mov %edx,%eax p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 9d1: 39 c7 cmp %eax,%edi 9d3: 75 eb jne 9c0 <malloc+0x50> p = sbrk(nu * sizeof(Header)); 9d5: 83 ec 0c sub $0xc,%esp 9d8: ff 75 e4 pushl -0x1c(%ebp) 9db: e8 4b fc ff ff call 62b <sbrk> if(p == (char*)-1) 9e0: 83 c4 10 add $0x10,%esp 9e3: 83 f8 ff cmp $0xffffffff,%eax 9e6: 74 1b je a03 <malloc+0x93> hp->s.size = nu; 9e8: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 9eb: 83 ec 0c sub $0xc,%esp 9ee: 83 c0 08 add $0x8,%eax 9f1: 50 push %eax 9f2: e8 e9 fe ff ff call 8e0 <free> return freep; 9f7: a1 60 0e 00 00 mov 0xe60,%eax if((p = morecore(nunits)) == 0) 9fc: 83 c4 10 add $0x10,%esp 9ff: 85 c0 test %eax,%eax a01: 75 bd jne 9c0 <malloc+0x50> return 0; } } a03: 8d 65 f4 lea -0xc(%ebp),%esp return 0; a06: 31 c0 xor %eax,%eax } a08: 5b pop %ebx a09: 5e pop %esi a0a: 5f pop %edi a0b: 5d pop %ebp a0c: c3 ret if(p->s.size >= nunits){ a0d: 89 c2 mov %eax,%edx a0f: 89 f8 mov %edi,%eax a11: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) a18: 39 ce cmp %ecx,%esi a1a: 74 54 je a70 <malloc+0x100> p->s.size -= nunits; a1c: 29 f1 sub %esi,%ecx a1e: 89 4a 04 mov %ecx,0x4(%edx) p += p->s.size; a21: 8d 14 ca lea (%edx,%ecx,8),%edx p->s.size = nunits; a24: 89 72 04 mov %esi,0x4(%edx) freep = prevp; a27: a3 60 0e 00 00 mov %eax,0xe60 } a2c: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); a2f: 8d 42 08 lea 0x8(%edx),%eax } a32: 5b pop %ebx a33: 5e pop %esi a34: 5f pop %edi a35: 5d pop %ebp a36: c3 ret a37: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi a3e: 66 90 xchg %ax,%ax base.s.ptr = freep = prevp = &base; a40: c7 05 60 0e 00 00 64 movl $0xe64,0xe60 a47: 0e 00 00 base.s.size = 0; a4a: bf 64 0e 00 00 mov $0xe64,%edi base.s.ptr = freep = prevp = &base; a4f: c7 05 64 0e 00 00 64 movl $0xe64,0xe64 a56: 0e 00 00 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ a59: 89 f8 mov %edi,%eax base.s.size = 0; a5b: c7 05 68 0e 00 00 00 movl $0x0,0xe68 a62: 00 00 00 if(p->s.size >= nunits){ a65: e9 36 ff ff ff jmp 9a0 <malloc+0x30> a6a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi prevp->s.ptr = p->s.ptr; a70: 8b 0a mov (%edx),%ecx a72: 89 08 mov %ecx,(%eax) a74: eb b1 jmp a27 <malloc+0xb7>
#include <system/memory_stream_buffer.h> namespace gef { MemoryStreamBuffer::MemoryStreamBuffer(char* buffer, size_t size) { setg(buffer, buffer, buffer + size); setp(buffer, buffer + size); } }
// Copyright 2010-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "storage/registry.h" #include <memory> #include <string> #include "base/file_util.h" #include "base/logging.h" #include "base/mutex.h" #include "base/singleton.h" #include "base/system_util.h" #include "storage/storage_interface.h" #include "storage/tiny_storage.h" namespace mozc { namespace storage { namespace { Mutex g_mutex; #ifdef OS_WIN const char kRegistryFileName[] = "registry.db"; #else const char kRegistryFileName[] = ".registry.db"; // hidden file #endif class StorageInitializer { public: StorageInitializer() : default_storage_(TinyStorage::New()), current_storage_(NULL) { if (!default_storage_->Open(FileUtil::JoinPath( SystemUtil::GetUserProfileDirectory(), kRegistryFileName))) { LOG(ERROR) << "cannot open registry"; } } StorageInterface *GetStorage() const { if (current_storage_ == NULL) { return default_storage_.get(); } else { return current_storage_; } } void SetStorage(StorageInterface *storage) { current_storage_ = storage; } private: std::unique_ptr<StorageInterface> default_storage_; StorageInterface *current_storage_; }; } // namespace bool Registry::Erase(const string &key) { scoped_lock l(&g_mutex); return Singleton<StorageInitializer>::get()->GetStorage()->Erase(key); } bool Registry::Sync() { scoped_lock l(&g_mutex); return Singleton<StorageInitializer>::get()->GetStorage()->Sync(); } // clear internal keys and values bool Registry::Clear() { scoped_lock l(&g_mutex); return Singleton<StorageInitializer>::get()->GetStorage()->Clear(); } void Registry::SetStorage(StorageInterface *handler) { VLOG(1) << "New storage interface is set"; scoped_lock l(&g_mutex); Singleton<StorageInitializer>::get()->SetStorage(handler); } bool Registry::LookupInternal(const string &key, string *value) { scoped_lock l(&g_mutex); // just for safe return Singleton<StorageInitializer>::get()->GetStorage()->Lookup(key, value); } bool Registry::InsertInternal(const string &key, const string &value) { scoped_lock l(&g_mutex); return Singleton<StorageInitializer>::get()->GetStorage()->Insert(key, value); } } // namespace storage } // namespace mozc
; A006152: Exponential generating function x*exp(x/(1-x)). ; Submitted by Jon Maiga ; 1,2,9,52,365,3006,28357,301064,3549177,45965530,648352001,9888877692,162112109029,2841669616982,53025262866045,1049180850990736,21937381717388657,483239096122434354,11184035897992673017,271287473871771163460,6881656485607798743261,182185366874848913979502,5024498372948847847451189,144111542172674220191169432,4291986813748642380761182825,132540945809371632049270556426,4238364943902600403876197998577,140174433368679079763743122719884,4789209304548979732019142449723477 mov $1,$0 add $0,1 seq $1,262 ; Number of "sets of lists": number of partitions of {1,...,n} into any number of lists, where a list means an ordered subset. mul $1,$0 mov $0,$1
; A131410: A127647 * A000012. ; 1,1,1,2,2,2,3,3,3,3,5,5,5,5,5,8,8,8,8,8,8,13,13,13,13,13,13,13,21,21,21,21,21,21,21,21,34,34,34,34,34,34,34,34,34,55,55,55,55,55,55,55,55,55,55,89,89,89,89,89,89,89,89,89,89,89,144,144,144,144,144,144,144,144,144,144,144,144,233,233,233,233,233,233,233,233,233,233,233,233,233,377,377,377,377,377,377,377,377,377,377,377,377,377,377,610,610,610,610,610,610,610,610,610,610,610,610,610,610,610,987,987,987,987,987,987,987,987,987,987,987,987,987,987,987,987,1597,1597,1597,1597,1597,1597,1597,1597,1597,1597,1597,1597,1597,1597,1597,1597,1597,2584,2584,2584,2584,2584,2584,2584,2584,2584,2584,2584,2584,2584,2584,2584,2584,2584,2584,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,4181,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,6765,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,10946,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711,17711 mov $1,1 mov $2,1 mov $4,1 lpb $0 sub $0,$2 trn $0,1 add $1,2 add $2,1 mov $3,$4 add $4,$1 mov $1,$3 add $4,1 lpe div $1,4 add $1,1
; Z88 Small C+ Graphics Functions ; Draw a circle on the Z88 map ; Adapted from my Spectrum Routine ; (C) 1995-1998 D.J.Morris ; ; $Id: dcircle.asm,v 1.4 2016-04-23 21:05:46 dom Exp $ ; IF !__CPU_INTEL__ & !__CPU_GBZ80__ SECTION code_graphics PUBLIC draw_circle DEFVARS 0 { x0 ds.b 1 y0 ds.b 1 radius ds.b 1 scale ds.b 1 cx ds.b 1 da ds.b 1 } ;iy points to table on stack (above) ;Entry: ; b=x0 c=y0, d=radius, e=scale factor ; ix=plot routine .draw_circle ld iy,-6 ;create buffer on stack add iy,sp ld sp,iy ld (iy+x0),b ld (iy+y0),c ld (iy+radius),d ld (iy+scale),e ;step factor - usually 1 call l9900 ld hl,6 add hl,sp ld sp,hl ret ;Line 9900 .l9900 ld (iy+cx),0 srl d ld (iy+da),d ;Line 9905 .l9905 ld a,(iy+cx) cp (iy+radius) ret nc ;Line 9910 ld a,(iy+da) and a jp p,l9915 add a,(iy+radius) ld (iy+da),a ld a,(iy+radius) sub (iy+scale) ld (iy+radius),a ;Line 9915 .l9915 ld a,(iy+da) dec a sub (iy+cx) ld (iy+da),a .l9920 ld a,(iy+y0) add a,(iy+radius) ld l,a ex af,af' ld a,(iy+x0) add a,(iy+cx) ld h,a call doplot ex af,af' ld l,a ld a,(iy+x0) sub (iy+cx) ld h,a call doplot ld a,(iy+y0) sub (iy+radius) ld l,a ex af,af' ld a,(iy+x0) add a,(iy+cx) ld h,a call doplot ex af,af' ld l,a ld a,(iy+x0) sub (iy+cx) ld h,a call doplot ;Line 9925 ld a,(iy+y0) add a,(iy+cx) ld l,a ex af,af' ld a,(iy+x0) add a,(iy+radius) ld h,a call doplot ex af,af' ld l,a ld a,(iy+x0) sub (iy+radius) ld h,a call doplot ld a,(iy+y0) sub (iy+cx) ld l,a ex af,af' ld a,(iy+x0) add a,(iy+radius) ld h,a call doplot ex af,af' ld l,a ld a,(iy+x0) sub (iy+radius) ld h,a call doplot ;Line 9930 ld a,(iy+cx) add a,(iy+scale) ld (iy+cx),a jp l9905 ;Entry to my plot is the same as for the z88 plot - very convenient! .doplot ret c jp (ix) ENDIF
/* Copyright 2021-2022 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ namespace cunumeric { template <typename T> __CUDA_HD__ Argval<T>::Argval() : arg(LLONG_MAX), arg_value(0) { } template <typename T> __CUDA_HD__ Argval<T>::Argval(T v) : arg(LLONG_MAX), arg_value(v) { } template <typename T> __CUDA_HD__ Argval<T>::Argval(int64_t a, T v) : arg(a), arg_value(v) { } template <typename T> __CUDA_HD__ Argval<T>::Argval(const Argval& other) : arg(other.arg), arg_value(other.arg_value) { } template <typename T> template <typename REDOP, bool EXCLUSIVE> __CUDA_HD__ inline void Argval<T>::apply(const Argval<T>& rhs) { if (EXCLUSIVE) { // This is the easy case T copy = arg_value; REDOP::template fold<true>(copy, rhs.arg_value); if (copy != arg_value) { arg_value = copy; arg = rhs.arg; } } else { // Handle conflicts here #ifdef __CUDA_ARCH__ const unsigned long long guard = (unsigned long long)-1LL; unsigned long long* ptr = (unsigned long long*)&arg; union { long long as_signed; unsigned long long as_unsigned; } next, current; next.as_signed = *ptr; do { current.as_signed = next.as_signed; next.as_unsigned = atomicCAS(ptr, current.as_unsigned, guard); } while ((next.as_signed != current.as_signed) || (next.as_signed == -1LL)); // Memory fence to prevent the compiler from hoisting the load __threadfence(); // Once we get here then we can do our comparison T copy = arg_value; REDOP::template fold<true>(copy, rhs.arg_value); if (copy != arg_value) { arg_value = copy; // Memory fence to make sure that things are ordered __threadfence(); // Write back the rhs args since the value changed // We know the value is minus 1 so this is guaranteed to succeed next.as_signed = rhs.arg; atomicCAS(ptr, guard, next.as_unsigned); } else { // Write back our arg since the value is the same // We know the value is minus 1 so this is guaranteed to succeed atomicCAS(ptr, guard, next.as_unsigned); } #else // Spin until no one else is doing their comparison // We use -1 as a guard to indicate we're doing our // comparison since we know all indexes should be >= 0 volatile long long* ptr = reinterpret_cast<volatile long long*>(&arg); long long next = *ptr; long long current; do { current = next; next = __sync_val_compare_and_swap(ptr, current, -1); } while ((next != current) || (next == -1)); // Memory fence to prevent the compiler from hoisting the load __sync_synchronize(); // Once we get here then we can do our comparison T copy = arg_value; REDOP::template fold<true>(copy, rhs.arg_value); if (copy != arg_value) { arg_value = copy; // Memory fence to make sure things are ordered __sync_synchronize(); // Write back the rhs args since the value changed // We know the value is minus 1 so this is guaranteed to succeed __sync_val_compare_and_swap(ptr, -1, rhs.arg); } else { // Write back our arg since the value is the same // We know the value is minus 1 so this is guaranteed to succeed __sync_val_compare_and_swap(ptr, -1, next); } #endif } } #define DECLARE_ARGMAX_IDENTITY(TYPE) \ template <> \ const Argval<TYPE> ArgmaxReduction<TYPE>::identity; #define DECLARE_ARGMIN_IDENTITY(TYPE) \ template <> \ const Argval<TYPE> ArgminReduction<TYPE>::identity; #define DECLARE_IDENTITIES(TYPE) \ DECLARE_ARGMAX_IDENTITY(TYPE) \ DECLARE_ARGMIN_IDENTITY(TYPE) DECLARE_IDENTITIES(__half) DECLARE_IDENTITIES(float) DECLARE_IDENTITIES(double) DECLARE_IDENTITIES(bool) DECLARE_IDENTITIES(int8_t) DECLARE_IDENTITIES(int16_t) DECLARE_IDENTITIES(int32_t) DECLARE_IDENTITIES(int64_t) DECLARE_IDENTITIES(uint8_t) DECLARE_IDENTITIES(uint16_t) DECLARE_IDENTITIES(uint32_t) DECLARE_IDENTITIES(uint64_t) DECLARE_IDENTITIES(complex<float>) #undef DECLARE_IDENTITIES #undef DECLARE_ARGMIN_IDENTITY #undef DECLARE_ARGMAX_IDENTITY } // namespace cunumeric
; SBAS_CMPADD - Resolve Addresses V2.00  1994 Tony Tebby section sbas xdef sb_cmpadd xref sb_sttadd xref sb_ixtable include 'dev8_keys_sbasic' include 'dev8_smsq_sbas_comp_keys' ;+++ ; SBASIC Resolve addresses. ; ; a5 c p pointer to compiler token base ; a6 c p pointer to SuperBASIC variables ; ; All other registers smashed ; Status return standard ;--- sb_cmpadd move.l sb_progb-sb_ptokb(a5),a1 ; program token move.l sb_progp-sb_ptokb(a5),a4 ; and top lea sb_ixtable,a3 ; extension table moveq #0,d4 sca_loop add.w d4,a1 cmp.l a4,a1 ; all processed? bge.s sca_done ; ... yes move.w (a1)+,d4 ; next token move.w (a3,d4.w),d4 ; flag / number of extension words blt.s sca_addr ; flag ext.w d4 bge.s sca_loop ; just move on move.w (a1)+,d4 ; skip variable list add.w d4,d4 bra.s sca_loop sca_addr move.l (a1),d0 jsr sb_sttadd ; convert statement to address move.l d0,(a1) ext.w d4 bra.s sca_loop sca_done moveq #0,d0 rts end
/*********************************************************************************************************************** * OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the * following conditions are met: * * (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following * disclaimer. * * (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the * following disclaimer in the documentation and/or other materials provided with the distribution. * * (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote * products derived from this software without specific prior written permission from the respective party. * * (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative * works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without * specific prior written permission from Alliance for Sustainable Energy, LLC. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************************************************************/ #ifndef OPENSTUDIO_GEOMETRYTABCONTROLLER_HPP #define OPENSTUDIO_GEOMETRYTABCONTROLLER_HPP #include "MainTabController.hpp" namespace openstudio { class GeometryPreviewController; class GeometryEditorController; class GeometryTabController : public MainTabController { Q_OBJECT public: GeometryTabController(bool isIP, const openstudio::model::Model& model); virtual ~GeometryTabController(); enum TabID { PREVIEW, EDITOR }; private: model::Model m_model; bool m_isIP; QObject * m_currentController = nullptr; int m_currentIndex = -1; public slots: virtual void setSubTab(int index) override; }; } // openstudio #endif // OPENSTUDIO_GEOMETRYTABCONTROLLER_HPP
;========================================================================= ; ; Sarien - A Sierra AGI resource interpreter engine ; Copyright (C) 1999-2001 Stuart George and Claudio Matsuoka ; ; $Id: pccga.asm,v 1.4 2002/07/27 12:17:15 cmatsuoka Exp $ ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; see docs/COPYING for further details. ; ;========================================================================= DGROUP group _DATA,_BSS assume cs:PCCGA_TEXT,ds:DGROUP _DATA segment word public 'DATA' d@ label byte d@w label word _DATA ends _BSS segment word public 'BSS' b@ label byte b@w label word _BSS ends ;========================================================================= ; Data ;========================================================================= _DATA segment word public 'DATA' gfx_pccga label word dd pc_init_vidmode dd pc_deinit_vidmode dd pc_put_block dd pc_put_pixels dd pc_timer dd pc_keypress dd pc_get_key cga_map label byte db 0, 1, 1, 1, 2, 2, 2, 3 db 0, 1, 1, 1, 2, 2, 2, 3 screen_buffer db 16000 dup (?) _DATA ends ;========================================================================= ; Code ;========================================================================= PCCGA_TEXT segment byte public 'CODE' ;------------------------------------------------------------------------- ; static void pc_timer () ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT pc_timer proc far push bp mov bp,sp @1@86: ; ; { ; static UINT32 cticks = 0; ; ; while (cticks == clock_ticks); ; mov ax,seg _clock_ticks mov es,ax mov ax,word ptr es:_clock_ticks+2 mov dx,word ptr es:_clock_ticks cmp ax,word ptr DGROUP:d@w+44+2 jne short @1@142 cmp dx,word ptr DGROUP:d@w+44 je short @1@86 @1@142: ; ; cticks = clock_ticks; ; mov ax,seg _clock_ticks mov es,ax mov ax,word ptr es:_clock_ticks+2 mov dx,word ptr es:_clock_ticks mov word ptr DGROUP:d@w+44+2,ax mov word ptr DGROUP:d@w+44,dx ; ; } ; pop bp ret pc_timer endp ;------------------------------------------------------------------------- ; int init_machine (int argc, char **argv) ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT _init_machine proc far push bp mov bp,sp @2@86: ; ; { ; gfx = &gfx_pccga; ; mov ax,seg _gfx mov es,ax mov word ptr es:_gfx+2,ds mov word ptr es:_gfx,offset DGROUP:gfx_pccga ; ; ; clock_count = 0; ; mov ax,seg _clock_count mov es,ax mov word ptr es:_clock_count+2,0 mov word ptr es:_clock_count,0 ; ; clock_ticks = 0; ; mov ax,seg _clock_ticks mov es,ax mov word ptr es:_clock_ticks+2,0 mov word ptr es:_clock_ticks,0 ; ; ; prev_08 = _dos_getvect (0x08); ; mov ax,8 push ax call far ptr __dos_getvect pop cx mov word ptr DGROUP:_prev_08+2,dx mov word ptr DGROUP:_prev_08,ax ; ; _dos_setvect (0x08, tick_increment); ; mov ax,seg _tick_increment push ax mov ax,offset _tick_increment push ax mov ax,8 push ax call far ptr __dos_setvect add sp,6 ; ; opt.cgaemu = TRUE; ; mov ax,seg _opt mov es,ax mov word ptr es:_opt+18,1 ; ; ; return err_OK; ; xor ax,ax ; ; } ; pop bp ret _init_machine endp ;------------------------------------------------------------------------- ; int deinit_machine () ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT _deinit_machine proc far push bp mov bp,sp @3@86: ; ; { ; _dos_setvect (0x08, prev_08); ; push word ptr DGROUP:_prev_08+2 push word ptr DGROUP:_prev_08 mov ax,8 push ax call far ptr __dos_setvect add sp,6 ; ; ; return err_OK; ; xor ax,ax ; ; } ; pop bp ret _deinit_machine endp ;------------------------------------------------------------------------- ; static int pc_init_vidmode () ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT pc_init_vidmode proc far mov ax, 4 int 10h xor ax, ax ret pc_init_vidmode endp ;------------------------------------------------------------------------- ; static int pc_deinit_vidmode () ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT pc_deinit_vidmode proc far mov ax, 3 int 10h xor ax, ax ret pc_deinit_vidmode endp ;------------------------------------------------------------------------- ; static void pc_put_block (int x1, int y1, int x2, int y2) ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT ;screen_buffer db 16000 dup (?) pc_put_block proc far push bp mov bp,sp sub sp,16 push si push di mov si,word ptr [bp+8] ; y1 @6@86: ; ; { ; unsigned int i, h, w, p, p2; ; UINT8 far *fbuffer; ; UINT8 *sbuffer; ; ; if (x1 >= GFX_WIDTH) x1 = GFX_WIDTH - 1; ; cmp word ptr [bp+6],320 jl short @6@142 mov word ptr [bp+6],319 @6@142: ; ; if (y1 >= GFX_HEIGHT) y1 = GFX_HEIGHT - 1; ; cmp si,200 jl short @6@198 mov si,199 @6@198: ; ; if (x2 >= GFX_WIDTH) x2 = GFX_WIDTH - 1; ; cmp word ptr [bp+10],320 jl short @6@254 mov word ptr [bp+10],319 @6@254: ; ; if (y2 >= GFX_HEIGHT) y2 = GFX_HEIGHT - 1; ; cmp word ptr [bp+12],200 jl short @6@310 mov word ptr [bp+12],199 @6@310: ; ; ; y1 &= ~1; /* Always start at an even line */ ; and si,65534 ; ; ; h = y2 - y1 + 1; ; mov ax,word ptr [bp+12] sub ax,si inc ax mov word ptr [bp-2],ax ; ; w = (x2 - x1 + 1) / 4 + 1; ; mov cx,word ptr [bp+10] sub cx,word ptr [bp+6] inc cx shr cx, 1 shr cx, 1 inc cx mov word ptr [bp-4],cx ; ; p = 40 * y1 + x1 / 4; /* Note: (GFX_WIDTH / 4) * (y1 / 2) */ ; mov ax,si mov dx,40 imul dx mov dx,word ptr [bp+6] shr dx, 1 shr dx, 1 add dx,ax mov word ptr [bp-6],dx ; ; p2 = p + 40 * y1; ; mov ax,si mov dx,40 imul dx mov dx,word ptr [bp-6] add dx,ax mov word ptr [bp-8],dx ; ; ; /* Write to the interlaced CGA framebuffer */ ; ; fbuffer = (UINT8 far *)0xb8000000 + p; ; mov ax, 0b800h push ax pop es mov di,word ptr [bp-6] ; ; sbuffer = screen_buffer + p2; ; mov si, offset screen_buffer add si, word ptr [bp-8] ; ; for (i = 0; i < h; i += 2) { ; xor dx,dx jmp short @6@394 @6@338: ; ; _fmemcpy (fbuffer, sbuffer, w); ; push di push si mov cx, word ptr [bp-4] repz movsb pop si pop di ; ; fbuffer += 80; ; add di,80 ;word ptr [bp-12],80 ; ; sbuffer += 160; ; add si, 160 ;word ptr [bp-16],160 add dx,2 @6@394: cmp dx,word ptr [bp-2] jb short @6@338 ; ; } ; ; fbuffer = (UINT8 far *)0xb8002000 + p; ; mov di,word ptr [bp-6] add di,8192 ; ; sbuffer = screen_buffer + p2 + 80; ; mov si, offset screen_buffer add si, word ptr [bp-8] add si, 80 ; ; for (i = 1; i < h; i += 2) { ; mov dx,1 jmp short @6@506 @6@450: ; ; _fmemcpy (fbuffer, sbuffer, w); ; push di push si mov cx, word ptr [bp-4] repz movsb pop si pop di ; ; fbuffer += 80; ; add di, 80 ;word ptr [bp-12],80 ; ; sbuffer += 160; ; add si, 160 ;word ptr [bp-16],160 add dx, 2 @6@506: cmp dx,word ptr [bp-2] jb short @6@450 ; ; } ; } ; pop di pop si mov sp,bp pop bp ret pc_put_block endp ;------------------------------------------------------------------------- ; static void pc_put_pixels(int x, int y, int w, UINT8 *p) ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT pc_put_pixels proc far push bp mov bp,sp sub sp,8 push si push di mov di, offset screen_buffer @7@86: ; ; { ; UINT8 *s, mask, val, shift, c; ; ; for (s = &screen_buffer[80 * y + x / 4]; w; w--, x++, p++) { ; mov ax, word ptr [bp+8] mov dx, 80 imul dx ; y * 80 mov dx, word ptr [bp+6] shr dx, 1 shr dx, 1 ; x / 4 add dx, ax ; 80 * y + x / 4 add di, dx jmp short condition @7@114: ; ; shift = (x & 3) * 2; ; mov cl,byte ptr [bp+6] and cl,3 shl cl,1 ; cl = shift ; ; ; /* Sorry, no transparent colors */ ; c = *p > 15 ? 0 : cga_map[*p]; ; les bx,dword ptr [bp+12] mov al,byte ptr es:[bx] cmp al,15 jbe short remap xor al, al ; al = color jmp short color_ok remap: mov bx, offset cga_map xlat ; al = color color_ok: ; ; ; mask = 0xc0 >> shift; ; mov dx,192 sar dx,cl ; dx = mask ; ; val = (c & 0x03) << (6 - shift); ; and al, 3 mov bl, cl mov cl, 6 sub cl, bl ; shl al, cl ; al = val ; ; *s = (*s & ~mask) | val; ; mov ch, byte ptr [di] not dl and ch, dl ; dl = !mask or al, ch mov byte ptr [di], al ; ; ; if ((x % 4) == 3) ; mov ax,word ptr [bp+6] and al, 3 cmp al,3 jne short @7@254 ; ; s++; ; ;inc word ptr [bp-4] inc di @7@254: dec word ptr [bp+10] ; w-- inc word ptr [bp+6] ; x++ inc word ptr [bp+12] ; p++ condition: mov ax, word ptr[bp+10] or ax,ax jne short @7@114 ; ; } ; } ; pop di pop si mov sp,bp pop bp ret pc_put_pixels endp ;------------------------------------------------------------------------- ; static int pc_keypress () ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT pc_keypress proc far ; { ; return !!kbhit(); ; call far ptr _kbhit ; ; } ; ret pc_keypress endp ;------------------------------------------------------------------------- ; static int pc_get_key () ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT pc_get_key proc far xor ax, ax int 16h or al, al jz high xor ah, ah high: ret pc_get_key endp ;------------------------------------------------------------------------- ; void __interrupt __far tick_increment (void) ;------------------------------------------------------------------------- assume cs:PCCGA_TEXT _tick_increment proc far push ax push bx push cx push dx push es push ds push si push di push bp mov bp,DGROUP mov ds,bp mov bp,sp ; ; { ; clock_ticks++; ; mov ax,seg _clock_ticks mov es,ax add word ptr es:_clock_ticks,1 adc word ptr es:_clock_ticks+2,0 ; ; _chain_intr(prev_08); ; push word ptr DGROUP:_prev_08+2 push word ptr DGROUP:_prev_08 call far ptr __chain_intr pop cx pop cx ; ; } ; pop bp pop di pop si pop ds pop es pop dx pop cx pop bx pop ax iret _tick_increment endp PCCGA_TEXT ends ;========================================================================= ; BSS ;========================================================================= _BSS segment word public 'BSS' _prev_08 label dword db 4 dup (?) _exec_name label dword db 4 dup (?) ?debug C E9 _BSS ends extrn _kbhit:far _cga_map equ cga_map _gfx_pccga equ gfx_pccga _pc_keypress equ pc_keypress _pc_get_key equ pc_get_key _pc_timer equ pc_timer _pc_put_pixels equ pc_put_pixels _pc_put_block equ pc_put_block _pc_deinit_vidmode equ pc_deinit_vidmode _pc_init_vidmode equ pc_init_vidmode public _tick_increment public _prev_08 extrn _gfx:dword extrn _clock_count:word extrn _clock_ticks:word public _exec_name extrn _opt:word public _deinit_machine public _init_machine extrn __dos_setvect:far extrn __dos_getvect:far extrn __chain_intr:far end
; 6502 - TMS9918 Font 2 (0 -255) 6x8 Text mode ; ; Copyright (c) 2021 Troy Schrapel ; ; This code is licensed under the MIT license ; ; https://github.com/visrealm/hbc-56 ; !byte $00,$00,$00,$00,$00,$00,$00,$00,$38,$44,$6C,$44,$54,$44,$38,$00,$38,$7C,$54,$7C,$44,$7C,$38,$00,$00,$28,$7C,$7C,$7C,$38,$10,$00,$00,$10,$38,$7C,$7C,$38,$10,$00 !byte $10,$38,$38,$10,$7C,$7C,$10,$00,$00,$10,$38,$7C,$7C,$10,$38,$00,$00,$00,$00,$30,$30,$00,$00,$00,$FC,$FC,$FC,$CC,$CC,$FC,$FC,$FC,$00,$00,$78,$48,$48,$78,$00,$00 !byte $FC,$FC,$84,$B4,$B4,$84,$FC,$FC,$00,$1C,$0C,$34,$48,$48,$30,$00,$38,$44,$44,$38,$10,$38,$10,$00 !byte $10,$18,$14,$10,$30,$70,$60,$00 !byte $0C,$34,$2C,$34,$2C,$6C,$60,$00 !byte $00,$54,$38,$6C,$38,$54,$00,$00 !byte $20,$30,$38,$3C,$38,$30,$20,$00 !byte $08,$18,$38,$78,$38,$18,$08,$00 !byte $10,$38,$7C,$10,$7C,$38,$10,$00 !byte $28,$28,$28,$28,$28,$00,$28,$00 !byte $3C,$54,$54,$34,$14,$14,$14,$00 !byte $38,$44,$30,$28,$18,$44,$38,$00 !byte $00,$00,$00,$00,$00,$78,$78,$00 !byte $10,$38,$7C,$10,$7C,$38,$10,$38 !byte $10,$38,$7C,$10,$10,$10,$10,$00 !byte $10,$10,$10,$10,$7C,$38,$10,$00 !byte $00,$10,$18,$7C,$18,$10,$00,$00 !byte $00,$10,$30,$7C,$30,$10,$00,$00 !byte $00,$00,$00,$40,$40,$40,$7C,$00 !byte $00,$28,$28,$7C,$28,$28,$00,$00 !byte $10,$10,$38,$38,$7C,$7C,$00,$00 !byte $7C,$7C,$38,$38,$10,$10,$00,$00 !byte $00,$00,$00,$00,$00,$00,$00,$00 ; <SPACE> !byte $10,$38,$38,$10,$10,$00,$10,$00 ; ! !byte $6C,$6C,$48,$00,$00,$00,$00,$00 ; " !byte $00,$28,$7C,$28,$28,$7C,$28,$00 ; # !byte $20,$38,$40,$30,$08,$70,$10,$00 ; $ !byte $64,$64,$08,$10,$20,$4C,$4C,$00 ; % !byte $20,$50,$50,$20,$54,$48,$34,$00 ; & !byte $30,$30,$20,$00,$00,$00,$00,$00 ; ' !byte $10,$20,$20,$20,$20,$20,$10,$00 ; ( !byte $20,$10,$10,$10,$10,$10,$20,$00 ; ) !byte $00,$28,$38,$7C,$38,$28,$00,$00 ; * !byte $00,$10,$10,$7C,$10,$10,$00,$00 ; + !byte $00,$00,$00,$00,$00,$30,$30,$20 ; , !byte $00,$00,$00,$7C,$00,$00,$00,$00 ; - !byte $00,$00,$00,$00,$00,$30,$30,$00 ; . !byte $00,$04,$08,$10,$20,$40,$00,$00 ; / !byte $38,$44,$4C,$54,$64,$44,$38,$00 ; 0 !byte $10,$30,$10,$10,$10,$10,$38,$00 ; 1 !byte $38,$44,$04,$18,$20,$40,$7C,$00 ; 2 !byte $38,$44,$04,$38,$04,$44,$38,$00 ; 3 !byte $08,$18,$28,$48,$7C,$08,$08,$00 ; 4 !byte $7C,$40,$40,$78,$04,$44,$38,$00 ; 5 !byte $18,$20,$40,$78,$44,$44,$38,$00 ; 6 !byte $7C,$04,$08,$10,$20,$20,$20,$00 ; 7 !byte $38,$44,$44,$38,$44,$44,$38,$00 ; 8 !byte $38,$44,$44,$3C,$04,$08,$30,$00 ; 9 !byte $00,$00,$30,$30,$00,$30,$30,$00 ; : !byte $00,$00,$30,$30,$00,$30,$30,$20 ; ; !byte $08,$10,$20,$40,$20,$10,$08,$00 ; < !byte $00,$00,$7C,$00,$00,$7C,$00,$00 ; = !byte $20,$10,$08,$04,$08,$10,$20,$00 ; > !byte $38,$44,$04,$18,$10,$00,$10,$00 ; ? !byte $38,$44,$5C,$54,$5C,$40,$38,$00 ; @ !byte $38,$44,$44,$44,$7C,$44,$44,$00 ; A !byte $78,$44,$44,$78,$44,$44,$78,$00 ; B !byte $38,$44,$40,$40,$40,$44,$38,$00 ; C !byte $78,$44,$44,$44,$44,$44,$78,$00 ; D !byte $7C,$40,$40,$78,$40,$40,$7C,$00 ; E !byte $7C,$40,$40,$78,$40,$40,$40,$00 ; F !byte $38,$44,$40,$5C,$44,$44,$3C,$00 ; G !byte $44,$44,$44,$7C,$44,$44,$44,$00 ; H !byte $38,$10,$10,$10,$10,$10,$38,$00 ; I !byte $04,$04,$04,$04,$44,$44,$38,$00 ; J !byte $44,$48,$50,$60,$50,$48,$44,$00 ; K !byte $40,$40,$40,$40,$40,$40,$7C,$00 ; L !byte $44,$6C,$54,$44,$44,$44,$44,$00 ; M !byte $44,$64,$54,$4C,$44,$44,$44,$00 ; N !byte $38,$44,$44,$44,$44,$44,$38,$00 ; O !byte $78,$44,$44,$78,$40,$40,$40,$00 ; P !byte $38,$44,$44,$44,$54,$48,$34,$00 ; Q !byte $78,$44,$44,$78,$48,$44,$44,$00 ; R !byte $38,$44,$40,$38,$04,$44,$38,$00 ; S !byte $7C,$10,$10,$10,$10,$10,$10,$00 ; T !byte $44,$44,$44,$44,$44,$44,$38,$00 ; U !byte $44,$44,$44,$44,$44,$28,$10,$00 ; V !byte $44,$44,$54,$54,$54,$54,$28,$00 ; W !byte $44,$44,$28,$10,$28,$44,$44,$00 ; X !byte $44,$44,$44,$28,$10,$10,$10,$00 ; Y !byte $78,$08,$10,$20,$40,$40,$78,$00 ; Z !byte $38,$20,$20,$20,$20,$20,$38,$00 ; [ !byte $00,$40,$20,$10,$08,$04,$00,$00 ; \ !byte $38,$08,$08,$08,$08,$08,$38,$00 ; ] !byte $10,$28,$44,$00,$00,$00,$00,$00 ; ^ !byte $00,$00,$00,$00,$00,$00,$00,$FC ; _ !byte $30,$30,$10,$00,$00,$00,$00,$00 ; ` !byte $00,$00,$38,$04,$3C,$44,$3C,$00 ; a !byte $40,$40,$78,$44,$44,$44,$78,$00 ; b !byte $00,$00,$38,$44,$40,$44,$38,$00 ; c !byte $04,$04,$3C,$44,$44,$44,$3C,$00 ; d !byte $00,$00,$38,$44,$78,$40,$38,$00 ; e !byte $18,$20,$20,$78,$20,$20,$20,$00 ; f !byte $00,$00,$3C,$44,$44,$3C,$04,$38 ; g !byte $40,$40,$70,$48,$48,$48,$48,$00 ; h !byte $10,$00,$10,$10,$10,$10,$18,$00 ; i !byte $08,$00,$18,$08,$08,$08,$48,$30 ; j !byte $40,$40,$48,$50,$60,$50,$48,$00 ; k !byte $10,$10,$10,$10,$10,$10,$18,$00 ; l !byte $00,$00,$68,$54,$54,$44,$44,$00 ; m !byte $00,$00,$70,$48,$48,$48,$48,$00 ; n !byte $00,$00,$38,$44,$44,$44,$38,$00 ; o !byte $00,$00,$78,$44,$44,$44,$78,$40 ; p !byte $00,$00,$3C,$44,$44,$44,$3C,$04 ; q !byte $00,$00,$58,$24,$20,$20,$70,$00 ; r !byte $00,$00,$38,$40,$38,$04,$38,$00 ; s !byte $00,$20,$78,$20,$20,$28,$10,$00 ; t !byte $00,$00,$48,$48,$48,$58,$28,$00 ; u !byte $00,$00,$44,$44,$44,$28,$10,$00 ; v !byte $00,$00,$44,$44,$54,$7C,$28,$00 ; w !byte $00,$00,$48,$48,$30,$48,$48,$00 ; x !byte $00,$00,$48,$48,$48,$38,$10,$60 ; y !byte $00,$00,$78,$08,$30,$40,$78,$00 ; z !byte $18,$20,$20,$60,$20,$20,$18,$00 ; { !byte $10,$10,$10,$00,$10,$10,$10,$00 ; | !byte $30,$08,$08,$0C,$08,$08,$30,$00 ; } !byte $28,$50,$00,$00,$00,$00,$00,$00 ; ~ !byte $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; !byte $38,$44,$40,$40,$44,$38,$10,$30 !byte $48,$00,$48,$48,$48,$58,$28,$00 !byte $0C,$00,$38,$44,$78,$40,$38,$00 !byte $38,$00,$38,$04,$3C,$44,$3C,$00 !byte $28,$00,$38,$04,$3C,$44,$3C,$00 !byte $30,$00,$38,$04,$3C,$44,$3C,$00 !byte $38,$28,$38,$04,$3C,$44,$3C,$00 !byte $00,$38,$44,$40,$44,$38,$10,$30 !byte $38,$00,$38,$44,$78,$40,$38,$00 !byte $28,$00,$38,$44,$78,$40,$38,$00 !byte $30,$00,$38,$44,$78,$40,$38,$00 !byte $28,$00,$10,$10,$10,$10,$18,$00 !byte $10,$28,$00,$10,$10,$10,$18,$00 !byte $20,$00,$10,$10,$10,$10,$18,$00 !byte $28,$00,$10,$28,$44,$7C,$44,$00 !byte $38,$28,$38,$6C,$44,$7C,$44,$00 !byte $0C,$00,$7C,$40,$78,$40,$7C,$00 !byte $00,$00,$78,$14,$7C,$50,$3C,$00 !byte $3C,$50,$50,$7C,$50,$50,$5C,$00 !byte $38,$00,$30,$48,$48,$48,$30,$00 !byte $28,$00,$30,$48,$48,$48,$30,$00 !byte $60,$00,$30,$48,$48,$48,$30,$00 !byte $38,$00,$48,$48,$48,$58,$28,$00 !byte $60,$00,$48,$48,$48,$58,$28,$00 !byte $28,$00,$48,$48,$48,$38,$10,$60 !byte $48,$30,$48,$48,$48,$48,$30,$00 !byte $28,$00,$48,$48,$48,$48,$30,$00 !byte $00,$10,$38,$40,$40,$38,$10,$00 !byte $18,$24,$20,$78,$20,$24,$5C,$00 !byte $44,$28,$10,$7C,$10,$7C,$10,$00 !byte $60,$50,$50,$68,$5C,$48,$48,$00 !byte $08,$14,$10,$38,$10,$10,$50,$20 !byte $18,$00,$38,$04,$3C,$44,$3C,$00 !byte $18,$00,$10,$10,$10,$10,$18,$00 !byte $18,$00,$30,$48,$48,$48,$30,$00 !byte $18,$00,$48,$48,$48,$58,$28,$00 !byte $28,$50,$00,$70,$48,$48,$48,$00 !byte $28,$50,$00,$48,$68,$58,$48,$00 !byte $38,$04,$3C,$44,$3C,$00,$3C,$00 !byte $30,$48,$48,$48,$30,$00,$78,$00 !byte $10,$00,$10,$30,$40,$44,$38,$00 !byte $00,$00,$7C,$40,$40,$40,$00,$00 !byte $00,$00,$FC,$04,$04,$00,$00,$00 !byte $40,$48,$50,$38,$44,$08,$1C,$00 !byte $40,$48,$50,$2C,$54,$1C,$04,$00 !byte $10,$00,$10,$10,$38,$38,$10,$00 !byte $00,$00,$24,$48,$24,$00,$00,$00 !byte $00,$00,$48,$24,$48,$00,$00,$00 !byte $54,$00,$A8,$00,$54,$00,$A8,$00 !byte $54,$A8,$54,$A8,$54,$A8,$54,$A8 !byte $A8,$FC,$54,$FC,$A8,$FC,$54,$FC !byte $10,$10,$10,$10,$10,$10,$10,$10 !byte $10,$10,$10,$F0,$10,$10,$10,$10 !byte $10,$F0,$10,$F0,$10,$10,$10,$10 !byte $50,$50,$50,$D0,$50,$50,$50,$50 !byte $00,$00,$00,$F0,$50,$50,$50,$50 !byte $00,$F0,$10,$F0,$10,$10,$10,$10 !byte $50,$D0,$10,$D0,$50,$50,$50,$50 !byte $50,$50,$50,$50,$50,$50,$50,$50 !byte $00,$F0,$10,$D0,$50,$50,$50,$50 !byte $50,$D0,$10,$F0,$00,$00,$00,$00 !byte $50,$50,$50,$F0,$00,$00,$00,$00 !byte $10,$F0,$10,$F0,$00,$00,$00,$00 !byte $00,$00,$00,$F0,$10,$10,$10,$10 !byte $10,$10,$10,$1C,$00,$00,$00,$00 !byte $10,$10,$10,$FC,$00,$00,$00,$00 !byte $00,$00,$00,$FC,$10,$10,$10,$10 !byte $10,$10,$10,$1C,$10,$10,$10,$10 !byte $00,$00,$00,$FC,$00,$00,$00,$00 !byte $10,$10,$10,$FC,$10,$10,$10,$10 !byte $10,$1C,$10,$1C,$10,$10,$10,$10 !byte $50,$50,$50,$5C,$50,$50,$50,$50 !byte $50,$5C,$40,$7C,$00,$00,$00,$00 !byte $00,$7C,$40,$5C,$50,$50,$50,$50 !byte $50,$DC,$00,$FC,$00,$00,$00,$00 !byte $00,$FC,$00,$DC,$50,$50,$50,$50 !byte $50,$5C,$40,$5C,$50,$50,$50,$50 !byte $00,$FC,$00,$FC,$00,$00,$00,$00 !byte $50,$DC,$00,$DC,$50,$50,$50,$50 !byte $10,$FC,$00,$FC,$00,$00,$00,$00 !byte $50,$50,$50,$FC,$00,$00,$00,$00 !byte $00,$FC,$00,$FC,$10,$10,$10,$10 !byte $00,$00,$00,$FC,$50,$50,$50,$50 !byte $50,$50,$50,$7C,$00,$00,$00,$00 !byte $10,$1C,$10,$1C,$00,$00,$00,$00 !byte $00,$1C,$10,$1C,$10,$10,$10,$10 !byte $00,$00,$00,$7C,$50,$50,$50,$50 !byte $50,$50,$50,$DC,$50,$50,$50,$50 !byte $10,$FC,$00,$FC,$10,$10,$10,$10 !byte $10,$10,$10,$F0,$00,$00,$00,$00 !byte $00,$00,$00,$1C,$10,$10,$10,$10 !byte $FC,$FC,$FC,$FC,$FC,$FC,$FC,$FC !byte $00,$00,$00,$00,$FC,$FC,$FC,$FC !byte $E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0 !byte $1C,$1C,$1C,$1C,$1C,$1C,$1C,$1C !byte $FC,$FC,$FC,$FC,$00,$00,$00,$00 !byte $00,$00,$34,$48,$48,$34,$00,$00 !byte $00,$70,$48,$70,$48,$48,$70,$40 !byte $78,$48,$40,$40,$40,$40,$40,$00 !byte $00,$7C,$28,$28,$28,$28,$28,$00 !byte $78,$48,$20,$10,$20,$48,$78,$00 !byte $00,$00,$3C,$48,$48,$30,$00,$00 !byte $00,$00,$48,$48,$48,$70,$40,$40 !byte $00,$00,$28,$50,$10,$10,$10,$00 !byte $38,$10,$38,$44,$38,$10,$38,$00 !byte $30,$48,$48,$78,$48,$48,$30,$00 !byte $00,$38,$44,$44,$28,$28,$6C,$00 !byte $30,$40,$20,$10,$38,$48,$30,$00 !byte $00,$00,$28,$54,$54,$28,$00,$00 !byte $00,$10,$38,$54,$54,$38,$10,$00 !byte $00,$38,$40,$78,$40,$38,$00,$00 !byte $00,$30,$48,$48,$48,$48,$00,$00 !byte $00,$78,$00,$78,$00,$78,$00,$00 !byte $00,$10,$38,$10,$00,$38,$00,$00 !byte $40,$30,$08,$30,$40,$00,$78,$00 !byte $08,$30,$40,$30,$08,$00,$78,$00 !byte $00,$08,$14,$10,$10,$10,$10,$10 !byte $10,$10,$10,$10,$10,$50,$20,$00 !byte $00,$10,$00,$7C,$00,$10,$00,$00 !byte $00,$28,$50,$00,$28,$50,$00,$00 !byte $30,$48,$48,$30,$00,$00,$00,$00 !byte $00,$00,$00,$30,$30,$00,$00,$00 !byte $00,$00,$00,$20,$00,$00,$00,$00 !byte $00,$1C,$10,$10,$50,$50,$20,$00 !byte $50,$28,$28,$28,$00,$00,$00,$00 !byte $60,$10,$20,$70,$00,$00,$00,$00 !byte $00,$00,$78,$78,$78,$78,$00,$00 !byte $00,$00,$00,$00,$00,$00,$00,$00
//===--- DeprecatedHeadersCheck.cpp - clang-tidy---------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "DeprecatedHeadersCheck.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSet.h" #include <vector> namespace clang { namespace tidy { namespace modernize { namespace { class IncludeModernizePPCallbacks : public PPCallbacks { public: explicit IncludeModernizePPCallbacks(ClangTidyCheck &Check, LangOptions LangOpts); void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported, SrcMgr::CharacteristicKind FileType) override; private: ClangTidyCheck &Check; LangOptions LangOpts; llvm::StringMap<std::string> CStyledHeaderToCxx; llvm::StringSet<> DeleteHeaders; }; } // namespace void DeprecatedHeadersCheck::registerPPCallbacks(CompilerInstance &Compiler) { if (this->getLangOpts().CPlusPlus) { Compiler.getPreprocessor().addPPCallbacks( ::llvm::make_unique<IncludeModernizePPCallbacks>(*this, this->getLangOpts())); } } IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck &Check, LangOptions LangOpts) : Check(Check), LangOpts(LangOpts) { for (const auto &KeyValue : std::vector<std::pair<llvm::StringRef, std::string>>( {{"assert.h", "cassert"}, {"complex.h", "complex"}, {"ctype.h", "cctype"}, {"errno.h", "cerrno"}, {"float.h", "cfloat"}, {"limits.h", "climits"}, {"locale.h", "clocale"}, {"math.h", "cmath"}, {"setjmp.h", "csetjmp"}, {"signal.h", "csignal"}, {"stdarg.h", "cstdarg"}, {"stddef.h", "cstddef"}, {"stdio.h", "cstdio"}, {"stdlib.h", "cstdlib"}, {"string.h", "cstring"}, {"time.h", "ctime"}, {"wchar.h", "cwchar"}, {"wctype.h", "cwctype"}})) { CStyledHeaderToCxx.insert(KeyValue); } // Add C++ 11 headers. if (LangOpts.CPlusPlus11) { for (const auto &KeyValue : std::vector<std::pair<llvm::StringRef, std::string>>( {{"fenv.h", "cfenv"}, {"stdint.h", "cstdint"}, {"inttypes.h", "cinttypes"}, {"tgmath.h", "ctgmath"}, {"uchar.h", "cuchar"}})) { CStyledHeaderToCxx.insert(KeyValue); } } for (const auto &Key : std::vector<std::string>({"stdalign.h", "stdbool.h", "iso646.h"})) { DeleteHeaders.insert(Key); } } void IncludeModernizePPCallbacks::InclusionDirective( SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported, SrcMgr::CharacteristicKind FileType) { // FIXME: Take care of library symbols from the global namespace. // // Reasonable options for the check: // // 1. Insert std prefix for every such symbol occurrence. // 2. Insert `using namespace std;` to the beginning of TU. // 3. Do nothing and let the user deal with the migration himself. if (CStyledHeaderToCxx.count(FileName) != 0) { std::string Replacement = (llvm::Twine("<") + CStyledHeaderToCxx[FileName] + ">").str(); Check.diag(FilenameRange.getBegin(), "inclusion of deprecated C++ header " "'%0'; consider using '%1' instead") << FileName << CStyledHeaderToCxx[FileName] << FixItHint::CreateReplacement(FilenameRange.getAsRange(), Replacement); } else if (DeleteHeaders.count(FileName) != 0) { Check.diag(FilenameRange.getBegin(), "including '%0' has no effect in C++; consider removing it") << FileName << FixItHint::CreateRemoval( SourceRange(HashLoc, FilenameRange.getEnd())); } } } // namespace modernize } // namespace tidy } // namespace clang
; FILE *freopen(char *filename, char *mode, FILE *stream) INCLUDE "config_private.inc" SECTION code_clib SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _freopen EXTERN asm_freopen _freopen: pop af pop hl pop de pop ix push hl push de push hl push af jp asm_freopen ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _freopen EXTERN _freopen_unlocked defc _freopen = _freopen_unlocked ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;================================================================= ; ; Copyright (c) 2014, Teriks ; ; All rights reserved. ; ; libasm_io is distributed under the following BSD 3-Clause License ; ; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ; ; 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. ; ; 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; ; 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from ; this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ; ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; ;================================================================== ;the following is defined when the library examples are being built with the library %ifdef _LIBASM_IO_BUILDING_ ;if the library build system is building the examples, then an option to NASM specifies the directory ;to find this include, so we can include it by its name only %include "libasm_io.inc" %else ;otherwise if this code is compiled against the already installed library ;it's header needs to be included from its installed location %include "/usr/local/include/libasm_io.inc" %endif ;main gets called by the C runtime library, so it needs to be global to let the linker find it ;the cglobal macro from the library is used to add an underscore to the front of main if needed ;some platforms (Like Mac) use underscores in front of all their C library symbols ;the macro also defines main as _main if an underscore is needed, so we can reference it as 'main' ;consistently across platforms cglobal main section .data ;a message to print when we enter main ;db stands for define bytes and the 0 at the end is the null terminator, ;so print_string knows when the string ends hello: db "Hello World!",0 section .text main: ;set up a new stack frame, first save the old stack base pointer by pushing it push rbp ;then slide the base of the stack down to RSP by moving RSP into RBP mov rbp, rsp ;Windows requires a minimum of 32 bytes on the stack before calling any other functions ;so this is for compatibility, its perfectly valid on Linux and Mac also sub rsp, 32 ;move the pointer to our hello message into RDI, RDI is the first parameter to print string mov rdi, QWORD hello call print_string ;prints new line to the console call print_nl ;restore the stack frame of the function that called this function ;first add back the amount that we subtracted from RSP ;including any additional subtractions we made to RSP after the initial one (just sum them) add rsp, 32 ;after we add what we subtracted back to RSP, the value of RBP we pushed is the only thing left ;so we pop it back into RBP to restore the stack base pointer pop rbp ret
; A096273: a(0)=0, then a(n)=a(n-1)+(n-1) if n is odd, a(n)=a(n/2)+n/2 otherwise. ; 0,0,1,3,3,7,6,12,7,15,12,22,12,24,19,33,15,31,24,42,22,42,33,55,24,48,37,63,33,61,48,78,31,63,48,82,42,78,61,99,42,82,63,105,55,99,78,124,48,96,73,123,63,115,90,144,61,117,90,148,78,138,109,171,63,127,96,162,82 lpb $0,1 mov $2,$0 div $0,2 lpb $2,1 mul $0,2 mov $2,$0 lpe add $1,$0 lpe
title "Interval Clock Interrupt" ;++ ; ; Copyright (c) 1989 Microsoft Corporation ; Copyright (c) 1992 Intel Corporation ; All rights reserved ; ; INTEL CORPORATION PROPRIETARY INFORMATION ; ; This software is supplied to Microsoft under the terms ; of a license agreement with Intel Corporation and may not be ; copied nor disclosed except in accordance with the terms ; of that agreement. ; ; ; Module Name: ; ; mpclock.asm ; ; Abstract: ; ; This module implements the code necessary to field and process the ; interval clock interrupt. ; ; Author: ; ; Shie-Lin Tzong (shielint) 12-Jan-1990 ; ; Environment: ; ; Kernel mode only. ; ; Revision History: ; ; Ron Mosgrove (Intel) Aug 1993 ; Modified to support PC+MP Systems ;-- .586p .xlist include hal386.inc include i386\ix8259.inc include i386\ixcmos.inc include callconv.inc include i386\kimacro.inc include mac386.inc include apic.inc include ntapic.inc include i386\mp8254.inc .list EXTRNP _KeUpdateSystemTime,0 EXTRNP _KeUpdateRunTime,1,IMPORT EXTRNP Kei386EoiHelper,0,IMPORT EXTRNP _HalEndSystemInterrupt,2 EXTRNP _HalBeginSystemInterrupt,3 EXTRNP _HalpAcquireCmosSpinLock ,0 EXTRNP _HalpReleaseCmosSpinLock ,0 EXTRNP _HalpAcquireSystemHardwareSpinLock ,0 EXTRNP _HalpReleaseSystemHardwareSpinLock ,0 EXTRNP _HalpSetInitialClockRate,0 EXTRNP _HalpMcaQueueDpc, 0 EXTRNP _KeQueryPerformanceCounter, 1 extrn _HalpRtcTimeIncrements:DWORD extrn _KdEnteredDebugger:DWORD extrn _HalpTimerWatchdogEnabled:DWORD extrn _HalpTimerWatchdogStorage:DWORD extrn _HalpTimerWatchdogCurFrame:DWORD extrn _HalpTimerWatchdogLastFrame:DWORD extrn _HalpTimerWatchdogStorageOverflow:DWORD ifdef ACPI_HAL ifdef NT_UP EXTRNP _HalpBrokenPiix4TimerTick, 0 extrn _HalpBrokenAcpiTimer:byte endif endif ifdef MMTIMER EXTRNP _HalpmmTimerClockInterrupt, 0 MMT_VECTOR EQU 0D3h endif ; ; Constants used to initialize CMOS/Real Time Clock ; CMOS_CONTROL_PORT EQU 70h ; command port for cmos CMOS_DATA_PORT EQU 71h ; cmos data port CMOS_STATUS_BUSY EQU 80H ; Time update in progress D_INT032 EQU 8E00h ; access word for 386 ring 0 interrupt gate REGISTER_B_ENABLE_PERIODIC_INTERRUPT EQU 01000010B ; RT/CMOS Register 'B' Init byte ; Values for byte shown are ; Bit 7 = Update inhibit ; Bit 6 = Periodic interrupt enable ; Bit 5 = Alarm interrupt disable ; Bit 4 = Update interrupt disable ; Bit 3 = Square wave disable ; Bit 2 = BCD data format ; Bit 1 = 24 hour time mode ; Bit 0 = Daylight Savings disable REGISTER_B_DISABLE_PERIODIC_INTERRUPT EQU 00000010B ; ; RegisterAInitByte sets 8Hz clock rate, used during init to set up ; KeStallExecutionProcessor, etc. (See RegASystemClockByte below.) ; RegisterAInitByte EQU 00101101B ; RT/CMOS Register 'A' init byte ; 32.768KHz Base divider rate ; 8Hz int rate, period = 125.0ms PeriodInMicroSecond EQU 125000 ; COUNTER_TICKS_AVG_SHIFT EQU 4 COUNTER_TICKS_FOR_AVG EQU 16 PAGE_SIZE EQU 1000H FRAME_COPY_SIZE EQU 64 _DATA SEGMENT DWORD PUBLIC 'DATA' ; ; There is a "C" version of this structure in MPCLOCKC.C ; TimeStrucSize EQU 20 RtcTimeIncStruc struc RTCRegisterA dd 0 ;The RTC register A value for this rate RateIn100ns dd 0 ;This rate in multiples of 100ns RateAdjustmentNs dd 0 ;Error Correction (in ns) RateAdjustmentCnt dd 0 ;Error Correction (as a fraction of 256) IpiRate dd 0 ;IPI Rate Count (as a fraction of 256) RtcTimeIncStruc ends ifdef DBGSSF DebugSSFStruc struc SSFCount1 dd 0 SSFCount2 dd 0 SSFRdtsc1 dd 0 SSFRdtsc2 dd 0 SSFRdtsc3 dd 0 SSFRna1 dd 0 SSFRna2 dd 0 SSFRna3 dd 0 DebugSSFStruc ends public HalpDbgSSF HalpDbgSSF db (size DebugSSFStruc) * 10 dup (0) endif ALIGN dword public RTCClockFreq public RegisterAClockValue RTCClockFreq dd 156250 RegisterAClockValue dd 00101010B ; default interval = 15.6250 ms MINIMUM_STALL_FACTOR EQU 10H ; Reasonable Minimum public HalpP0StallFactor HalpP0StallFactor dd MINIMUM_STALL_FACTOR public HalpInitStallComputedCount HalpInitStallComputedCount dd 0 public HalpInitStallLoopCount HalpInitStallLoopCount dd 0 ALIGN dword ; ; Clock Rate Adjustment Counter. This counter is used to keep a tally of ; adjustments needed to be applied to the RTC rate as passed to the ; kernel. ; public _HalpCurrentRTCRegisterA, _HalpCurrentClockRateIn100ns public _HalpCurrentClockRateAdjustment, _HalpCurrentIpiRate public _HalpIpiRateCounter, _HalpNextMSRate, _HalpPendingRate public _HalpRateAdjustment _HalpCurrentRTCRegisterA dd 0 _HalpCurrentClockRateIn100ns dd 0 _HalpCurrentClockRateAdjustment dd 0 _HalpCurrentIpiRate dd 0 _HalpIpiRateCounter dd 0 _HalpNextMSRate dd 0 _HalpPendingRate dd 0 _HalpRateAdjustment dd 0 ifdef ACPI_HAL public _HalpCurrentMSRateTableIndex _HalpCurrentMSRateTableIndex dd 0 endif ; ; HalpUse8254 - flag to indicate 8254 should be used ; HalpSample8254 - count to sample 8254 ; ; N.B. access to the 8254 is gaurded with the Cmos lock ; public _HalpUse8254 _HalpUse8254 db 0 _HalpSample8254 db 0 _b8254Reserved dw 0 ; ; Flag to tell clock routine when P0 can Ipi Other processors ; public _HalpIpiClock _HalpIpiClock dd 0 public _HalpClockWork, _HalpClockSetMSRate, _HalpClockMcaQueueDpc _HalpClockWork label dword _HalpClockSetMSRate db 0 _HalpClockMcaQueueDpc db 0 _bReserved1 db 0 _bReserved2 db 0 ; ; timer latency watchdog variables ; public _HalpWatchdogAvgCounter, _HalpWatchdogCountLow, _HalpWatchdogCountHigh public _HalpWatchdogTscLow, _HalpWatchdogTscHigh _HalpWatchdogAvgCounter dd 0 _HalpWatchdogCountLow dd 0 _HalpWatchdogCountHigh dd 0 _HalpWatchdogTscLow dd 0 _HalpWatchdogTscHigh dd 0 _DATA ends PAGELK SEGMENT PARA PUBLIC 'CODE' ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING page ,132 subttl "Initialize Clock" ;++ ; ; VOID ; HalpInitializeClock ( ; ) ; ; Routine Description: ; ; This routine initialize system time clock using RTC to generate an ; interrupt at every 15.6250 ms interval at APIC_CLOCK_VECTOR ; ; It also initializes the 8254 if the 8254 is to be used for performance ; counters. ; ; See the definition of RegisterAClockValue if clock rate needs to be ; changed. ; ; This routine assumes it runs during Phase 0 on P0. ; ; Arguments: ; ; None ; ; Return Value: ; ; None. ; ;-- cPublicProc _HalpInitializeClock ,0 ; ; timer latency watchdog initialization ; cmp _HalpTimerWatchdogEnabled, 0 jz short @f rdtsc mov _HalpWatchdogAvgCounter, COUNTER_TICKS_FOR_AVG mov _HalpWatchdogTscLow, eax mov _HalpWatchdogTscHigh, edx xor eax, eax mov _HalpWatchdogCountLow, eax mov _HalpWatchdogCountHigh, eax @@: pushfd ; save caller's eflag cli ; make sure interrupts are disabled stdCall _HalpSetInitialClockRate ; ; Set the interrupt rate to what is actually needed ; stdCall _HalpAcquireCmosSpinLock ; intr disabled mov eax, _HalpCurrentRTCRegisterA shl ax, 8 mov al, 0AH ; Register A CMOS_WRITE ; Initialize it ; ; Don't clobber the Daylight Savings Time bit in register B, because we ; stash the LastKnownGood "environment variable" there. ; mov ax, 0bh CMOS_READ and al, 1 mov ah, al or ah, REGISTER_B_ENABLE_PERIODIC_INTERRUPT mov al, 0bh CMOS_WRITE ; Initialize it mov al,0CH ; Register C CMOS_READ ; Read to initialize mov al,0DH ; Register D CMOS_READ ; Read to initialize stdCall _HalpReleaseCmosSpinLock ; ; For HALAACPI (free), init the 8254 so we can use it to ; verify the ACPI timer frequency ; ifdef ACPI_HAL ifdef NT_UP jmp short Hic50 endif endif cmp _HalpUse8254, 0 jz short Hic90 Hic50: stdCall _HalpAcquireSystemHardwareSpinLock ; intr disabled ; Program 8254 to count down the maximum interval ; (8254 access is gaurded with CmosSpinLock) mov eax, PERFORMANCE_INTERVAL mov ecx, eax ; set up counter 0 for periodic, binary count-down from max value mov al,COMMAND_8254_COUNTER0+COMMAND_8254_RW_16BIT+COMMAND_8254_MODE2 out TIMER1_CONTROL_PORT0, al ; program count mode of timer 0 IoDelay mov al, cl out TIMER1_DATA_PORT0, al ; program counter 0 LSB count IoDelay mov al,ch out TIMER1_DATA_PORT0, al ; program counter 0 MSB count or _HalpUse8254, PERF_8254_INITIALIZED stdCall _HalpReleaseSystemHardwareSpinLock Hic90: popfd ; restore caller's eflag stdRET _HalpInitializeClock stdENDP _HalpInitializeClock PAGELK ends _TEXT SEGMENT PARA PUBLIC 'CODE' ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING page ,132 subttl "System Clock Interrupt" ;++ ; ; Routine Description: ; ; ; This routine is entered as the result of an interrupt generated by CLOCK2. ; Its function is to dismiss the interrupt, raise system Irql to ; CLOCK2_LEVEL, update performance counter and transfer control to the ; standard system routine to update the system time and the execution ; time of the current thread ; and process. ; ; ; Arguments: ; ; None ; Interrupt is disabled ; ; Return Value: ; ; Does not return, jumps directly to KeUpdateSystemTime, which returns ; ; Sets Irql = CLOCK2_LEVEL and dismisses the interrupt ; ;-- APIC_ICR_CLOCK equ (DELIVER_FIXED OR ICR_ALL_EXCL_SELF OR APIC_CLOCK_VECTOR) ENTER_DR_ASSIST Hci_a, Hci_t cPublicProc _HalpClockInterrupt ,0 ; ; Save machine state in trap frame ; ENTER_INTERRUPT Hci_a, Hci_t ; ; (esp) - base of trap frame ; ; dismiss interrupt and raise Irql ; push APIC_CLOCK_VECTOR sub esp, 4 ; allocate space to save OldIrql stdCall _HalBeginSystemInterrupt, <CLOCK2_LEVEL,APIC_CLOCK_VECTOR,esp> ifdef NT_UP ifdef ACPI_HAL ; ; Check to see if we need to fix up a broken PIIX4 ; .if (_HalpBrokenAcpiTimer) stdCall _HalpBrokenPiix4TimerTick .endif endif endif mov al, _HalpUse8254 or al, al jz short Hci90 add _HalpSample8254, 56h jnc short Hci90 ; Call KeQueryPerformanceCounter() so that wrap-around of 8254 is ; detected and the base value for performance counters updated. ; Ignore returned value and reset HalpSample8254. ; ; WARNING - change increment value above if maximum RTC time increment ; is increased to be more than current maximum value of 15.625 ms. ; Currently the call will be made every 3rd timer tick. xor eax, eax mov _HalpSample8254, al stdCall _KeQueryPerformanceCounter, <eax> Hci90: ; ; This is the RTC interrupt, so we have to clear the ; interrupt flag on the RTC. ; stdCall _HalpAcquireCmosSpinLock ; ; clear interrupt flag on RTC by banging on the CMOS. On some systems this ; doesn't work the first time we do it, so we do it twice. It is rumored that ; some machines require more than this, but that hasn't been observed with NT. ; mov al,0CH ; Register C CMOS_READ ; Read to initialize mov al,0CH ; Register C CMOS_READ ; Read to initialize stdCall _HalpReleaseCmosSpinLock mov eax, _HalpCurrentClockRateIn100ns xor ebx, ebx ; ; Adjust the tick count as needed ; mov ecx, _HalpCurrentClockRateAdjustment add byte ptr _HalpRateAdjustment, cl sbb eax, ebx ; ; (esp) = OldIrql ; (esp+4) = Vector ; (esp+8) = base of trap frame ; eax = time increment of this tick ; ebx = 0 ; ; ; With an APIC Based System we will force a clock interrupt to all other ; processors. This is not really an IPI in the NT sense of the word, it ; uses the Local Apic to generate interrupts to other CPU's. ; ifdef NT_UP ; UP implemention, we don't care about IPI's here else ; ! NT_UP ; ; See if we need to IPI anyone, this happens only at the ; Lowest supported frequency (ie the value KeSetTimeIncrement ; is called with. We have a IPI Rate based upon the current ; clock rate relative to the lowest clock rate. ; mov ecx, _HalpIpiRateCounter add ecx, _HalpCurrentIpiRate cmp ch, bl mov byte ptr _HalpIpiRateCounter, cl jz short HalpDontSendClockIpi ; No, Skip it ; ; Don't send vectors onto the APIC bus until at least one other ; processor comes on line. Vectors placed on the bus will hang ; around until someone picks them up. ; cmp _HalpIpiClock, ebx je short HalpDontSendClockIpi ; ; At least one other processor is alive, send clock pulse to all ; other processors ; ; We use a destination shorthand and therefore only needs to ; write the lower 32 bits of the ICR. pushfd cli ; ; Now issue the Clock IPI Command by writing to the Memory Mapped Register ; STALL_WHILE_APIC_BUSY mov dword ptr APIC[LU_INT_CMD_LOW], APIC_ICR_CLOCK popfd HalpDontSendClockIpi: endif ; NT_UP cmp dword ptr _HalpTimerWatchdogEnabled, 0 jz Hci15 push eax ; ; Timer latency watchdog code ; rdtsc ; ; Compare difference to watchdog count, while storing a copy of the ; current counter. ; push eax push edx sub eax, _HalpWatchdogTscLow sbb edx, _HalpWatchdogTscHigh pop _HalpWatchdogTscHigh pop _HalpWatchdogTscLow js Hci115 ; Was this a bogus counter? ; (e.g, negative delta) push eax push edx mov ecx, dword ptr _KdEnteredDebugger mov eax, [ecx] ; eax = xor edx, edx ; InterlockedExchange( @@: cmpxchg [ecx], edx ; &KdEnteredDebugger, jnz short @b ; TRUE ); or al, al pop edx pop eax jnz Hci14 ; In the debugger? Yes, skip it. cmp _HalpPendingRate, ebx ; Was a new rate set during last jnz Hci14 ; tick? Yes, skip this compare ; ; If we need to compute the average of the time-stamp counter for ; the current period, add the delta to the counter. ; cmp _HalpWatchdogAvgCounter, ebx jnz Hci12 cmp edx, _HalpWatchdogCountHigh ja short Hci11 jb Hci14 cmp eax, _HalpWatchdogCountLow jbe Hci14 Hci11: cmp dword ptr [_HalpTimerWatchdogCurFrame], 0 je short Hci115 cmp dword ptr [_HalpTimerWatchdogStorageOverflow], 0 jne short Hci115 ; ; copy FRAME_COPY_SIZE dwords from the stack, or to next page boundary, ; whichever is less ; push esi push edi lea esi, [esp+8] lea ecx, [esi + PAGE_SIZE - 1] and ecx, NOT(PAGE_SIZE - 1) sub ecx, esi shr ecx, 2 cmp ecx, FRAME_COPY_SIZE jbe short Hci112 mov ecx, FRAME_COPY_SIZE Hci111: mov edi, dword ptr _HalpTimerWatchdogCurFrame rep movsd add _HalpTimerWatchdogCurFrame, (FRAME_COPY_SIZE*4) ; ; If we didn't copy an entire FRAME_COPY_SIZE dwords, zero fill. ; mov ecx, dword ptr _HalpTimerWatchdogCurFrame sub ecx, edi shr ecx, 2 xor eax, eax rep stosd cmp edi, dword ptr _HalpTimerWatchdogLastFrame jbe short Hci112 mov dword ptr [_HalpTimerWatchdogStorageOverflow], 1 Hci112: pop edi pop esi Hci115: ; ; Reset last time so that we're accurate after the trap ; rdtsc mov _HalpWatchdogTscHigh, edx mov _HalpWatchdogTscLow, eax jmp short Hci14 Hci12: ; ; Increment the total counter, perform average when the count is reached ; add _HalpWatchdogCountLow, eax adc _HalpWatchdogCountHigh, edx dec _HalpWatchdogAvgCounter jnz short Hci14 mov edx, _HalpWatchdogCountHigh mov eax, _HalpWatchdogCountLow ; ; compute the average * 2, this measures when we have missed ; an interrupt at this rate. ; mov ecx, COUNTER_TICKS_AVG_SHIFT - 1 Hci13: shr edx, 1 rcr eax, 1 loop short Hci13 mov _HalpWatchdogCountLow, eax mov _HalpWatchdogCountHigh, edx Hci14: pop eax Hci15: ; ; Check for any more work ; cmp _HalpClockWork, ebx ; Any clock interrupt work desired? jz _KeUpdateSystemTime@0 ; No, process tick cmp _HalpClockMcaQueueDpc, bl je short CheckTimerRate mov _HalpClockMcaQueueDpc, bl ; ; Queue MCA Dpc ; push eax stdCall _HalpMcaQueueDpc ; Queue MCA Dpc pop eax CheckTimerRate: ; ; (esp) = OldIrql ; (esp+4) = Vector ; (esp+8) = base of trap frame ; ebp = trap frame ; eax = time increment of this tick ; ebx = 0 ; cmp _HalpClockSetMSRate, bl ; New clock rate desired? jz _KeUpdateSystemTime@0 ; No, process tick ; ; Time of clock frequency is being changed. See if we have changed rates ; since the last tick ; cmp _HalpPendingRate, ebx ; Was a new rate set durning last jnz SetUpForNextTick ; tick? Yes, go update globals ProgramTimerRate: ; (eax) = time increment for current tick ; ; A new clock rate needs to be set. Setting the rate here will ; cause the tick after the next tick to be at the new rate. ; (the next tick is already in progress and will occur at the same ; rate as this tick) ; push eax stdCall _HalpAcquireCmosSpinLock mov eax, _HalpNextMSRate mov _HalpPendingRate, eax ; pending rate dec eax mov ecx, TimeStrucSize xor edx, edx mul ecx mov eax, _HalpRtcTimeIncrements[eax].RTCRegisterA mov _HalpCurrentRTCRegisterA, eax shl ax, 8 ; (ah) = (al) mov al, 0AH ; Register A CMOS_WRITE ; Set it cmp _HalpTimerWatchdogEnabled, 0 jz short @f ; ; Timer latency watchdog: schedule to recalibrate TSC delta ; rdtsc mov _HalpWatchdogAvgCounter, COUNTER_TICKS_FOR_AVG mov _HalpWatchdogTscLow, eax mov _HalpWatchdogTscHigh, edx xor eax,eax mov _HalpWatchdogCountHigh, eax mov _HalpWatchdogCountLow, eax @@: stdCall _HalpReleaseCmosSpinLock pop eax jmp _KeUpdateSystemTime@0 ; dispatch this tick SetUpForNextTick: ; ; The next tick will occur at the rate which was programmed during the last ; tick. Update globals for new rate which starts with the next tick. ; ; We will get here if there is a request for a rate change. There could ; been two requests. That is why we are conmparing the Pending with the ; NextRate. ; ; (eax) = time increment for current tick ; push eax mov eax, _HalpPendingRate dec eax ifdef ACPI_HAL ifdef NT_UP ; ; Update the index used by Piix4 workaround; this maps RTC system clock ; milisecond indices into PM Timer (PMT) milisecond indices ; ; RTC { 0=1ms, 1=2ms, 2=4ms, 3=8ms, 4=15.6ms } ; ; PMT { 0=1ms, 1=2ms, 2=3ms, ..., 14=15ms } ; ; So to convert from RTC index to PMT: PMT = (1 << RTC) - 1 ; ; NOTE: Since the PM timer array only goes to 15ms, we map our last RTC ; index (4=15.6) to PMT index 14 (15ms) as a special case ; mov edx, 1 mov cl, al shl edx, cl dec edx cmp edx, 0fh ; Check for special case RTC 15.6ms -> PMT 15ms jne short @f dec edx @@: mov _HalpCurrentMSRateTableIndex, edx endif endif mov ecx, TimeStrucSize xor edx, edx mul ecx mov ebx, _HalpRtcTimeIncrements[eax].RateIn100ns mov ecx, _HalpRtcTimeIncrements[eax].RateAdjustmentCnt mov edx, _HalpRtcTimeIncrements[eax].IpiRate mov _HalpCurrentClockRateIn100ns, ebx mov _HalpCurrentClockRateAdjustment, ecx mov _HalpCurrentIpiRate, edx mov ebx, _HalpPendingRate mov _HalpPendingRate, 0 ; no longer pending, clear it pop eax cmp ebx, _HalpNextMSRate ; new rate == NextRate? jne ProgramTimerRate ; no, go set new pending rate mov _HalpClockSetMSRate, 0 ; all done setting new rate jmp _KeUpdateSystemTime@0 ; dispatch this tick stdENDP _HalpClockInterrupt page ,132 subttl "System Clock Interrupt - Non BSP" ;++ ; ; Routine Description: ; ; ; This routine is entered as the result of an interrupt generated by ; CLOCK2. Its function is to dismiss the interrupt, raise system Irql ; to CLOCK2_LEVEL, transfer control to the standard system routine to ; the execution time of the current thread and process. ; ; This routine is executed on all processors other than P0 ; ; ; Arguments: ; ; None ; Interrupt is disabled ; ; Return Value: ; ; Does not return, jumps directly to KeUpdateSystemTime, which returns ; ; Sets Irql = CLOCK2_LEVEL and dismisses the interrupt ; ;-- ENTER_DR_ASSIST HPn_a, HPn_t cPublicProc _HalpClockInterruptPn ,0 ; ; Save machine state in trap frame ; ENTER_INTERRUPT HPn_a, HPn_t ; ; (esp) - base of trap frame ; ; dismiss interrupt and raise Irql ; push APIC_CLOCK_VECTOR sub esp, 4 ; allocate space to save OldIrql stdCall _HalBeginSystemInterrupt, <CLOCK2_LEVEL,APIC_CLOCK_VECTOR,esp> ; ; All processors will update RunTime for current thread ; sti ; TOS const PreviousIrql stdCall _KeUpdateRunTime,<dword ptr [esp]> INTERRUPT_EXIT ; lower irql to old value, iret ; ; We don't return here ; stdENDP _HalpClockInterruptPn page ,132 subttl "System Clock Interrupt - Stub" ;++ ; ; Routine Description: ; ; ; This routine is entered as the result of an interrupt generated by ; CLOCK2. Its function is to interrupt and return. ; ; This routine is executed on P0 During Phase 0 ; ; ; Arguments: ; ; None ; Interrupt is disabled ; ; Return Value: ; ;-- APIC_ICR_CLOCK equ (DELIVER_FIXED OR ICR_ALL_EXCL_SELF OR APIC_CLOCK_VECTOR) ENTER_DR_ASSIST HStub_a, HStub_t cPublicProc _HalpClockInterruptStub ,0 ; ; Save machine state in trap frame ; ENTER_INTERRUPT HStub_a, HStub_t ; ; (esp) - base of trap frame ; ; ; clear interrupt flag on RTC by banging on the CMOS. On some systems this ; doesn't work the first time we do it, so we do it twice. It is rumored that ; some machines require more than this, but that hasn't been observed with NT. ; mov al,0CH ; Register C CMOS_READ ; Read to initialize mov al,0CH ; Register C CMOS_READ ; Read to initialize Hpi10: test al, 80h jz short Hpi15 mov al,0CH ; Register C CMOS_READ ; Read to initialize jmp short Hpi10 Hpi15: mov dword ptr APIC[LU_EOI], 0 ; send EOI to APIC local unit ; ; Do interrupt exit processing without EOI ; SPURIOUS_INTERRUPT_EXIT ; ; We don't return here ; stdENDP _HalpClockInterruptStub ifdef MMTIMER page ,132 subttl "Multi Media Event Timer System Clock Interrupt Stub" ;++ ; ; Routine Description: ; ; ; This routine is entered as the result of an interrupt generated by ; CLOCK2, its function is to interrupt, call HalpmmTimerClockInterrupt ; to update performance counters and adjust the system clock frequency ; if necessary, to IPI other processors, and update system time ; ; This routine is executed on P0 ; ; Arguments: ; ; None - Interrupt is disabled ; ; Return Value: ; ;-- ENTER_DR_ASSIST Hmmt_a, Hmmt_t cPublicProc _HalpmmTimerClockInterruptStub ; ; Save machine state in trap frame ; ENTER_INTERRUPT Hmmt_a, Hmmt_t ; ; (esp) - base of trap frame ; ; dismiss interrupt and raise Irql ; push MMT_VECTOR sub esp, 4 ; allocate space to save OldIrql stdCall _HalBeginSystemInterrupt, <CLOCK2_LEVEL,MMT_VECTOR,esp> ; ; Update performace counter and adjust clock frequency if necessary ; stdCall _HalpmmTimerClockInterrupt INTERRUPT_EXIT ; lower irql to old value, iret ; ; We don't return here ; stdENDP _HalpmmTimerClockInterruptStub endif ifdef ACPI_HAL page ,132 subttl "Query 8254 Counter" ;++ ; ; ULONG ; HalpQuery8254Counter( ; VOID ; ) ; ; Routine Description: ; ; This routine returns the current value of the 8254 counter ; ; Arguments: ; ; None ; ; Return Value: ; ; Current value of the 8254 counter is returned ; ;-- cPublicProc _HalpQuery8254Counter, 0 stdCall _HalpAcquireSystemHardwareSpinLock ; intr disabled ; ; Fetch the current counter value from the hardware ; mov al, COMMAND_8254_LATCH_READ + COMMAND_8254_COUNTER0 ; Latch PIT Ctr 0 command. out TIMER1_CONTROL_PORT0, al IODelay in al, TIMER1_DATA_PORT0 ; Read PIT Ctr 0, LSByte. IODelay movzx ecx, al ; Zero upper bytes of (ECX). in al, TIMER1_DATA_PORT0 ; Read PIT Ctr 0, MSByte. mov ch, al ; (CX) = PIT Ctr 0 count. mov eax, ecx stdCall _HalpReleaseSystemHardwareSpinLock stdRET _HalpQuery8254Counter stdENDP _HalpQuery8254Counter endif _TEXT ends end
/* ============================================================================ * Copyright (c) 2009-2016 BlueQuartz Software, LLC * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * The code contained herein was partially funded by the followig contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SIMPLib/FilterParameters/JsonFilterParametersReader.h" #include <QtCore/QDir> #include <QtCore/QDirIterator> #include "SVWidgetsLib/Widgets/BookmarksModel.h" #include "SVWidgetsLib/Widgets/BookmarksTreeView.h" #include "SVWidgetsLib/Widgets/SVStyle.h" #include "SVWidgetsLib/QtSupport/QtSSettings.h" #define PREBUILT_PIPELINES_DIR "PrebuiltPipelines" BookmarksModel* BookmarksModel::self = nullptr; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- BookmarksModel::BookmarksModel(QObject* parent) : QAbstractItemModel(parent) { initialize(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- BookmarksModel::~BookmarksModel() { delete rootItem; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- BookmarksModel* BookmarksModel::Instance() { if(self == nullptr) { self = new BookmarksModel(); self->loadModel(); self->writeBookmarksToPrefsFile(); // Write out any "sanity check" changes that were made while loading the model } return self; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::initialize() { rootItem = new BookmarksItem(""); m_Watcher = new QFileSystemWatcher(this); connect(this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(updateModel(const QModelIndex&, const QModelIndex&))); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::setFileSystemWatcher(QFileSystemWatcher* watcher) { m_Watcher = watcher; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QFileSystemWatcher* BookmarksModel::getFileSystemWatcher() { return m_Watcher; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::updateRowState(const QString& path) { QFileInfo fi(path); QModelIndexList indexList = findIndexByPath(path); for(int i = 0; i < indexList.size(); i++) { QModelIndex nameIndex = index(indexList[i].row(), BookmarksItem::Contents, indexList[i].parent()); // Set the itemHasError variable setData(nameIndex, !fi.exists(), static_cast<int>(Roles::ErrorsRole)); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int BookmarksModel::columnCount(const QModelIndex& parent) const { return 1; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QVariant BookmarksModel::data(const QModelIndex& index, int role) const { if(!index.isValid()) { return QVariant(); } SVStyle* styles = SVStyle::Instance(); BookmarksItem* item = getItem(index); if(role == Qt::DisplayRole) { return item->getName(); } else if(role == static_cast<int>(Roles::PathRole)) { return item->getPath(); } else if(role == static_cast<int>(Roles::ErrorsRole)) { return item->getHasErrors(); } else if(role == static_cast<int>(Roles::ExpandedRole)) { return item->isExpanded(); } else if(role == static_cast<int>(Roles::ItemTypeRole)) { return static_cast<int>(item->getItemType()); } else if(role == Qt::ForegroundRole) { if(item->getHasErrors() == true) { return styles->getQTreeViewItem_error_color(); } else { return styles->getQTreeViewItem_color(); } } else if(role == Qt::ToolTipRole && item->getItemType() == BookmarksItem::ItemType::Bookmark) { QString path = item->getPath(); QFileInfo info(path); if(path.isEmpty() == false) { if(info.exists() == false) { QString tooltip = tr("'%1' was not found on the file system.\nYou can either locate the file or delete the entry from the table.").arg(item->getPath()); return tooltip; } else if(info.suffix().compare("json") == 0) { QString html = JsonFilterParametersReader::HtmlSummaryFromFile(path, nullptr); return html; } } return QVariant(); } else if(role == Qt::DecorationRole) { return item->getIcon(); } return QVariant(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- Qt::ItemFlags BookmarksModel::flags(const QModelIndex& index) const { if(!index.isValid()) { return 0; } Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); BookmarksItem* item = getItem(index); QString name = item->getName(); if(item->getItemType() == BookmarksItem::ItemType::Folder) { // This is a node return (defaultFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled); } else { // This is a leaf return (defaultFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- BookmarksItem* BookmarksModel::getItem(const QModelIndex& index) const { if(index.isValid()) { BookmarksItem* item = static_cast<BookmarksItem*>(index.internalPointer()); if(item) { return item; } } return rootItem; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QModelIndex BookmarksModel::index(int row, int column, const QModelIndex& parent) const { if(parent.isValid() && parent.column() != 0) { return QModelIndex(); } BookmarksItem* parentItem = getItem(parent); BookmarksItem* childItem = parentItem->child(row); if(childItem) { return createIndex(row, column, childItem); } else { return QModelIndex(); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- bool BookmarksModel::insertRows(int position, int rows, const QModelIndex& parent) { BookmarksItem* parentItem = getItem(parent); bool success; beginInsertRows(parent, position, position + rows - 1); success = parentItem->insertChildren(position, rows, columnCount()); endInsertRows(); if (m_LoadingModel == false) { writeBookmarksToPrefsFile(); } return success; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- bool BookmarksModel::removeRows(int position, int rows, const QModelIndex& parent) { BookmarksItem* parentItem = getItem(parent); bool success = true; beginRemoveRows(parent, position, position + rows - 1); success = parentItem->removeChildren(position, rows); endRemoveRows(); if (m_LoadingModel == false) { writeBookmarksToPrefsFile(); } return success; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- bool BookmarksModel::moveRows(const QModelIndex& sourceParent, int sourceRow, int count, const QModelIndex& destinationParent, int destinationChild) { beginMoveRows(sourceParent, sourceRow, sourceRow + count - 1, destinationParent, destinationChild); BookmarksItem* srcParentItem = getItem(sourceParent); BookmarksItem* destParentItem = getItem(destinationParent); for(int i = sourceRow; i < sourceRow + count; i++) { QModelIndex srcIndex = index(i, BookmarksItem::Contents, sourceParent); BookmarksItem* srcItem = getItem(srcIndex); destParentItem->insertChild(destinationChild, srcItem); srcItem->setParent(destParentItem); srcParentItem->removeChild(i); } endMoveRows(); if (m_LoadingModel == false) { writeBookmarksToPrefsFile(); } return true; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QModelIndex BookmarksModel::parent(const QModelIndex& index) const { if(!index.isValid()) { return QModelIndex(); } BookmarksItem* childItem = getItem(index); BookmarksItem* parentItem = childItem->parent(); if(parentItem == rootItem) { return QModelIndex(); } return createIndex(parentItem->childNumber(), 0, parentItem); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int BookmarksModel::rowCount(const QModelIndex& parent) const { BookmarksItem* parentItem = getItem(parent); return parentItem->childCount(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- bool BookmarksModel::setData(const QModelIndex& index, const QVariant& value, int role) { BookmarksItem* item = getItem(index); if(role == Qt::DisplayRole) { item->setName(value.toString()); } else if(role == static_cast<int>(Roles::PathRole)) { item->setPath(value.toString()); } else if(role == static_cast<int>(Roles::ExpandedRole)) { item->setExpanded(value.toBool()); } else if(role == static_cast<int>(Roles::ErrorsRole)) { item->setHasErrors(value.toBool()); } else if(role == static_cast<int>(Roles::ItemTypeRole)) { item->setItemType(static_cast<BookmarksItem::ItemType>(value.toInt())); } else if(role == Qt::DecorationRole) { item->setIcon(value.value<QIcon>()); } else if(role == Qt::ToolTipRole) { item->setItemTooltip(value.toString()); } else { return false; } emit dataChanged(index, index); if (m_LoadingModel == false) { writeBookmarksToPrefsFile(); } return true; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- BookmarksItem* BookmarksModel::getRootItem() { return rootItem; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- bool BookmarksModel::isEmpty() { if(rowCount(QModelIndex()) <= 0) { return true; } return false; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::addFileToTree(QString& path, QModelIndex& specifiedParent) { path = QDir::toNativeSeparators(path); QFileInfo fi(path); int rowPos = rowCount(specifiedParent); insertRow(rowPos, specifiedParent); QModelIndex index = this->index(rowPos, BookmarksItem::Contents, specifiedParent); if(fi.isFile()) { QString name = fi.baseName(); setData(index, name, Qt::DisplayRole); setData(index, path, Roles::PathRole); setData(index, static_cast<int>(BookmarksItem::ItemType::Bookmark), Roles::ItemTypeRole); setData(index, QIcon(":/SIMPL/icons/images/bookmark.png"), Qt::DecorationRole); } else { QDir dir(path); setData(index, dir.dirName(), Qt::DisplayRole); setData(index, static_cast<int>(BookmarksItem::ItemType::Folder), Roles::ItemTypeRole); setData(index, QIcon(":/SIMPL/icons/images/folder_blue.png"), Qt::DecorationRole); QStringList filters; filters << "*.dream3d" << "*.ini" << "*.txt" << "*.json"; QDirIterator iter(path, filters, QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); while(iter.hasNext()) { QString nextPath = iter.next(); addFileToTree(nextPath, index); } } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::fromJsonObject(QJsonObject treeObject) { QStringList keys = treeObject.keys(); keys.sort(Qt::CaseInsensitive); for(int i = 0; i < keys.size(); i++) { if(keys[i].compare("Prebuilt Pipelines") == 0) { continue; } QJsonValue val = treeObject.value(keys[i]); if(val.isObject()) { unwrapModel(keys[i], val.toObject(), QModelIndex()); } } QStringList paths = getFilePaths(); if(!paths.isEmpty()) { getFileSystemWatcher()->addPaths(paths); } connect(getFileSystemWatcher(), SIGNAL(fileChanged(const QString&)), SLOT(updateRowState(const QString&))); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QJsonObject BookmarksModel::toJsonObject() { BookmarksItem* rootItem = getRootItem(); QJsonObject treeObj; for(int i = 0; i < rootItem->childCount(); i++) { QModelIndex childIndex = index(i, BookmarksItem::Contents, QModelIndex()); BookmarksItem* childItem = getItem(childIndex); QString name = childItem->getName(); QJsonObject childObj = wrapModel(childIndex); treeObj.insert(name, childObj); } return treeObj; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QJsonObject BookmarksModel::wrapModel(QModelIndex currentIndex) { QJsonObject obj; for(int i = 0; i < rowCount(currentIndex); i++) { QModelIndex childIndex = this->index(i, BookmarksItem::Contents, currentIndex); BookmarksItem* childItem = getItem(childIndex); QString childName = childItem->getName(); QJsonObject childObj = wrapModel(childIndex); obj[childName] = childObj; } BookmarksItem* item = getItem(currentIndex); QString path = item->getPath(); obj.insert("Path", path); BookmarksItem::ItemType type = item->getItemType(); obj.insert("Item Type", static_cast<int>(type)); bool expanded = item->isExpanded(); obj.insert("Expanded", expanded); return obj; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::unwrapModel(QString objectName, QJsonObject object, QModelIndex parentIndex) { int row = rowCount(parentIndex); insertRow(row, parentIndex); QModelIndex index = this->index(row, BookmarksItem::Contents, parentIndex); QString path = object["Path"].toString(); bool expanded = object["Expanded"].toBool(); BookmarksItem::ItemType itemType = static_cast<BookmarksItem::ItemType>(object["Item Type"].toInt()); QFileInfo fi(path); // Sanity check to make sure that all bookmark items that are read in have the proper type if (fi.isFile() && fi.completeSuffix() == "json" && itemType == BookmarksItem::ItemType::Folder) { itemType = BookmarksItem::ItemType::Bookmark; } else if (path.isEmpty() && itemType == BookmarksItem::ItemType::Bookmark) { itemType = BookmarksItem::ItemType::Folder; } if(itemType == BookmarksItem::ItemType::Bookmark) { setData(index, QIcon(":/SIMPL/icons/images/bookmark.png"), Qt::DecorationRole); if(fi.exists() == false) { // Set the itemHasError variable setData(index, true, static_cast<int>(Roles::ErrorsRole)); } } else { setData(index, QIcon(":/SIMPL/icons/images/folder_blue.png"), Qt::DecorationRole); } path = QDir::toNativeSeparators(path); setData(index, objectName, Qt::DisplayRole); setData(index, path, static_cast<int>(Roles::PathRole)); setData(index, expanded, static_cast<int>(Roles::ExpandedRole)); setData(index, static_cast<int>(itemType), static_cast<int>(Roles::ItemTypeRole)); QStringList keys = object.keys(); keys.sort(Qt::CaseInsensitive); for(int i = 0; i < keys.size(); i++) { QJsonValue val = object.value(keys[i]); if(val.isObject()) { unwrapModel(keys[i], val.toObject(), index); } } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QStringList BookmarksModel::getFilePaths() { return getFilePaths(rootItem); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QStringList BookmarksModel::getFilePaths(BookmarksItem* item) { QStringList list; if(item != rootItem && item->childCount() <= 0) { QString filePath = item->getPath(); if(filePath.isEmpty() == false) { list.append(filePath); } return list; } for(int i = 0; i < item->childCount(); i++) { list.append(getFilePaths(item->child(i))); } return list; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QModelIndexList BookmarksModel::findIndexByPath(QString filePath) { QModelIndexList list; for(int i = 0; i < rootItem->childCount(); i++) { QModelIndex child = index(i, BookmarksItem::Contents); if(rowCount(child) <= 0 && data(child, static_cast<int>(Roles::PathRole)).toString() == filePath) { list.append(child); } for(int j = 0; j < rowCount(child); j++) { QModelIndexList subList = findIndexByPath(child, filePath); list.append(subList); } } return list; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QModelIndexList BookmarksModel::findIndexByPath(const QModelIndex& current, QString filePath) { QModelIndex actual = index(current.row(), BookmarksItem::Contents, current.parent()); QModelIndexList list; for(int i = 0; i < rowCount(actual); i++) { QModelIndex index = this->index(i, BookmarksItem::Contents, actual); if(rowCount(index) <= 0 && data(index, static_cast<int>(Roles::PathRole)).toString() == filePath) { list.append(index); } QModelIndexList subList = findIndexByPath(index, filePath); list.append(subList); } return list; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::updateModel(const QModelIndex& topLeft, const QModelIndex& bottomRight) { if(topLeft.isValid()) { QModelIndex index = this->index(topLeft.row(), BookmarksItem::Contents, topLeft.parent()); QString path = data(index, static_cast<int>(Roles::PathRole)).toString(); QFileInfo fi(path); if(nullptr != m_Watcher && path.isEmpty() == false && fi.exists()) { m_Watcher->addPath(path); } } else if(bottomRight.isValid()) { QModelIndex index = this->index(bottomRight.row(), BookmarksItem::Contents, bottomRight.parent()); QString path = data(index, static_cast<int>(Roles::PathRole)).toString(); QFileInfo fi(path); if(nullptr != m_Watcher && path.isEmpty() == false && fi.exists()) { m_Watcher->addPath(path); } } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::readBookmarksFromPrefsFile() { QJsonObject object = getBookmarksPrefsObject(); fromJsonObject(object); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QJsonObject BookmarksModel::getBookmarksPrefsObject() { QSharedPointer<QtSSettings> prefs = QSharedPointer<QtSSettings>(new QtSSettings(getBookmarksPrefsPath())); QJsonObject object; if(prefs->contains("Bookmarks")) { prefs->beginGroup("Bookmarks"); object = prefs->value("Bookmarks Model", QJsonObject()); prefs->endGroup(); } else { // If no bookmarks were found in the new location, check the old location prefs->beginGroup("DockWidgetSettings"); prefs->beginGroup("Bookmarks Dock Widget"); object = prefs->value("Bookmarks Model", QJsonObject()); prefs->endGroup(); prefs->endGroup(); } return object; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::writeBookmarksToPrefsFile() { QSharedPointer<QtSSettings> prefs = QSharedPointer<QtSSettings>(new QtSSettings(getBookmarksPrefsPath())); prefs->beginGroup("Bookmarks"); QJsonObject modelObj = toJsonObject(); prefs->setValue("Bookmarks Model", modelObj); prefs->endGroup(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::loadModel() { m_LoadingModel = true; readPrebuiltPipelines(); readBookmarksFromPrefsFile(); m_LoadingModel = false; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::readPrebuiltPipelines() { QDir pipelinesDir = findPipelinesDirectory(); QString pPath = pipelinesDir.absolutePath(); FilterLibraryTreeWidget::ItemType itemType = FilterLibraryTreeWidget::Leaf_Item_Type; QString iconFileName(":/SIMPL/icons/images/bookmark.png"); bool allowEditing = false; QStringList fileExtension; fileExtension.append("*.json"); // Add top-level folder and then load up all the pipelines into the folder QString dirName = "Prebuilt Pipelines"; QJsonObject prefsObject = getBookmarksPrefsObject(); QJsonObject prebuiltsObject = prefsObject["Prebuilt Pipelines"].toObject(); bool expanded = prebuiltsObject["Expanded"].toBool(); QModelIndex index = addTreeItem(QModelIndex(), dirName, QIcon(":/SIMPL/icons/images/folder_blue.png"), pPath, 0, BookmarksItem::ItemType::Folder, expanded); addPipelinesRecursively(pipelinesDir, index, prebuiltsObject, iconFileName, allowEditing, fileExtension, itemType); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QDir BookmarksModel::findPipelinesDirectory() { QString dirName(PREBUILT_PIPELINES_DIR); QString appPath = QCoreApplication::applicationDirPath(); QDir pipelinesDir = QDir(appPath); #if defined(Q_OS_WIN) QFileInfo fi(pipelinesDir.absolutePath() + QDir::separator() + dirName); if(fi.exists() == false) { // The PrebuiltPipelines file does not exist at the default location because we are probably running from visual studio. // Try up one more directory pipelinesDir.cdUp(); } #elif defined(Q_OS_MAC) if(pipelinesDir.dirName() == "MacOS") { pipelinesDir.cdUp(); // Can we change directory into the "PrebuiltPipeliines" directory at this level. QString pbpDir = QString("Resources/%1").arg(PREBUILT_PIPELINES_DIR); if (pipelinesDir.cd(pbpDir)) { return pipelinesDir; } pipelinesDir.cdUp(); pipelinesDir.cdUp(); if (pipelinesDir.cd(PREBUILT_PIPELINES_DIR) ) { return pipelinesDir; } } #else // We are on Linux - I think QFileInfo fi(pipelinesDir.absolutePath() + QDir::separator() + dirName); // qDebug() << fi.absolutePath(); // Look for the PREBUILT_PIPELINES_DIR directory in the current app directory if(fi.exists() == false) { // Try up one more directory pipelinesDir.cdUp(); } #endif pipelinesDir = pipelinesDir.absolutePath() + QDir::separator() + dirName; return pipelinesDir; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::addPipelinesRecursively(QDir currentDir, QModelIndex parent, QJsonObject prebuiltsObj, QString iconFileName, bool allowEditing, QStringList filters, FilterLibraryTreeWidget::ItemType itemType) { QModelIndex nextIndex; // Get a list of all the directories QFileInfoList dirList = currentDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); if(dirList.size() > 0) { foreach(QFileInfo fi, dirList) { // At this point we have the first level of directories and we want to do 2 things: // 1.Create an entry in the tree widget with this name // 2.drop into the directory and look for all the .json files and add entries for those items. // qDebug() << fi.absoluteFilePath() << "\n"; // Add a tree widget item for this Group // qDebug() << fi.absoluteFilePath(); int row = rowCount(parent); QString baseName = fi.baseName(); QJsonObject folderPrefsObj = prebuiltsObj[baseName].toObject(); bool expanded = folderPrefsObj["Expanded"].toBool(); nextIndex = addTreeItem(parent, baseName, QIcon(":/SIMPL/icons/images/folder_blue.png"), fi.absoluteFilePath(), row, BookmarksItem::ItemType::Folder, expanded); addPipelinesRecursively(QDir(fi.absoluteFilePath()), nextIndex, folderPrefsObj, iconFileName, allowEditing, filters, itemType); // Recursive call } } QFileInfoList itemList = currentDir.entryInfoList(filters); foreach(QFileInfo itemInfo, itemList) { QString itemFilePath = itemInfo.absoluteFilePath(); QString itemName; if(itemInfo.suffix().compare("json") == 0) { QString dVers; JsonFilterParametersReader::Pointer jsonReader = JsonFilterParametersReader::New(); jsonReader->readNameOfPipelineFromFile(itemFilePath, itemName, dVers, nullptr); } #if 0 else if(itemInfo.suffix().compare("ini") == 0 || itemInfo.suffix().compare("txt") == 0) { QSettings itemPref(itemFilePath, QSettings::IniFormat); itemPref.beginGroup(SIMPL::Settings::PipelineBuilderGroup); itemName = itemPref.value(SIMPL::Settings::PipelineName).toString(); itemPref.endGroup(); } #endif // Add tree widget for this Prebuilt Pipeline int row = rowCount(parent); addTreeItem(parent, itemName, QIcon(iconFileName), itemInfo.absoluteFilePath(), row, BookmarksItem::ItemType::Bookmark, false); nextIndex = index(row, BookmarksItem::Contents, parent); // QString htmlFormattedString = generateHtmlFilterListFromPipelineFile(itemInfo.absoluteFilePath()); // model->setData(nextIndex, htmlFormattedString, Qt::ToolTipRole); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QModelIndex BookmarksModel::addTreeItem(QModelIndex parent, QString& favoriteTitle, QIcon icon, QString favoritePath, int insertIndex, BookmarksItem::ItemType type, bool isExpanded) { favoritePath = QDir::toNativeSeparators(favoritePath); QFileInfo fileInfo(favoritePath); QString ext = fileInfo.completeSuffix(); if(fileInfo.isFile() && ext != "dream3d" && ext != "json" && ext != "ini" && ext != "txt") { return QModelIndex(); } // Add a new Item to the Tree insertRow(insertIndex, parent); QModelIndex index = this->index(insertIndex, BookmarksItem::Contents, parent); setData(index, favoriteTitle, Qt::DisplayRole); setData(index, favoritePath, static_cast<int>(Roles::PathRole)); setData(index, icon, Qt::DecorationRole); setData(index, static_cast<int>(type), static_cast<int>(Roles::ItemTypeRole)); sort(BookmarksItem::Contents, Qt::AscendingOrder); if(isExpanded) { setData(index, true, static_cast<int>(Roles::ExpandedRole)); } else { setData(index, false, static_cast<int>(Roles::ExpandedRole)); } if(type == BookmarksItem::ItemType::Bookmark) { m_Watcher->addPath(favoritePath); } return index; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QString BookmarksModel::getBookmarksPrefsPath() { QtSSettings prefs; QFileInfo fi(prefs.fileName()); QString parentPath = fi.absolutePath(); QString appName = QCoreApplication::applicationName(); if(appName.isEmpty()) { appName = QString("Application"); } #if defined(Q_OS_MAC) QString domain = QCoreApplication::organizationDomain(); if(domain.isEmpty()) { domain = QString("Domain"); } QStringList tokens = domain.split("."); QStringListIterator iter(tokens); iter.toBack(); domain = QString(""); while(iter.hasPrevious()) { domain = domain + iter.previous() + QString("."); } QString bookmarksPrefsPath = parentPath + "/" + domain + appName + "_BookmarksModel.json"; #else QString bookmarksPrefsPath = QDir::toNativeSeparators(parentPath + "/" + appName + "_BookmarksModel.json"); #endif return bookmarksPrefsPath; }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r8 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0x15309, %rsi lea addresses_WC_ht+0xa3d9, %rdi xor $23751, %rax mov $1, %rcx rep movsq nop nop nop nop nop cmp %rcx, %rcx lea addresses_UC_ht+0x1a009, %rsi lea addresses_normal_ht+0x10a69, %rdi nop nop nop nop cmp $32386, %r10 mov $24, %rcx rep movsq nop nop nop add $54443, %rsi lea addresses_UC_ht+0x1cb89, %rsi lea addresses_A_ht+0x10909, %rdi nop nop nop nop cmp %r10, %r10 mov $71, %rcx rep movsq nop nop nop and $43091, %rdi lea addresses_WC_ht+0x23e9, %rsi lea addresses_D_ht+0x13975, %rdi nop nop nop nop nop xor %r10, %r10 mov $70, %rcx rep movsq nop nop add %rsi, %rsi lea addresses_WT_ht+0x11a49, %r8 nop nop nop nop nop add $39000, %rbx mov $0x6162636465666768, %rcx movq %rcx, (%r8) nop nop nop nop cmp $46691, %rsi lea addresses_WC_ht+0x18259, %rax xor %rcx, %rcx movups (%rax), %xmm4 vpextrq $0, %xmm4, %rdi nop and $35739, %r8 lea addresses_WT_ht+0xf009, %rax add $44704, %r8 mov $0x6162636465666768, %r10 movq %r10, %xmm6 vmovups %ymm6, (%rax) nop nop nop nop nop add %rsi, %rsi lea addresses_WC_ht+0x16a49, %rsi lea addresses_D_ht+0x8c09, %rdi nop and $14299, %rbp mov $51, %rcx rep movsb xor %rbx, %rbx lea addresses_WC_ht+0x1c509, %rsi nop nop nop xor $33563, %rbx vmovups (%rsi), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $1, %xmm6, %rcx dec %rcx lea addresses_WC_ht+0x1e0c9, %r10 nop nop nop add %rax, %rax and $0xffffffffffffffc0, %r10 movaps (%r10), %xmm6 vpextrq $1, %xmm6, %rbx nop add %rbp, %rbp lea addresses_D_ht+0x85d0, %r8 nop nop nop add %rsi, %rsi movups (%r8), %xmm7 vpextrq $1, %xmm7, %rcx nop add %rdi, %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r8 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r15 push %rbp push %rcx push %rdi push %rdx push %rsi // Store lea addresses_PSE+0x15849, %r14 nop cmp $63143, %rbp movb $0x51, (%r14) nop nop add %rdx, %rdx // REPMOV lea addresses_normal+0x6b29, %rsi lea addresses_normal+0x1b555, %rdi cmp %rdx, %rdx mov $83, %rcx rep movsq nop nop nop add %r13, %r13 // Store lea addresses_D+0xad49, %r10 nop nop nop dec %rbp mov $0x5152535455565758, %r15 movq %r15, (%r10) nop nop add $26158, %rsi // Load lea addresses_US+0x11009, %rbp clflush (%rbp) nop nop nop dec %rcx movups (%rbp), %xmm5 vpextrq $1, %xmm5, %rdi nop nop nop nop dec %r15 // Faulty Load lea addresses_US+0x11009, %rbp nop nop sub %r13, %r13 mov (%rbp), %r14 lea oracles, %r13 and $0xff, %r14 shlq $12, %r14 mov (%r13,%r14,1), %r14 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r15 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 1}} {'src': {'same': False, 'congruent': 5, 'type': 'addresses_normal'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_normal'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_D', 'AVXalign': False, 'size': 8}} {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_WC_ht'}} {'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}} {'src': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8}} {'src': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32}} {'src': {'same': False, 'congruent': 6, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 16}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'00': 5444} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php. ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; SetMem.Asm ; ; Abstract: ; ; SetMem function ; ; Notes: ; ;------------------------------------------------------------------------------ .386 .model flat,C .code ;------------------------------------------------------------------------------ ; VOID * ; InternalMemSetMem ( ; IN VOID *Buffer, ; IN UINTN Count, ; IN UINT8 Value ; ) ;------------------------------------------------------------------------------ InternalMemSetMem PROC USES edi mov eax, [esp + 16] mov edi, [esp + 8] mov ecx, [esp + 12] rep stosb mov eax, [esp + 8] ret InternalMemSetMem ENDP END
/*========================================================================= * * Copyright Insight Software Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef itkFFTWRealToHalfHermitianForwardFFTImageFilter_hxx #define itkFFTWRealToHalfHermitianForwardFFTImageFilter_hxx #include "itkFFTWRealToHalfHermitianForwardFFTImageFilter.h" #include "itkRealToHalfHermitianForwardFFTImageFilter.hxx" #include "itkProgressReporter.h" namespace itk { /** TODO: There should be compile time type checks so that if only ITK_USE_FFTWF is defined, then only floats are valid. and if ITK_USE_FFTWD is defined, then only doubles are valid. */ template< typename TInputImage, typename TOutputImage > FFTWRealToHalfHermitianForwardFFTImageFilter< TInputImage, TOutputImage > ::FFTWRealToHalfHermitianForwardFFTImageFilter() { m_PlanRigor = FFTWGlobalConfiguration::GetPlanRigor(); } template< typename TInputImage, typename TOutputImage > void FFTWRealToHalfHermitianForwardFFTImageFilter< TInputImage, TOutputImage > ::GenerateData() { // Get pointers to the input and output. typename InputImageType::ConstPointer inputPtr = this->GetInput(); typename OutputImageType::Pointer outputPtr = this->GetOutput(); if ( !inputPtr || !outputPtr ) { return; } // We don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process. ProgressReporter progress(this, 0, 1); // allocate output buffer memory outputPtr->SetBufferedRegion( outputPtr->GetRequestedRegion() ); outputPtr->Allocate(); const typename InputImageType::SizeType & inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); const typename OutputImageType::SizeType & outputSize = outputPtr->GetLargestPossibleRegion().GetSize(); // figure out sizes // size of input and output aren't the same which is handled in the superclass, // sort of. // the input size and output size only differ in the fastest moving dimension unsigned int totalInputSize = 1; unsigned int totalOutputSize = 1; for ( unsigned i = 0; i < ImageDimension; i++ ) { totalInputSize *= inputSize[i]; totalOutputSize *= outputSize[i]; } typename FFTWProxyType::PlanType plan; InputPixelType * in = const_cast<InputPixelType*>(inputPtr->GetBufferPointer()); typename FFTWProxyType::ComplexType * out = (typename FFTWProxyType::ComplexType*) outputPtr->GetBufferPointer(); int flags = m_PlanRigor; if( !m_CanUseDestructiveAlgorithm ) { // if the input is about to be destroyed, there is no need to force fftw // to use an non destructive algorithm. If it is not released however, // we must be careful to not destroy it. flags = flags | FFTW_PRESERVE_INPUT; } int *sizes = new int[ImageDimension]; for(unsigned int i = 0; i < ImageDimension; i++) { sizes[(ImageDimension - 1) - i] = inputSize[i]; } plan = FFTWProxyType::Plan_dft_r2c(ImageDimension, sizes, in, out, flags, this->GetNumberOfThreads()); delete[] sizes; FFTWProxyType::Execute(plan); FFTWProxyType::DestroyPlan(plan); } template< typename TInputImage, typename TOutputImage > void FFTWRealToHalfHermitianForwardFFTImageFilter< TInputImage, TOutputImage > ::UpdateOutputData(DataObject * output) { // We need to catch that information now, because it is changed later // during the pipeline execution, and thus can't be grabbed in // GenerateData(). m_CanUseDestructiveAlgorithm = this->GetInput()->GetReleaseDataFlag(); Superclass::UpdateOutputData( output ); } template< typename TInputImage, typename TOutputImage > void FFTWRealToHalfHermitianForwardFFTImageFilter< TInputImage, TOutputImage > ::PrintSelf(std::ostream & os, Indent indent) const { Superclass::PrintSelf(os, indent); os << indent << "PlanRigor: " << FFTWGlobalConfiguration::GetPlanRigorName(m_PlanRigor) << " (" << m_PlanRigor << ")" << std::endl; } template< typename TInputImage, typename TOutputImage > SizeValueType FFTWRealToHalfHermitianForwardFFTImageFilter< TInputImage, TOutputImage > ::GetSizeGreatestPrimeFactor() const { return FFTWProxyType::GREATEST_PRIME_FACTOR; } } // namespace itk #endif //_itkFFTWRealToHalfHermitianForwardFFTImageFilter_hxx
; A335903: Column 1 in the matrix of A279212 (whose indexing starts at 0). ; 2,6,15,37,88,204,464,1040,2304,5056,11008,23808,51200,109568,233472,495616,1048576,2211840,4653056,9764864,20447232,42729472,89128960,185597952,385875968,801112064,1660944384,3439329280,7113539584,14696841216,30333206528,62545461248,128849018880,265214230528,545460846592 mov $5,2 mov $11,$0 lpb $5 mov $0,$11 sub $5,1 add $0,$5 sub $0,1 mov $7,$0 mov $9,2 lpb $9 mov $0,$7 sub $9,1 add $0,$9 sub $0,1 mov $2,$0 mov $0,2 mov $4,4 lpb $2 mul $0,2 add $0,2 lpb $4 add $0,$2 sub $4,1 lpe sub $2,1 mov $4,3 lpe mov $3,$0 mov $10,$9 lpb $10 mov $8,$3 sub $10,1 lpe lpe lpb $7 mov $7,0 sub $8,$3 lpe mov $3,$8 mov $6,$5 lpb $6 mov $1,$3 sub $6,1 lpe lpe lpb $11 sub $1,$3 mov $11,0 lpe mov $0,$1
;***************************************************************** ;* - Description: Device definition file for RC Calibration ;* - File: m8535.asm ;* - AppNote: AVR053 - Production calibration of the ;* RC oscillator ;* ;* - Author: Atmel Corporation: http://www.atmel.com ;* Support email: avr@atmel.com ;* ;* $Name$ ;* $Revision: 56 $ ;* $RCSfile$ ;* $Date: 2006-02-16 17:44:45 +0100 (to, 16 feb 2006) $ ;***************************************************************** .include "m8535def.inc" .include "Common\memoryMap.inc" .include "Device specific\s8535_family_pinout.inc" .equ OSC_VER = 3
#if !defined(XmlRpcServer_hxx) #define XmlRpcServer_hxx #include <rutil/Data.hxx> #include <rutil/TransportType.hxx> #include <resip/stack/Tuple.hxx> #include <rutil/XMLCursor.hxx> #include "XmlRpcServerBase.hxx" namespace resip { class DataStream; } namespace clicktocall { class Server; class XmlRpcServer; class XmlRpcInfo { public: XmlRpcInfo(unsigned int connectionId, unsigned int requestId, XmlRpcServer* xmlRpcServer) : mConnectionId(connectionId), mRequestId(requestId), mXmlRpcServer(xmlRpcServer) {} XmlRpcInfo() : mConnectionId(0), mRequestId(0), mXmlRpcServer(0) {} unsigned int mConnectionId; unsigned int mRequestId; XmlRpcServer* mXmlRpcServer; }; class XmlRpcServer: public XmlRpcServerBase { public: XmlRpcServer(Server& server, int port, resip::IpVersion version); // thread safe virtual void sendResponse(unsigned int connectionId, unsigned int requestId, const resip::Data& responseData, unsigned int resultCode, const resip::Data& resultText, const resip::Data& leg = resip::Data::Empty); protected: virtual void handleRequest(unsigned int connectionId, unsigned int requestId, const resip::Data& request); private: void handleClickToCallRequest(unsigned int connectionId, unsigned int requestId, resip::XMLCursor& xml); Server& mServer; }; } #endif /* ==================================================================== Copyright (c) 2009, SIP Spectrum, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of SIP Spectrum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ==================================================================== */
NOP HLT
#pragma once #include <coroutine> #include <cassert> #include <optional> #include "suspend_maybe.hpp" template<typename T> class generator { public: struct promise_type { std::optional<T> t_; std::optional<generator> innerCoroutine_; promise_type() = default; ~promise_type() = default; std::suspend_always initial_suspend() { return {}; } std::suspend_always final_suspend() noexcept { return {}; } [[noreturn]] void unhandled_exception() { throw; } generator get_return_object() { return {std::coroutine_handle<promise_type>::from_promise(*this)}; } std::suspend_always yield_value(T t) { t_ = std::move(t); return {}; } void return_void() {} suspend_maybe yield_value(generator innerCoroutine) { innerCoroutine_ = std::move(innerCoroutine); // Get first return value of the inner coroutine if(!innerCoroutine_->is_resumable()) { // coroutine is default-constructed (why TF yielding it), cancel it and do not suspend innerCoroutine_ = {}; return false; } else { // the coroutine is valid; run it to get the first yield (or until end) innerCoroutine_->operator()(); if(!innerCoroutine_->is_resumable()) { // the coroutine has yielded no value and is already ended, cancel it and do not suspend innerCoroutine_ = {}; return false; } else { t_ = std::move(innerCoroutine_->get()); // the coroutine has yield its first value; save it return true; } } } }; private: std::coroutine_handle<promise_type> h_; generator(std::coroutine_handle<promise_type> h) : h_(h) {} public: explicit generator() = default; // ------ Prevent copies generator(const generator&) = delete; generator& operator=(const generator&) = delete; // ------ Allow moves generator(generator&& other) noexcept { std::swap(h_, other.h_); } generator& operator=(generator&& other) noexcept { std::swap(h_, other.h_); return *this; } ~generator() { if(h_) { h_.destroy(); h_ = {}; } } bool is_resumable() const { return h_ && !h_.done(); } bool operator()() { return resume(); } bool resume() { assert(is_resumable()); if(h_.promise().innerCoroutine_) { // The coroutine has yielded another inner coroutine that is not finished yet // run it until next yield or its end h_.promise().innerCoroutine_->resume(); if(h_.promise().innerCoroutine_->is_resumable()) { h_.promise().t_ = std::move(h_.promise().innerCoroutine_->get()); // yielded a value - save it return true; } else { h_.promise().innerCoroutine_ = {}; h_(); // inner coroutine has stopped - continue main coroutine return !h_.done(); } } else { h_(); return !h_.done(); } } [[nodiscard]] const T& get() const { return h_.promise().t_.value(); } [[nodiscard]] T& get() // Allow movable { return h_.promise().t_.value(); } // ----------------- Range based loop stuff class iterator { public: using iterator_category = std::input_iterator_tag; using difference_type = std::ptrdiff_t; using value_type = T; using pointer = value_type*; using reference = value_type&; iterator(generator* gen = nullptr) : gen_(gen) { if(gen_) { if(!gen_->is_resumable()) { gen_ = nullptr; // gen_ is an default-constructed generator } else { ++(*this); // Since the generator does not run at creation, run until first yield (or until end) } } } auto& operator*() const { return gen_->get(); } bool operator==(const iterator&) const = default; iterator& operator++() { gen_->resume(); if(!gen_->is_resumable()) { gen_ = nullptr; } return *this; } private: generator* gen_; // If set to nullptr, this is an end pointer }; iterator begin() { return {this}; } iterator end() { return {}; } };
dnl AMD64 mpn_addlsh_n and mpn_rsblsh_n. R = V2^k +- U. dnl Copyright 2006, 2010-2012 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C AMD K8,K9 3.1 < 3.85 for lshift + add_n C AMD K10 3.1 < 3.85 for lshift + add_n C Intel P4 14.6 > 7.33 for lshift + add_n C Intel core2 3.87 > 3.27 for lshift + add_n C Intel NHM 4 > 3.75 for lshift + add_n C Intel SBR (5.8) > 3.46 for lshift + add_n C Intel atom (7.75) < 8.75 for lshift + add_n C VIA nano 4.7 < 6.25 for lshift + add_n C This was written quickly and not optimized at all. Surely one could get C closer to 3 c/l or perhaps even under 3 c/l. Ideas: C 1) Use indexing to save the 3 LEA C 2) Write reasonable feed-in code C 3) Be more clever about register usage C 4) Unroll more, handling CL negation, carry save/restore cost much now C 5) Reschedule C INPUT PARAMETERS define(`rp', `%rdi') define(`up', `%rsi') define(`vp', `%rdx') define(`n', `%rcx') define(`cnt', `%r8') ifdef(`OPERATION_addlsh_n',` define(ADCSBB, `adc') define(func, mpn_addlsh_n) ') ifdef(`OPERATION_rsblsh_n',` define(ADCSBB, `sbb') define(func, mpn_rsblsh_n) ') MULFUNC_PROLOGUE(mpn_addlsh_n mpn_rsblsh_n) ABI_SUPPORT(DOS64) ABI_SUPPORT(STD64) ASM_START() TEXT ALIGN(16) PROLOGUE(func) FUNC_ENTRY(4) IFDOS(` mov 56(%rsp), %r8d ') push %r12 push %r13 push %r14 push %rbp push %rbx mov n, %rax xor R32(%rbx), R32(%rbx) C clear carry save register mov R32(%r8), R32(%rcx) C shift count xor R32(%rbp), R32(%rbp) C limb carry mov R32(%rax), R32(%r11) and $3, R32(%r11) je L(4) sub $1, R32(%r11) L(012): mov (vp), %r8 mov %r8, %r12 shl R8(%rcx), %r8 or %rbp, %r8 neg R8(%rcx) mov %r12, %rbp shr R8(%rcx), %rbp neg R8(%rcx) add R32(%rbx), R32(%rbx) ADCSBB (up), %r8 mov %r8, (rp) sbb R32(%rbx), R32(%rbx) lea 8(up), up lea 8(vp), vp lea 8(rp), rp sub $1, R32(%r11) jnc L(012) L(4): sub $4, %rax jc L(end) ALIGN(16) L(top): mov (vp), %r8 mov %r8, %r12 mov 8(vp), %r9 mov %r9, %r13 mov 16(vp), %r10 mov %r10, %r14 mov 24(vp), %r11 shl R8(%rcx), %r8 shl R8(%rcx), %r9 shl R8(%rcx), %r10 or %rbp, %r8 mov %r11, %rbp shl R8(%rcx), %r11 neg R8(%rcx) shr R8(%rcx), %r12 shr R8(%rcx), %r13 shr R8(%rcx), %r14 shr R8(%rcx), %rbp C used next iteration or %r12, %r9 or %r13, %r10 or %r14, %r11 neg R8(%rcx) add R32(%rbx), R32(%rbx) C restore carry flag ADCSBB (up), %r8 ADCSBB 8(up), %r9 ADCSBB 16(up), %r10 ADCSBB 24(up), %r11 mov %r8, (rp) mov %r9, 8(rp) mov %r10, 16(rp) mov %r11, 24(rp) sbb R32(%rbx), R32(%rbx) C save carry flag lea 32(up), up lea 32(vp), vp lea 32(rp), rp sub $4, %rax jnc L(top) L(end): add R32(%rbx), R32(%rbx) ADCSBB $0, %rbp mov %rbp, %rax pop %rbx pop %rbp pop %r14 pop %r13 pop %r12 FUNC_EXIT() ret EPILOGUE()
*********************************************************************** 00001000 * * 00002000 * VSE KERMIT UPDATE CONVERTOR * 00003000 * * 00004000 * Author: Jeff Huestis, Washington University Libraries * 00005000 * * 00006000 * Purpose: Read sequential file of updates in GUPI format and * 00007000 * submit a job via POWER to update Kermit sources. * 00008000 * * 00009000 * Method: Read update file from SYSIPT and create LIBR control * 00010000 * sequences for individual library members based on a table * 00011000 * of starting sequence numbers for the Kermit source. Write * 00012000 * the output to SYSPCH along with LIBR directives for copying * 00013000 * the Kermit source library members to a work library. The * 00014000 * updates are then applied to the work library. Any errors * 00015000 * are noted on SYSLST for the conversion process. Bad syntax * 00016000 * in the input file will cause the program to abort. * 00017000 * * 00018000 * IKXTRN parameters are entered is the first lines in the input * 00019000 * file. Parameter lines are recognized by a keyword or all * 00020000 * numeric string in columns 1 through 8, and "=" in column 9. * 00021000 * * 00022000 * REQUIRED Parameters: * 00023000 * 1. BASELIBR= specify a 'library.sublibrary' string indicating where* 00024000 * unmodified KERMIT source is kept. * 00025000 * 2. WORKLIBR= specify a 'library.sublibrary' string for the library * 00026000 * where modified, working copies of KERMIT source are to be kept. * 00027000 * 3. LOCALLST= specify the text you want for the * $$ LST card for * 00028000 * the job which IKXTRN will punch to the POWER internal reader. * 00029000 * * 00030000 * OPTIONAL Parameters: * 00031000 * 4. LOCALSLI= parameter is optional. Use it to specify the name of * 00032000 * a library member containing label information not in the * 00033000 * standard label area. This member will be copied into the * 00034000 * generated job by a POWER SLI statement. The generated SLI will * 00035000 * use the "MEM=" format, so the member name qualifier should be * 00036000 * included. Example: LOCALSLI=KERMSLIS.P * 00037000 * 5. nnnnnnnn= Future releases of CICS Kermit (or local re-packaging)* 00038000 * may alter the sequence of module names included in the table * 00039000 * starting at label STARTNUM. For this reason, it is possible to * 00040000 * replace this table with a series of lines giving the starting * 00041000 * line number for each module in columns 1 through 8 and the name * 00042000 * of the module in the 12 columns from column 10 onwards. If this* 00043000 * option is used, the entire table must be replaced, and the * 00044000 * parameter cards must be in ascending order by line sequence #. * 00045000 * * 00046000 * Update history: * 00047000 * 1.0 - 1991 January - Implementation complete, except for the * 00048000 * resequence command "./ S". * 00049000 * 1.1 - 1991 January - Updated by Jeff Huestis and John Chandler. * 00050000 * Libraries specified via PARM * 00051000 * 1.2 - 1991 March - Updated by Jeff Huestis. * 00052000 * Libraries and other parameters specified * 00053000 * via SYSIPT. * 00054000 * 1.3 - 1991 July - Updated by John Chandler. * 00054300 * Input line number in error messages. * 00054600 * 1.4 - 1992 May - Updated by John Chandler. Ignore blank lines* 00054800 * * 00055000 *********************************************************************** 00056000 * 00057000 * REGISTER EQUATES 00058000 R0 EQU 0 00059000 R1 EQU 1 00060000 R2 EQU 2 00061000 R3 EQU 3 00062000 R4 EQU 4 00063000 R5 EQU 5 00064000 R6 EQU 6 00065000 R7 EQU 7 00066000 R8 EQU 8 00067000 R9 EQU 9 00068000 R10 EQU 10 00069000 R11 EQU 11 00070000 R12 EQU 12 00071000 R13 EQU 13 00072000 R14 EQU 14 00073000 R15 EQU 15 00074000 * 00075000 IKXTRN CSECT 00076000 BALR 12,0 STANDARD ENTRY LINKAGE 00077000 USING *,12 00078000 LA 13,REGSAVE 00079000 B A000 BRANCH AROUND PROGRAM ID & SAVE AREA 00080000 PGRMNAM DC CL8'IKXTRN' PROGRAM NAME 00081000 DC PL2'1,4' VERSION/LEVEL 00082000 REGSAVE DS 9D REGISTER SAVE AREA 00083000 * 00084000 *********************************************************************** 00085000 * PROCESS PARM DATA 00086000 *********************************************************************** 00087000 A000 EQU * 00088000 XC NRECBL,NRECBL Initialize blank count 00088200 XC NRECIN,NRECIN Initialize input count 00088500 OPEN LIST,INPFILE,OUTFILE OPEN FILES 00089000 MVC MESSLINE(35),=C'FILES OPENED; PARAMETER CARDS READ:' 00090000 PUT LIST,MESSAGE 00091000 L R4,=A(STARTNUM) POINT TO START OF MODULE TABLE 00092000 USING STARTNUM,R4 00093000 LA R5,MODCOUNT GET DEFAULT MODULE COUNT 00094000 STH R5,NUMMOD AND STORE WHERE IT COUNTS 00095000 LA R5,STARTEND GET POINTER TO LAST MODULE OF DEFAULT 00096000 ST R5,LSTMOD AND STORE IT FOR POSSIBLE CHANGE 00097000 XR R5,R5 INITIALIZE MODULE NAME COUNTER 00098000 NEXTPARM EQU * 00099000 LA 0,1 00099200 A 0,NRECIN 00099400 ST 0,NRECIN Count input records 00099600 GET INPFILE GET ANOTHER INPUT CARD 00100000 CLC =C'./ ',INRECORD ARE WE DONE WITH PARM CARDS? 00101000 BE JCLPROC YES, GO PROCESS JCL TABLE 00102000 MVC MESSLINE(80),INRECORD NO, ECHO INPUT TO SYSLST 00103000 PUT LIST,MESSAGE 00104000 CLC BLANKS(72),INRECORD Blank card? 00104100 BNE NEXTPAR1 No, assume it's a parm card 00104200 LA 0,1 Yes, skip it entirely 00104300 A 0,NRECBL 00104400 ST 0,NRECBL But count blank records 00104500 B NEXTPARM Go get another record 00104600 NEXTPAR1 DS 0H 00104700 CLI INRECORD+8,C'=' DO WE HAVE A VALID CARD? 00105000 BNE PARMEXIT No, assume we're done with parms 00106000 CLC =C'BASELIBR',INRECORD SEE IF THIS IS BASE LIBRARY 00107000 BNE NOTBASE NO, TRY SOMETHING ELSE 00108000 MVC CONNECT+18(16),INRECORD+9 YES, MOVE IT INTO JCL TABLE 00109000 OI LIBFLAG,X'01' INDICATE IT WAS FOUND 00110000 B NEXTPARM GO READ ANOTHER CARD 00111000 NOTBASE EQU * 00112000 CLC =C'WORKLIBR',INRECORD SEE IF THIS IS WORK LIBRARY 00113000 BNE NOTWORK NO, TRY SOMETHING ELSE 00114000 MVC CONNECT+35(16),INRECORD+9 YES, MOVE IT INTO JCL TABLE 00115000 MVC ACCESS+17(16),INRECORD+9 IN TWO PLACES 00116000 OI LIBFLAG,X'02' INDICATE IT WAS FOUND 00117000 B NEXTPARM GO READ ANOTHER CARD 00118000 NOTWORK EQU * 00119000 CLC =C'LOCALSLI',INRECORD IS THERE A POWER SLI CARD? 00120000 BNE NOTSLI NO, TRY SOMETHING ELSE 00121000 MVC SLI(13),=C'* $$ SLI MEM=' YES, CHANGE COMMENT TO SLI 00122000 MVC SLI+13(17),INRECORD+9 AND PUT IN MEMBER NAME 00123000 B NEXTPARM GO READ ANOTHER CARD 00124000 NOTSLI EQU * 00125000 CLC =C'LOCALLST',INRECORD IS THIS THE LOCAL LST CARD? 00126000 BNE NOTLST NO, GO LOOK FOR MODNAMES 00127000 MVC LSTCARD+9(JOBMX-9),INRECORD+9 YES, MOVE LST DATA 00128000 OI LIBFLAG,X'04' INDICATE LST FOUND 00129000 B NEXTPARM GO READ ANOTHER CARD 00130000 NOTLST EQU * 00131000 LA R3,INRECORD OTHER POSSIBILITIES EXHAUSTED, THIS 00132000 LR R2,R3 BETTER BE A MODULE CARD 00133000 BAL R14,DIGITVER SO CHECK FOR START NUMBER 00134000 SR R2,R3 00135000 CH R2,=H'8' LENGTH 8 => PROPER NUMERIC STRING 00136000 BNE NOPARM NOPE 00137000 MVC STARTNUM,INRECORD OKAY, MOVE START # TO TABLE 00138000 MVC MODNAME,INRECORD+9 MOVE NAME TO TABLE 00139000 LA R4,STTBLLEN(,R4) POINT TO NEXT TABLE ENTRY 00140000 ST R4,LSTMOD UPDATE LAST-MODULE POINTER 00141000 LA R5,1(,R5) INCREMENT MODULE COUNTER 00142000 B NEXTPARM 00143000 DROP R4 00144000 *********************************************************************** 00145000 * COPY JCL TABLE LINES TO SYSPCH 00146000 *********************************************************************** 00147000 PARMEXIT DS 0H 00147200 MVI MESSLINE,C' ' Clear message buffer 00147260 MVC MESSLINE+1(79),MESSLINE 00147320 MVC MESSLINE(49),=C'PRECEDING INVALID CARD TERMINATES PARM P$00147400 ROCESSING' 00147600 PUT LIST,MESSAGE 00147800 JCLPROC EQU * 00148000 TM LIBFLAG,X'07' DID WE GET THE REQUIRED PARAMETERS? 00149000 BNO NOPARM NO, GO ABORT 00150000 MVC OUTREC,BLANKS Clear output buffer 00151000 LA R3,JOBCARDS Start of JCL table 00152000 LTR R5,R5 DID WE HAVE ANY MODULE CARDS IN DECK? 00153000 BZ JCLLOOP NO; LEAVE DEFAULT 00154000 STH R5,NUMMOD YES; ADJUST COUNT 00155000 JCLLOOP EQU * 00156000 MVC OUTREC(JOBMX),0(R3) Copy a line to output 00157000 CLC COPIES,OUTREC Reached list of COPY directives? 00158000 BNE JCLWRITE No, just write the record 00159000 * Fill in names of modules in COPY directives 00160000 L R2,=A(STARTNUM) Start of module table 00161000 LH R5,NUMMOD Length of table (in entries) 00162000 JCLLP1 DS 0H 00163000 MVC OUTREC+8(12),8(R2) Copy module name 00164000 LA R4,OUTREC+8 Start of name 00165000 LA R4,1(,R4) 00166000 CLI 0(R4),C' ' Look for end of name 00167000 BNE *-8 00168000 MVC 1(20,R4),=CL20'REPLACE=YES' 00169000 PUT OUTFILE 00170000 LA R2,STTBLLEN(,R2) 00171000 BCT R5,JCLLP1 00172000 B JCLLP2 Finished COPY directives 00173000 JCLWRITE DS 0H 00174000 PUT OUTFILE PUNCH IT OUT 00175000 JCLLP2 DS 0H 00176000 LA R3,JOBMX(,R3) Point to next line 00177000 CLC =C'EOD',0(R3) CHECK FOR END OF TABLE 00178000 BNE JCLLOOP Not yet, keep copying 00179000 B PROCESS Go process first update card 00180000 * 00181000 *********************************************************************** 00182000 * PROCESS UPDATE LINES 00183000 *********************************************************************** 00184000 SKIPBLNK LA 0,1 00184200 A 0,NRECBL 00184400 ST 0,NRECBL Count blank records 00184600 * Main loop - read a control card 00185000 CTLP DS 0H 00186000 LA 0,1 00186200 A 0,NRECIN 00186400 ST 0,NRECIN Count input records 00186600 GET INPFILE READ NEXT LINE 00187000 CLC BLANKS(72),INRECORD Blank card? 00187300 BE SKIPBLNK Yes, skip it 00187600 CLC =C'./ ',INRECORD Control card? 00188000 BNE BADDECK No, too bad 00189000 * 00190000 * Process an editing card 00191000 PROCESS EQU * 00192000 LA R2,INRECORD+3 Start after control indicator 00193000 LA R8,SYNTAX Error handler for running off end 00194000 BAL R14,BLNKSKIP Find command code 00195000 MVC CMD,0(R2) Save code 00196000 CLI 1(R2),C' ' Should be 1 char 00197000 BNE SYNTAX No, bad syntax 00198000 CLI CMD,C'*' Comment? 00199000 BE CTLP Yes, ignore it 00200000 LA R2,2(,R2) Skip over command code 00201000 BAL R8,ARGLOAD Get a numeric argument 00202000 B SYNTAX Missing, too bad 00203000 UNPK FRSTLINE,ARGNO Get zoned copy 00204000 MVC LASTLINE,BLANKS Blank out last line as default 00205000 BAL R8,ARGLOAD Get 2nd numeric argument, if any 00206000 B PROCES2 Just one card 00207000 UNPK LASTLINE,ARGNO Get zoned copy of last line 00208000 BAL R8,ARGLOAD Should be followed by '$' (or end) 00209000 B PROCES2 Ok 00210000 B SYNTAX Oops, extra number there 00211000 PROCES2 DS 0H 00212000 CLI CMD,C'D' 00213000 BE NOSEQ Done if delete 00214000 LA R2,1(,R2) Skip over '$' 00215000 BAL R8,ARGLOAD Get output line number, if any 00216000 B SYNTAX Not given, too bad 00217000 MVC LINENUM,ARGNO FIRST NUMBER SHOULD BE START LINE # 00218000 BAL R8,ARGLOAD Get increment value, if any 00219000 B SYNTAX Not given, too bad 00220000 MVC INCRMENT,ARGNO Ok, use it 00221000 NOSEQ EQU * 00222000 BAL R8,MODSRCH GO FIND OUT NAME OF MODULE 00223000 MVC OUTREC,BLANKS Clear output buffer 00224000 CLI FRSTFLAG,X'FF' SEE IF THIS IS FIRST TIME THROUGH 00225000 BE FIRST YES 00226000 CLC MODOLD,MODULE Same module? 00227000 BNE SWITCH No, start new update 00228000 CLC LASTOLD,FRSTLINE Later in same module? 00229000 BL CONTINUE Yes, keep same update 00230000 SWITCH DS 0H 00231000 MVC OUTREC(4),=C')END' NO, TERMINATE PREVIOUS UPDATE 00232000 PUT OUTFILE 00233000 FIRST EQU * 00234000 XC FRSTFLAG,FRSTFLAG CLEAR LOOP TAG FOR FUTURE TESTS 00235000 MVC OUTREC(10),=C' UPDATE ' SET UP VSE LIBR DIRECTIVE 00236000 MVC OUTREC+10(12),MODULE SUPPLY MODULE NAME 00237000 MVC OUTREC+22(14),=C',SE=FS,C=73:80' LINE SEQUENCING INFO 00238000 PUT OUTFILE WRITE OUTPUT RECORD 00239000 MVC MODOLD,MODULE Save for comparison next time 00240000 CONTINUE DS 0H 00241000 MVC LASTOLD,FRSTLINE Ditto 00242000 MVC OUTREC,BLANKS Clear output buffer 00243000 MVC OUTREC+5(8),FRSTLINE PUT IN LOCATION WHERE IT STARTS 00244000 * NOW SEE WHAT TYPE OF UPDATE IT IS 00245000 ICHECK EQU * 00246000 CLI CMD,C'I' Insert? 00247000 BNE DCHECK NO, GO CHECK FOR DELETION 00248000 MVC OUTREC(4),=C')ADD' YES, SET UP VSE LIBR FORM 00249000 B PUTCMND GO WRITE IT OUT 00250000 DCHECK EQU * 00251000 * Now must be D or R, so copy end of range 00252000 MVI OUTREC+13,C',' Delimiter and 00253000 MVC OUTREC+14(8),LASTLINE Location of end of range 00254000 CLI CMD,C'D' Delete? 00255000 BNE RCHECK NO, GO CHECK FOR REPLACEMENT 00256000 MVC OUTREC(4),=C')DEL' YES, SET UP VSE LIBR FORM 00257000 B PUTCMND GO WRITE IT OUT 00258000 RCHECK EQU * 00259000 CLI CMD,C'R' Replace? 00260000 BNE SYNTAX NO, ERROR 00261000 MVC OUTREC(4),=C')REP' YES, SET UP VSE LIBR FORM 00262000 PUTCMND EQU * 00263000 PUT OUTFILE WRITE UPDATE DIRECTIVE OUT 00264000 * NOW GET THE UPDATE LINES THEMSELVES 00265000 LINELOOP EQU * 00266000 LA 0,1 00266200 A 0,NRECIN 00266400 ST 0,NRECIN Count input records 00266600 GET INPFILE GET ANOTHER INPUT LINE 00267000 CLC =C'./ ',INRECORD Control card? 00268000 BE PROCESS YES, PREVIOUS UPDATES ARE FINISHED 00269000 CLC BLANKS(72),INRECORD Blank card? 00269100 BNE LINELOO1 No, must be new data 00269200 LA 0,1 Yes, skip it entirely 00269300 A 0,NRECBL 00269400 ST 0,NRECBL But count blank records 00269500 B LINELOOP Go get another record 00269600 LINELOO1 DS 0H 00269700 UNPK ZONEHOLD,LINENUM NO, UNPACK CURRENT LINE NUMBER 00270000 OI ZONEHOLD+7,X'F0' GET RID OF ZONED DECIMAL SIGN 00271000 MVC OUTREC,INRECORD COPY RECORD 00272000 MVC OUTREC+72(8),ZONEHOLD AND OVERLAY LINE SEQUENCE NUMBER 00273000 PUT OUTFILE WRITE OUTPUT RECORD 00274000 MVC LASTOLD,ZONEHOLD Latest line put out 00275000 AP LINENUM,INCRMENT INCREMENT LINE NUMBER FOR NEXT PASS 00276000 B LINELOOP GO GET ANOTHER LINE 00277000 * END OF INPUT FILE REACHED 00278000 A100 EQU * 00279000 MVC OUTREC,BLANKS Clear output buffer 00280000 MVC OUTREC(4),=C')END' TERMINATE PREVIOUS UPDATE 00281000 PUT OUTFILE AND WRITE IT OUT 00282000 MVC OUTREC,BLANKS Clear output buffer 00283000 * WRITE TERMINATION SEQUENCE TO GENERATED JOB 00284000 MVC OUTREC(2),=C'/*' 00285000 PUT OUTFILE 00286000 MVC OUTREC(2),=C'/&&' 00287000 PUT OUTFILE 00288000 MVC OUTREC(8),=C'* $$ EOJ' 00289000 PUT OUTFILE 00290000 EOJ EQU * 00291000 BAL R8,PRNTSKIP Print number of skipped records, if any 00291500 CLOSE INPFILE,OUTFILE,LIST 00292000 EOJ 00293000 * 00294000 * Find name of module to be updated 00295000 MODSRCH EQU * 00296000 LH R7,NUMMOD Number of entries in table 00297000 L R2,LSTMOD End of table 00298000 MODLOOP EQU * 00299000 SH R2,=Y(STTBLLEN) Back up one entry 00300000 CLC 0(8,R2),FRSTLINE COMPARE START LINE TO CURRENT ENTRY 00301000 BNH FOUND ENTRY L.E. => THIS IS THE ONE 00302000 BCT R7,MODLOOP DECREMENT INDEX 00303000 NOTFOUND EQU * 00304000 XC MODULE,MODULE ZERO VALUE INDICATES ERROR 00305000 MVC MESSLINE,BLANKS Clear message buffer 00305500 MVC MESSLINE(21),=C'MODULE NAME NOT FOUND' 00306000 PUT LIST,MESSAGE 00307000 MVC MESSLINE(80),INRECORD 00308000 PUT LIST,MESSAGE 00309000 BR R8 RETURN TO CALLER 00310000 FOUND EQU * 00311000 MVC MODULE,8(R2) Copy module name from table 00312000 BR R8 RETURN TO CALLER 00313000 * Table of starting line numbers and module names 00314000 * 00315000 * Find next numeric field in card, skip if ok 00316000 * Clobbers R3, R14. Returns via R8. Advances R2 00317000 ARGLOAD DS 0H 00318000 BAL R14,BLNKSKIP 00319000 LR R3,R2 00320000 CLI 0(R3),C'0' Numeric? 00321000 BLR R8 No, return without skipping 00322000 BAL R14,DIGITVER 00323000 BCTR R2,0 Last char 00324000 SR R2,R3 Count - 1 00325000 EX R2,PCKA 00326000 OI ARGNO+4,15 Fix sign, just in case 00327000 LA R2,1(R2,R3) RESTORE POINTER TO END + 1 00328000 B 4(,R8) Return and skip 00329000 PCKA PACK ARGNO,0(,R3) Get packed decimal 00330000 * Scan R2 until it reaches a non-blank character 00331000 BLNKSKIP EQU * 00332000 CLI 0(R2),C' ' 00333000 BNER R14 00334000 LA R2,1(,R2) 00335000 C R2,=A(INRECORD+50) Off the end? 00336000 BNLR R8 Yes, go to error handler 00337000 B BLNKSKIP 00338000 * Scan R2 until it reaches a non-numeric character 00339000 DIGITVER EQU * 00340000 CLI 0(R2),C'0' 00341000 BLR R14 00342000 CLI 0(R2),C'9' 00343000 BHR R14 00344000 LA R2,1(,R2) 00345000 C R2,=A(INRECORD+50) Off the end? 00346000 BNLR R8 Yes, go to error handler 00347000 B DIGITVER 00348000 PRNTSKIP ICM 0,15,NRECBL Test count of blank records 00348100 BZR R8 00348200 MVC MESSLINE,BLANKS Clear message buffer 00348300 MVC MESSLINE(29),=C'BLANK INPUT RECORDS IGNORED: ' 00348400 CVD 0,TEMPDW 00348500 OI TEMPDW+7,15 00348600 UNPK MESSLINE+29(5),TEMPDW 00348700 PUT LIST,MESSAGE 00348800 BR R8 00348900 BADDECK EQU * 00349000 MVC MESSLINE,BLANKS Clear message buffer 00349500 MVC MESSLINE(34),=C'OUT-OF-SEQUENCE STATEMENT AT LINE ' 00350000 L 0,NRECIN Input record count 00350100 CVD 0,TEMPDW 00350200 OI TEMPDW+7,15 00350300 UNPK MESSLINE+34(5),TEMPDW 00350400 PUT LIST,MESSAGE 00351000 MVC MESSLINE(80),INRECORD 00352000 PUT LIST,MESSAGE 00353000 B EOJ 00354000 NOPARM EQU * 00355000 MVC MESSLINE,BLANKS 00355500 MVC MESSLINE(26),=C'MISSING OR INVALID PARM(S)' 00356000 PUT LIST,MESSAGE 00357000 B EOJ 00358000 SYNTAX DS 0H 00359000 MVC MESSLINE,BLANKS 00359500 MVC MESSLINE(33),=C'INVALID UPDATE STATEMENT AT LINE ' 00360000 L 0,NRECIN Input record count 00360100 CVD 0,TEMPDW 00360200 OI TEMPDW+7,15 00360300 UNPK MESSLINE+33(5),TEMPDW 00360400 MVI MESSLINE+38,C':' 00360500 PUT LIST,MESSAGE 00361000 MVC MESSLINE(80),INRECORD 00362000 PUT LIST,MESSAGE 00363000 B CTLP 00364000 INPERROR EQU * 00365000 MVC MESSLINE(19),=C'ERROR ON INPUT FILE' 00366000 PUT LIST,MESSAGE 00367000 BAL R8,PRNTSKIP Print number of skipped records, if any 00367500 ABORT SVC 50 00368000 * 00369000 TEMPDW DS D Work area 00369300 NRECBL DS F Counter for input blank records 00369400 NRECIN DS F Input record counter 00369600 LSTMOD DS F 00370000 NUMMOD DS H 00371000 LIBFLAG DC X'00' 00372000 MODULE DS CL12 NAME OF MODULE TO WHICH UPDATE LINES APPLY 00373000 ZONEHOLD DS CL8 PLACE TO HOLD ZONED DECIMAL NUMBERS 00374000 MODOLD DS CL12 Saved MODULE from previous control group 00375000 LASTOLD DS CL8 Saved output line number from ditto 00376000 ARGNO DS PL5 Number read from control card 00377000 CMD DS C Control command code 00378000 LINENUM DS PL5 STARTING LINE # FROM INPUT RECORD 00379000 INCRMENT DS PL5 INCREMENT VALUE FROM INPUT RECORD 00380000 FRSTLINE DS CL8 Line where changes start 00381000 LASTLINE DS CL8 Last line to delete or replace 00382000 INRECORD DS CL81 00383000 OUTCARD DS 0CL81 00384000 DC C'W' 00385000 OUTREC DS CL80 OUTPUT WORK AREA 00386000 FRSTFLAG DC X'FF' 00387000 MESSAGE DC C' ' 00388000 MESSLINE DC CL132' ' 00389000 BLANKS DC 132C' ' 00390000 LTORG 00391000 JOBMX EQU 60 Maximum length string below 00392000 JOBCARDS EQU * 00393000 LSTCARD DC CL(JOBMX)'* $$ LST ' 00394000 DC CL(JOBMX)'// JOB APPLY KERMIT UPDATES' 00395000 SLI DC CL(JOBMX)'*' 00396000 DC CL(JOBMX)'// EXEC LIBR' 00397000 CONNECT DC CL(JOBMX)' CONNECT SUBLIB= :' 00398000 COPIES DC CL(JOBMX)' COPY' This card is to be duplicated 00399000 DC CL(JOBMX)'/*' 00400000 DC CL(JOBMX)'// EXEC LIBR' 00401000 ACCESS DC CL(JOBMX)' ACCESS SUBLIB=' 00402000 DC C'EOD' 00403000 * INPUT AND OUTPUT FILES 00404000 INPFILE DTFDI DEVADDR=SYSIPT,IOAREA1=INRECORD,RECSIZE=81,EOFADDR=A100,X00405000 ERROPT=INPERROR 00406000 OUTFILE DTFDI DEVADDR=SYSPCH,IOAREA1=OUTCARD,RECSIZE=81 00407000 LIST DTFPR DEVADDR=SYSLST,CTLCHR=ASA,BLKSIZE=133,WORKA=YES, X00408000 IOAREA1=AREA 00409000 AREA DS CL133 00410000 IKXTMODS CSECT 00411000 STARTNUM DC CL8'00001000' 00412000 MODNAME DC CL12'IK0DOC.A' 00413000 STTBLLEN EQU *-STARTNUM Length of one entry 00414000 DC CL8'00300000',CL12'IK0MAC.A' 00415000 DC CL8'00800000',CL12'IKXMAC.A' 00416000 DC CL8'01400000',CL12'IK0DEF.A' 00417000 DC CL8'01500000',CL12'IK0MAI.A' 00418000 DC CL8'01800000',CL12'IK0COM.A' 00419000 DC CL8'03000000',CL12'IK0CMD.A' 00420000 DC CL8'05000000',CL12'IKXUTL.A' 00421000 DC CL8'07000000',CL12'IK0PRO.A' 00422000 STARTEND EQU * 00423000 MODCOUNT EQU (*-STARTNUM)/STTBLLEN 00424000 DS 100CL(STTBLLEN) 00425000 END 00426000
/* * Copyright (c) 2017, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ //! //! \file codechal_encode_mpeg2_g9.cpp //! \brief MPEG2 dual-pipe encoder for GEN9. //! #include "codechal_encode_mpeg2_g9.h" #include "igcodeckrn_g9.h" struct KernelHeader { uint32_t m_kernelCount; // MBEnc Norm/Perf/Quality moes for frame CODECHAL_KERNEL_HEADER m_mpeg2MbEncI; CODECHAL_KERNEL_HEADER m_mpeg2MbEncP; CODECHAL_KERNEL_HEADER m_mpeg2MbEncB; // ME Downscale CODECHAL_KERNEL_HEADER m_plyDscalePly; // AVC_ME kernels for distortion CODECHAL_KERNEL_HEADER m_mpeg2AvcMeP; CODECHAL_KERNEL_HEADER m_mpeg2AvcMeB; CODECHAL_KERNEL_HEADER m_mpeg2InitFrameBrc; CODECHAL_KERNEL_HEADER m_mpeg2FrameEncUpdate; CODECHAL_KERNEL_HEADER m_mpeg2BrcResetFrame; // BRCBlockCopy CODECHAL_KERNEL_HEADER m_mpeg2BrcBlockCopy; }; enum BindingTableOffsetMeG9 { meMvDataSurface = 0, meDistortionSurface = 2, meBrcDistortion = 3, meCurrForFwdRef = 5, meFwdRefIdx0 = 6, meCurrForBwdRef = 22, meBwdRefIdx0 = 23, meNumSurface = 27, }; enum BindingTableOffsetMbEncG9 { mbEncPakObj = 0, mbEncPakObjPrev = 1, mbEncCurrentY = 3, mbEncBrcDistortionSurface = 8, mbEncCurrentPic = 9, mbEncForwardPic = 10, mbEncBackwardPic = 11, mbEncInterlaceFrameCurrentPic = 14, mbEncInterlaceFrameBackwardPic = 15, mbEncMbControl = 18, mbEncNumBindingTableEntries = 19 }; class MeCurbeG9 { public: struct CurbeData { // DW0 union { struct { uint32_t m_skipModeEn : MOS_BITFIELD_BIT(0); uint32_t m_adaptiveEn : MOS_BITFIELD_BIT(1); uint32_t m_biMixDis : MOS_BITFIELD_BIT(2); uint32_t m_reserved3 : MOS_BITFIELD_RANGE(3, 4); uint32_t m_earlyImeSuccessEn : MOS_BITFIELD_BIT(5); uint32_t m_reserved6 : MOS_BITFIELD_BIT(6); uint32_t m_t8x8FlagForInterEn : MOS_BITFIELD_BIT(7); uint32_t m_reserved8 : MOS_BITFIELD_RANGE(8, 23); uint32_t m_earlyImeStop : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW0; // DW1 union { struct { uint32_t m_maxNumMVs : MOS_BITFIELD_RANGE(0, 5); uint32_t m_reserved6 : MOS_BITFIELD_RANGE(6, 15); uint32_t m_biWeight : MOS_BITFIELD_RANGE(16, 21); uint32_t m_reserved22 : MOS_BITFIELD_RANGE(22, 27); uint32_t m_uniMixDisable : MOS_BITFIELD_BIT(28); uint32_t m_reserved29 : MOS_BITFIELD_RANGE(29, 31); }; struct { uint32_t m_value; }; } DW1; // DW2 union { struct { uint32_t m_maxLenSP : MOS_BITFIELD_RANGE(0, 7); uint32_t m_maxNumSU : MOS_BITFIELD_RANGE(8, 15); uint32_t m_reserved16 : MOS_BITFIELD_RANGE(16, 31); }; struct { uint32_t m_value; }; } DW2; // DW3 union { struct { uint32_t m_srcSize : MOS_BITFIELD_RANGE(0, 1); uint32_t m_reserved2 : MOS_BITFIELD_RANGE(2, 3); uint32_t m_mbTypeRemap : MOS_BITFIELD_RANGE(4, 5); uint32_t m_srcAccess : MOS_BITFIELD_BIT(6); uint32_t m_refAccess : MOS_BITFIELD_BIT(7); uint32_t m_searchCtrl : MOS_BITFIELD_RANGE(8, 10); uint32_t m_dualSearchPathOption : MOS_BITFIELD_BIT(11); uint32_t m_subPelMode : MOS_BITFIELD_RANGE(12, 13); uint32_t m_skipType : MOS_BITFIELD_BIT(14); uint32_t m_disableFieldCacheAlloc : MOS_BITFIELD_BIT(15); uint32_t m_interChromaMode : MOS_BITFIELD_BIT(16); uint32_t m_ftEnable : MOS_BITFIELD_BIT(17); uint32_t m_bmeDisableFBR : MOS_BITFIELD_BIT(18); uint32_t m_blockBasedSkipEnable : MOS_BITFIELD_BIT(19); uint32_t m_interSAD : MOS_BITFIELD_RANGE(20, 21); uint32_t m_intraSAD : MOS_BITFIELD_RANGE(22, 23); uint32_t m_subMbPartMask : MOS_BITFIELD_RANGE(24, 30); uint32_t m_reserved31 : MOS_BITFIELD_BIT(31); }; struct { uint32_t m_value; }; } DW3; // DW4 union { struct { uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0, 7); uint32_t m_pictureHeightMinus1 : MOS_BITFIELD_RANGE(8, 15); uint32_t m_pictureWidth : MOS_BITFIELD_RANGE(16, 23); uint32_t m_reserved24 : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW4; // DW5 union { struct { uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0, 7); uint32_t m_qpPrimeY : MOS_BITFIELD_RANGE(8, 15); uint32_t m_refWidth : MOS_BITFIELD_RANGE(16, 23); uint32_t m_refHeight : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW5; // DW6 union { struct { uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0, 2); uint32_t m_meModes : MOS_BITFIELD_RANGE(3, 4); uint32_t m_reserved5 : MOS_BITFIELD_RANGE(5, 7); uint32_t m_superCombineDist : MOS_BITFIELD_RANGE(8, 15); uint32_t m_maxVmvR : MOS_BITFIELD_RANGE(16, 31); }; struct { uint32_t m_value; }; } DW6; // DW7 union { struct { uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0, 15); uint32_t m_mvCostScaleFactor : MOS_BITFIELD_RANGE(16, 17); uint32_t m_bilinearEnable : MOS_BITFIELD_BIT(18); uint32_t m_srcFieldPolarity : MOS_BITFIELD_BIT(19); uint32_t m_weightedSADHAAR : MOS_BITFIELD_BIT(20); uint32_t m_acOnlyHAAR : MOS_BITFIELD_BIT(21); uint32_t m_refIDCostMode : MOS_BITFIELD_BIT(22); uint32_t m_reserved23 : MOS_BITFIELD_BIT(23); uint32_t m_skipCenterMask : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW7; // DW8 union { struct { uint32_t m_mode0Cost : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mode1Cost : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mode2Cost : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mode3Cost : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW8; // DW9 union { struct { uint32_t m_mode4Cost : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mode5Cost : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mode6Cost : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mode7Cost : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW9; // DW10 union { struct { uint32_t m_mode8Cost : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mode9Cost : MOS_BITFIELD_RANGE(8, 15); uint32_t m_refIDCost : MOS_BITFIELD_RANGE(16, 23); uint32_t m_chromaIntraModeCost : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW10; // DW11 union { struct { uint32_t m_mv0Cost : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mv1Cost : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mv2Cost : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mv3Cost : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW11; // DW12 union { struct { uint32_t m_mv4Cost : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mv5Cost : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mv6Cost : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mv7Cost : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW12; // DW13 union { struct { uint32_t m_numRefIdxL0MinusOne : MOS_BITFIELD_RANGE(0, 7); uint32_t m_numRefIdxL1MinusOne : MOS_BITFIELD_RANGE(8, 15); uint32_t m_actualMBWidth : MOS_BITFIELD_RANGE(16, 23); uint32_t m_actualMBHeight : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW13; // DW14 union { struct { uint32_t m_list0RefID0FieldParity : MOS_BITFIELD_BIT(0); uint32_t m_list0RefID1FieldParity : MOS_BITFIELD_BIT(1); uint32_t m_list0RefID2FieldParity : MOS_BITFIELD_BIT(2); uint32_t m_list0RefID3FieldParity : MOS_BITFIELD_BIT(3); uint32_t m_list0RefID4FieldParity : MOS_BITFIELD_BIT(4); uint32_t m_list0RefID5FieldParity : MOS_BITFIELD_BIT(5); uint32_t m_list0RefID6FieldParity : MOS_BITFIELD_BIT(6); uint32_t m_list0RefID7FieldParity : MOS_BITFIELD_BIT(7); uint32_t m_list1RefID0FieldParity : MOS_BITFIELD_BIT(8); uint32_t m_list1RefID1FieldParity : MOS_BITFIELD_BIT(9); uint32_t m_reserved10 : MOS_BITFIELD_RANGE(10, 31); }; struct { uint32_t m_value; }; } DW14; // DW15 union { struct { uint32_t m_prevMvReadPosFactor : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mvShiftFactor : MOS_BITFIELD_RANGE(8, 15); uint32_t m_reserved16 : MOS_BITFIELD_RANGE(16, 31); }; struct { uint32_t m_value; }; } DW15; struct { // DW16 union { struct { SearchPathDelta m_spDelta_0; SearchPathDelta m_spDelta_1; SearchPathDelta m_spDelta_2; SearchPathDelta m_spDelta_3; }; struct { uint32_t m_value; }; } DW16; // DW17 union { struct { SearchPathDelta m_spDelta_4; SearchPathDelta m_spDelta_5; SearchPathDelta m_spDelta_6; SearchPathDelta m_spDelta_7; }; struct { uint32_t m_value; }; } DW17; // DW18 union { struct { SearchPathDelta m_spDelta_8; SearchPathDelta m_spDelta_9; SearchPathDelta m_spDelta_10; SearchPathDelta m_spDelta_11; }; struct { uint32_t m_value; }; } DW18; // DW19 union { struct { SearchPathDelta m_spDelta_12; SearchPathDelta m_spDelta_13; SearchPathDelta m_spDelta_14; SearchPathDelta m_spDelta_15; }; struct { uint32_t m_value; }; } DW19; // DW20 union { struct { SearchPathDelta m_spDelta_16; SearchPathDelta m_spDelta_17; SearchPathDelta m_spDelta_18; SearchPathDelta m_spDelta_19; }; struct { uint32_t m_value; }; } DW20; // DW21 union { struct { SearchPathDelta m_spDelta_20; SearchPathDelta m_spDelta_21; SearchPathDelta m_spDelta_22; SearchPathDelta m_spDelta_23; }; struct { uint32_t m_value; }; } DW21; // DW22 union { struct { SearchPathDelta m_spDelta_24; SearchPathDelta m_spDelta_25; SearchPathDelta m_spDelta_26; SearchPathDelta m_spDelta_27; }; struct { uint32_t m_value; }; } DW22; // DW23 union { struct { SearchPathDelta m_spDelta_28; SearchPathDelta m_spDelta_29; SearchPathDelta m_spDelta_30; SearchPathDelta m_spDelta_31; }; struct { uint32_t m_value; }; } DW23; // DW24 union { struct { SearchPathDelta m_spDelta_32; SearchPathDelta m_spDelta_33; SearchPathDelta m_spDelta_34; SearchPathDelta m_spDelta_35; }; struct { uint32_t m_value; }; } DW24; // DW25 union { struct { SearchPathDelta m_spDelta_36; SearchPathDelta m_spDelta_37; SearchPathDelta m_spDelta_38; SearchPathDelta m_spDelta_39; }; struct { uint32_t m_value; }; } DW25; // DW26 union { struct { SearchPathDelta m_spDelta_40; SearchPathDelta m_spDelta_41; SearchPathDelta m_spDelta_42; SearchPathDelta m_spDelta_43; }; struct { uint32_t m_value; }; } DW26; // DW27 union { struct { SearchPathDelta m_spDelta_44; SearchPathDelta m_spDelta_45; SearchPathDelta m_spDelta_46; SearchPathDelta m_spDelta_47; }; struct { uint32_t m_value; }; } DW27; // DW28 union { struct { SearchPathDelta m_spDelta_48; SearchPathDelta m_spDelta_49; SearchPathDelta m_spDelta_50; SearchPathDelta m_spDelta_51; }; struct { uint32_t m_value; }; } DW28; // DW29 union { struct { SearchPathDelta m_spDelta_52; SearchPathDelta m_spDelta_53; SearchPathDelta m_spDelta_54; SearchPathDelta m_spDelta_55; }; struct { uint32_t m_value; }; } DW29; } SpDelta; // DW30 union { struct { uint32_t m_reserved; }; struct { uint32_t m_value; }; } DW30; // DW31 union { struct { uint32_t m_reserved; }; struct { uint32_t m_value; }; } DW31; // DW32 union { struct { uint32_t m_4xMeMvOutputDataSurfIndex; }; struct { uint32_t m_value; }; } DW32; // DW33 union { struct { uint32_t m_16xMeMvInputDataSurfIndex; }; struct { uint32_t m_value; }; } DW33; // DW34 union { struct { uint32_t m_4xMeOutputDistSurfIndex; }; struct { uint32_t m_value; }; } DW34; // DW35 union { struct { uint32_t m_4xMeOutputBrcDistSurfIndex; }; struct { uint32_t m_value; }; } DW35; // DW36 union { struct { uint32_t m_vmeFwdInterPredictionSurfIndex; }; struct { uint32_t m_value; }; } DW36; // DW37 union { struct { uint32_t m_vmeBwdInterPredictionSurfIndex; }; struct { uint32_t m_value; }; } DW37; // DW38 union { struct { uint32_t m_reserved; }; struct { uint32_t m_value; }; } DW38; }m_curbeData; //! //! \brief Constructor //! MeCurbeG9(); //! //! \brief Destructor //! ~MeCurbeG9(){}; static const size_t m_byteSize = sizeof(CurbeData); } ; class MbEncCurbeG9 { public: struct CurbeData { union { struct { uint32_t m_skipModeEn : MOS_BITFIELD_BIT(0); uint32_t m_adaptiveEn : MOS_BITFIELD_BIT(1); uint32_t m_biMixDis : MOS_BITFIELD_BIT(2); uint32_t m_isInterlacedFrameFlag : MOS_BITFIELD_BIT(3); uint32_t m_isTopFieldFirst : MOS_BITFIELD_BIT(4); uint32_t m_earlyImeSuccessEn : MOS_BITFIELD_BIT(5); uint32_t m_forceToSkip : MOS_BITFIELD_BIT(6); uint32_t m_t8x8FlagForInterEn : MOS_BITFIELD_BIT(7); uint32_t m_refPixOff : MOS_BITFIELD_RANGE(8,15); uint32_t m_reserved1 : MOS_BITFIELD_RANGE(16,23); uint32_t m_earlyImeStop : MOS_BITFIELD_RANGE(24,31); }; struct { uint32_t m_value; }; } DW0; union { struct { uint32_t m_maxNumMVs : MOS_BITFIELD_RANGE(0,5); uint32_t m_reserved0 : MOS_BITFIELD_RANGE(6,7); uint32_t m_refIDPolBits : MOS_BITFIELD_RANGE(8,15); uint32_t m_biWeight : MOS_BITFIELD_RANGE(16,21); uint32_t m_gxMask : MOS_BITFIELD_BIT(22); uint32_t m_gyMask : MOS_BITFIELD_BIT(23); uint32_t m_refPixShift : MOS_BITFIELD_RANGE(24,27); uint32_t m_uniMixDisable : MOS_BITFIELD_BIT(28); uint32_t m_refPixBiasEn : MOS_BITFIELD_BIT(29); // m_refPixBiasEn (MBZ) uint32_t m_idmShapeModeExt7x7 : MOS_BITFIELD_BIT(30); uint32_t m_idmShapeModeExt5x5 : MOS_BITFIELD_BIT(31); }; struct { uint32_t m_value; }; } DW1; union { struct { uint32_t m_maxLenSP : MOS_BITFIELD_RANGE(0,7); uint32_t m_maxNumSU : MOS_BITFIELD_RANGE(8,15); uint32_t m_start0X : MOS_BITFIELD_RANGE(16,19); uint32_t m_start0Y : MOS_BITFIELD_RANGE(20,23); uint32_t m_start1X : MOS_BITFIELD_RANGE(24,27); uint32_t m_start1Y : MOS_BITFIELD_RANGE(28,31); }; struct { uint32_t m_value; }; } DW2; union { struct { uint32_t m_fieldBias : MOS_BITFIELD_RANGE(0,7); uint32_t m_oppFieldBias : MOS_BITFIELD_RANGE(8,15); uint32_t m_fieldSkipThr : MOS_BITFIELD_RANGE(16,31); }; struct { uint32_t m_value; }; } DW3; union { struct { uint32_t m_reserved0 : MOS_BITFIELD_RANGE(0,7); uint32_t m_picHeightMinus1 : MOS_BITFIELD_RANGE(8,15); uint32_t m_picWidth : MOS_BITFIELD_RANGE(16,23); uint32_t m_reserved24 : MOS_BITFIELD_BIT(24); // WalkerType uint32_t m_motionSeeding : MOS_BITFIELD_BIT(25); uint32_t m_kernelMBModeDecision : MOS_BITFIELD_BIT(26); uint32_t m_iFrameMBDistortionDumpEnable : MOS_BITFIELD_BIT(27); uint32_t m_fieldFlag : MOS_BITFIELD_BIT(28); uint32_t m_pictureType : MOS_BITFIELD_RANGE(29,30); uint32_t m_reserved1 : MOS_BITFIELD_BIT(31); }; struct { uint32_t m_value; }; } DW4; struct { union { struct { uint32_t m_mv0Cost : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mv1Cost : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mv2Cost : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mv3Cost : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW5; union { struct { uint32_t m_mv4Cost : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mv5Cost : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mv6Cost : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mv7Cost : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW6; } MvCost; union { struct { uint32_t m_intraPartMask : MOS_BITFIELD_RANGE(0,4); uint32_t m_nonSkipZMvAdded : MOS_BITFIELD_BIT(5); uint32_t m_nonSkipModeAdded : MOS_BITFIELD_BIT(6); uint32_t m_reserved7 : MOS_BITFIELD_BIT(7); uint32_t m_reserved8 : MOS_BITFIELD_RANGE(8,15); uint32_t m_mvCostScaleFactor : MOS_BITFIELD_RANGE(16,17); uint32_t m_bilinearEnable : MOS_BITFIELD_BIT(18); uint32_t m_srcFieldPolarity : MOS_BITFIELD_BIT(19); uint32_t m_weightedSADHAAR : MOS_BITFIELD_BIT(20); uint32_t m_acOnlyHAAR : MOS_BITFIELD_BIT(21); uint32_t m_refIDCostMode : MOS_BITFIELD_BIT(22); uint32_t m_idmShapeMode : MOS_BITFIELD_BIT(23); uint32_t m_skipCenterMask : MOS_BITFIELD_RANGE(24,31); }; struct { uint32_t m_value; }; } DW7; union { struct { uint32_t m_mode8Cost : MOS_BITFIELD_RANGE(0,7); uint32_t m_mode9Cost : MOS_BITFIELD_RANGE(8,15); uint32_t m_refIDCost : MOS_BITFIELD_RANGE(16,23); uint32_t m_chromaIntraModeCost : MOS_BITFIELD_RANGE(24,31); }; struct { uint32_t m_value; }; } DW8; union { struct { uint32_t m_srcSize : MOS_BITFIELD_RANGE(0,1); uint32_t m_mbQPEnable : MOS_BITFIELD_BIT(2); uint32_t m_mbSkipEnable : MOS_BITFIELD_BIT(3); uint32_t m_mbNonSkipEnable : MOS_BITFIELD_BIT(4); uint32_t m_reserved5 : MOS_BITFIELD_BIT(5); uint32_t m_srcAccess : MOS_BITFIELD_BIT(6); uint32_t m_refAccess : MOS_BITFIELD_BIT(7); uint32_t m_searchCtrl : MOS_BITFIELD_RANGE(8,10); uint32_t m_dualSearchOpt : MOS_BITFIELD_BIT(11); uint32_t m_subPelMode : MOS_BITFIELD_RANGE(12,13); uint32_t m_skipType : MOS_BITFIELD_BIT(14); uint32_t m_fieldCacheAllocationDis : MOS_BITFIELD_BIT(15); uint32_t m_interChromaMode : MOS_BITFIELD_BIT(16); uint32_t m_ftEnable : MOS_BITFIELD_BIT(17); uint32_t m_bmeDisableFBR : MOS_BITFIELD_BIT(18); uint32_t m_reserved19 : MOS_BITFIELD_BIT(19); uint32_t m_interSAD : MOS_BITFIELD_RANGE(20,21); uint32_t m_intraSAD : MOS_BITFIELD_RANGE(22,23); uint32_t m_subMbPartMask : MOS_BITFIELD_RANGE(24,30); uint32_t m_reserved31 : MOS_BITFIELD_BIT(31); }; struct { uint32_t m_value; }; } DW9; union { struct { uint32_t m_dispatchID : MOS_BITFIELD_RANGE(0,7); uint32_t m_largeMbSizeInWord : MOS_BITFIELD_RANGE(8,15); uint32_t m_refWidth : MOS_BITFIELD_RANGE(16,23); uint32_t m_refHeight : MOS_BITFIELD_RANGE(24,31); }; struct { uint32_t m_value; }; } DW10; union { struct { uint32_t m_qpScaleCode : MOS_BITFIELD_RANGE(0,7); uint32_t m_intraFactor : MOS_BITFIELD_RANGE(8,11); uint32_t m_intraMulFact : MOS_BITFIELD_RANGE(12,15); uint32_t m_intraBiasFF : MOS_BITFIELD_RANGE(16,23); uint32_t m_intraBiasFrame : MOS_BITFIELD_RANGE(24,31); }; struct { uint32_t m_value; }; } DW11; union { struct { uint32_t m_isFastMode : MOS_BITFIELD_RANGE(0,7); uint32_t m_smallMbSizeInWord : MOS_BITFIELD_RANGE(8,15); uint32_t m_distScaleFactor : MOS_BITFIELD_RANGE(16,31); }; struct { uint32_t m_value; }; } DW12; union { struct { uint32_t m_panicModeMBThreshold : MOS_BITFIELD_RANGE(0,15); uint32_t m_targetSizeInWord : MOS_BITFIELD_RANGE(16,23); uint32_t m_reserved14 : MOS_BITFIELD_RANGE(24,31); }; struct { uint32_t m_value; }; } DW13; union { struct { uint32_t m_forwardHorizontalSearchRange : MOS_BITFIELD_RANGE(0,15); uint32_t m_forwardVerticalSearchRange : MOS_BITFIELD_RANGE(16,31); }; struct { uint32_t m_value; }; } DW14; union { struct { uint32_t m_backwardHorizontalSearchRange : MOS_BITFIELD_RANGE(0,15); uint32_t m_backwardVerticalSearchRange : MOS_BITFIELD_RANGE(16,31); }; struct { uint32_t m_value; }; } DW15; struct { union { struct { uint32_t m_meDelta0to3; }; struct { uint32_t m_value; }; } DW16; union { struct { uint32_t m_meDelta4to7; }; struct { uint32_t m_value; }; } DW17; union { struct { uint32_t m_meDelta8to11; }; struct { uint32_t m_value; }; } DW18; union { struct { uint32_t m_meDelta12to15; }; struct { uint32_t m_value; }; } DW19; union { struct { uint32_t m_meDelta16to19; }; struct { uint32_t m_value; }; } DW20; union { struct { uint32_t m_meDelta20to23; }; struct { uint32_t m_value; }; } DW21; union { struct { uint32_t m_meDelta24to27; }; struct { uint32_t m_value; }; } DW22; union { struct { uint32_t m_meDelta28to31; }; struct { uint32_t m_value; }; } DW23; union { struct { uint32_t m_meDelta32to35; }; struct { uint32_t m_value; }; } DW24; union { struct { uint32_t m_meDelta36to39; }; struct { uint32_t m_value; }; } DW25; union { struct { uint32_t m_meDelta40to43; }; struct { uint32_t m_value; }; } DW26; union { struct { uint32_t m_meDelta44to47; }; struct { uint32_t m_value; }; } DW27; union { struct { uint32_t m_meDelta48to51; }; struct { uint32_t m_value; }; } DW28; union { struct { uint32_t m_meDelta52to55; }; struct { uint32_t m_value; }; } DW29; union { struct { uint32_t m_mode0Cost : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mode1Cost : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mode2Cost : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mode3Cost : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW30; union { struct { uint32_t m_mode4Cost : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mode5Cost : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mode6Cost : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mode7Cost : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW31; } VmeSPath0; struct { union { struct { uint32_t m_meDelta0to3; }; struct { uint32_t m_value; }; } DW32; union { struct { uint32_t m_meDelta4to7; }; struct { uint32_t m_value; }; } DW33; union { struct { uint32_t m_meDelta8to11; }; struct { uint32_t m_value; }; } DW34; union { struct { uint32_t m_meDelta12to15; }; struct { uint32_t m_value; }; } DW35; union { struct { uint32_t m_meDelta16to19; }; struct { uint32_t m_value; }; } DW36; union { struct { uint32_t m_meDelta20to23; }; struct { uint32_t m_value; }; } DW37; union { struct { uint32_t m_meDelta24to27; }; struct { uint32_t m_value; }; } DW38; union { struct { uint32_t m_meDelta28to31; }; struct { uint32_t m_value; }; } DW39; union { struct { uint32_t m_meDelta32to35; }; struct { uint32_t m_value; }; } DW40; union { struct { uint32_t m_meDelta36to39; }; struct { uint32_t m_value; }; } DW41; union { struct { uint32_t m_meDelta40to43; }; struct { uint32_t m_value; }; } DW42; union { struct { uint32_t m_meDelta44to47; }; struct { uint32_t m_value; }; } DW43; union { struct { uint32_t m_meDelta48to51; }; struct { uint32_t m_value; }; } DW44; union { struct { uint32_t m_meDelta52to55; }; struct { uint32_t m_value; }; } DW45; struct { union { struct { uint32_t m_mv0Cost_Interlaced : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mv1Cost_Interlaced : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mv2Cost_Interlaced : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mv3Cost_Interlaced : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW46; union { struct { uint32_t m_mv4Cost_Interlaced : MOS_BITFIELD_RANGE(0, 7); uint32_t m_mv5Cost_Interlaced : MOS_BITFIELD_RANGE(8, 15); uint32_t m_mv6Cost_Interlaced : MOS_BITFIELD_RANGE(16, 23); uint32_t m_mv7Cost_Interlaced : MOS_BITFIELD_RANGE(24, 31); }; struct { uint32_t m_value; }; } DW47; } MvCostInterlace; } VmeSPath1; union { struct { uint32_t m_batchBufferEnd; }; struct { uint32_t m_value; }; } DW48; union { struct { uint32_t m_pakObjCmds; }; struct { uint32_t m_value; }; } DW49; union { struct { uint32_t m_prevmPakObjCmds; }; struct { uint32_t m_value; }; } DW50; union { struct { uint32_t m_currPicY; }; struct { uint32_t m_value; }; } DW51; union { struct { uint32_t m_currFwdBwdRef; }; struct { uint32_t m_value; }; } DW52; union { struct { uint32_t m_currBwdRef; }; struct { uint32_t m_value; }; } DW53; union { struct { uint32_t m_distSurf4x; }; struct { uint32_t m_value; }; } DW54; union { struct { uint32_t m_mbControl; }; struct { uint32_t m_value; }; } DW55; }m_curbeData; //! //! \brief Constructor //! MbEncCurbeG9(uint8_t codingType); //! //! \brief Destructor //! ~MbEncCurbeG9(){}; static const size_t m_byteSize = sizeof(CurbeData); }; MeCurbeG9::MeCurbeG9() { CODECHAL_ENCODE_FUNCTION_ENTER; MOS_ZeroMemory(&m_curbeData, m_byteSize); m_curbeData.DW0.m_value = 0x00000000; m_curbeData.DW1.m_value = 0x00200010; m_curbeData.DW2.m_value = 0x00003939; m_curbeData.DW3.m_value = 0x77a43000; m_curbeData.DW4.m_value = 0x00000000; m_curbeData.DW5.m_value = 0x28300000; m_curbeData.DW32.m_value = 0xffffffff; m_curbeData.DW33.m_value = 0xffffffff; m_curbeData.DW34.m_value = 0xffffffff; m_curbeData.DW35.m_value = 0xffffffff; m_curbeData.DW36.m_value = 0xffffffff; m_curbeData.DW37.m_value = 0xffffffff; m_curbeData.DW38.m_value = 0xffffffff; } MbEncCurbeG9::MbEncCurbeG9(uint8_t codingType) { CODECHAL_ENCODE_FUNCTION_ENTER; MOS_ZeroMemory(&m_curbeData, m_byteSize); m_curbeData.DW0.m_value = 0x00000023; switch (codingType) { case I_TYPE: m_curbeData.DW1.m_value = 0x00200020; m_curbeData.DW2.m_value = 0x00000000; m_curbeData.DW4.m_value = 0x00000000; m_curbeData.DW7.m_value = 0x00050066; m_curbeData.DW8.m_value = 0x00000000; m_curbeData.DW9.m_value = 0x7EA41000; m_curbeData.DW10.m_value = 0x0000FF00; break; case P_TYPE: m_curbeData.DW1.m_value = 0x00200020; m_curbeData.DW2.m_value = 0x00001009; m_curbeData.DW4.m_value = 0x20000000; m_curbeData.DW7.m_value = 0x00050066; m_curbeData.DW8.m_value = 0x00000041; m_curbeData.DW9.m_value = 0x7EA41000; m_curbeData.DW10.m_value = 0x2830FF00; break; case B_TYPE: default: m_curbeData.DW1.m_value = 0x10200010; m_curbeData.DW2.m_value = 0x00001005; m_curbeData.DW4.m_value = 0x40000000; m_curbeData.DW7.m_value = 0xFF050066; m_curbeData.DW8.m_value = 0x00000041; m_curbeData.DW9.m_value = 0x7EA01000; m_curbeData.DW10.m_value = 0x2020FF00; break; } m_curbeData.DW3.m_value = 0xFE0C0000; m_curbeData.MvCost.DW5.m_value = 0x00000000; m_curbeData.MvCost.DW6.m_value = 0x00000000; m_curbeData.DW11.m_value = 0x5A325300; m_curbeData.DW12.m_value = 0x0000FF00; m_curbeData.DW13.m_value = 0x00FF0000; } CodechalEncodeMpeg2G9::CodechalEncodeMpeg2G9( CodechalHwInterface* hwInterface, CodechalDebugInterface* debugInterface, PCODECHAL_STANDARD_INFO standardInfo) :CodechalEncodeMpeg2(hwInterface, debugInterface, standardInfo) { CODECHAL_ENCODE_FUNCTION_ENTER; pfnGetKernelHeaderAndSize = GetKernelHeaderAndSize; m_rawSurfAlignment = MHW_VDBOX_MFX_RAW_UV_PLANE_ALIGNMENT_GEN9; MOS_STATUS eStatus = CodecHal_GetKernelBinaryAndSize( (uint8_t *)IGCODECKRN_G9, m_kuid, &m_kernelBinary, &m_combinedKernelSize); CODECHAL_ENCODE_ASSERT(eStatus == MOS_STATUS_SUCCESS); m_hwInterface->GetStateHeapSettings()->dwIshSize += MOS_ALIGN_CEIL(m_combinedKernelSize, (1 << MHW_KERNEL_OFFSET_SHIFT)); m_needCheckCpEnabled = true; } MOS_STATUS CodechalEncodeMpeg2G9::Initialize(PCODECHAL_SETTINGS codecHalSettings) { MOS_STATUS eStatus = MOS_STATUS_SUCCESS; CODECHAL_ENCODE_FUNCTION_ENTER; // common initilization CODECHAL_ENCODE_CHK_STATUS_RETURN(CodechalEncodeMpeg2::Initialize(codecHalSettings)); return eStatus; } MOS_STATUS CodechalEncodeMpeg2G9::GetKernelHeaderAndSize( void *binary, EncOperation operation, uint32_t krnStateIdx, void *krnHeader, uint32_t *krnSize) { MOS_STATUS eStatus = MOS_STATUS_SUCCESS; CODECHAL_ENCODE_FUNCTION_ENTER; CODECHAL_ENCODE_CHK_NULL_RETURN(binary); CODECHAL_ENCODE_CHK_NULL_RETURN(krnHeader); CODECHAL_ENCODE_CHK_NULL_RETURN(krnSize); auto kernelHeaderTable = (KernelHeader *)binary; PCODECHAL_KERNEL_HEADER currKrnHeader; if (operation == ENC_SCALING4X) { currKrnHeader = &kernelHeaderTable->m_plyDscalePly; } else if (operation == ENC_ME) { currKrnHeader = &kernelHeaderTable->m_mpeg2AvcMeP; } else if (operation == ENC_BRC) { currKrnHeader = &kernelHeaderTable->m_mpeg2InitFrameBrc; } else if (operation == ENC_MBENC) { currKrnHeader = &kernelHeaderTable->m_mpeg2MbEncI; } else { CODECHAL_ENCODE_ASSERTMESSAGE("Unsupported ENC mode requested"); eStatus = MOS_STATUS_INVALID_PARAMETER; return eStatus; } currKrnHeader += krnStateIdx; *((PCODECHAL_KERNEL_HEADER)krnHeader) = *currKrnHeader; PCODECHAL_KERNEL_HEADER invalidEntry = &(kernelHeaderTable->m_mpeg2BrcResetFrame) + 1; PCODECHAL_KERNEL_HEADER nextKrnHeader = (currKrnHeader + 1); uint32_t nextKrnOffset = *krnSize; if (nextKrnHeader < invalidEntry) { nextKrnOffset = nextKrnHeader->KernelStartPointer << MHW_KERNEL_OFFSET_SHIFT; } *krnSize = nextKrnOffset - (currKrnHeader->KernelStartPointer << MHW_KERNEL_OFFSET_SHIFT); return eStatus; } MOS_STATUS CodechalEncodeMpeg2G9::InitKernelState() { MOS_STATUS eStatus = MOS_STATUS_SUCCESS; CODECHAL_ENCODE_FUNCTION_ENTER; // Init kernel state CODECHAL_ENCODE_CHK_STATUS_RETURN(InitKernelStateMe()); CODECHAL_ENCODE_CHK_STATUS_RETURN(InitKernelStateMbEnc()); CODECHAL_ENCODE_CHK_STATUS_RETURN(InitKernelStateBrc()); return eStatus; } MOS_STATUS CodechalEncodeMpeg2G9::InitKernelStateMe() { MOS_STATUS eStatus = MOS_STATUS_SUCCESS; CODECHAL_ENCODE_FUNCTION_ENTER; for (uint8_t krnStateIdx = 0; krnStateIdx < 2; krnStateIdx++) { auto kernelStatePtr = &m_meKernelStates[krnStateIdx]; auto kernelSize = m_combinedKernelSize; CODECHAL_KERNEL_HEADER currKrnHeader; CODECHAL_ENCODE_CHK_STATUS_RETURN(pfnGetKernelHeaderAndSize( m_kernelBinary, ENC_ME, krnStateIdx, &currKrnHeader, &kernelSize)); kernelStatePtr->KernelParams.iBTCount = meNumSurface; kernelStatePtr->KernelParams.iThreadCount = m_hwInterface->GetRenderInterface()->GetHwCaps()->dwMaxThreads; kernelStatePtr->KernelParams.iCurbeLength = MeCurbeG9::m_byteSize; kernelStatePtr->KernelParams.iBlockWidth = CODECHAL_MACROBLOCK_WIDTH; kernelStatePtr->KernelParams.iBlockHeight = CODECHAL_MACROBLOCK_HEIGHT; kernelStatePtr->KernelParams.iIdCount = 1; kernelStatePtr->dwCurbeOffset = m_stateHeapInterface->pStateHeapInterface->GetSizeofCmdInterfaceDescriptorData(); kernelStatePtr->KernelParams.pBinary = m_kernelBinary + (currKrnHeader.KernelStartPointer << MHW_KERNEL_OFFSET_SHIFT); kernelStatePtr->KernelParams.iSize = kernelSize; CODECHAL_ENCODE_CHK_STATUS_RETURN(m_stateHeapInterface->pfnCalculateSshAndBtSizesRequested( m_stateHeapInterface, kernelStatePtr->KernelParams.iBTCount, &kernelStatePtr->dwSshSize, &kernelStatePtr->dwBindingTableSize)); CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHal_MhwInitISH(m_stateHeapInterface, kernelStatePtr)); } // Until a better way can be found, maintain old binding table structures auto meBindingTable = &m_meBindingTable; // Mpeg2 uses AVC ME Kernel for P/B distortion calculation meBindingTable->dwMEMVDataSurface = meMvDataSurface; meBindingTable->dwMECurrForFwdRef = meCurrForFwdRef; meBindingTable->dwMECurrForBwdRef = meCurrForBwdRef; meBindingTable->dwMEDist = meDistortionSurface; meBindingTable->dwMEBRCDist = meBrcDistortion; meBindingTable->dwMEFwdRefPicIdx[0] = meFwdRefIdx0; meBindingTable->dwMEFwdRefPicIdx[1] = CODECHAL_INVALID_BINDING_TABLE_IDX; meBindingTable->dwMEFwdRefPicIdx[2] = CODECHAL_INVALID_BINDING_TABLE_IDX; meBindingTable->dwMEFwdRefPicIdx[3] = CODECHAL_INVALID_BINDING_TABLE_IDX; meBindingTable->dwMEFwdRefPicIdx[4] = CODECHAL_INVALID_BINDING_TABLE_IDX; meBindingTable->dwMEFwdRefPicIdx[5] = CODECHAL_INVALID_BINDING_TABLE_IDX; meBindingTable->dwMEFwdRefPicIdx[6] = CODECHAL_INVALID_BINDING_TABLE_IDX; meBindingTable->dwMEFwdRefPicIdx[7] = CODECHAL_INVALID_BINDING_TABLE_IDX; meBindingTable->dwMEBwdRefPicIdx[0] = meBwdRefIdx0; meBindingTable->dwMEBwdRefPicIdx[1] = CODECHAL_INVALID_BINDING_TABLE_IDX; return eStatus; } MOS_STATUS CodechalEncodeMpeg2G9::InitKernelStateMbEnc() { MOS_STATUS eStatus = MOS_STATUS_SUCCESS; CODECHAL_ENCODE_FUNCTION_ENTER; for (uint8_t krnStateIdx = 0; krnStateIdx < mbEncKernelIdxNum; krnStateIdx++) { auto kernelStatePtr = &m_mbEncKernelStates[krnStateIdx]; auto kernelSize = m_combinedKernelSize; CODECHAL_KERNEL_HEADER currKrnHeader; CODECHAL_ENCODE_CHK_STATUS_RETURN(pfnGetKernelHeaderAndSize( m_kernelBinary, ENC_MBENC, krnStateIdx, &currKrnHeader, &kernelSize)); kernelStatePtr->KernelParams.iBTCount = mbEncNumBindingTableEntries; kernelStatePtr->KernelParams.iThreadCount = m_hwInterface->GetRenderInterface()->GetHwCaps()->dwMaxThreads; kernelStatePtr->KernelParams.iCurbeLength = MbEncCurbeG9::m_byteSize; kernelStatePtr->KernelParams.iBlockWidth = CODECHAL_MACROBLOCK_WIDTH; kernelStatePtr->KernelParams.iBlockHeight = CODECHAL_MACROBLOCK_HEIGHT; kernelStatePtr->KernelParams.iIdCount = 1; kernelStatePtr->dwCurbeOffset = m_stateHeapInterface->pStateHeapInterface->GetSizeofCmdInterfaceDescriptorData(); kernelStatePtr->KernelParams.pBinary = m_kernelBinary + (currKrnHeader.KernelStartPointer << MHW_KERNEL_OFFSET_SHIFT); kernelStatePtr->KernelParams.iSize = kernelSize; CODECHAL_ENCODE_CHK_STATUS_RETURN(m_stateHeapInterface->pfnCalculateSshAndBtSizesRequested( m_stateHeapInterface, kernelStatePtr->KernelParams.iBTCount, &kernelStatePtr->dwSshSize, &kernelStatePtr->dwBindingTableSize)); CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHal_MhwInitISH(m_stateHeapInterface, kernelStatePtr)); } m_mbEncBindingTable.m_mbEncPakObj = mbEncPakObj; m_mbEncBindingTable.m_mbEncPakObjPrev = mbEncPakObjPrev; m_mbEncBindingTable.m_mbEncCurrentY = mbEncCurrentY; m_mbEncBindingTable.m_mbEncBrcDistortionSurface = mbEncBrcDistortionSurface; m_mbEncBindingTable.m_mbEncCurrentPic = mbEncCurrentPic; m_mbEncBindingTable.m_mbEncForwardPic = mbEncForwardPic; m_mbEncBindingTable.m_mbEncBackwardPic = mbEncBackwardPic; m_mbEncBindingTable.m_mbEncInterlaceFrameCurrentPic = mbEncInterlaceFrameCurrentPic; m_mbEncBindingTable.m_mbEncInterlaceFrameBackwardPic = mbEncInterlaceFrameBackwardPic; m_mbEncBindingTable.m_mbEncMbControl = mbEncMbControl; return eStatus; } MOS_STATUS CodechalEncodeMpeg2G9::SetCurbeMe() { MOS_STATUS eStatus = MOS_STATUS_SUCCESS; CODECHAL_ENCODE_FUNCTION_ENTER; MeCurbeG9 cmd; // r1 cmd.m_curbeData.DW3.m_subPelMode = 3; if (m_fieldScalingOutputInterleaved) { cmd.m_curbeData.DW3.m_srcAccess = cmd.m_curbeData.DW3.m_refAccess = CodecHal_PictureIsField(m_picParams->m_currOriginalPic) ? 1 : 0; cmd.m_curbeData.DW7.m_srcFieldPolarity = CodecHal_PictureIsBottomField(m_picParams->m_currOriginalPic) ? 1 : 0; } uint32_t scaleFactor = 4; // Scale factor always 4x, SHME/UHME not supported cmd.m_curbeData.DW4.m_pictureHeightMinus1 = CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_frameFieldHeight / scaleFactor) - 1; cmd.m_curbeData.DW4.m_pictureWidth = CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_frameWidth / scaleFactor); cmd.m_curbeData.DW5.m_qpPrimeY = m_mvCostTableOffset; cmd.m_curbeData.DW6.m_meModes = CODECHAL_ENCODE_ME4X_ONLY; cmd.m_curbeData.DW6.m_superCombineDist = m_superCombineDistGeneric[m_seqParams->m_targetUsage]; cmd.m_curbeData.DW6.m_maxVmvR = m_maxVmvr; if (!CodecHal_PictureIsFrame(m_picParams->m_currOriginalPic)) { cmd.m_curbeData.DW6.m_maxVmvR = cmd.m_curbeData.DW6.m_maxVmvR >> 1; } if (m_pictureCodingType == B_TYPE) { // This field is irrelevant since we are not using the bi-direct search. // set it to 32 cmd.m_curbeData.DW1.m_biWeight = 32; cmd.m_curbeData.DW13.m_numRefIdxL1MinusOne = 0; // always 0 for MPEG2 } if (m_pictureCodingType == P_TYPE || m_pictureCodingType == B_TYPE) { cmd.m_curbeData.DW13.m_numRefIdxL0MinusOne = 0; // always 0 for MPEG2 } // r3 & r4 uint8_t meMethod = (m_pictureCodingType == B_TYPE) ? m_BMeMethodGeneric[m_seqParams->m_targetUsage] : m_MeMethodGeneric[m_seqParams->m_targetUsage]; uint8_t tableIdx = (m_pictureCodingType == B_TYPE) ? 1 : 0; CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( &(cmd.m_curbeData.SpDelta), 14 * sizeof(uint32_t), CodechalEncoderState::m_encodeSearchPath[tableIdx][meMethod], 14 * sizeof(uint32_t))); // r5 cmd.m_curbeData.DW32.m_4xMeMvOutputDataSurfIndex = m_meBindingTable.dwMEMVDataSurface ; cmd.m_curbeData.DW34.m_4xMeOutputDistSurfIndex = m_meBindingTable.dwMEDist; cmd.m_curbeData.DW35.m_4xMeOutputBrcDistSurfIndex = m_meBindingTable.dwMEBRCDist; cmd.m_curbeData.DW36.m_vmeFwdInterPredictionSurfIndex = m_meBindingTable.dwMECurrForFwdRef; cmd.m_curbeData.DW37.m_vmeBwdInterPredictionSurfIndex = m_meBindingTable.dwMECurrForBwdRef; uint32_t krnStateIdx = (m_pictureCodingType == P_TYPE) ? CODECHAL_ENCODE_ME_IDX_P : CODECHAL_ENCODE_ME_IDX_B; auto kernelState = &m_meKernelStates[krnStateIdx]; CODECHAL_ENCODE_CHK_STATUS_RETURN(kernelState->m_dshRegion.AddData( &cmd, kernelState->dwCurbeOffset, cmd.m_byteSize)); return eStatus; } MOS_STATUS CodechalEncodeMpeg2G9::SendMeSurfaces( PMOS_COMMAND_BUFFER cmdBuffer) { MOS_STATUS eStatus = MOS_STATUS_SUCCESS; CODECHAL_ENCODE_CHK_NULL_RETURN(cmdBuffer); auto meBindingTable = &m_meBindingTable; auto scaledIdx = m_refList[m_currReconstructedPic.FrameIdx]->ucScalingIdx; PMOS_SURFACE currScaledSurface = &m_trackedBuffer[scaledIdx].sScaled4xSurface; PMOS_SURFACE meMvDataBuffer = &m_4xMEMVDataBuffer; // Reference height and width information should be taken from the current scaled surface rather // than from the reference scaled surface in the case of PAFF. auto bufWidth = MOS_ALIGN_CEIL(m_downscaledWidthInMb4x * 32, 64); auto bufHeight = m_downscaledHeightInMb4x * 4 * CODECHAL_ENCODE_ME_DATA_SIZE_MULTIPLIER; // Force the values meMvDataBuffer->dwWidth = bufWidth; meMvDataBuffer->dwHeight = bufHeight; meMvDataBuffer->dwPitch = bufWidth; uint32_t krnStateIdx = (m_pictureCodingType == P_TYPE) ? CODECHAL_ENCODE_ME_IDX_P : CODECHAL_ENCODE_ME_IDX_B; auto kernelState = &m_meKernelStates[krnStateIdx]; CODECHAL_SURFACE_CODEC_PARAMS surfaceParams; MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); surfaceParams.bIs2DSurface = true; surfaceParams.bMediaBlockRW = true; surfaceParams.psSurface = meMvDataBuffer; surfaceParams.dwOffset = m_memvBottomFieldOffset; surfaceParams.dwCacheabilityControl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_MV_DATA_ENCODE].Value; surfaceParams.dwBindingTableOffset = meBindingTable->dwMEMVDataSurface; surfaceParams.bIsWritable = true; surfaceParams.bRenderTarget = true; CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHal_SetRcsSurfaceState( m_hwInterface, cmdBuffer, &surfaceParams, kernelState)); // Insert Distortion buffers only for 4xMe case MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); surfaceParams.bIs2DSurface = true; surfaceParams.bMediaBlockRW = true; surfaceParams.psSurface = &m_brcBuffers.sMeBrcDistortionBuffer; surfaceParams.dwOffset = m_brcBuffers.dwMeBrcDistortionBottomFieldOffset; surfaceParams.dwBindingTableOffset = meBindingTable->dwMEBRCDist; surfaceParams.dwCacheabilityControl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_BRC_ME_DISTORTION_ENCODE].Value; surfaceParams.bIsWritable = true; surfaceParams.bRenderTarget = true; CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHal_SetRcsSurfaceState( m_hwInterface, cmdBuffer, &surfaceParams, kernelState)); MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); surfaceParams.bIs2DSurface = true; surfaceParams.bMediaBlockRW = true; surfaceParams.psSurface = &m_4xMEDistortionBuffer; surfaceParams.dwOffset = m_meDistortionBottomFieldOffset; surfaceParams.dwBindingTableOffset = meBindingTable->dwMEDist; surfaceParams.dwCacheabilityControl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ME_DISTORTION_ENCODE].Value; surfaceParams.bIsWritable = true; surfaceParams.bRenderTarget = true; CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHal_SetRcsSurfaceState( m_hwInterface, cmdBuffer, &surfaceParams, kernelState)); bool currFieldPicture = CodecHal_PictureIsField(m_currOriginalPic) ? 1 : 0; bool currBottomField = CodecHal_PictureIsBottomField(m_currOriginalPic) ? 1 : 0; uint8_t currVDirection = (!currFieldPicture) ? CODECHAL_VDIRECTION_FRAME : ((currBottomField) ? CODECHAL_VDIRECTION_BOT_FIELD : CODECHAL_VDIRECTION_TOP_FIELD); uint32_t refScaledBottomFieldOffset = 0; auto refScaledSurface = *currScaledSurface; // Setup references 1...n // LIST 0 references CODEC_PICTURE refPic = m_picParams->m_refFrameList[0]; // no need to modify index if picture is invalid if (refPic.PicFlags != PICTURE_INVALID) { refPic.FrameIdx = 0; } if (!CodecHal_PictureIsInvalid(refPic) && m_picIdx[refPic.FrameIdx].bValid) { // Current Picture Y - VME MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); surfaceParams.bUseAdvState = true; surfaceParams.psSurface = currScaledSurface; surfaceParams.dwOffset = currBottomField ? (uint32_t)m_scaledBottomFieldOffset : 0; surfaceParams.dwCacheabilityControl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_CURR_ENCODE].Value; surfaceParams.dwBindingTableOffset = meBindingTable->dwMECurrForFwdRef; surfaceParams.ucVDirection = currVDirection; CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHal_SetRcsSurfaceState( m_hwInterface, cmdBuffer, &surfaceParams, kernelState)); bool refBottomField = (CodecHal_PictureIsBottomField(refPic)) ? 1 : 0; uint8_t refPicIdx = m_picIdx[refPic.FrameIdx].ucPicIdx; scaledIdx = m_refList[refPicIdx]->ucScalingIdx; // for 4xMe refScaledSurface.OsResource = m_trackedBuffer[scaledIdx].sScaled4xSurface.OsResource; refScaledBottomFieldOffset = refBottomField ? (uint32_t)m_scaledBottomFieldOffset : 0; // L0 Reference Picture Y - VME MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); surfaceParams.bUseAdvState = true; surfaceParams.psSurface = &refScaledSurface; surfaceParams.dwOffset = refBottomField ? refScaledBottomFieldOffset : 0; surfaceParams.dwCacheabilityControl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_REF_ENCODE].Value; surfaceParams.dwBindingTableOffset = meBindingTable->dwMEFwdRefPicIdx[0]; surfaceParams.ucVDirection = !currFieldPicture ? CODECHAL_VDIRECTION_FRAME : ((refBottomField) ? CODECHAL_VDIRECTION_BOT_FIELD : CODECHAL_VDIRECTION_TOP_FIELD); CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHal_SetRcsSurfaceState( m_hwInterface, cmdBuffer, &surfaceParams, kernelState)); } // Setup references 1...n // LIST 1 references refPic = m_picParams->m_refFrameList[1]; // no need to modify index if picture is invalid if (refPic.PicFlags != PICTURE_INVALID) { refPic.FrameIdx = 1; } if (!CodecHal_PictureIsInvalid(refPic) && m_picIdx[refPic.FrameIdx].bValid) { // Current Picture Y - VME MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); surfaceParams.bUseAdvState = true; surfaceParams.psSurface = currScaledSurface; surfaceParams.dwOffset = currBottomField ? (uint32_t)m_scaledBottomFieldOffset : 0; surfaceParams.dwCacheabilityControl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_CURR_ENCODE].Value; surfaceParams.dwBindingTableOffset = meBindingTable->dwMECurrForBwdRef; surfaceParams.ucVDirection = currVDirection; CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHal_SetRcsSurfaceState( m_hwInterface, cmdBuffer, &surfaceParams, kernelState)); bool refBottomField = (CodecHal_PictureIsBottomField(refPic)) ? 1 : 0; uint8_t refPicIdx = m_picIdx[refPic.FrameIdx].ucPicIdx; scaledIdx = m_refList[refPicIdx]->ucScalingIdx; // for 4xMe refScaledSurface.OsResource = m_trackedBuffer[scaledIdx].sScaled4xSurface.OsResource; refScaledBottomFieldOffset = refBottomField ? (uint32_t)m_scaledBottomFieldOffset : 0; // L1 Reference Picture Y - VME MOS_ZeroMemory(&surfaceParams, sizeof(surfaceParams)); surfaceParams.bUseAdvState = true; surfaceParams.psSurface = &refScaledSurface; surfaceParams.dwOffset = refBottomField ? refScaledBottomFieldOffset : 0; surfaceParams.dwCacheabilityControl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_REF_ENCODE].Value; surfaceParams.dwBindingTableOffset = meBindingTable->dwMEBwdRefPicIdx[0]; surfaceParams.ucVDirection = (!currFieldPicture) ? CODECHAL_VDIRECTION_FRAME : ((refBottomField) ? CODECHAL_VDIRECTION_BOT_FIELD : CODECHAL_VDIRECTION_TOP_FIELD); CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHal_SetRcsSurfaceState( m_hwInterface, cmdBuffer, &surfaceParams, kernelState)); } return eStatus; } MOS_STATUS CodechalEncodeMpeg2G9::SetCurbeMbEnc( bool mbEncIFrameDistEnabled, bool mbQpDataEnabled) { MOS_STATUS eStatus = MOS_STATUS_SUCCESS; CODECHAL_ENCODE_FUNCTION_ENTER; uint16_t picWidthInMb = mbEncIFrameDistEnabled ? (uint16_t)m_downscaledWidthInMb4x : m_picWidthInMb; uint16_t fieldFrameHeightInMb = mbEncIFrameDistEnabled ? (uint16_t)m_downscaledFrameFieldHeightInMb4x : m_frameFieldHeightInMb; MbEncCurbeG9 cmd(m_picParams->m_pictureCodingType); // Set CURBE data as per cmd.m_curbeData.DW0.m_isInterlacedFrameFlag = (CodecHal_PictureIsFrame(m_picParams->m_currOriginalPic)) ? (m_picParams->m_fieldCodingFlag || m_picParams->m_fieldFrameCodingFlag) : 0; cmd.m_curbeData.DW0.m_isTopFieldFirst = cmd.m_curbeData.DW0.m_isInterlacedFrameFlag ? !m_picParams->m_interleavedFieldBFF : 0; cmd.m_curbeData.DW0.m_forceToSkip = 0; cmd.m_curbeData.DW4.m_pictureType = m_picParams->m_pictureCodingType; cmd.m_curbeData.DW4.m_fieldFlag = (CodecHal_PictureIsFrame(m_picParams->m_currOriginalPic)) ? 0 : 1; cmd.m_curbeData.DW4.m_picWidth = picWidthInMb; cmd.m_curbeData.DW4.m_picHeightMinus1 = fieldFrameHeightInMb - 1; cmd.m_curbeData.DW7.m_bilinearEnable = 1; cmd.m_curbeData.DW7.m_mvCostScaleFactor = 1; // half-pel cmd.m_curbeData.DW7.m_idmShapeMode = 0; cmd.m_curbeData.DW9.m_srcAccess = cmd.m_curbeData.DW9.m_refAccess = 0; cmd.m_curbeData.DW9.m_fieldCacheAllocationDis = 0; // This is approximation using first slice // MPEG2 quantiser_scale_code legal range is [1, 31] inclusive if (m_sliceParams->m_quantiserScaleCode < 1) { m_sliceParams->m_quantiserScaleCode = 1; } else if (m_sliceParams->m_quantiserScaleCode > 31) { m_sliceParams->m_quantiserScaleCode = 31; } cmd.m_curbeData.DW9.m_mbQPEnable = mbQpDataEnabled; cmd.m_curbeData.DW11.m_qpScaleCode = m_sliceParams->m_quantiserScaleCode; cmd.m_curbeData.DW2.m_maxNumSU = 0x10; cmd.m_curbeData.DW12.m_isFastMode = 0; if (m_seqParams ->m_rateControlMethod == RATECONTROL_CQP) { cmd.m_curbeData.DW13.m_panicModeMBThreshold = 0xFFFF; } cmd.m_curbeData.DW14.m_forwardHorizontalSearchRange = 4 << m_picParams->m_fcode00; cmd.m_curbeData.DW14.m_forwardVerticalSearchRange = 4 << m_picParams->m_fcode01; cmd.m_curbeData.DW15.m_backwardHorizontalSearchRange = 4 << m_picParams->m_fcode10; cmd.m_curbeData.DW15.m_backwardVerticalSearchRange = 4 << m_picParams->m_fcode11; if (m_picParams->m_pictureCodingType == I_TYPE) { cmd.m_curbeData.DW2.m_value = 0; cmd.m_curbeData.DW4.m_pictureType = 0; cmd.m_curbeData.DW9.m_intraSAD = 0x2; // Modify CURBE for distortion calculation. if (mbEncIFrameDistEnabled) { cmd.m_curbeData.DW4.m_iFrameMBDistortionDumpEnable = true; } else { // Make sure the distortion dump flag is disabled for the normal MBEnc case. // No need to reset the height and width since they are set // correctly above this if-else and not modified after. cmd.m_curbeData.DW4.m_iFrameMBDistortionDumpEnable = false; } } else if (m_picParams->m_pictureCodingType == P_TYPE) { cmd.m_curbeData.DW1.m_uniMixDisable = 0; cmd.m_curbeData.DW1.m_biWeight = 32; cmd.m_curbeData.DW2.m_maxLenSP = 0x09; cmd.m_curbeData.DW4.m_pictureType = 1; cmd.m_curbeData.DW9.m_interSAD = 2; cmd.m_curbeData.DW9.m_intraSAD = 2; cmd.m_curbeData.DW9.m_searchCtrl = 0; cmd.m_curbeData.DW9.m_subPelMode = 1; cmd.m_curbeData.DW9.m_skipType = 0; cmd.m_curbeData.DW9.m_subMbPartMask = 0x7E; cmd.m_curbeData.DW10.m_refWidth = 48; cmd.m_curbeData.DW10.m_refHeight = 40; cmd.m_curbeData.DW12.m_distScaleFactor = 0; cmd.m_curbeData.DW7.m_skipCenterMask = 0x55; //Motion vector cost is taken from VME_LUTXY CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( &(cmd.m_curbeData.MvCost), sizeof(uint32_t)* 2, m_vmeLutXyP, sizeof(uint32_t)* 2)); //VME_SEARCH_PATH CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( &(cmd.m_curbeData.VmeSPath0), sizeof(uint32_t)* 16, m_vmeSPathP0, sizeof(uint32_t)* 16)); CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( &(cmd.m_curbeData.VmeSPath1), sizeof(uint32_t)* 16, m_vmeSPathP1, sizeof(uint32_t)* 16)); //Interlaced motion vector cost is the same as progressive P frame CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( &(cmd.m_curbeData.VmeSPath1.MvCostInterlace), sizeof(uint32_t)* 2, m_vmeLutXyP, sizeof(uint32_t)* 2)); } else// B_TYPE { cmd.m_curbeData.DW1.m_biWeight = 32; cmd.m_curbeData.DW1.m_refPixShift = 0; cmd.m_curbeData.DW2.m_maxLenSP = 0x05; cmd.m_curbeData.DW4.m_pictureType = 2; cmd.m_curbeData.DW9.m_subMbPartMask = 0x7E; cmd.m_curbeData.DW9.m_subPelMode = 1; cmd.m_curbeData.DW9.m_skipType = 0; cmd.m_curbeData.DW9.m_searchCtrl = 7; cmd.m_curbeData.DW9.m_interSAD = 2; cmd.m_curbeData.DW9.m_intraSAD = 2; cmd.m_curbeData.DW10.m_refWidth = 32; cmd.m_curbeData.DW10.m_refHeight = 32; cmd.m_curbeData.DW7.m_skipCenterMask = 0xFF; switch (m_picParams->m_gopRefDist) { case 3: cmd.m_curbeData.DW12.m_distScaleFactor = (m_bFrameNum > 1) ? 43 : 21; break; case 4: cmd.m_curbeData.DW12.m_distScaleFactor = (m_bFrameNum << 4); break; default: cmd.m_curbeData.DW12.m_distScaleFactor = 32; break; } //Motion vector cost is taken from VME_LUTXY CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( &(cmd.m_curbeData.MvCost), sizeof(uint32_t)* 2, m_vmeLutXyB, sizeof(uint32_t)* 2)); //VME_SEARCH_PATH CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( &(cmd.m_curbeData.VmeSPath0), sizeof(uint32_t)* 16, m_vmeSPathB0, sizeof(uint32_t)* 16)); CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( &(cmd.m_curbeData.VmeSPath1), sizeof(uint32_t)* 16, m_vmeSPathB1, sizeof(uint32_t)* 16)); //Interlaced motion vector cost is the same as progressive P frame CODECHAL_ENCODE_CHK_STATUS_RETURN(MOS_SecureMemcpy( &(cmd.m_curbeData.VmeSPath1.MvCostInterlace), sizeof(uint32_t)* 2, m_vmeLutXyP, sizeof(uint32_t)* 2)); } //ModeCost for P/B pictures if (m_picParams->m_pictureCodingType != I_TYPE) { cmd.m_curbeData.VmeSPath0.DW30.m_value = 0x83; // Setting mode 0 cost to 0x83 (131) cmd.m_curbeData.VmeSPath0.DW31.m_value = 0x41414141; // Set mode 4, 5, 6, 7 costs to 0x41 (67) cmd.m_curbeData.DW8.m_mode8Cost = 0x41; } cmd.m_curbeData.DW48.m_value = 0x05000000; // BB-End Command cmd.m_curbeData.DW49.m_value = m_mbEncBindingTable.m_mbEncPakObj; cmd.m_curbeData.DW50.m_value = m_mbEncBindingTable.m_mbEncPakObjPrev; cmd.m_curbeData.DW51.m_value = m_mbEncBindingTable.m_mbEncCurrentY; cmd.m_curbeData.DW52.m_value = m_mbEncBindingTable.m_mbEncCurrentPic; // Also FWD REF & BWD REF too, +1, +2 respectively cmd.m_curbeData.DW53.m_value = m_mbEncBindingTable.m_mbEncInterlaceFrameCurrentPic; // Also Int BWD Ref (+1) cmd.m_curbeData.DW54.m_value = m_mbEncBindingTable.m_mbEncBrcDistortionSurface; cmd.m_curbeData.DW55.m_value = m_mbEncBindingTable.m_mbEncMbControl; PMHW_KERNEL_STATE kernelState; // Initialize DSH kernel region if (mbEncIFrameDistEnabled) { kernelState = &m_brcKernelStates[CODECHAL_ENCODE_BRC_IDX_IFRAMEDIST]; } else { // wPictureCodingType: I_TYPE = 1, P_TYPE = 2, B_TYPE = 3 // KernelStates are I: 0, P: 1, B: 2 // m_mbEncKernelStates: I: m_mbEncKernelStates[0], P: m_mbEncKernelStates[1], B: m_mbEncKernelStates[2] uint32_t krnStateIdx = m_pictureCodingType - 1; kernelState = &m_mbEncKernelStates[krnStateIdx]; } CODECHAL_ENCODE_CHK_STATUS_RETURN(kernelState->m_dshRegion.AddData( &cmd, kernelState->dwCurbeOffset, cmd.m_byteSize)); return eStatus; }
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php. ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; ReadMm2.Asm ; ; Abstract: ; ; AsmReadMm2 function ; ; Notes: ; ;------------------------------------------------------------------------------ DEFAULT REL SECTION .text ;------------------------------------------------------------------------------ ; UINT64 ; EFIAPI ; AsmReadMm2 ( ; VOID ; ); ;------------------------------------------------------------------------------ global ASM_PFX(AsmReadMm2) ASM_PFX(AsmReadMm2): ; ; 64-bit MASM doesn't support MMX instructions, so use opcode here ; DB 0x48, 0xf, 0x7e, 0xd0 ret
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_D_ht+0x1244d, %rdi dec %rcx movups (%rdi), %xmm1 vpextrq $1, %xmm1, %r11 nop nop add $27776, %r12 lea addresses_WT_ht+0x1c234, %r9 nop nop nop nop nop inc %r13 mov $0x6162636465666768, %rax movq %rax, (%r9) nop nop nop nop and $59768, %rax lea addresses_WT_ht+0x340d, %rcx nop nop nop nop nop and $32997, %rax mov (%rcx), %r13d nop nop nop nop sub %rax, %rax lea addresses_D_ht+0x1208d, %r9 nop nop nop nop nop add $21073, %r12 movb $0x61, (%r9) nop nop nop sub $61320, %r11 lea addresses_WT_ht+0x13c8d, %rsi lea addresses_D_ht+0xed34, %rdi clflush (%rsi) and $7505, %r9 mov $54, %rcx rep movsl nop nop nop nop add %rsi, %rsi lea addresses_UC_ht+0x11e0d, %r12 nop nop nop nop nop sub $8923, %rax movb (%r12), %r13b nop nop nop cmp $17728, %rsi pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r8 push %r9 push %rdi push %rdx // Faulty Load lea addresses_A+0x1bf8d, %rdi nop nop nop nop nop inc %rdx movb (%rdi), %r12b lea oracles, %rdi and $0xff, %r12 shlq $12, %r12 mov (%rdi,%r12,1), %r12 pop %rdx pop %rdi pop %r9 pop %r8 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_A', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 7, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'35': 21829} 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
RocketHideout1_h: db FACILITY ; tileset db ROCKET_HIDEOUT_1_HEIGHT, ROCKET_HIDEOUT_1_WIDTH ; dimensions (y, x) dw RocketHideout1Blocks, RocketHideout1TextPointers, RocketHideout1Script ; blocks, texts, scripts db $00 ; connections dw RocketHideout1Object ; objects
; A062810: a(n) = Sum_{i=1..n} i^(n - i) + (n - i)^i. ; 1,3,7,17,45,131,419,1465,5561,22755,99727,465537,2303829,12037571,66174411,381560425,2301307841,14483421859,94909491607,646309392369,4565559980989,33401808977411,252713264780595,1974606909857945 lpb $0,1 add $3,1 mov $2,$3 pow $2,$0 sub $0,1 add $1,$2 lpe mul $1,2 add $1,1
; A283506: Decimal representation of the x-axis, from the left edge to the origin, of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 641", based on the 5-celled von Neumann neighborhood. ; Submitted by Jamie Morken(s1) ; 1,0,5,12,29,60,125,252,509,1020,2045,4092,8189,16380,32765,65532,131069,262140,524285,1048572,2097149,4194300,8388605,16777212,33554429,67108860,134217725,268435452,536870909,1073741820,2147483645,4294967292,8589934589,17179869180,34359738365,68719476732,137438953469,274877906940,549755813885,1099511627772,2199023255549,4398046511100,8796093022205,17592186044412,35184372088829,70368744177660,140737488355325,281474976710652,562949953421309,1125899906842620,2251799813685245,4503599627370492 mov $1,$0 mov $0,2 add $1,1 pow $0,$1 trn $0,4 add $0,5 mod $1,2 add $0,$1 sub $0,5
; A327672: a(n) = Sum_{k=0..n} ceiling(sqrt(k)). ; 0,1,3,5,7,10,13,16,19,22,26,30,34,38,42,46,50,55,60,65,70,75,80,85,90,95,101,107,113,119,125,131,137,143,149,155,161,168,175,182,189,196,203,210,217,224,231,238,245,252,260,268,276,284,292,300,308,316,324,332,340,348,356,364,372,381,390,399,408,417,426,435,444,453,462,471,480,489,498,507,516,525,535,545,555,565,575,585,595,605,615,625,635,645,655,665,675,685,695,705 lpb $0 add $1,$0 add $2,2 sub $0,$2 add $0,2 trn $0,1 lpe mov $0,$1
// // detail/shared_ptr.hpp // ~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef ASIO_DETAIL_SHARED_PTR_HPP #define ASIO_DETAIL_SHARED_PTR_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #if defined(ASIO_HAS_STD_SHARED_PTR) # include <memory> #else // defined(ASIO_HAS_STD_SHARED_PTR) # include <boost/shared_ptr.hpp> #endif // defined(ASIO_HAS_STD_SHARED_PTR) namespace asio { namespace detail { #if defined(ASIO_HAS_STD_SHARED_PTR) using std::shared_ptr; #else // defined(ASIO_HAS_STD_SHARED_PTR) using boost::shared_ptr; #endif // defined(ASIO_HAS_STD_SHARED_PTR) } // namespace detail } // namespace asio #endif // ASIO_DETAIL_SHARED_PTR_HPP
#include <ozo/connection_info.h> #include <gtest/gtest.h> #include <gmock/gmock.h> namespace { TEST(get_connection, should_return_timeout_error_for_zero_connect_timeout) { ozo::io_context io; const ozo::connection_info conn_info(OZO_PG_TEST_CONNINFO); const std::chrono::seconds timeout(0); std::atomic_flag called {}; ozo::get_connection(conn_info[io], timeout, [&] (ozo::error_code ec, auto conn) { EXPECT_FALSE(called.test_and_set()); EXPECT_EQ(ec, boost::asio::error::timed_out); EXPECT_TRUE(ozo::connection_bad(conn)); EXPECT_EQ(ozo::get_error_context(conn), "error while connection polling"); }); io.run(); } TEST(get_connection, should_return_connection_for_max_connect_timeout) { ozo::io_context io; const ozo::connection_info conn_info(OZO_PG_TEST_CONNINFO); const auto timeout = ozo::time_traits::duration::max(); std::atomic_flag called {}; ozo::get_connection(conn_info[io], timeout, [&] (ozo::error_code ec, auto conn) { EXPECT_FALSE(called.test_and_set()); EXPECT_FALSE(ec); EXPECT_FALSE(ozo::connection_bad(conn)); }); io.run(); } } // namespace
/******************************************************************************/ /* */ /* Copyright (c) 1990-2016, KAIST */ /* All rights reserved. */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* 1. Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* 2. Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* 3. Neither the name of the copyright holder nor the names of its */ /* contributors may be used to endorse or promote products derived */ /* from this software without specific prior written permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */ /* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */ /* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */ /* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */ /* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ /* */ /******************************************************************************/ /******************************************************************************/ /* */ /* ODYSSEUS/OOSQL DB-IR-Spatial Tightly-Integrated DBMS */ /* Version 5.0 */ /* */ /* Developed by Professor Kyu-Young Whang et al. */ /* */ /* Advanced Information Technology Research Center (AITrc) */ /* Korea Advanced Institute of Science and Technology (KAIST) */ /* */ /* e-mail: odysseus.oosql@gmail.com */ /* */ /* Bibliography: */ /* [1] Whang, K., Lee, J., Lee, M., Han, W., Kim, M., and Kim, J., "DB-IR */ /* Integration Using Tight-Coupling in the Odysseus DBMS," World Wide */ /* Web, Vol. 18, No. 3, pp. 491-520, May 2015. */ /* [2] Whang, K., Lee, M., Lee, J., Kim, M., and Han, W., "Odysseus: a */ /* High-Performance ORDBMS Tightly-Coupled with IR Features," In Proc. */ /* IEEE 21st Int'l Conf. on Data Engineering (ICDE), pp. 1104-1105 */ /* (demo), Tokyo, Japan, April 5-8, 2005. This paper received the Best */ /* Demonstration Award. */ /* [3] Whang, K., Park, B., Han, W., and Lee, Y., "An Inverted Index */ /* Storage Structure Using Subindexes and Large Objects for Tight */ /* Coupling of Information Retrieval with Database Management */ /* Systems," U.S. Patent No.6,349,308 (2002) (Appl. No. 09/250,487 */ /* (1999)). */ /* [4] Whang, K., Lee, J., Kim, M., Lee, M., Lee, K., Han, W., and Kim, */ /* J., "Tightly-Coupled Spatial Database Features in the */ /* Odysseus/OpenGIS DBMS for High-Performance," GeoInformatica, */ /* Vol. 14, No. 4, pp. 425-446, Oct. 2010. */ /* [5] Whang, K., Lee, J., Kim, M., Lee, M., and Lee, K., "Odysseus: a */ /* High-Performance ORDBMS Tightly-Coupled with Spatial Database */ /* Features," In Proc. 23rd IEEE Int'l Conf. on Data Engineering */ /* (ICDE), pp. 1493-1494 (demo), Istanbul, Turkey, Apr. 16-20, 2007. */ /* */ /******************************************************************************/ /**************************************************************************** * * Description: Header file for a stack class made of objects linked in * a singly linked list. * * ****************************************************************************/ #ifndef _OOSQL_TCL_STACK_H_ #define _OOSQL_TCL_STACK_H_ #include "OOSQL_List.hxx" /*--------------------------- Class Definition ----------------------------*/ //--------------------------------------------------------------------------- // The stack class is an abstraction of the list class that provides the // operations normally performed on a stack. Internally it is simply a // singly linked list, so all items placed on the stack MUST be derived // from OOSQL_TCListNode. //--------------------------------------------------------------------------- class OOSQL_TCGenStack : private OOSQL_TCGenList { public: // Method to examine the top item on the stack OOSQL_TCListNode* top() const { return peekHead(); }; // Method to push an item onto the stack void push(OOSQL_TCListNode* node) { addToHead(node); }; // Method to pop an item from the stack OOSQL_TCListNode* pop() { return removeFromHead(); }; // Empties the entire stack by destroying all nodes void empty() { OOSQL_TCGenList::empty(); }; // Returns the number of items on the stack UFour numberOfItems() const { return OOSQL_TCGenList::numberOfItems(); }; // Returns true if the stack is empty bool isEmpty() const { return OOSQL_TCGenList::isEmpty(); }; }; //--------------------------------------------------------------------------- // Template wrapper class for declaring Type Safe linked stacks. //--------------------------------------------------------------------------- template <class T> class OOSQL_TCStack : public OOSQL_TCGenStack { public: T* top() const { return (T*)OOSQL_TCGenStack::top(); }; T* pop() { return (T*)OOSQL_TCGenStack::pop(); }; }; #endif // _OOSQL_TCL_STACK_H_
#include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/RandomNumberGenerator.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" #include "DataFormats/Common/interface/Handle.h" #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h" #include "SimMuon/GEMDigitizer/interface/ME0DigiPreRecoProducer.h" #include "SimMuon/GEMDigitizer/interface/ME0DigiPreRecoModelFactory.h" #include "SimMuon/GEMDigitizer/interface/ME0DigiPreRecoModel.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/GEMGeometry/interface/ME0Geometry.h" #include <sstream> #include <string> #include <map> #include <vector> namespace CLHEP { class HepRandomEngine; } ME0DigiPreRecoProducer::ME0DigiPreRecoProducer(const edm::ParameterSet& ps) : digiPreRecoModelString_(ps.getParameter<std::string>("digiPreRecoModelString")), me0DigiPreRecoModel_{ME0DigiPreRecoModelFactory::get()->create("ME0" + digiPreRecoModelString_ + "Model", ps)} { produces<ME0DigiPreRecoCollection>(); edm::Service<edm::RandomNumberGenerator> rng; if (!rng.isAvailable()) { throw cms::Exception("Configuration") << "ME0DigiPreRecoProducer::ME0PreRecoDigiProducer() - RandomNumberGeneratorService is not present in " "configuration file.\n" << "Add the service in the configuration file or remove the modules that require it."; } LogDebug("ME0DigiPreRecoProducer") << "Using ME0" + digiPreRecoModelString_ + "Model"; std::string mix_(ps.getParameter<std::string>("mixLabel")); std::string collection_(ps.getParameter<std::string>("inputCollection")); cf_token = consumes<CrossingFrame<PSimHit> >(edm::InputTag(mix_, collection_)); } ME0DigiPreRecoProducer::~ME0DigiPreRecoProducer() = default; void ME0DigiPreRecoProducer::beginRun(const edm::Run&, const edm::EventSetup& eventSetup) { // set geometry edm::ESHandle<ME0Geometry> hGeom; eventSetup.get<MuonGeometryRecord>().get(hGeom); me0DigiPreRecoModel_->setGeometry(&*hGeom); me0DigiPreRecoModel_->setup(); } void ME0DigiPreRecoProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup) { edm::Service<edm::RandomNumberGenerator> rng; CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID()); edm::Handle<CrossingFrame<PSimHit> > cf; e.getByToken(cf_token, cf); MixCollection<PSimHit> hits{cf.product()}; // Create empty output auto digis = std::make_unique<ME0DigiPreRecoCollection>(); // arrange the hits by eta partition std::map<uint32_t, edm::PSimHitContainer> hitMap; for (const auto& hit : hits) { hitMap[hit.detUnitId()].push_back(hit); } // simulate signal and noise for each eta partition const auto& etaPartitions(me0DigiPreRecoModel_->getGeometry()->etaPartitions()); for (const auto& roll : etaPartitions) { const ME0DetId detId(roll->id()); const uint32_t rawId(detId.rawId()); const auto& simHits(hitMap[rawId]); LogDebug("ME0DigiPreRecoProducer") << "ME0DigiPreRecoProducer: found " << simHits.size() << " hit(s) in eta partition" << rawId; me0DigiPreRecoModel_->simulateSignal(roll, simHits, engine); me0DigiPreRecoModel_->simulateNoise(roll, engine); me0DigiPreRecoModel_->fillDigis(rawId, *digis); } // store them in the event e.put(std::move(digis)); }
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the Willow Garage nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ #include "ethercat_hardware/ethercat_com.h" #include <stdio.h> #include <errno.h> #include <assert.h> bool EthercatDirectCom::txandrx_once(struct EtherCAT_Frame * frame) { assert(frame != NULL); int handle = dll_->tx(frame); if (handle < 0) return false; return dll_->rx(frame, handle); } bool EthercatDirectCom::txandrx(struct EtherCAT_Frame * frame) { return dll_->txandrx(frame); } EthercatOobCom::EthercatOobCom(struct netif *ni) : ni_(ni), state_(IDLE), frame_(NULL), handle_(-1), line_(0) { assert(ni_ != NULL); pthread_mutexattr_t mutex_attr; int error = pthread_mutexattr_init(&mutex_attr); if (error != 0) { fprintf(stderr, "%s : Initializing mutex attr failed : %d\n", __func__, error); return; } error = pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_ERRORCHECK_NP); if (error != 0) { fprintf(stderr, "%s : Setting type of mutex attr failed : %d\n", __func__, error); return; } error = pthread_mutex_init(&mutex_, &mutex_attr); if (error != 0) { fprintf(stderr, "%s : Initializing mutex failed : %d\n", __func__, error); return; } error = pthread_cond_init(&share_cond_, NULL); if (error != 0) { fprintf(stderr, "%s : Initializing share condition failed : %d\n", __func__, error); return; } error = pthread_cond_init(&busy_cond_, NULL); if (error != 0) fprintf(stderr, "%s : Initializing busy condition failed : %d\n", __func__, error); return; } bool EthercatOobCom::lock(unsigned line) { int error; if (0 != (error = pthread_mutex_lock(&mutex_))) { fprintf(stderr, "%s : lock %d at %d\n", __func__, error, line); return false; } line_ = line; return true; } bool EthercatOobCom::trylock(unsigned line) { int error; if (0 != (error = pthread_mutex_trylock(&mutex_))) { if (error != EBUSY) fprintf(stderr, "%s : lock %d at %d\n", __func__, error, line); return false; } line_ = line; return true; } bool EthercatOobCom::unlock(unsigned line) { int error; if (0 != (error = pthread_mutex_unlock(&mutex_))) { fprintf(stderr, "%s : unlock %d at %d\n", __func__, error, line); return false; } line_ = 0; return true; } // OOB replacement for netif->txandrx() // Returns true for success, false for dropped packet bool EthercatOobCom::txandrx_once(struct EtherCAT_Frame * frame) { assert(frame != NULL); if (!lock(__LINE__)) return false; // Wait for an opening to send frame while (state_ != IDLE) { pthread_cond_wait(&share_cond_, &mutex_); } frame_ = frame; state_ = READY_TO_SEND; // RT control loop will send frame do { pthread_cond_wait(&busy_cond_, &mutex_); } while (state_ != WAITING_TO_RECV); // Packet has been sent, wait for recv bool success = false; if (handle_ >= 0) success = ni_->rx(frame_, ni_, handle_); handle_ = -1; // Allow other threads to send data assert(frame_ == frame); state_ = IDLE; pthread_cond_signal(&share_cond_); unlock(__LINE__); return success; } bool EthercatOobCom::txandrx(struct EtherCAT_Frame * frame) { static const unsigned MAX_TRIES = 10; for (unsigned tries = 0; tries < MAX_TRIES; ++tries) { if (this->txandrx_once(frame)) return true; } return false; } // Called by RT control loop to send oob data void EthercatOobCom::tx() { if (!trylock(__LINE__)) return; if (state_ == READY_TO_SEND) { // Packet is in need of being sent assert(frame_ != NULL); handle_ = ni_->tx(frame_, ni_); state_ = WAITING_TO_RECV; pthread_cond_signal(&busy_cond_); } unlock(__LINE__); }
; ; ; ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. ; ; Copyright 2007-2019 Broadcom Inc. All rights reserved. ; ; ; Adapted from sdk5670.asm ; February 27, 2004 ; ; This is the default program for the 5675 SDK. ; To start it, use the following commands from BCM: ; ; led load sdk5675.hex ; led auto on ; led start ; ; The BCM5675 SDK has 10 columns of 4 LEDs each as shown below: ; ; E1 E2 E3 E4 E5 E6 E7 E8 U1 U5 ; L1 L2 L3 L4 L5 L6 L7 L8 U2 U6 ; T1 T2 T3 T4 T5 T6 T7 T8 U3 U7 ; R1 R2 R3 R4 R5 R6 R7 R8 U4 U8 ; ; There is one bit per LED with the following colors: ; ; ZERO Green ; ONE Black ; ; The bits are shifted out in the following order: ; E1, L1, T1, R1, E2, L2, T2, R2, ; E3, L3, T3, R3, E4, L4, T4, R4, ; E5, L5, T5, R5, E6, L6, T6, R6, ; E7, L7, T7, R7, E8, L8, T8, R8, ; U1, U2, U3, U4, U5, U6, U7, U8 ; ; Current implementation: ; ; E1 reflects port 1 higig link enable ; L1 reflects port 1 higig link up ; T1 reflects port 1 higig transmit activity ; R1 reflects port 1 higig receive activity ; ; U1 through U8 are user-defined LEDs and ; just display a chasing LED pattern. ; ld a,1 ; Start with first column up1: port a pushst LINKEN tinv pack pushst LINKUP tinv pack pushst TX tinv pack pushst RX tinv pack inc a ; Next column cmp a,9 jnz up1 ; ; Put out 8 more values to user LEDs. ; In this case it is a cycling pattern. ; inc (0x7f) ld a,(0x7f) and a,7 jnz up2 inc (0x7e) up2: ld b,(0x7e) and b,0x07 sub a,a stc bit a,b ld b,0x08 up3: ror a push cy tinv pack dec b jnz up3 send 0x28 ; ; Symbolic names for the bits of the port status fields ; RX equ 0x0 ; received packet TX equ 0x1 ; transmitted packet COLL equ 0x2 ; collision indicator SPEED_C equ 0x3 ; 100 Mbps SPEED_M equ 0x4 ; 1000 Mbps DUPLEX equ 0x5 ; half/full duplex FLOW equ 0x6 ; flow control capable LINKUP equ 0x7 ; link down/up status LINKEN equ 0x8 ; link disabled/enabled status ZERO equ 0xE ; always 0 ONE equ 0xF ; always 1
; A311501: Coordination sequence Gal.4.38.1 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,4,8,12,17,22,26,30,34,38,42,46,51,56,60,64,68,72,76,80,85,90,94,98,102,106,110,114,119,124,128,132,136,140,144,148,153,158,162,166,170,174,178,182,187,192,196,200,204,208 mov $1,$0 seq $0,313793 ; Coordination sequence Gal.4.134.1 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. sub $0,$1
//===- SPIRVWriterPass.cpp - SPIRV writing pass -----------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // SPIRVWriterPass implementation. // //===----------------------------------------------------------------------===// #include "SPIRVWriterPass.h" #include "LLVMSPIRVLib.h" #include "llvm/IR/Module.h" #include "llvm/IR/PassManager.h" #include "llvm/Pass.h" using namespace llvm; PreservedAnalyses SPIRVWriterPass::run(Module &M) { // FIXME: at the moment LLVM/SPIR-V translation errors are ignored. std::string Err; writeSpirv(&M, OS, Err); return PreservedAnalyses::all(); } namespace { class WriteSPIRVPass : public ModulePass { std::ostream &OS; // std::ostream to print on public: static char ID; // Pass identification, replacement for typeid explicit WriteSPIRVPass(std::ostream &O) : ModulePass(ID), OS(O) {} StringRef getPassName() const override { return "SPIRV Writer"; } bool runOnModule(Module &M) override { // FIXME: at the moment LLVM/SPIR-V translation errors are ignored. std::string Err; writeSpirv(&M, OS, Err); return false; } }; } // namespace char WriteSPIRVPass::ID = 0; ModulePass *llvm::createSPIRVWriterPass(std::ostream &Str) { return new WriteSPIRVPass(Str); }
; A211227: Row sums of A211226. ; 1,2,3,4,8,8,20,16,48,32,112,64,256,128,576,256,1280,512,2816,1024,6144,2048,13312,4096,28672,8192,61440,16384,131072,32768,278528,65536,589824,131072,1245184,262144,2621440,524288,5505024 mov $3,$0 add $0,1 mov $4,1 lpb $0 sub $0,1 add $1,1 add $1,$4 div $2,2 add $2,$3 mov $3,$1 mov $1,1 add $1,$2 mov $2,1 mul $3,2 mov $4,0 lpe div $1,4 add $1,1
#include <iostream> #include <string> #include <algorithm> constexpr int MAX_XY = 1010; int lx, ly, q, dp[MAX_XY][MAX_XY]; std::string sx, sy; void fill_dp(){ for(int i = 1; i <= lx; ++i){ for(int j = 1; j <= ly; ++j){ if(sx[i - 1] == sy[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1; else dp[i][j] = std::max(dp[i - 1][j], dp[i][j - 1]); } } } void solve(){ fill_dp(); std::cout << dp[lx][ly] << std::endl; return; } int main(){ std::cin >> q; for(int i = 0; i < q; ++i){ std::cin >> sx >> sy; lx = sx.size(), ly = sy.size(); solve(); } return 0; }
#include "generator/routing_index_generator.hpp" #include "generator/borders.hpp" #include "generator/cross_mwm_osm_ways_collector.hpp" #include "generator/routing_helpers.hpp" #include "routing/base/astar_algorithm.hpp" #include "routing/base/astar_graph.hpp" #include "routing/cross_mwm_connector.hpp" #include "routing/cross_mwm_connector_serialization.hpp" #include "routing/cross_mwm_ids.hpp" #include "routing/index_graph.hpp" #include "routing/index_graph_loader.hpp" #include "routing/index_graph_serialization.hpp" #include "routing/index_graph_starter_joints.hpp" #include "routing/joint_segment.hpp" #include "routing/vehicle_mask.hpp" #include "transit/experimental/transit_data.hpp" #include "transit/transit_graph_data.hpp" #include "transit/transit_serdes.hpp" #include "routing_common/bicycle_model.hpp" #include "routing_common/car_model.hpp" #include "routing_common/pedestrian_model.hpp" #include "indexer/feature.hpp" #include "indexer/feature_processor.hpp" #include "coding/files_container.hpp" #include "coding/geometry_coding.hpp" #include "coding/point_coding.hpp" #include "coding/reader.hpp" #include "geometry/point2d.hpp" #include "base/assert.hpp" #include "base/checked_cast.hpp" #include "base/file_name_utils.hpp" #include "base/geo_object_id.hpp" #include "base/logging.hpp" #include "base/timer.hpp" #include <algorithm> #include <cstdint> #include <functional> #include <limits> #include <map> #include <memory> #include <unordered_map> #include <vector> using namespace feature; using namespace platform; using namespace std; using namespace std::placeholders; namespace { class VehicleMaskBuilder final { public: VehicleMaskBuilder(string const & country, routing::CountryParentNameGetterFn const & countryParentNameGetterFn) : m_pedestrianModel(routing::PedestrianModelFactory(countryParentNameGetterFn) .GetVehicleModelForCountry(country)) , m_bicycleModel(routing::BicycleModelFactory(countryParentNameGetterFn) .GetVehicleModelForCountry(country)) , m_carModel( routing::CarModelFactory(countryParentNameGetterFn).GetVehicleModelForCountry(country)) { CHECK(m_pedestrianModel, ()); CHECK(m_bicycleModel, ()); CHECK(m_carModel, ()); } routing::VehicleMask CalcRoadMask(FeatureType & f) const { return CalcMask(f, [&](routing::VehicleModelInterface const & model, FeatureType & f) { return model.IsRoad(f); }); } routing::VehicleMask CalcOneWayMask(FeatureType & f) const { return CalcMask(f, [&](routing::VehicleModelInterface const & model, FeatureType & f) { return model.IsOneWay(f); }); } private: template <class Fn> routing::VehicleMask CalcMask(FeatureType & f, Fn && fn) const { routing::VehicleMask mask = 0; if (fn(*m_pedestrianModel, f)) mask |= routing::kPedestrianMask; if (fn(*m_bicycleModel, f)) mask |= routing::kBicycleMask; if (fn(*m_carModel, f)) mask |= routing::kCarMask; return mask; } shared_ptr<routing::VehicleModelInterface> const m_pedestrianModel; shared_ptr<routing::VehicleModelInterface> const m_bicycleModel; shared_ptr<routing::VehicleModelInterface> const m_carModel; }; class Processor final { public: Processor(string const & country, routing::CountryParentNameGetterFn const & countryParentNameGetterFn) : m_maskBuilder(country, countryParentNameGetterFn) { } void ProcessAllFeatures(string const & filename) { feature::ForEachFeature(filename, bind(&Processor::ProcessFeature, this, _1, _2)); } void BuildGraph(routing::IndexGraph & graph) const { vector<routing::Joint> joints; for (auto const & it : m_posToJoint) { // Need only connected points (2 or more roads) if (it.second.GetSize() >= 2) joints.emplace_back(it.second); } graph.Import(joints); } unordered_map<uint32_t, routing::VehicleMask> const & GetMasks() const { return m_masks; } private: void ProcessFeature(FeatureType & f, uint32_t id) { routing::VehicleMask const mask = m_maskBuilder.CalcRoadMask(f); if (mask == 0) return; m_masks[id] = mask; f.ParseGeometry(FeatureType::BEST_GEOMETRY); for (size_t i = 0; i < f.GetPointsCount(); ++i) { uint64_t const locationKey = PointToInt64Obsolete(f.GetPoint(i), kPointCoordBits); m_posToJoint[locationKey].AddPoint(routing::RoadPoint(id, base::checked_cast<uint32_t>(i))); } } VehicleMaskBuilder const m_maskBuilder; unordered_map<uint64_t, routing::Joint> m_posToJoint; unordered_map<uint32_t, routing::VehicleMask> m_masks; }; class IndexGraphWrapper final { public: IndexGraphWrapper(routing::IndexGraph & graph, routing::Segment const & start) : m_graph(graph), m_start(start) { } // Just for compatibility with IndexGraphStarterJoints // @{ routing::Segment GetStartSegment() const { return m_start; } routing::Segment GetFinishSegment() const { return {}; } bool ConvertToReal(routing::Segment const & /* segment */) const { return false; } routing::RouteWeight HeuristicCostEstimate(routing::Segment const & /* from */, ms::LatLon const & /* to */) { CHECK(false, ("This method exists only for compatibility with IndexGraphStarterJoints")); return routing::GetAStarWeightZero<routing::RouteWeight>(); } bool AreWavesConnectible( routing::IndexGraph::Parents<routing::JointSegment> const & /* forwardParents */, routing::JointSegment const & /* commonVertex */, routing::IndexGraph::Parents<routing::JointSegment> const & /* backwardParents */, function<uint32_t(routing::JointSegment const &)> && /* fakeFeatureConverter */) { return true; } void SetAStarParents(bool /* forward */, routing::IndexGraph::Parents<routing::JointSegment> & parents) { m_AStarParents = &parents; } void DropAStarParents() { m_AStarParents = nullptr; } routing::RouteWeight GetAStarWeightEpsilon() { return routing::RouteWeight(0.0); } // @} ms::LatLon const & GetPoint(routing::Segment const & s, bool forward) { return m_graph.GetPoint(s, forward); } void GetEdgesList(routing::Segment const & child, bool isOutgoing, vector<routing::SegmentEdge> & edges) { m_graph.GetEdgeList(child, isOutgoing, true /* useRoutingOptions */, edges); } void GetEdgeList( routing::astar::VertexData<routing::JointSegment, routing::RouteWeight> const & vertexData, routing::Segment const & parent, bool isOutgoing, vector<routing::JointEdge> & edges, vector<routing::RouteWeight> & parentWeights) const { CHECK(m_AStarParents, ()); return m_graph.GetEdgeList(vertexData.m_vertex, parent, isOutgoing, edges, parentWeights, *m_AStarParents); } bool IsJoint(routing::Segment const & segment, bool fromStart) const { return IsJointOrEnd(segment, fromStart); } bool IsJointOrEnd(routing::Segment const & segment, bool fromStart) const { return m_graph.IsJointOrEnd(segment, fromStart); } template <typename Vertex> routing::RouteWeight HeuristicCostEstimate(Vertex const & /* from */, m2::PointD const & /* to */) { CHECK(false, ("This method should not be use, it is just for compatibility with " "IndexGraphStarterJoints.")); return routing::GetAStarWeightZero<routing::RouteWeight>(); } private: routing::IndexGraph::Parents<routing::JointSegment> * m_AStarParents = nullptr; routing::IndexGraph & m_graph; routing::Segment m_start; }; class DijkstraWrapperJoints : public routing::IndexGraphStarterJoints<IndexGraphWrapper> { public: DijkstraWrapperJoints(IndexGraphWrapper & graph, routing::Segment const & start) : routing::IndexGraphStarterJoints<IndexGraphWrapper>(graph, start) { } Weight HeuristicCostEstimate(Vertex const & /* from */, Vertex const & /* to */) override { return routing::GetAStarWeightZero<Weight>(); } }; /// \brief Fills |transitions| for osm id case. That means |Transition::m_roadMask| for items in /// |transitions| will be combination of |VehicleType::Pedestrian|, |VehicleType::Bicycle| /// and |VehicleType::Car|. void CalcCrossMwmTransitions( string const & mwmFile, string const & intermediateDir, string const & mappingFile, vector<m2::RegionD> const & borders, string const & country, routing::CountryParentNameGetterFn const & countryParentNameGetterFn, vector<routing::CrossMwmConnectorSerializer::Transition<base::GeoObjectId>> & transitions) { VehicleMaskBuilder const maskMaker(country, countryParentNameGetterFn); map<uint32_t, base::GeoObjectId> featureIdToOsmId; CHECK(routing::ParseWaysFeatureIdToOsmIdMapping(mappingFile, featureIdToOsmId), ("Can't parse feature id to osm id mapping. File:", mappingFile)); auto const & path = base::JoinPath(intermediateDir, CROSS_MWM_OSM_WAYS_DIR, country); auto const crossMwmOsmIdWays = generator::CrossMwmOsmWaysCollector::CrossMwmInfo::LoadFromFileToSet(path); ForEachFeature(mwmFile, [&](FeatureType & f, uint32_t featureId) { routing::VehicleMask const roadMask = maskMaker.CalcRoadMask(f); if (roadMask == 0) return; auto const it = featureIdToOsmId.find(featureId); CHECK(it != featureIdToOsmId.end(), ("Can't find osm id for feature id", featureId)); auto const osmId = it->second; CHECK(osmId.GetType() == base::GeoObjectId::Type::ObsoleteOsmWay, ()); auto const crossMwmWayInfoIt = crossMwmOsmIdWays.find(generator::CrossMwmOsmWaysCollector::CrossMwmInfo(osmId.GetEncodedId())); if (crossMwmWayInfoIt != crossMwmOsmIdWays.cend()) { f.ParseGeometry(FeatureType::BEST_GEOMETRY); routing::VehicleMask const oneWayMask = maskMaker.CalcOneWayMask(f); auto const & crossMwmWayInfo = *crossMwmWayInfoIt; for (auto const & segmentInfo : crossMwmWayInfo.m_crossMwmSegments) { uint32_t const segmentId = segmentInfo.m_segmentId; bool const forwardIsEnter = segmentInfo.m_forwardIsEnter; transitions.emplace_back(osmId, featureId, segmentId, roadMask, oneWayMask, forwardIsEnter); } } }); } /// \brief Fills |transitions| for transit case. That means Transition::m_roadMask for items in /// |transitions| will be equal to VehicleType::Transit after call of this method. void CalcCrossMwmTransitions( string const & mwmFile, string const & intermediateDir, string const & mappingFile, vector<m2::RegionD> const & borders, string const & country, routing::CountryParentNameGetterFn const & /* countryParentNameGetterFn */, vector<routing::CrossMwmConnectorSerializer::Transition<routing::connector::TransitId>> & transitions) { CHECK(mappingFile.empty(), ()); CHECK(intermediateDir.empty(), ()); try { FilesContainerR cont(mwmFile); if (!cont.IsExist(TRANSIT_FILE_TAG)) { LOG(LINFO, ("Transit cross mwm section is not generated because no transit section in mwm:", mwmFile)); return; } auto reader = cont.GetReader(TRANSIT_FILE_TAG); routing::transit::GraphData graphData; graphData.DeserializeForCrossMwm(*reader.GetPtr()); auto const & stops = graphData.GetStops(); auto const & edges = graphData.GetEdges(); auto const getStopIdPoint = [&stops](routing::transit::StopId stopId) -> m2::PointD const & { auto const it = equal_range(stops.cbegin(), stops.cend(), routing::transit::Stop(stopId)); CHECK_EQUAL( distance(it.first, it.second), 1, ("A stop with id:", stopId, "is not unique or there's no such item in stops:", stops)); return it.first->GetPoint(); }; // Index |i| is a zero based edge index. This zero based index should be increased with // |FakeFeatureIds::kTransitGraphFeaturesStart| by setting it as |featureNumerationOffset| for // CrossMwmConnector (see CrossMwmIndexGraph::Deserialize()) and then used in Segment class as // feature id in transit case. for (size_t i = 0; i < edges.size(); ++i) { auto const & e = edges[i]; m2::PointD const & stop1Point = getStopIdPoint(e.GetStop1Id()); m2::PointD const & stop2Point = getStopIdPoint(e.GetStop2Id()); bool const stop2In = m2::RegionsContain(borders, stop2Point); if (m2::RegionsContain(borders, stop1Point) == stop2In) continue; // Note. One way mask is set to kTransitMask because all transit edges are one way edges. transitions.emplace_back( routing::connector::TransitId(e.GetStop1Id(), e.GetStop2Id(), e.GetLineId()), i /* feature id */, 0 /* segment index */, routing::kTransitMask, routing::kTransitMask /* one way mask */, stop2In /* forward is enter */); } } catch (Reader::OpenException const & e) { CHECK(false, ("Error while reading", TRANSIT_FILE_TAG, "section.", e.Msg())); } } /// TODO(o.khlopkova) Rename CalcCrossMwmTransitionsExperimental() and remove /// CalcCrossMwmTransitions() when we abandon support of "subway" transit section version. /// \brief Fills |transitions| for experimental transit case. It means that Transition::m_roadMask /// for items in |transitions| will be equal to VehicleType::Transit after the call of this method. void CalcCrossMwmTransitionsExperimental( string const & mwmFile, vector<m2::RegionD> const & borders, string const & country, routing::CountryParentNameGetterFn const & /* countryParentNameGetterFn */, vector<routing::CrossMwmConnectorSerializer::Transition<routing::connector::TransitId>> & transitions) { try { FilesContainerR cont(mwmFile); if (!cont.IsExist(TRANSIT_FILE_TAG)) { LOG(LINFO, ("Experimental transit cross mwm section is not generated because there is no " "experimental transit section in mwm:", mwmFile)); return; } auto reader = cont.GetReader(TRANSIT_FILE_TAG); transit::experimental::TransitData transitData; transitData.DeserializeForCrossMwm(*reader.GetPtr()); auto const & stops = transitData.GetStops(); auto const & edges = transitData.GetEdges(); auto const getStopIdPoint = [&stops](transit::TransitId stopId) { auto const it = find_if( stops.begin(), stops.end(), [stopId](transit::experimental::Stop const & stop) { return stop.GetId() == stopId; }); CHECK(it != stops.end(), ("stopId:", stopId, "is not found in stops. Size of stops:", stops.size())); return it->GetPoint(); }; // Index |i| is a zero based edge index. This zero based index should be increased with // |FakeFeatureIds::kTransitGraphFeaturesStart| by setting it as |featureNumerationOffset| for // CrossMwmConnector (see CrossMwmIndexGraph::Deserialize()) and then used in Segment class as // feature id in transit case. for (size_t i = 0; i < edges.size(); ++i) { auto const & e = edges[i]; m2::PointD const & stop1Point = getStopIdPoint(e.GetStop1Id()); m2::PointD const & stop2Point = getStopIdPoint(e.GetStop2Id()); bool const stop2In = m2::RegionsContain(borders, stop2Point); if (m2::RegionsContain(borders, stop1Point) == stop2In) continue; // Note. One way mask is set to kTransitMask because all transit edges are one way edges. transitions.emplace_back( routing::connector::TransitId(e.GetStop1Id(), e.GetStop2Id(), e.GetLineId()), i /* feature id */, 0 /* segment index */, routing::kTransitMask, routing::kTransitMask /* one way mask */, stop2In /* forward is enter */); } } catch (Reader::OpenException const & e) { CHECK(false, ("Error while reading", TRANSIT_FILE_TAG, "section.", e.Msg())); } } // Dummy specialization. We need it to compile this function overload for experimental transit. void CalcCrossMwmTransitionsExperimental( string const & mwmFile, vector<m2::RegionD> const & borders, string const & country, routing::CountryParentNameGetterFn const & countryParentNameGetterFn, vector<routing::CrossMwmConnectorSerializer::Transition<base::GeoObjectId>> & transitions) { CHECK(false, ("This is dummy specialization and it shouldn't be called.")); } /// \brief Fills |transitions| and |connectors| params. /// \note This method fills only |connections| which are applicable for |CrossMwmId|. /// For example |VehicleType::Pedestrian|, |VehicleType::Bicycle| and |VehicleType::Car| /// are applicable for |connector::OsmId|. /// And |VehicleType::Transit| is applicable for |connector::TransitId|. template <typename CrossMwmId> void CalcCrossMwmConnectors( string const & path, string const & mwmFile, string const & intermediateDir, string const & country, routing::CountryParentNameGetterFn const & countryParentNameGetterFn, string const & mappingFile, vector<routing::CrossMwmConnectorSerializer::Transition<CrossMwmId>> & transitions, routing::CrossMwmConnectorPerVehicleType<CrossMwmId> & connectors, bool experimentalTransit = false) { base::Timer timer; string const polyFile = base::JoinPath(path, BORDERS_DIR, country + BORDERS_EXTENSION); vector<m2::RegionD> borders; borders::LoadBorders(polyFile, borders); // Note 1. CalcCrossMwmTransitions() method fills vector |transitions|. // There are two implementation of the method for |connector::OsmId| and for |connector::TransitId|. // For all items in |transitions| |Transition::m_roadMask| may be set to any combination of masks: // GetVehicleMask(VehicleType::Pedestrian), GetVehicleMask(VehicleType::Bicycle) and // GetVehicleMask(VehicleType::Car) for |connector::OsmId| implementation. // For all items in |transitions| |Transition::m_roadMask| is set to // GetVehicleMask(VehicleType::Transit) for |connector::TransitId| implementation. // Note 2. Taking into account note 1 it's clear that field |Transition<TransitId>::m_roadMask| // is always set to |VehicleType::Transit| and field |Transition<OsmId>::m_roadMask| can't have // |VehicleType::Transit| value. if (experimentalTransit) { CalcCrossMwmTransitionsExperimental(mwmFile, borders, country, countryParentNameGetterFn, transitions); } else { CalcCrossMwmTransitions(mwmFile, intermediateDir, mappingFile, borders, country, countryParentNameGetterFn, transitions); } LOG(LINFO, ("Transitions finished, transitions:", transitions.size(), ", elapsed:", timer.ElapsedSeconds(), "seconds")); timer.Reset(); for (auto const & transition : transitions) { for (size_t i = 0; i < connectors.size(); ++i) { routing::VehicleMask const mask = GetVehicleMask(static_cast<routing::VehicleType>(i)); routing::CrossMwmConnectorSerializer::AddTransition(transition, mask, connectors[i]); } } for (size_t i = 0; i < connectors.size(); ++i) { auto const vehicleType = static_cast<routing::VehicleType>(i); auto const & connector = connectors[i]; LOG(LINFO, (vehicleType, "model. Number of enters:", connector.GetEnters().size(), "Number of exits:", connector.GetExits().size())); } } template <typename CrossMwmId> void FillWeights(string const & path, string const & mwmFile, string const & country, routing::CountryParentNameGetterFn const & countryParentNameGetterFn, bool disableCrossMwmProgress, routing::CrossMwmConnector<CrossMwmId> & connector) { base::Timer timer; shared_ptr<routing::VehicleModelInterface> vehicleModel = routing::CarModelFactory(countryParentNameGetterFn).GetVehicleModelForCountry(country); routing::IndexGraph graph(make_shared<routing::Geometry>( routing::GeometryLoader::CreateFromFile(mwmFile, vehicleModel)), routing::EdgeEstimator::Create(routing::VehicleType::Car, *vehicleModel, nullptr /* trafficStash */)); MwmValue mwmValue(LocalCountryFile(path, platform::CountryFile(country), 0 /* version */)); DeserializeIndexGraph(mwmValue, routing::VehicleType::Car, graph); map<routing::Segment, map<routing::Segment, routing::RouteWeight>> weights; auto const numEnters = connector.GetEnters().size(); size_t foundCount = 0; size_t notFoundCount = 0; for (size_t i = 0; i < numEnters; ++i) { if (i % 10 == 0) LOG(LINFO, ("Building leaps:", i, "/", numEnters, "waves passed")); routing::Segment const & enter = connector.GetEnter(i); using Algorithm = routing::AStarAlgorithm<routing::JointSegment, routing::JointEdge, routing::RouteWeight>; Algorithm astar; IndexGraphWrapper indexGraphWrapper(graph, enter); DijkstraWrapperJoints wrapper(indexGraphWrapper, enter); routing::AStarAlgorithm<routing::JointSegment, routing::JointEdge, routing::RouteWeight>::Context context(wrapper); unordered_map<uint32_t, vector<routing::JointSegment>> visitedVertexes; astar.PropagateWave( wrapper, wrapper.GetStartJoint(), [&](routing::JointSegment const & vertex) { if (vertex.IsFake()) { routing::Segment start = wrapper.GetSegmentOfFakeJoint(vertex, true /* start */); routing::Segment end = wrapper.GetSegmentOfFakeJoint(vertex, false /* start */); if (start.IsForward() != end.IsForward()) return true; visitedVertexes[end.GetFeatureId()].emplace_back(start, end); } else { visitedVertexes[vertex.GetFeatureId()].emplace_back(vertex); } return true; } /* visitVertex */, context); for (routing::Segment const & exit : connector.GetExits()) { auto const it = visitedVertexes.find(exit.GetFeatureId()); if (it == visitedVertexes.cend()) { ++notFoundCount; continue; } uint32_t const id = exit.GetSegmentIdx(); bool const forward = exit.IsForward(); for (auto const & jointSegment : it->second) { if (jointSegment.IsForward() != forward) continue; if ((jointSegment.GetStartSegmentId() <= id && id <= jointSegment.GetEndSegmentId()) || (jointSegment.GetEndSegmentId() <= id && id <= jointSegment.GetStartSegmentId())) { routing::RouteWeight weight; routing::Segment parentSegment; if (context.HasParent(jointSegment)) { routing::JointSegment const & parent = context.GetParent(jointSegment); parentSegment = parent.IsFake() ? wrapper.GetSegmentOfFakeJoint(parent, false /* start */) : parent.GetSegment(false /* start */); weight = context.GetDistance(parent); } else { parentSegment = enter; } routing::Segment const & firstChild = jointSegment.GetSegment(true /* start */); uint32_t const lastPoint = exit.GetPointId(true /* front */); static map<routing::JointSegment, routing::JointSegment> kEmptyParents; auto optionalEdge = graph.GetJointEdgeByLastPoint(parentSegment, firstChild, true /* isOutgoing */, lastPoint); if (!optionalEdge) continue; weight += (*optionalEdge).GetWeight(); weights[enter][exit] = weight; ++foundCount; break; } } } } connector.FillWeights([&](routing::Segment const & enter, routing::Segment const & exit) { auto it0 = weights.find(enter); if (it0 == weights.end()) return routing::connector::kNoRoute; auto it1 = it0->second.find(exit); if (it1 == it0->second.end()) return routing::connector::kNoRoute; return it1->second.ToCrossMwmWeight(); }); LOG(LINFO, ("Leaps finished, elapsed:", timer.ElapsedSeconds(), "seconds, routes found:", foundCount, ", not found:", notFoundCount)); } } // namespace namespace routing { bool BuildRoutingIndex(string const & filename, string const & country, CountryParentNameGetterFn const & countryParentNameGetterFn) { LOG(LINFO, ("Building routing index for", filename)); try { Processor processor(country, countryParentNameGetterFn); processor.ProcessAllFeatures(filename); IndexGraph graph; processor.BuildGraph(graph); FilesContainerW cont(filename, FileWriter::OP_WRITE_EXISTING); auto writer = cont.GetWriter(ROUTING_FILE_TAG); auto const startPos = writer->Pos(); IndexGraphSerializer::Serialize(graph, processor.GetMasks(), *writer); auto const sectionSize = writer->Pos() - startPos; LOG(LINFO, ("Routing section created:", sectionSize, "bytes,", graph.GetNumRoads(), "roads,", graph.GetNumJoints(), "joints,", graph.GetNumPoints(), "points")); return true; } catch (RootException const & e) { LOG(LERROR, ("An exception happened while creating", ROUTING_FILE_TAG, "section:", e.what())); return false; } } /// \brief Serializes all the cross mwm information to |sectionName| of |mwmFile| including: /// * header /// * transitions /// * weight buffers if any template <typename CrossMwmId> void SerializeCrossMwm(string const & mwmFile, string const & sectionName, CrossMwmConnectorPerVehicleType<CrossMwmId> const & connectors, vector<CrossMwmConnectorSerializer::Transition<CrossMwmId>> const & transitions) { FilesContainerW cont(mwmFile, FileWriter::OP_WRITE_EXISTING); auto writer = cont.GetWriter(sectionName); auto const startPos = writer->Pos(); CrossMwmConnectorSerializer::Serialize(transitions, connectors, *writer); auto const sectionSize = writer->Pos() - startPos; LOG(LINFO, ("Cross mwm section generated, size:", sectionSize, "bytes")); } void BuildRoutingCrossMwmSection(string const & path, string const & mwmFile, string const & country, string const & intermediateDir, CountryParentNameGetterFn const & countryParentNameGetterFn, string const & osmToFeatureFile, bool disableCrossMwmProgress) { LOG(LINFO, ("Building cross mwm section for", country)); using CrossMwmId = base::GeoObjectId; CrossMwmConnectorPerVehicleType<CrossMwmId> connectors; vector<CrossMwmConnectorSerializer::Transition<CrossMwmId>> transitions; CalcCrossMwmConnectors(path, mwmFile, intermediateDir, country, countryParentNameGetterFn, osmToFeatureFile, transitions, connectors); // We use leaps for cars only. To use leaps for other vehicle types add weights generation // here and change WorldGraph mode selection rule in IndexRouter::CalculateSubroute. FillWeights(path, mwmFile, country, countryParentNameGetterFn, disableCrossMwmProgress, connectors[static_cast<size_t>(VehicleType::Car)]); CHECK(connectors[static_cast<size_t>(VehicleType::Transit)].IsEmpty(), ()); SerializeCrossMwm(mwmFile, CROSS_MWM_FILE_TAG, connectors, transitions); } void BuildTransitCrossMwmSection(string const & path, string const & mwmFile, string const & country, CountryParentNameGetterFn const & countryParentNameGetterFn, bool experimentalTransit) { LOG(LINFO, ("Building transit cross mwm section for", country)); using CrossMwmId = connector::TransitId; CrossMwmConnectorPerVehicleType<CrossMwmId> connectors; vector<CrossMwmConnectorSerializer::Transition<CrossMwmId>> transitions; CalcCrossMwmConnectors(path, mwmFile, "" /* intermediateDir */, country, countryParentNameGetterFn, "" /* mapping file */, transitions, connectors, experimentalTransit); CHECK(connectors[static_cast<size_t>(VehicleType::Pedestrian)].IsEmpty(), ()); CHECK(connectors[static_cast<size_t>(VehicleType::Bicycle)].IsEmpty(), ()); CHECK(connectors[static_cast<size_t>(VehicleType::Car)].IsEmpty(), ()); SerializeCrossMwm(mwmFile, TRANSIT_CROSS_MWM_FILE_TAG, connectors, transitions); } } // namespace routing
#include "alica_viewer/graphics_view_zoom.h" #include <QApplication> #include <QMouseEvent> #include <QScrollBar> #include <qmath.h> namespace alica { GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view) : QObject(view) , _view(view) { _view->viewport()->installEventFilter(this); _view->setMouseTracking(true); _modifiers = Qt::ControlModifier; _zoomFactorBase = 1.0015; } void GraphicsViewZoom::gentleZoom(double factor) { _view->scale(factor, factor); _view->centerOn(_targetScenePos); QPointF deltaViewportPos = _targetViewportPos - QPointF(_view->viewport()->width() / 2.0, _view->viewport()->height() / 2.0); QPointF viewportCenter = _view->mapFromScene(_targetScenePos) - deltaViewportPos; _view->centerOn(_view->mapToScene(viewportCenter.toPoint())); emit zoomed(); } void GraphicsViewZoom::setModifiers(Qt::KeyboardModifiers modifiers) { _modifiers = modifiers; } void GraphicsViewZoom::setZoomFactorBase(double value) { _zoomFactorBase = value; } bool GraphicsViewZoom::eventFilter(QObject* object, QEvent* event) { if (event->type() == QEvent::MouseMove) { QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); QPointF delta = _targetViewportPos - mouseEvent->pos(); if (qAbs(delta.x()) > 5 || qAbs(delta.y()) > 5) { _targetViewportPos = mouseEvent->pos(); _targetScenePos = _view->mapToScene(mouseEvent->pos()); } } else if (event->type() == QEvent::Wheel) { QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event); if (QApplication::keyboardModifiers() == _modifiers) { if (wheelEvent->orientation() == Qt::Vertical) { double angle = wheelEvent->angleDelta().y(); double factor = qPow(_zoomFactorBase, angle); gentleZoom(factor); return true; } } } Q_UNUSED(object) return false; } } // namespace alica
; ; helloworld.asm ; ; A sample assembly language file. ; ; Written by Greg M. Krsak <greg.krsak@gmail.com>, Feb. 2017 ; ; Processor: 64-bit, Intel or AMD ; Operating System: Windows, XP (Server 2003) or later ; Assembler: NASM ; ; Tested with: ; nasm -f win64 "helloworld.asm" ; golink /console /entry WinMain "helloworld.obj" kernel32.dll user32.dll ; ; For more information about 64-bit Windows programming in general, try these references: ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms632595.aspx ; https://msdn.microsoft.com/en-us/library/7kcdt6fy.aspx ; ; ; DEFINES ; MB_OK equ 0 ; Represents the "OK" button of a message box HWND_DESKTOP equ 0 ; Represents a window handle to the Windows desktop NULL equ 0 ; Defines the value NULL ; ; THE NAME OF THE PROGRAM ENTRY POINT ; global WinMain ; ; REQUIRED OPERATING SYSTEM LIBRARIES: ; ; (kernel32.dll) extern ExitProcess ; API Reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658.aspx ; (user32.dll) extern MessageBoxA ; API Reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505.aspx ; ; DATA ; section .data ; Used to display the message box UserGreeting.title: db "A message for you", NULL UserGreeting.message: db "Hello World!", NULL ; ; CODE ; section .text ; --- Program execution starts here --- WinMain: push rbp ; Prolog mov rbp, rsp ; ; Greet the user mov rcx, HWND_DESKTOP ; Get a window handle to the Windows desktop lea rdx, [UserGreeting.message] ; Get the memory address of the message box text lea r8, [UserGreeting.title] ; Get the memory address of the message box title mov r9d, MB_OK ; Configure the message box to only feature an OK button call MessageBoxA ; Use the Windows API to display a message box mov rsp, rbp ; Epilog pop rbp ; ; Exit the program mov ecx, eax ; Program exit code should equal the result of the MessageBoxA function call ExitProcess ; Use the Windows API to exit the program ; --- Program execution ends here --- ; End of helloworld.asm
; A198401: 8^n+n^8. ; 1,9,320,7073,69632,423393,1941760,7861953,33554432,177264449,1173741824,8804293473,69149458432,550571544609,4399522300160,35186934979457,281479271677952,2251806789442689,18014409529442560,144115205059418913,1152921530206846976,9223372074677635169,73786976349714080000,590295810437016636993,4722366482979720527872,37778931863109749600193,302231454903866120741120,2417851639229540778948833,19342813113834444597297152,154742504910673034608803489,1237940039285380930999124224,9903520314283043052084031233,79228162514264338693055578112,633825300114114702154760220929,5070602400912917607772606726400,40564819207303340850146377962657,324518553658426726785977130483712,2596148429267413814268760644063969,20769187434139310514126333109018880,166153499473114484112981234544303553 mov $1,8 pow $1,$0 pow $0,8 add $0,$1
; A170134: Number of reduced words of length n in Coxeter group on 29 generators S_i with relations (S_i)^2 = (S_i S_j)^38 = I. ; 1,29,812,22736,636608,17825024,499100672,13974818816,391294926848,10956257951744,306775222648832,8589706234167296,240511774556684288,6734329687587160064,188561231252440481792,5279714475068333490176 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,28 lpe mov $0,$2 div $0,28
#bits 16 #d16 5 #d16 7 #addr 6 #d16 4 ; = 0x0005_0007_0000_0000_0000_0000_0004
/*************************************************************************/ /* vset.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/
GymStatues: ; if in a gym and have the corresponding badge, a = GymStatueText2_id and jp PrintPredefTextID ; if in a gym and don’t have the corresponding badge, a = GymStatueText1_id and jp PrintPredefTextID ; else ret call EnableAutoTextBoxDrawing ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ret nz ld hl, .BadgeFlags ld a, [wCurMap] ld b, a .loop ld a, [hli] cp $ff ret z cp b jr z, .match inc hl jr .loop .match ld b, [hl] ld a, [wBeatGymFlags] and b cp b tx_pre_id GymStatueText2 jr z, .haveBadge tx_pre_id GymStatueText1 .haveBadge jp PrintPredefTextID .BadgeFlags: db PEWTER_GYM, %00000001 db CERULEAN_GYM, %00000010 db VERMILION_GYM, %00000100 db CELADON_GYM, %00001000 db FUCHSIA_GYM, %00010000 db SAFFRON_GYM, %00100000 db CINNABAR_GYM, %01000000 db VIRIDIAN_GYM, %10000000 db $ff GymStatueText1: TX_FAR _GymStatueText1 db "@" GymStatueText2: TX_FAR _GymStatueText2 db "@" PrintBenchGuyText: call EnableAutoTextBoxDrawing ld hl, BenchGuyTextPointers ld a, [wCurMap] ld b, a .loop ld a, [hli] cp $ff ret z cp b jr z, .match inc hl inc hl jr .loop .match ld a, [hli] ld b, a ld a, [wPlayerFacingDirection] cp b jr nz, .loop ; player isn't facing left at the bench guy ld a, [hl] jp PrintPredefTextID ; format: db map id, player sprite facing direction, text id of PredefTextIDPointerTable BenchGuyTextPointers: db VIRIDIAN_POKECENTER, SPRITE_FACING_LEFT db_tx_pre ViridianCityPokecenterBenchGuyText db PEWTER_POKECENTER, SPRITE_FACING_LEFT db_tx_pre PewterCityPokecenterBenchGuyText db CERULEAN_POKECENTER, SPRITE_FACING_LEFT db_tx_pre CeruleanCityPokecenterBenchGuyText db LAVENDER_POKECENTER, SPRITE_FACING_LEFT db_tx_pre LavenderCityPokecenterBenchGuyText db VERMILION_POKECENTER, SPRITE_FACING_LEFT db_tx_pre VermilionCityPokecenterBenchGuyText db CELADON_POKECENTER, SPRITE_FACING_LEFT db_tx_pre CeladonCityPokecenterBenchGuyText db CELADON_HOTEL, SPRITE_FACING_LEFT db_tx_pre CeladonCityHotelText db FUCHSIA_POKECENTER, SPRITE_FACING_LEFT db_tx_pre FuchsiaCityPokecenterBenchGuyText db CINNABAR_POKECENTER, SPRITE_FACING_LEFT db_tx_pre CinnabarIslandPokecenterBenchGuyText db SAFFRON_POKECENTER, SPRITE_FACING_LEFT db_tx_pre SaffronCityPokecenterBenchGuyText db MT_MOON_POKECENTER, SPRITE_FACING_LEFT db_tx_pre MtMoonPokecenterBenchGuyText db ROCK_TUNNEL_POKECENTER, SPRITE_FACING_LEFT db_tx_pre RockTunnelPokecenterBenchGuyText db SAFARI_ZONE_REST_HOUSE_2,SPRITE_FACING_LEFT db_tx_pre MtMoonPokecenterBenchGuyText;db_tx_pre UnusedBenchGuyText1 db SAFARI_ZONE_REST_HOUSE_3,SPRITE_FACING_LEFT db_tx_pre MtMoonPokecenterBenchGuyText;db_tx_pre UnusedBenchGuyText2 db SAFARI_ZONE_REST_HOUSE_4,SPRITE_FACING_LEFT db_tx_pre MtMoonPokecenterBenchGuyText;db_tx_pre UnusedBenchGuyText3 db $FF ViridianCityPokecenterBenchGuyText: TX_FAR _ViridianCityPokecenterGuyText db "@" PewterCityPokecenterBenchGuyText: TX_FAR _PewterCityPokecenterGuyText db "@" CeruleanCityPokecenterBenchGuyText: TX_FAR _CeruleanPokecenterGuyText db "@" LavenderCityPokecenterBenchGuyText: TX_FAR _LavenderPokecenterGuyText db "@" MtMoonPokecenterBenchGuyText: TX_FAR _MtMoonPokecenterBenchGuyText db "@" RockTunnelPokecenterBenchGuyText: TX_FAR _RockTunnelPokecenterGuyText db "@" ;UnusedBenchGuyText1: ; TX_FAR _UnusedBenchGuyText1 ; db "@" ;UnusedBenchGuyText2: ; TX_FAR _UnusedBenchGuyText2 ; db "@" ;UnusedBenchGuyText3: ; TX_FAR _UnusedBenchGuyText3 ; db "@" VermilionCityPokecenterBenchGuyText: TX_FAR _VermilionPokecenterGuyText db "@" CeladonCityPokecenterBenchGuyText: TX_FAR _CeladonCityPokecenterGuyText db "@" FuchsiaCityPokecenterBenchGuyText: TX_FAR _FuchsiaCityPokecenterGuyText db "@" CinnabarIslandPokecenterBenchGuyText: TX_FAR _CinnabarPokecenterGuyText db "@" SaffronCityPokecenterBenchGuyText: TX_ASM CheckEvent EVENT_BEAT_SILPH_CO_GIOVANNI ld hl, SaffronCityPokecenterBenchGuyText2 jr nz, .asm_624f2 ld hl, SaffronCityPokecenterBenchGuyText1 .asm_624f2 call PrintText jp TextScriptEnd SaffronCityPokecenterBenchGuyText1: TX_FAR _SaffronCityPokecenterGuyText1 db "@" SaffronCityPokecenterBenchGuyText2: TX_FAR _SaffronCityPokecenterGuyText2 db "@" CeladonCityHotelText: TX_FAR _CeladonCityHotelText db "@" ret UnusedPredefText: db "@" PrintBookcaseText: call EnableAutoTextBoxDrawing tx_pre_jump BookcaseText BookcaseText: TX_FAR _BookcaseText db "@" OpenPokemonCenterPC: ld a, [wPlayerFacingDirection] cp SPRITE_FACING_UP ; check to see if player is facing up ret nz call EnableAutoTextBoxDrawing ld a, $1 ld [wAutoTextBoxDrawingControl], a tx_pre_jump PokemonCenterPCText PokemonCenterPCText: TX_POKECENTER_PC
#include "sendcoinsentry.h" #include "ui_sendcoinsentry.h" #include "guiutil.h" #include "bitcoinunits.h" #include "addressbookpage.h" #include "walletmodel.h" #include "optionsmodel.h" #include "addresstablemodel.h" #include <QApplication> #include <QClipboard> SendCoinsEntry::SendCoinsEntry(QWidget *parent) : QFrame(parent), ui(new Ui::SendCoinsEntry), model(0) { ui->setupUi(this); #ifdef Q_OS_MAC ui->payToLayout->setSpacing(4); #endif #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); ui->payTo->setPlaceholderText(tr("Enter a radium address (e.g. X8gZqgY4r2RoEdqYk3QsAqFckyf9pRHN6i)")); #endif setFocusPolicy(Qt::TabFocus); setFocusProxy(ui->payTo); GUIUtil::setupAddressWidget(ui->payTo, this); } SendCoinsEntry::~SendCoinsEntry() { delete ui; } void SendCoinsEntry::on_pasteButton_clicked() { // Paste text from clipboard into recipient field ui->payTo->setText(QApplication::clipboard()->text()); } void SendCoinsEntry::on_addressBookButton_clicked() { if(!model) return; AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); dlg.setModel(model->getAddressTableModel()); if(dlg.exec()) { ui->payTo->setText(dlg.getReturnValue()); ui->payAmount->setFocus(); } } void SendCoinsEntry::on_payTo_textChanged(const QString &address) { if(!model) return; // Fill in label from address book, if address has an associated label QString associatedLabel = model->getAddressTableModel()->labelForAddress(address); if(!associatedLabel.isEmpty()) ui->addAsLabel->setText(associatedLabel); } void SendCoinsEntry::setModel(WalletModel *model) { this->model = model; if(model && model->getOptionsModel()) connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); connect(ui->payAmount, SIGNAL(textChanged()), this, SIGNAL(payAmountChanged())); clear(); } void SendCoinsEntry::setRemoveEnabled(bool enabled) { ui->deleteButton->setEnabled(enabled); } void SendCoinsEntry::clear() { ui->payTo->clear(); ui->addAsLabel->clear(); ui->payAmount->clear(); ui->payTo->setFocus(); // update the display unit, to not use the default ("BTC") updateDisplayUnit(); } void SendCoinsEntry::on_deleteButton_clicked() { emit removeEntry(this); } bool SendCoinsEntry::validate() { // Check input validity bool retval = true; if(!ui->payAmount->validate()) { retval = false; } else { if(ui->payAmount->value() <= 0) { // Cannot send 0 coins or less ui->payAmount->setValid(false); retval = false; } } if(!ui->payTo->hasAcceptableInput() || (model && !model->validateAddress(ui->payTo->text()))) { ui->payTo->setValid(false); retval = false; } return retval; } SendCoinsRecipient SendCoinsEntry::getValue() { SendCoinsRecipient rv; rv.address = ui->payTo->text(); rv.label = ui->addAsLabel->text(); rv.amount = ui->payAmount->value(); return rv; } QWidget *SendCoinsEntry::setupTabChain(QWidget *prev) { QWidget::setTabOrder(prev, ui->payTo); QWidget::setTabOrder(ui->payTo, ui->addressBookButton); QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton); QWidget::setTabOrder(ui->pasteButton, ui->deleteButton); QWidget::setTabOrder(ui->deleteButton, ui->addAsLabel); return ui->payAmount->setupTabChain(ui->addAsLabel); } void SendCoinsEntry::setValue(const SendCoinsRecipient &value) { ui->payTo->setText(value.address); ui->addAsLabel->setText(value.label); ui->payAmount->setValue(value.amount); } bool SendCoinsEntry::isClear() { return ui->payTo->text().isEmpty(); } void SendCoinsEntry::setFocus() { ui->payTo->setFocus(); } void SendCoinsEntry::updateDisplayUnit() { if(model && model->getOptionsModel()) { // Update payAmount with the current unit ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); } }
#define _CRT_SECURE_NO_WARNINGS #include "vg_config.h" #include <cstring> #include <iostream> #include <fstream> #include <sstream> #include <algorithm> #include <functional> #include <mochimazui/file.h> #include <mochimazui/string.h> #include <mochimazui/stdio_ext.h> // -------- -------- -------- -------- -------- -------- -------- -------- namespace Mochimazui { namespace PRIVATE { boost::program_options::variables_map g_config_variables; } int init_config(int argc, char *argv[]) { namespace po = boost::program_options; using PRIVATE::g_config_variables; using Mochimazui::parse_command_line_file; po::options_description general_options("General options"); general_options.add_options() ("help", "print help") ("verbose", po::bool_switch(), "verbose output to console") ("gl-debug", po::bool_switch(), "enable GL_DEBUG") ("draw-curve", po::bool_switch(), "draw curve") ("show-fps", po::bool_switch(), "show fps") ("benchmark", po::bool_switch(), "benchmark") ("step-timing", po::bool_switch(), "step timing") ("attach-timing-to", po::value<std::string>()->default_value(""), "") ("merge-path", po::bool_switch(), "") ("minimal-ui", po::bool_switch(), "produce help message") ("v-flip", po::bool_switch(), "") ("count-pixel", po::bool_switch(), "") ("attach-pixel-count-to", po::value<std::string>()->default_value(""), "") ("animation", po::bool_switch(), "run chrod animation") ; po::options_description io_options("Input/output options"); io_options.add_options() ("file-index", po::value<std::string>()->multitoken(), "file index") ("input-name", po::value<std::string>()->default_value(""), "") ("input-file,i", po::value<std::string>(), "input file") ("input-width", po::value<int>()->default_value(0), "") ("input-height", po::value<int>()->default_value(0), "") ("window-width", po::value<int>()->default_value(1200), "") ("window-height", po::value<int>()->default_value(1024), "") ("fit-to-vg", po::bool_switch(), "") ("fit-to-window", po::bool_switch(), "") ("save-output-file", po::bool_switch(), "") ("output-file,o", po::value<std::string>()->default_value(""), "input file") ("output-width", po::value<int>()->default_value(0), "") ("output-height", po::value<int>()->default_value(0), "") ("fix-output-size", po::bool_switch(), "") ; po::options_description rasterizer_options("Rasterizer options"); rasterizer_options.add_options() ("c-m-cs", po::bool_switch(), "cut, mask table, comb-like scanline") ("lrgb", po::bool_switch(), "") ("srgb", po::bool_switch(), "") ("samples", po::value<int>()->default_value(32), "") ("ms-output", po::bool_switch(), "") ("reserve-ink", po::value<int>()->default_value(0), "reserve ink") ("tiger-clip", po::bool_switch(), "") ("break-before-gl", po::bool_switch(), "break before gl step") ("a128", po::bool_switch(), "align alpha value to 1/128") ; po::options_description all_options; all_options.add(general_options).add(io_options).add(rasterizer_options); if (argc == 1) { po::store(parse_command_line_file<char>("vg_default.cfg", all_options), g_config_variables); } else { po::store(po::parse_command_line(argc, argv, all_options), g_config_variables); } po::notify(g_config_variables); if (g_config_variables.count("help")) { printf("\nLoads \"vg_default.cfg\" by default.\n"); printf("Using command line argument will skip config file loading.\n"); std::cout << all_options << "\n"; return -1; } return 0; } }
//================================================================================================= /*! // \file src/mtl/TMat3Vec3Mult.cpp // \brief Source file for the MTL 3D transpose matrix/vector multiplication kernel // // Copyright (C) 2012-2017 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <iostream> #include <vector> #include <boost/numeric/mtl/mtl.hpp> #include <blaze/util/Timing.h> #include <blazemark/mtl/init/Dense2D.h> #include <blazemark/mtl/init/DenseVector.h> #include <blazemark/mtl/TMat3Vec3Mult.h> #include <blazemark/system/Config.h> namespace blazemark { namespace mtl { //================================================================================================= // // KERNEL FUNCTIONS // //================================================================================================= //************************************************************************************************* /*!\brief MTL 3-dimensional transpose matrix/vector multiplication kernel. // // \param N The number of 3D vectors to be computed. // \param steps The number of iteration steps to perform. // \return Minimum runtime of the kernel function. // // This kernel function implements the 3-dimensional transpose matrix/vector multiplication by // means of the MTL functionality. */ double tmat3vec3mult( size_t N, size_t steps ) { using ::blazemark::element_t; using col_major = ::mtl::tag::col_major; using parameters = ::mtl::mat::parameters<col_major>; using dense2D = ::mtl::dense2D<element_t,parameters>; using dense_vector = ::mtl::dense_vector<element_t>; ::blaze::setSeed( seed ); ::std::vector<dense2D> A( N ); ::std::vector<dense_vector> a( N ), b( N ); ::blaze::timing::WcTimer timer; for( size_t i=0UL; i<N; ++i ) { A[i].change_dim( 3UL, 3UL ); a[i].change_dim( 3UL ); b[i].change_dim( 3UL ); init( A[i] ); init( a[i] ); } for( size_t i=0UL; i<N; ++i ) { b[i] = A[i] * a[i]; } for( size_t rep=0UL; rep<reps; ++rep ) { timer.start(); for( size_t step=0UL, i=0UL; step<steps; ++step, ++i ) { if( i == N ) i = 0UL; b[i] = A[i] * a[i]; } timer.end(); for( size_t i=0UL; i<N; ++i ) if( b[i][0] < element_t(0) ) std::cerr << " Line " << __LINE__ << ": ERROR detected!!!\n"; if( timer.last() > maxtime ) break; } const double minTime( timer.min() ); const double avgTime( timer.average() ); if( minTime * ( 1.0 + deviation*0.01 ) < avgTime ) std::cerr << " MTL kernel 'tmat3vec3mult': Time deviation too large!!!\n"; return minTime; } //************************************************************************************************* } // namespace mtl } // namespace blazemark
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft import six %> <%docstring>lock(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str Invokes the syscall lock. See 'man 2 lock' for more information. Arguments: vararg(int): vararg Returns: long </%docstring> <%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> <% abi = pwnlib.abi.ABI.syscall() stack = abi.stack regs = abi.register_arguments[1:] allregs = pwnlib.shellcraft.registers.current() can_pushstr = [] can_pushstr_array = [] argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] # Load all of the arguments into their destination registers / stack slots. register_arguments = dict() stack_arguments = collections.OrderedDict() string_arguments = dict() dict_arguments = dict() array_arguments = dict() syscall_repr = [] for name, arg in zip(argument_names, argument_values): if arg is not None: syscall_repr.append('%s=%r' % (name, arg)) # If the argument itself (input) is a register... if arg in allregs: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[index] = arg # The argument is not a register. It is a string value, and we # are expecting a string value elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): if isinstance(arg, six.text_type): arg = arg.encode('utf-8') string_arguments[name] = arg # The argument is not a register. It is a dictionary, and we are # expecting K:V paris. elif name in can_pushstr_array and isinstance(arg, dict): array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] # The arguent is not a register. It is a list, and we are expecting # a list of arguments. elif name in can_pushstr_array and isinstance(arg, (list, tuple)): array_arguments[name] = arg # The argument is not a register, string, dict, or list. # It could be a constant string ('O_RDONLY') for an integer argument, # an actual integer value, or a constant. else: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[target] = arg # Some syscalls have different names on various architectures. # Determine which syscall number to use for the current architecture. for syscall in ['SYS_lock']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* lock(${', '.join(syscall_repr)}) */ %for name, arg in string_arguments.items(): ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} %endfor %for name, arg in array_arguments.items(): ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} %endfor %for name, arg in stack_arguments.items(): ${pwnlib.shellcraft.push(arg)} %endfor ${pwnlib.shellcraft.setregs(register_arguments)} ${pwnlib.shellcraft.syscall(syscall)}
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r8 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x5ef9, %r11 nop sub $52351, %r8 movw $0x6162, (%r11) nop nop nop nop nop xor $18058, %r12 lea addresses_WC_ht+0x18d9, %rdx nop nop nop nop sub %rbp, %rbp movw $0x6162, (%rdx) nop nop nop nop nop inc %rdx lea addresses_WC_ht+0x12b09, %rdx nop nop and %rdi, %rdi movups (%rdx), %xmm4 vpextrq $0, %xmm4, %r11 nop nop nop nop cmp %r11, %r11 lea addresses_UC_ht+0x6fe7, %rbp nop nop inc %r13 movb $0x61, (%rbp) xor %r8, %r8 lea addresses_WC_ht+0xaa49, %rdx xor $28540, %r8 mov $0x6162636465666768, %r13 movq %r13, %xmm5 vmovups %ymm5, (%rdx) nop nop nop nop nop xor $25577, %rbp lea addresses_WT_ht+0x8a49, %rbp nop nop add %r12, %r12 mov $0x6162636465666768, %r8 movq %r8, %xmm1 movups %xmm1, (%rbp) add %r11, %r11 lea addresses_A_ht+0x8249, %r13 nop nop dec %rdi movw $0x6162, (%r13) nop sub $40790, %r13 lea addresses_A_ht+0xa3a9, %rsi lea addresses_A_ht+0xba49, %rdi inc %r12 mov $24, %rcx rep movsq nop nop inc %r13 lea addresses_UC_ht+0x18d79, %rsi lea addresses_A_ht+0x16a49, %rdi nop nop nop nop nop add %r12, %r12 mov $16, %rcx rep movsw nop nop nop nop and $5071, %rsi lea addresses_WC_ht+0x8591, %rbp nop nop nop and %rcx, %rcx movb (%rbp), %r8b nop nop nop sub %rdi, %rdi lea addresses_normal_ht+0x13599, %rcx clflush (%rcx) nop add $62670, %rsi movb $0x61, (%rcx) nop nop xor %rsi, %rsi lea addresses_UC_ht+0x1bfc9, %rbp clflush (%rbp) nop nop nop dec %rcx vmovups (%rbp), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $1, %xmm5, %r13 nop nop xor $15986, %rsi lea addresses_A_ht+0x173b9, %rcx add %rsi, %rsi movb (%rcx), %dl nop nop nop nop add %rsi, %rsi lea addresses_WC_ht+0x14c49, %rdx clflush (%rdx) xor %rcx, %rcx mov $0x6162636465666768, %r13 movq %r13, %xmm5 vmovups %ymm5, (%rdx) nop nop cmp %r11, %r11 lea addresses_WT_ht+0x19649, %rdi nop nop nop nop nop xor %rsi, %rsi mov (%rdi), %dx nop nop dec %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r8 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r15 push %rax push %rdi // Faulty Load lea addresses_normal+0xb249, %r11 nop dec %rdi mov (%r11), %r10w lea oracles, %rax and $0xff, %r10 shlq $12, %r10 mov (%rax,%r10,1), %r10 pop %rdi pop %rax pop %r15 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_normal', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_normal', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 2, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WT_ht', 'same': True, 'size': 16, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 2, 'congruent': 10, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 32, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 9, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
;; ;; Copyright (c) 2017-2020, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; %define SHA384 %include "avx512/mb_mgr_hmac_sha_512_flush_avx512.asm"
; ; Philips VG-5000 pseudo graphics routines ; Version for the 2x3 graphics symbols ; ; Stefano Bodrato 2015 ; ; ; Get pixel at (x,y) coordinate. ; ; ; $Id: pointxy.asm,v 1.1 2015/10/09 13:02:43 stefano Exp $ ; INCLUDE "graphics/grafix.inc" PUBLIC pointxy EXTERN div3 EXTERN coords EXTERN base_graphics .pointxy ld a,h cp maxx ret nc ld a,l cp maxy ret nc ; y0 out of range ld (coords),hl push bc push de push hl ld c,a ; y ld b,h ; x push bc ld hl,div3 ld d,0 ld e,c inc e add hl,de ld a,(hl) srl b ; x/2 ld l,b ld b,a ; y/3 and a jr z,zrow add 7 ; bias the default scroll register settings and so on.. .zrow ld h,a ; y/3 ;--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- push bc call $98 ; direct read access pop bc ;--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- pop hl ; restore x,y (y=h, x=l) ld a,l sub b sub b sub b ; we get the remainder of y/3 ld l,a ld a,16 ; the pixel we want to draw jr z,iszero bit 0,l jr nz,is1 srl a srl a .is1 srl a srl a .iszero bit 0,h jr z,evenrow add a,a ; move down the bit .evenrow and d pop hl pop de pop bc ret
push 5.5 push 3.3 stack div print
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %r8 push %r9 push %rax push %rbp push %rbx lea addresses_UC_ht+0x1253c, %r15 nop sub $42158, %rax mov (%r15), %r9d nop nop nop nop nop cmp %rbp, %rbp lea addresses_WT_ht+0x1de20, %r9 nop cmp $8348, %rbp movw $0x6162, (%r9) nop nop nop cmp $59915, %r15 lea addresses_normal_ht+0xea90, %r8 nop nop cmp %r11, %r11 mov $0x6162636465666768, %r15 movq %r15, %xmm4 vmovups %ymm4, (%r8) inc %r15 lea addresses_A_ht+0xe3a0, %rbp nop inc %r11 and $0xffffffffffffffc0, %rbp movaps (%rbp), %xmm6 vpextrq $0, %xmm6, %rbx nop nop cmp $21817, %r11 lea addresses_D_ht+0xd580, %rax nop nop sub $1121, %r11 mov (%rax), %rbx nop nop nop xor %r9, %r9 lea addresses_UC_ht+0x6c20, %rbp nop nop add $18378, %r11 movups (%rbp), %xmm0 vpextrq $0, %xmm0, %r9 nop and $28241, %rax pop %rbx pop %rbp pop %rax pop %r9 pop %r8 pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r13 push %r15 push %rbp push %rcx push %rdi push %rdx push %rsi // Load lea addresses_UC+0x1c134, %r13 and $63249, %rcx movups (%r13), %xmm5 vpextrq $1, %xmm5, %rdi nop nop nop add %rbp, %rbp // Store lea addresses_UC+0x16f20, %rdi nop nop nop nop nop dec %rsi movl $0x51525354, (%rdi) sub %rdi, %rdi // Load lea addresses_A+0x1de14, %rcx sub %rdx, %rdx mov (%rcx), %edi cmp %rbp, %rbp // Store mov $0x65f6eb0000000920, %rdx nop nop nop nop nop inc %r15 movb $0x51, (%rdx) nop nop nop nop xor %r13, %r13 // Faulty Load lea addresses_A+0x1f220, %rsi nop nop nop nop add %rdi, %rdi mov (%rsi), %r13 lea oracles, %r15 and $0xff, %r13 shlq $12, %r13 mov (%r15,%r13,1), %r13 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r15 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_A'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2, 'same': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 8, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_A'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 8, 'same': False, 'type': 'addresses_NC'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_A'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 5, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 5, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7, 'same': True, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A104674: a(n) = binomial(n+6, 6) * binomial(n+11, n). ; Submitted by Jon Maiga ; 1,84,2184,30576,286650,2018016,11435424,54609984,226972746,840639800,2824549728,8730426432,25099975992,67725379008,172768824000,419252346240,972796459635,2167754048460,4656656844840,9674494830000,19494107082450,38192536324800,72913023892800,135902157955200,247738308772500,442361524144176,774787048205184,1332761259875584,2254134477799776,3752423625350400,6153974745574656,9951380597942784,15879449118201669,25022162246863236,38961844329025800,59985337473096048,91366555688187962,137750599664295072 mov $2,$0 add $2,6 bin $2,$0 add $0,11 bin $0,11 mul $0,$2
#include "common/quic/client_connection_factory_impl.h" #include "common/quic/quic_transport_socket_factory.h" namespace Envoy { namespace Quic { const Envoy::Ssl::ClientContextConfig& getConfig(Network::TransportSocketFactory& transport_socket_factory) { auto* quic_socket_factory = dynamic_cast<QuicClientTransportSocketFactory*>(&transport_socket_factory); ASSERT(quic_socket_factory != nullptr); return quic_socket_factory->clientContextConfig(); } PersistentQuicInfoImpl::PersistentQuicInfoImpl( Event::Dispatcher& dispatcher, Network::TransportSocketFactory& transport_socket_factory, Stats::Scope& stats_scope, TimeSource& time_source, Network::Address::InstanceConstSharedPtr server_addr) : conn_helper_(dispatcher), alarm_factory_(dispatcher, *conn_helper_.GetClock()), server_id_{getConfig(transport_socket_factory).serverNameIndication(), static_cast<uint16_t>(server_addr->ip()->port()), false}, crypto_config_( std::make_unique<quic::QuicCryptoClientConfig>(std::make_unique<EnvoyQuicProofVerifier>( stats_scope, getConfig(transport_socket_factory), time_source))) { quiche::FlagRegistry::getInstance(); } namespace { // TODO(alyssawilk, danzh2010): This is mutable static info that is required for the QUICHE code. // This was preexisting but should either be removed or potentially moved inside // PersistentQuicInfoImpl. struct StaticInfo { quic::QuicConfig quic_config_; quic::QuicClientPushPromiseIndex push_promise_index_; static StaticInfo& get() { MUTABLE_CONSTRUCT_ON_FIRST_USE(StaticInfo); } }; } // namespace std::unique_ptr<Network::ClientConnection> createQuicNetworkConnection(Http::PersistentQuicInfo& info, Event::Dispatcher& dispatcher, Network::Address::InstanceConstSharedPtr server_addr, Network::Address::InstanceConstSharedPtr local_addr) { // This flag fix a QUICHE issue which may crash Envoy during connection close. SetQuicReloadableFlag(quic_single_ack_in_packet2, true); PersistentQuicInfoImpl* info_impl = reinterpret_cast<PersistentQuicInfoImpl*>(&info); auto connection = std::make_unique<EnvoyQuicClientConnection>( quic::QuicUtils::CreateRandomConnectionId(), server_addr, info_impl->conn_helper_, info_impl->alarm_factory_, quic::ParsedQuicVersionVector{info_impl->supported_versions_[0]}, local_addr, dispatcher, nullptr); auto& static_info = StaticInfo::get(); auto ret = std::make_unique<EnvoyQuicClientSession>( static_info.quic_config_, info_impl->supported_versions_, std::move(connection), info_impl->server_id_, info_impl->crypto_config_.get(), &static_info.push_promise_index_, dispatcher, 0); return ret; } } // namespace Quic } // namespace Envoy
; Moises Campos Zepeda ; 11-10-2020 ; IE0623: Microprocesadores ; Tarea 4: teclado matricial #include registers.inc ; ***************************************************************************** ; Data Structures ; ***************************************************************************** CR: equ $0D LF: equ $0A FIN: equ $0 org $1000 ; Size of Num_Array MAX_TCL: db 5 Tecla: ds 1 Tecla_IN: ds 1 Cont_Reb: ds 1 Cont_TCL: ds 1 Patron: ds 1 Banderas: ds 1 ; Array of pressed buttons, by default $FF Num_Array: ds 5 ; Key values Teclas: db $01,$02,$03,$04,$05,$06,$07,$08,$09,$0B,$00,$0E org $1200 ; DELETE OR COMMENT MSG0: fcc "Tecla: %X" fcb CR,LF,CR,LF,FIN MSG1: fcc "Array Ok" fcb CR,CR,LF,FIN MSG2: fcc "Reset Array" fcb CR,CR,LF,FIN ; ***************************************************************************** ; Interruption Vector Relocation ; ***************************************************************************** org $3E70 ;org $FFF0 dw RTI_ISR org $3E4C ;org $FFCC dw PHO_ISR ; ***************************************************************************** ; HW Config ; ***************************************************************************** org $2000 ; Key wakeup PHO bset PIEH,$01 bset PIFH,$01 ; Enable pullup resistors on Port A bset PUCR,$01 ; RTI bset CRGINT,$80 ; Set imputs and outputs movb #$F0, DDRA ; T = 11 ms movb $17,RTICTL cli ; ***************************************************************************** ; Main Program ; ***************************************************************************** lds #$3BFF movb #$FF, TECLA movb #$FF, TECLA_IN ldaa MAX_TCL ldx #Num_Array-1 ARRAY_RST: movb #$FF,A,X dbne A,ARRAY_RST clr Cont_Reb clr Cont_TCL clr Patron clr Banderas MAIN_LOOP: brset Banderas,$04,MAIN_LOOP jsr TAREA_TECLADO bra MAIN_LOOP ; ***************************************************************************** ; TAREA_TECLADO Subroutine ; ***************************************************************************** TAREA_TECLADO: tst Cont_Reb bne RETURN_TT ;Go to MUX_TECLADO jsr MUX_TECLADO ldaa Tecla cmpa #$FF beq CHECK_ARRAY brclr Banderas,$02,REBOTES cmpa Tecla_IN bne TCL_NOT_READY ; TCL_LISTA = 1 bset Banderas,$01 jmp RETURN_TT TCL_NOT_READY: movb #$FF,TECLA movb #$FF,TECLA_IN bclr Banderas, $03 jmp RETURN_TT REBOTES: movb TECLA,TECLA_IN ; TCL_LEIDA = 1 bset Banderas,$02 movb #10,Cont_Reb jmp RETURN_TT CHECK_ARRAY: brclr Banderas,$01,RETURN_TT ; Print Tecla value ldab Tecla_IN clra pshd ldx #0 ldd #MSG0 jsr [PrintF,X] leas 2,SP ;print ends bclr Banderas, $03 jsr FORMAR_ARRAY RETURN_TT: rts ; ***************************************************************************** ; MUX_TECLADO Subroutine ; ***************************************************************************** MUX_TECLADO: clrb ldx #Teclas movb #$EF,Patron READ_LOOP: movb Patron,PORTA ; Delay nop nop nop nop nop nop nop nop nop nop nop nop nop ; check col 1 of port A brclr PORTA,$02,WR_TECLA incb ; check col 2 of port A brclr PORTA,$04,WR_TECLA incb ; check col 3 of port A brclr PORTA,$08,WR_TECLA incb lsl Patron ldaa #$F0 cmpa Patron bne READ_LOOP ; If no key was pressed movb #$FF,Tecla rts ; If a key was pressed WR_TECLA: movb B,X,Tecla rts ; ***************************************************************************** ; FORMAR_ARRAY Subroutine ; ***************************************************************************** FORMAR_ARRAY: ldx #Num_Array ldaa TECLA_IN ldab Cont_TCL ; check for full array cmpb MAX_TCL beq CHECK_B cmpb #0 beq CATCH_EORB cmpa #$0B beq COMPARE_B cmpa #$0E beq COMPARE_E jmp ADD_ARRAY CHECK_B: cmpa #$0B bne CHECK_E COMPARE_B: decb stab Cont_TCL movb #$FF,B,X jmp RETURN_FA CHECK_E: cmpa #$0E bne RETURN_FA COMPARE_E: ; ARRAY_OK = 1 bset Banderas,$04 ; Print Array ok ldx #0 ldd #MSG1 jsr [PrintF,X] clr Cont_TCL jmp RETURN_FA CATCH_EORB: ; catch B cmpa #$0B beq RETURN_FA ; catch E cmpa #$0E beq RETURN_FA ADD_ARRAY: staa B,X inc Cont_TCL RETURN_FA rts ; ***************************************************************************** ; RTI_ISR Subroutine ; ***************************************************************************** RTI_ISR: bset CRGFLG, $80 tst Cont_Reb beq RETURN_RTI dec Cont_Reb RETURN_RTI: rti ; ***************************************************************************** ; PHO_ISR Subroutine ; ***************************************************************************** PHO_ISR: bset PIFH,$01 ldx #Num_Array brclr Banderas,$04,RETURN_PHO bclr Banderas,$04 ldaa MAX_TCL clr Cont_TCL LOOP_P: ldab 1,X+ cmpb #$FF beq RETURN_PHO movb #$FF,-1,X dbne A,LOOP_P ; Print Array reset msg ldx #0 ldd #MSG2 jsr [PrintF,X] RETURN_PHO: rti
/* $Id: mp-r0drv-darwin.cpp $ */ /** @file * IPRT - Multiprocessor, Ring-0 Driver, Darwin. */ /* * Copyright (C) 2008-2017 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * The contents of this file may alternatively be used under the terms * of the Common Development and Distribution License Version 1.0 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the * VirtualBox OSE distribution, in which case the provisions of the * CDDL are applicable instead of those of the GPL. * * You may elect to license modified versions of this file under the * terms and conditions of either the GPL or the CDDL or both. */ /********************************************************************************************************************************* * Header Files * *********************************************************************************************************************************/ #include "the-darwin-kernel.h" #include "internal/iprt.h" #include <iprt/mp.h> #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) # include <iprt/asm-amd64-x86.h> #endif #include <iprt/cpuset.h> #include <iprt/err.h> #include "r0drv/mp-r0drv.h" /********************************************************************************************************************************* * Global Variables * *********************************************************************************************************************************/ static int32_t volatile g_cMaxCpus = -1; static int rtMpDarwinInitMaxCpus(void) { IPRT_DARWIN_SAVE_EFL_AC(); int32_t cCpus = -1; size_t oldLen = sizeof(cCpus); int rc = sysctlbyname("hw.ncpu", &cCpus, &oldLen, NULL, NULL); if (rc) { printf("IPRT: sysctlbyname(hw.ncpu) failed with rc=%d!\n", rc); cCpus = 64; /* whatever */ } ASMAtomicWriteS32(&g_cMaxCpus, cCpus); IPRT_DARWIN_RESTORE_EFL_AC(); return cCpus; } DECLINLINE(int) rtMpDarwinMaxCpus(void) { int cCpus = g_cMaxCpus; if (RT_UNLIKELY(cCpus <= 0)) return rtMpDarwinInitMaxCpus(); return cCpus; } RTDECL(RTCPUID) RTMpCpuId(void) { return cpu_number(); } RTDECL(int) RTMpCurSetIndex(void) { return cpu_number(); } RTDECL(int) RTMpCurSetIndexAndId(PRTCPUID pidCpu) { return *pidCpu = cpu_number(); } RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu) { return idCpu < RTCPUSET_MAX_CPUS ? (int)idCpu : -1; } RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu) { return (unsigned)iCpu < RTCPUSET_MAX_CPUS ? (RTCPUID)iCpu : NIL_RTCPUID; } RTDECL(RTCPUID) RTMpGetMaxCpuId(void) { return rtMpDarwinMaxCpus() - 1; } RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu) { return idCpu < RTCPUSET_MAX_CPUS && idCpu < (RTCPUID)rtMpDarwinMaxCpus(); } RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet) { RTCPUID idCpu; RTCpuSetEmpty(pSet); idCpu = RTMpGetMaxCpuId(); do { if (RTMpIsCpuPossible(idCpu)) RTCpuSetAdd(pSet, idCpu); } while (idCpu-- > 0); return pSet; } RTDECL(RTCPUID) RTMpGetCount(void) { return rtMpDarwinMaxCpus(); } RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet) { /** @todo darwin R0 MP */ return RTMpGetSet(pSet); } RTDECL(RTCPUID) RTMpGetOnlineCount(void) { /** @todo darwin R0 MP */ return RTMpGetCount(); } RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu) { /** @todo darwin R0 MP */ return RTMpIsCpuPossible(idCpu); } RTDECL(uint32_t) RTMpGetCurFrequency(RTCPUID idCpu) { /** @todo darwin R0 MP (rainy day) */ RT_NOREF(idCpu); return 0; } RTDECL(uint32_t) RTMpGetMaxFrequency(RTCPUID idCpu) { /** @todo darwin R0 MP (rainy day) */ RT_NOREF(idCpu); return 0; } RTDECL(bool) RTMpIsCpuWorkPending(void) { /** @todo (not used on non-Windows platforms yet). */ return false; } /** * Wrapper between the native darwin per-cpu callback and PFNRTWORKER * for the RTMpOnAll API. * * @param pvArg Pointer to the RTMPARGS package. */ static void rtmpOnAllDarwinWrapper(void *pvArg) { PRTMPARGS pArgs = (PRTMPARGS)pvArg; IPRT_DARWIN_SAVE_EFL_AC(); pArgs->pfnWorker(cpu_number(), pArgs->pvUser1, pArgs->pvUser2); IPRT_DARWIN_RESTORE_EFL_AC(); } RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2) { RT_ASSERT_INTS_ON(); IPRT_DARWIN_SAVE_EFL_AC(); RTMPARGS Args; Args.pfnWorker = pfnWorker; Args.pvUser1 = pvUser1; Args.pvUser2 = pvUser2; Args.idCpu = NIL_RTCPUID; Args.cHits = 0; mp_rendezvous_no_intrs(rtmpOnAllDarwinWrapper, &Args); IPRT_DARWIN_RESTORE_EFL_AC(); return VINF_SUCCESS; } /** * Wrapper between the native darwin per-cpu callback and PFNRTWORKER * for the RTMpOnOthers API. * * @param pvArg Pointer to the RTMPARGS package. */ static void rtmpOnOthersDarwinWrapper(void *pvArg) { PRTMPARGS pArgs = (PRTMPARGS)pvArg; RTCPUID idCpu = cpu_number(); if (pArgs->idCpu != idCpu) { IPRT_DARWIN_SAVE_EFL_AC(); pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2); IPRT_DARWIN_RESTORE_EFL_AC(); } } RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2) { RT_ASSERT_INTS_ON(); IPRT_DARWIN_SAVE_EFL_AC(); RTMPARGS Args; Args.pfnWorker = pfnWorker; Args.pvUser1 = pvUser1; Args.pvUser2 = pvUser2; Args.idCpu = RTMpCpuId(); Args.cHits = 0; mp_rendezvous_no_intrs(rtmpOnOthersDarwinWrapper, &Args); IPRT_DARWIN_RESTORE_EFL_AC(); return VINF_SUCCESS; } /** * Wrapper between the native darwin per-cpu callback and PFNRTWORKER * for the RTMpOnSpecific API. * * @param pvArg Pointer to the RTMPARGS package. */ static void rtmpOnSpecificDarwinWrapper(void *pvArg) { PRTMPARGS pArgs = (PRTMPARGS)pvArg; RTCPUID idCpu = cpu_number(); if (pArgs->idCpu == idCpu) { IPRT_DARWIN_SAVE_EFL_AC(); pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2); ASMAtomicIncU32(&pArgs->cHits); IPRT_DARWIN_RESTORE_EFL_AC(); } } RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2) { RT_ASSERT_INTS_ON(); IPRT_DARWIN_SAVE_EFL_AC(); RTMPARGS Args; Args.pfnWorker = pfnWorker; Args.pvUser1 = pvUser1; Args.pvUser2 = pvUser2; Args.idCpu = idCpu; Args.cHits = 0; mp_rendezvous_no_intrs(rtmpOnSpecificDarwinWrapper, &Args); IPRT_DARWIN_RESTORE_EFL_AC(); return Args.cHits == 1 ? VINF_SUCCESS : VERR_CPU_NOT_FOUND; } RTDECL(int) RTMpPokeCpu(RTCPUID idCpu) { RT_ASSERT_INTS_ON(); if (g_pfnR0DarwinCpuInterrupt == NULL) return VERR_NOT_SUPPORTED; IPRT_DARWIN_SAVE_EFL_AC(); /* paranoia */ g_pfnR0DarwinCpuInterrupt(idCpu); IPRT_DARWIN_RESTORE_EFL_AC(); return VINF_SUCCESS; } RTDECL(bool) RTMpOnAllIsConcurrentSafe(void) { return true; }
.size 8000 .text@48 ld a, ff ldff(45), a jp lstatint .text@100 jp lbegin .data@143 80 .text@150 lbegin: ld a, ff ldff(45), a ld b, 03 call lwaitly_b ld a, 40 ldff(41), a ld a, 02 ldff(ff), a ei ld a, b inc a inc a ldff(45), a ld c, 41 .text@1000 lstatint: nop .text@1064 ld a, ff ldff(c), a xor a, a ldff(0f), a ld a, df ldff(c), a ldff a, (0f) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f