root/trunk/patches/2.6.22/96-kexec-cmdline.patch

Revision 896, 4.5 KB (checked in by mwester, 3 years ago)

2.6.22 patches - added kexec command-line patches, defconfig now builds via-velocity driver
into the kernel.

  • linux-2.6.21.5/kernel/ksysfs.c

    old new  
    4949#endif 
    5050 
    5151#ifdef CONFIG_KEXEC 
     52 
     53#include <asm/setup.h> 
     54 
     55extern unsigned long kexec_boot_params; 
     56 
     57char kexec_cmdline[COMMAND_LINE_SIZE] = ""; 
     58 
     59static void 
     60replace_cmdline_tag(void) 
     61{ 
     62        char *t; 
     63        struct tag *real; 
     64        struct tag *copy; 
     65        struct tag *rend; 
     66        int i; 
     67 
     68/* TODO: check the return params */ 
     69        t = kmalloc(KEXEC_BOOT_PARAMS_SIZE + COMMAND_LINE_SIZE, GFP_KERNEL); 
     70        memset((void *)t, 0, KEXEC_BOOT_PARAMS_SIZE + COMMAND_LINE_SIZE); 
     71 
     72/* TODO: validate that the boot params are ATAGS, in fact */ 
     73 
     74        copy = (struct tag *)t; 
     75        real = (struct tag *)kexec_boot_params; 
     76        rend = (struct tag *)(kexec_boot_params + KEXEC_BOOT_PARAMS_SIZE); 
     77        while ((real->hdr.size) && (real < rend)) { 
     78                if (real->hdr.tag != ATAG_CMDLINE) { 
     79                        memcpy((void *)copy, (void *)real, real->hdr.size * 4); 
     80                        copy = tag_next(copy); 
     81                } 
     82                real = tag_next(real); 
     83        } 
     84 
     85/* TODO: validate that we have enough space in the buffer */ 
     86         
     87        i = strlen(kexec_cmdline); 
     88        if (i) { 
     89                copy->hdr.tag = ATAG_CMDLINE; 
     90                copy->hdr.size = (sizeof(struct tag_header) + i + 1 + 4) >> 2; 
     91                strcpy(copy->u.cmdline.cmdline, kexec_cmdline); 
     92                copy = tag_next(copy); 
     93        } 
     94 
     95        copy->hdr.tag = ATAG_NONE;            /* Empty tag ends list */ 
     96        copy->hdr.size = 0;                   /* zero length */ 
     97 
     98/* TODO: validate that the temporary buffer isn't too full */ 
     99 
     100        memcpy((void *)kexec_boot_params, (void *)t, KEXEC_BOOT_PARAMS_SIZE); 
     101 
     102        kfree(t);  /* Don't forget to free the big buffer we used */ 
     103} 
     104 
     105static ssize_t kexec_cmdline_show(struct kset *kset, char *page) 
     106{ 
     107        return sprintf(page, "%s\n", kexec_cmdline); 
     108} 
     109 
     110static ssize_t kexec_cmdline_store(struct kset *kset, const char *page, 
     111                                   size_t count) 
     112{ 
     113        if ((count + 1) > COMMAND_LINE_SIZE) 
     114                count = COMMAND_LINE_SIZE; 
     115        memcpy(kexec_cmdline, page, count); 
     116        kexec_cmdline[count] = '\0'; 
     117        if (count && (kexec_cmdline[count - 1] == '\n')) 
     118                kexec_cmdline[count - 1] = '\0'; 
     119        replace_cmdline_tag(); 
     120        return count; 
     121} 
     122KERNEL_ATTR_RW(kexec_cmdline); 
     123 
     124static ssize_t kexec_boot_params_show(struct kset *kset, char *page) 
     125{ 
     126        unsigned long *p; 
     127        char buf[PAGE_SIZE]; 
     128        int keep_doing; 
     129 
     130        p = (unsigned long *)kexec_boot_params; 
     131 
     132        /* if this doesn't look like atags, just print first few words */ 
     133        if (p[1] != ATAG_CORE) 
     134                return sprintf(page, "0x%lx 0x%lx 0x%lx 0x%lx\n", 
     135                               p[0], p[1], p[2], p[3]); 
     136 
     137        /* carefully walk the atag list, and print out the structure */ 
     138        keep_doing = 1; 
     139        do { 
     140                switch (p[1]) { 
     141                case ATAG_CORE: 
     142                        /* watch out, core tag is permitted to be empty */ 
     143                        if (p[0] == 5) 
     144                                sprintf(buf, 
     145                                        "CORE flg=%ld pgsz=%ld rdev=0x%lx\n", 
     146                                        p[2], p[3], p[4]); 
     147                        else 
     148                                sprintf(buf,"CORE\n"); 
     149                        break; 
     150                case ATAG_MEM: 
     151                        sprintf(buf,"MEM  %ldM@0x%lx\n", p[2] / (1024 * 1024), 
     152                                p[3]); 
     153                        break; 
     154                case ATAG_VIDEOTEXT: 
     155                        sprintf(buf,"VIDEOTEXT sz=%ld\n", p[0]); 
     156                        break; 
     157                case ATAG_RAMDISK: 
     158                        sprintf(buf,"RAMDISK prmpt=%ld %ldK@0x%lx\n", 
     159                                p[2], p[3], p[4]); 
     160                        break; 
     161                case ATAG_INITRD2: 
     162                        sprintf(buf,"INITRD2 %ldK@0x%lx\n", p[3] / 1024, p[2]); 
     163                        break; 
     164                case ATAG_SERIAL: 
     165                        sprintf(buf,"SERIAL high=0x%08lx low=0x%08lx\n", 
     166                                p[3], p[2]); 
     167                        break; 
     168                case ATAG_REVISION: 
     169                        sprintf(buf,"REVISION rev=%ld\n", p[2]); 
     170                        break; 
     171                case ATAG_VIDEOLFB: 
     172                        sprintf(buf,"VIDEOLFB sz=%ld\n", p[0]); 
     173                        break; 
     174                case ATAG_CMDLINE: 
     175                        sprintf(buf,"CMD  \"%s\"\n", (char *)&p[2]); 
     176                        break; 
     177                case ATAG_NONE: 
     178                        sprintf(buf,"NONE\n"); 
     179                        keep_doing = 0; 
     180                        break; 
     181                default: 
     182                        sprintf(buf,"-unknown- sz=%ld\n", p[0]); 
     183                        break; 
     184                } 
     185 
     186                /* carefully add to page */ 
     187                if ((strlen(buf) + strlen(page)) < PAGE_SIZE) { 
     188                        strcat(page, buf); 
     189                } else { 
     190                        keep_doing = 0; 
     191                } 
     192 
     193                /* stop when we encounter a header length of 0 */ 
     194                if (p[0] == 0) 
     195                        keep_doing = 0; 
     196 
     197                /* go to the next tag */ 
     198                p += p[0]; 
     199 
     200                /* stop if we walked off the end of the buffer */ 
     201                if (p > (unsigned long *)(kexec_boot_params + 
     202                                          KEXEC_BOOT_PARAMS_SIZE)) 
     203                        keep_doing = 0; 
     204 
     205        } while (keep_doing); 
     206 
     207        return (strlen(page)); 
     208} 
     209KERNEL_ATTR_RO(kexec_boot_params); 
     210 
    52211static ssize_t kexec_loaded_show(struct kset *kset, char *page) 
    53212{ 
    54213        return sprintf(page, "%d\n", !!kexec_image); 
     
    73233#ifdef CONFIG_KEXEC 
    74234        &kexec_loaded_attr.attr, 
    75235        &kexec_crash_loaded_attr.attr, 
     236        &kexec_cmdline_attr.attr, 
     237        &kexec_boot_params_attr.attr, 
    76238#endif 
    77239        NULL 
    78240}; 
Note: See TracBrowser for help on using the browser.