qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 08/10] pc-bios/s390-ccw: Add core files for t


From: Thomas Huth
Subject: Re: [Qemu-devel] [PATCH v3 08/10] pc-bios/s390-ccw: Add core files for the network bootloading program
Date: Tue, 11 Jul 2017 15:30:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0

On 11.07.2017 10:52, Cornelia Huck wrote:
> On Mon, 10 Jul 2017 17:32:38 +0200
> Thomas Huth <address@hidden> wrote:
> 
>> This is just a preparation for the next steps: Add a makefile and a
>> stripped down copy of pc-bios/s390-ccw/main.c as a basis for the network
>> bootloader program, linked against the libc from SLOF already (which we
>> will need for SLOF's libnet). The networking code is not included yet.
>>
>> Signed-off-by: Thomas Huth <address@hidden>
>> ---
>>  pc-bios/s390-ccw/Makefile    |  11 +++-
>>  pc-bios/s390-ccw/netboot.mak |  41 +++++++++++++
>>  pc-bios/s390-ccw/netmain.c   | 140 
>> +++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 190 insertions(+), 2 deletions(-)
>>  create mode 100644 pc-bios/s390-ccw/netboot.mak
>>  create mode 100644 pc-bios/s390-ccw/netmain.c
>>
> 
>> diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
>> new file mode 100644
>> index 0000000..fcdd7a1
>> --- /dev/null
>> +++ b/pc-bios/s390-ccw/netmain.c
>> @@ -0,0 +1,140 @@
>> +/*
>> + * S390 virtio-ccw network boot loading program
>> + *
>> + * Copyright 2017 Thomas Huth, Red Hat Inc.
>> + *
>> + * Based on the S390 virtio-ccw loading program (main.c)
>> + * Copyright (c) 2013 Alexander Graf <address@hidden>
>> + *
>> + * This code is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU General Public License as published by the
>> + * Free Software Foundation; either version 2 of the License, or (at your
>> + * option) any later version.
>> + */
>> +
>> +#include <stdint.h>
>> +#include <stdbool.h>
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +#include <string.h>
>> +#include <unistd.h>
>> +#include <time.h>
>> +
>> +#include "s390-ccw.h"
>> +#include "virtio.h"
>> +
>> +extern char _start[];
>> +
>> +char stack[PAGE_SIZE * 8] __attribute__((aligned(PAGE_SIZE)));
>> +IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE)));
>> +
>> +static SubChannelId blk_schid = { .one = 1 };
> 
> Call that net_schid instead? ;)

Yes, makes sense.

>> +static uint64_t dest_timer;
>> +
>> +static uint64_t get_timer_ms(void)
>> +{
>> +    uint64_t clk;
>> +
>> +    asm volatile(" stck %0 " : : "Q"(clk) : "memory");
>> +
>> +    /* Bit 51 is incrememented each microsecond */
>> +    return (clk >> (63 - 51)) / 1000;
>> +}
>> +
>> +void set_timer(int val)
>> +{
>> +    dest_timer = get_timer_ms() + val;
>> +}
>> +
>> +int get_timer(void)
>> +{
>> +    return dest_timer - get_timer_ms();
>> +}
>> +
>> +int get_sec_ticks(void)
>> +{
>> +    return 1000;    /* number of ticks in 1 second */
>> +}
>> +
>> +void panic(const char *string)
>> +{
>> +    sclp_print(string);
>> +    for (;;) {
>> +        disabled_wait();
>> +    }
>> +}
>> +
>> +static bool find_dev(Schib *schib, int dev_no)
>> +{
>> +    int i, r;
>> +
>> +    for (i = 0; i < 0x10000; i++) {
>> +        blk_schid.sch_no = i;
>> +        r = stsch_err(blk_schid, schib);
>> +        if (r == 3 || r == -EIO) {
>> +            break;
>> +        }
>> +        if (!schib->pmcw.dnv) {
>> +            continue;
>> +        }
>> +        if (!virtio_is_supported(blk_schid)) {
>> +            continue;
>> +        }
>> +        /* Skip net devices since no IPLB is created and therefore no
>> +         * no network bootloader has been loaded
>> +         */
>> +        if (virtio_get_device_type() == VIRTIO_ID_NET && dev_no < 0) {
>> +            continue;
> 
> Don't you explicitly want to find net devices here? Confused.

Copy-n-paste left-over. It worked by accident since dev_no was not
negative in my tests, but that piece of code should look different in
netmain.c, of course...

I'll send a v4 ...

 Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]