VirtualBox

Changeset 18521 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Mar 30, 2009 11:26:14 AM (16 years ago)
Author:
vboxsync
Message:

iprt/asm.h: Finally added string I/O.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm.h

    r18368 r18521  
    5353#  pragma intrinsic(__writemsr)
    5454#  pragma intrinsic(__outbyte)
     55#  pragma intrinsic(__outbytestring)
    5556#  pragma intrinsic(__outword)
     57#  pragma intrinsic(__outwordstring)
    5658#  pragma intrinsic(__outdword)
     59#  pragma intrinsic(__outdwordstring)
    5760#  pragma intrinsic(__inbyte)
     61#  pragma intrinsic(__inbytestring)
    5862#  pragma intrinsic(__inword)
     63#  pragma intrinsic(__inwordstring)
    5964#  pragma intrinsic(__indword)
     65#  pragma intrinsic(__indwordstring)
    6066#  pragma intrinsic(__invlpg)
    6167#  pragma intrinsic(__stosd)
     
    21142120 * Writes a 8-bit unsigned integer to an I/O port, ordered.
    21152121 *
    2116  * @param   Port    I/O port to read from.
     2122 * @param   Port    I/O port to write to.
    21172123 * @param   u8      8-bit integer to write.
    21182124 */
     
    21432149
    21442150/**
    2145  * Gets a 8-bit unsigned integer from an I/O port, ordered.
     2151 * Reads a 8-bit unsigned integer from an I/O port, ordered.
    21462152 *
    21472153 * @returns 8-bit integer.
     
    21782184 * Writes a 16-bit unsigned integer to an I/O port, ordered.
    21792185 *
    2180  * @param   Port    I/O port to read from.
     2186 * @param   Port    I/O port to write to.
    21812187 * @param   u16     16-bit integer to write.
    21822188 */
     
    22072213
    22082214/**
    2209  * Gets a 16-bit unsigned integer from an I/O port, ordered.
     2215 * Reads a 16-bit unsigned integer from an I/O port, ordered.
    22102216 *
    22112217 * @returns 16-bit integer.
     
    22422248 * Writes a 32-bit unsigned integer to an I/O port, ordered.
    22432249 *
    2244  * @param   Port    I/O port to read from.
     2250 * @param   Port    I/O port to write to.
    22452251 * @param   u32     32-bit integer to write.
    22462252 */
     
    22712277
    22722278/**
    2273  * Gets a 32-bit unsigned integer from an I/O port, ordered.
     2279 * Reads a 32-bit unsigned integer from an I/O port, ordered.
    22742280 *
    22752281 * @returns 32-bit integer.
     
    23022308#endif
    23032309
    2304 /** @todo string i/o */
     2310
     2311/**
     2312 * Writes a string of 8-bit unsigned integer items to an I/O port, ordered.
     2313 *
     2314 * @param   Port    I/O port to write to.
     2315 * @param   pau8    Pointer to the string buffer.
     2316 * @param   c       The number of items to write.
     2317 */
     2318#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
     2319DECLASM(void) ASMOutStrU8(RTIOPORT Port, uint8_t const *pau8, size_t c);
     2320#else
     2321DECLINLINE(void) ASMOutStrU8(RTIOPORT Port, uint8_t const *pau8, size_t c)
     2322{
     2323# if RT_INLINE_ASM_GNU_STYLE
     2324    __asm__ __volatile__("rep; outsb\n\t"
     2325                         : "+S" (pau8),
     2326                           "+c" (c)
     2327                         : "d" (Port));
     2328
     2329# elif RT_INLINE_ASM_USES_INTRIN
     2330    __outbytestring(Port, (unsigned char *)pau8, (unsigned long)c);
     2331
     2332# else
     2333    __asm
     2334    {
     2335        mov     dx, [Port]
     2336        mov     ecx, [c]
     2337        mov     eax, [pau8]
     2338        xchg    esi, eax
     2339        rep outsb
     2340        xchg    esi, eax
     2341    }
     2342# endif
     2343}
     2344#endif
     2345
     2346
     2347/**
     2348 * Reads a string of 8-bit unsigned integer items from an I/O port, ordered.
     2349 *
     2350 * @param   Port    I/O port to read from.
     2351 * @param   pau8    Pointer to the string buffer (output).
     2352 * @param   c       The number of items to read.
     2353 */
     2354#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
     2355DECLASM(void) ASMInStrU8(RTIOPORT Port, uint8_t *pau8, size_t c);
     2356#else
     2357DECLINLINE(void) ASMInStrU8(RTIOPORT Port, uint8_t *pau8, size_t c)
     2358{
     2359# if RT_INLINE_ASM_GNU_STYLE
     2360    __asm__ __volatile__("rep; insb\n\t"
     2361                         : "+D" (pau8),
     2362                           "+c" (c)
     2363                         : "d" (Port));
     2364
     2365# elif RT_INLINE_ASM_USES_INTRIN
     2366    __inbytestring(Port, pau8, (unsigned long)c);
     2367
     2368# else
     2369    __asm
     2370    {
     2371        mov     dx, [Port]
     2372        mov     ecx, [c]
     2373        mov     eax, [pau8]
     2374        xchg    edi, eax
     2375        rep insb
     2376        xchg    edi, eax
     2377    }
     2378# endif
     2379}
     2380#endif
     2381
     2382
     2383/**
     2384 * Writes a string of 16-bit unsigned integer items to an I/O port, ordered.
     2385 *
     2386 * @param   Port    I/O port to write to.
     2387 * @param   pau16   Pointer to the string buffer.
     2388 * @param   c       The number of items to write.
     2389 */
     2390#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
     2391DECLASM(void) ASMOutStrU16(RTIOPORT Port, uint16_t const *pau16, size_t c);
     2392#else
     2393DECLINLINE(void) ASMOutStrU16(RTIOPORT Port, uint16_t const *pau16, size_t c)
     2394{
     2395# if RT_INLINE_ASM_GNU_STYLE
     2396    __asm__ __volatile__("rep; outsw\n\t"
     2397                         : "+S" (pau16),
     2398                           "+c" (c)
     2399                         : "d" (Port));
     2400
     2401# elif RT_INLINE_ASM_USES_INTRIN
     2402    __outwordstring(Port, (unsigned short *)pau16, (unsigned long)c);
     2403
     2404# else
     2405    __asm
     2406    {
     2407        mov     dx, [Port]
     2408        mov     ecx, [c]
     2409        mov     eax, [pau16]
     2410        xchg    esi, eax
     2411        rep outsw
     2412        xchg    esi, eax
     2413    }
     2414# endif
     2415}
     2416#endif
     2417
     2418
     2419/**
     2420 * Reads a string of 16-bit unsigned integer items from an I/O port, ordered.
     2421 *
     2422 * @param   Port    I/O port to read from.
     2423 * @param   pau16   Pointer to the string buffer (output).
     2424 * @param   c       The number of items to read.
     2425 */
     2426#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
     2427DECLASM(void) ASMInStrU16(RTIOPORT Port, uint16_t *pau16, size_t c);
     2428#else
     2429DECLINLINE(void) ASMInStrU16(RTIOPORT Port, uint16_t *pau16, size_t c)
     2430{
     2431# if RT_INLINE_ASM_GNU_STYLE
     2432    __asm__ __volatile__("rep; insw\n\t"
     2433                         : "+D" (pau16),
     2434                           "+c" (c)
     2435                         : "d" (Port));
     2436
     2437# elif RT_INLINE_ASM_USES_INTRIN
     2438    __inwordstring(Port, pau16, (unsigned long)c);
     2439
     2440# else
     2441    __asm
     2442    {
     2443        mov     dx, [Port]
     2444        mov     ecx, [c]
     2445        mov     eax, [pau16]
     2446        xchg    edi, eax
     2447        rep insw
     2448        xchg    edi, eax
     2449    }
     2450# endif
     2451}
     2452#endif
     2453
     2454
     2455/**
     2456 * Writes a string of 32-bit unsigned integer items to an I/O port, ordered.
     2457 *
     2458 * @param   Port    I/O port to write to.
     2459 * @param   pau32   Pointer to the string buffer.
     2460 * @param   c       The number of items to write.
     2461 */
     2462#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
     2463DECLASM(void) ASMOutStrU32(RTIOPORT Port, uint32_t const *pau32, size_t c);
     2464#else
     2465DECLINLINE(void) ASMOutStrU32(RTIOPORT Port, uint32_t const *pau32, size_t c)
     2466{
     2467# if RT_INLINE_ASM_GNU_STYLE
     2468    __asm__ __volatile__("rep; outsl\n\t"
     2469                         : "+S" (pau32),
     2470                           "+c" (c)
     2471                         : "d" (Port));
     2472
     2473# elif RT_INLINE_ASM_USES_INTRIN
     2474    __outdwordstring(Port, (unsigned long *)pau32, (unsigned long)c);
     2475
     2476# else
     2477    __asm
     2478    {
     2479        mov     dx, [Port]
     2480        mov     ecx, [c]
     2481        mov     eax, [pau32]
     2482        xchg    esi, eax
     2483        rep outsd
     2484        xchg    esi, eax
     2485    }
     2486# endif
     2487}
     2488#endif
     2489
     2490
     2491/**
     2492 * Reads a string of 32-bit unsigned integer items from an I/O port, ordered.
     2493 *
     2494 * @param   Port    I/O port to read from.
     2495 * @param   pau32   Pointer to the string buffer (output).
     2496 * @param   c       The number of items to read.
     2497 */
     2498#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
     2499DECLASM(void) ASMInStrU32(RTIOPORT Port, uint32_t *pau32, size_t c);
     2500#else
     2501DECLINLINE(void) ASMInStrU32(RTIOPORT Port, uint32_t *pau32, size_t c)
     2502{
     2503# if RT_INLINE_ASM_GNU_STYLE
     2504    __asm__ __volatile__("rep; insl\n\t"
     2505                         : "+D" (pau32),
     2506                           "+c" (c)
     2507                         : "d" (Port));
     2508
     2509# elif RT_INLINE_ASM_USES_INTRIN
     2510    __indwordstring(Port, (unsigned long *)pau32, (unsigned long)c);
     2511
     2512# else
     2513    __asm
     2514    {
     2515        mov     dx, [Port]
     2516        mov     ecx, [c]
     2517        mov     eax, [pau32]
     2518        xchg    edi, eax
     2519        rep insd
     2520        xchg    edi, eax
     2521    }
     2522# endif
     2523}
     2524#endif
    23052525
    23062526
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette