aboutsummaryrefslogtreecommitdiff
path: root/src/asm.rs
blob: daa7b55d80ffa2309b09b7736ea6022266f03e20 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! Miscellaneous assembly instructions

/// Puts the processor in Debug state. Debuggers can pick this up as a
/// "breakpoint".
///
/// NOTE calling `bkpt` when the processor is not connected to a debugger will
/// cause an exception
#[inline(always)]
pub fn bkpt() {
    #[cfg(target_arch = "arm")]
    unsafe {
        asm!("bkpt"
             :
             :
             :
             : "volatile");
    }
}

/// A no-operation. Useful to prevent delay loops from being optimized away.
#[inline(always)]
pub fn nop() {
    unsafe {
        asm!("nop"
             :
             :
             :
             : "volatile");
    }
}
/// Wait For Event
#[inline(always)]
pub fn wfe() {
    match () {
        #[cfg(target_arch = "arm")]
        () => unsafe {
            asm!("wfe"
                 :
                 :
                 :
                 : "volatile")
        },
        #[cfg(not(target_arch = "arm"))]
        () => {}
    }
}

/// Wait For Interrupt
#[inline(always)]
pub fn wfi() {
    match () {
        #[cfg(target_arch = "arm")]
        () => unsafe{
            asm!("wfi"
                 :
                 :
                 :
                 : "volatile")
        },
        #[cfg(not(target_arch = "arm"))]
        () => {}
    }
}

/// Instruction Synchronization Barrier
///
/// Flushes the pipeline in the processor, so that all instructions following the `ISB` are fetched
/// from cache or memory, after the instruction has been completed.
#[inline(always)]
pub fn isb() {
    match () {
        #[cfg(target_arch = "arm")]
        () => unsafe {
            asm!("isb 0xF" : : : "memory" : "volatile");
        },
        #[cfg(not(target_arch = "arm"))]
        () => {}
    }
}

/// Data Synchronization Barrier
///
/// Acts as a special kind of memory barrier. No instruction in program order after this
/// instruction can execute until this instruction completes. This instruction completes only when
/// both:
///
///  * any explicit memory access made before this instruction is complete
///  * all cache and branch predictor maintenance operations before this instruction complete
#[inline(always)]
pub fn dsb() {
    match () {
        #[cfg(target_arch = "arm")]
        () => unsafe {
            asm!("dsb 0xF" : : : "memory" : "volatile");
        },
        #[cfg(not(target_arch = "arm"))]
        () => {}
    }
}

/// Data Memory Barrier
///
/// Ensures that all explicit memory accesses that appear in program order before the `DMB`
/// instruction are observed before any explicit memory accesses that appear in program order
/// after the `DMB` instruction.
#[inline(always)]
pub fn dmb() {
    match () {
        #[cfg(target_arch = "arm")]
        () => unsafe {
            asm!("dmb 0xF" : : : "memory" : "volatile");
        },
        #[cfg(not(target_arch = "arm"))]
        () => {}
    }
}
h class='left'>FilesLines 2023-02-16faster Buffer.byteLength("latin1")Gravatar Jarred Sumner 1-36/+28 2023-02-16Support yarn-like `"workspaces"."packages": string[]` (#2086)Gravatar Jarred Sumner 2-97/+253 2023-02-16Implement `machine` for Linux (#2088)Gravatar Justin Whear 3-0/+19 2023-02-16Fix #1516 (#2089)Gravatar Justin Whear 3-7/+14 2023-02-16Update globals.d.tsGravatar Jarred Sumner 1-0/+15 2023-02-16Add missing type definitionGravatar Jarred Sumner 1-0/+2 2023-02-16[napi] Fix crash in creating arrays > 8 elements longGravatar Jarred Sumner 1-10/+9 2023-02-16Clarify and clean up macOS build process (#2087)Gravatar Luke Deen Taylor 2-4/+4 2023-02-15Don't crash on null version stringGravatar Jarred Sumner 1-1/+1 2023-02-15Add disabled optimizationGravatar Jarred Sumner 1-0/+51 2023-02-15Add more logging to napiGravatar Jarred Sumner 1-30/+150 2023-02-15Incorrect implementation of `napi_create_threadsafe_function`Gravatar Jarred Sumner 1-21/+43 2023-02-15feat(fetch) AbortSignal (#2019)Gravatar Ciro Spaciari 17-58/+443 2023-02-15fix(webcrypto): fix ed25519 CryptoKey.algorithm (#2082)Gravatar Derrick Farris 2-9/+28 2023-02-15Fix 2063 (#2079)Gravatar Justin Whear 2-2/+11 2023-02-15Make sure we test * in tesconfigGravatar Jarred Sumner 2-1/+3 2023-02-15don't return an error thereGravatar Jarred Sumner 2-1/+3 2023-02-15Fix castGravatar Jarred Sumner 1-15/+17 2023-02-15ensure we allocate for > 6 argumentsGravatar Jarred Sumner 1-6/+13 2023-02-15Update async_hooks.exports.jsGravatar Jarred Sumner 1-2/+2 2023-02-15workaround prisma's usage of `eval("__dirname")`Gravatar Jarred Sumner 1-1/+23 2023-02-15some cleanupGravatar Jarred Sumner 2-15/+9 2023-02-15ED25519 WebCrypto (#1971)Gravatar Jarred Sumner 12-11/+1167 2023-02-14Fix up async_hooks polyfillGravatar Jarred Sumner 2-8/+63 2023-02-14Add temporary polyfill for async_hooksGravatar Jarred Sumner 5-108/+324 2023-02-14:mask: async_hooksGravatar Jarred Sumner 1-0/+4 2023-02-14[install] link network-delayed `.bin` scripts correctly (#2076)Gravatar Alex Lam S.L 3-16/+21 2023-02-14don't break esbuildGravatar Jarred Sumner 7-75/+50 2023-02-14Add workaround for `tls` and `worker_threads`Gravatar Jarred Sumner 3-1/+64 2023-02-14[install] improve `package.json` validation (#2074)Gravatar Alex Lam S.L 6-104/+342 2023-02-14[WIP] fix(node:fs): export `fs.ReadStream` and `fs.WriteStream` (#1798)Gravatar Derrick Farris 4-72/+326 2023-02-14Reject with error when invalid fetch() body (#2047)Gravatar Eric Zhang 2-12/+44 2023-02-13fix(FormData): make String explicit, thanks @dylan-conway (#2065)Gravatar Derrick Farris 1-1/+1 2023-02-13fix(FormData): add string literal operator (#2064)Gravatar Derrick Farris 1-2/+2 2023-02-13Add pretty printer for FormDataGravatar Jarred Sumner 5-1/+101 2023-02-13Add dynamic port assigning to Bun.serve (#2062)Gravatar Michał Warda 3-5/+40 2023-02-13feat(napi): add `napi_get_value_bigint_words` (#2061)Gravatar Derrick Farris 3-0/+44 2023-02-13Fixes https://github.com/oven-sh/bun/issues/1456Gravatar Jarred Sumner 8-1/+148