Changeset 328bd35 in rtems


Ignore:
Timestamp:
Jan 23, 2016, 7:06:22 PM (4 years ago)
Author:
Joel Sherrill <joel@…>
Branches:
master
Children:
daa303d
Parents:
dda25b1
git-author:
Joel Sherrill <joel@…> (01/23/16 19:06:22)
git-committer:
Gedare Bloom <gedare@…> (03/03/16 21:36:30)
Message:

i386: refactor libcpu/cpu.h into rtems/score/i386.h

Fixes #2515.

Files:
1 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/pc386/include/bsp.h

    rdda25b1 r328bd35  
    5858#include <rtems/console.h>
    5959#include <rtems/clockdrv.h>
    60 #include <libcpu/cpu.h>
     60#include <rtems/score/cpu.h>
    6161#include <rtems/bspIo.h>
    6262
  • c/src/lib/libbsp/i386/shared/irq/idt.c

    rdda25b1 r328bd35  
    1717 */
    1818
    19 #include <libcpu/cpu.h>
     19#include <rtems/score/cpu.h>
    2020#include <bsp/irq.h>
    2121
  • c/src/lib/libbsp/i386/shared/irq/irq_init.c

    rdda25b1 r328bd35  
    1717#include <rtems/bspIo.h>
    1818
    19 #include <libcpu/cpu.h>
     19#include <rtems/score/cpu.h>
    2020
    2121#include <bsp.h>
  • c/src/lib/libbsp/i386/shared/realmode_int/realmode_int.h

    rdda25b1 r328bd35  
    2424#define _REALMODE_INT_H
    2525
    26 #include <libcpu/cpu.h>
     26#include <rtems/score/cpu.h>
    2727#include <stdint.h>
    2828
  • c/src/lib/libbsp/i386/shared/smp/smp-imps.c

    rdda25b1 r328bd35  
    8080#include <rtems.h>
    8181#include <rtems/bspIo.h>
    82 #include <libcpu/cpu.h>
     82#include <rtems/score/cpu.h>
    8383#include <assert.h>
    8484
  • c/src/lib/libcpu/i386/Makefile.am

    rdda25b1 r328bd35  
    77include_libcpudir = $(includedir)/libcpu
    88
    9 include_libcpu_HEADERS = cpu.h cpuModel.h
     9include_libcpu_HEADERS = page.h cpuModel.h
    1010include_libcpu_HEADERS += ../shared/include/cache.h
    1111include_libcpu_HEADERS += byteorder.h
     
    2323
    2424noinst_PROGRAMS += page.rel
    25 page_rel_SOURCES = page.c cpu.h
     25page_rel_SOURCES = page.c page.h
    2626page_rel_CPPFLAGS = $(AM_CPPFLAGS)
    2727page_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
  • c/src/lib/libcpu/i386/cache.c

    rdda25b1 r328bd35  
    44
    55#include <rtems.h>
    6 #include <rtems/score/registers.h>
    76#include "cache_.h"
    8 #include <libcpu/cpu.h>
     7#include <rtems/score/cpu.h>
     8#include <libcpu/page.h>
    99
    1010void _CPU_disable_cache(void)
  • c/src/lib/libcpu/i386/displayCpu.c

    rdda25b1 r328bd35  
    2121 */
    2222#include <stdio.h>
    23 #include <libcpu/cpu.h>
     23#include <rtems/score/cpu.h>
    2424#include <string.h>
    2525#include <libcpu/cpuModel.h>
  • c/src/lib/libcpu/i386/page.c

    rdda25b1 r328bd35  
    2222#include <string.h>
    2323#include <rtems.h>
    24 #include <libcpu/cpu.h>
     24#include <rtems/score/cpu.h>
     25#include <libcpu/page.h>
    2526
    2627#define MEMORY_SIZE 0x4000000           /* 64Mo */
  • c/src/lib/libcpu/i386/preinstall.am

    rdda25b1 r328bd35  
    1919PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
    2020
    21 $(PROJECT_INCLUDE)/libcpu/cpu.h: cpu.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
    22         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cpu.h
    23 PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cpu.h
     21$(PROJECT_INCLUDE)/libcpu/page.h: page.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
     22        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/page.h
     23PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/page.h
    2424
    2525$(PROJECT_INCLUDE)/libcpu/cpuModel.h: cpuModel.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
  • cpukit/score/cpu/i386/rtems/score/cpu.h

    rdda25b1 r328bd35  
    3030#include <rtems/score/types.h>
    3131#include <rtems/score/i386.h>
    32 
    33 #ifndef ASM
    34 #include <rtems/score/interrupts.h>     /* formerly in libcpu/cpu.h> */
    35 #include <rtems/score/registers.h>      /* formerly part of libcpu */
    36 #endif
    3732
    3833/* conditional compilation parameters */
  • cpukit/score/cpu/i386/rtems/score/i386.h

    rdda25b1 r328bd35  
    99
    1010/*
    11  *  COPYRIGHT (c) 1989-2013.
     11 *  COPYRIGHT (c) 1989-2016.
    1212 *  On-Line Applications Research Corporation (OAR).
     13 *
     14 *  Copyright (C) 1998  Eric Valette (valette@crf.canon.fr)
     15 *                     Canon Centre Recherche France.
    1316 *
    1417 *  The license and distribution terms for this file may be
     
    2326extern "C" {
    2427#endif
     28
     29#include <rtems/score/interrupts.h>
     30#include <rtems/score/registers.h>
    2531
    2632/*
     
    113119  return( lout );
    114120}
     121#define CPU_swap_u32( _value )  i386_swap_u32( _value )
    115122
    116123static inline uint16_t i386_swap_u16(
     
    123130  return (sout);
    124131}
     132#define CPU_swap_u16( _value )  i386_swap_u16( _value )
    125133
    126134/*
     
    203211
    204212/**
    205  * @brief Retreives real mode pointer elements {segmnet, offset} from
     213 * @brief Retrieves real mode pointer elements {segmnet, offset} from
    206214 * physical address.
    207215 *
     
    228236
    229237/*
    230  *  "Simpler" names for a lot of the things defined in this file
    231  */
    232 
    233 /* segment access routines */
    234 
    235 #define get_cs()   i386_get_cs()
    236 #define get_ds()   i386_get_ds()
    237 #define get_es()   i386_get_es()
    238 #define get_ss()   i386_get_ss()
    239 #define get_fs()   i386_get_fs()
    240 #define get_gs()   i386_get_gs()
    241 
    242 #define CPU_swap_u32( _value )  i386_swap_u32( _value )
    243 #define CPU_swap_u16( _value )  i386_swap_u16( _value )
    244 
    245 /* i80x86 I/O instructions */
    246 
     238 *  Segment Access Routines
     239 *
     240 *  NOTE:  Unfortunately, these are still static inlines even when the
     241 *         "macro" implementation of the generic code is used.
     242 */
     243
     244static __inline__ unsigned short i386_get_cs(void)
     245{
     246  register unsigned short segment = 0;
     247
     248  __asm__ volatile ( "movw %%cs,%0" : "=r" (segment) : "0" (segment) );
     249
     250  return segment;
     251}
     252
     253static __inline__ unsigned short i386_get_ds(void)
     254{
     255  register unsigned short segment = 0;
     256
     257  __asm__ volatile ( "movw %%ds,%0" : "=r" (segment) : "0" (segment) );
     258
     259  return segment;
     260}
     261
     262static __inline__ unsigned short i386_get_es(void)
     263{
     264  register unsigned short segment = 0;
     265
     266  __asm__ volatile ( "movw %%es,%0" : "=r" (segment) : "0" (segment) );
     267
     268  return segment;
     269}
     270
     271static __inline__ unsigned short i386_get_ss(void)
     272{
     273  register unsigned short segment = 0;
     274
     275  __asm__ volatile ( "movw %%ss,%0" : "=r" (segment) : "0" (segment) );
     276
     277  return segment;
     278}
     279
     280static __inline__ unsigned short i386_get_fs(void)
     281{
     282  register unsigned short segment = 0;
     283
     284  __asm__ volatile ( "movw %%fs,%0" : "=r" (segment) : "0" (segment) );
     285
     286  return segment;
     287}
     288
     289static __inline__ unsigned short i386_get_gs(void)
     290{
     291  register unsigned short segment = 0;
     292
     293  __asm__ volatile ( "movw %%gs,%0" : "=r" (segment) : "0" (segment) );
     294
     295  return segment;
     296}
     297
     298/*
     299 *  IO Port Access Routines
     300 */
     301
     302#define i386_outport_byte( _port, _value ) \
     303do { register unsigned short __port  = _port; \
     304     register unsigned char  __value = _value; \
     305     \
     306     __asm__ volatile ( "outb %0,%1" : : "a" (__value), "d" (__port) ); \
     307   } while (0)
     308
     309#define i386_outport_word( _port, _value ) \
     310do { register unsigned short __port  = _port; \
     311     register unsigned short __value = _value; \
     312     \
     313     __asm__ volatile ( "outw %0,%1" : : "a" (__value), "d" (__port) ); \
     314   } while (0)
     315
     316#define i386_outport_long( _port, _value ) \
     317do { register unsigned short __port  = _port; \
     318     register unsigned int  __value = _value; \
     319     \
     320     __asm__ volatile ( "outl %0,%1" : : "a" (__value), "d" (__port) ); \
     321   } while (0)
     322
     323#define i386_inport_byte( _port, _value ) \
     324do { register unsigned short __port  = _port; \
     325     register unsigned char  __value = 0; \
     326     \
     327     __asm__ volatile ( "inb %1,%0" : "=a" (__value) \
     328                                : "d"  (__port) \
     329                  ); \
     330     _value = __value; \
     331   } while (0)
     332
     333#define i386_inport_word( _port, _value ) \
     334do { register unsigned short __port  = _port; \
     335     register unsigned short __value = 0; \
     336     \
     337     __asm__ volatile ( "inw %1,%0" : "=a" (__value) \
     338                                : "d"  (__port) \
     339                  ); \
     340     _value = __value; \
     341   } while (0)
     342
     343#define i386_inport_long( _port, _value ) \
     344do { register unsigned short __port  = _port; \
     345     register unsigned int  __value = 0; \
     346     \
     347     __asm__ volatile ( "inl %1,%0" : "=a" (__value) \
     348                                : "d"  (__port) \
     349                  ); \
     350     _value = __value; \
     351   } while (0)
     352
     353/*
     354 * Type definition for raw interrupts.
     355 */
     356
     357typedef unsigned char  rtems_vector_offset;
     358
     359typedef struct __rtems_raw_irq_connect_data__{
     360 /*
     361  * IDT vector offset (IRQ line + PC386_IRQ_VECTOR_BASE)
     362  */
     363  rtems_vector_offset           idtIndex;
     364  /*
     365   * IDT raw handler. See comment on handler properties below in function prototype.
     366   */
     367  rtems_raw_irq_hdl             hdl;
     368  /*
     369   * function for enabling raw interrupts. In order to be consistent
     370   * with the fact that the raw connexion can defined in the
     371   * libcpu library, this library should have no knowledge of
     372   * board specific hardware to manage interrupts and thus the
     373   * "on" routine must enable the irq both at device and PIC level.
     374   *
     375   */
     376    rtems_raw_irq_enable        on;
     377  /*
     378   * function for disabling raw interrupts. In order to be consistent
     379   * with the fact that the raw connexion can defined in the
     380   * libcpu library, this library should have no knowledge of
     381   * board specific hardware to manage interrupts and thus the
     382   * "on" routine must disable the irq both at device and PIC level.
     383   *
     384   */
     385  rtems_raw_irq_disable         off;
     386  /*
     387   * function enabling to know what interrupt may currently occur
     388   */
     389  rtems_raw_irq_is_enabled      isOn;
     390}rtems_raw_irq_connect_data;
     391
     392typedef struct {
     393  /*
     394   * size of all the table fields (*Tbl) described below.
     395   */
     396  unsigned int                  idtSize;
     397  /*
     398   * Default handler used when disconnecting interrupts.
     399   */
     400  rtems_raw_irq_connect_data    defaultRawEntry;
     401  /*
     402   * Table containing initials/current value.
     403   */
     404  rtems_raw_irq_connect_data*   rawIrqHdlTbl;
     405}rtems_raw_irq_global_settings;
     406
     407#include <rtems/score/idtr.h>
     408
     409/*
     410 * C callable function enabling to get handler currently connected to a vector
     411 *
     412 */
     413rtems_raw_irq_hdl get_hdl_from_vector(rtems_vector_offset);
     414
     415/*
     416 * C callable function enabling to set up one raw idt entry
     417 */
     418extern int i386_set_idt_entry (const rtems_raw_irq_connect_data*);
     419
     420/*
     421 * C callable function enabling to get one current raw idt entry
     422 */
     423extern int i386_get_current_idt_entry (rtems_raw_irq_connect_data*);
     424
     425/*
     426 * C callable function enabling to remove one current raw idt entry
     427 */
     428extern int i386_delete_idt_entry (const rtems_raw_irq_connect_data*);
     429
     430/*
     431 * C callable function enabling to init idt.
     432 *
     433 * CAUTION : this function assumes that the IDTR register
     434 * has been already set.
     435 */
     436extern int i386_init_idt (rtems_raw_irq_global_settings* config);
     437
     438/*
     439 * C callable function enabling to get actual idt configuration
     440 */
     441extern int i386_get_idt_config (rtems_raw_irq_global_settings** config);
     442
     443
     444/*
     445 * See page 11.12 Figure 11-8.
     446 *
     447 */
     448/**
     449 * @brief describes one entry of Global/Local Descriptor Table
     450 */
     451typedef struct {
     452  unsigned int limit_15_0               : 16;
     453  unsigned int base_address_15_0        : 16;
     454  unsigned int base_address_23_16       : 8;
     455  unsigned int type                     : 4;
     456  unsigned int descriptor_type          : 1;
     457  unsigned int privilege                : 2;
     458  unsigned int present                  : 1;
     459  unsigned int limit_19_16              : 4;
     460  unsigned int available                : 1;
     461  unsigned int fixed_value_bits         : 1;
     462  unsigned int operation_size           : 1;
     463  unsigned int granularity              : 1;
     464  unsigned int base_address_31_24       : 8;
     465} RTEMS_PACKED segment_descriptors;
     466
     467/*
     468 * C callable function enabling to get easilly usable info from
     469 * the actual value of GDT register.
     470 */
     471extern void i386_get_info_from_GDTR (segment_descriptors** table,
     472                                     uint16_t* limit);
     473/*
     474 * C callable function enabling to change the value of GDT register. Must be called
     475 * with interrupts masked at processor level!!!.
     476 */
     477extern void i386_set_GDTR (segment_descriptors*,
     478                           uint16_t limit);
     479
     480/**
     481 * @brief Allows to set a GDT entry.
     482 *
     483 * Puts global descriptor \p sd to the global descriptor table on index
     484 * \p segment_selector_index
     485 *
     486 * @param[in] segment_selector_index index to GDT entry
     487 * @param[in] sd structure to be coppied to given \p segment_selector in GDT
     488 * @retval  0 FAILED out of GDT range or index is 0, which is not valid
     489 *                   index in GDT
     490 * @retval  1 SUCCESS
     491 */
     492extern uint32_t i386_raw_gdt_entry (uint16_t segment_selector_index,
     493                               segment_descriptors* sd);
     494
     495/**
     496 * @brief fills \p sd with provided \p base in appropriate fields of \p sd
     497 *
     498 * @param[in] base 32-bit address to be set as descriptor's base
     499 * @param[out] sd descriptor being filled with \p base
     500 */
     501extern void i386_fill_segment_desc_base (uint32_t base,
     502                                         segment_descriptors* sd);
     503
     504/**
     505 * @brief fills \p sd with provided \p limit in appropriate fields of \p sd
     506 *
     507 * sets granularity bit if necessary
     508 *
     509 * @param[in] limit 32-bit value representing number of limit bytes
     510 * @param[out] sd descriptor being filled with \p limit
     511 */
     512extern void i386_fill_segment_desc_limit (uint32_t limit,
     513                                          segment_descriptors* sd);
     514
     515/*
     516 * C callable function enabling to set up one raw interrupt handler
     517 */
     518extern uint32_t i386_set_gdt_entry (uint16_t segment_selector,
     519                                    uint32_t base,
     520                                    uint32_t limit);
     521
     522/**
     523 * @brief Returns next empty descriptor in GDT.
     524 *
     525 * Number of descriptors that can be returned depends on \a GDT_SIZE
     526 *
     527 * @retval  0 FAILED GDT is full
     528 * @retval  <1;65535> segment_selector number as index to GDT
     529 */
     530extern uint16_t i386_next_empty_gdt_entry (void);
     531
     532/**
     533 * @brief Copies GDT entry at index \p segment_selector to structure
     534 * pointed to by \p struct_to_fill
     535 *
     536 * @param[in] segment_selector index to GDT table specifying descriptor to copy
     537 * @param[out] struct_to_fill pointer to memory where will be descriptor coppied
     538 * @retval  0 FAILED segment_selector out of GDT range
     539 * @retval  <1;65535> retrieved segment_selector
     540 */
     541extern uint16_t i386_cpy_gdt_entry (uint16_t segment_selector,
     542                                    segment_descriptors* struct_to_fill);
     543
     544/**
     545 * @brief Returns pointer to GDT table at index given by \p segment_selector
     546 *
     547 * @param[in] sgmnt_selector index to GDT table for specifying descriptor to get
     548 * @retval  NULL FAILED segment_selector out of GDT range
     549 * @retval  pointer to GDT table at \p segment_selector
     550 */
     551extern segment_descriptors* i386_get_gdt_entry (uint16_t sgmnt_selector);
     552
     553/**
     554 * @brief Extracts base address from GDT entry pointed to by \p gdt_entry
     555 *
     556 * @param[in]  gdt_entry pointer to entry from which base should be retrieved
     557 * @retval base address from GDT entry
     558*/
     559RTEMS_INLINE_ROUTINE void* i386_base_gdt_entry (segment_descriptors* gdt_entry)
     560{
     561    return (void*)(gdt_entry->base_address_15_0 |
     562            (gdt_entry->base_address_23_16<<16) |
     563            (gdt_entry->base_address_31_24<<24));
     564}
     565
     566/**
     567 * @brief Extracts limit in bytes from GDT entry pointed to by \p gdt_entry
     568 *
     569 * @param[in]  gdt_entry pointer to entry from which limit should be retrieved
     570 * @retval limit value in bytes from GDT entry
     571 */
     572extern uint32_t i386_limit_gdt_entry (segment_descriptors* gdt_entry);
     573
     574/*
     575 * See page 11.18 Figure 11-12.
     576 *
     577 */
     578
     579typedef struct {
     580  unsigned int offset                   : 12;
     581  unsigned int page                     : 10;
     582  unsigned int directory                : 10;
     583}la_bits;
     584
     585typedef union {
     586  la_bits       bits;
     587  unsigned int  address;
     588}linear_address;
     589
     590
     591/*
     592 * See page 11.20 Figure 11-14.
     593 *
     594 */
     595
     596typedef struct {
     597  unsigned int present                  : 1;
     598  unsigned int writable                 : 1;
     599  unsigned int user                     : 1;
     600  unsigned int write_through            : 1;
     601  unsigned int cache_disable            : 1;
     602  unsigned int accessed                 : 1;
     603  unsigned int reserved1                : 1;
     604  unsigned int page_size                : 1;
     605  unsigned int reserved2                : 1;
     606  unsigned int available                : 3;
     607  unsigned int page_frame_address       : 20;
     608}page_dir_bits;
     609
     610typedef union {
     611  page_dir_bits bits;
     612  unsigned int  dir_entry;
     613}page_dir_entry;
     614
     615typedef struct {
     616  unsigned int present                  : 1;
     617  unsigned int writable                 : 1;
     618  unsigned int user                     : 1;
     619  unsigned int write_through            : 1;
     620  unsigned int cache_disable            : 1;
     621  unsigned int accessed                 : 1;
     622  unsigned int dirty                    : 1;
     623  unsigned int reserved2                : 2;
     624  unsigned int available                : 3;
     625  unsigned int page_frame_address       : 20;
     626}page_table_bits;
     627
     628typedef union {
     629  page_table_bits       bits;
     630  unsigned int          table_entry;
     631} page_table_entry;
     632
     633/*
     634 * definitions related to page table entry
     635 */
     636#define PG_SIZE 0x1000
     637#define MASK_OFFSET 0xFFF
     638#define MAX_ENTRY (PG_SIZE/sizeof(page_dir_entry))
     639#define FOUR_MB       0x400000
     640#define MASK_FLAGS 0x1A
     641
     642#define PTE_PRESENT             0x01
     643#define PTE_WRITABLE            0x02
     644#define PTE_USER                0x04
     645#define PTE_WRITE_THROUGH       0x08
     646#define PTE_CACHE_DISABLE       0x10
     647
     648typedef struct {
     649  page_dir_entry pageDirEntry[MAX_ENTRY];
     650} page_directory;
     651
     652typedef struct {
     653  page_table_entry pageTableEntry[MAX_ENTRY];
     654} page_table;
     655
     656/* Simpler names for the i80x86 I/O instructions */
    247657#define outport_byte( _port, _value ) i386_outport_byte( _port, _value )
    248658#define outport_word( _port, _value ) i386_outport_word( _port, _value )
     
    252662#define inport_long( _port, _value )  i386_inport_long( _port, _value )
    253663
    254 
    255664#ifdef __cplusplus
    256665}
Note: See TracChangeset for help on using the changeset viewer.