Changes in / [ac31040:85f7369] in mainline


Ignore:
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    rac31040 r85f7369  
    457457! [(CONFIG_HID_IN=generic|CONFIG_HID_IN=serial)&PLATFORM=ia64&MACHINE=i460GX] CONFIG_NS16550 (y/n)
    458458
    459 % Support for ARM926 on-chip UART
    460 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=integratorcp] CONFIG_ARM926_UART (y/n)
    461 
    462459% Support for Samsung S3C24XX on-chip UART
    463460! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=gta02] CONFIG_S3C24XX_UART (y/n)
     
    485482
    486483% Serial line input module
    487 ! [CONFIG_DSRLNIN=y|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=arm32&MACHINE=integratorcp&CONFIG_ARM926_UART=y)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&PROCESSOR=sun4v)] CONFIG_SRLN (y)
     484! [CONFIG_DSRLNIN=y|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&PROCESSOR=sun4v)] CONFIG_SRLN (y)
    488485
    489486% EGA support
  • boot/arch/arm32/include/main.h

    rac31040 r85f7369  
    5252
    5353/** GXemul testarm serial console output register */
    54 #define TESTARM_SCONS_ADDR      0x10000000
     54#define TESTARM_SCONS_ADDR      0x10000000
    5555
    5656/** IntegratorCP serial console output register */
    57 #define ICP_SCONS_ADDR          0x16000000
     57#define ICP_SCONS_ADDR          0x16000000
    5858
    5959extern void bootstrap(void);
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    rac31040 r85f7369  
    3838#include <console/chardev.h>
    3939#include <genarch/drivers/pl050/pl050.h>
    40 #include <genarch/drivers/arm926_uart/arm926_uart.h>
    4140#include <genarch/kbrd/kbrd.h>
    42 #include <genarch/srln/srln.h>
    4341#include <console/console.h>
    4442#include <sysinfo/sysinfo.h>
     
    5553#include <print.h>
    5654
    57 
    5855#define SDRAM_SIZE      (sdram[((*(uint32_t *)(ICP_CMCR+ICP_SDRAMCR_OFFSET) & ICP_SDRAM_MASK) >> 2)])
    59 
    60 static struct {
    61         icp_hw_map_t hw_map;
    62         irq_t timer_irq;
    63         arm926_uart_t uart;
    64 } icp;
    65 
    66 
    67 
     56static icp_hw_map_t icp_hw_map;
     57static irq_t icp_timer_irq;
    6858struct arm_machine_ops icp_machine_ops = {
    6959        icp_init,
     
    8070
    8171static bool hw_map_init_called = false;
     72static bool vga_init = false;
    8273uint32_t sdram[8] = {
    8374        16777216,       /* 16mb */
     
    9889void icp_vga_init(void)
    9990{
    100         *(uint32_t*)((char *)(icp.hw_map.cmcr)+0x14) = 0xA05F0000;
    101         *(uint32_t*)((char *)(icp.hw_map.cmcr)+0x1C) = 0x12C11000;
    102         *(uint32_t*)icp.hw_map.vga = 0x3F1F3F9C;
    103         *(uint32_t*)((char *)(icp.hw_map.vga) + 0x4) = 0x080B61DF;
    104         *(uint32_t*)((char *)(icp.hw_map.vga) + 0x8) = 0x067F3800;
    105         *(uint32_t*)((char *)(icp.hw_map.vga) + 0x10) = ICP_FB;
    106         *(uint32_t *)((char *)(icp.hw_map.vga) + 0x1C) = 0x182B;
    107         *(uint32_t*)((char *)(icp.hw_map.cmcr)+0xC) = 0x33805000;
     91        *(uint32_t*)((char *)(icp_hw_map.cmcr)+0x14) = 0xA05F0000;
     92        *(uint32_t*)((char *)(icp_hw_map.cmcr)+0x1C) = 0x12C11000;
     93        *(uint32_t*)icp_hw_map.vga = 0x3F1F3F9C;
     94        *(uint32_t*)((char *)(icp_hw_map.vga) + 0x4) = 0x080B61DF;
     95        *(uint32_t*)((char *)(icp_hw_map.vga) + 0x8) = 0x067F3800;
     96        *(uint32_t*)((char *)(icp_hw_map.vga) + 0x10) = ICP_FB;
     97        *(uint32_t *)((char *)(icp_hw_map.vga) + 0x1C) = 0x182B;
     98        *(uint32_t*)((char *)(icp_hw_map.cmcr)+0xC) = 0x33805000;
    10899       
    109100}
     
    112103static inline uint32_t icp_irqc_get_sources(void)
    113104{
    114         return *((uint32_t *) icp.hw_map.irqc);
     105        return *((uint32_t *) icp_hw_map.irqc);
    115106}
    116107
     
    122113static inline void icp_irqc_mask(uint32_t irq)
    123114{
    124         *((uint32_t *) icp.hw_map.irqc_mask) = (1 << irq);
     115        *((uint32_t *) icp_hw_map.irqc_mask) = (1 << irq);
    125116}
    126117
     
    132123static inline void icp_irqc_unmask(uint32_t irq)
    133124{
    134         *((uint32_t *) icp.hw_map.irqc_unmask) |= (1 << irq);
    135 }
    136 
    137 /** Initializes icp.hw_map. */
     125        *((uint32_t *) icp_hw_map.irqc_unmask) |= (1 << irq);
     126}
     127
     128/** Initializes icp_hw_map. */
    138129void icp_init(void)
    139130{
    140         icp.hw_map.uart = km_map(ICP_UART, PAGE_SIZE,
    141             PAGE_WRITE | PAGE_NOT_CACHEABLE);
    142         icp.hw_map.kbd_ctrl = km_map(ICP_KBD, PAGE_SIZE, PAGE_NOT_CACHEABLE);
    143         icp.hw_map.kbd_stat = icp.hw_map.kbd_ctrl + ICP_KBD_STAT;
    144         icp.hw_map.kbd_data = icp.hw_map.kbd_ctrl + ICP_KBD_DATA;
    145         icp.hw_map.kbd_intstat = icp.hw_map.kbd_ctrl + ICP_KBD_INTR_STAT;
    146         icp.hw_map.rtc = km_map(ICP_RTC, PAGE_SIZE,
    147             PAGE_WRITE | PAGE_NOT_CACHEABLE);
    148         icp.hw_map.rtc1_load = icp.hw_map.rtc + ICP_RTC1_LOAD_OFFSET;
    149         icp.hw_map.rtc1_read = icp.hw_map.rtc + ICP_RTC1_READ_OFFSET;
    150         icp.hw_map.rtc1_ctl = icp.hw_map.rtc + ICP_RTC1_CTL_OFFSET;
    151         icp.hw_map.rtc1_intrclr = icp.hw_map.rtc + ICP_RTC1_INTRCLR_OFFSET;
    152         icp.hw_map.rtc1_bgload = icp.hw_map.rtc + ICP_RTC1_BGLOAD_OFFSET;
    153         icp.hw_map.rtc1_intrstat = icp.hw_map.rtc + ICP_RTC1_INTRSTAT_OFFSET;
    154 
    155         icp.hw_map.irqc = km_map(ICP_IRQC, PAGE_SIZE,
    156             PAGE_WRITE | PAGE_NOT_CACHEABLE);
    157         icp.hw_map.irqc_mask = icp.hw_map.irqc + ICP_IRQC_MASK_OFFSET;
    158         icp.hw_map.irqc_unmask = icp.hw_map.irqc + ICP_IRQC_UNMASK_OFFSET;
    159         icp.hw_map.cmcr = km_map(ICP_CMCR, PAGE_SIZE,
    160             PAGE_WRITE | PAGE_NOT_CACHEABLE);
    161         icp.hw_map.sdramcr = icp.hw_map.cmcr + ICP_SDRAMCR_OFFSET;
    162         icp.hw_map.vga = km_map(ICP_VGA, PAGE_SIZE,
     131        icp_hw_map.uart = km_map(ICP_UART, PAGE_SIZE,
     132            PAGE_WRITE | PAGE_NOT_CACHEABLE);
     133        icp_hw_map.kbd_ctrl = km_map(ICP_KBD, PAGE_SIZE, PAGE_NOT_CACHEABLE);
     134        icp_hw_map.kbd_stat = icp_hw_map.kbd_ctrl + ICP_KBD_STAT;
     135        icp_hw_map.kbd_data = icp_hw_map.kbd_ctrl + ICP_KBD_DATA;
     136        icp_hw_map.kbd_intstat = icp_hw_map.kbd_ctrl + ICP_KBD_INTR_STAT;
     137        icp_hw_map.rtc = km_map(ICP_RTC, PAGE_SIZE,
     138            PAGE_WRITE | PAGE_NOT_CACHEABLE);
     139        icp_hw_map.rtc1_load = icp_hw_map.rtc + ICP_RTC1_LOAD_OFFSET;
     140        icp_hw_map.rtc1_read = icp_hw_map.rtc + ICP_RTC1_READ_OFFSET;
     141        icp_hw_map.rtc1_ctl = icp_hw_map.rtc + ICP_RTC1_CTL_OFFSET;
     142        icp_hw_map.rtc1_intrclr = icp_hw_map.rtc + ICP_RTC1_INTRCLR_OFFSET;
     143        icp_hw_map.rtc1_bgload = icp_hw_map.rtc + ICP_RTC1_BGLOAD_OFFSET;
     144        icp_hw_map.rtc1_intrstat = icp_hw_map.rtc + ICP_RTC1_INTRSTAT_OFFSET;
     145
     146        icp_hw_map.irqc = km_map(ICP_IRQC, PAGE_SIZE,
     147            PAGE_WRITE | PAGE_NOT_CACHEABLE);
     148        icp_hw_map.irqc_mask = icp_hw_map.irqc + ICP_IRQC_MASK_OFFSET;
     149        icp_hw_map.irqc_unmask = icp_hw_map.irqc + ICP_IRQC_UNMASK_OFFSET;
     150        icp_hw_map.cmcr = km_map(ICP_CMCR, PAGE_SIZE,
     151            PAGE_WRITE | PAGE_NOT_CACHEABLE);
     152        icp_hw_map.sdramcr = icp_hw_map.cmcr + ICP_SDRAMCR_OFFSET;
     153        icp_hw_map.vga = km_map(ICP_VGA, PAGE_SIZE,
    163154            PAGE_WRITE | PAGE_NOT_CACHEABLE);
    164155
     
    173164{
    174165        icp_irqc_mask(ICP_TIMER_IRQ);
    175         *((uint32_t*) icp.hw_map.rtc1_load) = frequency;
    176         *((uint32_t*) icp.hw_map.rtc1_bgload) = frequency;
    177         *((uint32_t*) icp.hw_map.rtc1_ctl) = ICP_RTC_CTL_VALUE;
     166        *((uint32_t*) icp_hw_map.rtc1_load) = frequency;
     167        *((uint32_t*) icp_hw_map.rtc1_bgload) = frequency;
     168        *((uint32_t*) icp_hw_map.rtc1_ctl) = ICP_RTC_CTL_VALUE;
    178169        icp_irqc_unmask(ICP_TIMER_IRQ);
    179170}
     
    181172static irq_ownership_t icp_timer_claim(irq_t *irq)
    182173{
    183         if (icp.hw_map.rtc1_intrstat) {
    184                 *((uint32_t*) icp.hw_map.rtc1_intrclr) = 1;
     174        if (icp_hw_map.rtc1_intrstat) {
     175                *((uint32_t*) icp_hw_map.rtc1_intrclr) = 1;
    185176                return IRQ_ACCEPT;
    186177        } else
     
    209200static void icp_timer_irq_init(void)
    210201{
    211         irq_initialize(&icp.timer_irq);
    212         icp.timer_irq.devno = device_assign_devno();
    213         icp.timer_irq.inr = ICP_TIMER_IRQ;
    214         icp.timer_irq.claim = icp_timer_claim;
    215         icp.timer_irq.handler = icp_timer_irq_handler;
    216 
    217         irq_register(&icp.timer_irq);
     202        irq_initialize(&icp_timer_irq);
     203        icp_timer_irq.devno = device_assign_devno();
     204        icp_timer_irq.inr = ICP_TIMER_IRQ;
     205        icp_timer_irq.claim = icp_timer_claim;
     206        icp_timer_irq.handler = icp_timer_irq_handler;
     207
     208        irq_register(&icp_timer_irq);
    218209}
    219210
     
    240231
    241232        if (hw_map_init_called) {
    242                 *size = (sdram[((*(uint32_t *)icp.hw_map.sdramcr &
     233                *size = (sdram[((*(uint32_t *)icp_hw_map.sdramcr &
    243234                    ICP_SDRAM_MASK) >> 2)]);
    244235        } else {
     
    295286{
    296287#ifdef CONFIG_FB
    297         static bool vga_init = false;
    298288        if (!vga_init) {
    299289                icp_vga_init();
     
    314304                stdout_wire(fbdev);
    315305#endif
    316 #ifdef CONFIG_ARM926_UART
    317         if (arm926_uart_init(&icp.uart, ARM926_UART0_IRQ,
    318             ARM926_UART0_BASE_ADDRESS, sizeof(arm926_uart_regs_t)))
    319                 stdout_wire(&icp.uart.outdev);
    320 #endif
    321306}
    322307
     
    325310
    326311        pl050_t *pl050 = malloc(sizeof(pl050_t), FRAME_ATOMIC);
    327         pl050->status = (ioport8_t *)icp.hw_map.kbd_stat;
    328         pl050->data = (ioport8_t *)icp.hw_map.kbd_data;
    329         pl050->ctrl = (ioport8_t *)icp.hw_map.kbd_ctrl;
     312        pl050->status = (ioport8_t *)icp_hw_map.kbd_stat;
     313        pl050->data = (ioport8_t *)icp_hw_map.kbd_data;
     314        pl050->ctrl = (ioport8_t *)icp_hw_map.kbd_ctrl;
    330315               
    331316        pl050_instance_t *pl050_instance = pl050_init(pl050, ICP_KBD_IRQ);
     
    350335            ICP_KBD);
    351336
    352 #ifdef CONFIG_ARM926_UART
    353         srln_instance_t *srln_instance = srln_init();
    354         if (srln_instance) {
    355                 indev_t *sink = stdin_wire();
    356                 indev_t *srln = srln_wire(srln_instance, sink);
    357                 arm926_uart_input_wire(&icp.uart, srln);
    358                 icp_irqc_unmask(ARM926_UART0_IRQ);
    359         }
    360 #endif
    361337}
    362338
  • kernel/genarch/Makefile.inc

    rac31040 r85f7369  
    9191endif
    9292
    93 ifeq ($(CONFIG_ARM926_UART),y)
    94         GENARCH_SOURCES += \
    95                 genarch/src/drivers/arm926_uart/arm926_uart.c
    96 endif
    97 
    9893ifeq ($(CONFIG_S3C24XX_IRQC),y)
    9994        GENARCH_SOURCES += \
  • uspace/lib/c/generic/tls.c

    rac31040 r85f7369  
    4242#include <str.h>
    4343#include <align.h>
    44 #include <unistd.h>
    4544
    4645/** Create TLS (Thread Local Storage) data structures.
     
    5857       
    5958        tcb = __alloc_tls(&data, tls_size);
    60         if (!tcb)
    61                 return NULL;
    6259       
    6360        /*
     
    9289
    9390        result = malloc(sizeof(tcb_t) + size);
    94         if (!result)
    95                 return NULL;
    9691        *data = ((void *)result) + sizeof(tcb_t);
    97 
    9892        return result;
    9993}
     
    124118        size = ALIGN_UP(size, &_tls_alignment);
    125119        *data = memalign((uintptr_t) &_tls_alignment, sizeof(tcb_t) + size);
    126         if (!*data)
    127                 return NULL;
     120
    128121        tcb = (tcb_t *) (*data + size);
    129122        tcb->self = tcb;
  • uspace/srv/fs/udf/udf_cksum.c

    rac31040 r85f7369  
    7373};
    7474
     75/** Calculate CRC16
     76 *
     77 */
     78uint16_t udf_cksum(uint8_t *buf, size_t len)
     79{
     80        uint16_t crc = 0;
     81       
     82        while (len-- > 0)
     83                crc = crc_table[(crc >> 8 ^ *buf++) & 0xff] ^ (crc << 8);
     84       
     85        return crc;
     86}
     87
    7588/** Unicode checksum
    7689 *
     
    90103       
    91104        return crc;
     105}
     106
     107/** EA checksum
     108 *
     109 * Calculate a 16-bit checksum of the Implementation Use
     110 * Extended Attribute header or Application Use Extended Attribute
     111 * header. The fields AttributeType through ImplementationIdentifier
     112 * (or ApplicationIdentifier) inclusively represent the
     113 * data covered by the checksum (48 bytes).
     114 *
     115 */
     116uint16_t udf_ea_cksum(uint8_t *data)
     117{
     118        uint16_t checksum = 0;
     119        size_t count;
     120       
     121        for (count = 0; count < 48; count++)
     122                checksum += *data++;
     123       
     124        return checksum;
    92125}
    93126
  • uspace/srv/fs/udf/udf_cksum.h

    rac31040 r85f7369  
    3939#define UDF_TAG_SIZE  16
    4040
     41extern uint16_t udf_cksum(uint8_t *, size_t);
    4142extern uint16_t udf_unicode_cksum(uint16_t *, size_t);
     43extern uint16_t udf_ea_cksum(uint8_t *);
    4244extern uint8_t udf_tag_checksum(uint8_t *);
    4345
  • uspace/srv/fs/udf/udf_file.c

    rac31040 r85f7369  
    5757 *
    5858 */
    59 static int udf_read_extended_allocator(udf_node_t *node, uint16_t icb_flag,
     59int udf_read_extended_allocator(udf_node_t *node, uint16_t icb_flag,
    6060    uint32_t pos)
    6161{
     
    185185                         */
    186186                        if (FLE32(long_d->length) >> 30 == 3) {
    187                                 udf_read_extended_allocator(node, icb_flag, pos_long_ad);
     187                                udf_read_extended_allocator (node, icb_flag, pos_long_ad);
    188188                                break;
    189189                        }
     
    296296}
    297297
     298/** Read ICB sequence of allocators in Unallocated space entry descriptor
     299 *
     300 * This function read ICB sequence if free space is saved by space table.
     301 * Not finished.
     302 *
     303 * @param uased       Unallocated space entry descriptor
     304 * @param icb_flag    Type of allocators in sequence.
     305 *                    According to ECMA 167 4/14.8.8
     306 * @param start_alloc Offset of the allocator
     307 * @param len         Length of sequence
     308 *
     309 * @return EOK on success or a negative error code.
     310 *
     311 */
     312int udf_read_free_space(uint8_t *uased, uint16_t icb_flag,
     313    uint32_t start_alloc, uint32_t len)
     314{
     315        switch (icb_flag) {
     316        case UDF_SHORT_AD:
     317                log_msg(LVL_DEBUG,
     318                    "UAICB: sequence of allocation descriptors - icbflag = short_ad_t");
     319               
     320                /* Identify number of current partition */
     321               
     322                size_t cnt = len / sizeof(udf_short_ad_t);
     323                size_t n = 0;
     324               
     325                while (n < cnt) {
     326                        udf_short_ad_t *short_d =
     327                            (udf_short_ad_t *) (uased + start_alloc + n * sizeof(udf_short_ad_t));
     328                       
     329                        if (short_d->length == 0)
     330                                break;
     331                       
     332                        n++;
     333                }
     334               
     335                break;
     336               
     337        case UDF_LONG_AD:
     338                log_msg(LVL_DEBUG,
     339                    "UAICB: sequence of allocation descriptors - icbflag = long_ad_t");
     340               
     341                cnt = len / sizeof(udf_long_ad_t);
     342                n = 0;
     343               
     344                while (n < cnt) {
     345                        udf_long_ad_t *long_d =
     346                            (udf_long_ad_t *) (uased + start_alloc + n * sizeof(udf_long_ad_t));
     347                       
     348                        if (long_d->length == 0)
     349                                break;
     350                       
     351                        n++;
     352                }
     353               
     354                break;
     355               
     356        case UDF_EXTENDED_AD:
     357                log_msg(LVL_DEBUG,
     358                    "UAICB: sequence of allocation descriptors - icbflag = extended_ad_t");
     359                break;
     360               
     361        case UDF_DATA_AD:
     362                log_msg(LVL_DEBUG,
     363                    "UAICB: sequence of allocation descriptors - icbflag = 3, node contains data itself");
     364                break;
     365        }
     366       
     367        return EOK;
     368}
     369
     370/** Read Unallocated space entry descriptor
     371 *
     372 * Read ICB sequence if free space is saved by space table.
     373 * Not finished.
     374 *
     375 */
     376int udf_read_unallocated_space_entry(udf_instance_t * instance, uint64_t pos,
     377    uint32_t len)
     378{
     379        block_t *block = NULL;
     380        int rc = block_get(&block, instance->service_id, pos, BLOCK_FLAGS_NONE);
     381        if (rc != EOK)
     382                return rc;
     383       
     384        udf_descriptor_tag_t *desc = (udf_descriptor_tag_t *) block->data;
     385        if (desc->checksum != udf_tag_checksum((uint8_t *) desc)) {
     386                block_put(block);
     387                return EINVAL;
     388        }
     389       
     390        if (FLE16(desc->id) != UDF_UASPACE_ENTRY) {
     391                // FIXME: Memory leak
     392                return EINVAL;
     393        }
     394       
     395        udf_unallocated_space_entry_descriptor_t *uased =
     396            (udf_unallocated_space_entry_descriptor_t *) block->data;
     397        if (uased->icbtag.file_type != UDF_ICBTYPE_UASE) {
     398                // FIXME: Memory leak
     399                return EINVAL;
     400        }
     401       
     402        uint16_t icb_flag = uased->icbtag.flags & UDF_ICBFLAG_MASK;
     403       
     404        rc = udf_read_free_space((uint8_t *) uased, icb_flag,
     405            UDF_UASE_OFFSET, uased->ad_lenght);
     406       
     407        return block_put(block);
     408}
     409
    298410/** Read data from disk - filling UDF node by allocators
    299411 *
     
    307419        node->link_cnt = 1;
    308420        return udf_read_icb(node);
     421}
     422
     423/** Read directory entry
     424 *
     425 * @param fid   Returned value
     426 * @param block Returned value
     427 * @param node  UDF node
     428 * @param pos   Number of FID which we need to find
     429 *
     430 * @return EOK on success or a negative error code.
     431 *
     432 */
     433int udf_get_fid(udf_file_identifier_descriptor_t **fid, block_t **block,
     434    udf_node_t *node, aoff64_t pos)
     435{
     436        if (node->data == NULL)
     437                return udf_get_fid_in_allocator(fid, block, node, pos);
     438       
     439        return udf_get_fid_in_data(fid, node, pos);
    309440}
    310441
     
    318449 *
    319450 */
    320 static int udf_get_fid_in_data(udf_file_identifier_descriptor_t **fid,
     451int udf_get_fid_in_data(udf_file_identifier_descriptor_t **fid,
    321452    udf_node_t *node, aoff64_t pos)
    322453{
     
    357488       
    358489        return ENOENT;
    359 }
    360 
    361 /** Read directory entry
    362  *
    363  * @param fid   Returned value
    364  * @param block Returned value
    365  * @param node  UDF node
    366  * @param pos   Number of FID which we need to find
    367  *
    368  * @return EOK on success or a negative error code.
    369  *
    370  */
    371 int udf_get_fid(udf_file_identifier_descriptor_t **fid, block_t **block,
    372     udf_node_t *node, aoff64_t pos)
    373 {
    374         if (node->data == NULL)
    375                 return udf_get_fid_in_allocator(fid, block, node, pos);
    376        
    377         return udf_get_fid_in_data(fid, node, pos);
    378490}
    379491
  • uspace/srv/fs/udf/udf_file.h

    rac31040 r85f7369  
    197197extern int udf_read_allocation_sequence(udf_node_t *, uint8_t *, uint16_t,
    198198    uint32_t, uint32_t);
     199extern int udf_read_extended_allocator(udf_node_t *, uint16_t, uint32_t);
    199200extern int udf_read_file(size_t *, ipc_callid_t, udf_node_t *, aoff64_t,
    200201    size_t);
    201202extern int udf_get_fid(udf_file_identifier_descriptor_t **, block_t **,
     203    udf_node_t *, aoff64_t);
     204extern int udf_get_fid_in_data(udf_file_identifier_descriptor_t **,
    202205    udf_node_t *, aoff64_t);
    203206extern int udf_get_fid_in_allocator(udf_file_identifier_descriptor_t **,
     
    205208extern int udf_get_fid_in_sector(udf_file_identifier_descriptor_t **,
    206209    block_t **, udf_node_t *, aoff64_t, size_t *, void **, size_t *);
     210extern int udf_read_free_space(uint8_t *, uint16_t, uint32_t, uint32_t);
     211extern int udf_read_unallocated_space_entry(udf_instance_t *, uint64_t,
     212    uint32_t);
    207213
    208214#endif /* UDF_FILE_H_ */
  • uspace/srv/fs/udf/udf_osta.c

    rac31040 r85f7369  
    9696 *
    9797 */
    98 static size_t udf_uncompress_unicode(size_t number_of_bytes,
    99     uint8_t *udf_compressed, uint16_t *unicode, size_t unicode_max_len)
     98size_t udf_uncompress_unicode(size_t number_of_bytes, uint8_t *udf_compressed,
     99    uint16_t *unicode, size_t unicode_max_len)
    100100{
    101101        /* Use udf_compressed to store current byte being read. */
     
    129129       
    130130        return unicode_idx;
     131}
     132
     133/** Convert Unicode wide characters to OSTA CS0 compressed Unicode string.
     134 *
     135 * The Unicode MUST be in the byte order of the compiler in order
     136 * to obtain correct results. Returns an error if the compression ID
     137 * is invalid.
     138 *
     139 * NOTE: This routine assumes the implementation already knows,
     140 * by the local environment, how many bits are appropriate and therefore
     141 * does no checking to test if the input characters fit into that number
     142 * of bits or not.
     143 *
     144 * @param[in]  number_of_chars Number of unicode characters.
     145 * @param[in]  comp_id         Compression ID to be used.
     146 * @param[in]  unicode         Unicode characters to compress.
     147 * @param[out] udf_compressed  Compressed string, as bytes.
     148 *
     149 * @return The total number of bytes in the compressed OSTA CS0 string,
     150 *         including the compression ID.
     151 *
     152 */
     153size_t udf_compress_unicode(size_t number_of_chars, uint8_t comp_id,
     154    uint16_t *unicode, uint8_t *udf_compressed)
     155{
     156        if ((comp_id != 8) && (comp_id != 16))
     157                return 0;
     158       
     159        /* Place compression code in first byte. */
     160        udf_compressed[0] = comp_id;
     161       
     162        size_t byte_idx = 1;
     163        size_t unicode_idx = 0;
     164       
     165        while (unicode_idx < number_of_chars) {
     166                if (comp_id == 16) {
     167                        /*
     168                         * First, place the high bits of the char
     169                         * into the byte stream.
     170                         */
     171                        udf_compressed[byte_idx++] =
     172                            (unicode[unicode_idx] & 0xFF00) >> 8;
     173                }
     174               
     175                /* Then place the low bits into the stream. */
     176                udf_compressed[byte_idx++] = unicode[unicode_idx] & 0x00FF;
     177                unicode_idx++;
     178        }
     179       
     180        return byte_idx;
    131181}
    132182
  • uspace/srv/fs/udf/udf_osta.h

    rac31040 r85f7369  
    5252#define PERIOD             0x002E
    5353
     54extern size_t udf_uncompress_unicode(size_t, uint8_t *, uint16_t *, size_t);
     55extern size_t udf_compress_unicode(size_t, uint8_t, uint16_t *, uint8_t *);
    5456extern size_t udf_translate_name(uint16_t *, uint16_t *, size_t);
    5557extern void udf_to_unix_name(char *, size_t, char *, size_t, udf_charspec_t *);
  • uspace/srv/fs/udf/udf_types.h

    rac31040 r85f7369  
    142142} __attribute__((packed)) udf_unallocated_space_descriptor_t;
    143143
     144extern void udf_prepare_tag(udf_descriptor_tag_t *);
     145
    144146#endif
    145147
  • uspace/srv/fs/udf/udf_volume.c

    rac31040 r85f7369  
    151151 *
    152152 */
    153 static void udf_prepare_tag(udf_descriptor_tag_t *tag)
     153void udf_prepare_tag(udf_descriptor_tag_t *tag)
    154154{
    155155        GET_LE16(tag->id);
     
    159159        GET_LE16(tag->descriptor_crc_length);
    160160        GET_LE32(tag->location);
    161 }
    162 
    163 /** Read AVD by using one of default sector size from array
    164  *
    165  * @param service_id
    166  * @param avd         Returned value - Anchor Volume Descriptor
    167  * @param sector_size Expected sector size
    168  *
    169  * @return EOK on success or a negative error code.
    170  *
    171  */
    172 static int udf_get_anchor_volume_descriptor_by_ssize(service_id_t service_id,
    173     udf_anchor_volume_descriptor_t *avd, uint32_t sector_size)
    174 {
    175         int rc = block_read_bytes_direct(service_id,
    176             UDF_AVDP_SECTOR * sector_size,
    177             sizeof(udf_anchor_volume_descriptor_t), avd);
    178         if (rc != EOK)
    179                 return rc;
    180        
    181         if (avd->tag.checksum != udf_tag_checksum((uint8_t *) &avd->tag))
    182                 return EINVAL;
    183        
    184         // TODO: Should be tested in big-endian mode
    185         udf_prepare_tag(&avd->tag);
    186        
    187         if (avd->tag.id != UDF_TAG_AVDP)
    188                 return EINVAL;
    189        
    190         GET_LE32(avd->main_extent.length);
    191         GET_LE32(avd->main_extent.location);
    192         GET_LE32(avd->reserve_extent.length);
    193         GET_LE32(avd->reserve_extent.location);
    194        
    195         return EOK;
    196161}
    197162
     
    235200       
    236201        return EINVAL;
     202}
     203
     204/** Read AVD by using one of default sector size from array
     205 *
     206 * @param service_id
     207 * @param avd         Returned value - Anchor Volume Descriptor
     208 * @param sector_size Expected sector size
     209 *
     210 * @return EOK on success or a negative error code.
     211 *
     212 */
     213int udf_get_anchor_volume_descriptor_by_ssize(service_id_t service_id,
     214    udf_anchor_volume_descriptor_t *avd, uint32_t sector_size)
     215{
     216        int rc = block_read_bytes_direct(service_id,
     217            UDF_AVDP_SECTOR * sector_size,
     218            sizeof(udf_anchor_volume_descriptor_t), avd);
     219        if (rc != EOK)
     220                return rc;
     221       
     222        if (avd->tag.checksum != udf_tag_checksum((uint8_t *) &avd->tag))
     223                return EINVAL;
     224       
     225        // TODO: Should be tested in BegEndian mode
     226        udf_prepare_tag(&avd->tag);
     227       
     228        if (avd->tag.id != UDF_TAG_AVDP)
     229                return EINVAL;
     230       
     231        GET_LE32(avd->main_extent.length);
     232        GET_LE32(avd->main_extent.location);
     233        GET_LE32(avd->reserve_extent.length);
     234        GET_LE32(avd->reserve_extent.location);
     235       
     236        return EOK;
    237237}
    238238
  • uspace/srv/fs/udf/udf_volume.h

    rac31040 r85f7369  
    215215extern int udf_get_anchor_volume_descriptor(service_id_t,
    216216    udf_anchor_volume_descriptor_t *);
     217extern int udf_get_anchor_volume_descriptor_by_ssize(service_id_t,
     218    udf_anchor_volume_descriptor_t *, uint32_t);
    217219extern int udf_read_volume_descriptor_sequence(service_id_t, udf_extent_t);
    218220extern fs_index_t udf_long_ad_to_pos(udf_instance_t *, udf_long_ad_t *);
Note: See TracChangeset for help on using the changeset viewer.