Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(23)

Side by Side Diff: src/pkg/runtime/sys_darwin_386.s

Issue 160200044: [dev.power64] code review 160200044: build: merge default into dev.power64 (Closed)
Patch Set: diff -r be0c14f62257b42485019e9e1db23cf40d2e249f https://code.google.com/p/go Created 10 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/symtab.goc ('k') | src/pkg/runtime/sys_darwin_amd64.s » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // System calls and other sys.stuff for 386, Darwin 5 // System calls and other sys.stuff for 386, Darwin
6 // See http://fxr.watson.org/fxr/source/bsd/kern/syscalls.c?v=xnu-1228 6 // See http://fxr.watson.org/fxr/source/bsd/kern/syscalls.c?v=xnu-1228
7 // or /usr/include/sys/syscall.h (on a Mac) for system call numbers. 7 // or /usr/include/sys/syscall.h (on a Mac) for system call numbers.
8 8
9 #include "zasm_GOOS_GOARCH.h" 9 #include "zasm_GOOS_GOARCH.h"
10 #include "../../cmd/ld/textflag.h" 10 #include "textflag.h"
11 11
12 // Exit the entire program (like C exit) 12 // Exit the entire program (like C exit)
13 TEXT runtime·exit(SB),NOSPLIT,$0 13 TEXT runtime·exit(SB),NOSPLIT,$0
14 MOVL $1, AX 14 MOVL $1, AX
15 INT $0x80 15 INT $0x80
16 MOVL $0xf1, 0xf1 // crash 16 MOVL $0xf1, 0xf1 // crash
17 RET 17 RET
18 18
19 // Exit this OS thread (like pthread_exit, which eventually 19 // Exit this OS thread (like pthread_exit, which eventually
20 // calls __bsdthread_terminate). 20 // calls __bsdthread_terminate).
21 TEXT runtime·exit1(SB),NOSPLIT,$0 21 TEXT runtime·exit1(SB),NOSPLIT,$0
22 MOVL $361, AX 22 MOVL $361, AX
23 INT $0x80 23 INT $0x80
24 JAE 2(PC) 24 JAE 2(PC)
25 MOVL $0xf1, 0xf1 // crash 25 MOVL $0xf1, 0xf1 // crash
26 RET 26 RET
27 27
28 TEXT runtime·open(SB),NOSPLIT,$0 28 TEXT runtime·open(SB),NOSPLIT,$0
29 MOVL $5, AX 29 MOVL $5, AX
30 INT $0x80 30 INT $0x80
31 MOVL AX, ret+12(FP)
31 RET 32 RET
32 33
33 TEXT runtime·close(SB),NOSPLIT,$0 34 TEXT runtime·close(SB),NOSPLIT,$0
34 MOVL $6, AX 35 MOVL $6, AX
35 INT $0x80 36 INT $0x80
37 MOVL AX, ret+4(FP)
36 RET 38 RET
37 39
38 TEXT runtime·read(SB),NOSPLIT,$0 40 TEXT runtime·read(SB),NOSPLIT,$0
39 MOVL $3, AX 41 MOVL $3, AX
40 INT $0x80 42 INT $0x80
43 MOVL AX, ret+12(FP)
41 RET 44 RET
42 45
43 TEXT runtime·write(SB),NOSPLIT,$0 46 TEXT runtime·write(SB),NOSPLIT,$0
44 MOVL $4, AX 47 MOVL $4, AX
45 INT $0x80 48 INT $0x80
49 MOVL AX, ret+12(FP)
46 RET 50 RET
47 51
48 TEXT runtime·raise(SB),NOSPLIT,$16 52 TEXT runtime·raise(SB),NOSPLIT,$16
49 MOVL $20, AX // getpid 53 MOVL $20, AX // getpid
50 INT $0x80 54 INT $0x80
51 MOVL AX, 4(SP) // pid 55 MOVL AX, 4(SP) // pid
52 MOVL sig+0(FP), AX 56 MOVL sig+0(FP), AX
53 MOVL AX, 8(SP) // signal 57 MOVL AX, 8(SP) // signal
54 MOVL $1, 12(SP) // posix 58 MOVL $1, 12(SP) // posix
55 MOVL $37, AX // kill 59 MOVL $37, AX // kill
56 INT $0x80 60 INT $0x80
57 RET 61 RET
58 62
59 TEXT runtime·mmap(SB),NOSPLIT,$0 63 TEXT runtime·mmap(SB),NOSPLIT,$0
60 MOVL $197, AX 64 MOVL $197, AX
61 INT $0x80 65 INT $0x80
66 MOVL AX, ret+24(FP)
62 RET 67 RET
63 68
64 TEXT runtime·madvise(SB),NOSPLIT,$0 69 TEXT runtime·madvise(SB),NOSPLIT,$0
65 MOVL $75, AX 70 MOVL $75, AX
66 INT $0x80 71 INT $0x80
67 // ignore failure - maybe pages are locked 72 // ignore failure - maybe pages are locked
68 RET 73 RET
69 74
70 TEXT runtime·munmap(SB),NOSPLIT,$0 75 TEXT runtime·munmap(SB),NOSPLIT,$0
71 MOVL $73, AX 76 MOVL $73, AX
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 DIVL CX 204 DIVL CX
200 MOVL AX, sec+0(FP) 205 MOVL AX, sec+0(FP)
201 MOVL $0, sec+4(FP) 206 MOVL $0, sec+4(FP)
202 MOVL DX, nsec+8(FP) 207 MOVL DX, nsec+8(FP)
203 RET 208 RET
204 209
205 // int64 nanotime(void) so really 210 // int64 nanotime(void) so really
206 // void nanotime(int64 *nsec) 211 // void nanotime(int64 *nsec)
207 TEXT runtime·nanotime(SB),NOSPLIT,$0 212 TEXT runtime·nanotime(SB),NOSPLIT,$0
208 CALL runtime·now(SB) 213 CALL runtime·now(SB)
209 » MOVL» ret+0(FP), DI 214 » MOVL» AX, ret_lo+0(FP)
210 » MOVL» AX, 0(DI) 215 » MOVL» DX, ret_hi+4(FP)
211 » MOVL» DX, 4(DI)
212 RET 216 RET
213 217
214 TEXT runtime·sigprocmask(SB),NOSPLIT,$0 218 TEXT runtime·sigprocmask(SB),NOSPLIT,$0
215 MOVL $329, AX // pthread_sigmask (on OS X, sigprocmask==entire proce ss) 219 MOVL $329, AX // pthread_sigmask (on OS X, sigprocmask==entire proce ss)
216 INT $0x80 220 INT $0x80
217 JAE 2(PC) 221 JAE 2(PC)
218 MOVL $0xf1, 0xf1 // crash 222 MOVL $0xf1, 0xf1 // crash
219 RET 223 RET
220 224
221 TEXT runtime·sigaction(SB),NOSPLIT,$0 225 TEXT runtime·sigaction(SB),NOSPLIT,$0
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 MOVL AX, 20(SP) 312 MOVL AX, 20(SP)
309 MOVL $93, AX 313 MOVL $93, AX
310 INT $0x80 314 INT $0x80
311 RET 315 RET
312 316
313 // void bsdthread_create(void *stk, M *mp, G *gp, void (*fn)(void)) 317 // void bsdthread_create(void *stk, M *mp, G *gp, void (*fn)(void))
314 // System call args are: func arg stack pthread flags. 318 // System call args are: func arg stack pthread flags.
315 TEXT runtime·bsdthread_create(SB),NOSPLIT,$32 319 TEXT runtime·bsdthread_create(SB),NOSPLIT,$32
316 MOVL $360, AX 320 MOVL $360, AX
317 // 0(SP) is where the caller PC would be; kernel skips it 321 // 0(SP) is where the caller PC would be; kernel skips it
318 » MOVL» func+12(FP), BX 322 » MOVL» fn+12(FP), BX
319 MOVL BX, 4(SP) // func 323 MOVL BX, 4(SP) // func
320 MOVL mm+4(FP), BX 324 MOVL mm+4(FP), BX
321 MOVL BX, 8(SP) // arg 325 MOVL BX, 8(SP) // arg
322 MOVL stk+0(FP), BX 326 MOVL stk+0(FP), BX
323 MOVL BX, 12(SP) // stack 327 MOVL BX, 12(SP) // stack
324 MOVL gg+8(FP), BX 328 MOVL gg+8(FP), BX
325 MOVL BX, 16(SP) // pthread 329 MOVL BX, 16(SP) // pthread
326 MOVL $0x1000000, 20(SP) // flags = PTHREAD_START_CUSTOM 330 MOVL $0x1000000, 20(SP) // flags = PTHREAD_START_CUSTOM
327 INT $0x80 331 INT $0x80
328 » JAE» 3(PC) 332 » JAE» 4(PC)
329 NEGL AX 333 NEGL AX
334 MOVL AX, ret+16(FP)
330 RET 335 RET
331 MOVL $0, AX 336 MOVL $0, AX
337 MOVL AX, ret+16(FP)
332 RET 338 RET
333 339
334 // The thread that bsdthread_create creates starts executing here, 340 // The thread that bsdthread_create creates starts executing here,
335 // because we registered this function using bsdthread_register 341 // because we registered this function using bsdthread_register
336 // at startup. 342 // at startup.
337 // AX = "pthread" (= g) 343 // AX = "pthread" (= g)
338 // BX = mach thread port 344 // BX = mach thread port
339 // CX = "func" (= fn) 345 // CX = "func" (= fn)
340 // DX = "arg" (= m) 346 // DX = "arg" (= m)
341 // DI = stack top 347 // DI = stack top
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 TEXT runtime·bsdthread_register(SB),NOSPLIT,$40 381 TEXT runtime·bsdthread_register(SB),NOSPLIT,$40
376 MOVL $366, AX 382 MOVL $366, AX
377 // 0(SP) is where kernel expects caller PC; ignored 383 // 0(SP) is where kernel expects caller PC; ignored
378 MOVL $runtime·bsdthread_start(SB), 4(SP) // threadstart 384 MOVL $runtime·bsdthread_start(SB), 4(SP) // threadstart
379 MOVL $0, 8(SP) // wqthread, not used by us 385 MOVL $0, 8(SP) // wqthread, not used by us
380 MOVL $0, 12(SP) // pthsize, not used by us 386 MOVL $0, 12(SP) // pthsize, not used by us
381 MOVL $0, 16(SP) // dummy_value [sic] 387 MOVL $0, 16(SP) // dummy_value [sic]
382 MOVL $0, 20(SP) // targetconc_ptr 388 MOVL $0, 20(SP) // targetconc_ptr
383 MOVL $0, 24(SP) // dispatchqueue_offset 389 MOVL $0, 24(SP) // dispatchqueue_offset
384 INT $0x80 390 INT $0x80
385 » JAE» 3(PC) 391 » JAE» 4(PC)
386 NEGL AX 392 NEGL AX
393 MOVL AX, ret+0(FP)
387 RET 394 RET
388 MOVL $0, AX 395 MOVL $0, AX
396 MOVL AX, ret+0(FP)
389 RET 397 RET
390 398
391 // Invoke Mach system call. 399 // Invoke Mach system call.
392 // Assumes system call number in AX, 400 // Assumes system call number in AX,
393 // caller PC on stack, caller's caller PC next, 401 // caller PC on stack, caller's caller PC next,
394 // and then the system call arguments. 402 // and then the system call arguments.
395 // 403 //
396 // Can be used for BSD too, but we don't, 404 // Can be used for BSD too, but we don't,
397 // because if you use this interface the BSD 405 // because if you use this interface the BSD
398 // system call numbers need an extra field 406 // system call numbers need an extra field
399 // in the high 16 bits that seems to be the 407 // in the high 16 bits that seems to be the
400 // argument count in bytes but is not always. 408 // argument count in bytes but is not always.
401 // INT $0x80 works fine for those. 409 // INT $0x80 works fine for those.
402 TEXT runtime·sysenter(SB),NOSPLIT,$0 410 TEXT runtime·sysenter(SB),NOSPLIT,$0
403 POPL DX 411 POPL DX
404 MOVL SP, CX 412 MOVL SP, CX
405 BYTE $0x0F; BYTE $0x34; // SYSENTER 413 BYTE $0x0F; BYTE $0x34; // SYSENTER
406 // returns to DX with SP set to CX 414 // returns to DX with SP set to CX
407 415
408 TEXT runtime·mach_msg_trap(SB),NOSPLIT,$0 416 TEXT runtime·mach_msg_trap(SB),NOSPLIT,$0
409 MOVL $-31, AX 417 MOVL $-31, AX
410 CALL runtime·sysenter(SB) 418 CALL runtime·sysenter(SB)
419 MOVL AX, ret+28(FP)
411 RET 420 RET
412 421
413 TEXT runtime·mach_reply_port(SB),NOSPLIT,$0 422 TEXT runtime·mach_reply_port(SB),NOSPLIT,$0
414 MOVL $-26, AX 423 MOVL $-26, AX
415 CALL runtime·sysenter(SB) 424 CALL runtime·sysenter(SB)
425 MOVL AX, ret+0(FP)
416 RET 426 RET
417 427
418 TEXT runtime·mach_task_self(SB),NOSPLIT,$0 428 TEXT runtime·mach_task_self(SB),NOSPLIT,$0
419 MOVL $-28, AX 429 MOVL $-28, AX
420 CALL runtime·sysenter(SB) 430 CALL runtime·sysenter(SB)
431 MOVL AX, ret+0(FP)
421 RET 432 RET
422 433
423 // Mach provides trap versions of the semaphore ops, 434 // Mach provides trap versions of the semaphore ops,
424 // instead of requiring the use of RPC. 435 // instead of requiring the use of RPC.
425 436
426 // uint32 mach_semaphore_wait(uint32) 437 // uint32 mach_semaphore_wait(uint32)
427 TEXT runtime·mach_semaphore_wait(SB),NOSPLIT,$0 438 TEXT runtime·mach_semaphore_wait(SB),NOSPLIT,$0
428 MOVL $-36, AX 439 MOVL $-36, AX
429 CALL runtime·sysenter(SB) 440 CALL runtime·sysenter(SB)
441 MOVL AX, ret+4(FP)
430 RET 442 RET
431 443
432 // uint32 mach_semaphore_timedwait(uint32, uint32, uint32) 444 // uint32 mach_semaphore_timedwait(uint32, uint32, uint32)
433 TEXT runtime·mach_semaphore_timedwait(SB),NOSPLIT,$0 445 TEXT runtime·mach_semaphore_timedwait(SB),NOSPLIT,$0
434 MOVL $-38, AX 446 MOVL $-38, AX
435 CALL runtime·sysenter(SB) 447 CALL runtime·sysenter(SB)
448 MOVL AX, ret+12(FP)
436 RET 449 RET
437 450
438 // uint32 mach_semaphore_signal(uint32) 451 // uint32 mach_semaphore_signal(uint32)
439 TEXT runtime·mach_semaphore_signal(SB),NOSPLIT,$0 452 TEXT runtime·mach_semaphore_signal(SB),NOSPLIT,$0
440 MOVL $-33, AX 453 MOVL $-33, AX
441 CALL runtime·sysenter(SB) 454 CALL runtime·sysenter(SB)
455 MOVL AX, ret+4(FP)
442 RET 456 RET
443 457
444 // uint32 mach_semaphore_signal_all(uint32) 458 // uint32 mach_semaphore_signal_all(uint32)
445 TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0 459 TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0
446 MOVL $-34, AX 460 MOVL $-34, AX
447 CALL runtime·sysenter(SB) 461 CALL runtime·sysenter(SB)
462 MOVL AX, ret+4(FP)
448 RET 463 RET
449 464
450 // setldt(int entry, int address, int limit) 465 // setldt(int entry, int address, int limit)
451 // entry and limit are ignored. 466 // entry and limit are ignored.
452 TEXT runtime·setldt(SB),NOSPLIT,$32 467 TEXT runtime·setldt(SB),NOSPLIT,$32
453 MOVL address+4(FP), BX // aka base 468 MOVL address+4(FP), BX // aka base
454 469
455 /* 470 /*
456 * When linking against the system libraries, 471 * When linking against the system libraries,
457 * we use its pthread_create and let it set up %gs 472 * we use its pthread_create and let it set up %gs
(...skipping 21 matching lines...) Expand all
479 MOVL $3, AX // thread_fast_set_cthread_self - machdep call #3 494 MOVL $3, AX // thread_fast_set_cthread_self - machdep call #3
480 INT $0x82 // sic: 0x82, not 0x80, for machdep call 495 INT $0x82 // sic: 0x82, not 0x80, for machdep call
481 496
482 XORL AX, AX 497 XORL AX, AX
483 MOVW GS, AX 498 MOVW GS, AX
484 RET 499 RET
485 500
486 TEXT runtime·sysctl(SB),NOSPLIT,$0 501 TEXT runtime·sysctl(SB),NOSPLIT,$0
487 MOVL $202, AX 502 MOVL $202, AX
488 INT $0x80 503 INT $0x80
489 » JAE» 3(PC) 504 » JAE» 4(PC)
490 NEGL AX 505 NEGL AX
506 MOVL AX, ret+24(FP)
491 RET 507 RET
492 MOVL $0, AX 508 MOVL $0, AX
509 MOVL AX, ret+24(FP)
493 RET 510 RET
494 511
495 // int32 runtime·kqueue(void); 512 // int32 runtime·kqueue(void);
496 TEXT runtime·kqueue(SB),NOSPLIT,$0 513 TEXT runtime·kqueue(SB),NOSPLIT,$0
497 MOVL $362, AX 514 MOVL $362, AX
498 INT $0x80 515 INT $0x80
499 JAE 2(PC) 516 JAE 2(PC)
500 NEGL AX 517 NEGL AX
518 MOVL AX, ret+0(FP)
501 RET 519 RET
502 520
503 // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventl ist, int nevents, Timespec *timeout); 521 // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventl ist, int nevents, Timespec *timeout);
504 TEXT runtime·kevent(SB),NOSPLIT,$0 522 TEXT runtime·kevent(SB),NOSPLIT,$0
505 MOVL $363, AX 523 MOVL $363, AX
506 INT $0x80 524 INT $0x80
507 JAE 2(PC) 525 JAE 2(PC)
508 NEGL AX 526 NEGL AX
527 MOVL AX, ret+24(FP)
509 RET 528 RET
510 529
511 // int32 runtime·closeonexec(int32 fd); 530 // int32 runtime·closeonexec(int32 fd);
512 TEXT runtime·closeonexec(SB),NOSPLIT,$32 531 TEXT runtime·closeonexec(SB),NOSPLIT,$32
513 MOVL $92, AX // fcntl 532 MOVL $92, AX // fcntl
514 // 0(SP) is where the caller PC would be; kernel skips it 533 // 0(SP) is where the caller PC would be; kernel skips it
515 MOVL fd+0(FP), BX 534 MOVL fd+0(FP), BX
516 MOVL BX, 4(SP) // fd 535 MOVL BX, 4(SP) // fd
517 MOVL $2, 8(SP) // F_SETFD 536 MOVL $2, 8(SP) // F_SETFD
518 MOVL $1, 12(SP) // FD_CLOEXEC 537 MOVL $1, 12(SP) // FD_CLOEXEC
519 INT $0x80 538 INT $0x80
520 JAE 2(PC) 539 JAE 2(PC)
521 NEGL AX 540 NEGL AX
522 RET 541 RET
OLDNEW
« no previous file with comments | « src/pkg/runtime/symtab.goc ('k') | src/pkg/runtime/sys_darwin_amd64.s » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b