Ticket #1119: bootsplash.diff

File bootsplash.diff, 14.4 KB (added by aljen, 16 years ago)
  • build/jam/ImageRules

     
    3838actions InitScript1
    3939{
    4040    rm -f $(1)
    41     echo -n > $(1)
     41#   echo -n > $(1)
     42    echo > $(1)
    4243}
    4344
    4445rule AddVariableToScript script : variable : value
  • src/tools/fs_shell/unistd.cpp

     
    2525#       include <sys/ioctl.h>
    2626#       include <sys/stat.h>
    2727#       include <sys/disk.h>
    28 #       include <sys/disklabel.h>
     28#       ifndef HAIKU_HOST_PLATFORM_DARWIN
     29#           include <sys/disklabel.h>
     30#       endif
    2931#   else
    3032        // the (POSIX) correct place of definition for ioctl()
    3133#       include <stropts.h>
  • src/system/boot/platform/bios_ia32/video.cpp

     
    1313
    1414#include <edid.h>
    1515
     16#include <OS.h>
    1617#include <arch/cpu.h>
    1718#include <boot/stage2.h>
    1819#include <boot/platform.h>
     
    4849static addr_t sFrameBuffer;
    4950static bool sModeChosen;
    5051static bool sSettingsLoaded;
     52static bootSplashImage* splashImage = NULL;
     53static bootSplashImage* splashIcons = NULL;
     54static bootSplashPalette* splashPalette = NULL;
     55static int bootStage = 0;
     56static bool bootLogoMode = false;
    5157
     58status_t
     59load_splash_data(stage2_args* args, Directory* volume)
     60{
     61    dprintf("load_splash_data: enter\n");
     62   
     63    // splash.raw
     64    int fd = open_from(volume, "home/config/settings/kernel/splash.raw", O_RDONLY);
     65    if (fd < 0)
     66    {
     67        dprintf("load_splash_data: error opening home/config/settings/kernel/splash.raw\n");
     68        unload_splash_data();
     69        return fd;
     70    }
     71    dprintf("load_splash_data: home/config/settings/kernel/splash.raw opened\n");
     72    splashImage = (bootSplashImage*)malloc(sizeof(bootSplashImage));
     73    if (!splashImage)
     74    {
     75        dprintf("load_splash_data: not enough memory to alloc splash image\n");
     76        return B_NO_MEMORY;
     77    }
     78    dprintf("load_splash_data: splashImage=%p\n", splashImage);
     79    memset(splashImage, 0, sizeof(bootSplashImage));
     80    if(read(fd, &(splashImage->width), sizeof(unsigned int)) != sizeof(unsigned int))
     81    {
     82        dprintf("load_splash_data: cant read image width from splash image\n");
     83        unload_splash_data();
     84        return B_IO_ERROR;
     85    }
     86    if(read(fd, &(splashImage->height), sizeof(unsigned int)) != sizeof(unsigned int))
     87    {
     88        dprintf("load_splash_data: cant read image height from splash image\n");
     89        unload_splash_data();
     90        return B_IO_ERROR;
     91    }
     92    if(read(fd, &(splashImage->size), sizeof(unsigned int)) != sizeof(unsigned int))
     93    {
     94        dprintf("load_splash_data: cant read image size from splash image\n");
     95        unload_splash_data();
     96        return B_IO_ERROR;
     97    }
     98    splashImage->data = (unsigned char*)malloc(splashImage->size);
     99    if(!splashImage->data)
     100    {
     101        dprintf("load_splash_data: not enough memory to alloc splash image data\n");
     102        unload_splash_data();
     103        return B_NO_MEMORY;
     104    }
     105    memset(splashImage->data, 0, splashImage->size);
     106    if(read(fd, splashImage->data, splashImage->size) != splashImage->size)
     107    {
     108        dprintf("load_splash_data: cant read image data from splash image\n");
     109        unload_splash_data();
     110        return B_IO_ERROR;
     111    }
     112    dprintf("load_splash_data: splash image width=%d, height=%d, size=%d, pointer=%p, data pointer=%p\n", splashImage->width, splashImage->height, splashImage->size, splashImage, splashImage->data);
     113    close(fd);
    52114
     115    // icons.raw
     116    fd = open_from(volume, "home/config/settings/kernel/icons.raw", O_RDONLY);
     117    if (fd < 0)
     118    {
     119        dprintf("load_splash_data: error opening home/config/settings/kernel/icons.raw\n");
     120        unload_splash_data();
     121        return fd;
     122    }
     123    dprintf("load_splash_data: home/config/settings/kernel/icons.raw opened\n");
     124    splashIcons = (bootSplashImage*)malloc(sizeof(bootSplashImage));
     125    if (!splashIcons)
     126    {
     127        dprintf("load_splash_data: not enough memory to alloc splash icons image\n");
     128        return B_NO_MEMORY;
     129    }
     130    dprintf("load_splash_data: splashIcons=%p\n", splashIcons);
     131    memset(splashIcons, 0, sizeof(bootSplashImage));
     132    if(read(fd, &(splashIcons->width), sizeof(unsigned int)) != sizeof(unsigned int))
     133    {
     134        dprintf("load_splash_data: cant read image width from splash icons image\n");
     135        unload_splash_data();
     136        return B_IO_ERROR;
     137    }
     138    if(read(fd, &(splashIcons->height), sizeof(unsigned int)) != sizeof(unsigned int))
     139    {
     140        dprintf("load_splash_data: cant read image height from splash icons image\n");
     141        unload_splash_data();
     142        return B_IO_ERROR;
     143    }
     144    if(read(fd, &(splashIcons->size), sizeof(unsigned int)) != sizeof(unsigned int))
     145    {
     146        dprintf("load_splash_data: cant read image size from splash icons image\n");
     147        unload_splash_data();
     148        return B_IO_ERROR;
     149    }
     150    splashIcons->data = (unsigned char*)malloc(splashIcons->size);
     151    if(!splashIcons->data)
     152    {
     153        dprintf("load_splash_data: not enough memory to alloc splash icons image data\n");
     154        unload_splash_data();
     155        return B_NO_MEMORY;
     156    }
     157    memset(splashIcons->data, 0, splashIcons->size);
     158    if(read(fd, splashIcons->data, splashIcons->size) != splashIcons->size)
     159    {
     160        dprintf("load_splash_data: cant read image data from splash icons image\n");
     161        unload_splash_data();
     162        return B_IO_ERROR;
     163    }
     164    dprintf("load_splash_data: splash icons image width=%d, height=%d, size=%d, pointer=%p, data pointer=%p\n", splashIcons->width, splashIcons->height, splashIcons->size, splashIcons, splashIcons->data);
     165    close(fd);
     166
     167    // palette.raw
     168    fd = open_from(volume, "home/config/settings/kernel/palette.raw", O_RDONLY);
     169    if (fd < 0)
     170    {
     171        dprintf("load_splash_data: error opening home/config/settings/kernel/palette.raw\n");
     172        unload_splash_data();
     173        return fd;
     174    }
     175    dprintf("load_splash_data: home/config/settings/kernel/palette.raw opened\n");
     176    splashPalette = (bootSplashPalette*)malloc(sizeof(bootSplashPalette));
     177    if (!splashPalette)
     178    {
     179        dprintf("load_splash_data: not enough memory to alloc splash palette\n");
     180        return B_NO_MEMORY;
     181    }
     182    dprintf("load_splash_data: splashPalette=%p\n", splashPalette);
     183    memset(splashPalette, 0, sizeof(bootSplashPalette));
     184    if(read(fd, &(splashPalette->size), sizeof(unsigned int)) != sizeof(unsigned int))
     185    {
     186        dprintf("load_splash_data: cant read size from splash palette\n");
     187        unload_splash_data();
     188        return B_IO_ERROR;
     189    }
     190    splashPalette->data = (unsigned char*)malloc(splashPalette->size);
     191    if(!splashPalette->data)
     192    {
     193        dprintf("load_splash_data: not enough memory to alloc splash palette data\n");
     194        unload_splash_data();
     195        return B_NO_MEMORY;
     196    }
     197    memset(splashPalette->data, 0, splashPalette->size);
     198    if(read(fd, splashPalette->data, splashPalette->size) != splashPalette->size)
     199    {
     200        dprintf("load_splash_data: cant read data from splash palette\n");
     201        unload_splash_data();
     202        return B_IO_ERROR;
     203    }
     204    dprintf("load_splash_data: splash palette size=%d, pointer=%p, data pointer=%p\n", splashPalette->size, splashPalette, splashPalette->data);
     205    close(fd);
     206
     207    return B_OK;
     208}
     209
     210void
     211unload_splash_data()
     212{
     213    dprintf("unload_splash_data\n");
     214    if (splashImage)
     215    {
     216        if (splashImage->data)
     217        {
     218            free(splashImage->data);
     219            splashImage->data = NULL;
     220        }
     221        free(splashImage);
     222        splashImage = NULL;
     223    }
     224    if (splashIcons)
     225    {
     226        if (splashIcons->data)
     227        {
     228            free(splashIcons->data);
     229            splashIcons->data = NULL;
     230        }
     231        free(splashIcons);
     232        splashIcons = NULL;
     233    }
     234    if (splashPalette)
     235    {
     236        if (splashPalette->data)
     237        {
     238            free(splashPalette->data);
     239            splashPalette->data = NULL;
     240        }
     241        free(splashPalette);
     242        splashPalette = NULL;
     243    }
     244}
     245
    53246static int
    54247compare_video_modes(video_mode *a, video_mode *b)
    55248{
     
    649842    }
    650843}
    651844
     845// data - image data
     846// imageLeft - cropped image left point
     847// imageRight - cropped image right point
     848// imageTop - cropped image top point
     849// imageBottom - cropped image bottom point
     850// imageWidth - image width
     851// imageHeight - image height
     852// palette - image palette
     853static void
     854blit16_cropped(const uint8 *data, uint16 imageLeft, uint16 imageTop, uint16 imageRight, uint16 imageBottom,
     855    uint16 imageWidth, uint16 imageHeight, const uint8 *palette, uint16 left, uint16 top)
     856{
     857    int32 dataOffset = (imageWidth * imageTop) + imageLeft;
    652858
     859    uint16 *start = (uint16 *)(sFrameBuffer
     860        + gKernelArgs.frame_buffer.bytes_per_row * top + 2 * left);
     861
     862    for (int32 y = imageTop; y < imageBottom; y++) {
     863        for (int32 x = imageLeft; x < imageRight; x++) {
     864            uint16 color = data[(y * (imageWidth)) + x] * 3;
     865
     866            start[x] = ((palette[color + 0] >> 3) << 11)
     867                | ((palette[color + 1] >> 2) << 5)
     868                | ((palette[color + 2] >> 3));
     869            dataOffset += imageWidth;
     870        }
     871
     872
     873        start = (uint16 *)((addr_t)start
     874            + gKernelArgs.frame_buffer.bytes_per_row);
     875    }
     876
     877//  for (int32 i = 0; i < (imageBottom - imageTop); i++) {
     878//      memcpy((void *)(start + gKernelArgs.frame_buffer.bytes_per_row * i),
     879//          &data[dataOffset], imageRight - imageLeft);
     880//          dataOffset += imageWidth;
     881//  }
     882}
     883
    653884static void
    654885blit4(const uint8 *data, uint16 width, uint16 height,
    655886    const uint8 *palette, uint16 left, uint16 top)
     
    719950    }
    720951}
    721952
     953static void
     954blit_8bit_image_cropped(const uint8 *data, uint16 imageLeft, uint16 imageTop, uint16 imageRight, uint16 imageBottom,
     955    uint16 imageWidth, uint16 imageHeight, const uint8 *palette, uint16 left, uint16 top)
     956{
     957    dprintf("blit_8bit_image_cropped: depth=%d\n", gKernelArgs.frame_buffer.depth);
     958    switch (gKernelArgs.frame_buffer.depth) {
     959        case 16:
     960            return blit16_cropped(data, imageLeft, imageTop, imageRight, imageBottom, imageWidth, imageHeight, palette, left, top);
     961        case 8:
     962        case 4:
     963        case 15:
     964        case 24:
     965        case 32:
     966            return;
     967    }
     968}
    722969
    723970//  #pragma mark -
    724971
     
    730977    if ((platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) != 0)
    731978        return;
    732979
     980    bootLogoMode = true;
     981
    733982    addr_t lastBase = gKernelArgs.frame_buffer.physical_buffer.start;
    734983    size_t lastSize = gKernelArgs.frame_buffer.physical_buffer.size;
    735984
     
    7861035            gKernelArgs.frame_buffer.physical_buffer.start,
    7871036            gKernelArgs.frame_buffer.physical_buffer.size, kDefaultPageFlags);
    7881037    }
    789 
    790     // clear the video memory
    791     memset((void *)sFrameBuffer, 0,
    792         gKernelArgs.frame_buffer.physical_buffer.size);
    793 
    794     // TODO: The image should be compressed, and eventually added by
    795     //  the build process.
    796 
    797     blit_8bit_image(kImageData, kWidth, kHeight, kPalette,
    798         gKernelArgs.frame_buffer.width - kWidth - 40,
    799         gKernelArgs.frame_buffer.height - kHeight - 60);
    8001038}
    8011039
    8021040
     
    8771115    return B_OK;
    8781116}
    8791117
     1118void
     1119set_bootsplash_stage(int stage)
     1120{
     1121    bootStage = stage;
     1122
     1123    if (!bootLogoMode)
     1124        return;
     1125
     1126    // clear the video memory
     1127    memset((void *)sFrameBuffer, 0,
     1128        gKernelArgs.frame_buffer.physical_buffer.size);
     1129
     1130    dprintf("set_bootsplash_stage: drawing logo\n");
     1131    if (splashImage && splashImage->data && splashPalette && splashPalette->data)
     1132    {
     1133        blit_8bit_image(splashImage->data, splashImage->width, splashImage->height, splashPalette->data,
     1134            gKernelArgs.frame_buffer.width - splashImage->width - 80,
     1135            gKernelArgs.frame_buffer.height - splashImage->height );
     1136    }
     1137    dprintf("set_bootsplash_stage: drawing icons\n");
     1138    if (splashIcons && splashIcons->data && splashPalette && splashPalette->data)
     1139    {
     1140        int iconsx = (gKernelArgs.frame_buffer.width / 2) - (splashIcons->width / 2);
     1141        int iconsy = (gKernelArgs.frame_buffer.height / 2) - (splashIcons->height / 4);
     1142        blit_8bit_image_cropped(splashIcons->data, 0, 32, splashIcons->width, 64, splashIcons->width, splashIcons->height,
     1143            splashPalette->data, iconsx, iconsy );
     1144        if (bootStage > 0)
     1145        {
     1146            blit_8bit_image_cropped(splashIcons->data, 0, 0, bootStage * 32, 32, splashIcons->width, splashIcons->height,
     1147                splashPalette->data, iconsx, iconsy );
     1148        }
     1149    }
     1150}
     1151
  • src/system/boot/platform/bios_ia32/start.c

     
    7474        // to the assembler inline below - might be a bug in GCC
    7575        // or I don't see something important...
    7676    addr_t stackTop = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size;
    77 
     77   
     78    // all commented calls was here only to test
     79    // set_bootsplash_stage(3);
    7880    smp_init_other_cpus();
    7981    serial_cleanup();
    8082    mmu_init_for_kernel();
    8183    smp_boot_other_cpus();
     84    // set_bootsplash_stage(4);
    8285
    8386    dprintf("kernel entry at %lx\n", gKernelArgs.kernel_image.elf_header.e_entry);
    8487
  • src/system/boot/loader/main.cpp

     
    101101            register_boot_file_system(volume);
    102102
    103103            if ((platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) == 0)
    104                 platform_switch_to_logo();
    105 
     104            {
     105                if (load_splash_data(args, volume) == B_OK)
     106                    platform_switch_to_logo();
     107            }
     108           
     109            // all commented calls was here only to test
     110            // set_bootsplash_stage(1);
    106111            load_modules(args, volume);
     112            // set_bootsplash_stage(2);
    107113            load_driver_settings(args, volume);
    108114
    109115            // set up kernel args version info
  • headers/private/kernel/boot/platform.h

     
    3535
    3636extern uint32 platform_boot_options(void);
    3737
     38/* bootsplash structs */
     39typedef struct
     40{
     41    unsigned int width;
     42    unsigned int height;
     43    unsigned int size;
     44    unsigned char* data;
     45} bootSplashImage;
     46
     47typedef struct
     48{
     49    unsigned int width;
     50    unsigned int height;
     51    unsigned int iconWidth;
     52    unsigned int iconHeight;
     53    unsigned int size;
     54    unsigned char* data;
     55} bootSplashIcons;
     56
     57typedef struct
     58{
     59    unsigned int size;
     60    unsigned char* data;
     61} bootSplashPalette;
     62
    3863/* misc functions */
    3964extern status_t platform_init_video(void);
     65extern void unload_splash_data();
     66extern void set_bootsplash_stage(int stage);
    4067extern void platform_switch_to_logo(void);
    4168extern void platform_switch_to_text_mode(void);
    4269extern void platform_start_kernel(void);
     
    5986extern status_t platform_get_boot_partition(struct stage2_args *args, Node *bootDevice,
    6087                    NodeList *partitions, boot::Partition **_partition);
    6188extern status_t platform_register_boot_device(Node *device);
     89extern status_t load_splash_data(struct stage2_args *args, Directory *volume);
    6290
    6391/* menu functions */
    6492